arm.h 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783
  1. /*++
  2. Copyright (c) 2012 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. arm.h
  9. Abstract:
  10. This header contains definitions for aspects of the system that are specific
  11. to the ARM architecture.
  12. Author:
  13. Evan Green 11-Aug-2012
  14. --*/
  15. //
  16. // ------------------------------------------------------------------- Includes
  17. //
  18. //
  19. // --------------------------------------------------------------------- Macros
  20. //
  21. //
  22. // This macro gets the index into the first level page table for the given
  23. // virtual address.
  24. //
  25. #define FLT_INDEX(_Address) \
  26. (((ULONG)(_Address) & FLT_INDEX_MASK) >> FLT_INDEX_SHIFT)
  27. //
  28. // This macro gets the index into the second level page table for the given
  29. // virtual address.
  30. //
  31. #define SLT_INDEX(_Address) \
  32. (((ULONG)(_Address) & SLT_INDEX_MASK) >> SLT_INDEX_SHIFT)
  33. //
  34. // This macro gets the fault status type from the fault status register.
  35. //
  36. #define ARM_FAULT_STATUS_TYPE(_FaultStatus) \
  37. ((_FaultStatus) & ARM_FAULT_STATUS_TYPE_MASK)
  38. //
  39. // This macro determines if the given fault status is a page fault.
  40. //
  41. #define IS_ARM_PAGE_FAULT(_FaultStatus) \
  42. ((ARM_FAULT_STATUS_TYPE(_FaultStatus) == \
  43. ARM_FAULT_STATUS_TYPE_SECTION_TRANLSATION) || \
  44. (ARM_FAULT_STATUS_TYPE(_FaultStatus) == \
  45. ARM_FAULT_STATUS_TYPE_PAGE_TRANSLATION))
  46. #define IS_ARM_PERMISSION_FAULT(_FaultStatus) \
  47. ((ARM_FAULT_STATUS_TYPE(_FaultStatus) == \
  48. ARM_FAULT_STATUS_TYPE_SECTION_PERMISSION) || \
  49. (ARM_FAULT_STATUS_TYPE(_FaultStatus) == \
  50. ARM_FAULT_STATUS_TYPE_PAGE_PERMISSION))
  51. #define IS_ARM_DEBUG_BREAK(_FaultStatus) \
  52. (ARM_FAULT_STATUS_TYPE(_FaultStatus) == ARM_FAULT_STATUS_TYPE_DEBUG)
  53. //
  54. // This macro removes the thumb bit from the PC.
  55. //
  56. #define REMOVE_THUMB_BIT(_Pc) ((_Pc) & ~ARM_THUMB_BIT)
  57. //
  58. // This macro extracts the if-then state from a current program status register
  59. // value.
  60. //
  61. #define PSR_GET_IT_STATE(_Cpsr) \
  62. ((((_Cpsr) >> 8) & 0xFC) | (((_Cpsr) >> 25) & 0x3))
  63. //
  64. // This macro returns the given current program status register value with the
  65. // if-then state bits set to the given if-then state.
  66. //
  67. #define PSR_SET_IT_STATE(_Cpsr, _ItState) \
  68. (((_Cpsr) & 0xF9FF03FF) | \
  69. (((_ItState) << 25) & 0x06000000) | \
  70. (((_ItState) << 8) & 0x0000FC00))
  71. //
  72. // This macro determines if, given a current Program Status Register value,
  73. // the if-then state is active in any form..
  74. //
  75. #define PSR_IS_IT_ACTIVE(_Cpsr) (((_Cpsr) & PSR_FLAG_IT_STATE) != 0)
  76. //
  77. // This macro determines if the given if-then state is active.
  78. //
  79. #define IS_THUMB_IT_STATE_ACTIVE(_ItState) (((_ItState) & 0x0F) != 0)
  80. //
  81. // This macro extracts the active condition code from the given if-then state.
  82. //
  83. #define THUMB_CONDITION_FROM_IT_STATE(_ItState) (((_ItState) >> 4) & 0xF)
  84. //
  85. // This macro returns the given if-then state, advanced by one instruction.
  86. //
  87. #define THUMB_ADVANCE_IT_STATE(_ItState) \
  88. ((((_ItState) & 0x07) == 0) ? 0 : \
  89. ((((_ItState) << 1) & 0x1F) | ((_ItState) & 0xE0)))
  90. //
  91. // This macro reverses the if-then state by one instruction, placing the given
  92. // next bit in the next conditional position. This macro assumes the if-then
  93. // state is already active, it does not add the trailing one.
  94. //
  95. #define THUMB_RETREAT_IT_STATE(_ItState, _NextBit) \
  96. ((((_ItState) >> 1) & 0xF) | ((_NextBit) << 4) | ((_ItState) & 0xE0))
  97. //
  98. // This macro returns whether or not the given trap from is from privileged
  99. // mode.
  100. //
  101. #define IS_TRAP_FRAME_FROM_PRIVILEGED_MODE(_TrapFrame) \
  102. (((_TrapFrame)->Cpsr & ARM_MODE_MASK) != ARM_MODE_USER)
  103. //
  104. // This macro determines whether or not the given trap frame is complete or
  105. // left mostly uninitialized by the system call handler. The system call
  106. // handler sets a reserved flag in the CPSR.
  107. //
  108. #define IS_TRAP_FRAME_COMPLETE(_TrapFrame) \
  109. ((_TrapFrame)->ExceptionCpsr != 0xFFFFFFFF)
  110. //
  111. // This macro manipulates the bitfields in the coprocessor access mask.
  112. //
  113. #define ARM_COPROCESSOR_ACCESS_MASK(_Coprocessor) (0x3 << ((_Coprocessor) * 2))
  114. #define ARM_COPROCESSOR_ACCESS(_Coprocessor, _Access) \
  115. ((_Access) << ((_Coprocessor) * 2))
  116. //
  117. // ---------------------------------------------------------------- Definitions
  118. //
  119. #define ARM_INSTRUCTION_LENGTH 4
  120. #define THUMB16_INSTRUCTION_LENGTH 2
  121. #define THUMB32_INSTRUCTION_LENGTH 4
  122. #define ARM_THUMB_BIT 0x00000001
  123. //
  124. // Processor modes.
  125. //
  126. #define ARM_MODE_USER 0x00000010
  127. #define ARM_MODE_FIQ 0x00000011
  128. #define ARM_MODE_IRQ 0x00000012
  129. #define ARM_MODE_SVC 0x00000013
  130. #define ARM_MODE_MON 0x00000016
  131. #define ARM_MODE_ABORT 0x00000017
  132. #define ARM_MODE_HYP 0x0000001A
  133. #define ARM_MODE_UNDEF 0x0000001B
  134. #define ARM_MODE_SYSTEM 0x0000001F
  135. #define ARM_MODE_MASK 0x0000001F
  136. //
  137. // Program Status Register flags.
  138. //
  139. #define PSR_FLAG_NEGATIVE 0x80000000
  140. #define PSR_FLAG_ZERO 0x40000000
  141. #define PSR_FLAG_CARRY 0x20000000
  142. #define PSR_FLAG_OVERFLOW 0x10000000
  143. #define PSR_FLAG_SATURATION 0x08000000
  144. #define PSR_FLAG_JAZELLE 0x01000000
  145. #define PSR_FLAG_THUMB 0x00000020
  146. #define PSR_FLAG_FIQ 0x00000040
  147. #define PSR_FLAG_IRQ 0x00000080
  148. #define PSR_FLAG_ALIGNMENT 0x00000100
  149. #define PSR_FLAG_IT_STATE 0x06000C00
  150. //
  151. // Interrupt vector ranges.
  152. //
  153. #define MINIMUM_VECTOR 0x30
  154. #define MAXIMUM_VECTOR 0xFF
  155. #define MAXIMUM_DEVICE_VECTOR 0xBF
  156. #define INTERRUPT_VECTOR_COUNT (MAXIMUM_VECTOR + 1)
  157. #define IO_PORT_COUNT 0
  158. //
  159. // Interrupt vectors.
  160. //
  161. #define VECTOR_CLOCK_INTERRUPT 0xD0
  162. #define VECTOR_CLOCK_IPI 0xD1
  163. #define VECTOR_IPI_INTERRUPT 0xE0
  164. #define VECTOR_TLB_IPI 0xE1
  165. #define VECTOR_PROFILER_INTERRUPT 0xF0
  166. #define VECTOR_NMI 0xF1
  167. //
  168. // Undefined instructions used for debug breakpoints.
  169. //
  170. #define THUMB_BREAK_INSTRUCTION 0xDE20
  171. #define THUMB_DEBUG_SERVICE_INSTRUCTION 0xDE24
  172. #define THUMB_SINGLE_STEP_INSTRUCTION 0xDE21
  173. #define ARM_BREAK_INSTRUCTION 0xE7F000F3
  174. #define ARM_SINGLE_STEP_INSTRUCTION 0xE7F000F1
  175. #define ARM_DEBUG_SERVICE_INSTRUCTION 0xE7F000F4
  176. //
  177. // Thumb instruction width constants.
  178. //
  179. #define THUMB32_OP_SHIFT 11
  180. #define THUMB32_OP_MASK 0x1F
  181. #define THUMB32_OP_MIN 0x1D
  182. //
  183. // Memory related definitions.
  184. //
  185. #define PAGE_SIZE 4096
  186. #define PAGE_MASK 0x00000FFF
  187. #define PAGE_SHIFT 12
  188. #define EXCEPTION_VECTOR_ADDRESS 0xFFFF0000
  189. #define EXCEPTION_VECTOR_LOW_ADDRESS 0x00000000
  190. //
  191. // Translation table base register address mask.
  192. //
  193. // Bit definitions are tricky for this register because they change based on
  194. // whether or not the Multiprocessing Extensions are supported on the CPU.
  195. //
  196. #define TTBR_ADDRESS_MASK 0x00003FFF
  197. #define TTBR_NO_MP_INNER_CACHEABLE 0x00000001
  198. #define TTBR_SHAREABLE 0x00000002
  199. #define TTBR_NOT_OUTER_SHAREABLE 0x00000020
  200. #define TTBR_MP_INNER_NON_CACHEABLE 0x00000000
  201. #define TTBR_MP_INNER_WRITE_BACK_WRITE_ALLOCATE 0x00000040
  202. #define TTBR_MP_INNER_WRITE_THROUGH 0x00000001
  203. #define TTBR_MP_INNER_WRITE_BACK_NO_WRITE_ALLOCATE 0x00000041
  204. #define TTBR_OUTER_NON_CACHEABLE 0x00000000
  205. #define TTBR_OUTER_WRITE_BACK_WRITE_ALLOCATE 0x00000008
  206. #define TTBR_OUTER_WRITE_THROUGH 0x00000010
  207. #define TTBR_OUTER_WRITE_BACK_NO_WRITE_ALLOCATE 0x00000018
  208. #define TTBR_NO_MP_KERNEL_MASK \
  209. (TTBR_NO_MP_INNER_CACHEABLE | \
  210. TTBR_OUTER_WRITE_BACK_WRITE_ALLOCATE)
  211. #define TTBR_MP_KERNEL_MASK \
  212. (TTBR_SHAREABLE | \
  213. TTBR_MP_INNER_WRITE_BACK_WRITE_ALLOCATE | \
  214. TTBR_OUTER_WRITE_BACK_WRITE_ALLOCATE | \
  215. TTBR_NOT_OUTER_SHAREABLE)
  216. //
  217. // Page table sizes and alignments.
  218. //
  219. #define FLT_SIZE 0x4000
  220. #define FLT_ALIGNMENT 0x4000
  221. #define FLT_INDEX_MASK 0xFFF00000
  222. #define FLT_INDEX_SHIFT 20
  223. #define SLT_SIZE 1024
  224. #define SLT_INDEX_MASK 0x000FF000
  225. #define SLT_INDEX_SHIFT 12
  226. #define SLT_ALIGNMENT 10
  227. //
  228. // First level page table formats.
  229. //
  230. #define FLT_UNMAPPED 0
  231. #define FLT_COARSE_PAGE_TABLE 1
  232. #define FLT_SECTION 2
  233. #define FLT_SUPERSECTION 2
  234. //
  235. // Second level page table formats.
  236. //
  237. #define SLT_UNMAPPED 0
  238. #define SLT_LARGE_PAGE 1
  239. #define SLT_SMALL_PAGE 2
  240. #define SLT_SMALL_PAGE_NO_EXECUTE 3
  241. //
  242. // Second level page table access permission bits.
  243. //
  244. #define SLT_ACCESS_NONE 0
  245. #define SLT_ACCESS_SUPERVISOR 1
  246. #define SLT_ACCESS_USER_READ_ONLY 2
  247. #define SLT_ACCESS_USER_FULL 3
  248. //
  249. // Second level page table access permission bits when the Extended Access Bit
  250. // is set. Note that the "read only all modes" value only works for ARMv7, on
  251. // ARMv6 and below this value was reserved and 2 is the correct value.
  252. //
  253. #define SLT_XACCESS_SUPERVISOR_READ_ONLY 1
  254. #define SLT_XACCESS_READ_ONLY_ALL_MODES 3
  255. //
  256. // Second level page table cache attributes
  257. //
  258. #define SLT_TEX_NORMAL 0
  259. #define SLT_UNCACHED 0
  260. #define SLT_SHARED_DEVICE 1
  261. #define SLT_WRITE_THROUGH 2
  262. #define SLT_WRITE_BACK 3
  263. //
  264. // MMU Control bits (SCTLR, CP15, register 1).
  265. //
  266. #define MMU_ENABLED 0x00000001
  267. #define MMU_ALIGNMENT_FAULT_ENABLED 0x00000002
  268. #define MMU_DCACHE_ENABLED 0x00000004
  269. #define MMU_WRITE_BUFFER_ENABLED 0x00000008
  270. #define MMU_ENDIANNESS 0x00000080
  271. #define MMU_SYSTEM_PROTECTION 0x00000100
  272. #define MMU_ROM_PROTECTION 0x00000200
  273. #define MMU_BRANCH_PREDICTION_ENABLED 0x00000800
  274. #define MMU_ICACHE_ENABLED 0x00001000
  275. #define MMU_HIGH_EXCEPTION_VECTORS 0x00002000
  276. #define MMU_PREDICTABLE_REPLACEMENT 0x00004000
  277. #define MMU_DISABLE_THUMB_DEPRECATED 0x00008000
  278. #define MMU_FAST_INTERRUPTS 0x00200000
  279. #define MMU_UNALIGNED_ACCESS_ENABLED 0x00400000
  280. #define MMU_VMSA6_ENABLED 0x00800000
  281. #define MMU_VECTORED_INTERRUPTS_ENABLED 0x01000000
  282. #define MMU_EXCEPTION_ENDIAN 0x02000000
  283. #define MMU_THUMB_EXCEPTIONS 0x40000000
  284. //
  285. // ARMv6 auxiliary control register bits (ACTLR).
  286. //
  287. #define ARMV6_AUX_16K_CACHE_SIZE 0x00000040
  288. //
  289. // Cortex A17 auxiliary control register bits (ACTLR).
  290. //
  291. #define CORTEX_A17_AUX_SMP_ENABLE 0x00000040
  292. //
  293. // Define multiprocessor ID register bits.
  294. //
  295. #define MPIDR_MP_EXTENSIONS_ENABLED 0x80000000
  296. #define MPIDR_UNIPROCESSOR_SYSTEM 0x40000000
  297. #define MPIDR_LOWEST_AFFINITY_INTERDEPENDENT 0x01000000
  298. //
  299. // Define processor features bits.
  300. //
  301. #define CPUID_PROCESSOR1_SECURITY_EXTENSION_MASK 0x000000F0
  302. #define CPUID_PROCESSOR1_SECURITY_EXTENSION_UNSUPPORTED 0x00000000
  303. #define CPUID_PROCESSOR1_GENERIC_TIMER_MASK 0x000F0000
  304. #define CPUID_PROCESSOR1_GENERIC_TIMER_UNSUPPORTED 0x00000000
  305. //
  306. // Define bits in the ARMv7 Cache Type Register (CTR).
  307. //
  308. #define ARMV7_CACHE_TYPE_DATA_CACHE_SIZE_MASK 0x000F0000
  309. #define ARMV7_CACHE_TYPE_DATA_CACHE_SIZE_SHIFT 16
  310. #define ARMV7_CACHE_TYPE_INSTRUCTION_CACHE_SIZE_MASK 0x0000000F
  311. #define ARMV7_CACHE_TYPE_INSTRUCTION_CACHE_TYPE_MASK 0x0000C000
  312. //
  313. // Physically indexed, physically tagged caches are the easiest to deal with.
  314. //
  315. #define ARMV7_CACHE_TYPE_INSTRUCTION_CACHE_TYPE_PIPT 0x0000C000
  316. //
  317. // Define bits in the ARMv6 Cache Type Register (CTR).
  318. //
  319. #define ARMV6_CACHE_TYPE_SEPARATE_MASK 0x01000000
  320. #define ARMV6_CACHE_TYPE_DATA_CACHE_SIZE_MASK 0x003C0000
  321. #define ARMV6_CACHE_TYPE_DATA_CACHE_SIZE_SHIFT 18
  322. #define ARMV6_CACHE_TYPE_DATA_CACHE_LENGTH_MASK 0x00003000
  323. #define ARMV6_CACHE_TYPE_DATA_CACHE_LENGTH_SHIFT 12
  324. #define ARMV6_CACHE_TYPE_INSTRUCTION_CACHE_LENGTH_MASK 0x00000003
  325. //
  326. // Define ARM fault status bits.
  327. //
  328. #define ARM_FAULT_STATUS_EXTERNAL 0x00001000
  329. #define ARM_FAULT_STATUS_WRITE 0x00000800
  330. #define ARM_FAULT_STATUS_TYPE_MASK 0x0000040F
  331. #define ARM_FAULT_STATUS_TYPE_ALIGNMENT 0x00000001
  332. #define ARM_FAULT_STATUS_TYPE_ICACHE_MAINTENANCE 0x00000004
  333. #define ARM_FAULT_STATUS_TYPE_SYNCHRONOUS_EXTERNAL_FIRST_LEVEL 0x0000000C
  334. #define ARM_FAULT_STATUS_TYPE_SYNCHRONOUS_EXTERNAL_SECOND_LEVEL 0x0000000E
  335. #define ARM_FAULT_STATUS_TYPE_PARITY_FIRST_LEVEL 0x0000040C
  336. #define ARM_FAULT_STATUS_TYPE_PARITY_SECOND_LEVEL 0x0000040E
  337. #define ARM_FAULT_STATUS_TYPE_SECTION_TRANLSATION 0x00000005
  338. #define ARM_FAULT_STATUS_TYPE_PAGE_TRANSLATION 0x00000007
  339. #define ARM_FAULT_STATUS_TYPE_SECTION_ACCESS 0x00000003
  340. #define ARM_FAULT_STATUS_TYPE_PAGE_ACCESS 0x00000006
  341. #define ARM_FAULT_STATUS_TYPE_SECTION_DOMAIN 0x00000009
  342. #define ARM_FAULT_STATUS_TYPE_PAGE_DOMAIN 0x0000000B
  343. #define ARM_FAULT_STATUS_TYPE_SECTION_PERMISSION 0x0000000D
  344. #define ARM_FAULT_STATUS_TYPE_PAGE_PERMISSION 0x0000000F
  345. #define ARM_FAULT_STATUS_TYPE_DEBUG 0x00000002
  346. #define ARM_FAULT_STATUS_TYPE_SYNCHRONOUS_EXTERNAL 0x00000008
  347. #define ARM_FAULT_STATUS_TYPE_PARITY_MEMORY 0x00000409
  348. #define ARM_FAULT_STATUS_TYPE_ASYNCHRONOUS_EXTERNAL 0x00000406
  349. #define ARM_FAULT_STATUS_TYPE_ASYNCHRONOUS_PARITY 0x00000408
  350. //
  351. // Define ARM coprocessor access values.
  352. //
  353. #define ARM_COPROCESSOR_ACCESS_NONE 0x0
  354. #define ARM_COPROCESSOR_ACCESS_SUPERVISOR 0x1
  355. #define ARM_COPROCESSOR_ACCESS_FULL 0x3
  356. //
  357. // Define ARM floating point system ID (FPSID) register values.
  358. //
  359. #define ARM_FPSID_IMPLEMENTER_MASK 0xFF000000
  360. #define ARM_FPSID_IMPLEMENTER_SHIFT 24
  361. #define ARM_FPSID_IMPLEMENTER_ARM 0x41
  362. #define ARM_FPSID_SOFTWARE (1 << 23)
  363. #define ARM_FPSID_SUBARCHITECTURE_MASK 0x007F0000
  364. #define ARM_FPSID_SUBARCHITECTURE_SHIFT 16
  365. #define ARM_FPSID_SUBARCHITECTURE_VFPV1 0
  366. #define ARM_FPSID_SUBARCHITECTURE_VFPV2 1
  367. #define ARM_FPSID_SUBARCHITECTURE_VFPV3_COMMON_V2 2
  368. #define ARM_FPSID_SUBARCHITECTURE_VFPV3 3
  369. #define ARM_FPSID_SUBARCHITECTURE_VFPV3_COMMON_V3 4
  370. //
  371. // Define the FPU/SIMD extensions register values.
  372. //
  373. #define ARM_MVFR0_SIMD_REGISTERS_MASK 0x0000000F
  374. #define ARM_MVFR0_SIMD_REGISTERS_NONE 0
  375. #define ARM_MVFR0_SIMD_REGISTERS_16 1
  376. #define ARM_MVFR0_SIMD_REGISTERS_32 2
  377. //
  378. // Define the FPU/SIMD exception control register.
  379. //
  380. #define ARM_FPEXC_EXCEPTION 0x80000000
  381. #define ARM_FPEXC_ENABLE 0x40000000
  382. //
  383. // Define floating point status registers.
  384. //
  385. #define ARM_FPSCR_FLUSH_TO_ZERO (1 << 24)
  386. #define ARM_FPSCR_DEFAULT_NAN (1 << 25)
  387. //
  388. // Define the required alignment for FPU context.
  389. //
  390. #define FPU_CONTEXT_ALIGNMENT 16
  391. //
  392. // Define ARM Main ID register values.
  393. //
  394. #define ARM_MAIN_ID_IMPLEMENTOR_MASK 0xFF000000
  395. #define ARM_MAIN_ID_IMPLEMENTER_SHIFT 24
  396. #define ARM_MAIN_ID_VARIANT_MASK 0x00F00000
  397. #define ARM_MAIN_ID_VARIANT_SHIFT 20
  398. #define ARM_MAIN_ID_ARCHITECTURE_MASK 0x000F0000
  399. #define ARM_MAIN_ID_ARCHITECTURE_SHIFT 16
  400. #define ARM_MAIN_ID_PART_MASK 0x0000FFF0
  401. #define ARM_MAIN_ID_PART_SHIFT 4
  402. #define ARM_MAIN_ID_REVISION_MASK 0x0000000F
  403. #define ARM_MAIN_ID_ARCHITECTURE_ARMV4 1
  404. #define ARM_MAIN_ID_ARCHITECTURE_ARMV4T 2
  405. #define ARM_MAIN_ID_ARCHITECTURE_ARMV5 3
  406. #define ARM_MAIN_ID_ARCHITECTURE_ARMV5T 4
  407. #define ARM_MAIN_ID_ARCHITECTURE_ARMV5TE 5
  408. #define ARM_MAIN_ID_ARCHITECTURE_ARMV5TEJ 6
  409. #define ARM_MAIN_ID_ARCHITECTURE_ARMV6 7
  410. #define ARM_MAIN_ID_ARCHITECTURE_CPUID 0xF
  411. //
  412. // Define performance monitor control register bits.
  413. //
  414. #define PERF_CONTROL_CYCLE_COUNT_DIVIDE_64 0x00000008
  415. #define PERF_CONTROL_ENABLE 0x00000001
  416. //
  417. // Define the cycle counter performance monitor bit.
  418. //
  419. #define PERF_MONITOR_CYCLE_COUNTER 0x80000000
  420. //
  421. // Define the mask of all performance counter bits.
  422. //
  423. #define PERF_MONITOR_COUNTER_MASK 0xFFFFFFFF
  424. //
  425. // Define performance monitor user mode access enable bit.
  426. //
  427. #define PERF_USER_ACCESS_ENABLE 0x00000001
  428. //
  429. // Define the interrupt mask for the ARM1176 (ARMv6) PMCR.
  430. //
  431. #define ARMV6_PERF_MONITOR_INTERRUPT_MASK 0x00000070
  432. //
  433. // Define the size of an exception stack, in bytes.
  434. //
  435. #define EXCEPTION_STACK_SIZE 8
  436. //
  437. // Define the number of exception stacks that are needed (IRQ, FIQ, Abort,
  438. // and Undefined instruction).
  439. //
  440. #define EXCEPTION_STACK_COUNT 4
  441. //
  442. // Define which bits of the MPIDR are valid processor ID bits.
  443. //
  444. #define ARM_PROCESSOR_ID_MASK 0x00FFFFFF
  445. //
  446. // Define the Secure Configuration Register values.
  447. //
  448. #define SCR_NON_SECURE 0x00000001
  449. #define SCR_MONITOR_MODE_IRQ 0x00000002
  450. #define SCR_MONITOR_MODE_FIQ 0x00000004
  451. #define SCR_MONITOR_MODE_EXTERNAL_ABORT 0x00000008
  452. #define SCR_CPSR_FIQ_WRITABLE 0x00000010
  453. #define SCR_CPSR_ASYNC_ABORT_WRITABLE 0x00000020
  454. #define SCR_EARLY_TERMINATION_DISABLED 0x00000040
  455. #define SCR_NON_SECURE_SMC_DISABLED 0x00000080
  456. #define SCR_NON_SECURE_HVC_ENABLED 0x00000100
  457. #define SCR_NON_SECURE_INSTRUCTION_FETCH_DISABLED 0x00000200
  458. //
  459. // ------------------------------------------------------ Data Type Definitions
  460. //
  461. typedef
  462. KSTATUS
  463. (*PGET_NEXT_PC_READ_MEMORY_FUNCTION) (
  464. PVOID Address,
  465. ULONG Size,
  466. PVOID Data
  467. );
  468. /*++
  469. Routine Description:
  470. This routine attempts to read memory on behalf of the function trying to
  471. figure out what the next instruction will be.
  472. Arguments:
  473. Address - Supplies the virtual address that needs to be read.
  474. Size - Supplies the number of bytes to be read.
  475. Data - Supplies a pointer to the buffer where the read data will be
  476. returned on success.
  477. Return Value:
  478. Status code. STATUS_SUCCESS will only be returned if all the requested
  479. bytes could be read.
  480. --*/
  481. typedef
  482. BOOL
  483. (*PARM_HANDLE_EXCEPTION) (
  484. PTRAP_FRAME TrapFrame
  485. );
  486. /*++
  487. Routine Description:
  488. This routine is called to handle an ARM exception. Interrupts are disabled
  489. upon entry, and may be enabled during this function.
  490. Arguments:
  491. TrapFrame - Supplies a pointer to the exception trap frame.
  492. Return Value:
  493. TRUE if the exception was handled.
  494. FALSE if the exception was not handled.
  495. --*/
  496. /*++
  497. Structure Description:
  498. This structure defines the VFPv3 floating point state of the ARM
  499. architecture.
  500. Members:
  501. Registers - Stores the floating point state.
  502. --*/
  503. #pragma pack(push, 1)
  504. struct _FPU_CONTEXT {
  505. ULONGLONG Registers[32];
  506. ULONG Fpscr;
  507. } PACKED ALIGNED16;
  508. #pragma pack(pop)
  509. /*++
  510. Structure Description:
  511. This structure outlines a trap frame that will be generated during most
  512. interrupts and exceptions.
  513. Members:
  514. Registers - Stores the current state of the machine's registers. These
  515. values will be restored upon completion of the interrupt or exception.
  516. --*/
  517. struct _TRAP_FRAME {
  518. ULONG SvcSp;
  519. ULONG UserSp;
  520. ULONG UserLink;
  521. ULONG R0;
  522. ULONG ExceptionCpsr;
  523. ULONG R1;
  524. ULONG R2;
  525. ULONG R3;
  526. ULONG R4;
  527. ULONG R5;
  528. ULONG R6;
  529. ULONG R7;
  530. ULONG R8;
  531. ULONG R9;
  532. ULONG R10;
  533. ULONG R11;
  534. ULONG R12;
  535. ULONG SvcLink;
  536. ULONG Pc;
  537. ULONG Cpsr;
  538. };
  539. /*++
  540. Structure Description:
  541. This structure outlines the register state saved by the kernel when a
  542. user mode signal is dispatched. This generally contains 1) control
  543. registers which are clobbered by switching to the signal handler, and
  544. 2) volatile registers.
  545. Members:
  546. Common - Stores the common signal context information.
  547. TrapFrame - Stores the general register state.
  548. FpuContext - Stores the FPU state.
  549. --*/
  550. #pragma pack(push, 1)
  551. typedef struct _SIGNAL_CONTEXT_ARM {
  552. SIGNAL_CONTEXT Common;
  553. TRAP_FRAME TrapFrame;
  554. FPU_CONTEXT FpuContext;
  555. } PACKED SIGNAL_CONTEXT_ARM, *PSIGNAL_CONTEXT_ARM;
  556. #pragma pack(pop)
  557. /*++
  558. Structure Description:
  559. This structure contains the state of the processor, including both the
  560. non-volatile general registers and the system registers configured by the
  561. kernel. This structure is used in a manner similar to the C library
  562. setjmp/longjmp routines, the save context function appears to return
  563. twice. It returns once after the saving is complete, and then again with
  564. a different return value after restoring.
  565. Members:
  566. Pc - Stores the PC to branch to upon restore. By default this is
  567. initialized to the return address of the save/restore function, though
  568. it can be manipulated after the function returns.
  569. R0 - Stores the R0 register, also the return value from the restore
  570. operation. By default this is initialized to 1.
  571. R1 - Stores the R1 register, which can be used for a second argument in
  572. case this context is being manipulated.
  573. R2 - Stores the R2 register, which can be used for a third argument in
  574. case the PC is manipulated after save context returns.
  575. R3 - Stores the R3 register, which can be used for a third argument in
  576. case the PC is manipulated after save context returns.
  577. Cpsr - Stores the program status word (processor flags and mode).
  578. Sp - Stores the stack pointer (in SVC mode, which is assumed to be the
  579. current mode when the context was saved).
  580. R4 - Stores a non-volatile register.
  581. R5 - Stores a non-volatile register.
  582. R6 - Stores a non-volatile register.
  583. R7 - Stores a non-volatile register.
  584. R8 - Stores a non-volatile register.
  585. R9 - Stores a non-volatile register.
  586. R10 - Stores a non-volatile register.
  587. R11 - Stores a non-volatile register. R12 is volatile, and is not available
  588. since the restore code needs a register for its operation.
  589. UserLink - Stores the user mode link register.
  590. UserSp - Stores the user mode stack pointer.
  591. IrqLink - Stores the interrupt mode link register.
  592. IrqSp - Stores the interrupt link stack pointer.
  593. FiqLink - Stores the fast interrupt link register.
  594. FiqSp - Stores the fast interrupt stack pointer.
  595. AbortLink - Stores the abort mode link register.
  596. AbortSp - Stores the abort mode stack pointer.
  597. UndefLink - Stores the undefined instruction mode link pointer.
  598. UndefSp - Stores the undefined instruction mode stack pointer.
  599. VirtualAddress - Stores the virtual address of this structure member. The
  600. restore process might enable paging when the SCTLR is restored, so this
  601. contains the address to continue the restore from in virtual land.
  602. Sctlr - Stores the system control register.
  603. Ttbr0 - Stores the translation table base register 0.
  604. Ttbr1 - Stores the translation table base register 1.
  605. Actlr - Stores the auxiliary system control register.
  606. Cpacr - Stores the coprocessor access control register.
  607. Prrr - Stores the primary region remap register.
  608. Nmrr - Stores the normal memory remap register.
  609. ContextIdr - Stores the ASID register.
  610. Dfsr - Stores the data fault status register.
  611. Dfar - Store the data fault address register.
  612. Ifsr - Stores the instruction fault status register.
  613. Ifar - Stores the instruction fault address register.
  614. Dacr - Stores the domain access control register.
  615. Vbar - Stores the virtual base address register.
  616. Tpidrprw - Stores the privileged thread pointer register.
  617. Tpidruro - Stores the user read-only thread pointer register.
  618. Tpidrurw - Stores the user read-write thread pointer register.
  619. Pmcr - Stores the performance control register.
  620. Pminten - Stores the performance enabled interrupts.
  621. Pmuserenr - Stores the performance user enable register.
  622. Pmcnten - Stores the performance counter enable value.
  623. Pmccntr - Stores the cycle counter value.
  624. --*/
  625. struct _PROCESSOR_CONTEXT {
  626. ULONG Pc;
  627. ULONG R0;
  628. ULONG R1;
  629. ULONG R2;
  630. ULONG R3;
  631. ULONG Cpsr;
  632. ULONG Sp;
  633. ULONG R4;
  634. ULONG R5;
  635. ULONG R6;
  636. ULONG R7;
  637. ULONG R8;
  638. ULONG R9;
  639. ULONG R10;
  640. ULONG R11;
  641. ULONG UserLink;
  642. ULONG UserSp;
  643. ULONG IrqLink;
  644. ULONG IrqSp;
  645. ULONG FiqLink;
  646. ULONG FiqSp;
  647. ULONG AbortLink;
  648. ULONG AbortSp;
  649. ULONG UndefLink;
  650. ULONG UndefSp;
  651. ULONG VirtualAddress;
  652. ULONG Sctlr;
  653. ULONG Ttbr0;
  654. ULONG Ttbr1;
  655. ULONG Actlr;
  656. ULONG Cpacr;
  657. ULONG Prrr;
  658. ULONG Nmrr;
  659. ULONG ContextIdr;
  660. ULONG Dfsr;
  661. ULONG Dfar;
  662. ULONG Ifsr;
  663. ULONG Ifar;
  664. ULONG Dacr;
  665. ULONG Vbar;
  666. ULONG Tpidrprw;
  667. ULONG Tpidruro;
  668. ULONG Tpidrurw;
  669. ULONG Pmcr;
  670. ULONG Pminten;
  671. ULONG Pmuserenr;
  672. ULONG Pmcntenset;
  673. ULONG Pmccntr;
  674. };
  675. /*++
  676. Structure Description:
  677. This structure outlines an ARM interrupt dispatch table. The first half of
  678. this table is defined by the hardware, and contains instructions at known
  679. locations where the PC is snapped to when various types of exceptions occur.
  680. The second half of the table contains pointers to handler routines. The
  681. instructions in the table by default contain load PC instructions for the
  682. corresponding pointers. The locations of these pointers (but not their
  683. values) need to be kept near to the jump table because a ldr instruction
  684. can only reach so far.
  685. Members:
  686. ResetInstruction - Stores the instruction to execute on a Reset.
  687. UndefinedInstructionInstruction - Stores the instruction to execute
  688. upon encountering an undefined instruction.
  689. SoftwareInterruptInstruction - Stores the instruction to execute on a SWI
  690. instruction.
  691. PrefetchAbortInstruction - Stores the instruction to execute on an
  692. instruction fetch page fault.
  693. DataAbortInstruction - Stores the instruction to execute on a data access
  694. fault.
  695. Reserved - This space is reserved by the ARM ISA.
  696. IrqInstruction - Stores the instruction to execute on an IRQ interrupt.
  697. FiqInstruction - Stores the instruction to execute on an FIQ interrupt.
  698. UndefinedInstructionVector - Stores the address to jump to on encountering
  699. an undefined instruction. This is used for setting software
  700. breakpoints.
  701. SoftwareInterruptVector - Stores the address to jump to on encountering
  702. an SWI instruction. This is used for user to kernel transitions.
  703. PrefetchAbortVector - Stores the address to jump to on encountering an
  704. instruction fetch fault.
  705. DataAbortVector - Stores the address to jump to on encountering a data
  706. access fault.
  707. IrqVector - Stores the address to jump to on an IRQ interrupt.
  708. FiqVector - Stores the address to jump to on an FIQ interrupt.
  709. ResetVector - Stores the address to jump to on a reset.
  710. --*/
  711. typedef struct _ARM_INTERRUPT_TABLE {
  712. ULONG ResetInstruction;
  713. ULONG UndefinedInstructionInstruction;
  714. ULONG SoftwareInterruptInstruction;
  715. ULONG PrefetchAbortInstruction;
  716. ULONG DataAbortInstruction;
  717. ULONG Reserved;
  718. ULONG IrqInstruction;
  719. ULONG FiqInstruction;
  720. PVOID UndefinedInstructionVector;
  721. PVOID SoftwareInterruptVector;
  722. PVOID PrefetchAbortVector;
  723. PVOID DataAbortVector;
  724. PVOID IrqVector;
  725. PVOID FiqVector;
  726. PVOID ResetVector;
  727. } ARM_INTERRUPT_TABLE, *PARM_INTERRUPT_TABLE;
  728. /*++
  729. Structure Description:
  730. This structure describes the first level page table entry for a "Coarse
  731. Page Table". It is equivalent to a PDE for x86.
  732. Members:
  733. Format - Stores the format of this table entry, which should be set to
  734. 1 to describe this structure, a Coarse Page Table. Other formats
  735. include Section (2), and Fault (0). Not present entries should set this
  736. to 0 (Fault).
  737. Reserved - Set to 0.
  738. Domain - Stores the broad level domain this entry falls under.
  739. ImplementationDefined - Stores an implementation-defined bit.
  740. Entry - Stores the high 22 bits of the physical address for the second
  741. level page table. The low 12 bits are 0 because the second level page
  742. table must be page-aligned.
  743. --*/
  744. typedef struct _FIRST_LEVEL_TABLE {
  745. ULONG Format:2;
  746. ULONG Reserved:3;
  747. ULONG Domain:4;
  748. ULONG ImplementationDefined:1;
  749. ULONG Entry:22;
  750. } FIRST_LEVEL_TABLE, *PFIRST_LEVEL_TABLE;
  751. /*++
  752. Structure Description:
  753. This structure describes the second level page table entry format for "Small
  754. Pages", which are 4KB in size.
  755. Members:
  756. Format - Stores the format of the second level page table entry. For this
  757. structure, this should be set to 2 or 3 (Extended Small Page). Unmapped
  758. pages would be marked 0 (Fault). Large pages would be marked 1.
  759. CacheAttributes - Stores the caching attributes for the page. Options are
  760. uncached, shared device, write back, and write through.
  761. Access - Stores the access permissions for user mode and supervisor mode to
  762. the page.
  763. CacheTypeExtension - Stores extension bits to the caching attributes. Set
  764. to 0 for most cache types.
  765. AccessExtension - Stores the extension bit to the access attributes. Set to
  766. 0 for read-only modes and 1 for full access modes.
  767. Shared - Stores whether or not this page is shared among multiple processors
  768. or restricted to one. This only applies for normal memory, device
  769. memory uses the TEX + CB (CacheAttributes) bits.
  770. NotGlobal - Stores whether this page is global (0) or local to the current
  771. process.
  772. Entry - Stores the high 20 bits of the physical address of the "Small page".
  773. --*/
  774. typedef struct _SECOND_LEVEL_TABLE {
  775. ULONG Format:2;
  776. ULONG CacheAttributes:2;
  777. ULONG Access:2;
  778. ULONG CacheTypeExtension:3;
  779. ULONG AccessExtension:1;
  780. ULONG Shared:1;
  781. ULONG NotGlobal:1;
  782. ULONG Entry:20;
  783. } SECOND_LEVEL_TABLE, *PSECOND_LEVEL_TABLE;
  784. /*++
  785. Structure Description:
  786. This structure passes information about the ARM CPU Identification
  787. registers.
  788. Members:
  789. ProcessorFeatures - Stores a bitfield of processor features (ID_PFR0 and
  790. ID_PFR1).
  791. DebugFeatures - Stores a bitfield of debug hardware features (ID_DFR0).
  792. AuxiliaryFeatures - Stores an implementation-defined feature bitfield
  793. (ID_AFR0).
  794. MemoryModelFeatures - Stores bitfields of memory model features (ID_MMFR0,
  795. ID_MMFR1, ID_MMFR2, and ID_MMFR3).
  796. IsaFeatures - Stores bitfields about the supported instruction sets on
  797. this processor (ID_ISAR0, ID_ISAR1, ID_ISAR2, ID_ISAR3, ID_ISAR4, and
  798. ID_ISAR5).
  799. --*/
  800. #pragma pack(push, 1)
  801. typedef struct _ARM_CPUID {
  802. ULONG ProcessorFeatures[2];
  803. ULONG DebugFeatures;
  804. ULONG AuxiliaryFeatures;
  805. ULONG MemoryModelFeatures[4];
  806. ULONG IsaFeatures[6];
  807. } PACKED ARM_CPUID, *PARM_CPUID;
  808. #pragma pack(pop)
  809. /*++
  810. Structure Description:
  811. This structure defines the architecture specific form of an address space
  812. structure.
  813. Members:
  814. Common - Stores the common address space information.
  815. PageDirectory - Stores the virtual address of the top level page directory.
  816. PageDirectoryPhysical - Stores the physical address of the top level page
  817. directory.
  818. PageTableCount - Stores the number of page tables (4k) allocated on
  819. behalf of this process (user mode only).
  820. --*/
  821. typedef struct _ADDRESS_SPACE_ARM {
  822. ADDRESS_SPACE Common;
  823. PFIRST_LEVEL_TABLE PageDirectory;
  824. ULONG PageDirectoryPhysical;
  825. ULONG PageTableCount;
  826. } ADDRESS_SPACE_ARM, *PADDRESS_SPACE_ARM;
  827. //
  828. // -------------------------------------------------------------------- Globals
  829. //
  830. //
  831. // -------------------------------------------------------- Function Prototypes
  832. //
  833. ULONG
  834. ArGetCacheTypeRegister (
  835. VOID
  836. );
  837. /*++
  838. Routine Description:
  839. This routine retrieves the Cache Type Register (CTR) from the system
  840. coprocessor.
  841. Arguments:
  842. None.
  843. Return Value:
  844. Returns the value of the CTR.
  845. --*/
  846. VOID
  847. ArCleanInvalidateEntireCache (
  848. VOID
  849. );
  850. /*++
  851. Routine Description:
  852. This routine cleans and invalidates the entire data cache.
  853. Arguments:
  854. None.
  855. Return Value:
  856. None.
  857. --*/
  858. ULONG
  859. ArLockTlbEntry (
  860. ULONG TlbEntry,
  861. PVOID VirtualAddress,
  862. ULONG NextTlbEntry
  863. );
  864. /*++
  865. Routine Description:
  866. This routine locks a translation in the TLB. This translation will stick
  867. even across total TLB invalidates.
  868. Arguments:
  869. TlbEntry - Supplies the base and victim number of the TLB entry to lock.
  870. VirtualAddress - Supplies the virtual address that should be locked in the
  871. TLB. The association to physical address will be created by touching
  872. that address, so the address had better be mapped.
  873. NextTlbEntry - Supplies the base and victim number to set after locking the
  874. entry.
  875. Return Value:
  876. Returns the value of the lockdown register after the TLB miss was forced.
  877. The lowest bit of this value should be set. If it is not, this indicates
  878. that TLB lockdown is not supported.
  879. --*/
  880. VOID
  881. ArpInitializeExceptionStacks (
  882. PVOID ExceptionStacksBase,
  883. ULONG ExceptionStackSize
  884. );
  885. /*++
  886. Routine Description:
  887. This routine initializes the stack pointer for all privileged ARM modes. It
  888. switches into each mode and initializes the banked r13. This function
  889. should be called with interrupts disabled and returns with interrupts
  890. disabled.
  891. Arguments:
  892. ExceptionStacksBase - Supplies a pointer to the lowest address that should
  893. be used for exception stacks. Each stack takes up 16 bytes and there are
  894. 4 modes, so at least 64 bytes are needed.
  895. ExceptionStackSize - Supplies the size of each exception stack in bytes.
  896. Return Value:
  897. None.
  898. --*/
  899. VOID
  900. ArpInitializePerformanceMonitor (
  901. VOID
  902. );
  903. /*++
  904. Routine Description:
  905. This routine initializes the system's performance monitor.
  906. Arguments:
  907. None.
  908. Return Value:
  909. None.
  910. --*/
  911. VOID
  912. ArpUndefinedInstructionEntry (
  913. VOID
  914. );
  915. /*++
  916. Routine Description:
  917. This routine directly handles an exception generated by an undefined
  918. instruction.
  919. Arguments:
  920. None.
  921. Return Value:
  922. None.
  923. --*/
  924. INTN
  925. ArpSoftwareInterruptEntry (
  926. VOID
  927. );
  928. /*++
  929. Routine Description:
  930. This routine directly handles an exception generated by a software
  931. interrupt (a system call). Upon entry, R0 holds the system call number,
  932. and R1 holds the system call parameter.
  933. Arguments:
  934. None.
  935. Return Value:
  936. STATUS_SUCCESS or positive integer on success.
  937. Error status code on failure.
  938. --*/
  939. VOID
  940. ArpPrefetchAbortEntry (
  941. VOID
  942. );
  943. /*++
  944. Routine Description:
  945. This routine directly handles an exception generated by a prefetch abort
  946. (page fault).
  947. Arguments:
  948. None.
  949. Return Value:
  950. None.
  951. --*/
  952. VOID
  953. ArpDataAbortEntry (
  954. VOID
  955. );
  956. /*++
  957. Routine Description:
  958. This routine directly handles an exception generated by a data abort (page
  959. fault).
  960. Arguments:
  961. None.
  962. Return Value:
  963. None.
  964. --*/
  965. VOID
  966. ArpIrqEntry (
  967. VOID
  968. );
  969. /*++
  970. Routine Description:
  971. This routine directly handles an exception generated by an external
  972. interrupt on the IRQ pin.
  973. Arguments:
  974. None.
  975. Return Value:
  976. None.
  977. --*/
  978. VOID
  979. ArpFiqEntry (
  980. VOID
  981. );
  982. /*++
  983. Routine Description:
  984. This routine directly handles an exception generated by an external
  985. interrupt on the FIQ pin.
  986. Arguments:
  987. None.
  988. Return Value:
  989. None.
  990. --*/
  991. PVOID
  992. ArGetDataFaultingAddress (
  993. VOID
  994. );
  995. /*++
  996. Routine Description:
  997. This routine determines which address caused a data abort.
  998. Arguments:
  999. None.
  1000. Return Value:
  1001. Returns the faulting address.
  1002. --*/
  1003. VOID
  1004. ArSetDataFaultingAddress (
  1005. PVOID Value
  1006. );
  1007. /*++
  1008. Routine Description:
  1009. This routine sets the data faulting address register (DFAR).
  1010. Arguments:
  1011. Value - Supplies the value to set.
  1012. Return Value:
  1013. None.
  1014. --*/
  1015. PVOID
  1016. ArGetInstructionFaultingAddress (
  1017. VOID
  1018. );
  1019. /*++
  1020. Routine Description:
  1021. This routine determines which address caused a prefetch abort.
  1022. Arguments:
  1023. None.
  1024. Return Value:
  1025. Returns the faulting address.
  1026. --*/
  1027. VOID
  1028. ArSetInstructionFaultingAddress (
  1029. PVOID Value
  1030. );
  1031. /*++
  1032. Routine Description:
  1033. This routine sets the instruction faulting address register (IFAR).
  1034. Arguments:
  1035. Value - Supplies the value to set.
  1036. Return Value:
  1037. None.
  1038. --*/
  1039. ULONG
  1040. ArGetDataFaultStatus (
  1041. VOID
  1042. );
  1043. /*++
  1044. Routine Description:
  1045. This routine determines the reason for the fault by reading the DFSR
  1046. register.
  1047. Arguments:
  1048. None.
  1049. Return Value:
  1050. Returns the contents of the Data Fault Status Register.
  1051. --*/
  1052. VOID
  1053. ArSetDataFaultStatus (
  1054. ULONG Value
  1055. );
  1056. /*++
  1057. Routine Description:
  1058. This routine sets the data fault status register (DFSR).
  1059. Arguments:
  1060. Value - Supplies the value to set.
  1061. Return Value:
  1062. None.
  1063. --*/
  1064. ULONG
  1065. ArGetInstructionFaultStatus (
  1066. VOID
  1067. );
  1068. /*++
  1069. Routine Description:
  1070. This routine determines the reason for the prefetch abort by reading the
  1071. IFAR register.
  1072. Arguments:
  1073. None.
  1074. Return Value:
  1075. Returns the contents of the Instruction Fault Status Register.
  1076. --*/
  1077. VOID
  1078. ArSetInstructionFaultStatus (
  1079. ULONG Value
  1080. );
  1081. /*++
  1082. Routine Description:
  1083. This routine sets the instruction fault status register (IFSR).
  1084. Arguments:
  1085. Value - Supplies the value to set.
  1086. Return Value:
  1087. None.
  1088. --*/
  1089. VOID
  1090. ArCpuid (
  1091. PARM_CPUID Features
  1092. );
  1093. /*++
  1094. Routine Description:
  1095. This routine returns the set of processor features present on the current
  1096. processor.
  1097. Arguments:
  1098. Features - Supplies a pointer where the processor feature register values
  1099. will be returned.
  1100. Return Value:
  1101. None.
  1102. --*/
  1103. ULONG
  1104. ArGetSystemControlRegister (
  1105. VOID
  1106. );
  1107. /*++
  1108. Routine Description:
  1109. This routine returns the MMU system control register (SCTLR).
  1110. Arguments:
  1111. None.
  1112. Return Value:
  1113. Returns the current SCTLR value.
  1114. --*/
  1115. VOID
  1116. ArSetSystemControlRegister (
  1117. ULONG NewValue
  1118. );
  1119. /*++
  1120. Routine Description:
  1121. This routine sets the MMU system control register (SCTLR).
  1122. Arguments:
  1123. NewValue - Supplies the value to set as the new MMU SCTLR.
  1124. Return Value:
  1125. None.
  1126. --*/
  1127. ULONG
  1128. ArGetAuxiliaryControlRegister (
  1129. VOID
  1130. );
  1131. /*++
  1132. Routine Description:
  1133. This routine returns the auxiliary system control register (ACTLR).
  1134. Arguments:
  1135. None.
  1136. Return Value:
  1137. Returns the current value.
  1138. --*/
  1139. VOID
  1140. ArSetAuxiliaryControlRegister (
  1141. ULONG NewValue
  1142. );
  1143. /*++
  1144. Routine Description:
  1145. This routine sets the auxiliary system control register (ACTLR).
  1146. Arguments:
  1147. NewValue - Supplies the value to set.
  1148. Return Value:
  1149. None.
  1150. --*/
  1151. PVOID
  1152. ArGetVectorBaseAddress (
  1153. VOID
  1154. );
  1155. /*++
  1156. Routine Description:
  1157. This routine gets the vector base address register (VBAR) which determines
  1158. where the ARM exception vector table starts.
  1159. Arguments:
  1160. None.
  1161. Return Value:
  1162. Returns the current VBAR.
  1163. --*/
  1164. VOID
  1165. ArSetVectorBaseAddress (
  1166. PVOID VectorBaseAddress
  1167. );
  1168. /*++
  1169. Routine Description:
  1170. This routine sets the vector base address register (VBAR) which determines
  1171. where the ARM exception vector table starts.
  1172. Arguments:
  1173. VectorBaseAddress - Supplies a pointer to the ARM exception vector base
  1174. address. This value must be 32-byte aligned.
  1175. Return Value:
  1176. None.
  1177. --*/
  1178. PVOID
  1179. ArGetProcessorBlockRegister (
  1180. VOID
  1181. );
  1182. /*++
  1183. Routine Description:
  1184. This routine gets the register used to store a pointer to the processor
  1185. block (TPIDRPRW in the ARMARM; Thread and Process ID Registers in the
  1186. ARM1176 TRM).
  1187. Arguments:
  1188. None.
  1189. Return Value:
  1190. Returns a pointer to the processor block.
  1191. --*/
  1192. PVOID
  1193. ArGetProcessorBlockRegisterForDebugger (
  1194. VOID
  1195. );
  1196. /*++
  1197. Routine Description:
  1198. This routine gets the register used to store a pointer to the processor
  1199. block (TPIDRPRW in the ARMARM; Thread and Process ID Registers in the
  1200. ARM1176 TRM). This routine is called inside the debugger.
  1201. Arguments:
  1202. None.
  1203. Return Value:
  1204. Returns a pointer to the processor block.
  1205. --*/
  1206. VOID
  1207. ArSetProcessorBlockRegister (
  1208. PVOID ProcessorBlockRegisterValue
  1209. );
  1210. /*++
  1211. Routine Description:
  1212. This routine sets the register used to store a pointer to the processor
  1213. block (TPIDRPRW in the ARMARM; Thread and Process ID Registers in the
  1214. ARM1176 TRM).
  1215. Arguments:
  1216. ProcessorBlockRegisterValue - Supplies the value to assign to the register
  1217. used to store the processor block.
  1218. Return Value:
  1219. None.
  1220. --*/
  1221. UINTN
  1222. ArDereferenceProcessorBlock (
  1223. UINTN Offset
  1224. );
  1225. /*++
  1226. Routine Description:
  1227. This routine performs a native integer read of the processor block plus
  1228. a given offset. The C equivalent of this would be
  1229. *((PUINTN)(ProcessorBlock + Offset)).
  1230. Arguments:
  1231. Offset - Supplies the offset into the processor block to read.
  1232. Return Value:
  1233. Returns the native integer read at the given address.
  1234. --*/
  1235. ULONG
  1236. ArGetTranslationTableBaseRegister0 (
  1237. VOID
  1238. );
  1239. /*++
  1240. Routine Description:
  1241. This routine gets the translation table base register 0 (TTBR0), used as
  1242. the base for all virtual to physical memory lookups.
  1243. Arguments:
  1244. None.
  1245. Return Value:
  1246. Returns the contents of TTBR0.
  1247. --*/
  1248. VOID
  1249. ArSetTranslationTableBaseRegister0 (
  1250. ULONG Value
  1251. );
  1252. /*++
  1253. Routine Description:
  1254. This routine sets the translation table base register 0 (TTBR0).
  1255. Arguments:
  1256. Value - Supplies the value to write.
  1257. Return Value:
  1258. None.
  1259. --*/
  1260. ULONG
  1261. ArGetTranslationTableBaseRegister1 (
  1262. VOID
  1263. );
  1264. /*++
  1265. Routine Description:
  1266. This routine gets the translation table base register 1 (TTBR1).
  1267. Arguments:
  1268. None.
  1269. Return Value:
  1270. Returns the contents of TTBR1.
  1271. --*/
  1272. VOID
  1273. ArSetTranslationTableBaseRegister1 (
  1274. ULONG Value
  1275. );
  1276. /*++
  1277. Routine Description:
  1278. This routine sets the translation table base register 1 (TTBR1).
  1279. Arguments:
  1280. Value - Supplies the value to write.
  1281. Return Value:
  1282. None.
  1283. --*/
  1284. ULONG
  1285. ArGetPrimaryRegionRemapRegister (
  1286. VOID
  1287. );
  1288. /*++
  1289. Routine Description:
  1290. This routine gets the Primary Region Remap Register (PRRR).
  1291. Arguments:
  1292. None.
  1293. Return Value:
  1294. Returns the contents of the register.
  1295. --*/
  1296. VOID
  1297. ArSetPrimaryRegionRemapRegister (
  1298. ULONG Value
  1299. );
  1300. /*++
  1301. Routine Description:
  1302. This routine sets the PRRR.
  1303. Arguments:
  1304. Value - Supplies the value to write.
  1305. Return Value:
  1306. None.
  1307. --*/
  1308. ULONG
  1309. ArGetNormalMemoryRemapRegister (
  1310. VOID
  1311. );
  1312. /*++
  1313. Routine Description:
  1314. This routine gets the Normal Memory Remap Register (NMRR).
  1315. Arguments:
  1316. None.
  1317. Return Value:
  1318. Returns the contents of the register.
  1319. --*/
  1320. VOID
  1321. ArSetNormalMemoryRemapRegister (
  1322. ULONG Value
  1323. );
  1324. /*++
  1325. Routine Description:
  1326. This routine sets the NMRR.
  1327. Arguments:
  1328. Value - Supplies the value to write.
  1329. Return Value:
  1330. None.
  1331. --*/
  1332. ULONG
  1333. ArGetPhysicalAddressRegister (
  1334. VOID
  1335. );
  1336. /*++
  1337. Routine Description:
  1338. This routine gets the Physical Address Register (PAR).
  1339. Arguments:
  1340. None.
  1341. Return Value:
  1342. Returns the contents of the register.
  1343. --*/
  1344. VOID
  1345. ArSetPhysicalAddressRegister (
  1346. ULONG Value
  1347. );
  1348. /*++
  1349. Routine Description:
  1350. This routine sets the Physical Address Register (PAR).
  1351. Arguments:
  1352. Value - Supplies the value to write.
  1353. Return Value:
  1354. None.
  1355. --*/
  1356. VOID
  1357. ArSetPrivilegedReadTranslateRegister (
  1358. ULONG Value
  1359. );
  1360. /*++
  1361. Routine Description:
  1362. This routine sets the Privileged Read address translation command register.
  1363. Arguments:
  1364. Value - Supplies the value to write.
  1365. Return Value:
  1366. None.
  1367. --*/
  1368. VOID
  1369. ArSetPrivilegedWriteTranslateRegister (
  1370. ULONG Value
  1371. );
  1372. /*++
  1373. Routine Description:
  1374. This routine sets the Privileged Write address translation command register.
  1375. Arguments:
  1376. Value - Supplies the value to write.
  1377. Return Value:
  1378. None.
  1379. --*/
  1380. VOID
  1381. ArSetUnprivilegedReadTranslateRegister (
  1382. ULONG Value
  1383. );
  1384. /*++
  1385. Routine Description:
  1386. This routine sets the Unrivileged Read address translation command register.
  1387. Arguments:
  1388. Value - Supplies the value to write.
  1389. Return Value:
  1390. None.
  1391. --*/
  1392. VOID
  1393. ArSetUnprivilegedWriteTranslateRegister (
  1394. ULONG Value
  1395. );
  1396. /*++
  1397. Routine Description:
  1398. This routine sets the Unprivileged Write address translation command
  1399. register.
  1400. Arguments:
  1401. Value - Supplies the value to write.
  1402. Return Value:
  1403. None.
  1404. --*/
  1405. ULONG
  1406. ArGetMultiprocessorIdRegister (
  1407. VOID
  1408. );
  1409. /*++
  1410. Routine Description:
  1411. This routine gets the Multiprocessor ID register (MPIDR).
  1412. Arguments:
  1413. None.
  1414. Return Value:
  1415. Returns the value of the MPIDR.
  1416. --*/
  1417. ULONG
  1418. ArTranslateVirtualToPhysical (
  1419. PVOID VirtualAddress
  1420. );
  1421. /*++
  1422. Routine Description:
  1423. This routine translates a virtual address to its corresponding physical
  1424. address by using the current translation tables.
  1425. Arguments:
  1426. VirtualAddress - Supplies the virtual address to translate.
  1427. Return Value:
  1428. Returns the physical address that the virtual address corresponds to
  1429. (with some bits at the bottom relating to the cache type).
  1430. --*/
  1431. VOID
  1432. ArSetThreadPointerUserReadOnly (
  1433. PVOID NewPointer
  1434. );
  1435. /*++
  1436. Routine Description:
  1437. This routine sets the TPIDRURO user-mode-read-only thread pointer register.
  1438. Arguments:
  1439. NewPointer - Supplies the value to write.
  1440. Return Value:
  1441. None.
  1442. --*/
  1443. ULONG
  1444. ArGetThreadPointerUser (
  1445. VOID
  1446. );
  1447. /*++
  1448. Routine Description:
  1449. This routine sets the TPIDRURW user-mode thread pointer register.
  1450. Arguments:
  1451. None.
  1452. Return Value:
  1453. Returns the current value of the TPIDRURW.
  1454. --*/
  1455. VOID
  1456. ArSwitchTtbr0 (
  1457. ULONG NewValue
  1458. );
  1459. /*++
  1460. Routine Description:
  1461. This routine performs the proper sequence for changing contexts in TTBR0,
  1462. including the necessary invalidates and barriers.
  1463. Arguments:
  1464. NewValue - Supplies the new value to write.
  1465. Return Value:
  1466. None.
  1467. --*/
  1468. ULONG
  1469. ArGetPerformanceControlRegister (
  1470. VOID
  1471. );
  1472. /*++
  1473. Routine Description:
  1474. This routine retrieves the PMCR (Performance Monitor Control Register).
  1475. Arguments:
  1476. None.
  1477. Return Value:
  1478. Returns the value of the PMCR.
  1479. --*/
  1480. VOID
  1481. ArSetPerformanceControlRegister (
  1482. ULONG Value
  1483. );
  1484. /*++
  1485. Routine Description:
  1486. This routine sets the PMCR (Performance Monitor Control Register).
  1487. Arguments:
  1488. Value - Supplies the value to set in the PMCR.
  1489. Return Value:
  1490. None.
  1491. --*/
  1492. VOID
  1493. ArClearPerformanceInterruptRegister (
  1494. ULONG Value
  1495. );
  1496. /*++
  1497. Routine Description:
  1498. This routine sets the PMINTENCLR (Performance Monitor Interrupt Clear)
  1499. register.
  1500. Arguments:
  1501. Value - Supplies the value to set in the PMINTENCLR.
  1502. Return Value:
  1503. None.
  1504. --*/
  1505. VOID
  1506. ArSetPerformanceUserEnableRegister (
  1507. ULONG Value
  1508. );
  1509. /*++
  1510. Routine Description:
  1511. This routine sets the PMUSERENR (Performance Monitor User Enable Register).
  1512. Arguments:
  1513. Value - Supplies the value to set in the PMUSERENR.
  1514. Return Value:
  1515. None.
  1516. --*/
  1517. ULONG
  1518. ArGetPerformanceCounterEnableRegister (
  1519. VOID
  1520. );
  1521. /*++
  1522. Routine Description:
  1523. This routine retrieves the PMCNTENSET (Performance Monitor Counter Enable
  1524. Set) register.
  1525. Arguments:
  1526. None.
  1527. Return Value:
  1528. Returns the value of the PMCNTENSET.
  1529. --*/
  1530. VOID
  1531. ArSetPerformanceCounterEnableRegister (
  1532. ULONG Value
  1533. );
  1534. /*++
  1535. Routine Description:
  1536. This routine sets the PMCNTENSET (Performance Monitor Counter Enable
  1537. Set) register.
  1538. Arguments:
  1539. Value - Supplies the value to set in the PMCNTENSET register.
  1540. Return Value:
  1541. None.
  1542. --*/
  1543. ULONG
  1544. ArGetCycleCountRegister (
  1545. VOID
  1546. );
  1547. /*++
  1548. Routine Description:
  1549. This routine retrieves the PMCCNTR (Performance Monitor Cycle Counter)
  1550. register.
  1551. Arguments:
  1552. None.
  1553. Return Value:
  1554. Returns the value of the PMCCNTR.
  1555. --*/
  1556. VOID
  1557. ArSetCycleCountRegister (
  1558. ULONG Value
  1559. );
  1560. /*++
  1561. Routine Description:
  1562. This routine sets the PMCCNTR (Performance Monitor Cycle Counter) register.
  1563. Arguments:
  1564. Value - Supplies the value to set in the PMCCNTR register.
  1565. Return Value:
  1566. None.
  1567. --*/
  1568. KSTATUS
  1569. ArGetNextPc (
  1570. PTRAP_FRAME TrapFrame,
  1571. PGET_NEXT_PC_READ_MEMORY_FUNCTION ReadMemoryFunction,
  1572. PBOOL IsFunctionReturning,
  1573. PVOID *NextPcValue
  1574. );
  1575. /*++
  1576. Routine Description:
  1577. This routine attempts to predict the next instruction to be executed. It
  1578. will decode the current instruction, check if the condition matches, and
  1579. attempt to follow any branches.
  1580. Arguments:
  1581. TrapFrame - Supplies a pointer to the current machine state.
  1582. ReadMemoryFunction - Supplies a pointer to a function this routine can
  1583. call when it needs to read target memory.
  1584. IsFunctionReturning - Supplies an optional pointer where a boolean will be
  1585. stored indicating if the current instruction is a return of some kind.
  1586. NextPcValue - Supplies a pointer of the next executing address.
  1587. Return Value:
  1588. Status code. This routine will attempt to make a guess at the next PC even
  1589. if the status code is failing, but chances it's right go way down if a
  1590. failing status is returned.
  1591. --*/
  1592. VOID
  1593. ArBackUpIfThenState (
  1594. PTRAP_FRAME TrapFrame
  1595. );
  1596. /*++
  1597. Routine Description:
  1598. This routine backs up the Thumb if-then state in the CPSR by one
  1599. instruction, assuming that the previous instruction tested positively for
  1600. being executed.
  1601. Arguments:
  1602. TrapFrame - Supplies a pointer to the current machine state.
  1603. Return Value:
  1604. Status code. This routine will attempt to make a guess at the next PC even
  1605. if the status code is failing, but chances it's right go way down if a
  1606. failing status is returned.
  1607. --*/
  1608. ULONG
  1609. ArGetMainIdRegister (
  1610. VOID
  1611. );
  1612. /*++
  1613. Routine Description:
  1614. This routine gets the Main ID Register (MIDR).
  1615. Arguments:
  1616. None.
  1617. Return Value:
  1618. Returns the contents of the register.
  1619. --*/
  1620. ULONG
  1621. ArGetCoprocessorAccessRegister (
  1622. VOID
  1623. );
  1624. /*++
  1625. Routine Description:
  1626. This routine gets the Coprocessor Access Control Register (CPACR).
  1627. Arguments:
  1628. None.
  1629. Return Value:
  1630. Returns the contents of the register.
  1631. --*/
  1632. VOID
  1633. ArSetCoprocessorAccessRegister (
  1634. ULONG Value
  1635. );
  1636. /*++
  1637. Routine Description:
  1638. This routine sets the Coprocessor Access Control Register (CPACR).
  1639. Arguments:
  1640. Value - Supplies the value to write.
  1641. Return Value:
  1642. None.
  1643. --*/
  1644. ULONG
  1645. ArGetFloatingPointIdRegister (
  1646. VOID
  1647. );
  1648. /*++
  1649. Routine Description:
  1650. This routine gets the Floating Point unit ID register (FPSID).
  1651. Arguments:
  1652. None.
  1653. Return Value:
  1654. Returns the contents of the register.
  1655. --*/
  1656. ULONG
  1657. ArGetMvfr0Register (
  1658. VOID
  1659. );
  1660. /*++
  1661. Routine Description:
  1662. This routine gets the floating point extensions identification register
  1663. (MVFR0).
  1664. Arguments:
  1665. None.
  1666. Return Value:
  1667. Returns the contents of the register.
  1668. --*/
  1669. ULONG
  1670. ArGetVfpExceptionRegister (
  1671. VOID
  1672. );
  1673. /*++
  1674. Routine Description:
  1675. This routine gets the floating point exception control register (FPEXC).
  1676. Arguments:
  1677. None.
  1678. Return Value:
  1679. Returns the contents of the register.
  1680. --*/
  1681. VOID
  1682. ArSetVfpExceptionRegister (
  1683. ULONG Value
  1684. );
  1685. /*++
  1686. Routine Description:
  1687. This routine sets the floating point exception control register (FPEXC).
  1688. Arguments:
  1689. Value - Supplies the new value to set.
  1690. Return Value:
  1691. None.
  1692. --*/
  1693. ULONG
  1694. ArGetVfpInstructionRegister (
  1695. VOID
  1696. );
  1697. /*++
  1698. Routine Description:
  1699. This routine gets the floating point instruction register (FPINST).
  1700. Arguments:
  1701. None.
  1702. Return Value:
  1703. Returns the contents of the register.
  1704. --*/
  1705. ULONG
  1706. ArGetFpscr (
  1707. VOID
  1708. );
  1709. /*++
  1710. Routine Description:
  1711. This routine gets the floating point status and control register (FPSCR).
  1712. Arguments:
  1713. None.
  1714. Return Value:
  1715. Returns the contents of the register.
  1716. --*/
  1717. VOID
  1718. ArSaveVfp (
  1719. PFPU_CONTEXT Context,
  1720. BOOL SimdSupport
  1721. );
  1722. /*++
  1723. Routine Description:
  1724. This routine saves the Vector Floating Point unit state.
  1725. Arguments:
  1726. Context - Supplies a pointer where the context will be saved.
  1727. SimdSupport - Supplies a boolean indicating whether the VFP unit contains
  1728. 32 64-bit registers (TRUE) or 16 64-bit registers (FALSE).
  1729. Return Value:
  1730. None.
  1731. --*/
  1732. VOID
  1733. ArRestoreVfp (
  1734. PFPU_CONTEXT Context,
  1735. BOOL SimdSupport
  1736. );
  1737. /*++
  1738. Routine Description:
  1739. This routine restores the Vector Floating Point unit state into the
  1740. hardware.
  1741. Arguments:
  1742. Context - Supplies a pointer to the context to restore.
  1743. SimdSupport - Supplies a boolean indicating whether the VFP unit contains
  1744. 32 64-bit registers (TRUE) or 16 64-bit registers (FALSE).
  1745. Return Value:
  1746. None.
  1747. --*/
  1748. VOID
  1749. ArInitializeVfpSupport (
  1750. VOID
  1751. );
  1752. /*++
  1753. Routine Description:
  1754. This routine initializes processor support for the VFP unit, and sets the
  1755. related feature bits in the user shared data.
  1756. Arguments:
  1757. None.
  1758. Return Value:
  1759. None.
  1760. --*/
  1761. VOID
  1762. ArSaveFpuState (
  1763. PFPU_CONTEXT Buffer
  1764. );
  1765. /*++
  1766. Routine Description:
  1767. This routine saves the current FPU context into the given buffer.
  1768. Arguments:
  1769. Buffer - Supplies a pointer to the buffer where the information will be
  1770. saved to.
  1771. Return Value:
  1772. None.
  1773. --*/
  1774. BOOL
  1775. ArCheckForVfpException (
  1776. PTRAP_FRAME TrapFrame,
  1777. ULONG Instruction
  1778. );
  1779. /*++
  1780. Routine Description:
  1781. This routine checks for VFP or NEON undefined instruction faults, and
  1782. potentially handles them if found.
  1783. Arguments:
  1784. TrapFrame - Supplies a pointer to the state immediately before the
  1785. exception.
  1786. Instruction - Supplies the instruction that caused the abort.
  1787. Return Value:
  1788. None.
  1789. --*/
  1790. VOID
  1791. ArDisableFpu (
  1792. VOID
  1793. );
  1794. /*++
  1795. Routine Description:
  1796. This routine disallows access to the FPU on the current processor, causing
  1797. all future accesses to generate exceptions.
  1798. Arguments:
  1799. None.
  1800. Return Value:
  1801. None.
  1802. --*/