Unit PlatformARMv7

From Ultibo.org
Jump to: navigation, search

Return to Unit Reference


Description


Ultibo Platform Interface unit for ARMv7

The ARMv7 does not support the SWP/SWPB instructions for syncronisation (Lock/Mutex/Semaphore etc) unless enabled.

On ARMv7 Unaligned memory access is always enabled.

On ARMv7 the Extended Page Table format is always enabled.

For usage of barriers (DMB/DSB/ISB) after cache maintenance operations see: ARM.Reference_Manual_1.pdf - Appendix G Barrier Litmus Tests

Constants



[Expand]
ARMv7 page tables shift ARMV7_PAGE_TABLES_*


[Expand]
ARMv7 CP15 C0 main Id ARMV7_CP15_C0_MAINID_*


[Expand]
ARMv7 CP15 C0 multiprocessor affinity ARMV7_CP15_C0_MPID_*


[Expand]
ARMv7 CP15 C0 cache size Id ARMV7_CP15_C0_CCSID_*


[Expand]
ARMv7 CP15 C0 cache level Id ARMV7_CP15_C0_CLID_*


[Expand]
ARMv7 CP15 C0 cache size selection ARMV7_CP15_C0_CSSEL_*


[Expand]
ARMv7 CP15 C1 control ARMV7_CP15_C1_*


[Expand]
ARMv7 CP15 C1 auxiliary control ARMV7_CP15_C1_AUX_*


[Expand]
ARMv7 CP15 C1 coprocessor access control ARMV7_CP15_C1_CP*


[Expand]
ARMv7 CP15 C1 secure configuration ARMV7_CP15_C1_SCR_*


[Expand]
ARMv7 CP15 C2 translation table base ARMV7_CP15_C2_TTBR_*


[Expand]
ARMv7 CP15 C3 domain access control ARMV7_CP15_C3_DOMAIN*


[Expand]
ARMv7 CP15 C10 primary region remap ARMV7_CP15_C10_PRRR_*


[Expand]
ARMv7 CP15 C10 normal memory remap ARMV7_CP15_C10_NMRR_*


[Expand]
ARMv7 CP15 C14 generic timer control ARMV7_CP15_C14_CNT_CTL_*


[Expand]
ARMv7 CP15 C14 generic timer ARMV7_CP15_C14_*


[Expand]
ARMv7 floating-point exception ARMV7_FPEXC_*


[Expand]
ARMv7 level one descriptor type ARMV7_L1D_TYPE_*


[Expand]
ARMv7 level one descriptor flag ARMV7_L1D_FLAG_*


[Expand]
ARMv7 level one descriptor mask ARMV7_L1D_*_MASK


[Expand]
ARMv7 level one descriptor TEX value ARMV7_L1D_TEX*


[Expand]
ARMv7 level one descriptor AP value ARMV7_L1D_AP*


[Expand]
ARMv7 level one descriptor permission value ARMV7_L1D_ACCESS_*


[Expand]
ARMv7 level one descriptor cache value ARMV7_L1D_CACHE_*


[Expand]
ARMv7 level one descriptor cacheable memory value ARMV7_L1D_CACHE_CACHEABLE_*


[Expand]
ARMv7 level one descriptor cache TEX remap value ARMV7_L1D_CACHE_REMAP_*


[Expand]
ARMv7 level two descriptor type ARMV7_L2D_TYPE_*


[Expand]
ARMv7 level two descriptor flag ARMV7_L2D_FLAG_*


[Expand]
ARMv7 level two descriptor mask ARMV7_L2D_*_MASK


[Expand]
ARMv7 level two descriptor large TEX value ARMV7_L2D_LARGE_TEX*


[Expand]
ARMv7 level two descriptor small TEX value ARMV7_L2D_SMALL_TEX*


[Expand]
ARMv7 level two descriptor AP value ARMV7_L2D_AP*


[Expand]
ARMv7 level two descriptor permission value ARMV7_L2D_ACCESS_*


[Expand]
ARMv7 level two descriptor large cache value ARMV7_L2D_LARGE_CACHE_*


