Difference between revisions of "Unit PlatformARM"

From Ultibo.org
Jump to: navigation, search
 
(6 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
----
 
----
  
'''Ultibo Platform interface unit for ARM'''
+
'''Ultibo Platform Interface unit for ARM'''
 
+
''To be documented''
+
  
 
=== Constants ===
 
=== Constants ===
Line 139: Line 137:
 
|  
 
|  
 
|-
 
|-
| <code>ATAG_INITRD2 = $54410005;</code>
+
| <code>ATAG_INITRD = $54410005;</code>
 +
| Deprecated
 +
|-
 +
| <code>ATAG_INITRD2 = $54420005;</code>
 
| &nbsp;
 
| &nbsp;
 
|-
 
|-
Line 162: Line 163:
 
</div></div>
 
</div></div>
 
<br />
 
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''Device tree blob''' <code> DTB_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>DTB_SIGNATURE = $d00dfeed;</code>
 +
| style="width: 50%;"|See: https://github.com/devicetree-org/devicetree-specification/releases/download/v0.3/devicetree-specification-v0.3.pdf
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 
<div style="font-size: 14px; padding-left: 12px;">'''ARM machine type''' <code> ARM_MACHINE_* </code></div>
 
<div style="font-size: 14px; padding-left: 12px;">'''ARM machine type''' <code> ARM_MACHINE_* </code></div>
Line 317: Line 329:
 
</div></div>   
 
</div></div>   
 
   
 
   
'''ARM tag initialize ramdisk'''  
+
'''Tag initialize RD'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TagInitRdCount:LongWord;</code>
 +
| style="width: 40%;"|Number of ARM INITRD Tags found during parse (Deprecated)
 +
|-
 +
|}
 
   
 
   
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
+
'''Tag initialize RD2'''
<code>PARMTagInitRd2 = ^TARMTagInitRd2;</code>
+
  
<code>TARMTagInitRd2 = record</code>
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
+
{| class="wikitable" style="font-size: 14px; background: white;"
+
 
|-
 
|-
|colspan="2"|Note: Description of the physical location of the compressed ramdisk image (ATAG_INITRD2)
+
| <code>TagInitRd2Count:LongWord;</code>
 +
| style="width: 40%;"|Number of ARM INITRD2 Tags found during parse
 
|-
 
|-
| <code>Start:LongWord;</code>
+
|}
| Physical start address
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 
|-
 
|-
| <code>Size:LongWord;</code>
+
| <code>TagInitRd2Start:LongWord;</code>
| Size of compressed ramdisk image in bytes
+
| style="width: 40%;"|
 
|-
 
|-
 
|}
 
|}
</div></div>   
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TagInitRd2Size:LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}  
 
    
 
    
 
'''ARM tag serial'''  
 
'''ARM tag serial'''  
Line 441: Line 463:
 
|colspan="2"|Note: Commandline for the kernel (ATAG_CMDLINE)
 
|colspan="2"|Note: Commandline for the kernel (ATAG_CMDLINE)
 
|-
 
|-
| <code>Cmdline:array[0..0] of Char;</code>
+
| <code>Cmdline:array[0..0] of AnsiChar;</code>
 
| This is the minimum size
 
| This is the minimum size
 
|-
 
|-
Line 490: Line 512:
 
| <code>8:(Command:TARMTagCommand)</code>
 
| <code>8:(Command:TARMTagCommand)</code>
 
| &nbsp;
 
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 +
'''Device tree blob header'''
 +
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PDTBHeader = ^TDTBHeader;</code>
 +
 +
<code>TDTBHeader = packed record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Magic:LongWord;</code>
 +
| The value 0xd00dfeed (big-endian)
 +
|-
 +
| <code>TotalSize:LongWord;</code>
 +
| The total size in bytes of the devicetree data structure (big-endian)
 +
|-
 +
| <code>StructureOffset:LongWord;</code>
 +
| The offset in bytes of the structure block from the beginning of the header (big-endian)
 +
|-
 +
