harmony 鸿蒙Base DDK

  • 2025-06-12
  • 浏览 (2)

Base DDK

Overview

Provides APIs for creating, mapping, unmapping, and destroying an Ashmem object.

System capability: SystemCapability.Driver.DDK.Extension

Since

12

Summary

File

Name Description
ddk_api.h Declares the HID DDK functions for accessing an input device from the host.
File to include: <base/ddk_api.h>
Library: libddk_base.z.so
ddk_types.h Defines the enum variables and structs used in the HID DDK.
File to include:
Library: libddk_base.z.so

Structs

Name Description
DDK_Ashmem Shared memory.

Enums

Name Description
DDK_RetCode Base DDK error code definitions.

Functions

Name Description
OH_DDK_CreateAshmem (const uint8_t name, DDK_Ashmem *ashmem) Creates an Ashmem object.
OH_DDK_MapAshmem (DDK_Ashmem *ashmem, const uint8_t ashmemMapType) Maps an Ashmem object.
OH_DDK_UnmapAshmem (DDK_Ashmem *ashmem) Unmaps an Ashmem object.
OH_DDK_DestroyAshmem (DDK_Ashmem *ashmem) Destroys an Ashmem object.

Enum Description

DDK_RetCode

enum DDK_RetCode

Description

Base DDK error code definitions.

Value Description
DDK_SUCCESS The operation is successful.
DDK_FAILED Operation failed.
DDK_INVALID_PARAMETER Invalid parameter.
DDK_INVALID_OPERATION Invalid operation.
DDK_NULL_PTR Null pointer.

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.

Parameters

Name Description
name Name of the Ashmem object.
size Buffer size of the Ashmem object.
ashmem Pointer to the Ashmem object.

Returns

  • DK_SUCCESS if the API is called successfully.
  • DDK_INVALID_PARAMETER if the input name or ashmem is a null pointer, or size is 0.
  • DDK_FAILURE if the attempt to create the shared memory or the DDK_Ashmem structure fails.

OH_DDK_MapAshmem()

DDK_RetCode OH_DDK_MapAshmem(DDK_Ashmem *ashmem, const uint8_t ashmemMapType);

Description

Maps an Ashmem object.

Parameters

Name Description
ashmem Pointer to the Ashmem object.
ashmemMapType Mapping type for the Ashmem object.

Returns

OH_DDK_UnmapAshmem()

DDK_RetCode OH_DDK_UnmapAshmem(DDK_Ashmem *ashmem);

Description

Unmaps an Ashmem object.

Parameters

Name Description
ashmem Pointer to the Ashmem object.

Returns

  • DK_SUCCESS if the API is called successfully.
  • DDK_NULL_PTR if the input ashmem is a null pointer.
  • DDK_FAILURE if the file descriptor of the shared memory is invalid.

OH_DDK_DestroyAshmem()

DDK_RetCode OH_DDK_DestroyAshmem(DDK_Ashmem *ashmem);

Description

Destroys the created shared memory.

Parameters

Name Description
ashmem Pointer to the Ashmem object.

Returns

  • DK_SUCCESS if the API is called successfully.
  • DDK_NULL_PTR if the input ashmem is a null pointer.
  • DDK_FAILURE if the file descriptor of the shared memory is invalid.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Driver Development Kit

harmony 鸿蒙DDK_Ashmem

harmony 鸿蒙Hid_AbsAxesArray

harmony 鸿蒙Hid_Device

harmony 鸿蒙Hid_EmitItem

harmony 鸿蒙Hid_EventProperties

harmony 鸿蒙Hid_EventTypeArray

harmony 鸿蒙Hid_KeyCodeArray

harmony 鸿蒙Hid_MscEventArray

harmony 鸿蒙Hid_RawDevInfo

0  赞