12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541 |
- /*++
- Copyright (c) 2014 Minoca Corp. All Rights Reserved
- Module Name:
- commsup.S
- Abstract:
- This module implements assembly-based architecture support routines common
- to all ARM platforms.
- Author:
- Chris Stevens 20-Mar-2014
- Environment:
- Firmware
- --*/
- ##
- ## ------------------------------------------------------------------- Includes
- ##
- #include <minoca/kernel/arm.inc>
- ##
- ## ---------------------------------------------------------------- Definitions
- ##
- ##
- ## ---------------------------------------------------------------------- Code
- ##
- ASSEMBLY_FILE_HEADER
- ##
- ## VOID
- ## EfipInitializeExceptionStacks (
- ## PVOID ExceptionStacksBase,
- ## ULONG ExceptionStackSize
- ## )
- ##
- /*++
- Routine Description:
- This routine initializes the stack pointer for all privileged ARM modes. It
- switches into each mode and initializes the banked r13. This function
- should be called with interrupts disabled and returns with interrupts
- disabled.
- Arguments:
- ExceptionStacksBase - Supplies a pointer to the lowest address that should
- be used for exception stacks. Each stack takes up 16 bytes and there are
- 4 modes, so at least 64 bytes are needed.
- ExceptionStackSize - Supplies the size of each exception stack.
- Return Value:
- None.
- --*/
- FUNCTION EfipInitializeExceptionStacks
- ##
- ## Load R1 with an individual stack size.
- ##
- add %r0, %r0, %r1
- ##
- ## Disable interrupts and switch into IRQ mode. Note that this also
- ## clobbers the flags register.
- ##
- mov %r2, #(PSR_FLAG_IRQ | ARM_MODE_IRQ)
- msr CPSR_cxsf, %r2
- mov %sp, %r0
- add %r0, %r0, %r1
- ##
- ## Initialize the FIQ stack.
- ##
- mov %r2, #(PSR_FLAG_IRQ | ARM_MODE_FIQ)
- msr CPSR_cxsf, %r2
- mov %sp, %r0
- add %r0, %r0, %r1
- ##
- ## Initialize the undefined instruction stack.
- ##
- mov %r2, #(PSR_FLAG_IRQ | ARM_MODE_UNDEF)
- msr CPSR_cxsf, %r2
- mov %sp, %r0
- add %r0, %r0, %r1
- ##
- ## Initialize the data fetch abort stack.
- ##
- mov %r2, #(PSR_FLAG_IRQ | ARM_MODE_ABORT)
- msr CPSR_cxsf, %r2
- mov %sp, %r0
- ##
- ## Switch back to SVC mode and return.
- ##
- mov %r2, #(PSR_FLAG_IRQ | ARM_MODE_SVC)
- msr CPSR_cxsf, %r2
- bx %lr
- END_FUNCTION EfipInitializeExceptionStacks
- ##
- ## BOOLEAN
- ## EfiDisableInterrupts (
- ## 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.
- --*/
- FUNCTION EfiDisableInterrupts
- 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 EfiDisableInterrupts
- ##
- ## VOID
- ## EfiEnableInterrupts (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine enables interrupts on the current processor.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- FUNCTION EfiEnableInterrupts
- cpsie i @ Enable interrupts.
- bx %lr @
- END_FUNCTION EfiEnableInterrupts
- ##
- ## BOOLEAN
- ## EfiAreInterruptsEnabled (
- ## 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.
- --*/
- FUNCTION EfiAreInterruptsEnabled
- 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 EfiAreInterruptsEnabled
- ##
- ## VOID
- ## EfipUndefinedInstructionEntry (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine directly handles an exception generated by an undefined
- instruction. It uses a largely separate code path from normal exceptions
- to avoid recursively breaking into the debugger.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- FUNCTION EfipUndefinedInstructionEntry
- ##
- ## Save state and create a trap frame.
- ##
- ARM_ENTER_INTERRUPT
- ##
- ## Call the main dispatch routine routine with a pointer to the trap frame
- ## as the only parameter.
- ##
- mov %r0, %sp
- blx EfipDispatchUndefinedInstructionException
- ##
- ## Restore state and return.
- ##
- ARM_EXIT_INTERRUPT
- END_FUNCTION EfipUndefinedInstructionEntry
- ##
- ## VOID
- ## EfipSoftwareInterruptEntry (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine directly handles an exception generated by a software
- interrupt (a system call).
- Arguments:
- None.
- Return Value:
- None.
- --*/
- FUNCTION EfipSoftwareInterruptEntry
- b EfipCommonInterruptEntry @ This is neither expected nor handled.
- END_FUNCTION EfipSoftwareInterruptEntry
- ##
- ## VOID
- ## EfipPrefetchAbortEntry (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine directly handles an exception generated by a prefetch abort
- (page fault).
- Arguments:
- None.
- Return Value:
- None.
- --*/
- FUNCTION EfipPrefetchAbortEntry
- sub %lr, %lr, #4 @ Prefetches go too far by 4.
- ##
- ## Save state and create a trap frame.
- ##
- ARM_ENTER_INTERRUPT
- ##
- ## Call the main dispatch routine routine with a pointer to the trap frame
- ## and 1 to indicate a prefetch abort.
- ##
- mov %r0, %sp
- mov %r1, #1
- blx EfipDispatchException
- ##
- ## Restore state and return.
- ##
- ARM_EXIT_INTERRUPT
- END_FUNCTION EfipPrefetchAbortEntry
- ##
- ## VOID
- ## EfipDataAbortEntry (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine directly handles an exception generated by a data abort (page
- fault).
- Arguments:
- None.
- Return Value:
- None.
- --*/
- FUNCTION EfipDataAbortEntry
- sub %lr, %lr, #8 @ Data aborts go too far by 8.
- ##
- ## Save state and create a trap frame.
- ##
- ARM_ENTER_INTERRUPT
- ##
- ## Call the main dispatch routine routine with a pointer to the trap frame
- ## and 0 to indicate a prefetch abort.
- ##
- mov %r0, %sp
- mov %r1, #0
- blx EfipDispatchException
- ##
- ## Restore state and return.
- ##
- ARM_EXIT_INTERRUPT
- END_FUNCTION EfipDataAbortEntry
- ##
- ## VOID
- ## EfipIrqEntry (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine directly handles an exception generated by an external
- interrupt on the IRQ pin.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- FUNCTION EfipIrqEntry
- b EfipCommonInterruptEntry
- END_FUNCTION EfipIrqEntry
- ##
- ## VOID
- ## EfipFiqEntry (
- ## VOID
- ## )
- ##
- /*++
- Routine Description:
- This routine directly handles an exception generated by an external
- interrupt on the FIQ pin.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- FUNCTION EfipFiqEntry
- b EfipCommonInterruptEntry
- END_FUNCTION EfipFiqEntry
- ##
- ## VOID
- ## EfipCpuid (
- ## 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 EfipCpuid
- 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 EfipCpuid
- ##
- ## EFIAPI
- ## UINTN
- ## EfipArchSetJump (
- ## PEFI_JUMP_BUFFER JumpBuffer
- ## )
- ##
- /*++
- Routine Description:
- This routine sets the context in the given jump buffer such that when
- long jump is called, execution continues at the return value from this
- routine with a non-zero return value.
- Arguments:
- JumpBuffer - Supplies a pointer where the architecture-specific context
- will be saved.
- Return Value:
- 0 upon the initial return from this routine.
- Non-zero when returning as the target of a long jump.
- --*/
- FUNCTION EfipArchSetJump
- mov %r3, %r13 @ Save the stack pointer.
- stmia %r0, {%r3-%r12,%r14} @ Save the non-volatile registers.
- eor %r0, %r0, %r0 @ Zero out the return value.
- bx %lr @ Return.
- END_FUNCTION EfipArchSetJump
- ##
- ## EFIAPI
- ## VOID
- ## EfipArchLongJump (
- ## PEFI_JUMP_BUFFER JumpBuffer,
- ## UINTN Value
- ## )
- ##
- /*++
- Routine Description:
- This routine restores machine context to the state it was in when the
- set jump that saved into the given jump buffer was called. The return
- value will be set to the given value.
- Arguments:
- JumpBuffer - Supplies a pointer to the context to restore.
- Value - Supplies the new return value to set from set jump. This should not
- be zero, otherwise the caller of set jump will not be able to
- differentiate it from its initial return.
- Return Value:
- This routine does not return.
- --*/
- FUNCTION EfipArchLongJump
- ldmia %r0, {%r3-%r12,%r14} @ Restore the non-volatile registers.
- mov %r13, %r3 @ Restore the stack pointer.
- mov %r0, %r1 @ Move the return value into place.
- bx %lr @ Return.
- END_FUNCTION EfipArchLongJump
- ##
- ## 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
- ## 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
- ##
- ## 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
- ##
- ## 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
- ##
- ## 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
- ## 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
- ##
- ## --------------------------------------------------------- Internal Functions
- ##
- ##
- ## This code is entered as the result of any interrupt or exception. Its job is
- ## to transition back to the SVC stack and then call the real interrupt
- ## dispatch routine.
- ##
- EfipCommonInterruptEntry:
- ##
- ## Save state and create a trap frame.
- ##
- ARM_ENTER_INTERRUPT
- ##
- ## Call the main dispatch routine routine with a pointer to the trap frame
- ## as the only parameter.
- ##
- mov %r0, %sp
- blx EfipDispatchException
- ##
- ## Restore state and return.
- ##
- ARM_EXIT_INTERRUPT
|