• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 
19 #ifndef __HI_TYPE_H__
20 #define __HI_TYPE_H__
21 
22 #if defined(__KERNEL__)
23 #include <linux/version.h>
24 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36))
25 #define DECLARE_MUTEX DEFINE_SEMAPHORE
26 #endif
27 #else
28 #include <stddef.h>
29 #include <stdint.h>
30 #endif
31 
32 #ifdef __cplusplus
33 #if __cplusplus
34 extern "C" {
35 #endif
36 #endif /* __cplusplus */
37 
38 /* --------------------------------------------------------------------------------------------------------------*
39  * Defintion of basic data types. The data types are applicable to both the application layer and kernel codes. *
40  * CNcomment: Basic data type definitions, both application layer and kernel codes use CNend *
41  * -------------------------------------------------------------------------------------------------------------- */
42 /*************************** Structure Definition ****************************/
43 /** \addtogroup      Common_TYPE */
44 /** @{ */ /** <!-- [Common_TYPE] */
45 #ifndef __KERNEL__
46 #ifndef UINT_MAX
47 #define UINT_MAX (~0U)
48 #endif
49 #ifndef HZ
50 #define HZ 1000
51 #endif
52 #ifndef U32_MAX
53 #define U32_MAX (~0U)
54 #endif
55 #endif
56 typedef unsigned char HI_U8;
57 typedef unsigned char HI_UCHAR;
58 typedef unsigned short HI_U16;
59 typedef unsigned int HI_U32;
60 typedef unsigned long HI_ULONG;
61 
62 typedef signed char HI_S8;
63 typedef short HI_S16;
64 typedef int HI_S32;
65 
66 #ifndef _M_IX86
67 typedef unsigned long long HI_U64;
68 typedef long long HI_S64;
69 #else
70 typedef __int64 HI_U64;
71 typedef __int64 HI_S64;
72 #endif
73 
74 typedef char HI_CHAR;
75 typedef char *HI_PCHAR;
76 
77 typedef float HI_FLOAT;
78 typedef double HI_DOUBLE;
79 #define HI_VOID void
80 
81 typedef unsigned long HI_SIZE_T;
82 typedef unsigned long HI_LENGTH_T;
83 
84 typedef HI_U32 HI_HANDLE;
85 
86 typedef unsigned int HI_PHYS_ADDR_T;
87 typedef unsigned int HI_VIRT_ADDR_T;
88 
89 /** Constant Definition */
90 /** CNcomment: ??��????  */
91 typedef enum {
92     HI_FALSE = 0,
93     HI_TRUE = 1,
94 } HI_BOOL;
95 
96 #define __isr_forbid__
97 
98 #ifndef NULL
99 #define NULL 0L
100 #endif
101 
102 #define HI_NULL     0L
103 #define HI_NULL_PTR 0L
104 
105 #define HI_SUCCESS 0
106 #define HI_FAILURE (-1)
107 
108 #define HI_INVALID_HANDLE (0xffffffff)
109 
110 #define HI_INVALID_PTS  (0xffffffff)
111 #define HI_INVALID_TIME (0xffffffff)
112 
113 #define HI_OS_LINUX 0xabcd
114 #define HI_OS_WIN32 0xcdef
115 
116 #ifdef _WIN32
117 #define HI_OS_TYPE HI_OS_WIN32
118 #else
119 #define __OS_LINUX__
120 #define HI_OS_TYPE HI_OS_LINUX
121 #endif
122 
123 #ifdef HI_ADVCA_SUPPORT
124 #define __INIT__
125 #define __EXIT__
126 #else
127 #define __INIT__ __init
128 #define __EXIT__ __exit
129 #endif
130 
131 /**
132 define of HI_HANDLE :
133 bit31                                                           bit0
134   |<----   16bit --------->|<---   8bit    --->|<---  8bit   --->|
135   |--------------------------------------------------------------|
136   |      HI_MOD_ID_E       |  mod defined data |     chnID       |
137   |--------------------------------------------------------------|
138 
139 mod defined data: private data define by each module(for example: sub-mod id), usually, set to 0.
140 */
141 
142 #define HI_HANDLE_MAKEHANDLE(mod, privatedata, chnid) (HI_HANDLE)((((mod)&0xffff) << 16) | \
143 ((((privatedata)&0xff) << 8)) | (((chnid)&0xff)))
144 
145 #define HI_HANDLE_GET_MODID(handle)   (((handle) >> 16) & 0xffff)
146 #define HI_HANDLE_GET_PriDATA(handle) (((handle) >> 8) & 0xff)
147 #define HI_HANDLE_GET_CHNID(handle)   (((handle)) & 0xff)
148 
149 #define HI_UNUSED(x) ((x) = (x))
150 typedef unsigned char hi_uchar;
151 typedef unsigned char hi_u8;
152 typedef unsigned short hi_u16;
153 typedef unsigned int hi_u32;
154 typedef unsigned long long hi_u64;
155 typedef unsigned long hi_ulong;
156 
157 typedef char hi_char;
158 typedef signed char hi_s8;
159 typedef short hi_s16;
160 typedef int hi_s32;
161 typedef long long hi_s64;
162 typedef long hi_slong;
163 
164 typedef float hi_float;
165 typedef double hi_double;
166 
167 typedef void hi_void;
168 
169 typedef unsigned long hi_size_t;
170 typedef unsigned long hi_length_t;
171 
172 typedef unsigned long hi_uintptr_t;
173 
174 typedef hi_u32 hi_handle;
175 
176 typedef HI_BOOL hi_bool;
177 
178 typedef unsigned int hi_phys_addr_t;
179 typedef unsigned int hi_virt_addr_t;
180 
181 /** @} */ /** <!-- ==== Structure Definition end ==== */
182 
183 #ifdef __cplusplus
184 #if __cplusplus
185 }
186 #endif
187 #endif /* __cplusplus */
188 
189 #endif /* __HI_TYPE_H__ */
190 
191