[Expand]
ARMv7 level two descriptor large cacheable memory value ARMV7_L2D_LARGE_CACHE_CACHEABLE_*


[Expand]
ARMv7 level two descriptor large cache TEX remap value ARMV7_L2D_LARGE_CACHE_REMAP_*


[Expand]
ARMv7 level two descriptor small cache value ARMV7_L2D_SMALL_CACHE_*


[Expand]
ARMv7 level two descriptor small cacheable memory value ARMV7_L2D_SMALL_CACHE_CACHEABLE_*


[Expand]
ARMv7 level two descriptor small cache TEX remap value ARMV7_L2D_SMALL_CACHE_REMAP_*


[Expand]
ARMv7 specific constants ARMV7_*


Type definitions



ARMv7 page table initialization

TARMv7PageTableInit = procedure;

ARMv7 dispatch IRQ

TARMv7DispatchIRQ = function(CPUID:LongWord; Thread:TThreadHandle):TThreadHandle;

ARMv7 dispatch FIQ

TARMv7DispatchFIQ = function(CPUID:LongWord; Thread:TThreadHandle):TThreadHandle;

ARMv7 dispatch SWI

TARMv7DispatchSWI = function(CPUID:LongWord; Thread:TThreadHandle; Request:PSystemCallRequest):TThreadHandle;


Public variables



ARMv7 specific variables

ARMv7Initialized:Boolean;

Page table handlers

ARMv7PageTableInitHandler:TARMv7PageTableInit;

IRQ handlers

ARMv7DispatchIRQHandler:TARMv7DispatchIRQ;

FIQ handlers

ARMv7DispatchFIQHandler:TARMv7DispatchFIQ;

SWI handlers

ARMv7DispatchSWIHandler:TARMv7DispatchSWI;


Function declarations



Initialization functions

[Expand]
procedure ARMv7Init;
Description: To be documented


ARMv7 platform functions

[Expand]
procedure ARMv7CPUInit; assembler; nostackframe;
Description: To be documented


[Expand]
procedure ARMv7FPUInit; assembler; nostackframe;
Description: To be documented


[Expand]
procedure ARMv7MMUInit;
Description: To be documented


[Expand]
procedure ARMv7CacheInit; assembler; nostackframe;
Description: To be documented


[Expand]
procedure ARMv7TimerInit(Frequency:LongWord); assembler; nostackframe;
Description: To be documented


[Expand]
procedure ARMv7PageTableInit;
Description: Initialize the Hardware Page Tables before enabling the MMU


[Expand]
procedure ARMv7SystemCall(Number:LongWord; Param1,Param2,Param3:PtrUInt);
Description: To be documented


[Expand]
function ARMv7CPUGetMode:LongWord; assembler; nostackframe;
Description: To be documented


[Expand]
function ARMv7CPUGetState:LongWord; assembler; nostackframe;
Description: To be documented


[Expand]
function ARMv7CPUGetCurrent:LongWord; assembler; nostackframe;
Description: To be documented


[Expand]
function ARMv7CPUGetMainID:LongWord; assembler; nostackframe;
Description: To be documented


[Expand]
function ARMv7CPUGetMultiprocessorID:LongWord; assembler; nostackframe;
Description: To be documented


[Expand]
function ARMv7CPUGetModel:LongWord;
Description: To be documented


[Expand]
function ARMv7CPUGetRevision:LongWord;
Description: To be documented


[Expand]
function ARMv7CPUGetDescription:String;
Description: To be documented


[Expand]
function ARMv7FPUGetState:LongWord; assembler; nostackframe;
Description: To be documented


[Expand]
function ARMv7L1CacheGetType:LongWord; assembler; nostackframe;
Description: To be documented


[Expand]
function ARMv7L1DataCacheGetSize:LongWord; assembler; nostackframe;
Description: To be documented


[Expand]
function ARMv7L1DataCacheGetLineSize:LongWord; assembler; nostackframe;
Description: To be documented


[Expand]
function ARMv7L1InstructionCacheGetSize:LongWord; assembler; nostackframe;
Description: To be documented


[Expand]
function ARMv7L1InstructionCacheGetLineSize:LongWord; assembler; nostackframe;
Description: To be documented


