26#ifndef _ULTIBO_DEVICETREE_H
27#define _ULTIBO_DEVICETREE_H
39#define DTB_MAGIC 0xD00DFEED
42#define DTB_VERSION_17 17
43#define DTB_VERSION_16 16
45#define DTB_VERSION_CURRENT DTB_VERSION_17
46#define DTB_VERSION_COMPATIBLE DTB_VERSION_16
49#define DTB_BEGIN_NODE 0x00000001
50#define DTB_END_NODE 0x00000002
51#define DTB_PROP 0x00000003
52#define DTB_NOP 0x00000004
53#define DTB_END 0x00000009
56#define DTB_NODE_OFFSET 4
57#define DTB_PROPERTY_OFFSET 12
60#define DTB_STRUCTURE_ALIGNMENT 4
61#define DTB_RESERVATION_ALIGNMENT 8
65#define DTB_NODE_ROOT "/"
66#define DTB_NODE_CPUS "cpus"
67#define DTB_NODE_MEMORY "memory"
68#define DTB_NODE_CHOSEN "chosen"
69#define DTB_NODE_ALIASES "aliases"
71#define DTB_NODE_SYMBOLS "__symbols__"
72#define DTB_NODE_OVERRIDES "__overrides__"
75#define DTB_PATH_SEPARATOR "/"
78#define DTB_TYPE_UNKNOWN 0
79#define DTB_TYPE_EMPTY 1
82#define DTB_TYPE_STRING 4
83#define DTB_TYPE_ENCODED_ARRAY 5
84#define DTB_TYPE_PHANDLE 6
85#define DTB_TYPE_STRINGLIST 7
89#define DTB_PROPERTY_COMPATIBLE "compatible"
90#define DTB_PROPERTY_MODEL "model"
91#define DTB_PROPERTY_PHANDLE "phandle"
92#define DTB_PROPERTY_STATUS "status"
93#define DTB_PROPERTY_ADDRESS_CELLS "#address-cells"
94#define DTB_PROPERTY_SIZE_CELLS "#size-cells"
95#define DTB_PROPERTY_REG "reg"
96#define DTB_PROPERTY_VIRTUAL_REG "virtual-reg"
97#define DTB_PROPERTY_RANGES "ranges"
98#define DTB_PROPERTY_DMA_RANGES "dma-ranges"
99#define DTB_PROPERTY_NAME "name"
100#define DTB_PROPERTY_DEVICE_TYPE "device_type"
103#define DTB_PROPERTY_INTERRUPTS "interrupts"
104#define DTB_PROPERTY_INTERRUPT_PARENT "interrupt-parent"
105#define DTB_PROPERTY_INTERRUPTS_EXTENDED "interrupts-extended"
108#define DTB_PROPERTY_INTERRUPT_CELLS "#interrupt-cells"
109#define DTB_PROPERTY_INTERRUPT_CONTROLLER "interrupt-controller"
112#define DTB_PROPERTY_INTERRUPT_MAP "interrupt-map"
113#define DTB_PROPERTY_INTERRUPT_MAP_MASK "interrupt-map-mask"
116#define DTB_PROPERTY_INITIAL_MAPPED_AREA "initial-mapped-area"
119#define DTB_PROPERTY_BOOTARGS "bootargs"
120#define DTB_PROPERTY_STDOUT_PATH "stdout-path"
121#define DTB_PROPERTY_STDIN_PATH "stdin-path"
122#define DTB_PROPERTY_INITRD_START "initrd-start"
123#define DTB_PROPERTY_INITRD_END "initrd-end"
126#define DTB_PROPERTY_CLOCK_FREQUENCY "clock-frequency"
127#define DTB_PROPERTY_TIMEBASE_FREQUENCY "timebase-frequency"
128#define DTB_PROPERTY_ENABLE_METHOD "enable-method"
129#define DTB_PROPERTY_CPU_RELEASE_ADDR "cpu-release-addr"
131#define DTB_PROPERTY_POWER_ISA_VERSION "power-isa-version"
132#define DTB_PROPERTY_CACHE_OP_BLOCK_SIZE "cache-op-block-size"
133#define DTB_PROPERTY_RESERVATION_GRANULE_SIZE "reservation-granule-size"
134#define DTB_PROPERTY_MMU_TYPE "mmu-type"
136#define DTB_PROPERTY_TLB_SPLIT "tlb-split"
137#define DTB_PROPERTY_TLB_SIZE "tlb-size"
138#define DTB_PROPERTY_TLB_SETS "tlb-sets"
139#define DTB_PROPERTY_D_TLB_SIZE "d-tlb-size"
140#define DTB_PROPERTY_D_TLB_SETS "d-tlb-sets"
141#define DTB_PROPERTY_I_TLB_SIZE "i-tlb-size"
142#define DTB_PROPERTY_I_TLB_SETS "i-tlb-sets"
144#define DTB_PROPERTY_CACHE_UNIFIED "cache-unified"
145#define DTB_PROPERTY_CACHE_SIZE "cache-size"
146#define DTB_PROPERTY_CACHE_SETS "cache-sets"
147#define DTB_PROPERTY_CACHE_BLOCK_SIZE "cache-block-size"
148#define DTB_PROPERTY_CACHE_LINE_SIZE "cache-line-size"
149#define DTB_PROPERTY_I_CACHE_SIZE "i-cache-size"
150#define DTB_PROPERTY_I_CACHE_SETS "i-cache-sets"
151#define DTB_PROPERTY_I_CACHE_BLOCK_SIZE "i-cache-block-size"
152#define DTB_PROPERTY_I_CACHE_LINE_SIZE "i-cache-line-size"
153#define DTB_PROPERTY_D_CACHE_SIZE "d-cache-size"
154#define DTB_PROPERTY_D_CACHE_SETS "d-cache-sets"
155#define DTB_PROPERTY_D_CACHE_BLOCK_SIZE "d-cache-block-size"
156#define DTB_PROPERTY_D_CACHE_LINE_SIZE "d-cache-line-size"
157#define DTB_PROPERTY_NEXT_LEVEL_CACHE "next-level-cache"
159#define DTB_PROPERTY_CACHE_LEVEL "cache-level"
162#define DTB_PROPERTY_SERIAL_NUMBER "serial-number"
163#define DTB_PROPERTY_ALLOC_RANGES "alloc-ranges"
164#define DTB_PROPERTY_RESETS "resets"
165#define DTB_PROPERTY_CLOCK_CELLS "#clock-cells"
166#define DTB_PROPERTY_LINUX_INITRD_START "linux,initrd-start"
167#define DTB_PROPERTY_LINUX_INITRD_END "linux,initrd-end"
170#define DTB_MAX_PROPERTY_TYPE 60
424#if defined (__i386__) || defined (__arm__)
uint32_t STDCALL device_tree_get_property_name(HANDLE handle, char *name, uint32_t len)
Get the name of the specified property.
struct _DTB_PROPERTY_LONGWORD DTB_PROPERTY_LONGWORD
Definition devicetree.h:228
uint32_t STDCALL device_tree_log_tree(void)
Print information about all nodes and properties in the device tree.
uint32_t STDCALL device_tree_get_property_length(HANDLE handle)
Get the length of the raw value of the specified property.
BOOL STDCALL device_tree_get_memory(uint32_t index, size_t *address, uint64_t *size)
Return the address and size of a memory block specified in the device tree blob.
uint32_t STDCALL device_tree_get_property_longword(HANDLE handle)
Get the value of the specified property as a longword.
uint32_t STDCALL device_tree_get_property_string(HANDLE handle, char *string, uint32_t len)
Get the value of the specified property as a string.
HANDLE STDCALL device_tree_next_node(HANDLE parent, HANDLE previous)
Find the next DTB node within the Device Tree.
void *STDCALL device_tree_get_property_value(HANDLE handle)
Get a pointer to the raw value of the specified property.
BOOL STDCALL device_tree_get_ramdisk(size_t *address, uint64_t *size)
Return the address and size of the initial ram disk specified in the device tree blob.
BOOL STDCALL device_tree_get_node_range_cells(HANDLE handle, uint32_t *parentaddress, uint32_t *nodeaddress, uint32_t *nodesize)
Get the address-cells and size-cells values that apply to range properties of the specified node.
HANDLE STDCALL device_tree_get_property(HANDLE node, const char *name)
Get the handle of the property matching the specified name.
HANDLE STDCALL device_tree_get_node(const char *path, HANDLE parent)
Get the handle of the node matching the specified path, optionally within a specified parent.
HANDLE STDCALL device_tree_next_property(HANDLE node, HANDLE previous)
Find the next DTB property within the specified node of the Device Tree.
uint32_t STDCALL device_tree_split_node_name(HANDLE handle, char *nodename, uint32_t namelen, char *unitaddress, uint32_t addresslen)
Split the name of a node into node name and unit address.
struct _DTB_NODE DTB_NODE
Definition devicetree.h:198
struct _DTB_PROPERTY DTB_PROPERTY
Definition devicetree.h:206
HANDLE STDCALL device_tree_get_node_parent(HANDLE handle)
Get the parent node of the specified node.
char *STDCALL(* dtb_decode_value_cb)(HANDLE node, HANDLE handle, void *value, uint32_t size, void *data)
Definition devicetree.h:250
struct _DTB_PROPERTY_CHAR DTB_PROPERTY_CHAR
Definition devicetree.h:217
void STDCALL(* dtb_log_output_cb)(const char *text, void *data)
Definition devicetree.h:249
BOOL STDCALL device_tree_get_node_reg_cells(HANDLE handle, uint32_t *address, uint32_t *size)
Get the address-cells and size-cells values that apply to reg properties of the specified node.
struct _DTB_PROPERTY_QUADWORD DTB_PROPERTY_QUADWORD
Definition devicetree.h:239
struct _DTB_RESERVATION DTB_RESERVATION
Definition devicetree.h:190
struct _DTB_HEADER DTB_HEADER
Definition devicetree.h:174
uint32_t STDCALL device_tree_split_property_name(HANDLE handle, char *uniqueprefix, uint32_t prefixlen, char *propertyname, uint32_t namelen)
Split the name of a property into property name and unique prefix.
uint32_t STDCALL device_tree_get_node_name(HANDLE handle, char *name, uint32_t len)
Get the name of the specified node.
BOOL STDCALL device_tree_get_reservation(uint32_t index, size_t *address, uint64_t *size)
Return the address and size of a memory reservation specified in the device tree blob.
BOOL STDCALL device_tree_validate(size_t address, uint32_t *size)
Check the data at the supplied address to determine if it is a valid Device Tree Blob.
char *STDCALL device_tree_get_boot_args(void)
Return a character pointer to the location of the command line in the device tree blob.
uint32_t STDCALL device_tree_log_tree_ex(HANDLE node, dtb_log_output_cb output, dtb_decode_value_cb decode, void *data)
Print information about one or all nodes and properties in the device tree with custom value decode c...
uint64_t STDCALL device_tree_get_property_quadword(HANDLE handle)
Get the value of the specified property as a quadword.
size_t HANDLE
Definition globaltypes.h:51
#define STDCALL
Definition globaltypes.h:45
#define PACKED
Definition globaltypes.h:48
_Bool BOOL
Built in Boolean type (1 byte) (Redeclared here for flexibility).
Definition globaltypes.h:55
Definition devicetree.h:200
char name[1]
The name stored as a null-terminated string, shall include the unit address if any.
Definition devicetree.h:202
uint32_t token
Token (big-endian).
Definition devicetree.h:201
Definition devicetree.h:219
uint32_t nameoffset
The offset into the strings block of the property name stored as a null-terminated string.
Definition devicetree.h:222
uint32_t valuelength
The length of the property value in bytes.
Definition devicetree.h:221
char value[1]
The property value as a string of value length.
Definition devicetree.h:223
uint32_t token
Token (big-endian).
Definition devicetree.h:220
Definition devicetree.h:230
uint32_t nameoffset
The offset into the strings block of the property name stored as a null-terminated string.
Definition devicetree.h:233
uint32_t valuelength
The length of the property value in bytes.
Definition devicetree.h:232
uint32_t value[1]
The property value as an array of longwords of value length (big-endian).
Definition devicetree.h:234
uint32_t token
Token (big-endian).
Definition devicetree.h:231
Definition devicetree.h:241
uint64_t value[1]
The property value as an array of quadwords of value length (big-endian).
Definition devicetree.h:245
uint32_t nameoffset
The offset into the strings block of the property name stored as a null-terminated string.
Definition devicetree.h:244
uint32_t valuelength
The length of the property value in bytes.
Definition devicetree.h:243
uint32_t token
Token (big-endian).
Definition devicetree.h:242
Definition devicetree.h:208
uint8_t value[1]
The property value as an array of bytes of value length.
Definition devicetree.h:212
uint32_t nameoffset
The offset into the strings block of the property name stored as a null-terminated string.
Definition devicetree.h:211
uint32_t valuelength
The length of the property value in bytes.
Definition devicetree.h:210
uint32_t token
Token (big-endian).
Definition devicetree.h:209
Definition devicetree.h:192
uint64_t address
Physical address of a reserved memory region.
Definition devicetree.h:193
uint64_t size
Size in bytes of a reserved memory region.
Definition devicetree.h:194