head.S 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. * linux/arch/m32r/boot/compressed/head.S
  3. *
  4. * Copyright (c) 2001-2003 Hiroyuki Kondo, Hirokazu Takata,
  5. * Hitoshi Yamamoto, Takeo Takahashi
  6. * Copyright (c) 2004 Hirokazu Takata
  7. */
  8. .text
  9. #include <linux/config.h>
  10. #include <linux/linkage.h>
  11. #include <asm/addrspace.h>
  12. #include <asm/page.h>
  13. #include <asm/assembler.h>
  14. /*
  15. * This code can be loaded anywhere, as long as output will not
  16. * overlap it.
  17. *
  18. * NOTE: This head.S should *NOT* be compiled with -fpic.
  19. *
  20. */
  21. .global startup
  22. .global __bss_start, _ebss, end, zimage_data, zimage_len
  23. __ALIGN
  24. startup:
  25. ldi r0, #0x0000 /* SPI, disable EI */
  26. mvtc r0, psw
  27. ldi r12, #-8
  28. bl 1f
  29. .fillinsn
  30. 1:
  31. seth r1, #high(CONFIG_MEMORY_START + 0x00400000) /* Start address */
  32. add r12, r14 /* Real address */
  33. sub r12, r1 /* difference */
  34. .global got_len
  35. seth r3, #high(_GLOBAL_OFFSET_TABLE_+8)
  36. or3 r3, r3, #low(_GLOBAL_OFFSET_TABLE_+12)
  37. add r3, r14
  38. /* Update the contents of global offset table */
  39. ldi r1, #low(got_len)
  40. srli r1, #2
  41. beqz r1, 2f
  42. .fillinsn
  43. 1:
  44. ld r2, @r3
  45. add r2, r12
  46. st r2, @r3
  47. addi r3, #4
  48. addi r1, #-1
  49. bnez r1, 1b
  50. .fillinsn
  51. 2:
  52. /* XXX: resolve plt */
  53. /*
  54. * Clear BSS first so that there are no surprises...
  55. */
  56. #ifdef CONFIG_ISA_DUAL_ISSUE
  57. seth r2, #high(__bss_start)
  58. or3 r2, r2, #low(__bss_start)
  59. add r2, r12
  60. seth r3, #high(_ebss)
  61. or3 r3, r3, #low(_ebss)
  62. add r3, r12
  63. sub r3, r2
  64. ; R4 = BSS size in longwords (rounded down)
  65. mv r4, r3 || ldi r1, #0
  66. srli r4, #4 || addi r2, #-4
  67. beqz r4, .Lendloop1
  68. .Lloop1:
  69. #ifndef CONFIG_CHIP_M32310
  70. ; Touch memory for the no-write-allocating cache.
  71. ld r0, @(4,r2)
  72. #endif
  73. st r1, @+r2 || addi r4, #-1
  74. st r1, @+r2
  75. st r1, @+r2
  76. st r1, @+r2 || cmpeq r1, r4 ; R4 = 0?
  77. bnc .Lloop1
  78. .Lendloop1:
  79. and3 r4, r3, #15
  80. addi r2, #4
  81. beqz r4, .Lendloop2
  82. .Lloop2:
  83. stb r1, @r2 || addi r4, #-1
  84. addi r2, #1
  85. bnez r4, .Lloop2
  86. .Lendloop2:
  87. #else /* not CONFIG_ISA_DUAL_ISSUE */
  88. seth r2, #high(__bss_start)
  89. or3 r2, r2, #low(__bss_start)
  90. add r2, r12
  91. seth r3, #high(_ebss)
  92. or3 r3, r3, #low(_ebss)
  93. add r3, r12
  94. sub r3, r2
  95. mv r4, r3
  96. srli r4, #2 ; R4 = BSS size in longwords (rounded down)
  97. ldi r1, #0 ; clear R1 for longwords store
  98. addi r2, #-4 ; account for pre-inc store
  99. beqz r4, .Lendloop1 ; any more to go?
  100. .Lloop1:
  101. st r1, @+r2 ; yep, zero out another longword
  102. addi r4, #-1 ; decrement count
  103. bnez r4, .Lloop1 ; go do some more
  104. .Lendloop1:
  105. #endif /* not CONFIG_ISA_DUAL_ISSUE */
  106. seth r1, #high(end)
  107. or3 r1, r1, #low(end)
  108. add r1, r12
  109. mv sp, r1
  110. /*
  111. * decompress the kernel
  112. */
  113. mv r0, sp
  114. srli r0, 31 /* MMU is ON or OFF */
  115. seth r1, #high(zimage_data)
  116. or3 r1, r1, #low(zimage_data)
  117. add r1, r12
  118. seth r2, #high(zimage_len)
  119. or3 r2, r2, #low(zimage_len)
  120. mv r3, sp
  121. bl decompress_kernel
  122. #if defined(CONFIG_CHIP_M32700) || defined(CONFIG_CHIP_OPSP) || defined(CONFIG_CHIP_VDEC2)
  123. /* Cache flush */
  124. ldi r0, -1
  125. ldi r1, 0xd0 ; invalidate i-cache, copy back d-cache
  126. stb r1, @r0
  127. #elif defined(CONFIG_CHIP_M32102)
  128. /* Cache flush */
  129. ldi r0, -2
  130. ldi r1, 0x0100 ; invalidate
  131. stb r1, @r0
  132. #else
  133. #error "put your cache flush function, please"
  134. #endif
  135. mv r0, sp
  136. srli r0, 31 /* MMU is ON or OFF */
  137. slli r0, 31
  138. or3 r0, r0, #0x2000
  139. seth r1, #high(CONFIG_MEMORY_START)
  140. or r0, r1
  141. jmp r0
  142. .balign 512
  143. fake_headers_as_bzImage:
  144. .short 0
  145. .ascii "HdrS"
  146. .short 0x0202
  147. .short 0
  148. .short 0
  149. .byte 0x00, 0x10
  150. .short 0
  151. .byte 0
  152. .byte 1
  153. .byte 0x00, 0x80
  154. .long 0
  155. .long 0