head.S 3.5 KB

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