1# BASE DDK 2 3 4## Overview 5 6Provides APIs for creating, mapping, unmapping, and destroying an **Ashmem** object. 7 8**System capability**: SystemCapability.Driver.DDK.Extension 9 10**Since** 11 1212 13 14## Summary 15 16 17### File 18 19| Name| Description| 20| -------- | -------- | 21| [ddk_api.h](ddk_api.md) | Declares the HID DDK functions for accessing an input device from the host.<br>File to include: <base/ddk_api.h> <br>Library: libddk_base.z.so| 22| [ddk_types.h](ddk_types.md) | Defines the enum variables and structs used in the HID DDK.<br>File to include: <base/ddk_types.h><br>Library: libddk_base.z.so| 23 24 25### Structs 26 27| Name| Description| 28| -------- | -------- | 29| [DDK_Ashmem](_ddk_ashmem.md) | Shared memory. | 30 31 32### Enums 33 34| Name| Description| 35| -------- | -------- | 36| [DDK_RetCode](#ddk_retcode) | BASE DDK error code definitions. | 37 38 39### Functions 40 41| Name| Description| 42| -------- | -------- | 43| [OH_DDK_CreateAshmem](#oh_ddk_createashmem) (const uint8_t *name, [DDK_Ashmem](_ddk_ashmem.md) \*\*ashmem) | Creates an **Ashmem** object. | 44| [OH_DDK_MapAshmem](#oh_ddk_mapashmem) ([DDK_Ashmem](_ddk_ashmem.md) \*ashmem, const uint8_t ashmemMapType) | Maps an **Ashmem** object. | 45| [OH_DDK_UnmapAshmem](#oh_ddk_unmapashmem) ([DDK_Ashmem](_ddk_ashmem.md) \*ashmem) | Unmaps an **Ashmem** object. | 46| [OH_DDK_DestoryAshmem](#oh_ddk_destoryashmem) ([DDK_Ashmem](_ddk_ashmem.md) \*ashmem) | Destroys an **Ashmem** object. | 47 48 49## Enum Description 50 51 52### DDK_RetCode 53 54 55``` 56enum DDK_RetCode 57``` 58 59**Description** 60 61BASE DDK error code definitions. 62 63| Value| Description| 64| -------- | -------- | 65| DDK_SUCCESS | The operation is successful.| 66| DDK_FAILED | Operation failed.| 67| DDK_INVALID_PARAMETER | Invalid parameter.| 68| DDK_INVALID_OPERATION | Invalid operation.| 69| DDK_NULL_PTR | Null pointer.| 70 71 72## Function Description 73 74 75### OH_DDK_CreateAshmem() 76 77 78``` 79DDK_RetCode OH_DDK_CreateAshmem(const uint8_t *name, uint32_t size, DDK_Ashmem **ashmem); 80``` 81 82**Description** 83 84Creates an **Ashmem** object. 85 86**Parameters** 87 88| Name| Description| 89| -------- | -------- | 90| name | Name of the **Ashmem** object.| 91| size | Buffer size of the **Ashmem** object.| 92| ashmem | Pointer to the **Ashmem** object.| 93 94**Returns** 95 96**0** if the operation is successful; a negative value otherwise. 97 98 99### OH_DDK_MapAshmem() 100 101 102``` 103DDK_RetCode OH_DDK_MapAshmem(DDK_Ashmem *ashmem, const uint8_t ashmemMapType); 104``` 105 106**Description** 107 108Maps an **Ashmem** object. 109 110**Parameters** 111 112| Name| Description| 113| -------- | -------- | 114| ashmem | Pointer to the **Ashmem** object.| 115| ashmemMapType | Mapping type for the **Ashmem** object.| 116 117**Returns** 118 119**0** if the operation is successful; a negative value otherwise. 120 121 122### OH_DDK_UnmapAshmem() 123 124 125``` 126DDK_RetCode OH_DDK_UnmapAshmem(DDK_Ashmem *ashmem); 127``` 128 129**Description** 130 131Unmaps an **Ashmem** object. 132 133**Parameters** 134 135| Name| Description| 136| -------- | -------- | 137| ashmem | Pointer to the **Ashmem** object.| 138 139**Returns** 140 141**0** if the operation is successful; a negative value otherwise. 142 143 144### OH_DDK_DestoryAshmem() 145 146 147``` 148DDK_RetCode OH_DDK_DestroyAshmem(DDK_Ashmem *ashmem); 149``` 150 151**Description** 152 153Destroys the created shared memory. 154 155**Parameters** 156 157| Name| Description| 158| -------- | -------- | 159| ashmem | Pointer to the **Ashmem** object.| 160 161**Returns** 162 163**0** if the operation is successful; a negative value otherwise. 164