同步操作将从 OpenHarmony/docs 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
Provides OpenHarmony Driver Foundation (HDF) APIs.
The HDF implements driver framework capabilities such as driver loading, service management, and driver message model. You can develop drivers based on the HDF.
Since:
1.0
Declares functions related to driver loading, service obtaining, and power management. |
|
Declares the structures defining driver service objects and event listeners, as well as the functions for obtaining a driver service object, dispatching a driver service call, and registering or unregistering an event listener. |
|
Declares the base object provided by the HDF for the driver. |
|
Defines functions related to a HdfSBuf. The HDF provides data serialization and deserialization capabilities for data transmission between user-mode applications and kernel-mode drivers. |
Defines the power management functions provided by the HDF for the driver. |
|
Defines a HdfSBuf. |
HDF_INIT(module) HDF_DRIVER_INIT(module) |
OnEventReceived) (void *priv, uint32_t id, struct HdfSBuf *data) |
ServicePolicy { SERVICE_POLICY_NONE = 0, SERVICE_POLICY_PUBLIC, SERVICE_POLICY_CAPACITY, SERVICE_POLICY_FRIENDLY, SERVICE_POLICY_PRIVATE, SERVICE_POLICY_INVALID } |
Enumerates policies for releasing driver services developed based on the HDF. |
DevicePreload { DEVICE_PRELOAD_ENABLE = 0, DEVICE_PRELOAD_DISABLE, DEVICE_PRELOAD_INVALID } |
DevSvcManagerClntGetService (const char *svcName) |
const struct HdfObject * Obtains the driver service object based on a driver service name. |
HdfDeviceGetServiceName (const struct HdfDeviceObject *deviceObject) |
|
HdfDeviceSubscribeService (struct HdfDeviceObject *deviceObject, const char *serviceName, struct SubscriberCallback callback) |
|
HdfDeviceSendEvent (const struct HdfDeviceObject *deviceObject, uint32_t id, const struct HdfSBuf *data) |
|
HdfDeviceSendEventToClient (const struct HdfDeviceIoClient *client, uint32_t id, const struct HdfSBuf *data) |
|
HdfIoServiceBind (const char *serviceName, mode_t permission) |
struct HdfIoService * |
HdfIoServiceRecycle (struct HdfIoService *service) |
Destroys a specified driver service object to release resources if it is no longer required. |
HdfDeviceRegisterEventListener (struct HdfIoService *target, struct HdfDevEventlistener *listener) |
Registers a custom HdfDevEventlistener for listening for events reported by a specified driver service object. |
HdfDeviceUnregisterEventListener (struct HdfIoService *target, struct HdfDevEventlistener *listener) |
Unregisters a previously registered HdfDevEventlistener to release resources if it is no longer required. |
HdfSbufWriteBuffer (struct HdfSBuf *sbuf, const void *data, uint32_t writeSize) |
|
HdfSbufWriteUint64 (struct HdfSBuf *sbuf, uint64_t value) |
|
HdfSbufWriteUint32 (struct HdfSBuf *sbuf, uint32_t value) |
|
HdfSbufWriteUint16 (struct HdfSBuf *sbuf, uint16_t value) |
|
HdfSbufWriteUint8 (struct HdfSBuf *sbuf, uint8_t value) |
|
HdfSbufWriteInt64 (struct HdfSBuf *sbuf, int64_t value) |
|
HdfSbufWriteInt32 (struct HdfSBuf *sbuf, int32_t value) |
|
HdfSbufWriteInt16 (struct HdfSBuf *sbuf, int16_t value) |
|
HdfSbufWriteInt8 (struct HdfSBuf *sbuf, int8_t value) |
|
HdfSbufWriteString (struct HdfSBuf *sbuf, const char *value) |
|
HdfSbufReadBuffer (struct HdfSBuf *sbuf, const void **data, uint32_t *readSize) |
|
HdfSbufReadUint64 (struct HdfSBuf *sbuf, uint64_t *value) |
|
HdfSbufReadUint32 (struct HdfSBuf *sbuf, uint32_t *value) |
|
HdfSbufReadUint16 (struct HdfSBuf *sbuf, uint16_t *value) |
|
HdfSbufReadUint8 (struct HdfSBuf *sbuf, uint8_t *value) |
|
HdfSbufReadInt64 (struct HdfSBuf *sbuf, int64_t *value) |
|
HdfSbufReadInt32 (struct HdfSBuf *sbuf, int32_t *value) |
|
HdfSbufReadInt16 (struct HdfSBuf *sbuf, int16_t *value) |
|
HdfSbufReadInt8 (struct HdfSBuf *sbuf, int8_t *value) |
|
HdfSbufReadString (struct HdfSBuf *sbuf) |
|
HdfSbufGetData (const struct HdfSBuf *sbuf) |
|
HdfSbufFlush (struct HdfSBuf *sbuf) |
|
HdfSbufGetCapacity (const struct HdfSBuf *sbuf) |
|
HdfSbufGetDataSize (const struct HdfSBuf *sbuf) |
|
HdfSBufObtain (size_t capacity) |
struct HdfSBuf * |
HdfSBufObtainDefaultSize (void) |
struct HdfSBuf * Obtains a SBuf instance of the default capacity (256 bytes). |
HdfSBufBind (uintptr_t base, size_t size) |
struct HdfSBuf * Creates a SBuf instance with the specified data and size. The pointer to the data stored in the SBuf is released by the caller, and the written data size should not exceed the specified value of size. |
HdfSBufRecycle (struct HdfSBuf *sbuf) |
|
HdfSBufMove (struct HdfSBuf *sbuf) |
struct HdfSBuf * Creates a SBuf instance with an original SBuf. This function moves the data stored in the original SBuf to the new one without memory copy. |
HdfSBufCopy (const struct HdfSBuf *sbuf) |
struct HdfSBuf * Creates a SBuf instance with an original SBuf. This function copies the data stored in the original SBuf to the new one. |
HdfSbufTransDataOwnership (struct HdfSBuf *sbuf) |
Transfers the data ownership to a SBuf. Once the SBuf is released, the bound data memory is also released. This function is used together with HdfSBufBind. |
#define HDF_INIT( module) HDF_DRIVER_INIT(module)
Description:
Registers the driver with the HDF.
For a driver developed based on the HDF, HDF_INIT must be used to register an entry with the HDF, and the registered object must be of the HdfDriverEntry type.
Parameters:
module | Indicates the global variable of the HdfDriverEntry type |
typedef int(* OnEventReceived) (void *priv, uint32_t id, struct [HdfSBuf](HdfSBuf.md) *data)
Description:
Called when a driver event occurs.
You can implement this function and bind it to the custom HdfDevEventlistener object.
Parameters:
priv | Indicates the pointer to the private data bound to this listener. |
id | Indicates the serial number of the driver event occurred. |
data | Indicates the pointer to the content data of the driver event. |
Returns:
Returns 0 if the operation is successful; returns a negative value otherwise.
enum [DevicePreload](Core.md#ga0f3d81b5ff5d3896f7d8cf15f76b451e)
Description:
Enumerates driver loading policies.
If a driver developed based on the HDF needs to use the on-demand loading mechanism in the HDF, the PRELOAD field must be correctly set in the driver configuration information to control the driver loading mode.
DEVICE_PRELOAD_ENABLE | |
DEVICE_PRELOAD_DISABLE | |
DEVICE_PRELOAD_INVALID |
enum [ServicePolicy](Core.md#ga172844da8a6908bf7226eee703ad9f80)
Description:
Enumerates policies for releasing driver services developed based on the HDF.
If a driver is developed based on the HDF and uses the service management feature of the HDF, you need to configure the policy for releasing services to external systems.
const struct [HdfObject](HdfObject.md)* DevSvcManagerClntGetService (const char * svcName)
Description:
Obtains the driver service object based on a driver service name.
Parameters:
serviceName | Indicates the pointer to the released driver service name. |
Returns:
Returns the driver service object if the operation is successful; returns NULL otherwise.
const char* HdfDeviceGetServiceName (const struct [HdfDeviceObject](HdfDeviceObject.md) * deviceObject)
Description:
Obtains the service name of a driver.
If a driver does not save its service name, it can use this function to obtain the service name.
Parameters:
deviceObject | Indicates the pointer to the driver device object. |
Returns:
Returns the service name if the operation is successful; returns NULL otherwise.
int HdfDeviceRegisterEventListener (struct [HdfIoService](HdfIoService.md) * target, struct [HdfDevEventlistener](HdfDevEventlistener.md) * listener )
Description:
Registers a custom HdfDevEventlistener for listening for events reported by a specified driver service object.
Parameters:
target | Indicates the pointer to the driver service object to listen, which is obtained through the HdfIoServiceBind function. |
listener | Indicates the pointer to the listener to register. |
Returns:
Returns 0 if the operation is successful; returns a negative value otherwise.
int32_t HdfDeviceSendEvent (const struct [HdfDeviceObject](HdfDeviceObject.md) * deviceObject, uint32_t id, const struct [HdfSBuf](HdfSBuf.md) * data )
Description:
Sends event messages.
When the driver service invokes this function to send a message, all user-level applications that have registered listeners through HdfDeviceRegisterEventListener will receive the message.
Parameters:
deviceObject | Indicates the pointer to the driver device object. |
id | Indicates the ID of the message sending event. |
data | Indicates the pointer to the message content sent by the driver. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
int32_t HdfDeviceSendEventToClient (const struct [HdfDeviceIoClient](HdfDeviceIoClient.md) * client, uint32_t id, const struct [HdfSBuf](HdfSBuf.md) * data )
Description:
Sends an event message to a specified client object.
When the driver service invokes this function to send a message, the user-level applications that have registered listeners through HdfDeviceRegisterEventListener and correspond to this client object will receive the message.
Parameters:
client | Indicates the pointer to the client object of the driver service. |
id | Indicates the ID of the message sending event. |
data | Indicates the pointer to the message content sent by the driver. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
int32_t HdfDeviceSubscribeService (struct [HdfDeviceObject](HdfDeviceObject.md) * deviceObject, const char * serviceName, struct [SubscriberCallback](SubscriberCallback.md) callback )
Description:
Subscribes to a driver service.
If the driver loading time is not perceived, this function can be used to subscribe to the driver service. (The driver service and the subscriber must be on the same host.) After the subscribed-to driver service is loaded by the HDF, the framework proactively releases the service interface to the subscriber.
Parameters:
deviceObject | Indicates the pointer to the driver device object of the subscriber. |
serviceName | Indicates the pointer to the driver service name. |
callback | Indicates the callback invoked by the HDF after the subscribed-to driver service is loaded. |
Returns:
Returns 0 if the operation is successful; returns a non-zero value otherwise.
int HdfDeviceUnregisterEventListener (struct [HdfIoService](HdfIoService.md) * target, struct [HdfDevEventlistener](HdfDevEventlistener.md) * listener )
Description:
Unregisters a previously registered HdfDevEventlistener to release resources if it is no longer required.
Parameters:
target | Indicates the pointer to the driver service object that has been listened. |
listener | Indicates the listener object registered by HdfDeviceRegisterEventListener. |
Returns:
Returns 0 if the operation is successful; returns a negative value otherwise.
struct [HdfIoService](HdfIoService.md)* HdfIoServiceBind (const char * serviceName, mode_t permission )
Description:
Obtains a driver service object.
Parameters:
Returns:
Returns the pointer to the driver service object if the operation is successful; returns NULL otherwise.
void HdfIoServiceRecycle (struct [HdfIoService](HdfIoService.md) * service)
Description:
Destroys a specified driver service object to release resources if it is no longer required.
Parameters:
service | Indicates the pointer to the driver service object to destroy. |
struct [HdfSBuf](HdfSBuf.md)* HdfSBufBind (uintptr_t base, size_t size )
Description:
Creates a SBuf instance with the specified data and size. The pointer to the data stored in the SBuf is released by the caller, and the written data size should not exceed the specified value of size.
Parameters:
base | Indicates the base of the data to use. |
size | Indicates the size of the data to use. |
Returns:
Returns the SBuf instance.
struct [HdfSBuf](HdfSBuf.md)* HdfSBufCopy (const struct [HdfSBuf](HdfSBuf.md) * sbuf)
Description:
Creates a SBuf instance with an original SBuf. This function copies the data stored in the original SBuf to the new one.
Parameters:
sbuf | Indicates the pointer to the original SBuf. |
Returns:
Returns the new SBuf instance.
void HdfSbufFlush (struct [HdfSBuf](HdfSBuf.md) * sbuf)
Description:
Clears the data stored in a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
size_t HdfSbufGetCapacity (const struct [HdfSBuf](HdfSBuf.md) * sbuf)
Description:
Obtains the capacity of a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
Returns:
Returns the SBuf capacity.
uint8_t* HdfSbufGetData (const struct [HdfSBuf](HdfSBuf.md) * sbuf)
Description:
Obtains the pointer to the data stored in aSBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
Returns:
Returns the pointer to the data stored in the target SBuf.
size_t HdfSbufGetDataSize (const struct [HdfSBuf](HdfSBuf.md) * sbuf)
Description:
Obtains the size of the data stored in a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
Returns:
Returns the data size.
struct [HdfSBuf](HdfSBuf.md)* HdfSBufMove (struct [HdfSBuf](HdfSBuf.md) * sbuf)
Description:
Creates a SBuf instance with an original SBuf. This function moves the data stored in the original SBuf to the new one without memory copy.
Parameters:
sbuf | Indicates the pointer to the original SBuf. |
Returns:
Returns the new SBuf instance.
struct [HdfSBuf](HdfSBuf.md)* HdfSBufObtain (size_t capacity)
Description:
Obtains a SBuf instance.
Parameters:
capacity | Indicates the initial capacity of theSBuf. |
Returns:
Returns the SBuf instance.
struct [HdfSBuf](HdfSBuf.md)* HdfSBufObtainDefaultSize (void )
Description:
Obtains a SBuf instance of the default capacity (256 bytes).
Returns:
Returns the SBuf instance.
bool HdfSbufReadBuffer (struct [HdfSBuf](HdfSBuf.md) * sbuf, const void ** data, uint32_t * readSize )
Description:
Reads a data segment from a SBuf.
Parameters:
Returns:
Returns true if the operation is successful; returns false otherwise.
bool HdfSbufReadInt16 (struct [HdfSBuf](HdfSBuf.md) * sbuf, int16_t * value )
Description:
Reads a 16-bit signed integer from a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the pointer to the 16-bit signed integer read, which is requested by the caller. |
Returns:
Returns true if the operation is successful; returns false otherwise.
bool HdfSbufReadInt32 (struct [HdfSBuf](HdfSBuf.md) * sbuf, int32_t * value )
Description:
Reads a 32-bit signed integer from a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the pointer to the 32-bit signed integer read, which is requested by the caller. |
Returns:
Returns true if the operation is successful; returns false otherwise.
bool HdfSbufReadInt64 (struct [HdfSBuf](HdfSBuf.md) * sbuf, int64_t * value )
Description:
Reads a 64-bit signed integer from a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the pointer to the 64-bit signed integer read, which is requested by the caller. |
Returns:
Returns true if the operation is successful; returns false otherwise.
bool HdfSbufReadInt8 (struct [HdfSBuf](HdfSBuf.md) * sbuf, int8_t * value )
Description:
Reads an 8-bit signed integer from a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the pointer to the 8-bit signed integer read, which is requested by the caller. |
Returns:
Returns true if the operation is successful; returns false otherwise.
const char* HdfSbufReadString (struct [HdfSBuf](HdfSBuf.md) * sbuf)
Description:
Reads a string from a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
Returns:
Returns the pointer to the string read if the operation is successful; returns NULL otherwise. The memory pointed to by this pointer is managed by the SBuf and they share the same lifecycle.
bool HdfSbufReadUint16 (struct [HdfSBuf](HdfSBuf.md) * sbuf, uint16_t * value )
Description:
Reads a 16-bit unsigned integer from a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the pointer to the 16-bit unsigned integer read, which is requested by the caller. |
Returns:
Returns true if the operation is successful; returns false otherwise.
bool HdfSbufReadUint32 (struct [HdfSBuf](HdfSBuf.md) * sbuf, uint32_t * value )
Description:
Reads a 32-bit unsigned integer from a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the pointer to the 32-bit unsigned integer read, which is requested by the caller. |
Returns:
Returns true if the operation is successful; returns false otherwise.
bool HdfSbufReadUint64 (struct [HdfSBuf](HdfSBuf.md) * sbuf, uint64_t * value )
Description:
Reads a 64-bit unsigned integer from a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the pointer to the 64-bit unsigned integer read, which is requested by the caller. |
Returns:
Returns true if the operation is successful; returns false otherwise.
bool HdfSbufReadUint8 (struct [HdfSBuf](HdfSBuf.md) * sbuf, uint8_t * value )
Description:
Reads an 8-bit unsigned integer from a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the pointer to the 8-bit unsigned integer read, which is requested by the caller. |
Returns:
Returns true if the operation is successful; returns false otherwise.
void HdfSBufRecycle (struct [HdfSBuf](HdfSBuf.md) * sbuf)
Description:
Releases a **SBuf **.
Parameters:
sbuf | Indicates the pointer to the SBuf to release. |
void HdfSbufTransDataOwnership (struct [HdfSBuf](HdfSBuf.md) * sbuf)
Description:
Transfers the data ownership to a SBuf. Once the SBuf is released, the bound data memory is also released. This function is used together with HdfSBufBind.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
bool HdfSbufWriteBuffer (struct [HdfSBuf](HdfSBuf.md) * sbuf, const void * data, uint32_t writeSize )
Description:
Writes a data segment to a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
data | Indicates the pointer to the data segment to write. |
writeSize | Indicates the size of the data segment to write. The maximum value is 512 KB. |
Returns:
Returns true if the operation is successful; returns false otherwise.
bool HdfSbufWriteInt16 (struct [HdfSBuf](HdfSBuf.md) * sbuf, int16_t value )
Description:
Writes a 16-bit signed integer to a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the 16-bit signed integer to write. |
Returns:
Returns true if the operation is successful; returns false otherwise.
bool HdfSbufWriteInt32 (struct [HdfSBuf](HdfSBuf.md) * sbuf, int32_t value )
Description:
Writes a 32-bit signed integer to a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the 32-bit signed integer to write. |
Returns:
Returns true if the operation is successful; returns false otherwise.
bool HdfSbufWriteInt64 (struct [HdfSBuf](HdfSBuf.md) * sbuf, int64_t value )
Description:
Writes a 64-bit signed integer to a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the 64-bit signed integer to write. |
Returns:
Returns true if the operation is successful; returns false otherwise.
bool HdfSbufWriteInt8 (struct [HdfSBuf](HdfSBuf.md) * sbuf, int8_t value )
Description:
Writes an 8-bit signed integer to a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the 8-bit signed integer to write. |
Returns:
Returns true if the operation is successful; returns false otherwise.
bool HdfSbufWriteString (struct [HdfSBuf](HdfSBuf.md) * sbuf, const char * value )
Description:
Writes a string to a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the pointer to the string to write. |
Returns:
Returns true if the operation is successful; returns false otherwise.
bool HdfSbufWriteUint16 (struct [HdfSBuf](HdfSBuf.md) * sbuf, uint16_t value )
Description:
Writes a 16-bit unsigned integer to a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the 16-bit unsigned integer to write. |
Returns:
Returns true if the operation is successful; returns false otherwise.
bool HdfSbufWriteUint32 (struct [HdfSBuf](HdfSBuf.md) * sbuf, uint32_t value )
Description:
Writes a 32-bit unsigned integer to a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the 32-bit unsigned integer to write. |
Returns:
Returns true if the operation is successful; returns false otherwise.
bool HdfSbufWriteUint64 (struct [HdfSBuf](HdfSBuf.md) * sbuf, uint64_t value )
Description:
Writes a 64-bit unsigned integer to a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the 64-bit unsigned integer to write. |
Returns:
Returns true if the operation is successful; returns false otherwise.
bool HdfSbufWriteUint8 (struct [HdfSBuf](HdfSBuf.md) * sbuf, uint8_t value )
Description:
Writes an 8-bit unsigned integer to a SBuf.
Parameters:
sbuf | Indicates the pointer to the target SBuf. |
value | Indicates the 8-bit unsigned integer to write. |
Returns:
Returns true if the operation is successful; returns false otherwise.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。