Unit PlatformRPi

From Ultibo.org
Revision as of 03:54, 10 November 2016 by Ultibo (Talk | contribs)

Jump to: navigation, search

Return to Unit Reference


Description


The RPi A+/B+ have the Power LED connected to GPIO Pin 35 (Activity LED is now on GPIO Pin 47 instead of Pin 16 in model A/B).

Constants


To be documented

Type definitions


To be documented

Public variables


To be documented

Function declarations



Initialization functions

procedure RPiInit;
Description: To be documented
Note None documented


RPi platform functions

procedure RPiBoardInit;
Description: To be documented
Note None documented


procedure RPiMemoryInit;
Description: To be documented
Note None documented


procedure RPiClockInit;
Description: To be documented
Note None documented


procedure RPiPowerInit;
Description: To be documented
Note None documented


procedure RPiMailboxInit;
Description: To be documented
Note None documented


procedure RPiInterruptInit;
Description: To be documented
Note None documented


procedure RPiPeripheralInit;
Description: To be documented
Note None documented


procedure RPiFramebufferInit;
Description: To be documented
Note None documented


procedure RPiPageTableInit;
Description: Initialize the Hardware Page Tables before enabling the MMU
Note See page 6-36 of the ARM1176JZF-S Technical Reference Manual


procedure RPiPowerLEDEnable;
Description: To be documented
Note None documented


procedure RPiPowerLEDOn;
Description: To be documented
Note None documented


procedure RPiPowerLEDOff;
Description: To be documented
Note None documented


procedure RPiActivityLEDEnable;
Description: To be documented
Note None documented


procedure RPiActivityLEDOn;
Description: To be documented
Note None documented


procedure RPiActivityLEDOff;
Description: To be documented
Note None documented


function RPiMailboxReceive(Mailbox,Channel:LongWord):LongWord;
Description: Receive from specified mailbox on specified channel
Note Data = first 28 bits, Channel = last 4 bits


procedure RPiMailboxSend(Mailbox,Channel,Data:LongWord);
Description: Send to specified mailbox on specified channel
Note Data = first 28 bits, Channel = last 4 bits


function RPiMailboxCall(Mailbox,Channel,Data:LongWord; var Response:LongWord):LongWord;
Description: Perform a transaction (Send/Receive) to specified mailbox on specified channel
Note Data = first 28 bits, Channel = last 4 bits

Data pointer must be 16 byte aligned to allow for the 4 bit channel number


function RPiMailboxCallEx(Mailbox,Channel,Data:LongWord; var Response:LongWord; Timeout:LongWord):LongWord;
Description: Perform a transaction (Send/Receive) to specified mailbox on specified channel
Note Data = first 28 bits, Channel = last 4 bits

Data pointer must be 16 byte aligned to allow for the 4 bit channel number


function RPiMailboxPropertyCall(Mailbox,Channel:LongWord; Data:Pointer; var Response:LongWord):LongWord;
Description: Perform a property tag transaction (Send/Receive) to specified mailbox on specified channel
Note Data = first 28 bits, Channel = last 4 bits

Data pointer must be 16 byte aligned to allow for the 4 bit channel number


function RPiMailboxPropertyCallEx(Mailbox,Channel:LongWord; Data:Pointer; var Response:LongWord; Timeout:LongWord):LongWord;
Description: Perform a property tag transaction (Send/Receive) to specified mailbox on specified channel
Note Data = first 28 bits, Channel = last 4 bits

Data pointer must be 16 byte aligned to allow for the 4 bit channel number


function RPiRequestExIRQ(CPUID,Number:LongWord; Handler:TInterruptHandler; HandlerEx:TInterruptExHandler; Parameter:Pointer):LongWord;
Description: Request registration of the supplied handler to the specified IRQ number
CPUID CPU to route IRQ to (Ignored on RPi)
Number IRQ number to register
Handler Interrupt handler function to register
HandlerEx Extended Interrupt handler function to register
Note Only one of Handler or HandlerEx can be specified