| <code>StringsOffset:LongWord;</code>
 +
| The offset in bytes of the strings block from the beginning of the header (big-endian)
 +
|-
 +
| <code>ReservationOffset:LongWord;</code>
 +
| The offset in bytes of the memory reservation block from the beginning of the header (big-endian)
 +
|-
 +
| <code>Version:LongWord;</code>
 +
| The version of the devicetree data structure (big-endian)
 +
|-
 +
| <code>CompatibleVersion:LongWord;</code>
 +
| The lowest version of the devicetree data structure with which the version used is backwards compatible (big-endian)
 +
|-
 +
| <code>BootCPUID:LongWord;</code>
 +
| The physical ID of the system’s boot CPU (big-endian)
 +
|-
 +
| <code>StringsSize:LongWord;</code>
 +
| The length in bytes of the strings block section of the devicetree blob (big-endian)
 +
|-
 +
| <code>StructureSize:LongWord;</code>
 +
| The length in bytes of the structure block section of the devicetree blob (big-endian)
 
|-
 
|-
 
|}
 
|}
Line 762: Line 826:
 
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 
|-
 
|-
| <code>TagCommandAddress:PChar;</code>
+
| <code>TagCommandAddress:PAnsiChar;</code>
 
| style="width: 40%;"|Pointer to the start of the command line
 
| style="width: 40%;"|Pointer to the start of the command line
 
|-
 
|-
Line 828: Line 892:
 
<pre style="border: 0; padding-bottom:0px;">procedure ARMParseBootTags;</pre>
 
<pre style="border: 0; padding-bottom:0px;">procedure ARMParseBootTags;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Extract some information from the ARM boot tag list and use it to load the memory manager, some other information is stored in variables for future use</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Extract some information from the ARM boot tag list and use it to load the memory manager, some other information is stored in variables for future use</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function ExtractCommandLine(Value:PAnsiChar):Boolean;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function ExtractMemoryBlock(Address,Size:LongWord):Boolean;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function ExtractInitialRamdisk(Address,Size:LongWord):Boolean;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"

Latest revision as of 06:17, 6 September 2024

Return to Unit Reference


Description


Ultibo Platform Interface unit for ARM

Constants



[Expand]
ARM mode ARM_MODE_*


[Expand]
ARM interrupt disable ARM_I_*


[Expand]
ARM thumb and jazelle ARM_*_BIT


[Expand]
ARM abort ARM_A_*


[Expand]
ARM boot tag ATAG_*



[Expand]
ARM machine type ARM_MACHINE_*


Type definitions



ARM boot tag header

[Expand]

PARMTagHeader = ^TARMTagHeader;

TARMTagHeader = record

ARM tag core

[Expand]

PARMTagCore = ^TARMTagCore;

TARMTagCore = record

ARM tag memory

[Expand]

PARMTagMemory = ^TARMTagMemory;

TARMTagMemory = record

ARM tag video text

[Expand]

PARMTagVideoText = ^TARMTagVideoText;

TARMTagVideoText = record

ARM tag ramdisk

[Expand]

PARMTagRamdisk = ^TARMTagRamdisk;

TARMTagRamdisk = record

Tag initialize RD

TagInitRdCount:LongWord; Number of ARM INITRD Tags found during parse (Deprecated)

Tag initialize RD2

TagInitRd2Count:LongWord; Number of ARM INITRD2 Tags found during parse
TagInitRd2Start:LongWord;
TagInitRd2Size:LongWord;

ARM tag serial

[Expand]

PARMTagSerial = ^TARMTagSerial;

TARMTagSerial = record

ARM tag revision

[Expand]

PARMTagRevision = ^TARMTagRevision;

TARMTagRevision = record

ARM tag video framebuffer

[Expand]

PARMTagVideoFB = ^TARMTagVideoFB;

TARMTagVideoFB = record

ARM tag command

[Expand]

PARMTagCommand = ^TARMTagCommand;

TARMTagCommand = record

ARM boot tag

[Expand]

PARMTag = ^TARMTag;

