device/device.h header reference
[Devices support library module]

The source code of this header can be browsed online.

Description  

Device structures and device tree

Members  

Types  

Functions  

Constant  

Macros  

Members detail  

#define DEVICE_NODE_FOREACH(root_, rvar_, ... /* loop body */)  

This macro is declared in device/device.h source file, line 348.

This macro iterates over child nodes of a device tree node.

Alternate declarations with same identifier: [1], [2].

Preprocessor condition: defined( CONFIG_DEVICE_TREE )

See also Device tree.

#define DEVICE_NODE_FOREACH(root_, rvar_, ... /* loop body */)  

This macro is declared in device/device.h source file, line 355.

This macro iterates over statically defined devices.

Alternate declarations with same identifier: [1], [2].

Preprocessor condition: not defined( CONFIG_DEVICE_TREE )

#define DEVICE_TREE_WALKER(x)  

This macro is declared in device/device.h source file, line 524.

See also device_tree_walker_t.

#define DEV_DECLARE_STATIC(declname_, name_, flags_, driver_, resources_...)  

This macro is declared in device/device.h source file, line 291.

This macro statically declares and intializes a global struct device_s object. The device object is initialized as if the device_init, device_set_name and device_bind_driver functions were called.

When CONFIG_DEVICE_TREE is defined, statically declared devices are attached to the device tree on startup, unless the DEVICE_FLAG_IGNORE flag is used.

When CONFIG_DEVICE_TREE is not defined, statically declared devices are part of the static device table. Devices in this table are initialized on startup and can be searched using device_get_by_path and related functions, unless the DEVICE_FLAG_IGNORE flag is set.

Alternate declarations with same identifier: [1], [2].

Preprocessor condition: defined( CONFIG_DEVICE_TREE )

See also Device instance and enum dev_resource_type_e.

#define DEV_DECLARE_STATIC(declname_, name_, flags_, driver_, resources_...)  

This macro is declared in device/device.h source file, line 312.

Documentation from alternate declaration:

This macro statically declares and intializes a global struct device_s object. The device object is initialized as if the device_init, device_set_name and device_bind_driver functions were called.

When CONFIG_DEVICE_TREE is defined, statically declared devices are attached to the device tree on startup, unless the DEVICE_FLAG_IGNORE flag is used.

When CONFIG_DEVICE_TREE is not defined, statically declared devices are part of the static device table. Devices in this table are initialized on startup and can be searched using device_get_by_path and related functions, unless the DEVICE_FLAG_IGNORE flag is set.

Alternate declarations with same identifier: [1], [2].

Preprocessor condition: not defined( CONFIG_DEVICE_TREE )

See also Device instance and enum dev_resource_type_e.

#define GCT_CONTAINER_ALGO_device_list  

This macro is declared in device/device.h source file, line 143.

#define GCT_CONTAINER_ALGO_device_sleep  

This macro is declared in device/device.h source file, line 145.

#define GCT_CONTAINER_LOCK_device_sleep  

This macro is declared in device/device.h source file, line 146.

#define GCT_CONTAINER_ORPHAN_device_sleep  

This macro is declared in device/device.h source file, line 147.

#define __DEVICE_H__  

This macro is declared in device/device.h source file, line 29.

typedef uint8_t address_space_id_t  

This typedef is declared in device/device.h source file, line 45.

enum device_access_type_e  

This enum is declared in device/device.h source file, line 542.

This enum specifies type of access on address space of a device.

IdentifierDescription
DEVICE_ACCESS_READ
DEVICE_ACCESS_WRITE

void device_alias_remove(struct device_alias_s *alias)  

This is available when CONFIG_DEVICE_TREE is defined.

See also Device tree.

struct device_alias_s  

This struct is declared in device/device.h source file, line 337.

device alias node structure

Preprocessor condition: defined( CONFIG_DEVICE_TREE )

See also Device tree.

FieldDescription
struct device_node_s node;
const char * path;alias path in device tree

struct device_s * device_alloc(size_t resources)  

This function dynamically allocates and initializes a device object. The specified number of resource slots are pre-allocated.

See also device_cleanup, device_shrink and Device instance.

void device_attach(struct device_s *dev, struct device_s *parent, const struct driver_s *drv)  

