12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183 |
- /*++
- Copyright (c) 2014 Minoca Corp. All Rights Reserved
- Module Name:
- commsup.S
- Abstract:
- This module implements ARM processor architecture features not
- implementable in C that are common to all ARM architectures.
- Author:
- Chris Stevens 19-Mar-2014
- Environment:
- Kernel mode
- --*/
- ##
- ## ------------------------------------------------------------------ Includes
- ##
- #include <minoca/kernel/arm.inc>
- ##
- ## --------------------------------------------------------------- Definitions
- ##
- ##
- ## ---------------------------------------------------------------------- Code
- ##
- ASSEMBLY_FILE_HEADER
- .fpu vfpv3
- ##
- ## KERNEL_API
- ## BOOL
- ## ArDisableInterrupts (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine disables all interrupts on the current processor.
- Arguments:
- None.
- Return Value:
- TRUE if interrupts were previously enabled on the processor.
- FALSE if interrupts were not previously enabled on the processor.
- --*/
- PROTECTED_FUNCTION ArDisableInterrupts
- mrs %r1, CPSR @ Get the status register.
- cpsid i @ Disable interrupts.
- mov %r0, #0 @ Assume interrupts disabled.
- tst %r1, #PSR_FLAG_IRQ @ AND the interrupt flag.
- IT(eq) @ If the zero flag is set...
- moveq %r0, #1 @ Interrupts were enabled.
- bx %lr @ Return.
- END_FUNCTION ArDisableInterrupts
- ##
- ## KERNEL_API
- ## VOID
- ## ArEnableInterrupts (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine enables interrupts on the current processor.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- PROTECTED_FUNCTION ArEnableInterrupts
- cpsie i @ Enable interrupts.
- bx %lr @
- END_FUNCTION ArEnableInterrupts
- ##
- ## KERNEL_API
- ## BOOL
- ## ArAreInterruptsEnabled (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine determines whether or not interrupts are currently enabled
- on the processor.
- Arguments:
- None.
- Return Value:
- TRUE if interrupts are enabled in the processor.
- FALSE if interrupts are globally disabled.
- --*/
- PROTECTED_FUNCTION ArAreInterruptsEnabled
- mrs %r1, CPSR @ Get the status register.
- mov %r0, #0 @ Assume interrupts disabled.
- tst %r1, #PSR_FLAG_IRQ @ AND the interrupt flag.
- IT(eq) @ If the zero flag is set...
- moveq %r0, #1 @ Interrupts were enabled.
- bx %lr @ Return.
- END_FUNCTION ArAreInterruptsEnabled
- ##
- ## ULONG
- ## ArGetProcessorFlags (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine gets the current processor's flags register.
- Arguments:
- None.
- Return Value:
- Returns the current flags.
- --*/
- FUNCTION ArGetProcessorFlags
- mrs %r0, CPSR @ Get the status register.
- bx %lr @
- END_FUNCTION ArGetProcessorFlags
- ##
- ## ULONG
- ## ArGetCacheTypeRegister (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine retrives the Cache Type Register (CTR) from the system
- coprocessor.
- Arguments:
- None.
- Return Value:
- Returns the value of the CTR.
- --*/
- FUNCTION ArGetCacheTypeRegister
- mrc p15, 0, %r0, %cr0, %cr0, 1 @ Read the CTR.
- bx %lr @
- END_FUNCTION ArGetCacheTypeRegister
- ##
- ## VOID
- ## ArInvalidateInstructionCache (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine invalidate the processor's instruction only cache, indicating
- that a page containing code has changed.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- FUNCTION ArInvalidateInstructionCache
- DSB
- mcr p15, 0, %r0, c7, c5, 0 @ ICIALLU, Invalidate I-Cache.
- DSB @ Make instructions finish.
- ISB @ Prevent speculative fetching.
- bx %lr @ Return
- END_FUNCTION ArInvalidateInstructionCache
- ##
- ## VOID
- ## ArInvalidateTlbEntry (
- ## PVOID Address
- ## )
- ##
- /*++
- Routine Description:
- This routine invalidates one TLB entry corresponding to the given virtual
- address.
- Arguments:
- Address - Supplies the virtual address whose associated TLB entry will be
- invalidated.
- Return Value:
- None.
- --*/
- FUNCTION ArInvalidateTlbEntry
- DSB @ Ensure changes are visible.
- mcr p15, 0, %r0, %cr8, %cr7, 1 @ Write to TLBIMVA.
- BPIALL @ Write to BPIALL (branch pred).
- DSB @ Data synchronization barrier.
- ISB @ Instruction sync barrier.
- bx %lr @
- END_FUNCTION ArInvalidateTlbEntry
- ##
- ## VOID
- ## ArInvalidateEntireTlb (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine invalidates the entire TLB.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- FUNCTION ArInvalidateEntireTlb
- DSB @ Ensure changes are visible.
- mcr p15, 0, %r0, c8, c7, 0 @ TLBIALL (invalidate TLB).
- BPIALL @ Write to BPIALL (branch pred).
- DSB @ Data synchronization barrier.
- ISB @ Instruction sync barrier.
- bx %lr @
- END_FUNCTION ArInvalidateEntireTlb
- ##
- ## ULONG
- ## ArLockTlbEntry (
- ## ULONG TlbEntry,
- ## PVOID VirtualAddress,
- ## ULONG NextTlbEntry
- ## )
- ##
- /*++
- Routine Description:
- This routine locks a translation in the TLB. This translation will stick
- even across total TLB invalidates.
- Arguments:
- TlbEntry - Supplies the base and victim number of the TLB entry to lock.
- VirtualAddress - Supplies the virtual address that should be locked in the
- TLB. The association to physical address will be created by touching
- that address, so the address had better be mapped.
- NextTlbEntry - Supplies the base and victim number to set after locking the
- entry.
- Return Value:
- Returns the value of the lockdown register after the TLB miss was forced.
- The lowest bit of this value should be set. If it is not, this indicates
- that TLB lockdown is not supported.
- --*/
- FUNCTION ArLockTlbEntry
- orr %r0, %r0, #1 @ Set lock flag.
- mcr p15, 0, %r1, %cr8, %cr7, 1 @ Invalidate the TLB entry.
- mcr p15, 0, %r0, %cr10, %cr0, 0 @ Write lockdown register.
- mcr p15, 0, %r1, %cr10, %cr1, 0 @ Prefetch data TLB.
- ldr %r3, [%r1] @ Also do standard load.
- mrc p15, 0, %r0, %cr10, %cr0, 0 @ Read the lockdown register.
- bic %r2, %r2, #1 @ Clear lock flag.
- mcr p15, 0, %r2, %cr10, %cr0, 0 @ Write lockdown register.
- DSB @ Make instructions finish.
- ISB @ Prevent speculative fetching.
- bx %lr @ Return.
- END_FUNCTION ArLockTlbEntry
- ##
- ## VOID
- ## ArSerializeExecution (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine acts a serializing instruction, preventing the processor
- from speculatively executing beyond this point.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- FUNCTION ArSerializeExecution
- DSB
- ISB
- bx %lr
- END_FUNCTION ArSerializeExecution
- ##
- ## PVOID
- ## ArGetDataFaultingAddress (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine determines which address caused a data abort.
- Arguments:
- None.
- Return Value:
- Returns the faulting address.
- --*/
- FUNCTION ArGetDataFaultingAddress
- mrc p15, 0, %r0, %cr6, %cr0, 0 @ Get the combined/data FAR.
- bx %lr @
- END_FUNCTION ArGetDataFaultingAddress
- ##
- ## VOID
- ## ArSetDataFaultingAddress (
- ## PVOID Value
- ## )
- ##
- /*++
- Routine Description:
- This routine sets the data faulting address register (DFAR).
- Arguments:
- Value - Supplies the value to set.
- Return Value:
- None.
- --*/
- FUNCTION ArSetDataFaultingAddress
- mcr p15, 0, %r0, %cr6, %cr0, 0
- bx %lr
- END_FUNCTION ArSetDataFaultingAddress
- ##
- ## PVOID
- ## ArGetInstructionFaultingAddress (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine determines which address caused a prefetch abort.
- Arguments:
- None.
- Return Value:
- Returns the faulting address.
- --*/
- FUNCTION ArGetInstructionFaultingAddress
- mrc p15, 0, %r0, %cr6, %cr0, 2 @ Get the IFAR.
- bx %lr @
- END_FUNCTION ArGetInstructionFaultingAddress
- ##
- ## VOID
- ## ArSetInstructionFaultingAddress (
- ## PVOID Value
- ## )
- ##
- /*++
- Routine Description:
- This routine sets the instruction faulting address register (IFAR).
- Arguments:
- Value - Supplies the value to set.
- Return Value:
- None.
- --*/
- FUNCTION ArSetInstructionFaultingAddress
- mcr p15, 0, %r0, %cr6, %cr0, 2
- bx %lr
- END_FUNCTION ArSetInstructionFaultingAddress
- ##
- ## ULONG
- ## ArGetDataFaultStatus (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine determines the reason for the fault by reading the DFSR
- register.
- Arguments:
- None.
- Return Value:
- Returns the contents of the Data Fault Status Register.
- --*/
- FUNCTION ArGetDataFaultStatus
- mrc p15, 0, %r0, %cr5, %cr0, 0 @ Get the DFSR.
- bx %lr @
- END_FUNCTION ArGetDataFaultStatus
- ##
- ## VOID
- ## ArSetDataFaultStatus (
- ## ULONG Value
- ## )
- ##
- /*++
- Routine Description:
- This routine sets the data fault status register (DFSR).
- Arguments:
- Value - Supplies the value to set.
- Return Value:
- None.
- --*/
- FUNCTION ArSetDataFaultStatus
- mcr p15, 0, %r0, %cr5, %cr0, 0
- bx %lr
- END_FUNCTION ArSetDataFaultStatus
- ##
- ## ULONG
- ## ArGetInstructionFaultStatus (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine determines the reason for the prefetch abort by reading the
- IFAR register.
- Arguments:
- None.
- Return Value:
- Returns the contents of the Instruction Fault Status Register.
- --*/
- FUNCTION ArGetInstructionFaultStatus
- mrc p15, 0, %r0, %cr5, %cr0, 1 @ Get the IFSR.
- bx %lr @
- END_FUNCTION ArGetInstructionFaultStatus
- ##
- ## VOID
- ## ArSetInstructionFaultStatus (
- ## ULONG Value
- ## )
- ##
- /*++
- Routine Description:
- This routine sets the instruction fault status register (IFSR).
- Arguments:
- Value - Supplies the value to set.
- Return Value:
- None.
- --*/
- FUNCTION ArSetInstructionFaultStatus
- mcr p15, 0, %r0, %cr5, %cr0, 1
- bx %lr
- END_FUNCTION ArSetInstructionFaultStatus
- ##
- ## VOID
- ## ArProcessorYield (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine executes a short processor yield in hardware.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- FUNCTION ArProcessorYield
- yield
- bx %lr
- END_FUNCTION ArProcessorYield
- ##
- ## KERNEL_API
- ## VOID
- ## ArWaitForInterrupt (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine halts the processor until the next interrupt comes in. This
- routine should be called with interrupts disabled, and will return with
- interrupts enabled.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- PROTECTED_FUNCTION ArWaitForInterrupt
- DSB @ Ensure everything is done.
- wfi @ Wait for interrupt.
- cpsie if @ Enable interrupts.
- bx %lr
- END_FUNCTION ArWaitForInterrupt
- ##
- ## VOID
- ## ArCpuid (
- ## PARM_CPUID Features
- ## )
- ##
- /*++
- Routine Description:
- This routine returns the set of processor features present on the current
- processor.
- Arguments:
- Features - Supplies a pointer where the processor feature register values
- will be returned.
- Return Value:
- None.
- --*/
- FUNCTION ArCpuid
- mrc p15, 0, %r1, c0, c1, 0 @ Get ID_PFR0.
- str %r1, [%r0], #4 @ Save it.
- mrc p15, 0, %r1, c0, c1, 1 @ Get ID_PFR1.
- str %r1, [%r0], #4 @ Save it.
- mrc p15, 0, %r1, c0, c1, 2 @ Get ID_DFR0.
- str %r1, [%r0], #4 @ Save it.
- mrc p15, 0, %r1, c0, c1, 3 @ Get ID_AFR0.
- str %r1, [%r0], #4 @ Save it.
- mrc p15, 0, %r1, c0, c1, 4 @ Get ID_MMFR0.
- str %r1, [%r0], #4 @ Save it.
- mrc p15, 0, %r1, c0, c1, 5 @ Get ID_MMFR1.
- str %r1, [%r0], #4 @ Save it.
- mrc p15, 0, %r1, c0, c1, 6 @ Get ID_MMFR2.
- str %r1, [%r0], #4 @ Save it.
- mrc p15, 0, %r1, c0, c1, 7 @ Get ID_MMFR3.
- str %r1, [%r0], #4 @ Save it.
- mrc p15, 0, %r1, c0, c2, 0 @ Get ID_IDAR0.
- str %r1, [%r0], #4 @ Save it.
- mrc p15, 0, %r1, c0, c2, 1 @ Get ID_IDAR1.
- str %r1, [%r0], #4 @ Save it.
- mrc p15, 0, %r1, c0, c2, 2 @ Get ID_IDAR2.
- str %r1, [%r0], #4 @ Save it.
- mrc p15, 0, %r1, c0, c2, 3 @ Get ID_IDAR3.
- str %r1, [%r0], #4 @ Save it.
- mrc p15, 0, %r1, c0, c2, 4 @ Get ID_IDAR4.
- str %r1, [%r0], #4 @ Save it.
- mrc p15, 0, %r1, c0, c2, 5 @ Get ID_IDAR5.
- str %r1, [%r0], #4 @ Save it.
- bx %lr @ Return!
- END_FUNCTION ArCpuid
- ##
- ## ULONG
- ## ArGetSystemControlRegister (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine returns the MMU system control register (SCTLR).
- Arguments:
- None.
- Return Value:
- Returns the current SCTLR value.
- --*/
- FUNCTION ArGetSystemControlRegister
- mrc p15, 0, %r0, %cr1, %cr0, 0 @ Get the SCTLR.
- bx %lr @ Return.
- END_FUNCTION ArGetSystemControlRegister
- ##
- ## VOID
- ## ArSetSystemControlRegister (
- ## ULONG NewValue
- ## )
- ##
- /*++
- Routine Description:
- This routine sets the MMU system control register (SCTLR).
- Arguments:
- NewValue - Supplies the value to set as the new MMU SCTLR.
- Return Value:
- None.
- --*/
- FUNCTION ArSetSystemControlRegister
- mcr p15, 0, %r0, %cr1, %cr0, 0 @ Set the SCTLR.
- bx %lr @ Return.
- END_FUNCTION ArSetSystemControlRegister
- ##
- ## ULONG
- ## ArGetAuxiliaryControlRegister (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine returns the auxiliary system control register (ACTLR).
- Arguments:
- None.
- Return Value:
- Returns the current value.
- --*/
- FUNCTION ArGetAuxiliaryControlRegister
- mrc p15, 0, %r0, %cr1, %cr0, 1
- bx %lr
- END_FUNCTION ArGetAuxiliaryControlRegister
- ##
- ## VOID
- ## ArSetAuxiliaryControlRegister (
- ## ULONG NewValue
- ## )
- ##
- /*++
- Routine Description:
- This routine sets the auxiliary system control register (ACTLR).
- Arguments:
- NewValue - Supplies the value to set.
- Return Value:
- None.
- --*/
- FUNCTION ArSetAuxiliaryControlRegister
- mcr p15, 0, %r0, %cr1, %cr0, 1
- bx %lr
- END_FUNCTION ArSetAuxiliaryControlRegister
- ##
- ## PVOID
- ## ArGetVectorBaseAddress (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine gets the vector base address register (VBAR) which determines
- where the ARM exception vector table starts.
- Arguments:
- None.
- Return Value:
- Returns the current VBAR.
- --*/
- FUNCTION ArGetVectorBaseAddress
- mrc p15, 0, %r0, c12, c0, 0
- bx %lr
- END_FUNCTION ArGetVectorBaseAddress
- ##
- ## VOID
- ## ArSetVectorBaseAddress (
- ## PVOID VectorBaseAddress
- ## )
- ##
- /*++
- Routine Description:
- This routine sets the vector base address register (VBAR) which determines
- where the ARM exception vector table starts.
- Arguments:
- VectorBaseAddress - Supplies a pointer to the ARM exception vector base
- address. This value must be 32-byte aligned.
- Return Value:
- None.
- --*/
- FUNCTION ArSetVectorBaseAddress
- mcr p15, 0, %r0, c12, c0, 0 @ Set VBAR.
- bx %lr @ Return.
- END_FUNCTION ArSetVectorBaseAddress
- ##
- ## PVOID
- ## ArGetProcessorBlockRegister (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine gets the register used to store a pointer to the processor
- block (TPIDRPRW in the ARMARM; Thread and Process ID Registers in the
- ARM1176 TRM).
- Arguments:
- None.
- Return Value:
- Returns a pointer to the processor block.
- --*/
- FUNCTION ArGetProcessorBlockRegister
- mrc p15, 0, %r0, c13, c0, 4 @ Get TPIDRPRW.
- bx %lr @ Return.
- END_FUNCTION ArGetProcessorBlockRegister
- ##
- ## PVOID
- ## ArGetProcessorBlockRegisterForDebugger (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine gets the register used to store a pointer to the processor
- block (TPIDRPRW in the ARMARM; Thread and Process ID Registers in the
- ARM1176 TRM). This routine is called from inside the debugger.
- Arguments:
- None.
- Return Value:
- Returns a pointer to the processor block.
- --*/
- FUNCTION ArGetProcessorBlockRegisterForDebugger
- mrc p15, 0, %r0, c13, c0, 4 @ Get TPIDRPRW.
- bx %lr @ Return.
- END_FUNCTION ArGetProcessorBlockRegisterForDebugger
- ##
- ## VOID
- ## ArSetProcessorBlockRegister (
- ## PVOID ProcessorBlockRegisterValue
- ## )
- ##
- /*++
- Routine Description:
- This routine sets the register used to store a pointer to the processor
- block (TPIDRPRW in the ARMARM; Thread and Process ID Registers in the
- ARM1176 TRM).
- Arguments:
- ProcessorBlockRegisterValue - Supplies the value to assign to the register
- used to store the processor block.
- Return Value:
- None.
- --*/
- FUNCTION ArSetProcessorBlockRegister
- mcr p15, 0, %r0, c13, c0, 4 @ Set TPIDRPRW.
- bx %lr @ Return.
- END_FUNCTION ArSetProcessorBlockRegister
- ##
- ## UINTN
- ## ArDereferenceProcessorBlock (
- ## UINTN Offset
- ## )
- ##
- /*++
- Routine Description:
- This routine performs a native integer read of the processor block plus
- a given offset. The C equivalent of this would be
- *((PUINTN)(ProcessorBlock + Offset)).
- Arguments:
- Offset - Supplies the offset into the processor block to read.
- Return Value:
- Returns the native integer read at the given address.
- --*/
- FUNCTION ArDereferenceProcessorBlock
- mrs %r1, CPSR @ Get the original status register.
- cpsid i @ Disable interrupts.
- mrc p15, 0, %r2, c13, c0, 4 @ Get TPIDRPRW.
- ldr %r0, [%r2, %r0] @ Read at offset.
- msr CPSR, %r1 @ Restore interrupts.
- bx %lr @ Return.
- END_FUNCTION ArDereferenceProcessorBlock
- ##
- ## ULONG
- ## ArGetTranslationTableBaseRegister0 (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine gets the translation table base register 0 (TTBR0), used as
- the base for all virtual to physical memory lookups.
- Arguments:
- None.
- Return Value:
- Returns the contents of TTBR0.
- --*/
- FUNCTION ArGetTranslationTableBaseRegister0
- mrc p15, 0, %r0, c2, c0, 0 @ Get TTBR0.
- bx %lr @ Return.
- END_FUNCTION ArGetTranslationTableBaseRegister0
- ##
- ## VOID
- ## ArSetTranslationTableBaseRegister0 (
- ## ULONG Value
- ## )
- ##
- /*++
- Routine Description:
- This routine sets the translation table base register 0 (TTBR0).
- Arguments:
- Value - Supplies the value to write.
- Return Value:
- None.
- --*/
- FUNCTION ArSetTranslationTableBaseRegister0
- mcr p15, 0, %r0, c2, c0, 0
- bx %lr
- END_FUNCTION ArSetTranslationTableBaseRegister0
- ##
- ## ULONG
- ## ArGetTranslationTableBaseRegister1 (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine gets the translation table base register 1 (TTBR1).
- Arguments:
- None.
- Return Value:
- Returns the contents of TTBR1.
- --*/
- FUNCTION ArGetTranslationTableBaseRegister1
- mrc p15, 0, %r0, c2, c0, 1
- bx %lr
- END_FUNCTION ArGetTranslationTableBaseRegister1
- ##
- ## VOID
- ## ArSetTranslationTableBaseRegister1 (
- ## ULONG Value
- ## )
- ##
- /*++
- Routine Description:
- This routine sets the translation table base register 1 (TTBR1).
- Arguments:
- Value - Supplies the value to write.
- Return Value:
- None.
- --*/
- FUNCTION ArSetTranslationTableBaseRegister1
- mcr p15, 0, %r0, c2, c0, 1
- bx %lr
- END_FUNCTION ArSetTranslationTableBaseRegister1
- ##
- ## ULONG
- ## ArGetPrimaryRegionRemapRegister (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine gets the Primary Region Remap Register (PRRR).
- Arguments:
- None.
- Return Value:
- Returns the contents of the register.
- --*/
- FUNCTION ArGetPrimaryRegionRemapRegister
- mrc p15, 0, %r0, c10, c2, 0
- bx %lr
- END_FUNCTION ArGetPrimaryRegionRemapRegister
- ##
- ## VOID
- ## ArSetPrimaryRegionRemapRegister (
- ## ULONG Value
- ## )
- ##
- /*++
- Routine Description:
- This routine sets the PRRR.
- Arguments:
- Value - Supplies the value to write.
- Return Value:
- None.
- --*/
- FUNCTION ArSetPrimaryRegionRemapRegister
- mcr p15, 0, %r0, c10, c2, 0
- bx %lr
- END_FUNCTION ArSetPrimaryRegionRemapRegister
- ##
- ## ULONG
- ## ArGetNormalMemoryRemapRegister (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine gets the Normal Memory Remap Register (NMRR).
- Arguments:
- None.
- Return Value:
- Returns the contents of the register.
- --*/
- FUNCTION ArGetNormalMemoryRemapRegister
- mrc p15, 0, %r0, c10, c2, 1
- bx %lr
- END_FUNCTION ArGetNormalMemoryRemapRegister
- ##
- ## VOID
- ## ArSetNormalMemoryRemapRegister (
- ## ULONG Value
- ## )
- ##
- /*++
- Routine Description:
- This routine sets the NMRR.
- Arguments:
- Value - Supplies the value to write.
- Return Value:
- None.
- --*/
- FUNCTION ArSetNormalMemoryRemapRegister
- mcr p15, 0, %r0, c10, c2, 1
- bx %lr
- END_FUNCTION ArSetNormalMemoryRemapRegister
- ##
- ## ULONG
- ## ArGetPhysicalAddressRegister (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine gets the Physical Address Register (PAR).
- Arguments:
- None.
- Return Value:
- Returns the contents of the register.
- --*/
- FUNCTION ArGetPhysicalAddressRegister
- mrc p15, 0, %r0, c7, c4, 0
- bx %lr
- END_FUNCTION ArGetPhysicalAddressRegister
- ##
- ## VOID
- ## ArSetPhysicalAddressRegister (
- ## ULONG Value
- ## )
- ##
- /*++
- Routine Description:
- This routine sets the Physical Address Register (PAR).
- Arguments:
- Value - Supplies the value to write.
- Return Value:
- None.
- --*/
- FUNCTION ArSetPhysicalAddressRegister
- mcr p15, 0, %r0, c7, c4, 0
- bx %lr
- END_FUNCTION ArSetPhysicalAddressRegister
- ##
- ## VOID
- ## ArSetPrivilegedReadTranslateRegister (
- ## ULONG Value
- ## )
- ##
- /*++
- Routine Description:
- This routine sets the Privileged Read address translation command register.
- Arguments:
- Value - Supplies the value to write.
- Return Value:
- None.
- --*/
- FUNCTION ArSetPrivilegedReadTranslateRegister
- mcr p15, 0, %r0, c7, c8, 0
- bx %lr
- END_FUNCTION ArSetPrivilegedReadTranslateRegister
- ##
- ## VOID
- ## ArSetPrivilegedWriteTranslateRegister (
- ## ULONG Value
- ## )
- ##
- /*++
- Routine Description:
- This routine sets the Privileged Write address translation command register.
- Arguments:
- Value - Supplies the value to write.
- Return Value:
- None.
- --*/
- FUNCTION ArSetPrivilegedWriteTranslateRegister
- mcr p15, 0, %r0, c7, c8, 1
- bx %lr
- END_FUNCTION ArSetPrivilegedWriteTranslateRegister
- ##
- ## VOID
- ## ArSetUnprivilegedReadTranslateRegister (
- ## ULONG Value
- ## )
- ##
- /*++
- Routine Description:
- This routine sets the Unrivileged Read address translation command register.
- Arguments:
- Value - Supplies the value to write.
- Return Value:
- None.
- --*/
- FUNCTION ArSetUnprivilegedReadTranslateRegister
- mcr p15, 0, %r0, c7, c8, 2
- bx %lr
- END_FUNCTION ArSetUnprivilegedReadTranslateRegister
- ##
- ## VOID
- ## ArSetUnprivilegedWriteTranslateRegister (
- ## ULONG Value
- ## )
- ##
- /*++
- Routine Description:
- This routine sets the Unprivileged Write address translation command
- register.
- Arguments:
- Value - Supplies the value to write.
- Return Value:
- None.
- --*/
- FUNCTION ArSetUnprivilegedWriteTranslateRegister
- mcr p15, 0, %r0, c7, c8, 3
- bx %lr
- END_FUNCTION ArSetUnprivilegedWriteTranslateRegister
- ##
- ## ULONG
- ## ArTranslateVirtualToPhysical (
- ## PVOID VirtualAddress
- ## )
- ##
- /*++
- Routine Description:
- This routine translates a virtual address to its corresponding physical
- address by using the current translation tables.
- Arguments:
- VirtualAddress - Supplies the virtual address to translate.
- Return Value:
- Returns the physical address that the virtual address corresponds to
- (with some bits at the bottom relating to the cache type).
- --*/
- FUNCTION ArTranslateVirtualToPhysical
- mrs %r1, CPSR @ Get the status register.
- orr %r2, %r1, #PSR_FLAG_IRQ @ Turn on the interrupt mask bit.
- msr CPSR_cxsf, %r2 @ Write the status register.
- mcr p15, 0, %r0, c7, c8, 0 @ Write VA into V2PCWPR
- mrc p15, 0, %r0, c7, c4, 0 @ Read PAR.
- msr CPSR_cxsf, %r1 @ Restore interrupts.
- bx %lr @ Return.
- END_FUNCTION ArTranslateVirtualToPhysical
- ##
- ## VOID
- ## ArSetThreadPointerUserReadOnly (
- ## PVOID NewPointer
- ## )
- ##
- /*++
- Routine Description:
- This routine sets the TPIDRURO user-mode-read-only thread pointer register.
- Arguments:
- NewPointer - Supplies the value to write.
- Return Value:
- None.
- --*/
- FUNCTION ArSetThreadPointerUserReadOnly
- mcr p15, 0, %r0, c13, c0, 3 @ Set the TPIDRURO register.
- bx %lr
- END_FUNCTION ArSetThreadPointerUserReadOnly
- ##
- ## ULONG
- ## ArGetThreadPointerUser (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine sets the TPIDRURW user-mode thread pointer register.
- Arguments:
- None.
- Return Value:
- Returns the current value of the TPIDRURW.
- --*/
- FUNCTION ArGetThreadPointerUser
- mrc p15, 0, %r0, c13, c0, 2 @ Get the TPIDRURW register.
- bx %lr
- END_FUNCTION ArGetThreadPointerUser
- ##
- ## VOID
- ## ArSwitchTtbr0 (
- ## ULONG NewValue
- ## )
- ##
- /*++
- Routine Description:
- This routine performs the proper sequence for changing contexts in TTBR0,
- including the necessary invalidates and barriers.
- Arguments:
- NewValue - Supplies the new value to write.
- Return Value:
- None.
- --*/
- FUNCTION ArSwitchTtbr0
- mcr p15, 0, %r0, c2, c0, 0 @ Set TTBR0.
- mov %r0, #0 @ Get a zero register.
- DSB @ Ensure everything finished.
- mcr p15, 0, %r0, c8, c7, 0 @ TLBIALL, Invalidate entire TLB.
- mcr p15, 0, %r0, c7, c5, 0 @ ICIALLU, Invalidate I-Cache + BTB.
- DSB @ Ensure those operations finished.
- ISB @ Instruction synchronization.
- bx %lr @ Return.
- END_FUNCTION ArSwitchTtbr0
- ##
- ## UINTN
- ## ArSaveProcessorContext (
- ## PPROCESSOR_CONTEXT Context
- ## )
- ##
- /*++
- Routine Description:
- This routine saves the current processor context, including the
- non-volatile general registers and the system level control registers. This
- function appears to return twice, once when the context is saved and then
- again when the context is restored. Because the stack pointer is restored,
- the caller of this function may not return without either abandoning the
- context or calling restore. Returning and then calling restore would almost
- certainly result in stack corruption.
- Arguments:
- Context - Supplies a pointer to the context area to save into.
- Return Value:
- Returns 0 after the context was successfully saved (first time).
- Returns the value in the context return address register when the restore
- function is called (the second time). By default this value is 1, though it
- can be manipulated after the initial save is complete.
- --*/
- FUNCTION ArSaveProcessorContext
- stmia %r0!, {%lr} @ Save PC (return address).
- mov %r1, #1 @ "Save" 1 to R0.
- stmia %r0!, {%r1} @
- mov %r1, #0 @ "Save" 0 to R1, R2, and R3.
- stmia %r0!, {%r1} @
- stmia %r0!, {%r1} @
- stmia %r0!, {%r1} @
- mrs %r1, CPSR @ Save CPSR.
- stmia %r0!, {%r1} @
- mov %r3, %sp @ Put SP in R3 because no pushing SP.
- stmia %r0!, {%r3-%r11} @ Save SP and R4-R11.
- mrs %r1, CPSR @ Get the current mode and status.
- cpsid if, #ARM_MODE_SYSTEM @ Get to user mode (disable interrupts).
- mov %r2, %sp @ Get banked SP.
- stmia %r0!, {%r2, %lr} @ Save banked registers.
- cpsid if, #ARM_MODE_IRQ @ Get to interrupt mode.
- mov %r2, %sp @ Get banked SP.
- stmia %r0!, {%r2, %lr} @ Save banked registers.
- cpsid if, #ARM_MODE_FIQ @ Get to fast interrupt mode.
- mov %r2, %sp @ Get banked SP.
- stmia %r0!, {%r2, %lr} @ Save banked registers.
- cpsid if, #ARM_MODE_ABORT @ Get to abort mode.
- mov %r2, %sp @ Get banked SP.
- stmia %r0!, {%r2, %lr} @ Save banked registers.
- cpsid if, #ARM_MODE_UNDEF @ Get to undefined instruction mode.
- mov %r2, %sp @ Get banked SP.
- stmia %r0!, {%r2, %lr} @ Save banked registers.
- msr CPSR, %r1 @ Restore interrupts and mode.
- stmia %r0!, {%r0} @ Remember the VA right here.
- mrc p15, 0, %r1, c1, c0, 0 @ Save SCTLR.
- stmia %r0!, {%r1} @
- mrc p15, 0, %r1, c2, c0, 0 @ Save TTBR0.
- stmia %r0!, {%r1} @
- mrc p15, 0, %r1, c2, c0, 1 @ Save TTBR1.
- stmia %r0!, {%r1} @
- mrc p15, 0, %r1, c1, c0, 1 @ Save ACTLR.
- stmia %r0!, {%r1} @
- mrc p15, 0, %r1, c1, c0, 2 @ Save CPACR.
- stmia %r0!, {%r1} @
- mrc p15, 0, %r1, c10, c2, 0 @ Save PRRR.
- stmia %r0!, {%r1} @
- mrc p15, 0, %r1, c10, c2, 1 @ Save NMRR.
- stmia %r0!, {%r1} @
- mrc p15, 0, %r1, c13, c0, 1 @ Save CONTEXTIDR.
- stmia %r0!, {%r1} @
- mrc p15, 0, %r1, c5, c0, 0 @ Save DFSR.
- stmia %r0!, {%r1} @
- mrc p15, 0, %r1, c6, c0, 0 @ Save DFAR
- stmia %r0!, {%r1} @
- mrc p15, 0, %r1, c5, c0, 1 @ Save IFSR.
- stmia %r0!, {%r1} @
- mrc p15, 0, %r1, c6, c0, 2 @ Save IFAR.
- stmia %r0!, {%r1} @
- mrc p15, 0, %r1, c3, c0, 0 @ Save DACR
- stmia %r0!, {%r1} @
- mrc p15, 0, %r1, c12, c0, 0 @ Save VBAR.
- stmia %r0!, {%r1} @
- mrc p15, 0, %r1, c13, c0, 4 @ Save TPIDRPRW.
- stmia %r0!, {%r1} @
- mrc p15, 0, %r1, c13, c0, 3 @ Save TPIDRURO.
- stmia %r0!, {%r1} @
- mrc p15, 0, %r1, c13, c0, 2 @ Save TPIDRURW.
- stmia %r0!, {%r1} @
- mrc p15, 0, %r1, c9, c12, 0 @ Save PMCR.
- stmia %r0!, {%r1} @
- mrc p15, 0, %r1, c9, c14, 1 @ Save PMINTENSET.
- stmia %r0!, {%r1} @
- mrc p15, 0, %r1, c9, c14, 0 @ Save PMUSERENR.
- stmia %r0!, {%r1} @
- mrc p15, 0, %r1, c9, c12, 1 @ Save PMCNTENSET.
- stmia %r0!, {%r1} @
- mrc p15, 0, %r1, c9, c13, 0 @ Save PMCCNTR. Start losing time.
- stmia %r0!, {%r1} @
- mov %r0, #0 @ Return 0 initially.
- bx %lr
- END_FUNCTION ArSaveProcessorContext
- ##
- ## VOID
- ## ArRestoreProcessorContext (
- ## PPROCESSOR_CONTEXT Context
- ## )
- ##
- /*++
- Routine Description:
- This routine restores the current processor context, including the
- non-volatile general registers and the system level control registers. This
- function does not return, but instead jumps to the return address from
- the caller of the save context function.
- Arguments:
- Context - Supplies a pointer to the context to restore.
- Return Value:
- Does not return, at least not conventionally.
- --*/
- FUNCTION ArRestoreProcessorContext
- add %r0, %r0, #PROCESSOR_CONTEXT_SIZE @ Jump to the end.
- ldmdb %r0!, {%r1} @
- mcr p15, 0, %r1, c9, c13, 0 @ Restore PMCCNTR. Start losing time.
- ldmdb %r0!, {%r1} @
- mcr p15, 0, %r1, c9, c12, 1 @ Restore PMCNTENSET.
- ldmdb %r0!, {%r1} @
- mcr p15, 0, %r1, c9, c14, 0 @ Restore PMUSERENR.
- ldmdb %r0!, {%r1} @
- mcr p15, 0, %r1, c9, c14, 1 @ Restore PMINTENSET.
- ldmdb %r0!, {%r1} @
- mcr p15, 0, %r1, c9, c12, 0 @ Restore PMCR.
- ldmdb %r0!, {%r1} @
- mcr p15, 0, %r1, c13, c0, 2 @ Restore TPIDRURW.
- ldmdb %r0!, {%r1} @
- mcr p15, 0, %r1, c13, c0, 3 @ Restore TPIDRURO.
- ldmdb %r0!, {%r1} @
- mcr p15, 0, %r1, c13, c0, 4 @ Restore TPIDRPRW.
- ldmdb %r0!, {%r1} @
- mcr p15, 0, %r1, c12, c0, 0 @ Restore VBAR.
- ldmdb %r0!, {%r1} @
- mcr p15, 0, %r1, c3, c0, 0 @ Restore DACR
- ldmdb %r0!, {%r1} @
- mcr p15, 0, %r1, c6, c0, 2 @ Restore IFAR.
- ldmdb %r0!, {%r1} @
- mcr p15, 0, %r1, c5, c0, 1 @ Restore IFSR.
- ldmdb %r0!, {%r1} @
- mcr p15, 0, %r1, c6, c0, 0 @ Restore DFAR
- ldmdb %r0!, {%r1} @
- mcr p15, 0, %r1, c5, c0, 0 @ Restore DFSR.
- ldmdb %r0!, {%r1} @
- mcr p15, 0, %r1, c13, c0, 1 @ Restore CONTEXTIDR.
- ldmdb %r0!, {%r1} @
- mcr p15, 0, %r1, c10, c2, 1 @ Restore NMRR.
- ldmdb %r0!, {%r1} @
- mcr p15, 0, %r1, c10, c2, 0 @ Restore PRRR.
- ldmdb %r0!, {%r1} @
- mcr p15, 0, %r1, c1, c0, 2 @ Restore CPACR.
- ##
- ## Sometimes the ACTLR cannot be written in non-secure mode, so only try to
- ## write it if it appears to need restoring.
- ##
- mrc p15, 0, %r2, c1, c0, 1 @ Get current ACTLR.
- ldmdb %r0!, {%r1} @ Load saved one.
- cmp %r1, %r2 @ Compare.
- beq ArRestoreProcessorContextAfterActlr
- mcr p15, 0, %r1, c1, c0, 1 @ Restore ACTLR.
- ArRestoreProcessorContextAfterActlr:
- ldmdb %r0!, {%r1} @
- mcr p15, 0, %r1, c2, c0, 1 @ Restore TTBR1.
- ldmdb %r0!, {%r1} @
- mcr p15, 0, %r1, c2, c0, 0 @ Restore TTBR0.
- ##
- ## This next bit is tricky, because paging may suddenly become enabled.
- ## This code must be identity mapped, but the context might not be. Load
- ## the SCTLR and the virtual address of the next structure member. Then
- ## restore SCTLR and continue the restore from the virtual address.
- ##
- ldmdb %r0!, {%r1} @ Get SCTLR.
- ldmdb %r0, {%r2} @ Also get the VA of the remainder.
- mov %r0, %r2 @ Make it the new current pointer.
- mcr p15, 0, %r1, c1, c0, 0 @ Restore SCTLR.
- ##
- ## The paging context may have changed (and observed a wonky ASID in the
- ## process), so some invalidations are in order.
- ##
- mcr p15, 0, %r0, c7, c5, 0 @ ICIALLU, Invalidate I-Cache.
- BPIALL @ BPIALL, Invalidate Branch Predictor.
- mcr p15, 0, %r0, c8, c7, 0 @ Clear the TLB, TLBIALL.
- DSB @ Data synchronization barrier.
- ISB @ Instruction syncrhonization barrier.
- ##
- ## Restore the banked registers.
- ##
- cpsid if, #ARM_MODE_UNDEF @ Get to undefined instruction mode.
- ldmdb %r0!, {%r1, %lr} @ Restore banked registers.
- mov %sp, %r1 @ Restore banked SP.
- cpsid if, #ARM_MODE_ABORT @ Get to abort mode.
- ldmdb %r0!, {%r1, %lr} @ Restore banked registers.
- mov %sp, %r1 @ Restore banked SP.
- cpsid if, #ARM_MODE_FIQ @ Get to fast interrupt mode.
- ldmdb %r0!, {%r1, %lr} @ Restore banked registers.
- mov %sp, %r1 @ Restore banked SP.
- cpsid if, #ARM_MODE_IRQ @ Get to interrupt mode.
- ldmdb %r0!, {%r1, %lr} @ Restore banked registers.
- mov %sp, %r1 @ Restore banked SP.
- cpsid if, #ARM_MODE_SYSTEM @ Get to user mode (disable interrupts).
- ldmdb %r0!, {%r1, %lr} @ Restore banked registers.
- mov %sp, %r1 @ Restore banked SP.
- cpsid if, #ARM_MODE_SVC @ Get back to SVC mode.
- ##
- ## Restore the general registers and jump back to the return of the
- ## save context function.
- ##
- mov %r12, %r0 @ Move to a free register.
- ldmdb %r12!, {%r3-%r11} @ Restore general context.
- mov %sp, %r3 @ Restore stack.
- ldmdb %r12!, {%r0-%r3,%lr} @ Restore arguments and CPSR.
- msr CPSR, %lr @ Restore CPSR.
- ldr %r12, [%r12, #-4] @ Read the last value: PC.
- mov %lr, #0 @ Zero out lr for goodwill.
- bx %r12 @ Jump to the return address.
- END_FUNCTION ArRestoreProcessorContext
- ##
- ## ULONG
- ## ArGetMainIdRegister (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine gets the Main ID Register (MIDR).
- Arguments:
- None.
- Return Value:
- Returns the contents of the register.
- --*/
- FUNCTION ArGetMainIdRegister
- mrc p15, 0, %r0, c0, c0, 0
- bx %lr
- END_FUNCTION ArGetMainIdRegister
- ##
- ## ULONG
- ## ArGetCoprocessorAccessRegister (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine gets the Coprocessor Access Control Register (CPACR).
- Arguments:
- None.
- Return Value:
- Returns the contents of the register.
- --*/
- FUNCTION ArGetCoprocessorAccessRegister
- mrc p15, 0, %r0, c1, c0, 2
- bx %lr
- END_FUNCTION ArGetCoprocessorAccessRegister
- ##
- ## VOID
- ## ArSetCoprocessorAccessRegister (
- ## ULONG Value
- ## )
- ##
- /*++
- Routine Description:
- This routine sets the Coprocessor Access Control Register (CPACR).
- Arguments:
- Value - Supplies the value to write.
- Return Value:
- None.
- --*/
- FUNCTION ArSetCoprocessorAccessRegister
- mcr p15, 0, %r0, c1, c0, 2
- bx %lr
- END_FUNCTION ArSetCoprocessorAccessRegister
- ##
- ## ULONG
- ## ArGetFloatingPointIdRegister (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine gets the Floating Point unit ID register (FPSID).
- Arguments:
- None.
- Return Value:
- Returns the contents of the register.
- --*/
- FUNCTION ArGetFloatingPointIdRegister
- vmrs %r0, FPSID
- bx %lr
- END_FUNCTION ArGetFloatingPointIdRegister
- ##
- ## ULONG
- ## ArGetMvfr0Register (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine gets the floating point extensions identification register
- (MVFR0).
- Arguments:
- None.
- Return Value:
- Returns the contents of the register.
- --*/
- FUNCTION ArGetMvfr0Register
- vmrs %r0, MVFR0
- bx %lr
- END_FUNCTION ArGetMvfr0Register
- ##
- ## ULONG
- ## ArGetVfpExceptionRegister (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine gets the floating point exception control register (FPEXC).
- Arguments:
- None.
- Return Value:
- Returns the contents of the register.
- --*/
- FUNCTION ArGetVfpExceptionRegister
- vmrs %r0, FPEXC
- bx %lr
- END_FUNCTION ArGetVfpExceptionRegister
- ##
- ## VOID
- ## ArSetVfpExceptionRegister (
- ## ULONG Value
- ## )
- ##
- /*++
- Routine Description:
- This routine sets the floating point exception control register (FPEXC).
- Arguments:
- Value - Supplies the new value to set.
- Return Value:
- None.
- --*/
- FUNCTION ArSetVfpExceptionRegister
- vmsr FPEXC, %r0
- bx %lr
- END_FUNCTION ArSetVfpExceptionRegister
- ##
- ## ULONG
- ## ArGetVfpInstructionRegister (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine gets the floating point instruction register (FPINST).
- Arguments:
- None.
- Return Value:
- Returns the contents of the register.
- --*/
- FUNCTION ArGetVfpInstructionRegister
- mrc p10, 7, %r0, c9, c0, 0
- bx %lr
- END_FUNCTION ArGetVfpInstructionRegister
- ##
- ## ULONG
- ## ArGetFpscr (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine gets the floating point status and control register (FPSCR).
- Arguments:
- None.
- Return Value:
- Returns the contents of the register.
- --*/
- FUNCTION ArGetFpscr
- vmrs %r0, FPSCR @ Get FPSCR.
- bx %lr
- END_FUNCTION ArGetFpscr
- ##
- ## VOID
- ## ArSaveVfp (
- ## PFPU_CONTEXT Context,
- ## BOOL SimdSupport
- ## )
- ##
- /*++
- Routine Description:
- This routine saves the Vector Floating Point unit state.
- Arguments:
- Context - Supplies a pointer where the context will be saved.
- SimdSupport - Supplies a boolean indicating whether the VFP unit contains
- 32 64-bit registers (TRUE) or 16 64-bit registers (FALSE).
- Return Value:
- None.
- --*/
- FUNCTION ArSaveVfp
- stc p11, c0, [%r0], #16*8 @ Save D0-D15 (stmia).
- cmp %r1, #0 @ Test for no SIMD support.
- ITE(ne) @ If equal then else.
- stclne p11, c0, [%r0], #16*8 @ Save D16-D31 if SIMD support.
- addeq %r0, %r0, #16*8 @ Skip those registers if not.
- vmrs %r2, FPSCR @ Get FPSCR.
- str %r2, [%r0] @ Store it.
- bx %lr @ Return.
- END_FUNCTION ArSaveVfp
- ##
- ## VOID
- ## ArRestoreVfp (
- ## PFPU_CONTEXT Context,
- ## BOOL SimdSupport
- ## )
- ##
- /*++
- Routine Description:
- This routine restores the Vector Floating Point unit state into the
- hardware.
- Arguments:
- Context - Supplies a pointer to the context to restore.
- SimdSupport - Supplies a boolean indicating whether the VFP unit contains
- 32 64-bit registers (TRUE) or 16 64-bit registers (FALSE).
- Return Value:
- None.
- --*/
- FUNCTION ArRestoreVfp
- ldc p11, c0, [%r0], #16*8 @ Restore D0-D15 (ldmia).
- cmp %r1, #0 @ Test for no SIMD support.
- ITE(ne) @ If equal then else.
- ldclne p11, c0, [%r0], #16*8 @ Restore D16-D31 if SIMD support.
- addeq %r0, %r0, #16*8 @ Skip those registers if not.
- ldr %r2, [%r0] @ Get FPSCR.
- vmsr FPSCR, %r2 @ Restore FPSCR.
- bx %lr @ Return.
- END_FUNCTION ArRestoreVfp
- ##
- ## --------------------------------------------------------- Internal Functions
- ##
|