[Expand]
function ARMv7L2CacheGetType:LongWord; assembler; nostackframe;
Description: To be documented


[Expand]
function ARMv7L2CacheGetSize:LongWord; assembler; nostackframe;
Description: To be documented


[Expand]
function ARMv7L2CacheGetLineSize:LongWord; assembler; nostackframe;
Description: To be documented


[Expand]
procedure ARMv7Halt; assembler; nostackframe; public name '_haltproc';
Description: The purpose of the Wait For Interrupt operation is to put the processor in to a low power state


[Expand]
procedure ARMv7Pause; assembler; nostackframe;
Description: The purpose of the Wait For Interrupt operation is to put the processor in to a low power state


[Expand]
procedure ARMv7SendEvent; assembler; nostackframe;
Description: To be documented


[Expand]
procedure ARMv7WaitForEvent; assembler; nostackframe;
Description: To be documented


[Expand]
procedure ARMv7WaitForInterrupt; assembler; nostackframe;
Description: The purpose of the Wait For Interrupt operation is to put the processor in to a low power state


[Expand]
procedure ARMv7DataMemoryBarrier; assembler; nostackframe;
Description: Perform a data memory barrier operation using the c7 (Cache Operations) register of system control coprocessor CP15


[Expand]
procedure ARMv7DataSynchronizationBarrier; assembler; nostackframe;
Description: Perform a data synchronization barrier operation


[Expand]
procedure ARMv7InstructionMemoryBarrier; assembler; nostackframe;
Description: Perform a instruction synchronization barrier operation


[Expand]
procedure ARMv7InvalidateTLB; assembler; nostackframe;
Description: Perform an invalidate entire TLB operation using the c8 (TLB Operations) register of system control coprocessor CP15


[Expand]
procedure ARMv7InvalidateDataTLB; assembler; nostackframe;
Description: Perform an invalidate data TLB (Unlocked/Data) operation using the c8 (TLB Operations) register of system control coprocessor CP15


[Expand]
procedure ARMv7InvalidateInstructionTLB; assembler; nostackframe;
Description: Perform an invalidate instruction TLB (Unlocked/Instruction) operation using the c8 (TLB Operations) register of system control coprocessor CP15


[Expand]
procedure ARMv7InvalidateCache; assembler; nostackframe;
Description: Perform an invalidate both caches operation using the c7 (Cache Operations) register of system control coprocessor CP15


[Expand]
procedure ARMv7CleanDataCache; assembler; nostackframe;
Description: Perform a clean entire data cache operation


[Expand]
procedure ARMv7InvalidateDataCache; assembler; nostackframe;
Description: Perform an invalidate entire data cache operation


[Expand]
procedure ARMv7InvalidateL1DataCache; assembler; nostackframe;
Description: Perform an invalidate entire L1 data cache operation


[Expand]
procedure ARMv7CleanAndInvalidateDataCache; assembler; nostackframe;
Description: Perform a clean and invalidate entire data cache operation


[Expand]
procedure ARMv7InvalidateInstructionCache; assembler; nostackframe;
Description: Perform an invalidate entire instruction cache operation using the c7 (Cache Operations) register of system control coprocessor CP15


[Expand]
procedure ARMv7CleanDataCacheRange(Address:PtrUInt; Size:LongWord);
Description: Perform a clean data cache by MVA to PoC operation


[Expand]
procedure ARMv7InvalidateDataCacheRange(Address:PtrUInt; Size:LongWord);
Description: Perform an invalidate data cache by MVA to PoC operation


[Expand]
procedure ARMv7CleanAndInvalidateDataCacheRange(Address:PtrUInt; Size:LongWord);
Description: Perform a clean and invalidate data cache by MVA to PoC operation


[Expand]
procedure ARMv7InvalidateInstructionCacheRange(Address:PtrUInt; Size:LongWord);
Description: Perform an invalidate instruction caches by MVA to PoU operation


[Expand]
procedure ARMv7CleanDataCacheSetWay(SetWay:LongWord); assembler; nostackframe;
Description: Perform a clean data cache line by set/way operation