TARMTag = record

Device tree blob header

[Expand]

PDTBHeader = ^TDTBHeader;

TDTBHeader = packed record

ARM wait

TARMWait = procedure;

ARM long wait

TARMLongWait = procedure;

ARM short wait

TARMShortWait = procedure;

ARM slow blink

TARMSlowBlink = procedure;

ARM fast blink

TARMFastBlink = procedure;


Public variables



ARM specific variables

ARMInitialized:Boolean;
ARMBootMode:LongWord = 0; The ARM Mode that the processor was in at boot time (Set by Startup)
ARMBootVectors:LongWord = 0; The Vector Base Address that was current at boot time (Set by Startup)
ARMTagsAddress:PtrUInt = ARMTAGS_INITIAL; Pointer to the ARM TAGS provided by the bootloader at startup (Set by Startup)
ARMMachineType:LongWord = 0; ARM Machine Type provided by the bootloader at startup (Set by Startup)
ARMSecureBoot:LongWord = 1; If 1 then startup will attempt to switch back to secure world during boot process (If supported by the ARM boot stub)
ARMEmulatorMode:LongWord = 0; If 1 then startup detected that the machine is running in an emulator (If applicable)

Note: These variables must be initialized to remain in .data or else they are rewritten to zero with .bss

ARM tags

ARMTagsCount:LongWord; Number of ARM Tags found during parse

Tag none variables

TagNoneCount:LongWord; Number of ARM NONE Tags found during parse

Tag core

TagCoreCount:LongWord; Number of ARM CORE Tags found during parse
TagCoreFlags:LongWord;
TagCorePageSize:LongWord;
TagCoreRootDevice:LongWord;

Tag memory

TagMemoryCount:LongWord; Number of ARM MEM Tags found during parse
TagMemorySize:LongWord; Size of the last block reported by ARM Tags
TagMemoryStart:PtrUInt; Start of the last block reported by ARM Tags
TagMemoryLength:LongWord; Adjusted Size of the last block reported by ARM Tags
TagMemoryAddress:PtrUInt; Adjusted Address of the last block reported by ARM Tags

Tag video text

TagVideoTextCount:LongWord; Number of ARM VIDEOTEXT Tags found during parse

Tag ramdisk

TagRamdiskCount:LongWord; Number of ARM RAMDISK Tags found during parse

Tag initialize RD2

TagInitRd2Count:LongWord; Number of ARM INITRD2 Tags found during parse

Tag serial

TagSerialCount:LongWord; Number of ARM SERIAL Tags found during parse
TagSerialNoLow:LongWord;
TagSerialNoHigh:LongWord;

Tag revision

TagRevisionCount:LongWord; Number of ARM REVISION Tags found during parse
TagRevisionNo:LongWord;

Tag video framebuffer

TagVideoFBCount:LongWord; Number of ARM VIDEOLFB Tags found during parse

Tag command

TagCmdCount:LongWord; Number of ARM CMDLINE Tags found during parse
TagCommandSize:LongWord; Length of the command line in characters (Including null terminator)
TagCommandCount:LongInt; Count of parameters (space delimited) in the command line
TagCommandAddress:PAnsiChar; Pointer to the start of the command line

Wait handlers

ARMWaitHandler:TARMWait;
ARMLongWaitHandler:TARMLongWait;
ARMShortWaitHandler:TARMShortWait;

Blink handlers

ARMSlowBlinkHandler:TARMSlowBlink;
ARMFastBlinkHandler:TARMFastBlink;


Function declarations



Initialization functions

[Expand]
procedure ARMInit;
Description: To be documented


ARM platform functions

[Expand]
procedure ARMParseBootTags;
Description: Extract some information from the ARM boot tag list and use it to load the memory manager, some other information is stored in variables for future use


[Expand]
function ExtractCommandLine(Value:PAnsiChar):Boolean;
Description: To be documented


[Expand]
function ExtractMemoryBlock(Address,Size:LongWord):Boolean;
Description: To be documented


