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 * @syscap SystemCapability.Driver.DDK.Extension 34 * @since 12 35 */ 36 37 #include <stddef.h> 38 #include <stdint.h> 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif /* __cplusplus */ 43 44 /** 45 * @brief Defines the shared memory created by using <b>OH_DDK_CreateAShMem</b>.\n 46 * A buffer for the shared memory provides better performance. 47 * 48 * @since 12 49 */ 50 typedef struct DDK_Ashmem { 51 /** File descriptor of the shared memory. */ 52 int32_t ashmemFd; 53 /** Buffer address. */ 54 const uint8_t *address; 55 /** Buffer size. */ 56 const uint32_t size; 57 /** Offset of the used buffer. The default value is 0, which indicates that there is no offset\n 58 * and the buffer starts from the specified address. 59 */ 60 uint32_t offset; 61 /** Length of the used buffer. By default, the value is equal to the size, which indicates that\n 62 * the entire buffer is used. 63 */ 64 uint32_t bufferLength; 65 /** Length of the transferred data. */ 66 uint32_t transferredLength; 67 } DDK_Ashmem; 68 69 /** 70 * @brief Enumerates the error codes used in the Base DDK. 71 * 72 * @since 12 73 */ 74 typedef enum { 75 /** Operation success */ 76 DDK_SUCCESS = 0, 77 /** Operation failed */ 78 DDK_FAILURE = 28600001, 79 /** Invalid parameter */ 80 DDK_INVALID_PARAMETER = 28600002, 81 /** Invalid operation */ 82 DDK_INVALID_OPERATION = 28600003, 83 /** Null pointer exception */ 84 DDK_NULL_PTR = 28600004 85 } DDK_RetCode; 86 #ifdef __cplusplus 87 } 88 /** @} */ 89 #endif /* __cplusplus */ 90 #endif // DDK_TYPES_H