Unit DeviceTree

From Ultibo.org
Jump to: navigation, search

Return to Unit Reference


Description


Ultibo Flattened Device Tree (DTB) interface unit

Using Device Tree Blob (DTB) files for passing configuration information to the Linux kernel is now widely accepted as the standard method of providing platform specific information without it needing to be hard coded into the kernel at build time.

With this adoption of device tree by Linux it is becoming increasingly common for the only source of information about the runtime configuration of specific hardware to be found in the blob loaded and configured during startup by the firmware and passed to the kernel at the beginning of the boot process.

While Ultibo targets a much smaller range of devices than Linux and does not need the generic kernel model it still requires detailed configuration information in order to be able to interface with the full range of available devices.

It can also benefit from the ability to adapt to the runtime environment by checking for known device tree parameters while registering and initializing hardware and devices. Use of device tree is considered optional and Ultibo will operate correctly with or without the information provided, however some devices may be forced to operate in a fall back or default mode without the complete configuration.

Constants



[Expand]
DTB signature DTB_*


[Expand]
DTB version DTB_VERSION_*


[Expand]
DTB token DTB_*_NODE


[Expand]
DTB offset DTB_*_OFFSET


[Expand]
DTB alignment DTB_*_ALIGNMENT


[Expand]
DTB node DTB_NODE_*


[Expand]
DTB path DTB_PATH_*


[Expand]
DTB type DTB_TYPE_*


[Expand]
DTB properties DTB_PROPERTY_*


[Expand]
DTB property type DTB_*_PROPERTY_TYPE*


Type definitions



DTB header

[Expand]

PDTBHeader = ^TDTBHeader;

TDTBHeader = packed record

DTB reservation

[Expand]

PDTBReservation = ^TDTBReservation;

TDTBReservation = packed record

DTB node

[Expand]

PDTBNode = ^TDTBNode;

TDTBNode = packed record

DTB property

[Expand]

PDTBProperty = ^TDTBProperty;

TDTBProperty = packed record

DTB property char

[Expand]

PDTBPropertyChar = ^TDTBPropertyChar;

TDTBPropertyChar = packed record

DTB property longWord

[Expand]

PDTBPropertyLongWord = ^TDTBPropertyLongWord;

TDTBPropertyLongWord = packed record

DTB property quadWord

[Expand]

PDTBPropertyQuadWord = ^TDTBPropertyQuadWord;

TDTBPropertyQuadWord = packed record

DTB property type

[Expand]

TDTBPropertyType = record

DTB logoutput

TDTBLogOutput = procedure(const AText:String; Data:Pointer);

DTB code value

TDTBDecodeValue = function(Node,Handle:THandle; Value:Pointer; Size:LongWord; Data:Pointer):String;


Public variables


None defined

Function declarations



Initialization functions

[Expand]
procedure DeviceTreeInit;
Description: Initialize the Device Tree unit


Device tree functions

[Expand]
function DeviceTreeValidate(Address:PtrUInt; var Size:LongWord):Boolean;
Description: Check the data at the supplied address to determine if it is a valid Device Tree Blob


[Expand]
function DeviceTreeNextNode(Parent,Previous:THandle):THandle;
Description: Find the next DTB node within the Device Tree


[Expand]
function DeviceTreeNextProperty(Node,Previous:THandle):THandle;
Description: Find the next DTB property within the specified node of the Device Tree


[Expand]
function DeviceTreeGetNode(const Path:String; Parent:THandle):THandle;
Description: Get the handle of the node matching the specified path, optionally within a specified parent


[Expand]
function DeviceTreeGetProperty(Node:THandle; const Name:String):THandle;
Description: Get the handle of the property matching the specified name


[Expand]
function DeviceTreeGetNodeName(Handle:THandle):String;
Description: Get the name of the specified node


[Expand]
procedure DeviceTreeSplitNodeName(Handle:THandle; var NodeName,UnitAddress:String);
Description: Split the name of a node into node name and unit address


[Expand]
function DeviceTreeGetNodeParent(Handle:THandle):THandle;
Description: Get the parent node of the specified node


[Expand]
function DeviceTreeGetNodeRegCells(Handle:THandle; var Address,Size:LongWord):Boolean;
Description: Get the #address-cells and #size-cells values that apply to reg properties of the specified node


[Expand]
function DeviceTreeGetNodeRangeCells(Handle:THandle; var ParentAddress,NodeAddress,NodeSize:LongWord):Boolean;
Description: Get the #address-cells and #size-cells values that apply to range properties of the specified node


[Expand]
function DeviceTreeGetPropertyName(Handle:THandle):String;
Description: Get the name of the specified property


[Expand]
procedure DeviceTreeSplitPropertyName(Handle:THandle; var UniquePrefix,PropertyName:String);
Description: Split the name of a property into property name and unique prefix


[Expand]
function DeviceTreeGetPropertyValue(Handle:THandle):Pointer;
Description: Get a pointer to the raw value of the specified property


[Expand]
function DeviceTreeGetPropertyLength(Handle:THandle):LongWord;
Description: Get the length of the raw value of the specified property


[Expand]
function DeviceTreeGetPropertyString(Handle:THandle):String;
Description: Get the value of the specified property as a string


[Expand]
function DeviceTreeGetPropertyLongWord(Handle:THandle):LongWord;
Description: Get the value of the specified property as a longword


[Expand]
function DeviceTreeGetPropertyQuadWord(Handle:THandle):UInt64;
Description: Get the value of the specified property as a quadword


RTL Device tree functions

[Expand]
function SysDeviceTreeRead(const Path,Name:String; Buffer:Pointer; var Size:LongWord):LongWord;
Description: Implementation of DeviceTreeRead API


[Expand]
function SysDeviceTreeRead32(const Path,Name:String; var Value:LongWord):LongWord;
Description: Implementation of DeviceTreeRead32 API


[Expand]
function SysDeviceTreeRead64(const Path,Name:String; var Value:UInt64):LongWord;
Description: Implementation of DeviceTreeRead64 API


[Expand]
function SysDeviceTreeReadString(const Path,Name:String; var Value:String):LongWord;
Description: Implementation of DeviceTreeReadString API


Device tree helper functions

[Expand]
function DeviceTreeGetBootArgs:PChar;
Description: Return a character pointer to the location of the command line in the device tree blob


[Expand]
function DeviceTreeGetRamdisk(var Address:PtrUInt; var Size:UInt64):Boolean;
Description: Return the address and size of the initial ram disk specified in the device tree blob


[Expand]
function DeviceTreeGetMemory(Index:LongWord; var Range:LongWord; var Address:PtrUInt; var Size:UInt64):Boolean;
Description: Return the address and size of a memory block specified in the device tree blob


[Expand]
function DeviceTreeGetReservation(Index:LongWord; var Address:PtrUInt; var Size:UInt64):Boolean;
Description: Return the address and size of a memory reservation specified in the device tree blob


[Expand]
function DeviceTreeLogTree:LongWord;
Description: Print information about all nodes and properties in the device tree


[Expand]
function DeviceTreeLogTreeEx(Node:THandle; Output:TDTBLogOutput; Decode:TDTBDecodeValue; Data:Pointer):LongWord;
Description: Print information about one or all nodes and properties in the device tree with custom value decode callback


Return to Unit Reference