This function attaches a device to a parent enumerator device. If the parent device pointer is NULL, the device is attached on root enumerator.

This is available when CONFIG_DEVICE_TREE is defined.

See also Device tree.

void device_cleanup(struct device_s *dev)  

This function release memory used by a device. This includes device object allocated by the device_alloc function along with resources entries. The device must not be attached or have attached children and its reference count must be zero when this function is called.

This is available when CONFIG_DEVICE_CLEANUP is defined.

See also Device instance.

error_t device_detach(struct device_s *dev)  

This function detaches a device from its parent enumerator device

This is available when CONFIG_DEVICE_TREE is defined.

See also Device tree.

typedef uint16_t device_enum_rev_t  

This typedef is declared in device/device.h source file, line 46.

enum device_flags_e  

This enum is declared in device/device.h source file, line 118.

This enum specifies struct device_node_s type and flags

IdentifierDescription
DEVICE_FLAG_ALLOCATED The device object has been dynamically allocated and must be freed on cleanup.
DEVICE_FLAG_NAME_ALLOCATED The node name has been dynamically allocated and must be freed on cleanup.
DEVICE_FLAG_CPUThis device is a processor. Operations on this device may only be executed on the corresponding processor.
DEVICE_FLAG_DEVICE The tree node is a device node
DEVICE_FLAG_ALIAS The tree node is an alias node
DEVICE_FLAG_NO_AUTOBINDAutomatic binding of a driver to the device will not be performed, the device_bind_driver function must be called explicitly.
DEVICE_FLAG_NO_AUTOINITAutomatic initialization of the device will not be performed, the device_init_driver function must be called explicitly.
DEVICE_FLAG_NO_STARTUP_WAITDo not wait for initialization of this device before starting execution of the INIT_DEVREADY_INIT group during startup.

error_t device_get_address_route(struct device_s *dev, struct device_s *target, enum device_access_type_e ops, uint_fast8_t *id)  

This function finds the master interface number (id) of the device dev suitable to perform a memory access of types ops on the device target.

This is available when CONFIG_DEVICE_ADDRESS_SPACES is defined.

error_t device_get_by_path(struct device_s **dev, uint_fast8_t *number, struct device_node_s *root, const char *path, device_filter_t *filter)  

This function returns child device by path. The node parameter must provide an initialized device pointer which will be updated is a matching device is found. The initial value is the search root node and may be NULL to lookup from the device tree root. Multiple paths separated by spaces can be specified, the first match is retained.

Paths with a leading / are searched from the device tree root regardless of the root parameter. The special name .. and . can be used to write relative paths. The ? character can be used as a single character wildcard and the * character can be used to match any node name suffix.

The filter can be used to provide an additional filter function. It may be NULL.

See also Device tree.

uint_fast8_t device_get_cpu_count(void )  

This function returns the number of processor devices present in the devices tree with a properly initialized driver attached.

error_t device_get_path(struct device_node_s *root, char *buf, size_t buflen, struct device_node_s *dev, uint_fast8_t number)  

This function writes a null terminated device tree path in buffer. If the number parameter is not 0, the value is appended at the end within a pair of square brackets.

The return value is size of string excluding null byte or a negative error code.

This is available when CONFIG_DEVICE_TREE is defined.

See also Device tree.

void device_init(struct device_s *dev, const struct dev_resource_table_s *tbl)  

This function initializes a statically allocated device object. Devices declared using the DEV_DECLARE_STATIC macro do not require use of this function.

See also Device instance.

typedef void * device_list_entry_t  

This typedef is declared in device/device.h source file, line 170.

Preprocessor condition: defined( CONFIG_DEVICE_TREE )

typedef struct device_node_s * device_list_item_t  

This typedef is declared in device/device.h source file, line 185.

Preprocessor condition: defined( CONFIG_DEVICE_TREE )

typedef void * device_list_root_t  

This typedef is declared in device/device.h source file, line 170.

Preprocessor condition: defined( CONFIG_DEVICE_TREE )

struct device_alias_s * device_new_alias_to_node(struct device_node_s *parent, const char *name, struct device_node_s *node)  

