# DriverUtils ## **Overview** Defines common macros and interfaces of the driver module. This module provides interfaces such as log printing, doubly linked list operations, and work queues. **Since:** 1.0 **Version:** 1.0 ## **Summary** ## Files
Describes a work item and a delayed work item. This structure defines the work and delayed work items, and then calls the initialization function HdfWorkInit or HdfDelayedWorkInit to perform initialization. The HdfAddWork() function is to add a work item to a work queue immediately, and the HdfAddDelayedWork() function is to add a work item to a work queue after the configured delayed time. |
|
Indicates that the function keeps waiting to obtain a semaphore or mutex. |
|
Defines a time conversion unit, for example, the unit for converting from second to millisecond. |
|
CONTAINER_OF(ptr, type, member) (type *)((char *)(ptr) - (char *)&((type *)0)->member) |
Obtains the address of a structure variable from its member address. |
DLIST_FIRST_ENTRY(ptr, type, member) CONTAINER_OF((ptr)->next, type, member) |
|
DLIST_LAST_ENTRY(ptr, type, member) CONTAINER_OF((ptr)->prev, type, member) |
|
DLIST_FOR_EACH_ENTRY(pos, head, type, member) |
|
DLIST_FOR_EACH_ENTRY_SAFE(pos, tmp, head, type, member) |
Traverses all nodes in a doubly linked list. This function is used to delete the nodes pointed to by pos during traversal. |
LOG_TAG_MARK_EXTEND(HDF_TAG) #HDF_TAG |
|
HDF_LOGV(fmt, arg...) printf("[HDF:V/" LOG_TAG "]" fmt "\r\n", ##arg) |
|
HDF_LOGD(fmt, arg...) printf("[HDF:D/" LOG_TAG "]" fmt "\r\n", ##arg) |
|
HDF_LOGI(fmt, arg...) printf("[HDF:I/" LOG_TAG "]" fmt "\r\n", ##arg) |
|
HDF_LOGW(fmt, arg...) printf("[HDF:W/" LOG_TAG "]" fmt "\r\n", ##arg) |
|
HDF_LOGE(fmt, arg...) printf("[HDF:E/" LOG_TAG "]" fmt "\r\n", ##arg) |
HdfWorkFunc) (void *) |
HDF_STATUS { HDF_SUCCESS = 0, HDF_FAILURE = -1, HDF_ERR_NOT_SUPPORT = -2, HDF_ERR_INVALID_PARAM = -3, HDF_ERR_INVALID_OBJECT = -4, HDF_ERR_MALLOC_FAIL = -6, HDF_ERR_TIMEOUT = -7, HDF_ERR_THREAD_CREATE_FAIL = -10, HDF_ERR_QUEUE_FULL = -15, HDF_ERR_DEVICE_BUSY = -16, HDF_ERR_IO = -17, HDF_ERR_BAD_FD = -18, HDF_BSP_ERR_OP = HDF_BSP_ERR_NUM(-1), HDF_ERR_BSP_PLT_API_ERR = HDF_BSP_ERR_NUM(-2), HDF_PAL_ERR_DEV_CREATE = HDF_BSP_ERR_NUM(-3), HDF_PAL_ERR_INNER = HDF_BSP_ERR_NUM(-4), HDF_DEV_ERR_NO_MEMORY = HDF_DEV_ERR_NUM(-1), HDF_DEV_ERR_NO_DEVICE = HDF_DEV_ERR_NUM(-2), HDF_DEV_ERR_NO_DEVICE_SERVICE = HDF_DEV_ERR_NUM(-3), HDF_DEV_ERR_DEV_INIT_FAIL = HDF_DEV_ERR_NUM(-4), HDF_DEV_ERR_PUBLISH_FAIL = HDF_DEV_ERR_NUM(-5), HDF_DEV_ERR_ATTACHDEV_FAIL = HDF_DEV_ERR_NUM(-6), HDF_DEV_ERR_NODATA = HDF_DEV_ERR_NUM(-7), HDF_DEV_ERR_NORANGE = HDF_DEV_ERR_NUM(-8), HDF_DEV_ERR_OP = HDF_DEV_ERR_NUM(-10) } |
|
{ HDF_WORK_BUSY_PENDING = 1 << 0, HDF_WORK_BUSY_RUNNING = 1 << 1 } |
DListHeadInit (struct DListHead *head) |
|
DListIsEmpty (const struct DListHead *head) |
|
DListRemove (struct DListHead *entry) |
|
DListInsertHead (struct DListHead *entry, struct DListHead *head) |
|
DListInsertTail (struct DListHead *entry, struct DListHead *head) |
|
DListMerge (struct DListHead *list, struct DListHead *head) |
Merges two linked lists by adding the list specified by list to the head of the list specified by head and initializes the merged list. |
HdfWorkQueueInit (HdfWorkQueue *queue, char *name) |
|
HdfWorkInit (HdfWork *work, HdfWorkFunc func, void *arg) |
|
HdfDelayedWorkInit (HdfWork *work, HdfWorkFunc func, void *arg) |
|
HdfWorkDestroy (HdfWork *work) |
|
HdfWorkQueueDestroy (HdfWorkQueue *queue) |
|
HdfDelayedWorkDestroy (HdfWork *work) |
|
HdfAddWork (HdfWorkQueue *queue, HdfWork *work) |
|
HdfAddDelayedWork (HdfWorkQueue *queue, HdfWork *work, unsigned long ms) |
|
HdfWorkBusy (HdfWork *work) |
|
HdfCancelWorkSync (HdfWork *work) |
Cancels a work item. This function waits until the work item is complete. |
HdfCancelDelayedWorkSync (HdfWork *work) |
| ptr | Indicates the structure member address. |
| type | Indicates the structure type. |
| member | Indicates the structure member. |
| ptr | Indicates the structure member address. |
| type | Indicates the structure type. |
| member | Indicates the structure member. |
| pos | Indicates the pointer to the structure variable. |
| head | Indicates the pointer to the linked list head. |
| type | Indicates the structure type. |
| member | Indicates the member type of the structure. |
| ptr | Indicates the structure member address. |
| type | Indicates the structure type. |
| member | Indicates the structure member. |
| HDF_WORK_BUSY_PENDING | |
| HDF_WORK_BUSY_RUNNING |
| head | Indicates the pointer to the linked list DListHead. The parameter cannot be empty. |
| entry | Indicates the pointer to the node to insert. For details, see DListHead. The parameter cannot be empty. |
| head | Indicates the pointer to the linked list DListHead. The parameter cannot be empty. |
| entry | Indicates the pointer to the node to insert. For details, see DListHead. The parameter cannot be empty. |
| head | Indicates the pointer to the linked list DListHead. The parameter cannot be empty. |
| head | Indicates the pointer to the linked list DListHead. The parameter cannot be empty. |
| list | Indicates the pointer to the linked list DListHead. The parameter cannot be empty. |
| head | Indicates the pointer to the linked list DListHead. The parameter cannot be empty. |
| entry | Indicates the pointer to the node to remove. For details, see DListHead. The parameter cannot be empty. |
| queue | Indicates the pointer to the work queue HdfWorkQueue. |
| work | Indicates the pointer to the delayed work item HdfWork. |
| queue | Indicates the pointer to the work queue HdfWorkQueue. |
| work | Indicates the pointer to the work item HdfWork. |
| work | Indicates the pointer to the delayed work item HdfWork. |
| work | Indicates the pointer to the work item HdfWork. |
| work | Indicates the pointer to the delayed work item HdfWork. |
| work | Indicates the pointer to the delayed work item HdfWork. |
| func | Indicates the work execution function. |
| arg | Indicates the pointer to the argument of the work execution function. |
| work | Indicates the pointer to the work item or delayed work item HdfWork. |
| work | Indicates the pointer to the work item HdfWork. |
| work | Indicates the pointer to the work item HdfWork. |
| func | Indicates the work execution function. |
| arg | Indicates the pointer to the argument of the work execution function. |
| queue | Indicates the pointer to the work queue HdfWorkQueue. |
| queue | Indicates the pointer to the work queue OsalWorkQueue. |
| name | Indicates the pointer to the work queue name. |