[Expand]
procedure ARMv7InvalidateDataCacheSetWay(SetWay:LongWord); assembler; nostackframe;
Description: Perform an invalidate data cache line by set/way operation


[Expand]
procedure ARMv7CleanAndInvalidateDataCacheSetWay(SetWay:LongWord); assembler; nostackframe;
Description: Perform a clean and invalidate data cache line by set/way operation


[Expand]
procedure ARMv7FlushPrefetchBuffer; assembler; nostackframe;
Description: Perform an Instruction Synchronization Barrier operation


[Expand]
procedure ARMv7FlushBranchTargetCache; assembler; nostackframe;
Description: Perform a Flush Entire Branch Target Cache operation


[Expand]
procedure ARMv7ContextSwitch(OldStack,NewStack:Pointer; NewThread:TThreadHandle); assembler; nostackframe;
Description: Perform a context switch from one thread to another as a result of a thread yielding, sleeping or waiting


[Expand]
procedure ARMv7ContextSwitchIRQ(OldStack,NewStack:Pointer; NewThread:TThreadHandle); assembler; nostackframe;
Description: Perform a context switch from one thread to another as a result of an interrupt request (IRQ)


[Expand]
procedure ARMv7ContextSwitchFIQ(OldStack,NewStack:Pointer; NewThread:TThreadHandle); assembler; nostackframe;
Description: Perform a context switch from one thread to another as a result of a fast interrupt request (FIQ)


[Expand]
procedure ARMv7ContextSwitchSWI(OldStack,NewStack:Pointer; NewThread:TThreadHandle); assembler; nostackframe; 
Description: Perform a context switch from one thread to another as a result of a software interrupt (SWI)


[Expand]
function ARMv7InterlockedOr(var Target:LongInt; Value:LongInt):LongInt; assembler; nostackframe;
Description: Perform an atomic OR operation using LDREX/STREX


[Expand]
function ARMv7InterlockedXor(var Target:LongInt; Value:LongInt):LongInt; assembler; nostackframe;
Description: Perform an atomic XOR operation using LDREX/STREX


[Expand]
function ARMv7InterlockedAnd(var Target:LongInt; Value:LongInt):LongInt; assembler; nostackframe;
Description: Perform an atomic AND operation using LDREX/STREX


[Expand]
function ARMv7InterlockedDecrement(var Target:LongInt):LongInt; assembler; nostackframe;
Description: Perform an atomic decrement operation using LDREX/STREX


[Expand]
function ARMv7InterlockedIncrement(var Target:LongInt):LongInt; assembler; nostackframe;
Description: Perform an atomic increment operation using LDREX/STREX


[Expand]
function ARMv7InterlockedExchange(var Target:LongInt; Source:LongInt):LongInt; assembler; nostackframe;
Description: Perform an atomic exchange operation using LDREX/STREX


[Expand]
function ARMv7InterlockedAddExchange(var Target:LongInt; Source:LongInt):LongInt; assembler; nostackframe;
Description: Perform an atomic add and exchange operation using LDREX/STREX


[Expand]
function ARMv7InterlockedCompareExchange(var Target:LongInt; Source,Compare:LongInt):LongInt; assembler; nostackframe;
Description: Perform an atomic compare and exchange operation using LDREX/STREX


[Expand]
procedure ARMv7PageTableGetEntry(Address:PtrUInt; var Entry:TPageTableEntry);
Description: Get and Decode the entry in the Page Table that corresponds to the supplied virtual address


[Expand]
function ARMv7PageTableSetEntry(const Entry:TPageTableEntry):LongWord;
Description: Encode and Set an entry in the Page Table that corresponds to the supplied virtual address


[Expand]
function ARMv7VectorTableGetEntry(Number:LongWord):PtrUInt;
Description: Return the address of the specified vector table entry number


[Expand]
function ARMv7VectorTableSetEntry(Number:LongWord; Address:PtrUInt):LongWord;
Description: Set the supplied address as the value of the specified vector table entry number


[Expand]
function ARMv7FirstBitSet(Value:LongWord):LongWord; assembler; nostackframe; 
Description: To be documented


[Expand]
function ARMv7CountLeadingZeros(Value:LongWord):LongWord; assembler; nostackframe;
Description: Equivalent of the GCC Builtin function __builtin_clz


