1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef DDK_TYPES_H 16 #define DDK_TYPES_H 17 18 /** 19 * @addtogroup Ddk 20 * @{ 21 * 22 * @brief Provides Base DDK types and declares the macros, enums, and\n 23 * data structs used by the Base DDK APIs. 24 * 25 * @since 12 26 */ 27 28 /** 29 * @file ddk_types.h 30 * 31 * @brief Provides the enums, structs, and macros used in USB Base APIs. 32 * 33 * @library libddk_base.z.so 34 * @kit DriverDevelopmentKit 35 * @syscap SystemCapability.Driver.DDK.Extension 36 * @since 12 37 */ 38 39 #include <stddef.h> 40 #include <stdint.h> 41 42 #ifdef __cplusplus 43 extern "C" { 44 #endif /* __cplusplus */ 45 46 /** 47 * @brief Defines the shared memory created by using <b>OH_DDK_CreateAshmem</b>.\n 48 * A buffer for the shared memory provides better performance. 49 * 50 * @since 12 51 */ 52 typedef struct DDK_Ashmem { 53 /** File descriptor of the shared memory. */ 54 int32_t ashmemFd; 55 /** Buffer address. */ 56 const uint8_t *address; 57 /** Buffer size. */ 58 const uint32_t size; 59 /** Offset of the used buffer. The default value is 0, which indicates that there is no offset\n 60 * and the buffer starts from the specified address. 61 */ 62 uint32_t offset; 63 /** Length of the used buffer. By default, the value is equal to the size, which indicates that\n 64 * the entire buffer is used. 65 */ 66 uint32_t bufferLength; 67 /** Length of the transferred data. */ 68 uint32_t transferredLength; 69 } DDK_Ashmem; 70 71 /** 72 * @brief Enumerates the error codes used in the Base DDK. 73 * 74 * @since 12 75 */ 76 typedef enum { 77 /** @error Operation success */ 78 DDK_SUCCESS = 0, 79 /** @error Operation failed */ 80 DDK_FAILURE = 28600001, 81 /** @error Invalid parameter */ 82 DDK_INVALID_PARAMETER = 28600002, 83 /** @error Invalid operation */ 84 DDK_INVALID_OPERATION = 28600003, 85 /** @error Null pointer exception */ 86 DDK_NULL_PTR = 28600004 87 } DDK_RetCode; 88 #ifdef __cplusplus 89 } 90 /** @} */ 91 #endif /* __cplusplus */ 92 #endif // DDK_TYPES_H