function RPiReleaseExIRQ(CPUID,Number:LongWord; Handler:TInterruptHandler; HandlerEx:TInterruptExHandler; Parameter:Pointer):LongWord;
Description: Request deregistration of the supplied handler from the specified IRQ number
CPUID CPU to route IRQ to (Ignored on RPi)
Number IRQ number to deregister
Handler Interrupt handler function to deregister
HandlerEx Extended Interrupt handler function to deregister
Note Only one of Handler or HandlerEx can be specified


function RPiRequestExFIQ(CPUID,Number:LongWord; Handler:TInterruptHandler; HandlerEx:TInterruptExHandler; Parameter:Pointer):LongWord;
Description: Request registration of the supplied handler to the specified FIQ number
CPUID CPU to route FIQ to (Ignored on RPi)
Number FIQ number to register
Handler Interrupt handler function to register
HandlerEx Extended Interrupt handler function to register
Note Only one of Handler or HandlerEx can be specified


function RPiReleaseExFIQ(CPUID,Number:LongWord; Handler:TInterruptHandler; HandlerEx:TInterruptExHandler; Parameter:Pointer):LongWord;
Description: Request deregistration of the supplied handler from the specified FIQ number
CPUID CPU to route FIQ to (Ignored on RPi)
Number FIQ number to deregister
Handler Interrupt handler function to deregister
HandlerEx Extended Interrupt handler function to deregister
Note Only one of Handler or HandlerEx can be specified


function RPiRegisterSystemCallEx(CPUID,Number:LongWord; Handler:TSystemCallHandler; HandlerEx:TSystemCallExHandler):LongWord;
Description: Request registration of the supplied extended handler to the specified System Call number
CPUID The CPU ID to register the System Call against (Ignored on RPi)
Number The System Call number to be registered
Handler The handler function to be registered
HandlerEx The extended handler function to be registered
Note Only one of Handler or HandlerEx can be specified


function RPiDeregisterSystemCallEx(CPUID,Number:LongWord; Handler:TSystemCallHandler; HandlerEx:TSystemCallExHandler):LongWord;
Description: Request deregistration of the supplied extended handler from the specified System Call number
CPUID The CPU ID to deregister the System Call from (Ignored on RPi)
Number The System Call number to be deregistered
Handler The handler function to be deregistered
HandlerEx The extended handler function to be deregistered
Note Only one of Handler or HandlerEx can be specified


function RPiGetInterruptEntry(Number:LongWord):TInterruptEntry;
Description: Get the interrupt entry for the specified interrupt number
Note None documented


function RPiGetSystemCallEntry(Number:LongWord):TSystemCallEntry;
Description: To be documented
Note Get the system call entry for the specified system call number


function RPiSystemRestart(Delay:LongWord):LongWord;
Description: To be documented
Note None documented


function RPiSystemShutdown(Delay:LongWord):LongWord;
Description: To be documented
Note None documented


function RPiSystemGetCommandLine:String;
Description: Get the Command Line from the Mailbox property tags channel
Note None documented


function RPiCPUGetMemory(var Address:PtrUInt; var Length:LongWord):LongWord;
Description: Get the CPU Memory from the Mailbox property tags channel
Note None documented


function RPiGPUGetState:LongWord;
Description: To be documented
Note None documented


function RPiGPUGetMemory(var Address:PtrUInt; var Length:LongWord):LongWord;
Description: Get the GPU Memory from the Mailbox property tags channel
Note None documented


function RPiBoardGetModel:LongWord;
Description: Get the Board Model from the Mailbox property tags channel
Note None documented


function RPiBoardGetSerial:Int64;
Description: Get the Board Serial from the Mailbox property tags channel
Note None documented


function RPiBoardGetRevision:LongWord;
Description: Get the Board Revision from the Mailbox property tags channel
Note None documented


function RPiBoardGetMACAddress:String;
Description: Get the Board MAC Address from the Mailbox property tags channel
Note None documented


function RPiFirmwareGetRevision:LongWord;
Description: Get the Firmware Revision from the Mailbox property tags channel
Note None documented


