fdt/reader.h header reference
[Flattened device tree IO module]
The source code of this header can be browsed online.
Description [link]
Read-only access to FDT blobs
Members [link]
Types [link]
- typedef void (fdt_on_mem_reserve_func_t)(void *priv, uint64_t addr, uint64_t size)
- typedef bool_t (fdt_on_node_entry_func_t)(void *priv, struct fdt_walker_state_s *state, const char *path)
- typedef void (fdt_on_node_leave_func_t)(void *priv)
- typedef void (fdt_on_node_prop_func_t)(void *priv, struct fdt_walker_state_s *state, const char *name, const void *data, size_t datalen)
- struct fdt_walker_s
Functions [link]
- error_t fdt_get_prop_at(const void *blob, uint32_t offset, const char *propname, const void **data, size_t *datasize)
- void fdt_get_rsvmap(const void *blob, uint32_t resno, uint64_t *addr, uint64_t *size)
- size_t fdt_get_size(void *blob)
- void * fdt_parse_cell(const void *data, uint8_t cells, uintptr_t *retval)
- bool_t fdt_reader_get_prop_int(const struct fdt_walker_state_s *state, const char *propname, uintptr_t *rval)
- uint32_t fdt_reader_get_struct_offset(struct fdt_walker_state_s *state)
- bool_t fdt_reader_has_prop(const struct fdt_walker_state_s *state, const char *propname, const void **propval, size_t *propsize)
- error_t fdt_walk_blob(const void *blob, struct fdt_walker_s *walker)
- error_t fdt_walk_blob_from(const void *blob, struct fdt_walker_s *walker, uint32_t offset)
Macros [link]
Members detail [link]
#define FDT_ON_MEM_RESERVE_FUNC(x) [link]
This macro is declared in fdt/reader.h source file, line 46.
on_mem_reserve prototype macro
See also fdt_on_mem_reserve_func_t.
#define FDT_ON_NODE_ENTRY_FUNC(x) [link]
This macro is declared in fdt/reader.h source file, line 20.
on_node_entry prototype macro
See also fdt_on_node_entry_func_t.
#define FDT_ON_NODE_LEAVE_FUNC(x) [link]
This macro is declared in fdt/reader.h source file, line 29.
on_node_leave prototype macro
See also fdt_on_node_leave_func_t.
#define FDT_ON_NODE_PROP_FUNC(x) [link]
This macro is declared in fdt/reader.h source file, line 35.
on_node_prop prototype macro
See also fdt_on_node_prop_func_t.
#define FDT_READ_H_ [link]
This macro is declared in fdt/reader.h source file, line 1.
error_t fdt_get_prop_at(const void *blob, uint32_t offset, const char *propname, const void **data, size_t *datasize) [link]
This function is declared in fdt/reader.h source file, line 253.
This function is declared in fdt/reader.h source file, line 192.
this function retrieves a particular memory reservation entry from the table. This function does not check for bounds. User can tell it reached the last entry when *addr and *size are 0.
Parameter list:
- blob: Pointer to the FDT blob header
- resno: Index of the memory reservation in the map, 0-indexed
- addr: Pointer this function must fill with the address of the reservation
- size: Pointer this function must fill with the size of the reservation
size_t fdt_get_size(void *blob) [link]
This function is declared in fdt/reader.h source file, line 160.
this function gets the complete size of a blob as told in its header.
Parameter list:
- blob: a pointer to the start of a device tree blob
The return value is the total size of the blob, 0 if the blob is invalid
This typedef is declared in fdt/reader.h source file, line 102.
Type definition for function called on a memory reservation node. Note values are always 64 bits for this type of nodes.
There is no endian adaptation to perform on the parameters.
Parameter list:
- priv: private data provided in the struct fdt_walker_s
- addr: base address of reservation
- size: size of reservation
This declaration involves expansion of the FDT_ON_MEM_RESERVE_FUNC macro.
typedef bool_t (fdt_on_node_entry_func_t)(void *priv, struct fdt_walker_state_s *state, const char *path) [link]
This typedef is declared in fdt/reader.h source file, line 64.
Type definition for entry in a new node. As nodes may be nested, this function may be called many times in a row.
Parameter list:
- priv: private data provided in the struct fdt_walker_s
- offset: node offset from the beginning of the structure, this can be used to resolve references
- path: full path of the node
The return value is whether user is interested in this node, its properties and its subnodes.
This declaration involves expansion of the FDT_ON_NODE_ENTRY_FUNC macro.
See also FDT_ON_NODE_ENTRY_FUNC.
typedef void (fdt_on_node_leave_func_t)(void *priv) [link]
This typedef is declared in fdt/reader.h source file, line 73.
Type definition for end of a node. As nodes may be nested, this function may be called many times in a row.
Parameter list:
- priv: private data provided in the struct fdt_walker_s
This declaration involves expansion of the FDT_ON_NODE_LEAVE_FUNC macro.
typedef void (fdt_on_node_prop_func_t)(void *priv, struct fdt_walker_state_s *state, const char *name, const void *data, size_t datalen) [link]
This typedef is declared in fdt/reader.h source file, line 89.
Type definition for function called on a node property. As properties are inside nodes, on_node_entry has already be called once when calling this function.
Parameter list:
- priv: private data provided in the struct fdt_walker_s
- offset: offset of the parameter in the structure
- name: name of the parameter
- data: pointer to raw data. User must take care of the meaning by itself. If data contains numeric values, they are stored bigendian.
- datalen: length of the data, in bytes
This declaration involves expansion of the FDT_ON_NODE_PROP_FUNC macro.
This function is declared in fdt/reader.h source file, line 206.
this function parses an integer value from the blob. It abides #*-cell for the input data, and a size of output data.
Parameter list:
- cells: Number of cells for one integer starting at data
- data: Pointer to a data cell
- retval_size: User-provided sizeof(*retval)
- retval: Pointer to a data value to fill
The return value is the memory following the parsed data cell
bool_t fdt_reader_get_prop_int(const struct fdt_walker_state_s *state, const char *propname, uintptr_t *rval) [link]
This function is declared in fdt/reader.h source file, line 240.
this function retrieves an integer value from the current node. This is a shortcut for fdt_reader_has_prop followed by fdt_parse_sized.
Parameter list:
- state: Walker state
- propname: Property name to lookup
- rval: Pointer to an integer to fill
- rsize: Size of the data pointed by rval, in bytes
The return value is whether a value has been found
This function is declared in fdt/reader.h source file, line 137.
this function retrieves the structure offset for the current state.
This is not valid when walking through memory reservation.
Parameter list:
- state: Internal state of the parser
The return value is the current token offset
bool_t fdt_reader_has_prop(const struct fdt_walker_state_s *state, const char *propname, const void **propval, size_t *propsize) [link]
This function is declared in fdt/reader.h source file, line 152.
this function retrieves the value of a property inside a node, if it exists. Calling this function is only valid when inside a on_node_entry.
Parameter list:
- state: Internal state of the parser
- prop: Property name to look for
- propval: return pointer to the property value, if found
- propsize: return size of property value, if found
The return value is 1 if the property has been found, 0 otherwise
error_t fdt_walk_blob(const void *blob, struct fdt_walker_s *walker) [link]
This function is declared in fdt/reader.h source file, line 127.
this function processes a whole blob calling the provided functions when needed. The blob contains its size in its own header.
Parameter list:
- blob: Pointer to the FDT blob header
- walker: User-provided functions
The return value is whether the parsing went well, to the end
error_t fdt_walk_blob_from(const void *blob, struct fdt_walker_s *walker, uint32_t offset) [link]
This function is declared in fdt/reader.h source file, line 177.
this function processes a blob calling the provided functions when needed, only from the given offset in the blob. The offset must be a value previously returned by fdt_reader_get_struct_offset, and has no meaningful value outside this context. This function will never walk the memory reservation nodes. The corresponding pointer in walker may be NULL.
Parameter list:
- blob: Pointer to the FDT blob header
- walker: User-provided functions
- offset: The subnode offset to walk
The return value is whether the parsing went well, to the end
struct fdt_walker_s [link]
This struct is declared in fdt/reader.h source file, line 111.
Structure containing pointers to user-provided functions and private data. When using fdt_walk_blob with this structure, all function pointers must be provided. Leaving a NULL pointer to function will lead to unpredictable results.
Field | Description |
---|---|
void * priv; | User-owned pointer, ignored by walker |
fdt_on_node_entry_func_t * on_node_entry; | Function to call entering a node |
fdt_on_node_leave_func_t * on_node_leave; | Function to call leaving a node |
fdt_on_node_prop_func_t * on_node_prop; | Function to call for each property |
fdt_on_mem_reserve_func_t * on_mem_reserve; | Function to call for each memory reservation map |