head.S 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. /* Boot entry point for MN10300 kernel
  2. *
  3. * Copyright (C) 2005 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #include <linux/init.h>
  12. #include <linux/threads.h>
  13. #include <linux/linkage.h>
  14. #include <linux/serial_reg.h>
  15. #include <asm/thread_info.h>
  16. #include <asm/page.h>
  17. #include <asm/pgtable.h>
  18. #include <asm/frame.inc>
  19. #include <asm/param.h>
  20. #include <unit/serial.h>
  21. __HEAD
  22. ###############################################################################
  23. #
  24. # bootloader entry point
  25. #
  26. ###############################################################################
  27. .globl _start
  28. .type _start,@function
  29. _start:
  30. # save commandline pointer
  31. mov d0,a3
  32. # preload the PGD pointer register
  33. mov swapper_pg_dir,d0
  34. mov d0,(PTBR)
  35. # turn on the TLBs
  36. mov MMUCTR_IIV|MMUCTR_DIV,d0
  37. mov d0,(MMUCTR)
  38. mov MMUCTR_ITE|MMUCTR_DTE|MMUCTR_CE,d0
  39. mov d0,(MMUCTR)
  40. # turn on AM33v2 exception handling mode and set the trap table base
  41. movhu (CPUP),d0
  42. or CPUP_EXM_AM33V2,d0
  43. movhu d0,(CPUP)
  44. mov CONFIG_INTERRUPT_VECTOR_BASE,d0
  45. mov d0,(TBR)
  46. # invalidate and enable both of the caches
  47. mov CHCTR,a0
  48. clr d0
  49. movhu d0,(a0) # turn off first
  50. mov CHCTR_ICINV|CHCTR_DCINV,d0
  51. movhu d0,(a0)
  52. setlb
  53. mov (a0),d0
  54. btst CHCTR_ICBUSY|CHCTR_DCBUSY,d0 # wait till not busy
  55. lne
  56. #ifndef CONFIG_MN10300_CACHE_DISABLED
  57. #ifdef CONFIG_MN10300_CACHE_WBACK
  58. #ifndef CONFIG_MN10300_CACHE_WBACK_NOWRALLOC
  59. mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRBACK,d0
  60. #else
  61. mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRBACK|CHCTR_DCALMD,d0
  62. #endif /* CACHE_DISABLED */
  63. #else
  64. mov CHCTR_ICEN|CHCTR_DCEN|CHCTR_DCWTMD_WRTHROUGH,d0
  65. #endif /* WBACK */
  66. movhu d0,(a0) # enable
  67. #endif /* NOWRALLOC */
  68. # turn on RTS on the debug serial port if applicable
  69. #ifdef CONFIG_MN10300_UNIT_ASB2305
  70. bset UART_MCR_RTS,(ASB2305_DEBUG_MCR)
  71. #endif
  72. # clear the BSS area
  73. mov __bss_start,a0
  74. mov __bss_stop,a1
  75. clr d0
  76. bssclear:
  77. cmp a1,a0
  78. bge bssclear_end
  79. mov d0,(a0)
  80. inc4 a0
  81. bra bssclear
  82. bssclear_end:
  83. # retrieve the parameters (including command line) before we overwrite
  84. # them
  85. cmp 0xabadcafe,d1
  86. bne __no_parameters
  87. __copy_parameters:
  88. mov redboot_command_line,a0
  89. mov a0,a1
  90. add COMMAND_LINE_SIZE,a1
  91. 1:
  92. movbu (a3),d0
  93. inc a3
  94. movbu d0,(a0)
  95. inc a0
  96. cmp a1,a0
  97. blt 1b
  98. mov redboot_platform_name,a0
  99. mov a0,a1
  100. add COMMAND_LINE_SIZE,a1
  101. mov d2,a3
  102. 1:
  103. movbu (a3),d0
  104. inc a3
  105. movbu d0,(a0)
  106. inc a0
  107. cmp a1,a0
  108. blt 1b
  109. __no_parameters:
  110. # set up the registers with recognisable rubbish in them
  111. mov init_thread_union+THREAD_SIZE-12,sp
  112. mov 0xea01eaea,d0
  113. mov d0,(4,sp) # EPSW save area
  114. mov 0xea02eaea,d0
  115. mov d0,(8,sp) # PC save area
  116. mov 0xeb0060ed,d0
  117. mov d0,mdr
  118. mov 0xeb0061ed,d0
  119. mov d0,mdrq
  120. mov 0xeb0062ed,d0
  121. mov d0,mcrh
  122. mov 0xeb0063ed,d0
  123. mov d0,mcrl
  124. mov 0xeb0064ed,d0
  125. mov d0,mcvf
  126. mov 0xed0065ed,a3
  127. mov a3,usp
  128. mov 0xed00e0ed,e0
  129. mov 0xed00e1ed,e1
  130. mov 0xed00e2ed,e2
  131. mov 0xed00e3ed,e3
  132. mov 0xed00e4ed,e4
  133. mov 0xed00e5ed,e5
  134. mov 0xed00e6ed,e6
  135. mov 0xed00e7ed,e7
  136. mov 0xed00d0ed,d0
  137. mov 0xed00d1ed,d1
  138. mov 0xed00d2ed,d2
  139. mov 0xed00d3ed,d3
  140. mov 0xed00a0ed,a0
  141. mov 0xed00a1ed,a1
  142. mov 0xed00a2ed,a2
  143. mov 0,a3
  144. # set up the initial kernel stack
  145. SAVE_ALL
  146. mov 0xffffffff,d0
  147. mov d0,(REG_ORIG_D0,fp)
  148. # put different recognisable rubbish in the regs
  149. mov 0xfb0060ed,d0
  150. mov d0,mdr
  151. mov 0xfb0061ed,d0
  152. mov d0,mdrq
  153. mov 0xfb0062ed,d0
  154. mov d0,mcrh
  155. mov 0xfb0063ed,d0
  156. mov d0,mcrl
  157. mov 0xfb0064ed,d0
  158. mov d0,mcvf
  159. mov 0xfd0065ed,a0
  160. mov a0,usp
  161. mov 0xfd00e0ed,e0
  162. mov 0xfd00e1ed,e1
  163. mov 0xfd00e2ed,e2
  164. mov 0xfd00e3ed,e3
  165. mov 0xfd00e4ed,e4
  166. mov 0xfd00e5ed,e5
  167. mov 0xfd00e6ed,e6
  168. mov 0xfd00e7ed,e7
  169. mov 0xfd00d0ed,d0
  170. mov 0xfd00d1ed,d1
  171. mov 0xfd00d2ed,d2
  172. mov 0xfd00d3ed,d3
  173. mov 0xfd00a0ed,a0
  174. mov 0xfd00a1ed,a1
  175. mov 0xfd00a2ed,a2
  176. # we may be holding current in E2
  177. #ifdef CONFIG_MN10300_CURRENT_IN_E2
  178. mov init_task,e2
  179. #endif
  180. # initialise the processor and the unit
  181. call processor_init[],0
  182. call unit_init[],0
  183. #ifdef CONFIG_GDBSTUB
  184. call gdbstub_init[],0
  185. #ifdef CONFIG_GDBSTUB_IMMEDIATE
  186. .globl __gdbstub_pause
  187. __gdbstub_pause:
  188. bra __gdbstub_pause
  189. #endif
  190. #endif
  191. jmp start_kernel
  192. .size _start, _start-.
  193. ENTRY(__head_end)
  194. /*
  195. * This is initialized to disallow all access to the low 2G region
  196. * - the high 2G region is managed directly by the MMU
  197. * - range 0x70000000-0x7C000000 are initialised for use by VMALLOC
  198. */
  199. .section .bss
  200. .balign PAGE_SIZE
  201. ENTRY(swapper_pg_dir)
  202. .space PTRS_PER_PGD*4
  203. /*
  204. * The page tables are initialized to only 8MB here - the final page
  205. * tables are set up later depending on memory size.
  206. */
  207. .balign PAGE_SIZE
  208. ENTRY(empty_zero_page)
  209. .space PAGE_SIZE
  210. .balign PAGE_SIZE
  211. ENTRY(empty_bad_page)
  212. .space PAGE_SIZE
  213. .balign PAGE_SIZE
  214. ENTRY(empty_bad_pte_table)
  215. .space PAGE_SIZE
  216. .balign PAGE_SIZE
  217. ENTRY(large_page_table)
  218. .space PAGE_SIZE
  219. .balign PAGE_SIZE
  220. ENTRY(kernel_vmalloc_ptes)
  221. .space ((VMALLOC_END-VMALLOC_START)/PAGE_SIZE)*4