ddk_api.h

Overview

Declares the BASE DDK APIs used by the USB host to access USB devices.

File to include: <ddk/ddk_api.h>

Library: libddk_base.z.so

System capability: SystemCapability.Driver.DDK.Extension

Since: 12

Related module: Ddk

Summary

Function

Name Description
DDK_RetCode OH_DDK_CreateAshmem(const uint8_t *name, uint32_t size, DDK_Ashmem **ashmem) Creates an Ashmem object. To prevent resource leakage, call OH_DDK_DestroyAshmem to destroy the Ashmem object when it is no longer needed.
DDK_RetCode OH_DDK_MapAshmem(DDK_Ashmem *ashmem, const uint8_t ashmemMapType) Maps the created Ashmem object to the user space. Call OH_DDK_UnmapAshmem to unmap the Ashmem object when it is no longer needed.
DDK_RetCode OH_DDK_UnmapAshmem(DDK_Ashmem *ashmem) Unmaps an Ashmem object.
DDK_RetCode OH_DDK_DestroyAshmem(DDK_Ashmem *ashmem) Destroys an Ashmem object.

Function Description

OH_DDK_CreateAshmem()

DDK_RetCode OH_DDK_CreateAshmem(const uint8_t *name, uint32_t size, DDK_Ashmem **ashmem)

Description

Creates an Ashmem object. To prevent resource leakage, call OH_DDK_DestroyAshmem to destroy the Ashmem object when it is no longer needed.

Since: 12

Parameters

Name Description
const uint8_t *name Pointer to the name of the Ashmem object.
uint32_t size Buffer size of the Ashmem object.
DDK_Ashmem **ashmem Pointer to the Ashmem object.

Returns

Type Description
DDK_RetCode DDK_SUCCESS: The API call is successful.
DDK_INVALID_PARAMETER: The input name is a null pointer, the value of size is 0, or the input ashmem is a null pointer.
DDK_FAILURE: The attempt to create an Ashmem object or the DDK_Ashmem structure fails.

OH_DDK_MapAshmem()

DDK_RetCode OH_DDK_MapAshmem(DDK_Ashmem *ashmem, const uint8_t ashmemMapType)

Description

Maps the created Ashmem object to the user space. Call OH_DDK_UnmapAshmem to unmap the Ashmem object when it is no longer needed.

Since: 12

Parameters

Name Description
DDK_Ashmem *ashmem Pointer to the Ashmem object.
const uint8_t ashmemMapType Mapping type for the Ashmem object.

Returns

Type Description
DDK_RetCode DDK_SUCCESS: The API call is successful.
DDK_NULL_PTR: The input ashmem is a null pointer.
DDK_FAILURE: The file descriptor of the Ashmem object is invalid.
DDK_INVALID_OPERATION: The attempt to call MapAshmem fails.

OH_DDK_UnmapAshmem()

DDK_RetCode OH_DDK_UnmapAshmem(DDK_Ashmem *ashmem)

Description

Unmaps an Ashmem object.

Since: 12

Parameters

Name Description
DDK_Ashmem *ashmem Pointer to the Ashmem object.

Returns

Type Description
DDK_RetCode DDK_SUCCESS: The API call is successful.
DDK_NULL_PTR: The input ashmem is a null pointer.
DDK_FAILURE: The file descriptor of the Ashmem object is invalid.

OH_DDK_DestroyAshmem()

DDK_RetCode OH_DDK_DestroyAshmem(DDK_Ashmem *ashmem)

Description

Destroys an Ashmem object.

Since: 12

Parameters

Name Description
DDK_Ashmem *ashmem Pointer to the Ashmem object.

Returns

Type Description
DDK_RetCode DDK_SUCCESS: The API call is successful.
DDK_NULL_PTR: The input ashmem is a null pointer.
DDK_FAILURE: The file descriptor of the Ashmem object is invalid.