ARMv7 thread functions

[Expand]
procedure ARMv7PrimaryInit; assembler; nostackframe;
Description: To be documented


[Expand]
function ARMv7SpinLock(Spin:PSpinEntry):LongWord; assembler; nostackframe;
Description: Lock an existing Spin entry


[Expand]
function ARMv7SpinUnlock(Spin:PSpinEntry):LongWord; assembler; nostackframe;
Description: Unlock an existing Spin entry


[Expand]
function ARMv7SpinLockIRQ(Spin:PSpinEntry):LongWord; assembler; nostackframe;
Description: Lock an existing Spin entry, disable IRQ and save the previous IRQ state


[Expand]
function ARMv7SpinUnlockIRQ(Spin:PSpinEntry):LongWord; assembler; nostackframe;
Description: Unlock an existing Spin entry and restore the previous IRQ state


[Expand]
function ARMv7SpinLockFIQ(Spin:PSpinEntry):LongWord; assembler; nostackframe;
Description: Lock an existing Spin entry, disable FIQ and save the previous FIQ state


[Expand]
function ARMv7SpinUnlockFIQ(Spin:PSpinEntry):LongWord; assembler; nostackframe;
Description: Unlock an existing Spin entry and restore the previous FIQ state


[Expand]
function ARMv7SpinLockIRQFIQ(Spin:PSpinEntry):LongWord; assembler; nostackframe;
Description: Lock an existing Spin entry, disable IRQ and FIQ and save the previous IRQ/FIQ state


[Expand]
function ARMv7SpinUnlockIRQFIQ(Spin:PSpinEntry):LongWord; assembler; nostackframe;
Description: Unlock an existing Spin entry and restore the previous IRQ/FIQ state


[Expand]
function ARMv7SpinCheckIRQ(Spin:PSpinEntry):Boolean;
Description: To be documented


[Expand]
function ARMv7SpinCheckFIQ(Spin:PSpinEntry):Boolean;
Description: To be documented


[Expand]
function ARMv7SpinExchangeIRQ(Spin1,Spin2:PSpinEntry):LongWord;
Description: To be documented


[Expand]
function ARMv7SpinExchangeFIQ(Spin1,Spin2:PSpinEntry):LongWord;
Description: To be documented


[Expand]
function ARMv7MutexLock(Mutex:PMutexEntry):LongWord; assembler; nostackframe;
Description: Lock an existing Mutex entry


[Expand]
function ARMv7MutexUnlock(Mutex:PMutexEntry):LongWord; assembler; nostackframe;
Description: Unlock an existing Mutex entry


[Expand]
function ARMv7MutexTryLock(Mutex:PMutexEntry):LongWord; assembler; nostackframe;
Description: Try to lock an existing Mutex entry


[Expand]
function ARMv7ThreadGetCurrent:TThreadHandle; assembler; nostackframe;
Description: Get the current thread Id from the c13 (Thread and process ID) register of system control coprocessor CP15


[Expand]
function ARMv7ThreadSetCurrent(Thread:TThreadHandle):LongWord; assembler; nostackframe;
Description: Set the current thread Id in the c13 (Thread and process ID) register of system control coprocessor CP15


[Expand]
function ARMv7ThreadSetupStack(StackBase:Pointer; StartProc:TThreadStart; ReturnProc:TThreadEnd; Parameter:Pointer):Pointer;
Description: Set up the context record and arguments on the stack for a new thread


ARMv7 IRQ functions

[Expand]
function ARMv7DispatchIRQ(CPUID:LongWord; Thread:TThreadHandle):TThreadHandle; inline;
Description: To be documented


ARMv7 FIQ functions

[Expand]
function ARMv7DispatchFIQ(CPUID:LongWord; Thread:TThreadHandle):TThreadHandle; inline;
Description: To be documented


ARMv7 SWI functions

[Expand]
function ARMv7DispatchSWI(CPUID:LongWord; Thread:TThreadHandle; Request:PSystemCallRequest):TThreadHandle; inline;
Description: To be documented


ARMv7 interrupt functions

