head_44x.S 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. /*
  2. * Kernel execution entry point code.
  3. *
  4. * Copyright (c) 1995-1996 Gary Thomas <gdt@linuxppc.org>
  5. * Initial PowerPC version.
  6. * Copyright (c) 1996 Cort Dougan <cort@cs.nmt.edu>
  7. * Rewritten for PReP
  8. * Copyright (c) 1996 Paul Mackerras <paulus@cs.anu.edu.au>
  9. * Low-level exception handers, MMU support, and rewrite.
  10. * Copyright (c) 1997 Dan Malek <dmalek@jlc.net>
  11. * PowerPC 8xx modifications.
  12. * Copyright (c) 1998-1999 TiVo, Inc.
  13. * PowerPC 403GCX modifications.
  14. * Copyright (c) 1999 Grant Erickson <grant@lcse.umn.edu>
  15. * PowerPC 403GCX/405GP modifications.
  16. * Copyright 2000 MontaVista Software Inc.
  17. * PPC405 modifications
  18. * PowerPC 403GCX/405GP modifications.
  19. * Author: MontaVista Software, Inc.
  20. * frank_rowand@mvista.com or source@mvista.com
  21. * debbie_chu@mvista.com
  22. * Copyright 2002-2005 MontaVista Software, Inc.
  23. * PowerPC 44x support, Matt Porter <mporter@kernel.crashing.org>
  24. *
  25. * This program is free software; you can redistribute it and/or modify it
  26. * under the terms of the GNU General Public License as published by the
  27. * Free Software Foundation; either version 2 of the License, or (at your
  28. * option) any later version.
  29. */
  30. #include <linux/init.h>
  31. #include <asm/processor.h>
  32. #include <asm/page.h>
  33. #include <asm/mmu.h>
  34. #include <asm/pgtable.h>
  35. #include <asm/cputable.h>
  36. #include <asm/thread_info.h>
  37. #include <asm/ppc_asm.h>
  38. #include <asm/asm-offsets.h>
  39. #include "head_booke.h"
  40. /* As with the other PowerPC ports, it is expected that when code
  41. * execution begins here, the following registers contain valid, yet
  42. * optional, information:
  43. *
  44. * r3 - Board info structure pointer (DRAM, frequency, MAC address, etc.)
  45. * r4 - Starting address of the init RAM disk
  46. * r5 - Ending address of the init RAM disk
  47. * r6 - Start of kernel command line string (e.g. "mem=128")
  48. * r7 - End of kernel command line string
  49. *
  50. */
  51. __HEAD
  52. _ENTRY(_stext);
  53. _ENTRY(_start);
  54. /*
  55. * Reserve a word at a fixed location to store the address
  56. * of abatron_pteptrs
  57. */
  58. nop
  59. /*
  60. * Save parameters we are passed
  61. */
  62. mr r31,r3
  63. mr r30,r4
  64. mr r29,r5
  65. mr r28,r6
  66. mr r27,r7
  67. li r24,0 /* CPU number */
  68. /*
  69. * In case the firmware didn't do it, we apply some workarounds
  70. * that are good for all 440 core variants here
  71. */
  72. mfspr r3,SPRN_CCR0
  73. rlwinm r3,r3,0,0,27 /* disable icache prefetch */
  74. isync
  75. mtspr SPRN_CCR0,r3
  76. isync
  77. sync
  78. /*
  79. * Set up the initial MMU state
  80. *
  81. * We are still executing code at the virtual address
  82. * mappings set by the firmware for the base of RAM.
  83. *
  84. * We first invalidate all TLB entries but the one
  85. * we are running from. We then load the KERNELBASE
  86. * mappings so we can begin to use kernel addresses
  87. * natively and so the interrupt vector locations are
  88. * permanently pinned (necessary since Book E
  89. * implementations always have translation enabled).
  90. *
  91. * TODO: Use the known TLB entry we are running from to
  92. * determine which physical region we are located
  93. * in. This can be used to determine where in RAM
  94. * (on a shared CPU system) or PCI memory space
  95. * (on a DRAMless system) we are located.
  96. * For now, we assume a perfect world which means
  97. * we are located at the base of DRAM (physical 0).
  98. */
  99. /*
  100. * Search TLB for entry that we are currently using.
  101. * Invalidate all entries but the one we are using.
  102. */
  103. /* Load our current PID->MMUCR TID and MSR IS->MMUCR STS */
  104. mfspr r3,SPRN_PID /* Get PID */
  105. mfmsr r4 /* Get MSR */
  106. andi. r4,r4,MSR_IS@l /* TS=1? */
  107. beq wmmucr /* If not, leave STS=0 */
  108. oris r3,r3,PPC44x_MMUCR_STS@h /* Set STS=1 */
  109. wmmucr: mtspr SPRN_MMUCR,r3 /* Put MMUCR */
  110. sync
  111. bl invstr /* Find our address */
  112. invstr: mflr r5 /* Make it accessible */
  113. tlbsx r23,0,r5 /* Find entry we are in */
  114. li r4,0 /* Start at TLB entry 0 */
  115. li r3,0 /* Set PAGEID inval value */
  116. 1: cmpw r23,r4 /* Is this our entry? */
  117. beq skpinv /* If so, skip the inval */
  118. tlbwe r3,r4,PPC44x_TLB_PAGEID /* If not, inval the entry */
  119. skpinv: addi r4,r4,1 /* Increment */
  120. cmpwi r4,64 /* Are we done? */
  121. bne 1b /* If not, repeat */
  122. isync /* If so, context change */
  123. /*
  124. * Configure and load pinned entry into TLB slot 63.
  125. */
  126. lis r3,PAGE_OFFSET@h
  127. ori r3,r3,PAGE_OFFSET@l
  128. /* Kernel is at the base of RAM */
  129. li r4, 0 /* Load the kernel physical address */
  130. /* Load the kernel PID = 0 */
  131. li r0,0
  132. mtspr SPRN_PID,r0
  133. sync
  134. /* Initialize MMUCR */
  135. li r5,0
  136. mtspr SPRN_MMUCR,r5
  137. sync
  138. /* pageid fields */
  139. clrrwi r3,r3,10 /* Mask off the effective page number */
  140. ori r3,r3,PPC44x_TLB_VALID | PPC44x_TLB_256M
  141. /* xlat fields */
  142. clrrwi r4,r4,10 /* Mask off the real page number */
  143. /* ERPN is 0 for first 4GB page */
  144. /* attrib fields */
  145. /* Added guarded bit to protect against speculative loads/stores */
  146. li r5,0
  147. ori r5,r5,(PPC44x_TLB_SW | PPC44x_TLB_SR | PPC44x_TLB_SX | PPC44x_TLB_G)
  148. li r0,63 /* TLB slot 63 */
  149. tlbwe r3,r0,PPC44x_TLB_PAGEID /* Load the pageid fields */
  150. tlbwe r4,r0,PPC44x_TLB_XLAT /* Load the translation fields */
  151. tlbwe r5,r0,PPC44x_TLB_ATTRIB /* Load the attrib/access fields */
  152. /* Force context change */
  153. mfmsr r0
  154. mtspr SPRN_SRR1, r0
  155. lis r0,3f@h
  156. ori r0,r0,3f@l
  157. mtspr SPRN_SRR0,r0
  158. sync
  159. rfi
  160. /* If necessary, invalidate original entry we used */
  161. 3: cmpwi r23,63
  162. beq 4f
  163. li r6,0
  164. tlbwe r6,r23,PPC44x_TLB_PAGEID
  165. isync
  166. 4:
  167. #ifdef CONFIG_PPC_EARLY_DEBUG_44x
  168. /* Add UART mapping for early debug. */
  169. /* pageid fields */
  170. lis r3,PPC44x_EARLY_DEBUG_VIRTADDR@h
  171. ori r3,r3,PPC44x_TLB_VALID|PPC44x_TLB_TS|PPC44x_TLB_64K
  172. /* xlat fields */
  173. lis r4,CONFIG_PPC_EARLY_DEBUG_44x_PHYSLOW@h
  174. ori r4,r4,CONFIG_PPC_EARLY_DEBUG_44x_PHYSHIGH
  175. /* attrib fields */
  176. li r5,(PPC44x_TLB_SW|PPC44x_TLB_SR|PPC44x_TLB_I|PPC44x_TLB_G)
  177. li r0,62 /* TLB slot 0 */
  178. tlbwe r3,r0,PPC44x_TLB_PAGEID
  179. tlbwe r4,r0,PPC44x_TLB_XLAT
  180. tlbwe r5,r0,PPC44x_TLB_ATTRIB
  181. /* Force context change */
  182. isync
  183. #endif /* CONFIG_PPC_EARLY_DEBUG_44x */
  184. /* Establish the interrupt vector offsets */
  185. SET_IVOR(0, CriticalInput);
  186. SET_IVOR(1, MachineCheck);
  187. SET_IVOR(2, DataStorage);
  188. SET_IVOR(3, InstructionStorage);
  189. SET_IVOR(4, ExternalInput);
  190. SET_IVOR(5, Alignment);
  191. SET_IVOR(6, Program);
  192. SET_IVOR(7, FloatingPointUnavailable);
  193. SET_IVOR(8, SystemCall);
  194. SET_IVOR(9, AuxillaryProcessorUnavailable);
  195. SET_IVOR(10, Decrementer);
  196. SET_IVOR(11, FixedIntervalTimer);
  197. SET_IVOR(12, WatchdogTimer);
  198. SET_IVOR(13, DataTLBError);
  199. SET_IVOR(14, InstructionTLBError);
  200. SET_IVOR(15, DebugCrit);
  201. /* Establish the interrupt vector base */
  202. lis r4,interrupt_base@h /* IVPR only uses the high 16-bits */
  203. mtspr SPRN_IVPR,r4
  204. /*
  205. * This is where the main kernel code starts.
  206. */
  207. /* ptr to current */
  208. lis r2,init_task@h
  209. ori r2,r2,init_task@l
  210. /* ptr to current thread */
  211. addi r4,r2,THREAD /* init task's THREAD */
  212. mtspr SPRN_SPRG3,r4
  213. /* stack */
  214. lis r1,init_thread_union@h
  215. ori r1,r1,init_thread_union@l
  216. li r0,0
  217. stwu r0,THREAD_SIZE-STACK_FRAME_OVERHEAD(r1)
  218. bl early_init
  219. /*
  220. * Decide what sort of machine this is and initialize the MMU.
  221. */
  222. mr r3,r31
  223. mr r4,r30
  224. mr r5,r29
  225. mr r6,r28
  226. mr r7,r27
  227. bl machine_init
  228. bl MMU_init
  229. /* Setup PTE pointers for the Abatron bdiGDB */
  230. lis r6, swapper_pg_dir@h
  231. ori r6, r6, swapper_pg_dir@l
  232. lis r5, abatron_pteptrs@h
  233. ori r5, r5, abatron_pteptrs@l
  234. lis r4, KERNELBASE@h
  235. ori r4, r4, KERNELBASE@l
  236. stw r5, 0(r4) /* Save abatron_pteptrs at a fixed location */
  237. stw r6, 0(r5)
  238. /* Let's move on */
  239. lis r4,start_kernel@h
  240. ori r4,r4,start_kernel@l
  241. lis r3,MSR_KERNEL@h
  242. ori r3,r3,MSR_KERNEL@l
  243. mtspr SPRN_SRR0,r4
  244. mtspr SPRN_SRR1,r3
  245. rfi /* change context and jump to start_kernel */
  246. /*
  247. * Interrupt vector entry code
  248. *
  249. * The Book E MMUs are always on so we don't need to handle
  250. * interrupts in real mode as with previous PPC processors. In
  251. * this case we handle interrupts in the kernel virtual address
  252. * space.
  253. *
  254. * Interrupt vectors are dynamically placed relative to the
  255. * interrupt prefix as determined by the address of interrupt_base.
  256. * The interrupt vectors offsets are programmed using the labels
  257. * for each interrupt vector entry.
  258. *
  259. * Interrupt vectors must be aligned on a 16 byte boundary.
  260. * We align on a 32 byte cache line boundary for good measure.
  261. */
  262. interrupt_base:
  263. /* Critical Input Interrupt */
  264. CRITICAL_EXCEPTION(0x0100, CriticalInput, unknown_exception)
  265. /* Machine Check Interrupt */
  266. CRITICAL_EXCEPTION(0x0200, MachineCheck, machine_check_exception)
  267. MCHECK_EXCEPTION(0x0210, MachineCheckA, machine_check_exception)
  268. /* Data Storage Interrupt */
  269. DATA_STORAGE_EXCEPTION
  270. /* Instruction Storage Interrupt */
  271. INSTRUCTION_STORAGE_EXCEPTION
  272. /* External Input Interrupt */
  273. EXCEPTION(0x0500, ExternalInput, do_IRQ, EXC_XFER_LITE)
  274. /* Alignment Interrupt */
  275. ALIGNMENT_EXCEPTION
  276. /* Program Interrupt */
  277. PROGRAM_EXCEPTION
  278. /* Floating Point Unavailable Interrupt */
  279. #ifdef CONFIG_PPC_FPU
  280. FP_UNAVAILABLE_EXCEPTION
  281. #else
  282. EXCEPTION(0x2010, FloatingPointUnavailable, unknown_exception, EXC_XFER_EE)
  283. #endif
  284. /* System Call Interrupt */
  285. START_EXCEPTION(SystemCall)
  286. NORMAL_EXCEPTION_PROLOG
  287. EXC_XFER_EE_LITE(0x0c00, DoSyscall)
  288. /* Auxillary Processor Unavailable Interrupt */
  289. EXCEPTION(0x2020, AuxillaryProcessorUnavailable, unknown_exception, EXC_XFER_EE)
  290. /* Decrementer Interrupt */
  291. DECREMENTER_EXCEPTION
  292. /* Fixed Internal Timer Interrupt */
  293. /* TODO: Add FIT support */
  294. EXCEPTION(0x1010, FixedIntervalTimer, unknown_exception, EXC_XFER_EE)
  295. /* Watchdog Timer Interrupt */
  296. /* TODO: Add watchdog support */
  297. #ifdef CONFIG_BOOKE_WDT
  298. CRITICAL_EXCEPTION(0x1020, WatchdogTimer, WatchdogException)
  299. #else
  300. CRITICAL_EXCEPTION(0x1020, WatchdogTimer, unknown_exception)
  301. #endif
  302. /* Data TLB Error Interrupt */
  303. START_EXCEPTION(DataTLBError)
  304. mtspr SPRN_SPRG0, r10 /* Save some working registers */
  305. mtspr SPRN_SPRG1, r11
  306. mtspr SPRN_SPRG4W, r12
  307. mtspr SPRN_SPRG5W, r13
  308. mfcr r11
  309. mtspr SPRN_SPRG7W, r11
  310. mfspr r10, SPRN_DEAR /* Get faulting address */
  311. /* If we are faulting a kernel address, we have to use the
  312. * kernel page tables.
  313. */
  314. lis r11, PAGE_OFFSET@h
  315. cmplw r10, r11
  316. blt+ 3f
  317. lis r11, swapper_pg_dir@h
  318. ori r11, r11, swapper_pg_dir@l
  319. mfspr r12,SPRN_MMUCR
  320. rlwinm r12,r12,0,0,23 /* Clear TID */
  321. b 4f
  322. /* Get the PGD for the current thread */
  323. 3:
  324. mfspr r11,SPRN_SPRG3
  325. lwz r11,PGDIR(r11)
  326. /* Load PID into MMUCR TID */
  327. mfspr r12,SPRN_MMUCR
  328. mfspr r13,SPRN_PID /* Get PID */
  329. rlwimi r12,r13,0,24,31 /* Set TID */
  330. 4:
  331. mtspr SPRN_MMUCR,r12
  332. /* Mask of required permission bits. Note that while we
  333. * do copy ESR:ST to _PAGE_RW position as trying to write
  334. * to an RO page is pretty common, we don't do it with
  335. * _PAGE_DIRTY. We could do it, but it's a fairly rare
  336. * event so I'd rather take the overhead when it happens
  337. * rather than adding an instruction here. We should measure
  338. * whether the whole thing is worth it in the first place
  339. * as we could avoid loading SPRN_ESR completely in the first
  340. * place...
  341. *
  342. * TODO: Is it worth doing that mfspr & rlwimi in the first
  343. * place or can we save a couple of instructions here ?
  344. */
  345. mfspr r12,SPRN_ESR
  346. li r13,_PAGE_PRESENT|_PAGE_ACCESSED
  347. rlwimi r13,r12,10,30,30
  348. /* Load the PTE */
  349. /* Compute pgdir/pmd offset */
  350. rlwinm r12, r10, PPC44x_PGD_OFF_SHIFT, PPC44x_PGD_OFF_MASK_BIT, 29
  351. lwzx r11, r12, r11 /* Get pgd/pmd entry */
  352. rlwinm. r12, r11, 0, 0, 20 /* Extract pt base address */
  353. beq 2f /* Bail if no table */
  354. /* Compute pte address */
  355. rlwimi r12, r10, PPC44x_PTE_ADD_SHIFT, PPC44x_PTE_ADD_MASK_BIT, 28
  356. lwz r11, 0(r12) /* Get high word of pte entry */
  357. lwz r12, 4(r12) /* Get low word of pte entry */
  358. lis r10,tlb_44x_index@ha
  359. andc. r13,r13,r12 /* Check permission */
  360. /* Load the next available TLB index */
  361. lwz r13,tlb_44x_index@l(r10)
  362. bne 2f /* Bail if permission mismach */
  363. /* Increment, rollover, and store TLB index */
  364. addi r13,r13,1
  365. /* Compare with watermark (instruction gets patched) */
  366. .globl tlb_44x_patch_hwater_D
  367. tlb_44x_patch_hwater_D:
  368. cmpwi 0,r13,1 /* reserve entries */
  369. ble 5f
  370. li r13,0
  371. 5:
  372. /* Store the next available TLB index */
  373. stw r13,tlb_44x_index@l(r10)
  374. /* Re-load the faulting address */
  375. mfspr r10,SPRN_DEAR
  376. /* Jump to common tlb load */
  377. b finish_tlb_load
  378. 2:
  379. /* The bailout. Restore registers to pre-exception conditions
  380. * and call the heavyweights to help us out.
  381. */
  382. mfspr r11, SPRN_SPRG7R
  383. mtcr r11
  384. mfspr r13, SPRN_SPRG5R
  385. mfspr r12, SPRN_SPRG4R
  386. mfspr r11, SPRN_SPRG1
  387. mfspr r10, SPRN_SPRG0
  388. b DataStorage
  389. /* Instruction TLB Error Interrupt */
  390. /*
  391. * Nearly the same as above, except we get our
  392. * information from different registers and bailout
  393. * to a different point.
  394. */
  395. START_EXCEPTION(InstructionTLBError)
  396. mtspr SPRN_SPRG0, r10 /* Save some working registers */
  397. mtspr SPRN_SPRG1, r11
  398. mtspr SPRN_SPRG4W, r12
  399. mtspr SPRN_SPRG5W, r13
  400. mfcr r11
  401. mtspr SPRN_SPRG7W, r11
  402. mfspr r10, SPRN_SRR0 /* Get faulting address */
  403. /* If we are faulting a kernel address, we have to use the
  404. * kernel page tables.
  405. */
  406. lis r11, PAGE_OFFSET@h
  407. cmplw r10, r11
  408. blt+ 3f
  409. lis r11, swapper_pg_dir@h
  410. ori r11, r11, swapper_pg_dir@l
  411. mfspr r12,SPRN_MMUCR
  412. rlwinm r12,r12,0,0,23 /* Clear TID */
  413. b 4f
  414. /* Get the PGD for the current thread */
  415. 3:
  416. mfspr r11,SPRN_SPRG3
  417. lwz r11,PGDIR(r11)
  418. /* Load PID into MMUCR TID */
  419. mfspr r12,SPRN_MMUCR
  420. mfspr r13,SPRN_PID /* Get PID */
  421. rlwimi r12,r13,0,24,31 /* Set TID */
  422. 4:
  423. mtspr SPRN_MMUCR,r12
  424. /* Make up the required permissions */
  425. li r13,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_HWEXEC
  426. /* Compute pgdir/pmd offset */
  427. rlwinm r12, r10, PPC44x_PGD_OFF_SHIFT, PPC44x_PGD_OFF_MASK_BIT, 29
  428. lwzx r11, r12, r11 /* Get pgd/pmd entry */
  429. rlwinm. r12, r11, 0, 0, 20 /* Extract pt base address */
  430. beq 2f /* Bail if no table */
  431. /* Compute pte address */
  432. rlwimi r12, r10, PPC44x_PTE_ADD_SHIFT, PPC44x_PTE_ADD_MASK_BIT, 28
  433. lwz r11, 0(r12) /* Get high word of pte entry */
  434. lwz r12, 4(r12) /* Get low word of pte entry */
  435. lis r10,tlb_44x_index@ha
  436. andc. r13,r13,r12 /* Check permission */
  437. /* Load the next available TLB index */
  438. lwz r13,tlb_44x_index@l(r10)
  439. bne 2f /* Bail if permission mismach */
  440. /* Increment, rollover, and store TLB index */
  441. addi r13,r13,1
  442. /* Compare with watermark (instruction gets patched) */
  443. .globl tlb_44x_patch_hwater_I
  444. tlb_44x_patch_hwater_I:
  445. cmpwi 0,r13,1 /* reserve entries */
  446. ble 5f
  447. li r13,0
  448. 5:
  449. /* Store the next available TLB index */
  450. stw r13,tlb_44x_index@l(r10)
  451. /* Re-load the faulting address */
  452. mfspr r10,SPRN_SRR0
  453. /* Jump to common TLB load point */
  454. b finish_tlb_load
  455. 2:
  456. /* The bailout. Restore registers to pre-exception conditions
  457. * and call the heavyweights to help us out.
  458. */
  459. mfspr r11, SPRN_SPRG7R
  460. mtcr r11
  461. mfspr r13, SPRN_SPRG5R
  462. mfspr r12, SPRN_SPRG4R
  463. mfspr r11, SPRN_SPRG1
  464. mfspr r10, SPRN_SPRG0
  465. b InstructionStorage
  466. /* Debug Interrupt */
  467. DEBUG_CRIT_EXCEPTION
  468. /*
  469. * Local functions
  470. */
  471. /*
  472. * Both the instruction and data TLB miss get to this
  473. * point to load the TLB.
  474. * r10 - EA of fault
  475. * r11 - PTE high word value
  476. * r12 - PTE low word value
  477. * r13 - TLB index
  478. * MMUCR - loaded with proper value when we get here
  479. * Upon exit, we reload everything and RFI.
  480. */
  481. finish_tlb_load:
  482. /* Combine RPN & ERPN an write WS 0 */
  483. rlwimi r11,r12,0,0,31-PAGE_SHIFT
  484. tlbwe r11,r13,PPC44x_TLB_XLAT
  485. /*
  486. * Create WS1. This is the faulting address (EPN),
  487. * page size, and valid flag.
  488. */
  489. li r11,PPC44x_TLB_VALID | PPC44x_TLBE_SIZE
  490. /* Insert valid and page size */
  491. rlwimi r10,r11,0,PPC44x_PTE_ADD_MASK_BIT,31
  492. tlbwe r10,r13,PPC44x_TLB_PAGEID /* Write PAGEID */
  493. /* And WS 2 */
  494. li r10,0xf85 /* Mask to apply from PTE */
  495. rlwimi r10,r12,29,30,30 /* DIRTY -> SW position */
  496. and r11,r12,r10 /* Mask PTE bits to keep */
  497. andi. r10,r12,_PAGE_USER /* User page ? */
  498. beq 1f /* nope, leave U bits empty */
  499. rlwimi r11,r11,3,26,28 /* yes, copy S bits to U */
  500. 1: tlbwe r11,r13,PPC44x_TLB_ATTRIB /* Write ATTRIB */
  501. /* Done...restore registers and get out of here.
  502. */
  503. mfspr r11, SPRN_SPRG7R
  504. mtcr r11
  505. mfspr r13, SPRN_SPRG5R
  506. mfspr r12, SPRN_SPRG4R
  507. mfspr r11, SPRN_SPRG1
  508. mfspr r10, SPRN_SPRG0
  509. rfi /* Force context change */
  510. /*
  511. * Global functions
  512. */
  513. /*
  514. * Adjust the machine check IVOR on 440A cores
  515. */
  516. _GLOBAL(__fixup_440A_mcheck)
  517. li r3,MachineCheckA@l
  518. mtspr SPRN_IVOR1,r3
  519. sync
  520. blr
  521. /*
  522. * extern void giveup_altivec(struct task_struct *prev)
  523. *
  524. * The 44x core does not have an AltiVec unit.
  525. */
  526. _GLOBAL(giveup_altivec)
  527. blr
  528. /*
  529. * extern void giveup_fpu(struct task_struct *prev)
  530. *
  531. * The 44x core does not have an FPU.
  532. */
  533. #ifndef CONFIG_PPC_FPU
  534. _GLOBAL(giveup_fpu)
  535. blr
  536. #endif
  537. _GLOBAL(set_context)
  538. #ifdef CONFIG_BDI_SWITCH
  539. /* Context switch the PTE pointer for the Abatron BDI2000.
  540. * The PGDIR is the second parameter.
  541. */
  542. lis r5, abatron_pteptrs@h
  543. ori r5, r5, abatron_pteptrs@l
  544. stw r4, 0x4(r5)
  545. #endif
  546. mtspr SPRN_PID,r3
  547. isync /* Force context change */
  548. blr
  549. /*
  550. * We put a few things here that have to be page-aligned. This stuff
  551. * goes at the beginning of the data segment, which is page-aligned.
  552. */
  553. .data
  554. .align PAGE_SHIFT
  555. .globl sdata
  556. sdata:
  557. .globl empty_zero_page
  558. empty_zero_page:
  559. .space PAGE_SIZE
  560. /*
  561. * To support >32-bit physical addresses, we use an 8KB pgdir.
  562. */
  563. .globl swapper_pg_dir
  564. swapper_pg_dir:
  565. .space PGD_TABLE_SIZE
  566. /*
  567. * Room for two PTE pointers, usually the kernel and current user pointers
  568. * to their respective root page table.
  569. */
  570. abatron_pteptrs:
  571. .space 8