同步操作将从 OpenHarmony/docs 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
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
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) |
#define CONTAINER_OF( ptr, type, member ) (type *)((char *)(ptr) - (char *)&((type *)0)->member)
Description:
Obtains the address of a structure variable from its member address.
Parameters:
ptr | Indicates the structure member address. |
type | Indicates the structure type. |
member | Indicates the structure member. |
#define DLIST_FIRST_ENTRY( ptr, type, member ) [CONTAINER_OF](DriverUtils.md#ga818b9cca761fe7bc18e4e417da772976)((ptr)->next, type, member)
Description:
Obtains the first node of a doubly linked list.
Parameters:
ptr | Indicates the structure member address. |
type | Indicates the structure type. |
member | Indicates the structure member. |
#define DLIST_FOR_EACH_ENTRY( pos, head, type, member )
Values: for ((pos) = [CONTAINER_OF](DriverUtils.md#ga818b9cca761fe7bc18e4e417da772976)((head)->next, type, member); \
&(pos)->member != (head); \
(pos) = [CONTAINER_OF](DriverUtils.md#ga818b9cca761fe7bc18e4e417da772976)((pos)->member.next, type, member))
Description:
Traverses all nodes in a doubly linked list.
Parameters:
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. |
#define DLIST_FOR_EACH_ENTRY_SAFE( pos, tmp, head, type, member )
Values: for ((pos) = [CONTAINER_OF](DriverUtils.md#ga818b9cca761fe7bc18e4e417da772976)((head)->next, type, member), \
(tmp) = [CONTAINER_OF](DriverUtils.md#ga818b9cca761fe7bc18e4e417da772976)((pos)->member.next, type, member); \
&(pos)->member != (head); \
(pos) = (tmp), (tmp) = [CONTAINER_OF](DriverUtils.md#ga818b9cca761fe7bc18e4e417da772976)((pos)->member.next, type, member))
Description:
Traverses all nodes in a doubly linked list. This function is used to delete the nodes pointed to by pos during traversal.
Parameters:
#define DLIST_LAST_ENTRY( ptr, type, member ) [CONTAINER_OF](DriverUtils.md#ga818b9cca761fe7bc18e4e417da772976)((ptr)->prev, type, member)
Description:
Obtains the last node of a doubly linked list.
Parameters:
ptr | Indicates the structure member address. |
type | Indicates the structure type. |
member | Indicates the structure member. |
#define HDF_LOGD( fmt, arg... ) [printf](IO.md#ga98631211a4a8aee62f572375d5b637be)("[HDF:D/" LOG_TAG "]" fmt "\r\n", ##arg)
Description:
Prints logs at the debug level.
To use this function, you must define HDF_LOG_TAG, for example, #define HDF_LOG_TAG evt.
#define HDF_LOGE( fmt, arg... ) [printf](IO.md#ga98631211a4a8aee62f572375d5b637be)("[HDF:E/" LOG_TAG "]" fmt "\r\n", ##arg)
Description:
Prints logs at the error level.
To use this function, you must define HDF_LOG_TAG, for example, #define HDF_LOG_TAG evt.
#define HDF_LOGI( fmt, arg... ) [printf](IO.md#ga98631211a4a8aee62f572375d5b637be)("[HDF:I/" LOG_TAG "]" fmt "\r\n", ##arg)
Description:
Prints logs at the information level.
To use this function, you must define HDF_LOG_TAG, for example, #define HDF_LOG_TAG evt.
#define HDF_LOGV( fmt, arg... ) [printf](IO.md#ga98631211a4a8aee62f572375d5b637be)("[HDF:V/" LOG_TAG "]" fmt "\r\n", ##arg)
Description:
Prints logs at the verbose level.
To use this function, you must define HDF_LOG_TAG, for example, #define HDF_LOG_TAG evt.
#define HDF_LOGW( fmt, arg... ) [printf](IO.md#ga98631211a4a8aee62f572375d5b637be)("[HDF:W/" LOG_TAG "]" fmt "\r\n", ##arg)
Description:
Prints logs at the warning level.
To use this function, you must define HDF_LOG_TAG, for example, #define HDF_LOG_TAG evt.
#define LOG_TAG_MARK_EXTEND( HDF_TAG) #HDF_TAG
Description:
Add quotation mark
typedef void(* HdfWorkFunc) (void *)
Description:
Describes a work execution function type.
The thread of the work queue executes this function after the work item is added to the work queue.
anonymous enum
Description:
Enumerates statuses of a work item or a delayed work item.
HDF_WORK_BUSY_PENDING | |
HDF_WORK_BUSY_RUNNING |
enum [HDF_STATUS](DriverUtils.md#ga7e01536ecbe9b17563dd3fe256202a67)
Description:
Enumerates HDF return value types.
static void DListHeadInit (struct [DListHead](DListHead.md) * head)
Description:
Initializes a doubly linked list.
Parameters:
head | Indicates the pointer to the linked list DListHead. The parameter cannot be empty. |
static void DListInsertHead (struct [DListHead](DListHead.md) * entry, struct [DListHead](DListHead.md) * head )
Description:
Inserts a node from the head of a doubly linked list.
Parameters:
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. |
static void DListInsertTail (struct [DListHead](DListHead.md) * entry, struct [DListHead](DListHead.md) * head )
Description:
Inserts a node from the tail of a doubly linked list.
Parameters:
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. |
static bool DListIsEmpty (const struct [DListHead](DListHead.md) * head)
Description:
Checks whether a doubly linked list is empty.
Parameters:
head | Indicates the pointer to the linked list DListHead. The parameter cannot be empty. |
static void DListMerge (struct [DListHead](DListHead.md) * list, struct [DListHead](DListHead.md) * head )
Description:
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.
Parameters:
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. |
static void DListRemove (struct [DListHead](DListHead.md) * entry)
Description:
Removes a node from a doubly linked list.
Parameters:
entry | Indicates the pointer to the node to remove. For details, see DListHead. The parameter cannot be empty. |
bool HdfAddDelayedWork ([HdfWorkQueue](HdfWorkQueue.md) * queue, [HdfWork](HdfWork.md) * work, unsigned long ms )
Description:
Adds a delayed work item to a work queue.
A delayed work item is added to a work queue after the configured delayed time (ms), and the thread of the work queue executes the work function.
Parameters:
queue | Indicates the pointer to the work queue HdfWorkQueue. |
work | Indicates the pointer to the delayed work item HdfWork. |
Returns:
Returns true if the operation is successful; returns false otherwise.
bool HdfAddWork ([HdfWorkQueue](HdfWorkQueue.md) * queue, [HdfWork](HdfWork.md) * work )
Description:
Adds a work item to a work queue.
After a work item is added to a work queue, the thread of the work queue executes the function of the work item.
Parameters:
queue | Indicates the pointer to the work queue HdfWorkQueue. |
work | Indicates the pointer to the work item HdfWork. |
Returns:
Returns true if the operation is successful; returns false otherwise.
bool HdfCancelDelayedWorkSync ([HdfWork](HdfWork.md) * work)
Description:
Cancels a delayed work item.
Parameters:
work | Indicates the pointer to the delayed work item HdfWork. |
Returns:
Returns true if the operation is successful; returns false otherwise.
bool HdfCancelWorkSync ([HdfWork](HdfWork.md) * work)
Description:
Cancels a work item. This function waits until the work item is complete.
Parameters:
work | Indicates the pointer to the work item HdfWork. |
Returns:
Returns true if the operation is successful; returns false otherwise.
void HdfDelayedWorkDestroy ([HdfWork](HdfWork.md) * work)
Description:
Destroys a delayed work item.
Parameters:
work | Indicates the pointer to the delayed work item HdfWork. |
int32_t HdfDelayedWorkInit ([HdfWork](HdfWork.md) * work, [HdfWorkFunc](DriverUtils.md#ga30665d61b03fae4a2ebc778c3d775ce5) func, void * arg )
Description:
Initializes a delayed work item.
This function uses func and arg to initialize a work item. The work item is added to a work queue after the configured delayed time. The thread of the work queue executes this function, and arg is passed to func.
Parameters:
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. |
Returns:
Returns a value listed below:
unsigned int HdfWorkBusy ([HdfWork](HdfWork.md) * work)
Description:
Obtains the status of a work item or delayed work item.
Parameters:
work | Indicates the pointer to the work item or delayed work item HdfWork. |
Returns:
Returns HDF_WORK_BUSY_PENDING if the work item is pending; returns HDF_WORK_BUSY_RUNNING if the work item is running.
void HdfWorkDestroy ([HdfWork](HdfWork.md) * work)
Description:
Destroys a work item.
Parameters:
work | Indicates the pointer to the work item HdfWork. |
int32_t HdfWorkInit ([HdfWork](HdfWork.md) * work, [HdfWorkFunc](DriverUtils.md#ga30665d61b03fae4a2ebc778c3d775ce5) func, void * arg )
Description:
Initializes a work item.
This function uses func and arg to initialize a work item. After the work item is added to a work queue, the thread of the work queue executes this function, and arg is passed to func.
Parameters:
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. |
Returns:
Returns a value listed below:
void HdfWorkQueueDestroy ([HdfWorkQueue](HdfWorkQueue.md) * queue)
Description:
Destroys a work queue.
Parameters:
queue | Indicates the pointer to the work queue HdfWorkQueue. |
int32_t HdfWorkQueueInit ([HdfWorkQueue](HdfWorkQueue.md) * queue, char * name )
Description:
Initializes a work queue.
When a work queue is initialized, a thread is created. The thread cyclically executes the work items in the work queue, that is, executes their functions.
Parameters:
queue | Indicates the pointer to the work queue OsalWorkQueue. |
name | Indicates the pointer to the work queue name. |
Returns:
Returns a value listed below:
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。