RTEMS 6.1-rc1
|
#include <bsp/fdt.h>
#include <sys/param.h>
#include <ofw/ofw.h>
#include <libfdt.h>
#include <assert.h>
#include <rtems/sysinit.h>
#include <ofw/ofw_test.h>
Functions | |
void | rtems_ofw_init (void) |
Initialize the OFW API with the device tree blob. This function should only be invoked for testing purposes. | |
RTEMS_SYSINIT_ITEM (rtems_ofw_init, RTEMS_SYSINIT_BSP_PRE_DRIVERS, RTEMS_SYSINIT_ORDER_FIRST) | |
phandle_t | rtems_ofw_peer (phandle_t node) |
Gets the node that is next to node. More... | |
phandle_t | rtems_ofw_child (phandle_t node) |
Gets the node that is the child of node. More... | |
phandle_t | rtems_ofw_parent (phandle_t node) |
Gets the node that is the parent of node. More... | |
ssize_t | rtems_ofw_get_prop_len (phandle_t node, const char *propname) |
Gets the length of the property mentioned in propname. More... | |
ssize_t | rtems_ofw_get_prop (phandle_t node, const char *propname, void *buf, size_t bufsize) |
Gets the value of property mentioned in propname. More... | |
ssize_t | rtems_ofw_get_enc_prop (phandle_t node, const char *prop, pcell_t *buf, size_t len) |
Gets the value of property mentioned in prop. More... | |
int | rtems_ofw_has_prop (phandle_t node, const char *propname) |
Checks if the property propname is present in node. More... | |
ssize_t | rtems_ofw_search_prop (phandle_t node, const char *propname, void *buf, size_t len) |
Searches for property propname in node. More... | |
ssize_t | rtems_ofw_search_enc_prop (phandle_t node, const char *propname, pcell_t *buf, size_t len) |
Searches for property propname in node. More... | |
ssize_t | rtems_ofw_get_prop_alloc (phandle_t node, const char *propname, void **buf) |
Gets the value of property mentioned in propname. More... | |
ssize_t | rtems_ofw_get_prop_alloc_multi (phandle_t node, const char *propname, int elsz, void **buf) |
Gets multiple values of the property propname. More... | |
ssize_t | rtems_ofw_get_enc_prop_alloc (phandle_t node, const char *propname, void **buf) |
Gets the value of property mentioned in propname. More... | |
ssize_t | rtems_ofw_get_enc_prop_alloc_multi (phandle_t node, const char *propname, int elsz, void **buf) |
Gets multiple values of the property propname. More... | |
void | rtems_ofw_free (void *buf) |
Free's the buffers allocated by the rtems_ofw_*_alloc functions. More... | |
int | rtems_ofw_next_prop (phandle_t node, const char *previous, char *buf, size_t len) |
Finds the next property of node. More... | |
int | rtems_ofw_set_prop (phandle_t node, const char *name, const void *buf, size_t len) |
phandle_t | rtems_ofw_find_device (const char *path) |
Finds the node at the given path. More... | |
phandle_t | rtems_ofw_node_from_xref (phandle_t xref) |
This routine converts effective phandle xref to node offset. More... | |
phandle_t | rtems_ofw_xref_from_node (phandle_t node) |
This routine converts node offset to effective phandle of node. More... | |
phandle_t | rtems_ofw_instance_to_package (ihandle_t instance) |
Converts instance handle to phandle. More... | |
ssize_t | rtems_ofw_package_to_path (phandle_t node, char *buf, size_t len) |
Find the node's path from phandle. More... | |
ssize_t | rtems_ofw_instance_to_path (ihandle_t instance, char *buf, size_t len) |
Find the node's path from ihandle. More... | |
int | rtems_ofw_get_reg (phandle_t node, rtems_ofw_memory_area *buf, size_t size) |
Queries the node's reg value. More... | |
int | rtems_ofw_get_interrupts (phandle_t node, rtems_vector_number *buf, size_t size) |
Queries the node's interrupt value. More... | |
bool | rtems_ofw_node_status (phandle_t node) |
Queries the node's status. More... | |
phandle_t | rtems_ofw_find_device_by_compat (const char *compat) |
Gets node phandle from compatible property. More... | |
bool | rtems_ofw_is_node_compatible (phandle_t node, const char *compat) |
check a nodes compatible property. More... | |
Gets the node that is the child of node.
[in] | node | Node offset |
child | node offset Successful operation. |
0 | No child node or invalid node handle |
phandle_t rtems_ofw_find_device | ( | const char * | path | ) |
Finds the node at the given path.
[in] | path | to the node from root |
-1 | node does not exist |
node | handle on success |
phandle_t rtems_ofw_find_device_by_compat | ( | const char * | compat | ) |
Gets node phandle from compatible property.
This routine is local to RTEMS OFW and does not have an corresponding FreeBSD OFW pair.
[in] | compat | Compatible string |
0 | Node with compat as compatible string not found |
Node | phandle on success. |
void rtems_ofw_free | ( | void * | buf | ) |
Free's the buffers allocated by the rtems_ofw_*_alloc functions.
[in] | buf | Buffer to be freed |
Gets the value of property mentioned in prop.
Gets the value of property of node and converts the value into the host's endianness.
[in] | node | Node offset |
[in] | prop | Property name |
[out] | buf | The property value gets stored in this buffer(Pre-allocated) after converted to the host's endianness |
[in] | len | Length of the buffer |
-1 | Invalid node or property |
Length | of property on successful operation |
ssize_t rtems_ofw_get_enc_prop_alloc | ( | phandle_t | node, |
const char * | propname, | ||
void ** | buf | ||
) |
Gets the value of property mentioned in propname.
Same as rtems_ofw_getprop_alloc but the value stored in the buffer is converted into the host's endianness.
[in] | node | Node offset |
[in] | propname | Property name |
[out] | buf | The buffer is allocated in this routine and user is responsible for freeing. |
-1 | Property is not found. |
Length | of the property if property is found. |
ssize_t rtems_ofw_get_enc_prop_alloc_multi | ( | phandle_t | node, |
const char * | propname, | ||
int | elsz, | ||
void ** | buf | ||
) |
Gets multiple values of the property propname.
Same as rtems_ofw_getprop_alloc_multi but the values stored in the buffer are converted to the host's endianness.
[in] | node | Node offset |
[in] | propname | Property name |
[in] | elsz | Size of the single value |
[out] | buf | The buffer is allocated in this routine and user is responsible for freeing. |
-1 | Property is not found. |
Number | of values read. |
int rtems_ofw_get_interrupts | ( | phandle_t | node, |
rtems_vector_number * | buf, | ||
size_t | size | ||
) |
Queries the node's interrupt value.
This routine fills the buffer buf with the interrupt number. In case of multiple numbers it fills the buffer to its full extent. This routine is local to RTEMS OFW and does not have an corresponding FreeBSD OFW pair.
[in] | node | Node offset |
[out] | buf | Interrupt values are stored in this buffer(Pre-allocated). |
[in] | size | Length of the buffer. |
-1 | If interrupts property is missing. |
The | number of interrupt numbers read. |
ssize_t rtems_ofw_get_prop | ( | phandle_t | node, |
const char * | propname, | ||
void * | buf, | ||
size_t | len | ||
) |
Gets the value of property mentioned in propname.
[in] | node | Node offset |
[in] | prop | Property name |
[out] | buf | The property value gets stored in this buffer (Pre-allocated) |
[in] | len | Length of the buffer |
-1 | Invalid node or property |
Length | of property on successful operation |
ssize_t rtems_ofw_get_prop_alloc | ( | phandle_t | node, |
const char * | propname, | ||
void ** | buf | ||
) |
Gets the value of property mentioned in propname.
Same as rtems_ofw_getprop, but the buf is allocated in this routine and the user is responsible for freeing it.
[in] | node | Node offset |
[in] | propname | Property name |
[out] | buf | The buffer is allocated in this routine and user is responsible for freeing. |
-1 | Property is not found. |
Length | of the property if property is found. |
ssize_t rtems_ofw_get_prop_alloc_multi | ( | phandle_t | node, |
const char * | propname, | ||
int | elsz, | ||
void ** | buf | ||
) |
Gets multiple values of the property propname.
Same as rtems_ofw_getprop_alloc but it can read properties with multiple values. For eg: reg = <0x1000 0x10 0x2000 0x20>
[in] | node | Node offset |
[in] | propname | Property name |
[in] | elsz | Size of the single value |
[out] | buf | The buffer is allocated in this routine and user is responsible for freeing. |
-1 | Property is not found. |
Number | of values read. |
ssize_t rtems_ofw_get_prop_len | ( | phandle_t | node, |
const char * | propname | ||
) |
Gets the length of the property mentioned in propname.
[in] | node | Node offset |
[in] | prop | Property name |
-1 | Invalid node or property |
Length | of property on successful operation |
int rtems_ofw_get_reg | ( | phandle_t | node, |
rtems_ofw_memory_area * | buf, | ||
size_t | size | ||
) |
Queries the node's reg value.
This routine fills the buffer buf with the values in reg property of node node. It reads all the values of the property and fills the buffer to max size. This routine is local to RTEMS OFW and does not have an corresponding FreeBSD OFW pair.
[in] | node | Node offset |
[out] | buf | Register values are stored in this buffer(Pre-allocated). |
[in] | size | Length of the buffer. |
-1 | If reg property is missing. |
Length | of the reg property in bytes. |
(buf + size - (sizeof(buf[0]) - 1) is the last valid address for buf[i]. If buf[i] points to any address larger than this, it will be an out of bound access
int rtems_ofw_has_prop | ( | phandle_t | node, |
const char * | propname | ||
) |
Checks if the property propname is present in node.
[in] | node | Node offset |
[in] | propname | Property name |
0 | Property not present. |
1 | Property is present. |
Converts instance handle to phandle.
instance are same as node offsets in FDT.
[in] | instance | Node offset |
phandle | of node on success. |
instance | of node on failure. |
ssize_t rtems_ofw_instance_to_path | ( | ihandle_t | instance, |
char * | buf, | ||
size_t | len | ||
) |
Find the node's path from ihandle.
[in] | instance | Node offset |
[out] | buf | Path is filled into this buffer(Pre-allocated). |
[in] | len | Length of the buffer. |
-1 | always. Unimplemented. |
bool rtems_ofw_is_node_compatible | ( | phandle_t | node, |
const char * | compat | ||
) |
check a nodes compatible property.
This routine is local to RTEMS OFW and does not have an corresponding FreeBSD OFW pair.
Return true if compat equals node compatible property
[in] | node | phandle of node |
[in] | compat | Compatible string |
1 | If node contains the compat as a element in compatible property. |
0 | Otherwise. |
int rtems_ofw_next_prop | ( | phandle_t | node, |
const char * | previous, | ||
char * | buf, | ||
size_t | len | ||
) |
Finds the next property of node.
Finds the next property of the node and when propname is NULL it returns the value in the first property.
[in] | node | Node offset |
[in] | previous | Previous property name |
[out] | buf | The value of the next property gets stored in this buffer (Pre-allocated) |
[in] | len | Length of the buffer |
-1 | node or previous property does not exist |
0 | no more properties |
1 | success |
This routine converts effective phandle xref to node offset.
[in] | xref | Node phandle |
Node | offset on success |
Node | phandle on failure |
bool rtems_ofw_node_status | ( | phandle_t | node | ) |
Queries the node's status.
This routine is local to RTEMS OFW and does not have an corresponding FreeBSD OFW pair.
[in] | node | Node offset |
true | Status is OK or empty. |
false | Status is not OK or missing. |
ssize_t rtems_ofw_package_to_path | ( | phandle_t | node, |
char * | buf, | ||
size_t | len | ||
) |
Find the node's path from phandle.
[in] | node | Node offset |
[out] | buf | Path is filled into this buffer(Pre-allocated). |
[in] | len | Length of the buffer. |
-1 | always. Unimplemented. |
Gets the node that is the parent of node.
[in] | node | Node offset |
child | node offset Successful operation. |
0 | No child node or invalid node handle |
Gets the node that is next to node.
[in] | node | Node offset |
Peer | node offset Successful operation. |
0 | No peer node or invalid node handle |
ssize_t rtems_ofw_search_enc_prop | ( | phandle_t | node, |
const char * | propname, | ||
pcell_t * | buf, | ||
size_t | len | ||
) |
Searches for property propname in node.
Searches the node and its parent recursively for the property and fills the buffer with the first value found after converting it to the endianness of the host.
[in] | node | Node offset |
[in] | propname | Property name |
[out] | buf | The property value gets stored in this buffer(Pre-allocated) after converted to the host's endianness |
[in] | len | Length of the buffer |
Length | of the property if property is found. |
-1 | Property is not found. |
ssize_t rtems_ofw_search_prop | ( | phandle_t | node, |
const char * | propname, | ||
void * | buf, | ||
size_t | len | ||
) |
Searches for property propname in node.
Searches the node and its parent recursively for the property and fills the buffer with the first found value.
[in] | node | Node offset |
[in] | propname | Property name |
[out] | buf | The property value gets stored in this buffer (Pre-allocated) |
[in] | len | Length of the buffer |
Length | of the property if property is found. |
-1 | Property is not found. |