head.S 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320
  1. /* $Id: head.S,v 1.105 2001/08/12 09:08:56 davem Exp $
  2. * head.S: The initial boot code for the Sparc port of Linux.
  3. *
  4. * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  5. * Copyright (C) 1995,1999 Pete Zaitcev (zaitcev@yahoo.com)
  6. * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
  7. * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  8. * Copyright (C) 1997 Michael A. Griffith (grif@acm.org)
  9. *
  10. * CompactPCI platform by Eric Brower, 1999.
  11. */
  12. #include <linux/version.h>
  13. #include <linux/init.h>
  14. #include <asm/head.h>
  15. #include <asm/asi.h>
  16. #include <asm/contregs.h>
  17. #include <asm/ptrace.h>
  18. #include <asm/psr.h>
  19. #include <asm/page.h>
  20. #include <asm/kdebug.h>
  21. #include <asm/winmacro.h>
  22. #include <asm/thread_info.h> /* TI_UWINMASK */
  23. #include <asm/errno.h>
  24. #include <asm/pgtsrmmu.h> /* SRMMU_PGDIR_SHIFT */
  25. .data
  26. /*
  27. * The following are used with the prom_vector node-ops to figure out
  28. * the cpu-type
  29. */
  30. .align 4
  31. .globl cputyp
  32. cputyp:
  33. .word 1
  34. .align 4
  35. .globl cputypval
  36. cputypval:
  37. .asciz "sun4c"
  38. .ascii " "
  39. cputypvalend:
  40. cputypvallen = cputypvar - cputypval
  41. .align 4
  42. /*
  43. * Sun people can't spell worth damn. "compatability" indeed.
  44. * At least we *know* we can't spell, and use a spell-checker.
  45. */
  46. /* Uh, actually Linus it is I who cannot spell. Too much murky
  47. * Sparc assembly will do this to ya.
  48. */
  49. cputypvar:
  50. .asciz "compatability"
  51. /* Tested on SS-5, SS-10. Probably someone at Sun applied a spell-checker. */
  52. .align 4
  53. cputypvar_sun4m:
  54. .asciz "compatible"
  55. .align 4
  56. #ifndef CONFIG_SUN4
  57. sun4_notsup:
  58. .asciz "Sparc-Linux sun4 needs a specially compiled kernel, turn CONFIG_SUN4 on.\n\n"
  59. .align 4
  60. #else
  61. sun4cdm_notsup:
  62. .asciz "Kernel compiled with CONFIG_SUN4 cannot run on SUN4C/SUN4M/SUN4D\nTurn CONFIG_SUN4 off.\n\n"
  63. .align 4
  64. #endif
  65. sun4e_notsup:
  66. .asciz "Sparc-Linux sun4e support does not exist\n\n"
  67. .align 4
  68. /* The Sparc trap table, bootloader gives us control at _start. */
  69. .text
  70. .globl start, _stext, _start, __stext
  71. .globl trapbase
  72. _start: /* danger danger */
  73. __stext:
  74. _stext:
  75. start:
  76. trapbase:
  77. #ifdef CONFIG_SMP
  78. trapbase_cpu0:
  79. #endif
  80. /* We get control passed to us here at t_zero. */
  81. t_zero: b gokernel; nop; nop; nop;
  82. t_tflt: SPARC_TFAULT /* Inst. Access Exception */
  83. t_bins: TRAP_ENTRY(0x2, bad_instruction) /* Illegal Instruction */
  84. t_pins: TRAP_ENTRY(0x3, priv_instruction) /* Privileged Instruction */
  85. t_fpd: TRAP_ENTRY(0x4, fpd_trap_handler) /* Floating Point Disabled */
  86. t_wovf: WINDOW_SPILL /* Window Overflow */
  87. t_wunf: WINDOW_FILL /* Window Underflow */
  88. t_mna: TRAP_ENTRY(0x7, mna_handler) /* Memory Address Not Aligned */
  89. t_fpe: TRAP_ENTRY(0x8, fpe_trap_handler) /* Floating Point Exception */
  90. t_dflt: SPARC_DFAULT /* Data Miss Exception */
  91. t_tio: TRAP_ENTRY(0xa, do_tag_overflow) /* Tagged Instruction Ovrflw */
  92. t_wpt: TRAP_ENTRY(0xb, do_watchpoint) /* Watchpoint Detected */
  93. t_badc: BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
  94. t_irq1: TRAP_ENTRY_INTERRUPT(1) /* IRQ Software/SBUS Level 1 */
  95. t_irq2: TRAP_ENTRY_INTERRUPT(2) /* IRQ SBUS Level 2 */
  96. t_irq3: TRAP_ENTRY_INTERRUPT(3) /* IRQ SCSI/DMA/SBUS Level 3 */
  97. t_irq4: TRAP_ENTRY_INTERRUPT(4) /* IRQ Software Level 4 */
  98. t_irq5: TRAP_ENTRY_INTERRUPT(5) /* IRQ SBUS/Ethernet Level 5 */
  99. t_irq6: TRAP_ENTRY_INTERRUPT(6) /* IRQ Software Level 6 */
  100. t_irq7: TRAP_ENTRY_INTERRUPT(7) /* IRQ Video/SBUS Level 5 */
  101. t_irq8: TRAP_ENTRY_INTERRUPT(8) /* IRQ SBUS Level 6 */
  102. t_irq9: TRAP_ENTRY_INTERRUPT(9) /* IRQ SBUS Level 7 */
  103. t_irq10:TRAP_ENTRY_INTERRUPT(10) /* IRQ Timer #1 (one we use) */
  104. t_irq11:TRAP_ENTRY_INTERRUPT(11) /* IRQ Floppy Intr. */
  105. t_irq12:TRAP_ENTRY_INTERRUPT(12) /* IRQ Zilog serial chip */
  106. t_irq13:TRAP_ENTRY_INTERRUPT(13) /* IRQ Audio Intr. */
  107. t_irq14:TRAP_ENTRY_INTERRUPT(14) /* IRQ Timer #2 */
  108. .globl t_nmi
  109. #ifndef CONFIG_SMP
  110. t_nmi: NMI_TRAP /* Level 15 (NMI) */
  111. #else
  112. t_nmi: TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
  113. #endif
  114. t_racc: TRAP_ENTRY(0x20, do_reg_access) /* General Register Access Error */
  115. t_iacce:BAD_TRAP(0x21) /* Instr Access Error */
  116. t_bad22:BAD_TRAP(0x22) BAD_TRAP(0x23)
  117. t_cpdis:TRAP_ENTRY(0x24, do_cp_disabled) /* Co-Processor Disabled */
  118. t_uflsh:SKIP_TRAP(0x25, unimp_flush) /* Unimplemented FLUSH inst. */
  119. t_bad26:BAD_TRAP(0x26) BAD_TRAP(0x27)
  120. t_cpexc:TRAP_ENTRY(0x28, do_cp_exception) /* Co-Processor Exception */
  121. t_dacce:SPARC_DFAULT /* Data Access Error */
  122. t_hwdz: TRAP_ENTRY(0x2a, do_hw_divzero) /* Division by zero, you lose... */
  123. t_dserr:BAD_TRAP(0x2b) /* Data Store Error */
  124. t_daccm:BAD_TRAP(0x2c) /* Data Access MMU-Miss */
  125. t_bad2d:BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
  126. t_bad32:BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
  127. t_bad37:BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
  128. t_iaccm:BAD_TRAP(0x3c) /* Instr Access MMU-Miss */
  129. t_bad3d:BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40) BAD_TRAP(0x41)
  130. t_bad42:BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45) BAD_TRAP(0x46)
  131. t_bad47:BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a) BAD_TRAP(0x4b)
  132. t_bad4c:BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f) BAD_TRAP(0x50)
  133. t_bad51:BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
  134. t_bad56:BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
  135. t_bad5b:BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
  136. t_bad60:BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
  137. t_bad65:BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
  138. t_bad6a:BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
  139. t_bad6f:BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
  140. t_bad74:BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
  141. t_bad79:BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
  142. t_bad7e:BAD_TRAP(0x7e) BAD_TRAP(0x7f)
  143. t_bad80:BAD_TRAP(0x80) /* SunOS System Call */
  144. t_sbkpt:BREAKPOINT_TRAP /* Software Breakpoint/KGDB */
  145. t_divz: TRAP_ENTRY(0x82, do_hw_divzero) /* Divide by zero trap */
  146. t_flwin:TRAP_ENTRY(0x83, do_flush_windows) /* Flush Windows Trap */
  147. t_clwin:BAD_TRAP(0x84) /* Clean Windows Trap */
  148. t_rchk: BAD_TRAP(0x85) /* Range Check */
  149. t_funal:BAD_TRAP(0x86) /* Fix Unaligned Access Trap */
  150. t_iovf: BAD_TRAP(0x87) /* Integer Overflow Trap */
  151. t_bad88:BAD_TRAP(0x88) /* Slowaris System Call */
  152. t_bad89:BAD_TRAP(0x89) /* Net-B.S. System Call */
  153. t_bad8a:BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c) BAD_TRAP(0x8d) BAD_TRAP(0x8e)
  154. t_bad8f:BAD_TRAP(0x8f)
  155. t_linux:LINUX_SYSCALL_TRAP /* Linux System Call */
  156. t_bad91:BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94) BAD_TRAP(0x95)
  157. t_bad96:BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99) BAD_TRAP(0x9a)
  158. t_bad9b:BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e) BAD_TRAP(0x9f)
  159. t_getcc:GETCC_TRAP /* Get Condition Codes */
  160. t_setcc:SETCC_TRAP /* Set Condition Codes */
  161. t_getpsr:GETPSR_TRAP /* Get PSR Register */
  162. t_bada3:BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
  163. t_bada7:BAD_TRAP(0xa7)
  164. t_bada8:BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
  165. t_badac:BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
  166. t_badb1:BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
  167. t_badb6:BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
  168. t_badbb:BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
  169. t_badc0:BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
  170. t_badc5:BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
  171. t_badca:BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
  172. t_badcf:BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
  173. t_badd4:BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
  174. t_badd9:BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
  175. t_badde:BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
  176. t_bade3:BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
  177. t_bade8:BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
  178. t_baded:BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
  179. t_badf2:BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
  180. t_badf7:BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
  181. t_badfc:BAD_TRAP(0xfc) BAD_TRAP(0xfd)
  182. dbtrap: BAD_TRAP(0xfe) /* Debugger/PROM breakpoint #1 */
  183. dbtrap2:BAD_TRAP(0xff) /* Debugger/PROM breakpoint #2 */
  184. .globl end_traptable
  185. end_traptable:
  186. #ifdef CONFIG_SMP
  187. /* Trap tables for the other cpus. */
  188. .globl trapbase_cpu1, trapbase_cpu2, trapbase_cpu3
  189. trapbase_cpu1:
  190. BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction)
  191. TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler)
  192. WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler)
  193. TRAP_ENTRY(0x8, fpe_trap_handler) SRMMU_DFAULT
  194. TRAP_ENTRY(0xa, do_tag_overflow) TRAP_ENTRY(0xb, do_watchpoint)
  195. BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
  196. TRAP_ENTRY_INTERRUPT(1) TRAP_ENTRY_INTERRUPT(2)
  197. TRAP_ENTRY_INTERRUPT(3) TRAP_ENTRY_INTERRUPT(4)
  198. TRAP_ENTRY_INTERRUPT(5) TRAP_ENTRY_INTERRUPT(6)
  199. TRAP_ENTRY_INTERRUPT(7) TRAP_ENTRY_INTERRUPT(8)
  200. TRAP_ENTRY_INTERRUPT(9) TRAP_ENTRY_INTERRUPT(10)
  201. TRAP_ENTRY_INTERRUPT(11) TRAP_ENTRY_INTERRUPT(12)
  202. TRAP_ENTRY_INTERRUPT(13) TRAP_ENTRY_INTERRUPT(14)
  203. TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
  204. TRAP_ENTRY(0x20, do_reg_access) BAD_TRAP(0x21) BAD_TRAP(0x22)
  205. BAD_TRAP(0x23) TRAP_ENTRY(0x24, do_cp_disabled) SKIP_TRAP(0x25, unimp_flush)
  206. BAD_TRAP(0x26) BAD_TRAP(0x27) TRAP_ENTRY(0x28, do_cp_exception)
  207. SRMMU_DFAULT TRAP_ENTRY(0x2a, do_hw_divzero) BAD_TRAP(0x2b) BAD_TRAP(0x2c)
  208. BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
  209. BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
  210. BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
  211. BAD_TRAP(0x3c) BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40)
  212. BAD_TRAP(0x41) BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45)
  213. BAD_TRAP(0x46) BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a)
  214. BAD_TRAP(0x4b) BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f)
  215. BAD_TRAP(0x50)
  216. BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
  217. BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
  218. BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
  219. BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
  220. BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
  221. BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
  222. BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
  223. BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
  224. BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
  225. BAD_TRAP(0x7e) BAD_TRAP(0x7f)
  226. BAD_TRAP(0x80)
  227. BREAKPOINT_TRAP
  228. TRAP_ENTRY(0x82, do_hw_divzero)
  229. TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
  230. BAD_TRAP(0x86) BAD_TRAP(0x87) BAD_TRAP(0x88)
  231. BAD_TRAP(0x89) BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
  232. BAD_TRAP(0x8d) BAD_TRAP(0x8e) BAD_TRAP(0x8f)
  233. LINUX_SYSCALL_TRAP BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94)
  234. BAD_TRAP(0x95) BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99)
  235. BAD_TRAP(0x9a) BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e)
  236. BAD_TRAP(0x9f) GETCC_TRAP SETCC_TRAP GETPSR_TRAP
  237. BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
  238. BAD_TRAP(0xa7) BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
  239. BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
  240. BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
  241. BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
  242. BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
  243. BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
  244. BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
  245. BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
  246. BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
  247. BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
  248. BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
  249. BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
  250. BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
  251. BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
  252. BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
  253. BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
  254. BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
  255. BAD_TRAP(0xfc) BAD_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
  256. trapbase_cpu2:
  257. BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction)
  258. TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler)
  259. WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler)
  260. TRAP_ENTRY(0x8, fpe_trap_handler) SRMMU_DFAULT
  261. TRAP_ENTRY(0xa, do_tag_overflow) TRAP_ENTRY(0xb, do_watchpoint)
  262. BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
  263. TRAP_ENTRY_INTERRUPT(1) TRAP_ENTRY_INTERRUPT(2)
  264. TRAP_ENTRY_INTERRUPT(3) TRAP_ENTRY_INTERRUPT(4)
  265. TRAP_ENTRY_INTERRUPT(5) TRAP_ENTRY_INTERRUPT(6)
  266. TRAP_ENTRY_INTERRUPT(7) TRAP_ENTRY_INTERRUPT(8)
  267. TRAP_ENTRY_INTERRUPT(9) TRAP_ENTRY_INTERRUPT(10)
  268. TRAP_ENTRY_INTERRUPT(11) TRAP_ENTRY_INTERRUPT(12)
  269. TRAP_ENTRY_INTERRUPT(13) TRAP_ENTRY_INTERRUPT(14)
  270. TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
  271. TRAP_ENTRY(0x20, do_reg_access) BAD_TRAP(0x21) BAD_TRAP(0x22)
  272. BAD_TRAP(0x23) TRAP_ENTRY(0x24, do_cp_disabled) SKIP_TRAP(0x25, unimp_flush)
  273. BAD_TRAP(0x26) BAD_TRAP(0x27) TRAP_ENTRY(0x28, do_cp_exception)
  274. SRMMU_DFAULT TRAP_ENTRY(0x2a, do_hw_divzero) BAD_TRAP(0x2b) BAD_TRAP(0x2c)
  275. BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
  276. BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
  277. BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
  278. BAD_TRAP(0x3c) BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40)
  279. BAD_TRAP(0x41) BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45)
  280. BAD_TRAP(0x46) BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a)
  281. BAD_TRAP(0x4b) BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f)
  282. BAD_TRAP(0x50)
  283. BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
  284. BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
  285. BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
  286. BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
  287. BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
  288. BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
  289. BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
  290. BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
  291. BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
  292. BAD_TRAP(0x7e) BAD_TRAP(0x7f)
  293. BAD_TRAP(0x80)
  294. BREAKPOINT_TRAP
  295. TRAP_ENTRY(0x82, do_hw_divzero)
  296. TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
  297. BAD_TRAP(0x86) BAD_TRAP(0x87) BAD_TRAP(0x88)
  298. BAD_TRAP(0x89) BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
  299. BAD_TRAP(0x8d) BAD_TRAP(0x8e) BAD_TRAP(0x8f)
  300. LINUX_SYSCALL_TRAP BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94)
  301. BAD_TRAP(0x95) BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99)
  302. BAD_TRAP(0x9a) BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e)
  303. BAD_TRAP(0x9f) GETCC_TRAP SETCC_TRAP GETPSR_TRAP
  304. BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
  305. BAD_TRAP(0xa7) BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
  306. BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
  307. BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
  308. BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
  309. BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
  310. BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
  311. BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
  312. BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
  313. BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
  314. BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
  315. BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
  316. BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
  317. BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
  318. BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
  319. BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
  320. BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
  321. BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
  322. BAD_TRAP(0xfc) BAD_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
  323. trapbase_cpu3:
  324. BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction)
  325. TRAP_ENTRY(0x3, priv_instruction) TRAP_ENTRY(0x4, fpd_trap_handler)
  326. WINDOW_SPILL WINDOW_FILL TRAP_ENTRY(0x7, mna_handler)
  327. TRAP_ENTRY(0x8, fpe_trap_handler) SRMMU_DFAULT
  328. TRAP_ENTRY(0xa, do_tag_overflow) TRAP_ENTRY(0xb, do_watchpoint)
  329. BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
  330. TRAP_ENTRY_INTERRUPT(1) TRAP_ENTRY_INTERRUPT(2)
  331. TRAP_ENTRY_INTERRUPT(3) TRAP_ENTRY_INTERRUPT(4)
  332. TRAP_ENTRY_INTERRUPT(5) TRAP_ENTRY_INTERRUPT(6)
  333. TRAP_ENTRY_INTERRUPT(7) TRAP_ENTRY_INTERRUPT(8)
  334. TRAP_ENTRY_INTERRUPT(9) TRAP_ENTRY_INTERRUPT(10)
  335. TRAP_ENTRY_INTERRUPT(11) TRAP_ENTRY_INTERRUPT(12)
  336. TRAP_ENTRY_INTERRUPT(13) TRAP_ENTRY_INTERRUPT(14)
  337. TRAP_ENTRY(0x1f, linux_trap_ipi15_sun4m)
  338. TRAP_ENTRY(0x20, do_reg_access) BAD_TRAP(0x21) BAD_TRAP(0x22)
  339. BAD_TRAP(0x23) TRAP_ENTRY(0x24, do_cp_disabled) SKIP_TRAP(0x25, unimp_flush)
  340. BAD_TRAP(0x26) BAD_TRAP(0x27) TRAP_ENTRY(0x28, do_cp_exception)
  341. SRMMU_DFAULT TRAP_ENTRY(0x2a, do_hw_divzero) BAD_TRAP(0x2b) BAD_TRAP(0x2c)
  342. BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f) BAD_TRAP(0x30) BAD_TRAP(0x31)
  343. BAD_TRAP(0x32) BAD_TRAP(0x33) BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36)
  344. BAD_TRAP(0x37) BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
  345. BAD_TRAP(0x3c) BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f) BAD_TRAP(0x40)
  346. BAD_TRAP(0x41) BAD_TRAP(0x42) BAD_TRAP(0x43) BAD_TRAP(0x44) BAD_TRAP(0x45)
  347. BAD_TRAP(0x46) BAD_TRAP(0x47) BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a)
  348. BAD_TRAP(0x4b) BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f)
  349. BAD_TRAP(0x50)
  350. BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53) BAD_TRAP(0x54) BAD_TRAP(0x55)
  351. BAD_TRAP(0x56) BAD_TRAP(0x57) BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a)
  352. BAD_TRAP(0x5b) BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
  353. BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63) BAD_TRAP(0x64)
  354. BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67) BAD_TRAP(0x68) BAD_TRAP(0x69)
  355. BAD_TRAP(0x6a) BAD_TRAP(0x6b) BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e)
  356. BAD_TRAP(0x6f) BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
  357. BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77) BAD_TRAP(0x78)
  358. BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b) BAD_TRAP(0x7c) BAD_TRAP(0x7d)
  359. BAD_TRAP(0x7e) BAD_TRAP(0x7f)
  360. BAD_TRAP(0x80)
  361. BREAKPOINT_TRAP
  362. TRAP_ENTRY(0x82, do_hw_divzero)
  363. TRAP_ENTRY(0x83, do_flush_windows) BAD_TRAP(0x84) BAD_TRAP(0x85)
  364. BAD_TRAP(0x86) BAD_TRAP(0x87) BAD_TRAP(0x88)
  365. BAD_TRAP(0x89) BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c)
  366. BAD_TRAP(0x8d) BAD_TRAP(0x8e) BAD_TRAP(0x8f)
  367. LINUX_SYSCALL_TRAP BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93) BAD_TRAP(0x94)
  368. BAD_TRAP(0x95) BAD_TRAP(0x96) BAD_TRAP(0x97) BAD_TRAP(0x98) BAD_TRAP(0x99)
  369. BAD_TRAP(0x9a) BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e)
  370. BAD_TRAP(0x9f) GETCC_TRAP SETCC_TRAP GETPSR_TRAP
  371. BAD_TRAP(0xa3) BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
  372. BAD_TRAP(0xa7) BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
  373. BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf) BAD_TRAP(0xb0)
  374. BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3) BAD_TRAP(0xb4) BAD_TRAP(0xb5)
  375. BAD_TRAP(0xb6) BAD_TRAP(0xb7) BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba)
  376. BAD_TRAP(0xbb) BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
  377. BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3) BAD_TRAP(0xc4)
  378. BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7) BAD_TRAP(0xc8) BAD_TRAP(0xc9)
  379. BAD_TRAP(0xca) BAD_TRAP(0xcb) BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce)
  380. BAD_TRAP(0xcf) BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
  381. BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7) BAD_TRAP(0xd8)
  382. BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb) BAD_TRAP(0xdc) BAD_TRAP(0xdd)
  383. BAD_TRAP(0xde) BAD_TRAP(0xdf) BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2)
  384. BAD_TRAP(0xe3) BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
  385. BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xec)
  386. BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
  387. BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
  388. BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
  389. BAD_TRAP(0xfc) BAD_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
  390. #endif
  391. .align PAGE_SIZE
  392. /* This was the only reasonable way I could think of to properly align
  393. * these page-table data structures.
  394. */
  395. .globl pg0, pg1, pg2, pg3
  396. .globl empty_bad_page
  397. .globl empty_bad_page_table
  398. .globl empty_zero_page
  399. .globl swapper_pg_dir
  400. swapper_pg_dir: .skip PAGE_SIZE
  401. pg0: .skip PAGE_SIZE
  402. pg1: .skip PAGE_SIZE
  403. pg2: .skip PAGE_SIZE
  404. pg3: .skip PAGE_SIZE
  405. empty_bad_page: .skip PAGE_SIZE
  406. empty_bad_page_table: .skip PAGE_SIZE
  407. empty_zero_page: .skip PAGE_SIZE
  408. .global root_flags
  409. .global ram_flags
  410. .global root_dev
  411. .global sparc_ramdisk_image
  412. .global sparc_ramdisk_size
  413. /* This stuff has to be in sync with SILO and other potential boot loaders
  414. * Fields should be kept upward compatible and whenever any change is made,
  415. * HdrS version should be incremented.
  416. */
  417. .ascii "HdrS"
  418. .word LINUX_VERSION_CODE
  419. .half 0x0203 /* HdrS version */
  420. root_flags:
  421. .half 1
  422. root_dev:
  423. .half 0
  424. ram_flags:
  425. .half 0
  426. sparc_ramdisk_image:
  427. .word 0
  428. sparc_ramdisk_size:
  429. .word 0
  430. .word reboot_command
  431. .word 0, 0, 0
  432. .word _end
  433. /* Cool, here we go. Pick up the romvec pointer in %o0 and stash it in
  434. * %g7 and at prom_vector_p. And also quickly check whether we are on
  435. * a v0, v2, or v3 prom.
  436. */
  437. gokernel:
  438. /* Ok, it's nice to know, as early as possible, if we
  439. * are already mapped where we expect to be in virtual
  440. * memory. The Solaris /boot elf format bootloader
  441. * will peek into our elf header and load us where
  442. * we want to be, otherwise we have to re-map.
  443. *
  444. * Some boot loaders don't place the jmp'rs address
  445. * in %o7, so we do a pc-relative call to a local
  446. * label, then see what %o7 has.
  447. */
  448. mov %o7, %g4 ! Save %o7
  449. /* Jump to it, and pray... */
  450. current_pc:
  451. call 1f
  452. nop
  453. 1:
  454. mov %o7, %g3
  455. tst %o0
  456. be no_sun4u_here
  457. mov %g4, %o7 /* Previous %o7. */
  458. mov %o0, %l0 ! stash away romvec
  459. mov %o0, %g7 ! put it here too
  460. mov %o1, %l1 ! stash away debug_vec too
  461. /* Ok, let's check out our run time program counter. */
  462. set current_pc, %g5
  463. cmp %g3, %g5
  464. be already_mapped
  465. nop
  466. /* %l6 will hold the offset we have to subtract
  467. * from absolute symbols in order to access areas
  468. * in our own image. If already mapped this is
  469. * just plain zero, else it is KERNBASE.
  470. */
  471. set KERNBASE, %l6
  472. b copy_prom_lvl14
  473. nop
  474. already_mapped:
  475. mov 0, %l6
  476. /* Copy over the Prom's level 14 clock handler. */
  477. copy_prom_lvl14:
  478. #if 1
  479. /* DJHR
  480. * preserve our linked/calculated instructions
  481. */
  482. set lvl14_save, %g1
  483. set t_irq14, %g3
  484. sub %g1, %l6, %g1 ! translate to physical
  485. sub %g3, %l6, %g3 ! translate to physical
  486. ldd [%g3], %g4
  487. std %g4, [%g1]
  488. ldd [%g3+8], %g4
  489. std %g4, [%g1+8]
  490. #endif
  491. rd %tbr, %g1
  492. andn %g1, 0xfff, %g1 ! proms trap table base
  493. or %g0, (0x1e<<4), %g2 ! offset to lvl14 intr
  494. or %g1, %g2, %g2
  495. set t_irq14, %g3
  496. sub %g3, %l6, %g3
  497. ldd [%g2], %g4
  498. std %g4, [%g3]
  499. ldd [%g2 + 0x8], %g4
  500. std %g4, [%g3 + 0x8] ! Copy proms handler
  501. /* Must determine whether we are on a sun4c MMU, SRMMU, or SUN4/400 MUTANT
  502. * MMU so we can remap ourselves properly. DON'T TOUCH %l0 thru %l5 in these
  503. * remapping routines, we need their values afterwards!
  504. */
  505. /* Now check whether we are already mapped, if we
  506. * are we can skip all this garbage coming up.
  507. */
  508. copy_prom_done:
  509. cmp %l6, 0
  510. be go_to_highmem ! this will be a nop then
  511. nop
  512. set LOAD_ADDR, %g6
  513. cmp %g7, %g6
  514. bne remap_not_a_sun4 ! This is not a Sun4
  515. nop
  516. or %g0, 0x1, %g1
  517. lduba [%g1] ASI_CONTROL, %g1 ! Only safe to try on Sun4.
  518. subcc %g1, 0x24, %g0 ! Is this a mutant Sun4/400???
  519. be sun4_mutant_remap ! Ugh, it is...
  520. nop
  521. b sun4_normal_remap ! regular sun4, 2 level mmu
  522. nop
  523. remap_not_a_sun4:
  524. lda [%g0] ASI_M_MMUREGS, %g1 ! same as ASI_PTE on sun4c
  525. and %g1, 0x1, %g1 ! Test SRMMU Enable bit ;-)
  526. cmp %g1, 0x0
  527. be sun4c_remap ! A sun4c MMU or normal Sun4
  528. nop
  529. srmmu_remap:
  530. /* First, check for a viking (TI) module. */
  531. set 0x40000000, %g2
  532. rd %psr, %g3
  533. and %g2, %g3, %g3
  534. subcc %g3, 0x0, %g0
  535. bz srmmu_nviking
  536. nop
  537. /* Figure out what kind of viking we are on.
  538. * We need to know if we have to play with the
  539. * AC bit and disable traps or not.
  540. */
  541. /* I've only seen MicroSparc's on SparcClassics with this
  542. * bit set.
  543. */
  544. set 0x800, %g2
  545. lda [%g0] ASI_M_MMUREGS, %g3 ! peek in the control reg
  546. and %g2, %g3, %g3
  547. subcc %g3, 0x0, %g0
  548. bnz srmmu_nviking ! is in mbus mode
  549. nop
  550. rd %psr, %g3 ! DO NOT TOUCH %g3
  551. andn %g3, PSR_ET, %g2
  552. wr %g2, 0x0, %psr
  553. WRITE_PAUSE
  554. /* Get context table pointer, then convert to
  555. * a physical address, which is 36 bits.
  556. */
  557. set AC_M_CTPR, %g4
  558. lda [%g4] ASI_M_MMUREGS, %g4
  559. sll %g4, 0x4, %g4 ! We use this below
  560. ! DO NOT TOUCH %g4
  561. /* Set the AC bit in the Viking's MMU control reg. */
  562. lda [%g0] ASI_M_MMUREGS, %g5 ! DO NOT TOUCH %g5
  563. set 0x8000, %g6 ! AC bit mask
  564. or %g5, %g6, %g6 ! Or it in...
  565. sta %g6, [%g0] ASI_M_MMUREGS ! Close your eyes...
  566. /* Grrr, why does it seem like every other load/store
  567. * on the sun4m is in some ASI space...
  568. * Fine with me, let's get the pointer to the level 1
  569. * page table directory and fetch its entry.
  570. */
  571. lda [%g4] ASI_M_BYPASS, %o1 ! This is a level 1 ptr
  572. srl %o1, 0x4, %o1 ! Clear low 4 bits
  573. sll %o1, 0x8, %o1 ! Make physical
  574. /* Ok, pull in the PTD. */
  575. lda [%o1] ASI_M_BYPASS, %o2 ! This is the 0x0 16MB pgd
  576. /* Calculate to KERNBASE entry. */
  577. add %o1, KERNBASE >> (SRMMU_PGDIR_SHIFT - 2), %o3
  578. /* Poke the entry into the calculated address. */
  579. sta %o2, [%o3] ASI_M_BYPASS
  580. /* I don't get it Sun, if you engineered all these
  581. * boot loaders and the PROM (thank you for the debugging
  582. * features btw) why did you not have them load kernel
  583. * images up in high address space, since this is necessary
  584. * for ABI compliance anyways? Does this low-mapping provide
  585. * enhanced interoperability?
  586. *
  587. * "The PROM is the computer."
  588. */
  589. /* Ok, restore the MMU control register we saved in %g5 */
  590. sta %g5, [%g0] ASI_M_MMUREGS ! POW... ouch
  591. /* Turn traps back on. We saved it in %g3 earlier. */
  592. wr %g3, 0x0, %psr ! tick tock, tick tock
  593. /* Now we burn precious CPU cycles due to bad engineering. */
  594. WRITE_PAUSE
  595. /* Wow, all that just to move a 32-bit value from one
  596. * place to another... Jump to high memory.
  597. */
  598. b go_to_highmem
  599. nop
  600. /* This works on viking's in Mbus mode and all
  601. * other MBUS modules. It is virtually the same as
  602. * the above madness sans turning traps off and flipping
  603. * the AC bit.
  604. */
  605. srmmu_nviking:
  606. set AC_M_CTPR, %g1
  607. lda [%g1] ASI_M_MMUREGS, %g1 ! get ctx table ptr
  608. sll %g1, 0x4, %g1 ! make physical addr
  609. lda [%g1] ASI_M_BYPASS, %g1 ! ptr to level 1 pg_table
  610. srl %g1, 0x4, %g1
  611. sll %g1, 0x8, %g1 ! make phys addr for l1 tbl
  612. lda [%g1] ASI_M_BYPASS, %g2 ! get level1 entry for 0x0
  613. add %g1, KERNBASE >> (SRMMU_PGDIR_SHIFT - 2), %g3
  614. sta %g2, [%g3] ASI_M_BYPASS ! place at KERNBASE entry
  615. b go_to_highmem
  616. nop ! wheee....
  617. /* This remaps the kernel on Sun4/4xx machines
  618. * that have the Sun Mutant Three Level MMU.
  619. * It's like a platypus, Sun didn't have the
  620. * SRMMU in conception so they kludged the three
  621. * level logic in the regular Sun4 MMU probably.
  622. *
  623. * Basically, you take each entry in the top level
  624. * directory that maps the low 3MB starting at
  625. * address zero and put the mapping in the KERNBASE
  626. * slots. These top level pgd's are called regmaps.
  627. */
  628. sun4_mutant_remap:
  629. or %g0, %g0, %g3 ! source base
  630. sethi %hi(KERNBASE), %g4 ! destination base
  631. or %g4, %lo(KERNBASE), %g4
  632. sethi %hi(0x300000), %g5
  633. or %g5, %lo(0x300000), %g5 ! upper bound 3MB
  634. or %g0, 0x1, %l6
  635. sll %l6, 24, %l6 ! Regmap mapping size
  636. add %g3, 0x2, %g3 ! Base magic
  637. add %g4, 0x2, %g4 ! Base magic
  638. /* Main remapping loop on Sun4-Mutant-MMU.
  639. * "I am not an animal..." -Famous Mutant Person
  640. */
  641. sun4_mutant_loop:
  642. lduha [%g3] ASI_REGMAP, %g2 ! Get lower entry
  643. stha %g2, [%g4] ASI_REGMAP ! Store in high entry
  644. add %g4, %l6, %g4 ! Move up high memory ptr
  645. subcc %g3, %g5, %g0 ! Reached our limit?
  646. blu sun4_mutant_loop ! Nope, loop again
  647. add %g3, %l6, %g3 ! delay, Move up low ptr
  648. b go_to_highmem ! Jump to high memory.
  649. nop
  650. /* The following is for non-4/4xx sun4 MMU's. */
  651. sun4_normal_remap:
  652. mov 0, %g3 ! source base
  653. set KERNBASE, %g4 ! destination base
  654. set 0x300000, %g5 ! upper bound 3MB
  655. mov 1, %l6
  656. sll %l6, 18, %l6 ! sun4 mmu segmap size
  657. sun4_normal_loop:
  658. lduha [%g3] ASI_SEGMAP, %g6 ! load phys_seg
  659. stha %g6, [%g4] ASI_SEGMAP ! stort new virt mapping
  660. add %g3, %l6, %g3 ! increment source pointer
  661. subcc %g3, %g5, %g0 ! reached limit?
  662. blu sun4_normal_loop ! nope, loop again
  663. add %g4, %l6, %g4 ! delay, increment dest ptr
  664. b go_to_highmem
  665. nop
  666. /* The following works for Sun4c MMU's */
  667. sun4c_remap:
  668. mov 0, %g3 ! source base
  669. set KERNBASE, %g4 ! destination base
  670. set 0x300000, %g5 ! upper bound 3MB
  671. mov 1, %l6
  672. sll %l6, 18, %l6 ! sun4c mmu segmap size
  673. sun4c_remap_loop:
  674. lda [%g3] ASI_SEGMAP, %g6 ! load phys_seg
  675. sta %g6, [%g4] ASI_SEGMAP ! store new virt mapping
  676. add %g3, %l6, %g3 ! Increment source ptr
  677. subcc %g3, %g5, %g0 ! Reached limit?
  678. bl sun4c_remap_loop ! Nope, loop again
  679. add %g4, %l6, %g4 ! delay, Increment dest ptr
  680. /* Now do a non-relative jump so that PC is in high-memory */
  681. go_to_highmem:
  682. set execute_in_high_mem, %g1
  683. jmpl %g1, %g0
  684. nop
  685. /* The code above should be at beginning and we have to take care about
  686. * short jumps, as branching to .text.init section from .text is usually
  687. * impossible */
  688. __INIT
  689. /* Acquire boot time privileged register values, this will help debugging.
  690. * I figure out and store nwindows and nwindowsm1 later on.
  691. */
  692. execute_in_high_mem:
  693. mov %l0, %o0 ! put back romvec
  694. mov %l1, %o1 ! and debug_vec
  695. sethi %hi(prom_vector_p), %g1
  696. st %o0, [%g1 + %lo(prom_vector_p)]
  697. sethi %hi(linux_dbvec), %g1
  698. st %o1, [%g1 + %lo(linux_dbvec)]
  699. ld [%o0 + 0x4], %o3
  700. and %o3, 0x3, %o5 ! get the version
  701. cmp %o3, 0x2 ! a v2 prom?
  702. be found_version
  703. nop
  704. /* paul@sfe.com.au */
  705. cmp %o3, 0x3 ! a v3 prom?
  706. be found_version
  707. nop
  708. /* Old sun4's pass our load address into %o0 instead of the prom
  709. * pointer. On sun4's you have to hard code the romvec pointer into
  710. * your code. Sun probably still does that because they don't even
  711. * trust their own "OpenBoot" specifications.
  712. */
  713. set LOAD_ADDR, %g6
  714. cmp %o0, %g6 ! an old sun4?
  715. be sun4_init
  716. nop
  717. found_version:
  718. #ifdef CONFIG_SUN4
  719. /* For people who try sun4 kernels, even if Configure.help advises them. */
  720. ld [%g7 + 0x68], %o1
  721. set sun4cdm_notsup, %o0
  722. call %o1
  723. nop
  724. b halt_me
  725. nop
  726. #endif
  727. /* Get the machine type via the mysterious romvec node operations. */
  728. add %g7, 0x1c, %l1
  729. ld [%l1], %l0
  730. ld [%l0], %l0
  731. call %l0
  732. or %g0, %g0, %o0 ! next_node(0) = first_node
  733. or %o0, %g0, %g6
  734. sethi %hi(cputypvar), %o1 ! First node has cpu-arch
  735. or %o1, %lo(cputypvar), %o1
  736. sethi %hi(cputypval), %o2 ! information, the string
  737. or %o2, %lo(cputypval), %o2
  738. ld [%l1], %l0 ! 'compatibility' tells
  739. ld [%l0 + 0xc], %l0 ! that we want 'sun4x' where
  740. call %l0 ! x is one of '', 'c', 'm',
  741. nop ! 'd' or 'e'. %o2 holds pointer
  742. ! to a buf where above string
  743. ! will get stored by the prom.
  744. subcc %o0, %g0, %g0
  745. bpos got_prop ! Got the property
  746. nop
  747. or %g6, %g0, %o0
  748. sethi %hi(cputypvar_sun4m), %o1
  749. or %o1, %lo(cputypvar_sun4m), %o1
  750. sethi %hi(cputypval), %o2
  751. or %o2, %lo(cputypval), %o2
  752. ld [%l1], %l0
  753. ld [%l0 + 0xc], %l0
  754. call %l0
  755. nop
  756. got_prop:
  757. set cputypval, %o2
  758. ldub [%o2 + 0x4], %l1
  759. cmp %l1, ' '
  760. be 1f
  761. cmp %l1, 'c'
  762. be 1f
  763. cmp %l1, 'm'
  764. be 1f
  765. cmp %l1, 's'
  766. be 1f
  767. cmp %l1, 'd'
  768. be 1f
  769. cmp %l1, 'e'
  770. be no_sun4e_here ! Could be a sun4e.
  771. nop
  772. b no_sun4u_here ! AIEEE, a V9 sun4u... Get our BIG BROTHER kernel :))
  773. nop
  774. 1: set cputypval, %l1
  775. ldub [%l1 + 0x4], %l1
  776. cmp %l1, 'm' ! Test for sun4d, sun4e ?
  777. be sun4m_init
  778. cmp %l1, 's' ! Treat sun4s as sun4m
  779. be sun4m_init
  780. cmp %l1, 'd' ! Let us see how the beast will die
  781. be sun4d_init
  782. nop
  783. /* Jump into mmu context zero. */
  784. set AC_CONTEXT, %g1
  785. stba %g0, [%g1] ASI_CONTROL
  786. b sun4c_continue_boot
  787. nop
  788. /* CPUID in bootbus can be found at PA 0xff0140000 */
  789. #define SUN4D_BOOTBUS_CPUID 0xf0140000
  790. sun4d_init:
  791. /* Need to patch call to handler_irq */
  792. set patch_handler_irq, %g4
  793. set sun4d_handler_irq, %g5
  794. sethi %hi(0x40000000), %g3 ! call
  795. sub %g5, %g4, %g5
  796. srl %g5, 2, %g5
  797. or %g5, %g3, %g5
  798. st %g5, [%g4]
  799. #ifdef CONFIG_SMP
  800. /* Get our CPU id out of bootbus */
  801. set SUN4D_BOOTBUS_CPUID, %g3
  802. lduba [%g3] ASI_M_CTL, %g3
  803. and %g3, 0xf8, %g3
  804. srl %g3, 3, %g4
  805. sta %g4, [%g0] ASI_M_VIKING_TMP1
  806. sethi %hi(boot_cpu_id), %g5
  807. stb %g4, [%g5 + %lo(boot_cpu_id)]
  808. sll %g4, 2, %g4
  809. sethi %hi(boot_cpu_id4), %g5
  810. stb %g4, [%g5 + %lo(boot_cpu_id4)]
  811. #endif
  812. /* Fall through to sun4m_init */
  813. sun4m_init:
  814. /* XXX Fucking Cypress... */
  815. lda [%g0] ASI_M_MMUREGS, %g5
  816. srl %g5, 28, %g4
  817. cmp %g4, 1
  818. bne 1f
  819. srl %g5, 24, %g4
  820. and %g4, 0xf, %g4
  821. cmp %g4, 7 /* This would be a HyperSparc. */
  822. bne 2f
  823. nop
  824. 1:
  825. #define PATCH_IT(dst, src) \
  826. set (dst), %g5; \
  827. set (src), %g4; \
  828. ld [%g4], %g3; \
  829. st %g3, [%g5]; \
  830. ld [%g4+0x4], %g3; \
  831. st %g3, [%g5+0x4];
  832. /* Signed multiply. */
  833. PATCH_IT(.mul, .mul_patch)
  834. PATCH_IT(.mul+0x08, .mul_patch+0x08)
  835. /* Signed remainder. */
  836. PATCH_IT(.rem, .rem_patch)
  837. PATCH_IT(.rem+0x08, .rem_patch+0x08)
  838. PATCH_IT(.rem+0x10, .rem_patch+0x10)
  839. PATCH_IT(.rem+0x18, .rem_patch+0x18)
  840. PATCH_IT(.rem+0x20, .rem_patch+0x20)
  841. PATCH_IT(.rem+0x28, .rem_patch+0x28)
  842. /* Signed division. */
  843. PATCH_IT(.div, .div_patch)
  844. PATCH_IT(.div+0x08, .div_patch+0x08)
  845. PATCH_IT(.div+0x10, .div_patch+0x10)
  846. PATCH_IT(.div+0x18, .div_patch+0x18)
  847. PATCH_IT(.div+0x20, .div_patch+0x20)
  848. /* Unsigned multiply. */
  849. PATCH_IT(.umul, .umul_patch)
  850. PATCH_IT(.umul+0x08, .umul_patch+0x08)
  851. /* Unsigned remainder. */
  852. PATCH_IT(.urem, .urem_patch)
  853. PATCH_IT(.urem+0x08, .urem_patch+0x08)
  854. PATCH_IT(.urem+0x10, .urem_patch+0x10)
  855. PATCH_IT(.urem+0x18, .urem_patch+0x18)
  856. /* Unsigned division. */
  857. PATCH_IT(.udiv, .udiv_patch)
  858. PATCH_IT(.udiv+0x08, .udiv_patch+0x08)
  859. PATCH_IT(.udiv+0x10, .udiv_patch+0x10)
  860. #undef PATCH_IT
  861. /* Ok, the PROM could have done funny things and apple cider could still
  862. * be sitting in the fault status/address registers. Read them all to
  863. * clear them so we don't get magic faults later on.
  864. */
  865. /* This sucks, apparently this makes Vikings call prom panic, will fix later */
  866. 2:
  867. rd %psr, %o1
  868. srl %o1, 28, %o1 ! Get a type of the CPU
  869. subcc %o1, 4, %g0 ! TI: Viking or MicroSPARC
  870. be sun4c_continue_boot
  871. nop
  872. set AC_M_SFSR, %o0
  873. lda [%o0] ASI_M_MMUREGS, %g0
  874. set AC_M_SFAR, %o0
  875. lda [%o0] ASI_M_MMUREGS, %g0
  876. /* Fujitsu MicroSPARC-II has no asynchronous flavors of FARs */
  877. subcc %o1, 0, %g0
  878. be sun4c_continue_boot
  879. nop
  880. set AC_M_AFSR, %o0
  881. lda [%o0] ASI_M_MMUREGS, %g0
  882. set AC_M_AFAR, %o0
  883. lda [%o0] ASI_M_MMUREGS, %g0
  884. nop
  885. sun4c_continue_boot:
  886. /* Aieee, now set PC and nPC, enable traps, give ourselves a stack and it's
  887. * show-time!
  888. */
  889. sethi %hi(cputyp), %o0
  890. st %g4, [%o0 + %lo(cputyp)]
  891. /* Turn on Supervisor, EnableFloating, and all the PIL bits.
  892. * Also puts us in register window zero with traps off.
  893. */
  894. set (PSR_PS | PSR_S | PSR_PIL | PSR_EF), %g2
  895. wr %g2, 0x0, %psr
  896. WRITE_PAUSE
  897. /* I want a kernel stack NOW! */
  898. set init_thread_union, %g1
  899. set (THREAD_SIZE - STACKFRAME_SZ), %g2
  900. add %g1, %g2, %sp
  901. mov 0, %fp /* And for good luck */
  902. /* Zero out our BSS section. */
  903. set __bss_start , %o0 ! First address of BSS
  904. set end , %o1 ! Last address of BSS
  905. add %o0, 0x1, %o0
  906. 1:
  907. stb %g0, [%o0]
  908. subcc %o0, %o1, %g0
  909. bl 1b
  910. add %o0, 0x1, %o0
  911. /* Initialize the uwinmask value for init task just in case.
  912. * But first make current_set[boot_cpu_id] point to something useful.
  913. */
  914. set init_thread_union, %g6
  915. set current_set, %g2
  916. #ifdef CONFIG_SMP
  917. sethi %hi(boot_cpu_id4), %g3
  918. ldub [%g3 + %lo(boot_cpu_id4)], %g3
  919. st %g6, [%g2]
  920. add %g2, %g3, %g2
  921. #endif
  922. st %g6, [%g2]
  923. st %g0, [%g6 + TI_UWINMASK]
  924. /* Compute NWINDOWS and stash it away. Now uses %wim trick explained
  925. * in the V8 manual. Ok, this method seems to work, Sparc is cool...
  926. * No, it doesn't work, have to play the save/readCWP/restore trick.
  927. */
  928. wr %g0, 0x0, %wim ! so we do not get a trap
  929. WRITE_PAUSE
  930. save
  931. rd %psr, %g3
  932. restore
  933. and %g3, 0x1f, %g3
  934. add %g3, 0x1, %g3
  935. mov 2, %g1
  936. wr %g1, 0x0, %wim ! make window 1 invalid
  937. WRITE_PAUSE
  938. cmp %g3, 0x7
  939. bne 2f
  940. nop
  941. /* Adjust our window handling routines to
  942. * do things correctly on 7 window Sparcs.
  943. */
  944. #define PATCH_INSN(src, dest) \
  945. set src, %g5; \
  946. set dest, %g2; \
  947. ld [%g5], %g4; \
  948. st %g4, [%g2];
  949. /* Patch for window spills... */
  950. PATCH_INSN(spnwin_patch1_7win, spnwin_patch1)
  951. PATCH_INSN(spnwin_patch2_7win, spnwin_patch2)
  952. PATCH_INSN(spnwin_patch3_7win, spnwin_patch3)
  953. /* Patch for window fills... */
  954. PATCH_INSN(fnwin_patch1_7win, fnwin_patch1)
  955. PATCH_INSN(fnwin_patch2_7win, fnwin_patch2)
  956. /* Patch for trap entry setup... */
  957. PATCH_INSN(tsetup_7win_patch1, tsetup_patch1)
  958. PATCH_INSN(tsetup_7win_patch2, tsetup_patch2)
  959. PATCH_INSN(tsetup_7win_patch3, tsetup_patch3)
  960. PATCH_INSN(tsetup_7win_patch4, tsetup_patch4)
  961. PATCH_INSN(tsetup_7win_patch5, tsetup_patch5)
  962. PATCH_INSN(tsetup_7win_patch6, tsetup_patch6)
  963. /* Patch for returning from traps... */
  964. PATCH_INSN(rtrap_7win_patch1, rtrap_patch1)
  965. PATCH_INSN(rtrap_7win_patch2, rtrap_patch2)
  966. PATCH_INSN(rtrap_7win_patch3, rtrap_patch3)
  967. PATCH_INSN(rtrap_7win_patch4, rtrap_patch4)
  968. PATCH_INSN(rtrap_7win_patch5, rtrap_patch5)
  969. /* Patch for killing user windows from the register file. */
  970. PATCH_INSN(kuw_patch1_7win, kuw_patch1)
  971. /* Now patch the kernel window flush sequences.
  972. * This saves 2 traps on every switch and fork.
  973. */
  974. set 0x01000000, %g4
  975. set flush_patch_one, %g5
  976. st %g4, [%g5 + 0x18]
  977. st %g4, [%g5 + 0x1c]
  978. set flush_patch_two, %g5
  979. st %g4, [%g5 + 0x18]
  980. st %g4, [%g5 + 0x1c]
  981. set flush_patch_three, %g5
  982. st %g4, [%g5 + 0x18]
  983. st %g4, [%g5 + 0x1c]
  984. set flush_patch_four, %g5
  985. st %g4, [%g5 + 0x18]
  986. st %g4, [%g5 + 0x1c]
  987. set flush_patch_exception, %g5
  988. st %g4, [%g5 + 0x18]
  989. st %g4, [%g5 + 0x1c]
  990. set flush_patch_switch, %g5
  991. st %g4, [%g5 + 0x18]
  992. st %g4, [%g5 + 0x1c]
  993. 2:
  994. sethi %hi(nwindows), %g4
  995. st %g3, [%g4 + %lo(nwindows)] ! store final value
  996. sub %g3, 0x1, %g3
  997. sethi %hi(nwindowsm1), %g4
  998. st %g3, [%g4 + %lo(nwindowsm1)]
  999. /* Here we go, start using Linux's trap table... */
  1000. set trapbase, %g3
  1001. wr %g3, 0x0, %tbr
  1002. WRITE_PAUSE
  1003. /* Finally, turn on traps so that we can call c-code. */
  1004. rd %psr, %g3
  1005. wr %g3, 0x0, %psr
  1006. WRITE_PAUSE
  1007. wr %g3, PSR_ET, %psr
  1008. WRITE_PAUSE
  1009. /* First we call prom_init() to set up PROMLIB, then
  1010. * off to start_kernel().
  1011. */
  1012. sethi %hi(prom_vector_p), %g5
  1013. ld [%g5 + %lo(prom_vector_p)], %o0
  1014. call prom_init
  1015. nop
  1016. call start_kernel
  1017. nop
  1018. /* We should not get here. */
  1019. call halt_me
  1020. nop
  1021. sun4_init:
  1022. #ifdef CONFIG_SUN4
  1023. /* There, happy now Adrian? */
  1024. set cputypval, %o2 ! Let everyone know we
  1025. set ' ', %o0 ! are a "sun4 " architecture
  1026. stb %o0, [%o2 + 0x4]
  1027. b got_prop
  1028. nop
  1029. #else
  1030. sethi %hi(SUN4_PROM_VECTOR+0x84), %o1
  1031. ld [%o1 + %lo(SUN4_PROM_VECTOR+0x84)], %o1
  1032. set sun4_notsup, %o0
  1033. call %o1 /* printf */
  1034. nop
  1035. sethi %hi(SUN4_PROM_VECTOR+0xc4), %o1
  1036. ld [%o1 + %lo(SUN4_PROM_VECTOR+0xc4)], %o1
  1037. call %o1 /* exittomon */
  1038. nop
  1039. 1: ba 1b ! Cannot exit into KMON
  1040. nop
  1041. #endif
  1042. no_sun4e_here:
  1043. ld [%g7 + 0x68], %o1
  1044. set sun4e_notsup, %o0
  1045. call %o1
  1046. nop
  1047. b halt_me
  1048. nop
  1049. __INITDATA
  1050. sun4u_1:
  1051. .asciz "finddevice"
  1052. .align 4
  1053. sun4u_2:
  1054. .asciz "/chosen"
  1055. .align 4
  1056. sun4u_3:
  1057. .asciz "getprop"
  1058. .align 4
  1059. sun4u_4:
  1060. .asciz "stdout"
  1061. .align 4
  1062. sun4u_5:
  1063. .asciz "write"
  1064. .align 4
  1065. sun4u_6:
  1066. .asciz "\n\rOn sun4u you have to use UltraLinux (64bit) kernel\n\rand not a 32bit sun4[cdem] version\n\r\n\r"
  1067. sun4u_6e:
  1068. .align 4
  1069. sun4u_7:
  1070. .asciz "exit"
  1071. .align 8
  1072. sun4u_a1:
  1073. .word 0, sun4u_1, 0, 1, 0, 1, 0, sun4u_2, 0
  1074. sun4u_r1:
  1075. .word 0
  1076. sun4u_a2:
  1077. .word 0, sun4u_3, 0, 4, 0, 1, 0
  1078. sun4u_i2:
  1079. .word 0, 0, sun4u_4, 0, sun4u_1, 0, 8, 0
  1080. sun4u_r2:
  1081. .word 0
  1082. sun4u_a3:
  1083. .word 0, sun4u_5, 0, 3, 0, 1, 0
  1084. sun4u_i3:
  1085. .word 0, 0, sun4u_6, 0, sun4u_6e - sun4u_6 - 1, 0
  1086. sun4u_r3:
  1087. .word 0
  1088. sun4u_a4:
  1089. .word 0, sun4u_7, 0, 0, 0, 0
  1090. sun4u_r4:
  1091. __INIT
  1092. no_sun4u_here:
  1093. set sun4u_a1, %o0
  1094. set current_pc, %l2
  1095. cmp %l2, %g3
  1096. be 1f
  1097. mov %o4, %l0
  1098. sub %g3, %l2, %l6
  1099. add %o0, %l6, %o0
  1100. mov %o0, %l4
  1101. mov sun4u_r4 - sun4u_a1, %l3
  1102. ld [%l4], %l5
  1103. 2:
  1104. add %l4, 4, %l4
  1105. cmp %l5, %l2
  1106. add %l5, %l6, %l5
  1107. bgeu,a 3f
  1108. st %l5, [%l4 - 4]
  1109. 3:
  1110. subcc %l3, 4, %l3
  1111. bne 2b
  1112. ld [%l4], %l5
  1113. 1:
  1114. call %l0
  1115. mov %o0, %l1
  1116. ld [%l1 + (sun4u_r1 - sun4u_a1)], %o1
  1117. add %l1, (sun4u_a2 - sun4u_a1), %o0
  1118. call %l0
  1119. st %o1, [%o0 + (sun4u_i2 - sun4u_a2)]
  1120. ld [%l1 + (sun4u_1 - sun4u_a1)], %o1
  1121. add %l1, (sun4u_a3 - sun4u_a1), %o0
  1122. call %l0
  1123. st %o1, [%o0 + (sun4u_i3 - sun4u_a3)]
  1124. call %l0
  1125. add %l1, (sun4u_a4 - sun4u_a1), %o0
  1126. /* Not reached */
  1127. halt_me:
  1128. ld [%g7 + 0x74], %o0
  1129. call %o0 ! Get us out of here...
  1130. nop ! Apparently Solaris is better.
  1131. /* Ok, now we continue in the .data/.text sections */
  1132. .data
  1133. .align 4
  1134. /*
  1135. * Fill up the prom vector, note in particular the kind first element,
  1136. * no joke. I don't need all of them in here as the entire prom vector
  1137. * gets initialized in c-code so all routines can use it.
  1138. */
  1139. .globl prom_vector_p
  1140. prom_vector_p:
  1141. .word 0
  1142. /* We calculate the following at boot time, window fills/spills and trap entry
  1143. * code uses these to keep track of the register windows.
  1144. */
  1145. .align 4
  1146. .globl nwindows
  1147. .globl nwindowsm1
  1148. nwindows:
  1149. .word 8
  1150. nwindowsm1:
  1151. .word 7
  1152. /* Boot time debugger vector value. We need this later on. */
  1153. .align 4
  1154. .globl linux_dbvec
  1155. linux_dbvec:
  1156. .word 0
  1157. .word 0
  1158. .align 8
  1159. .globl lvl14_save
  1160. lvl14_save:
  1161. .word 0
  1162. .word 0
  1163. .word 0
  1164. .word 0
  1165. .word t_irq14
  1166. .section ".fixup",#alloc,#execinstr
  1167. .globl __ret_efault
  1168. __ret_efault:
  1169. ret
  1170. restore %g0, -EFAULT, %o0