function RPiPowerGetWait(PowerId:LongWord):LongWord;
Description: Get the Power Wait from the Mailbox property tags channel
Note None documented


function RPiPowerGetState(PowerId:LongWord):LongWord;
Description: Get the Power State from the Mailbox property tags channel
Note None documented


function RPiPowerSetState(PowerId,State:LongWord; Wait:Boolean):LongWord;
Description: Set the Power State in the Mailbox property tags channel
Note Power Lock not required due to Mailbox Property Call serialization


function RPiClockGetCount:LongWord;
Description: Gets the current system clock count (32 least significant bits of total)
Note On the Raspberry Pi this comes from the System Timer free running counter which runs at 1MHz and therefore overflows every 4295 seconds


function RPiClockGetTotal:Int64;
Description: Gets the total system clock count
Note On the Raspberry Pi this comes from the System Timer free running counter which runs at 1MHz, the clock interrupt also uses this timer to increment the clock every second and therefore keep time.


function RPiClockGetRate(ClockId:LongWord):LongWord;
Description: Get the Clock Rate from the Mailbox property tags channel
Note None documented


function RPiClockSetRate(ClockId,Rate:LongWord; Turbo:Boolean):LongWord;
Description: Set the Clock Rate in the Mailbox property tags channel
Note None documented


function RPiClockGetState(ClockId:LongWord):LongWord;
Description: Get the Clock State from the Mailbox property tags channel
Note None documented


function RPiClockSetState(ClockId,State:LongWord):LongWord;
Description: Set the Clock State in the Mailbox property tags channel
Note None documented


function RPiClockGetMinRate(ClockId:LongWord):LongWord;
Description: Get the Clock Min Rate from the Mailbox property tags channel
Note None documented


function RPiClockGetMaxRate(ClockId:LongWord):LongWord;
Description: Get the Clock Max Rate from the Mailbox property tags channel
Note None documented


function RPiTurboGetState(TurboId:LongWord):LongWord;
Description: Get the Turbo State from the Mailbox property tags channel
Note None documented


function RPiTurboSetState(TurboId,State:LongWord):LongWord;
Description: Set the Turbo State in the Mailbox property tags channel
Note None documented


function RPiVoltageGetValue(VoltageId:LongWord):LongWord;
Description: Get the Voltage Value from the Mailbox property tags channel
Note None documented


function RPiVoltageSetValue(VoltageId,Value:LongWord):LongWord;
Description: Set the Voltage Value in the Mailbox property tags channel
Note None documented


function RPiVoltageGetMinValue(VoltageId:LongWord):LongWord;
Description: Get the Voltage Min Value from the Mailbox property tags channel
Note None documented


function RPiVoltageGetMaxValue(VoltageId:LongWord):LongWord;
Description: Get the Voltage Max Value from the Mailbox property tags channel
Note None documented


function RPiTemperatureGetCurrent(TemperatureId:LongWord):LongWord;
Description: Get the Temperature Current from the Mailbox property tags channel
Note None documented


function RPiTemperatureGetMaximum(TemperatureId:LongWord):LongWord;
Description: Get the Temperature Maximum Model from the Mailbox property tags channel
Note None documented


function RPiGPUMemoryAllocate(Length,Alignment,Flags:LongWord):THandle;
Description: Allocate GPU Memory from the Mailbox property tags channel
Note None documented


function RPiGPUMemoryRelease(Handle:THandle):LongWord;
Description: Release GPU Memory from the Mailbox property tags channel
Note None documented


function RPiGPUMemoryLock(Handle:THandle):LongWord;
Description: Lock GPU Memory from the Mailbox property tags channel
Note None documented


function RPiGPUMemoryUnlock(Handle:THandle):LongWord;
Description: Unlock GPU Memory from the Mailbox property tags channel
Note None documented


function RPiGPUExecuteCode(Address:Pointer; R0,R1,R2,R3,R4,R5:LongWord):LongWord;
Description: Execute GPU Code from the Mailbox property tags channel
Note None documented