This function creates an alias in the device tree. The target string is obtained using the device_get_path function. The parent parameter may be NULL to attach the alias on the tree root.

This is available when CONFIG_DEVICE_TREE is defined.

See also device_new_alias_to_path and Device tree.

struct device_alias_s * device_new_alias_to_path(struct device_node_s *parent, const char *name, const char *path)  

This function creates an alias in the device tree. The parent parameter may be NULL to attach the alias on the tree root.

This is available when CONFIG_DEVICE_TREE is defined.

See also device_new_alias_to_node and Device tree.

struct device_s  

This struct is declared in device/device.h source file, line 195.

device node structure

See also Device instance.

FieldDescription
struct device_node_s node;
enum device_status_e status:4;Device/driver initialization status
See also Device status.
uint8_t init_mask:8; When the status is DEVICE_INIT_ONGOING or DEVICE_INIT_PARTIAL, this is a mask of initialized classes in driver API order. Extra bits can be used by the driver in order to flag internal initialization states.
See also device_init_enable_apies.
uint16_t ref_count:CONFIG_DEVICE_USE_BITS;device uses counter,
See also device_get_accessor.
uint16_t start_count:CONFIG_DEVICE_USE_BITS+CONFIG_DEVICE_START_LOG2INC;device start counter,
See also device_start.
uint_fast8_t sleep_order;
enum device_sleep_policy_e sleep_policy;
lock_t lock;general purpose device lock
const struct driver_s * drv;pointer to device driver if any
void * drv_pv;pointer to device driver private data
device_enum_rev_t enum_rev;enumerator list revision
void * enum_pv;pointer to device enumerator private data if any
struct dev_resource_table_s * res_tbl;device resources table

See also device_sleep_item_t.

error_t device_set_name(struct device_s *dev, const char *name)  

This function sets the name of the device. The device name can only be changed if the device has not been attached to a parent node.

The name string will be duplicated and later freed on cleanup only if the DEVICE_FLAG_NAME_ALLOCATED flag of the device node is set.

See also Device instance.

void device_shrink(struct device_s *dev)  

This function reduces resource slots count to number of used slots count. The device node is reallocated to save memory.

This is available when CONFIG_DEVICE_RESOURCE_ALLOC is defined.

See also Device instance and Device resources.

typedef void * device_sleep_entry_t  

This typedef is declared in device/device.h source file, line 247.

Preprocessor condition: defined( CONFIG_DEVICE_SLEEP )

typedef struct device_s * device_sleep_item_t  

This typedef is declared in device/device.h source file, line 247.

Preprocessor condition: defined( CONFIG_DEVICE_SLEEP )

enum device_sleep_policy_e  

This enum is declared in device/device.h source file, line 59.

Preprocessor condition: defined( CONFIG_DEVICE_SLEEP )

See also device_sleep_schedule.

IdentifierDescription
DEVICE_SLEEP_CPUIDLEWhen this policy is in use, the DEV_USE_SLEEP driver operation is delayed until all processors in the platform become idle.

typedef void * device_sleep_root_t  

This typedef is declared in device/device.h source file, line 247.

Preprocessor condition: defined( CONFIG_DEVICE_SLEEP )

void device_sleep_schedule(struct device_s *dev)  

This function schedules a call to the dev_use_t function of the device driver so that the device power consumption can be reduced.

This function should be called when the driver notice that the device is not in active use anymore and is candidate for being put in low power mode.

When the dev_use_t function is called, the driver then have to take the required actions to reduce device power usage. See DEV_USE_SLEEP for details. This call is delayed depending on the current device sleep policy.

This function must be called with the device lock held. It is harmless to call this function multiple times.

This is available when CONFIG_DEVICE_SLEEP is defined.

See also enum device_sleep_policy_e and CONFIG_DEVICE_SLEEP.

const char device_status_e[]  

This variable is declared in ENUM_DESCRIPTOR function like macro expansion, line 1 in device/device.h source file, line 67.

Alternate declarations with same identifier: [1], [2].

enum device_status_e  

This enum is declared in device/device.h source file, line 72.

This enum specifies the initialization status of a struct device_s

Alternate declarations with same identifier: [1], [2].

See also Device status.

