1
0

commsup.S 24 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466
  1. /*++
  2. Copyright (c) 2014 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. commsup.S
  5. Abstract:
  6. This module implements assembly-based architecture support routines common
  7. to all ARM platforms.
  8. Author:
  9. Chris Stevens 19-Mar-2014
  10. Environment:
  11. Boot
  12. --*/
  13. ##
  14. ## ------------------------------------------------------------------- Includes
  15. ##
  16. #include <minoca/kernel/arm.inc>
  17. ##
  18. ## ---------------------------------------------------------------- Definitions
  19. ##
  20. ##
  21. ## ---------------------------------------------------------------------- Code
  22. ##
  23. ASSEMBLY_FILE_HEADER
  24. ##
  25. ## VOID
  26. ## BoInitializeExceptionStacks (
  27. ## PVOID ExceptionStacksBase,
  28. ## ULONG ExceptionStackSize
  29. ## )
  30. ##
  31. /*++
  32. Routine Description:
  33. This routine initializes the stack pointer for all privileged ARM modes. It
  34. switches into each mode and initializes the banked r13. This function
  35. should be called with interrupts disabled and returns with interrupts
  36. disabled.
  37. Arguments:
  38. ExceptionStacksBase - Supplies a pointer to the lowest address that should
  39. be used for exception stacks. Each stack takes up 16 bytes and there are
  40. 4 modes, so at least 64 bytes are needed.
  41. ExceptionStackSize - Supplies the size of each exception stack.
  42. Return Value:
  43. None.
  44. --*/
  45. FUNCTION BoInitializeExceptionStacks
  46. ##
  47. ## Load R1 with an individual stack size.
  48. ##
  49. add %r0, %r0, %r1
  50. ##
  51. ## Disable interrupts and switch into IRQ mode. Note that this also
  52. ## clobbers the flags register.
  53. ##
  54. mov %r2, #(PSR_FLAG_IRQ | ARM_MODE_IRQ)
  55. msr CPSR_cxsf, %r2
  56. mov %sp, %r0
  57. add %r0, %r0, %r1
  58. ##
  59. ## Initialize the FIQ stack.
  60. ##
  61. mov %r2, #(PSR_FLAG_IRQ | ARM_MODE_FIQ)
  62. msr CPSR_cxsf, %r2
  63. mov %sp, %r0
  64. add %r0, %r0, %r1
  65. ##
  66. ## Initialize the undefined instruction stack.
  67. ##
  68. mov %r2, #(PSR_FLAG_IRQ | ARM_MODE_UNDEF)
  69. msr CPSR_cxsf, %r2
  70. mov %sp, %r0
  71. add %r0, %r0, %r1
  72. ##
  73. ## Initialize the data fetch abort stack.
  74. ##
  75. mov %r2, #(PSR_FLAG_IRQ | ARM_MODE_ABORT)
  76. msr CPSR_cxsf, %r2
  77. mov %sp, %r0
  78. ##
  79. ## Switch back to SVC mode and return.
  80. ##
  81. mov %r2, #(PSR_FLAG_IRQ | ARM_MODE_SVC)
  82. msr CPSR_cxsf, %r2
  83. bx %lr
  84. END_FUNCTION BoInitializeExceptionStacks
  85. ##
  86. ## BOOL
  87. ## BoDisableInterrupts (
  88. ## VOID
  89. ## )
  90. ##
  91. /*++
  92. Routine Description:
  93. This routine disables all interrupts on the current processor.
  94. Arguments:
  95. None.
  96. Return Value:
  97. TRUE if interrupts were previously enabled on the processor.
  98. FALSE if interrupts were not previously enabled on the processor.
  99. --*/
  100. FUNCTION BoDisableInterrupts
  101. mrs %r1, CPSR @ Get the status register.
  102. cpsid i @ Disable interrupts.
  103. mov %r0, #0 @ Assume interrupts disabled.
  104. tst %r1, #PSR_FLAG_IRQ @ AND the interrupt flag.
  105. IT(eq) @ If the zero flag is set...
  106. moveq %r0, #1 @ Interrupts were enabled.
  107. bx %lr @ Return.
  108. END_FUNCTION BoDisableInterrupts
  109. ##
  110. ## VOID
  111. ## BoEnableInterrupts (
  112. ## VOID
  113. ## )
  114. ##
  115. /*++
  116. Routine Description:
  117. This routine enables interrupts on the current processor.
  118. Arguments:
  119. None.
  120. Return Value:
  121. None.
  122. --*/
  123. FUNCTION BoEnableInterrupts
  124. mrs %r0, CPSR @ Get the status register.
  125. bic %r0, %r0, #PSR_FLAG_IRQ @ Clear the interrupt bits.
  126. msr CPSR_cxsf, %r0 @ Write the status register.
  127. bx %lr @
  128. END_FUNCTION BoEnableInterrupts
  129. ##
  130. ## BOOL
  131. ## BoAreInterruptsEnabled (
  132. ## VOID
  133. ## )
  134. ##
  135. /*++
  136. Routine Description:
  137. This routine determines whether or not interrupts are currently enabled
  138. on the processor.
  139. Arguments:
  140. None.
  141. Return Value:
  142. TRUE if interrupts are enabled in the processor.
  143. FALSE if interrupts are globally disabled.
  144. --*/
  145. FUNCTION BoAreInterruptsEnabled
  146. mrs %r1, CPSR @ Get the status register.
  147. mov %r0, #0 @ Assume interrupts disabled.
  148. tst %r1, #PSR_FLAG_IRQ @ AND the interrupt flag.
  149. IT(eq) @ If the zero flag is set...
  150. moveq %r0, #1 @ Interrupts were enabled.
  151. bx %lr @ Return.
  152. END_FUNCTION BoAreInterruptsEnabled
  153. ##
  154. ## VOID
  155. ## ArSerializeExecution (
  156. ## VOID
  157. ## )
  158. ##
  159. /*++
  160. Routine Description:
  161. This routine acts a serializing instruction, preventing the processor
  162. from speculatively executing beyond this point.
  163. Arguments:
  164. None.
  165. Return Value:
  166. None.
  167. --*/
  168. FUNCTION ArSerializeExecution
  169. DSB
  170. ISB
  171. bx %lr
  172. END_FUNCTION ArSerializeExecution
  173. ##
  174. ## VOID
  175. ## BoUndefinedInstructionEntry (
  176. ## VOID
  177. ## )
  178. ##
  179. /*++
  180. Routine Description:
  181. This routine directly handles an exception generated by an undefined
  182. instruction. It uses a largely separate code path from normal exceptions
  183. to avoid recursively breaking into the debugger.
  184. Arguments:
  185. None.
  186. Return Value:
  187. None.
  188. --*/
  189. FUNCTION BoUndefinedInstructionEntry
  190. ##
  191. ## Save state and create a trap frame.
  192. ##
  193. ARM_ENTER_INTERRUPT
  194. ##
  195. ## Call the main dispatch routine routine with a pointer to the trap frame
  196. ## as the only parameter.
  197. ##
  198. mov %r0, %sp
  199. bl BopDispatchUndefinedInstructionException
  200. ##
  201. ## Restore state and return.
  202. ##
  203. ARM_EXIT_INTERRUPT
  204. END_FUNCTION BoUndefinedInstructionEntry
  205. ##
  206. ## VOID
  207. ## BoSoftwareInterruptEntry (
  208. ## VOID
  209. ## )
  210. ##
  211. /*++
  212. Routine Description:
  213. This routine directly handles an exception generated by a software
  214. interrupt (a system call).
  215. Arguments:
  216. None.
  217. Return Value:
  218. None.
  219. --*/
  220. FUNCTION BoSoftwareInterruptEntry
  221. b BopCommonInterruptEntry @ This is neither expected nor handled.
  222. END_FUNCTION BoSoftwareInterruptEntry
  223. ##
  224. ## VOID
  225. ## BoPrefetchAbortEntry (
  226. ## VOID
  227. ## )
  228. ##
  229. /*++
  230. Routine Description:
  231. This routine directly handles an exception generated by a prefetch abort
  232. (page fault).
  233. Arguments:
  234. None.
  235. Return Value:
  236. None.
  237. --*/
  238. FUNCTION BoPrefetchAbortEntry
  239. sub %lr, %lr, #4 @ Prefetches go too far by 4.
  240. ##
  241. ## Save state and create a trap frame.
  242. ##
  243. ARM_ENTER_INTERRUPT
  244. ##
  245. ## Call the main dispatch routine routine with a pointer to the trap frame
  246. ## and 1 to indicate a prefetch abort.
  247. ##
  248. mov %r0, %sp
  249. mov %r1, #1
  250. blx BopDispatchException
  251. ##
  252. ## Restore state and return.
  253. ##
  254. ARM_EXIT_INTERRUPT
  255. END_FUNCTION BoPrefetchAbortEntry
  256. ##
  257. ## VOID
  258. ## BoDataAbortEntry (
  259. ## VOID
  260. ## )
  261. ##
  262. /*++
  263. Routine Description:
  264. This routine directly handles an exception generated by a data abort (page
  265. fault).
  266. Arguments:
  267. None.
  268. Return Value:
  269. None.
  270. --*/
  271. FUNCTION BoDataAbortEntry
  272. sub %lr, %lr, #8 @ Data aborts go too far by 8.
  273. ##
  274. ## Save state and create a trap frame.
  275. ##
  276. ARM_ENTER_INTERRUPT
  277. ##
  278. ## Call the main dispatch routine routine with a pointer to the trap frame
  279. ## and 0 to indicate a prefetch abort.
  280. ##
  281. mov %r0, %sp
  282. mov %r1, #0
  283. blx BopDispatchException
  284. ##
  285. ## Restore state and return.
  286. ##
  287. ARM_EXIT_INTERRUPT
  288. END_FUNCTION BoDataAbortEntry
  289. ##
  290. ## VOID
  291. ## BoIrqEntry (
  292. ## VOID
  293. ## )
  294. ##
  295. /*++
  296. Routine Description:
  297. This routine directly handles an exception generated by an external
  298. interrupt on the IRQ pin.
  299. Arguments:
  300. None.
  301. Return Value:
  302. None.
  303. --*/
  304. FUNCTION BoIrqEntry
  305. b BopCommonInterruptEntry
  306. END_FUNCTION BoIrqEntry
  307. ##
  308. ## VOID
  309. ## BoFiqEntry (
  310. ## VOID
  311. ## )
  312. ##
  313. /*++
  314. Routine Description:
  315. This routine directly handles an exception generated by an external
  316. interrupt on the FIQ pin.
  317. Arguments:
  318. None.
  319. Return Value:
  320. None.
  321. --*/
  322. FUNCTION BoFiqEntry
  323. b BopCommonInterruptEntry
  324. END_FUNCTION BoFiqEntry
  325. ##
  326. ## VOID
  327. ## BoCpuid (
  328. ## PARM_CPUID Features
  329. ## )
  330. ##
  331. /*++
  332. Routine Description:
  333. This routine returns the set of processor features present on the current
  334. processor.
  335. Arguments:
  336. Features - Supplies a pointer where the processor feature register values
  337. will be returned.
  338. Return Value:
  339. None.
  340. --*/
  341. FUNCTION BoCpuid
  342. mrc p15, 0, %r1, c0, c1, 0 @ Get ID_PFR0.
  343. str %r1, [%r0], #4 @ Save it.
  344. mrc p15, 0, %r1, c0, c1, 1 @ Get ID_PFR1.
  345. str %r1, [%r0], #4 @ Save it.
  346. mrc p15, 0, %r1, c0, c1, 2 @ Get ID_DFR0.
  347. str %r1, [%r0], #4 @ Save it.
  348. mrc p15, 0, %r1, c0, c1, 3 @ Get ID_AFR0.
  349. str %r1, [%r0], #4 @ Save it.
  350. mrc p15, 0, %r1, c0, c1, 4 @ Get ID_MMFR0.
  351. str %r1, [%r0], #4 @ Save it.
  352. mrc p15, 0, %r1, c0, c1, 5 @ Get ID_MMFR1.
  353. str %r1, [%r0], #4 @ Save it.
  354. mrc p15, 0, %r1, c0, c1, 6 @ Get ID_MMFR2.
  355. str %r1, [%r0], #4 @ Save it.
  356. mrc p15, 0, %r1, c0, c1, 7 @ Get ID_MMFR3.
  357. str %r1, [%r0], #4 @ Save it.
  358. mrc p15, 0, %r1, c0, c2, 0 @ Get ID_IDAR0.
  359. str %r1, [%r0], #4 @ Save it.
  360. mrc p15, 0, %r1, c0, c2, 1 @ Get ID_IDAR1.
  361. str %r1, [%r0], #4 @ Save it.
  362. mrc p15, 0, %r1, c0, c2, 2 @ Get ID_IDAR2.
  363. str %r1, [%r0], #4 @ Save it.
  364. mrc p15, 0, %r1, c0, c2, 3 @ Get ID_IDAR3.
  365. str %r1, [%r0], #4 @ Save it.
  366. mrc p15, 0, %r1, c0, c2, 4 @ Get ID_IDAR4.
  367. str %r1, [%r0], #4 @ Save it.
  368. mrc p15, 0, %r1, c0, c2, 5 @ Get ID_IDAR5.
  369. str %r1, [%r0], #4 @ Save it.
  370. bx %lr @ Return!
  371. END_FUNCTION BoCpuid
  372. ##
  373. ## ULONG
  374. ## ArGetSystemControlRegister (
  375. ## VOID
  376. ## )
  377. ##
  378. /*++
  379. Routine Description:
  380. This routine returns the MMU system control register (SCTLR).
  381. Arguments:
  382. None.
  383. Return Value:
  384. Returns the current SCTLR value.
  385. --*/
  386. FUNCTION ArGetSystemControlRegister
  387. mrc p15, 0, %r0, %cr1, %cr0, 0 @ Get the SCTLR.
  388. bx %lr @ Return.
  389. END_FUNCTION ArGetSystemControlRegister
  390. ##
  391. ## VOID
  392. ## ArSetSystemControlRegister (
  393. ## ULONG NewValue
  394. ## )
  395. ##
  396. /*++
  397. Routine Description:
  398. This routine sets the MMU system control register (SCTLR).
  399. Arguments:
  400. NewValue - Supplies the value to set as the new MMU SCTLR.
  401. Return Value:
  402. None.
  403. --*/
  404. FUNCTION ArSetSystemControlRegister
  405. mcr p15, 0, %r0, %cr1, %cr0, 0 @ Set the SCTLR.
  406. bx %lr @ Return.
  407. END_FUNCTION ArSetSystemControlRegister
  408. ##
  409. ## ULONG
  410. ## ArGetAuxiliaryControlRegister (
  411. ## VOID
  412. ## )
  413. ##
  414. /*++
  415. Routine Description:
  416. This routine returns the auxiliary system control register (ACTLR).
  417. Arguments:
  418. None.
  419. Return Value:
  420. Returns the current value.
  421. --*/
  422. FUNCTION ArGetAuxiliaryControlRegister
  423. mrc p15, 0, %r0, %cr1, %cr0, 1
  424. bx %lr
  425. END_FUNCTION ArGetAuxiliaryControlRegister
  426. ##
  427. ## VOID
  428. ## ArSetAuxiliaryControlRegister (
  429. ## ULONG NewValue
  430. ## )
  431. ##
  432. /*++
  433. Routine Description:
  434. This routine sets the auxiliary system control register (ACTLR).
  435. Arguments:
  436. NewValue - Supplies the value to set.
  437. Return Value:
  438. None.
  439. --*/
  440. FUNCTION ArSetAuxiliaryControlRegister
  441. mcr p15, 0, %r0, %cr1, %cr0, 1
  442. bx %lr
  443. END_FUNCTION ArSetAuxiliaryControlRegister
  444. ##
  445. ## PVOID
  446. ## ArGetVectorBaseAddress (
  447. ## VOID
  448. ## )
  449. ##
  450. /*++
  451. Routine Description:
  452. This routine gets the vector base address register (VBAR) which determines
  453. where the ARM exception vector table starts.
  454. Arguments:
  455. None.
  456. Return Value:
  457. Returns the current VBAR.
  458. --*/
  459. FUNCTION ArGetVectorBaseAddress
  460. mrc p15, 0, %r0, c12, c0, 0
  461. bx %lr
  462. END_FUNCTION ArGetVectorBaseAddress
  463. ##
  464. ## VOID
  465. ## ArSetVectorBaseAddress (
  466. ## PVOID VectorBaseAddress
  467. ## )
  468. ##
  469. /*++
  470. Routine Description:
  471. This routine sets the vector base address register (VBAR) which determines
  472. where the ARM exception vector table starts.
  473. Arguments:
  474. VectorBaseAddress - Supplies a pointer to the ARM exception vector base
  475. address. This value must be 32-byte aligned.
  476. Return Value:
  477. None.
  478. --*/
  479. FUNCTION ArSetVectorBaseAddress
  480. mcr p15, 0, %r0, c12, c0, 0 @ Set VBAR.
  481. bx %lr @ Return.
  482. END_FUNCTION ArSetVectorBaseAddress
  483. ##
  484. ## PVOID
  485. ## ArGetDataFaultingAddress (
  486. ## VOID
  487. ## )
  488. ##
  489. /*++
  490. Routine Description:
  491. This routine determines which address caused a data abort.
  492. Arguments:
  493. None.
  494. Return Value:
  495. Returns the faulting address.
  496. --*/
  497. FUNCTION ArGetDataFaultingAddress
  498. mrc p15, 0, %r0, %cr6, %cr0, 0 @ Get the combined/data FAR.
  499. bx %lr @
  500. END_FUNCTION ArGetDataFaultingAddress
  501. ##
  502. ## VOID
  503. ## ArSetDataFaultingAddress (
  504. ## PVOID Value
  505. ## )
  506. ##
  507. /*++
  508. Routine Description:
  509. This routine sets the data faulting address register (DFAR).
  510. Arguments:
  511. Value - Supplies the value to set.
  512. Return Value:
  513. None.
  514. --*/
  515. FUNCTION ArSetDataFaultingAddress
  516. mcr p15, 0, %r0, %cr6, %cr0, 0
  517. bx %lr
  518. END_FUNCTION ArSetDataFaultingAddress
  519. ##
  520. ## PVOID
  521. ## ArGetInstructionFaultingAddress (
  522. ## VOID
  523. ## )
  524. ##
  525. /*++
  526. Routine Description:
  527. This routine determines which address caused a prefetch abort.
  528. Arguments:
  529. None.
  530. Return Value:
  531. Returns the faulting address.
  532. --*/
  533. FUNCTION ArGetInstructionFaultingAddress
  534. mrc p15, 0, %r0, %cr6, %cr0, 2 @ Get the IFAR.
  535. bx %lr @
  536. END_FUNCTION ArGetInstructionFaultingAddress
  537. ##
  538. ## VOID
  539. ## ArSetInstructionFaultingAddress (
  540. ## PVOID Value
  541. ## )
  542. ##
  543. /*++
  544. Routine Description:
  545. This routine sets the instruction faulting address register (IFAR).
  546. Arguments:
  547. Value - Supplies the value to set.
  548. Return Value:
  549. None.
  550. --*/
  551. FUNCTION ArSetInstructionFaultingAddress
  552. mcr p15, 0, %r0, %cr6, %cr0, 2
  553. bx %lr
  554. END_FUNCTION ArSetInstructionFaultingAddress
  555. ##
  556. ## ULONG
  557. ## ArGetDataFaultStatus (
  558. ## VOID
  559. ## )
  560. ##
  561. /*++
  562. Routine Description:
  563. This routine determines the reason for the fault by reading the DFSR
  564. register.
  565. Arguments:
  566. None.
  567. Return Value:
  568. Returns the contents of the Data Fault Status Register.
  569. --*/
  570. FUNCTION ArGetDataFaultStatus
  571. mrc p15, 0, %r0, %cr5, %cr0, 0 @ Get the DFSR.
  572. bx %lr @
  573. END_FUNCTION ArGetDataFaultStatus
  574. ##
  575. ## VOID
  576. ## ArSetDataFaultStatus (
  577. ## ULONG Value
  578. ## )
  579. ##
  580. /*++
  581. Routine Description:
  582. This routine sets the data fault status register (DFSR).
  583. Arguments:
  584. Value - Supplies the value to set.
  585. Return Value:
  586. None.
  587. --*/
  588. FUNCTION ArSetDataFaultStatus
  589. mcr p15, 0, %r0, %cr5, %cr0, 0
  590. bx %lr
  591. END_FUNCTION ArSetDataFaultStatus
  592. ##
  593. ## ULONG
  594. ## ArGetInstructionFaultStatus (
  595. ## VOID
  596. ## )
  597. ##
  598. /*++
  599. Routine Description:
  600. This routine determines the reason for the prefetch abort by reading the
  601. IFAR register.
  602. Arguments:
  603. None.
  604. Return Value:
  605. Returns the contents of the Instruction Fault Status Register.
  606. --*/
  607. FUNCTION ArGetInstructionFaultStatus
  608. mrc p15, 0, %r0, %cr5, %cr0, 1 @ Get the IFSR.
  609. bx %lr @
  610. END_FUNCTION ArGetInstructionFaultStatus
  611. ##
  612. ## VOID
  613. ## ArSetInstructionFaultStatus (
  614. ## ULONG Value
  615. ## )
  616. ##
  617. /*++
  618. Routine Description:
  619. This routine sets the instruction fault status register (IFSR).
  620. Arguments:
  621. Value - Supplies the value to set.
  622. Return Value:
  623. None.
  624. --*/
  625. FUNCTION ArSetInstructionFaultStatus
  626. mcr p15, 0, %r0, %cr5, %cr0, 1
  627. bx %lr
  628. END_FUNCTION ArSetInstructionFaultStatus
  629. ##
  630. ## PVOID
  631. ## ArGetProcessorBlockRegister (
  632. ## VOID
  633. ## )
  634. ##
  635. /*++
  636. Routine Description:
  637. This routine gets the register used to store a pointer to the processor
  638. block (TPIDRPRW in the ARMARM; Thread and Process ID Registers in the
  639. ARM1176 TRM).
  640. Arguments:
  641. None.
  642. Return Value:
  643. Returns a pointer to the processor block.
  644. --*/
  645. FUNCTION ArGetProcessorBlockRegister
  646. mrc p15, 0, %r0, c13, c0, 4 @ Get TPIDRPRW.
  647. bx %lr @ Return.
  648. END_FUNCTION ArGetProcessorBlockRegister
  649. ##
  650. ## VOID
  651. ## ArSetProcessorBlockRegister (
  652. ## PVOID ProcessorBlockRegisterValue
  653. ## )
  654. ##
  655. /*++
  656. Routine Description:
  657. This routine sets the register used to store a pointer to the processor
  658. block (TPIDRPRW in the ARMARM; Thread and Process ID Registers in the
  659. ARM1176 TRM).
  660. Arguments:
  661. ProcessorBlockRegisterValue - Supplies the value to assign to the register
  662. used to store the processor block.
  663. Return Value:
  664. None.
  665. --*/
  666. FUNCTION ArSetProcessorBlockRegister
  667. mcr p15, 0, %r0, c13, c0, 4 @ Set TPIDRPRW.
  668. bx %lr @ Return.
  669. END_FUNCTION ArSetProcessorBlockRegister
  670. ##
  671. ## ULONG
  672. ## ArGetTranslationTableBaseRegister0 (
  673. ## VOID
  674. ## )
  675. ##
  676. /*++
  677. Routine Description:
  678. This routine gets the translation table base register 0 (TTBR0), used as
  679. the base for all virtual to physical memory lookups.
  680. Arguments:
  681. None.
  682. Return Value:
  683. Returns the contents of TTBR0.
  684. --*/
  685. FUNCTION ArGetTranslationTableBaseRegister0
  686. mrc p15, 0, %r0, c2, c0, 0 @ Get TTBR0.
  687. bx %lr @ Return.
  688. END_FUNCTION ArGetTranslationTableBaseRegister0
  689. ##
  690. ## VOID
  691. ## ArSetTranslationTableBaseRegister0 (
  692. ## ULONG Value
  693. ## )
  694. ##
  695. /*++
  696. Routine Description:
  697. This routine sets the translation table base register 0 (TTBR0).
  698. Arguments:
  699. Value - Supplies the value to write.
  700. Return Value:
  701. None.
  702. --*/
  703. FUNCTION ArSetTranslationTableBaseRegister0
  704. mcr p15, 0, %r0, c2, c0, 0
  705. bx %lr
  706. END_FUNCTION ArSetTranslationTableBaseRegister0
  707. ##
  708. ## ULONG
  709. ## ArGetTranslationTableBaseRegister1 (
  710. ## VOID
  711. ## )
  712. ##
  713. /*++
  714. Routine Description:
  715. This routine gets the translation table base register 1 (TTBR1).
  716. Arguments:
  717. None.
  718. Return Value:
  719. Returns the contents of TTBR1.
  720. --*/
  721. FUNCTION ArGetTranslationTableBaseRegister1
  722. mrc p15, 0, %r0, c2, c0, 1
  723. bx %lr
  724. END_FUNCTION ArGetTranslationTableBaseRegister1
  725. ##
  726. ## VOID
  727. ## ArSetTranslationTableBaseRegister1 (
  728. ## ULONG Value
  729. ## )
  730. ##
  731. /*++
  732. Routine Description:
  733. This routine sets the translation table base register 1 (TTBR1).
  734. Arguments:
  735. Value - Supplies the value to write.
  736. Return Value:
  737. None.
  738. --*/
  739. FUNCTION ArSetTranslationTableBaseRegister1
  740. mcr p15, 0, %r0, c2, c0, 1
  741. bx %lr
  742. END_FUNCTION ArSetTranslationTableBaseRegister1
  743. ##
  744. ## ULONG
  745. ## ArGetPrimaryRegionRemapRegister (
  746. ## VOID
  747. ## )
  748. ##
  749. /*++
  750. Routine Description:
  751. This routine gets the Primary Region Remap Register (PRRR).
  752. Arguments:
  753. None.
  754. Return Value:
  755. Returns the contents of the register.
  756. --*/
  757. FUNCTION ArGetPrimaryRegionRemapRegister
  758. mrc p15, 0, %r0, c10, c2, 0
  759. bx %lr
  760. END_FUNCTION ArGetPrimaryRegionRemapRegister
  761. ##
  762. ## VOID
  763. ## ArSetPrimaryRegionRemapRegister (
  764. ## ULONG Value
  765. ## )
  766. ##
  767. /*++
  768. Routine Description:
  769. This routine sets the PRRR.
  770. Arguments:
  771. Value - Supplies the value to write.
  772. Return Value:
  773. None.
  774. --*/
  775. FUNCTION ArSetPrimaryRegionRemapRegister
  776. mcr p15, 0, %r0, c10, c2, 0
  777. bx %lr
  778. END_FUNCTION ArSetPrimaryRegionRemapRegister
  779. ##
  780. ## ULONG
  781. ## ArGetNormalMemoryRemapRegister (
  782. ## VOID
  783. ## )
  784. ##
  785. /*++
  786. Routine Description:
  787. This routine gets the Normal Memory Remap Register (NMRR).
  788. Arguments:
  789. None.
  790. Return Value:
  791. Returns the contents of the register.
  792. --*/
  793. FUNCTION ArGetNormalMemoryRemapRegister
  794. mrc p15, 0, %r0, c10, c2, 1
  795. bx %lr
  796. END_FUNCTION ArGetNormalMemoryRemapRegister
  797. ##
  798. ## VOID
  799. ## ArSetNormalMemoryRemapRegister (
  800. ## ULONG Value
  801. ## )
  802. ##
  803. /*++
  804. Routine Description:
  805. This routine sets the NMRR.
  806. Arguments:
  807. Value - Supplies the value to write.
  808. Return Value:
  809. None.
  810. --*/
  811. FUNCTION ArSetNormalMemoryRemapRegister
  812. mcr p15, 0, %r0, c10, c2, 1
  813. bx %lr
  814. END_FUNCTION ArSetNormalMemoryRemapRegister
  815. ##
  816. ## ULONG
  817. ## ArGetPhysicalAddressRegister (
  818. ## VOID
  819. ## )
  820. ##
  821. /*++
  822. Routine Description:
  823. This routine gets the Physical Address Register (PAR).
  824. Arguments:
  825. None.
  826. Return Value:
  827. Returns the contents of the register.
  828. --*/
  829. FUNCTION ArGetPhysicalAddressRegister
  830. mrc p15, 0, %r0, c7, c4, 0
  831. bx %lr
  832. END_FUNCTION ArGetPhysicalAddressRegister
  833. ##
  834. ## VOID
  835. ## ArSetPhysicalAddressRegister (
  836. ## ULONG Value
  837. ## )
  838. ##
  839. /*++
  840. Routine Description:
  841. This routine sets the Physical Address Register (PAR).
  842. Arguments:
  843. Value - Supplies the value to write.
  844. Return Value:
  845. None.
  846. --*/
  847. FUNCTION ArSetPhysicalAddressRegister
  848. mcr p15, 0, %r0, c7, c4, 0
  849. bx %lr
  850. END_FUNCTION ArSetPhysicalAddressRegister
  851. ##
  852. ## VOID
  853. ## ArSetPrivilegedReadTranslateRegister (
  854. ## ULONG Value
  855. ## )
  856. ##
  857. /*++
  858. Routine Description:
  859. This routine sets the Privileged Read address translation command register.
  860. Arguments:
  861. Value - Supplies the value to write.
  862. Return Value:
  863. None.
  864. --*/
  865. FUNCTION ArSetPrivilegedReadTranslateRegister
  866. mcr p15, 0, %r0, c7, c8, 0
  867. bx %lr
  868. END_FUNCTION ArSetPrivilegedReadTranslateRegister
  869. ##
  870. ## VOID
  871. ## ArSetPrivilegedWriteTranslateRegister (
  872. ## ULONG Value
  873. ## )
  874. ##
  875. /*++
  876. Routine Description:
  877. This routine sets the Privileged Write address translation command register.
  878. Arguments:
  879. Value - Supplies the value to write.
  880. Return Value:
  881. None.
  882. --*/
  883. FUNCTION ArSetPrivilegedWriteTranslateRegister
  884. mcr p15, 0, %r0, c7, c8, 1
  885. bx %lr
  886. END_FUNCTION ArSetPrivilegedWriteTranslateRegister
  887. ##
  888. ## VOID
  889. ## ArSetUnprivilegedReadTranslateRegister (
  890. ## ULONG Value
  891. ## )
  892. ##
  893. /*++
  894. Routine Description:
  895. This routine sets the Unrivileged Read address translation command register.
  896. Arguments:
  897. Value - Supplies the value to write.
  898. Return Value:
  899. None.
  900. --*/
  901. FUNCTION ArSetUnprivilegedReadTranslateRegister
  902. mcr p15, 0, %r0, c7, c8, 2
  903. bx %lr
  904. END_FUNCTION ArSetUnprivilegedReadTranslateRegister
  905. ##
  906. ## VOID
  907. ## ArSetUnprivilegedWriteTranslateRegister (
  908. ## ULONG Value
  909. ## )
  910. ##
  911. /*++
  912. Routine Description:
  913. This routine sets the Unprivileged Write address translation command
  914. register.
  915. Arguments:
  916. Value - Supplies the value to write.
  917. Return Value:
  918. None.
  919. --*/
  920. FUNCTION ArSetUnprivilegedWriteTranslateRegister
  921. mcr p15, 0, %r0, c7, c8, 3
  922. bx %lr
  923. END_FUNCTION ArSetUnprivilegedWriteTranslateRegister
  924. ##
  925. ## --------------------------------------------------------- Internal Functions
  926. ##
  927. ##
  928. ## This code is entered as the result of any interrupt or exception. Its job is
  929. ## to transition back to the SVC stack and then call the real interrupt
  930. ## dispatch routine.
  931. ##
  932. BopCommonInterruptEntry:
  933. ##
  934. ## Save state and create a trap frame.
  935. ##
  936. ARM_ENTER_INTERRUPT
  937. ##
  938. ## Call the main dispatch routine routine with a pointer to the trap frame
  939. ## as the only parameter.
  940. ##
  941. mov %r0, %sp
  942. bl BopDispatchException
  943. ##
  944. ## Restore state and return.
  945. ##
  946. ARM_EXIT_INTERRUPT