function RPiDispmanxHandleGet(Resource:THandle):THandle;
Description: Get Dispmanx Memory Handle from the Mailbox property tags channel
Note None documented


function RPiEDIDBlockGet(Block:LongWord; Buffer:Pointer; Length:LongWord):LongWord;
Description: Get EDID Block from the Mailbox property tags channel
Note None documented


function RPiFramebufferAllocate(Alignment:LongWord; var Address,Length:LongWord):LongWord;
Description: Allocate Framebuffer from the Mailbox property tags channel
Note None documented


function RPiFramebufferRelease:LongWord;
Description: Release Framebuffer from the Mailbox property tags channel
Note None documented


function RPiFramebufferSetState(State:LongWord):LongWord;
Description: Set Framebuffer State (Blank Screen) from the Mailbox property tags channel
Note None documented


function RPiFramebufferGetDimensions(var Width,Height,Top,Bottom,Left,Right:LongWord):LongWord;
Description: Get Framebuffer Dimensions from the Mailbox property tags channel
Note None documented


function RPiFramebufferGetPhysical(var Width,Height:LongWord):LongWord;
Description: Get Framebuffer Physical size from the Mailbox property tags channel
Note None documented


function RPiFramebufferSetPhysical(var Width,Height:LongWord):LongWord;
Description: Set Framebuffer Physical size from the Mailbox property tags channel
Note None documented


function RPiFramebufferTestPhysical(var Width,Height:LongWord):LongWord;
Description: Test Framebuffer Physical size from the Mailbox property tags channel
Note None documented


function RPiFramebufferGetVirtual(var Width,Height:LongWord):LongWord;
Description: Get Framebuffer Virtual size from the Mailbox property tags channel
Note None documented


function RPiFramebufferSetVirtual(var Width,Height:LongWord):LongWord;
Description: Set Framebuffer Virtual size from the Mailbox property tags channel
Note None documented


function RPiFramebufferTestVirtual(var Width,Height:LongWord):LongWord;
Description: Test Framebuffer Virtual size from the Mailbox property tags channel
Note None documented


function RPiFramebufferGetDepth(var Depth:LongWord):LongWord;
Description: Get Framebuffer Depth (Bits per pixel) from the Mailbox property tags channel
Note None documented


function RPiFramebufferSetDepth(var Depth:LongWord):LongWord;
Description: Set Framebuffer Depth (Bits per pixel) from the Mailbox property tags channel
Note None documented


function RPiFramebufferTestDepth(var Depth:LongWord):LongWord;
Description: Test Framebuffer Depth (Bits per pixel) from the Mailbox property tags channel
Note None documented


function RPiFramebufferGetPixelOrder(var Order:LongWord):LongWord;
Description: Get Framebuffer Pixel Order (RGB) from the Mailbox property tags channel
Note None documented


function RPiFramebufferSetPixelOrder(var Order:LongWord):LongWord;
Description: Set Framebuffer Pixel Order (RGB) from the Mailbox property tags channel
Note None documented


function RPiFramebufferTestPixelOrder(var Order:LongWord):LongWord;
Description: Test Framebuffer Pixel Order (RGB) from the Mailbox property tags channel
Note None documented


function RPiFramebufferGetAlphaMode(var Mode:LongWord):LongWord;
Description: Get Framebuffer Alpha Mode from the Mailbox property tags channel
Note None documented


function RPiFramebufferSetAlphaMode(var Mode:LongWord):LongWord;
Description: Set Framebuffer Alpha Mode from the Mailbox property tags channel
Note None documented


function RPiFramebufferTestAlphaMode(var Mode:LongWord):LongWord;
Description: Test Framebuffer Alpha Mode from the Mailbox property tags channel
Note None documented


function RPiFramebufferGetPitch:LongWord;
Description: Get Framebuffer Pitch (Bytes per line) from the Mailbox property tags channel
Note None documented