IdentifierDescription
DEVICE_INIT_ENUM_ERRDevice enumeration incomplete, some resource entries may be wrong or missing.
DEVICE_INIT_ENUM_DRVNo driver is currently attached to the device but the driver registry will be searched for an appropriate driver.
DEVICE_INIT_NODRVNo driver is currently attached to the device.
DEVICE_INIT_PENDINGA driver has been attached to the device but initialization has not been performed yet. Initialization will start as soon as all dependencies are satisfied. It is not possible to get a device accessor at this point.
DEVICE_INIT_ONGOINGThe driver initialization is ongoing. Some classes of the driver may already be usable. This can only result from the dev_init_t function returning -EAGAIN. It is possible to get a device accessor for the initialized classes at this point if the driver supports partial initialization.
DEVICE_INIT_PARTIALSome classes of the driver have not been properly initialized but other classes are usable. This occurs when the device_init_enable_api function is called during an initialization which eventually terminate with an error.
DEVICE_INIT_DONEThe device is fully initialized and functional. This results from the dev_init_t function returning 0 or by invoking the device_async_init_done function.
DEVICE_INIT_DECLINEThe driver cleanup is ongoing. This can only result from the dev_cleanup_t function returning -EAGAIN. It is not possible to get a device accessor anymore.
DEVICE_INIT_FAILEDA driver is attached to the device but the initialization has failed or a dependency is not available. It is not possible to get a device accessor but the device initialization may be retried.
DEVICE_INIT_RELEASEDThe device was previously initialized but has been explicitely released. This is similar to DEVICE_INIT_PENDING but the initialization will not be performed automatically.

struct device_node_s * device_tree_root(void )  

This function returns the device tree root node.

This is available when CONFIG_DEVICE_TREE is defined.

See also Device tree.

bool_t device_tree_walk(struct device_node_s *root, device_tree_walker_t *walker, void *priv)  

This function traverse device tree calling device_tree_walker_t function type foreach each node. Traversal stops if the provided function returns non-zero.

See also Device tree.

typedef bool_t (device_tree_walker_t)(struct device_s *dev, void *priv)   

This typedef is declared in device/device.h source file, line 528.

This declaration involves expansion of the DEVICE_TREE_WALKER macro.

See also device_tree_walk.

#define DEVICE_FILTER(n)  

This macro is declared in device/device.h source file, line 424.

device lookup filter prototype

This macro is for internal use only.

See also device_filter_t.

struct device_alias_s * device_alias_from_node(struct device_node_s *node)  

This function is declared in device/device.h source file, line 477.

This is available when CONFIG_DEVICE_TREE is defined.

This function is for internal use only.

typedef bool_t (device_filter_t)(struct device_node_s *)   

This typedef is declared in device/device.h source file, line 428.

device lookup filter function type

This typedef is for internal use only.

This declaration involves expansion of the DEVICE_FILTER macro.

struct device_s * device_from_node(struct device_node_s *node)  

This function is declared in device/device.h source file, line 470.

This function is for internal use only.

struct device_node_s * device_node_from_alias(struct device_alias_s *alias)  

This function is declared in device/device.h source file, line 494.

This is available when CONFIG_DEVICE_TREE is defined.

This function is for internal use only.

error_t device_node_from_path(struct device_node_s **node, const char *path, uint_fast8_t depth, const char **brackets, device_filter_t *filter)  

This function lookup a node in the device tree.

This function is for internal use only.

struct device_node_s  

This struct is declared in device/device.h source file, line 174.

Device tree base node structure

This struct is for internal use only.

Preprocessor condition: defined( CONFIG_DEVICE_TREE )

See also Device tree.

FieldDescription
const char * name;device name, freed on device object destruction if not NULL and allocated is set.
struct device_node_s * parent;
device_list_root_t children;
enum device_flags_e flags:8;

See also device_list_item_t.

error_t device_resolve_alias(struct device_node_s **node, uint_fast8_t depth, const char **brackets)  

This function is for internal use only.

struct device_node_s * device_to_node(struct device_s *dev)  

This function is declared in device/device.h source file, line 487.

This function is for internal use only.

Valid XHTML 1.0 StrictGenerated by diaxen on Wed Oct 17 21:18:38 2018 using MkDoc