[Expand]
function ExtractInitialRamdisk(Address,Size:LongWord):Boolean;
Description: To be documented


[Expand]
procedure ARMParseCommandLine;
Description: Setup argc, argv and cmdline and process known command line options


[Expand]
procedure ARMParseEnvironment;
Description: Setup envp and process known environment options


[Expand]
function ARMGetSP:PtrUInt; assembler; nostackframe;
Description: Get the current stack pointer (SP)


[Expand]
function ARMGetPC:PtrUInt; assembler; nostackframe;
Description: Get the current program counter (PC)


[Expand]
function ARMGetIRQ:Boolean; assembler; nostackframe;
Description: Get Interrupts (IRQ) state


[Expand]
procedure ARMEnableIRQ; assembler; nostackframe;
Description: Enable Interrupts (IRQ) unconditionally


[Expand]
procedure ARMDisableIRQ; assembler; nostackframe;
Description: Disable Interrupts (IRQ) unconditionally


[Expand]
function ARMSaveIRQ:TIRQMask; assembler; nostackframe;
Description: Disable Interrupts (IRQ) and return the previous state


[Expand]
function ARMRestoreIRQ(IRQMask:TIRQMask):TIRQMask; assembler; nostackframe;
Description: Restore Interrupts (IRQ) to a previous state


[Expand]
function ARMGetFIQ:Boolean; assembler; nostackframe;
Description: Get Fast Interrupts (FIQ) state


[Expand]
procedure ARMEnableFIQ; assembler; nostackframe;
Description: Enable Fast Interrupts (FIQ) unconditionally


[Expand]
procedure ARMDisableFIQ; assembler; nostackframe;
Description: Disable Fast Interrupts (FIQ) unconditionally


[Expand]
function ARMSaveFIQ:TFIQMask; assembler; nostackframe;
Description: Disable Fast Interrupts (FIQ) and return the previous state


[Expand]
function ARMRestoreFIQ(FIQMask:TFIQMask):TFIQMask; assembler; nostackframe;
Description: Restore Fast Interrupts (FIQ) to a previous state


[Expand]
procedure ARMEnableIRQFIQ; assembler; nostackframe;
Description: Enable Interrupts and Fast Interrupts (IRQ/FIQ) unconditionally


[Expand]
procedure ARMDisableIRQFIQ; assembler; nostackframe;
Description: Disable Interrupts and Fast Interrupts (IRQ/FIQ) unconditionally


[Expand]
function ARMSaveIRQFIQ:TIRQFIQMask; assembler; nostackframe;
Description: Disable Interrupts and Fast Interrupts (IRQ/FIQ) and return the previous state


[Expand]
function ARMRestoreIRQFIQ(IRQFIQMask:TIRQFIQMask):TIRQFIQMask; assembler; nostackframe;
Description: Restore Interrupts and Fast Interrupts (IRQ/FIQ) to a previous state


[Expand]
function ARMGetAbort:Boolean; assembler; nostackframe;
Description: Get Abort state


[Expand]
procedure ARMEnableAbort; assembler; nostackframe;
Description: Enable Aborts unconditionally


[Expand]
procedure ARMDisableAbort; assembler; nostackframe;
Description: Disable Aborts unconditionally


[Expand]
function ARMSaveAbort:TAbortMask; assembler; nostackframe;
Description: Disable Aborts and return the previous state


[Expand]
function ARMRestoreAbort(AbortMask:TAbortMask):TAbortMask; assembler; nostackframe;
Description: Restore Aborts to a previous state


ARM helper functions

[Expand]
procedure ARMWait; inline;
Description: To be documented


[Expand]
procedure ARMLongWait; inline;
Description: To be documented


[Expand]
procedure ARMShortWait; inline;
Description: To be documented


[Expand]
procedure ARMSlowBlink; inline;
Description: To be documented


[Expand]
procedure ARMFastBlink; inline;
Description: To be documented


[Expand]
function ARMModeToString(ARMMode:LongWord):String;
Description: To be documented


Return to Unit Reference