[Expand]
procedure ARMv7ResetHandler; assembler; nostackframe;
Description: To be documented


[Expand]
procedure ARMv7UndefinedInstructionHandler; assembler; nostackframe;
Description: Handle an undefined instruction exception


[Expand]
procedure ARMv7SoftwareInterruptHandler; assembler; nostackframe;
Description: Handle a software interrupt (SWI) from a system call (SVC)


[Expand]
procedure ARMv7PrefetchAbortHandler; assembler; nostackframe;
Description: Handle a prefetch abort exception


[Expand]
procedure ARMv7DataAbortHandler; assembler; nostackframe;
Description: Handle a data abort exception


[Expand]
procedure ARMv7ReservedHandler; assembler; nostackframe;
Description: To be documented


[Expand]
procedure ARMv7IRQHandler; assembler; nostackframe;
Description: Handle an interrupt request IRQ from an interrupt source


[Expand]
procedure ARMv7FIQHandler; assembler; nostackframe;
Description: Handle a fast interrupt request FIQ from an interrupt source


ARMv7 helper functions

[Expand]
function ARMv7GetFPEXC:LongWord; assembler; nostackframe;
Description: To be documented


[Expand]
function ARMv7GetFPSCR:LongWord; assembler; nostackframe;
Description: To be documented


[Expand]
procedure ARMv7StartMMU; assembler; nostackframe;
Description: To be documented


[Expand]
function ARMv7GetTimerState(Timer:LongWord):LongWord; assembler; nostackframe;
Description: To be documented


[Expand]
procedure ARMv7SetTimerState(Timer,State:LongWord); assembler; nostackframe;
Description: To be documented


[Expand]
function ARMv7GetTimerCount(Timer:LongWord):Int64; assembler; nostackframe;
Description: To be documented


[Expand]
function ARMv7GetTimerValue(Timer:LongWord):LongWord; assembler; nostackframe;
Description: To be documented


[Expand]
procedure ARMV7SetTimerValue(Timer,Value:LongWord); assembler; nostackframe;
Description: To be documented


[Expand]
function ARMv7GetTimerCompare(Timer:LongWord):Int64; assembler; nostackframe;
Description: To be documented


[Expand]
procedure ARMV7SetTimerCompare(Timer,High,Low:LongWord); assembler; nostackframe;
Description: To be documented


[Expand]
function ARMv7GetTimerFrequency:LongWord; assembler; nostackframe;
Description: To be documented


[Expand]
function ARMv7GetPageTableCoarse(Address:PtrUInt):LongWord;
Description: Get the descriptor for a Coarse Page Table entry (1MB)


[Expand]
function ARMv7SetPageTableCoarse(Address,CoarseAddress:PtrUInt; Flags:Word):Boolean;
Description: Set the descriptor for a Coarse Page Table entry (1MB)


[Expand]
function ARMv7GetPageTableLarge(Address:PtrUInt):LongWord;
Description: Get the descriptor for a Large Page Table entry (64KB)


[Expand]
function ARMv7SetPageTableLarge(Address,PhysicalAddress:PtrUInt; Flags:Word):Boolean;
Description: Set the descriptor for a Large Page Table entry (64KB)


[Expand]
function ARMv7GetPageTableSmall(Address:PtrUInt):LongWord;
Description: Get the descriptor for a Small Page Table entry (4KB)


[Expand]
function ARMv7SetPageTableSmall(Address,PhysicalAddress:PtrUInt; Flags:Word):Boolean;
Description: Set the descriptor for a Small Page Table entry (4KB)


[Expand]
function ARMv7GetPageTableSection(Address:PtrUInt):LongWord;
Description: Get the descriptor for a Page Table Section (1MB) or Supersection (16MB)


[Expand]
function ARMv7SetPageTableSection(Address,PhysicalAddress:PtrUInt; Flags:LongWord):Boolean;
Description: Set the descriptor for a Page Table Section (1MB)


[Expand]
function ARMv7SetPageTableSupersection(Address,PhysicalAddress:PtrUInt; Flags:LongWord):Boolean;
Description: Set the descriptor for a Page Table Supersection (16MB)


Return to Unit Reference