function RPiFramebufferGetOffset(var X,Y:LongWord):LongWord;
Description: Get Framebuffer Virtual Offset from the Mailbox property tags channel
Note None documented


function RPiFramebufferSetOffset(var X,Y:LongWord):LongWord;
Description: Set Framebuffer Virtual Offset from the Mailbox property tags channel
Note None documented


function RPiFramebufferTestOffset(var X,Y:LongWord):LongWord;
Description: Test Framebuffer Virtual Offset from the Mailbox property tags channel
Note None documented


function RPiFramebufferGetOverscan(var Top,Bottom,Left,Right:LongWord):LongWord;
Description: Get Framebuffer Overscan from the Mailbox property tags channel
Note None documented


function RPiFramebufferSetOverscan(var Top,Bottom,Left,Right:LongWord):LongWord;
Description: Set Framebuffer Overscan from the Mailbox property tags channel
Note None documented


function RPiFramebufferTestOverscan(var Top,Bottom,Left,Right:LongWord):LongWord;
Description: Test Framebuffer Overscan from the Mailbox property tags channel
Note None documented


function RPiFramebufferGetPalette(Buffer:Pointer; Length:LongWord):LongWord;
Description: Get Framebuffer Palette from the Mailbox property tags channel
Note None documented


function RPiFramebufferSetPalette(Start,Count:LongWord; Buffer:Pointer; Length:LongWord):LongWord;
Description: Set Framebuffer Palette from the Mailbox property tags channel
Note None documented


function RPiFramebufferTestPalette(Start,Count:LongWord; Buffer:Pointer; Length:LongWord):LongWord;
Description: Test Framebuffer Palette from the Mailbox property tags channel
Note None documented


function RPiFramebufferSetBacklight(Brightness:LongWord):LongWord;
Description: Set Framebuffer Backlight Brightness from the Mailbox property tags channel
Note None documented


function RPiTouchGetBuffer(var Address:LongWord):LongWord;
Description: Get the Touchscreen buffer from the Mailbox property tags channel
Note None documented


function RPiCursorSetInfo(Width,Height,HotspotX,HotspotY:LongWord; Pixels:Pointer; Length:LongWord):LongWord;
Description: Set Curson Info (Pixels) from the Mailbox property tags channel
Note None documented


function RPiCursorSetState(Enabled:Boolean; X,Y:LongWord; Relative:Boolean):LongWord;
Description: Set Cursor State (Enable, X, Y) from the Mailbox property tags channel
Relative X, Y is relative to Display (Virtual) not Framebuffer (Physical)


function RPiDMAGetChannels:LongWord;
Description: Get the available DMA Channels from the Mailbox property tags channel
Note None documented


RPi tthread functions

procedure RPiSchedulerInit;
Description: To be documented
Note None documented


RPi IRQ functions

function RPiDispatchIRQ(CPUID:LongWord; Thread:TThreadHandle):TThreadHandle;
Description: Process any pending IRQ requests
Note Called by ARMv6IRQHandler in PlatformARMv6

A DataMemoryBarrier is executed before and after calling this function


function RPiHandleIRQ(Number,CPUID:LongWord; Thread:TThreadHandle):TThreadHandle;
Description: Call the handler function for an IRQ that was received, or halt if it doesn't exist
Note None documented


RPi FIQ functions

function RPiDispatchFIQ(CPUID:LongWord; Thread:TThreadHandle):TThreadHandle;
Description: Process any pending FIQ requests
Note Called by ARMv6FIQHandler in PlatformARMv6

A DataMemoryBarrier is executed before and after calling this function


function RPiHandleFIQ(Number,CPUID:LongWord; Thread:TThreadHandle):TThreadHandle;
Description: Call the handler function for an FIQ that was received, or halt if it doesn't exist
Note None documented


RPi SWI functions

function RPiDispatchSWI(CPUID:LongWord; Thread:TThreadHandle; Request:PSystemCallRequest):TThreadHandle;
Description: Process an SWI request
Note Called by ARMv6SoftwareInterruptHandler in PlatformARMv6

