commsup.S 26 KB

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