harmony 鸿蒙Base DDK

2025-06-12 浏览 (1)

Base DDK

Overview

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

System capability: SystemCapability.Driver.DDK.Extension

Since

12

Summary

File

NameDescription
ddk_api.hDeclares 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.hDefines the enum variables and structs used in the HID DDK.
File to include: <base/ddk_types.h>
Library: libddk_base.z.so

Structs

NameDescription
DDK_AshmemShared memory.

Enums

NameDescription
DDK_RetCodeBase DDK error code definitions.

Functions

NameDescription
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.

ValueDescription
DDK_SUCCESSThe operation is successful.
DDK_FAILEDOperation failed.
DDK_INVALID_PARAMETERInvalid parameter.
DDK_INVALID_OPERATIONInvalid operation.
DDK_NULL_PTRNull 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

NameDescription
nameName of the Ashmem object.
sizeBuffer size of the Ashmem object.
ashmemPointer 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] (#ddk_retcode) 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

NameDescription
ashmemPointer to the Ashmem object.
ashmemMapTypeMapping type for 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] (#ddk_retcode) if the file descriptor of the shared memory is invalid.
  • DDK_INVALID_OPERATION if calling the MapAshmem API fails.

OH_DDK_UnmapAshmem()

DDK_RetCode OH_DDK_UnmapAshmem(DDK_Ashmem *ashmem);

Description

Unmaps an Ashmem object.

Parameters

NameDescription
ashmemPointer 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] (#ddk_retcode) 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

NameDescription
ashmemPointer 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] (#ddk_retcode) 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

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/D0JtdU