A DataMemoryBarrier is executed before and after calling this function


RPi clock functions

procedure RPiClockInterrupt(Parameter:Pointer);
Description: Interrupt handler function for the clock interrupt
Note This schedules another clock interrupt to occur CLOCK_CYCLES_PER_TICK in the future, then updates ClockTicks and ClockSeconds.


procedure RPiClockUpdate(Cycles:LongWord; var Last:LongWord);
Description: ?etup a clock interrupt to trigger after the specified number of clock cycles
Cycles Number of cycles after which the timer interrupt is to be triggered
Note This refers to native clock cycles as specified by CLOCK_FREQUENCY


RPi scheduler functions

function RPiSchedulerInterrupt(CPUID:LongWord; Thread:TThreadHandle; Parameter:Pointer):TThreadHandle;
Description: Interrupt handler function for the scheduler interrupt
Note This schedules another scheduler interrupt to occur SCHEDULER_CLOCKS_PER_INTERRUPT in the future, then checks for threads to wakeup and the next thread to schedule.


procedure RPiSchedulerUpdate(Cycles:LongWord; var Last:LongWord);
Description: ?etup a scheduler interrupt to trigger after the specified number of clock cycles
Cycles Number of cycles after which the scheduler interrupt is to be triggered
Note This refers to native clock cycles as specified by CLOCK_FREQUENCY


procedure RPiSchedulerSystemCall(Request:PSystemCallRequest);
Description: System Call handler for the scheduler
Note This is registered to receive requests for the SYSTEM_CALL_CONTEXT_SWITCH and will perform a context switch from within an SWI


RPi framebuffer functions

function RPiFramebufferDeviceAllocate(Framebuffer:PFramebufferDevice; Properties:PFramebufferProperties):LongWord;
Description: Allocate a framebuffer using the Mailbox Property Tags
Note None documented


function RPiFramebufferDeviceAllocateAlt(Framebuffer:PFramebufferDevice; Properties:PFramebufferProperties):LongWord;
Description: Allocate a framebuffer using a simple Mailbox Call
Note None documented


function RPiFramebufferDeviceRelease(Framebuffer:PFramebufferDevice):LongWord;
Description: To be documented
Note None documented


function RPiFramebufferDeviceBlank(Framebuffer:PFramebufferDevice; Blank:Boolean):LongWord;
Description: To be documented
Note None documented


function RPiFramebufferDeviceCommit(Framebuffer:PFramebufferDevice; Address,Size,Flags:LongWord):LongWord;
Description: To be documented
Note None documented


function RPiFramebufferDevice?etBacklight(Framebuffer:PFramebufferDevice; Brightness:LongWord):LongWord;
Description: To be documented
Note None documented


function RPiFramebufferDevice?etProperties(Framebuffer:PFramebufferDevice; Properties:PFramebufferProperties):LongWord;
Description: To be documented
Note None documented


RPi helper functions

procedure RPiWait; assembler; nostackframe;
Description: To be documented
Note None documented


procedure RPiLongWait; assembler; nostackframe;
Description: To be documented
Note None documented


procedure RPiShortWait; assembler; nostackframe;
Description: To be documented
Note None documented


procedure RPiSlowBlink; assembler; nostackframe;
Description: To be documented
Note None documented


procedure RPiFastBlink; assembler; nostackframe;
Description: To be documented
Note None documented


procedure RPiBootBlink; assembler; nostackframe;
Description: Blink the Activity LED without dependency on any other RTL ?etup
Note This currently only works for RPiA+/B+


function RPiConvertPowerIdRequest(PowerId:LongWord):LongWord;
Description: Convert Ultibo Power Id to BCM2835 Power Id
Note None documented


function RPiConvertPowerStateRequest(PowerState:LongWord):LongWord;
Description: Convert Ultibo Power State to BCM2835 Power State
Note None documented


function RPiConvertPowerStateResponse(PowerState:LongWord):LongWord;
Description: Convert BCM2835 Power State to Ultibo Power State
Note None documented


Return to Unit Reference