diff options
Diffstat (limited to '')
-rw-r--r-- | cpukit/include/rtems/rtems-fdt.h | 127 |
1 files changed, 115 insertions, 12 deletions
diff --git a/cpukit/include/rtems/rtems-fdt.h b/cpukit/include/rtems/rtems-fdt.h index 62db32e912..e3ebfe3ba4 100644 --- a/cpukit/include/rtems/rtems-fdt.h +++ b/cpukit/include/rtems/rtems-fdt.h @@ -64,6 +64,21 @@ typedef struct rtems_fdt_blob* blob; /**< The blob the handle references. */ } rtems_fdt_handle; +/** + * FDT Address property. It is an address an optionally a size. + * + * Only 32bit addresses and sizes on 32bit machine. Ignore the upper + * 32bits. + */ +typedef struct +{ + int node; + uint64_t address; + uint64_t size; + int address_cells; + int size_cells; +} rtems_fdt_address_map; + /* * The following are mappings to the standard FDT calls. */ @@ -165,9 +180,13 @@ typedef struct * The blob cannot be unloaded as it is referenced. */ #define RTEMS_FDT_ERR_REFERENCED 104 +/** + * The property length is invalid + */ +#define RTEMS_FDT_ERR_BADLENGTH 105 #define RTEMS_FDT_ERR_RTEMS_MIN 100 -#define RTEMS_FDT_ERR_MAX 104 +#define RTEMS_FDT_ERR_MAX 105 /** * Initialise a handle to a default state. @@ -237,7 +256,7 @@ int rtems_fdt_register (const void* blob, rtems_fdt_handle* handle); /** * Unload a device tree blob or DTB file and release any memory allocated when - * loading. The blob is removed from the list of registered. + * loading. The blob is removed from the list if registered. * * @param blob_desc A valid blob descriptor. * @return int If less than 0 it is an error code else 0 is return on success. @@ -277,7 +296,7 @@ int rtems_fdt_get_mem_rsv (rtems_fdt_handle* handle, * larger string, such as a full path. * * @param blob_desc A valid blob descriptor. - * @param arentoffset Structure block offset of a node + * @param parentoffset Structure block offset of a node * @param name Name of the subnode to locate. * @param namelen Number of characters of name to consider. * @return int If less than 0 it is an error code else the node offset is @@ -326,7 +345,9 @@ int rtems_fdt_path_offset (rtems_fdt_handle* handle, const char* path); * * @param handle The FDT handle to the current blob. * @param nodeoffset Structure block offset of the starting node. - * @param length Pointer to an integer variable (will be overwritten) or NULL. + * @param length Pointer to an integer variable or NULL. If non-NULL, this will + * be overwritten with either the length in bytes or the error + * code. * @return const char* The node's name on success or NULL on error. The length * if non-NULL will hold the error code. */ @@ -335,6 +356,41 @@ const char* rtems_fdt_get_name (rtems_fdt_handle* handle, int* length); /** + * Retrieve the offset for the first property for a node. + * + * @param handle The FDT handle to the current blob. + * @param nodeoffset Structure block offset of the starting node. + * @return int The offset of a node's first property. + */ +int rtems_fdt_first_prop_offset(rtems_fdt_handle* handle, int nodeoffset); + +/** + * Retrieve the next property of a node relative to the property + * + * @param handle The FDT handle to the current blob. + * @param propoffset Property offset to search from + * @return int Property offset or end if less than 0. + */ +int rtems_fdt_next_prop_offset(rtems_fdt_handle* handle, int propoffset); + +/** + * Retrieve the property value, name and length of name given a + * property offset. + * + * @param handle The FDT handle to the current blob. + * @param propoffset Property offset + * @param name If not NULL set the pointer to the name string. + * @param length Pointer to an integer variable or NULL. If non-NULL, this will + * be overwritten with either the length in bytes or the error + * code. + * @return const void* The node's value data. + */ +const void* rtems_fdt_getprop_by_offset(rtems_fdt_handle* handle, + int propoffset, + const char** name, + int* length); + +/** * Get property value based on substring. Identical to rtems_fdt_getprop(), but * only examine the first namelen characters of name for matching the property * name. @@ -343,8 +399,9 @@ const char* rtems_fdt_get_name (rtems_fdt_handle* handle, * @param nodeoffset Offset of the node whose property to find * @param name The name of the property to find * @param namelen The number of characters of name to consider - * @param length A pointer to an integer variable (will be overwritten) or - * NULL. + * @param length Pointer to an integer variable or NULL. If non-NULL, this will + * be overwritten with either the length in bytes or the error + * code. * @return const void* The node's property on success or NULL on error. The * length if non-NULL will hold the error code. */ @@ -364,8 +421,9 @@ const void *rtems_fdt_getprop_namelen (rtems_fdt_handle* handle, * @param handle The FDT handle to the current blob. * @param nodeoffset The offset of the node whose property to find. * @param name The name of the property to find. - * @param length A pointer to an integer variable (will be overwritten) or - * NULL. + * @param length Pointer to an integer variable or NULL. If non-NULL, this will + * be overwritten with either the length in bytes or the error + * code. * @return const void* The node's property on success or NULL on error. The * length if non-NULL will hold the error code. */ @@ -375,7 +433,7 @@ const void *rtems_fdt_getprop (rtems_fdt_handle* handle, int* length); /** - * Retrieve the phandle of a given of the device tree node at structure block + * Retrieve the phandle of the device tree node at structure block * offset nodeoffset. * * @param handle The FDT handle to the current blob. @@ -586,6 +644,14 @@ int rtems_fdt_next_node (rtems_fdt_handle* handle, int offset, int* depth); const char* rtems_fdt_strerror (int errval); /** + * Return a parent property given a node offset. Travel up until found + * or the root node is reached + */ +bool rtems_fdt_get_parent_prop_value(rtems_fdt_handle* handle, + int nodeoffset, + const char* name, + uint32_t* value); +/** * Return a property given a path. */ int rtems_fdt_prop_value(const char* const path, @@ -600,7 +666,7 @@ int rtems_fdt_prop_value(const char* const path, int rtems_fdt_prop_map (const char* const path, const char* const propname, const char* const names[], - uint32_t* values, + uintptr_t* values, size_t count); /* @@ -609,7 +675,7 @@ int rtems_fdt_prop_map (const char* const path, int rtems_fdt_get_value (const char* const path, const char* const property, size_t size, - uint32_t* value); + uintptr_t* value); /** * Get the number of entries in an FDT handle. @@ -629,9 +695,46 @@ const char *rtems_fdt_entry_name(rtems_fdt_handle* handle, int id); int rtems_fdt_entry_offset(rtems_fdt_handle* handle, int id); /* + * Helper function to convert the void* property result of unknown + * length to an unsigned int pointer value. + */ +uintptr_t rtems_fdt_get_offset_len_uintptr(const void* prop, int offset, int len); + +/* * Helper function to convert the void* property result to a 32bit unsigned int. */ -uint32_t rtems_fdt_get_uint32 (const void* prop); +uint32_t rtems_fdt_get_uint32(const void* prop); +uint32_t rtems_fdt_get_offset_uint32(const void* prop, int offset); + +/* + * Helper function to convert the void* property result to a 64bit unsigned int. + */ +uint64_t rtems_fdt_get_uint64(const void* prop); +uint64_t rtems_fdt_get_offset_uint64(const void* prop, int offset); + +/* + * Helper function to convert the void* property result to a uintptr_t + */ +uintptr_t rtems_fdt_get_uintptr(const void* prop); +uintptr_t rtems_fdt_get_offset_uintptr(const void* prop, int offset); + +/* + * Find the address cells property in parent nodes. + */ +int rtems_fdt_getprop_address_cells(rtems_fdt_handle* handle, int nodeoffset); + +/* + * Find the size cells property in parent nodes. + */ +int rtems_fdt_getprop_size_cells(rtems_fdt_handle* handle, int nodeoffset); + +/* + * Get an address space property. + */ +int rtems_fdt_getprop_address_map(rtems_fdt_handle* handle, + const char* path, + const char* name, + rtems_fdt_address_map* addr_map); #ifdef __cplusplus } |