• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 /**
17  * @addtogroup Ddk
18  * @{
19  *
20  * @brief Provides Base DDK types and declares the macros, enums, and\n
21  * data structs used by the Base DDK APIs.
22  *
23  * @since 12
24  */
25 
26 /**
27  * @file ddk_types.h
28  *
29  * @brief Provides the enums, structs, and macros used in USB Base APIs.
30  *
31  * @library libddk_base.z.so
32  * @kit DriverDevelopmentKit
33  * @syscap SystemCapability.Driver.DDK.Extension
34  * @since 12
35  */
36 
37 #ifndef DDK_TYPES_H
38 #define DDK_TYPES_H
39 
40 #include <stddef.h>
41 #include <stdint.h>
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif /* __cplusplus */
46 
47 /**
48  * @brief Defines the shared memory created by using <b>OH_DDK_CreateAshmem</b>.\n
49  * A buffer for the shared memory provides better performance.
50  *
51  * @since 12
52  */
53 typedef struct DDK_Ashmem {
54     /** File descriptor of the shared memory. */
55     int32_t ashmemFd;
56     /** Buffer address. */
57     const uint8_t *address;
58     /** Buffer size. */
59     const uint32_t size;
60     /** Offset of the used buffer. The default value is 0, which indicates that there is no offset\n
61      * and the buffer starts from the specified address.
62      */
63     uint32_t offset;
64     /** Length of the used buffer. By default, the value is equal to the size, which indicates that\n
65      * the entire buffer is used.
66      */
67     uint32_t bufferLength;
68     /** Length of the transferred data. */
69     uint32_t transferredLength;
70 } DDK_Ashmem;
71 
72 /**
73  * @brief Enumerates the error codes used in the Base DDK.
74  *
75  * @since 12
76  */
77 typedef enum {
78     /** @error Operation success */
79     DDK_SUCCESS = 0,
80     /** @error Operation failed */
81     DDK_FAILURE = 28600001,
82     /** @error Invalid parameter */
83     DDK_INVALID_PARAMETER = 28600002,
84     /** @error Invalid operation */
85     DDK_INVALID_OPERATION = 28600003,
86     /** @error Null pointer exception */
87     DDK_NULL_PTR = 28600004
88 } DDK_RetCode;
89 #ifdef __cplusplus
90 }
91 /** @} */
92 #endif /* __cplusplus */
93 #endif // DDK_TYPES_H