• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
3  * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice, this list of
9  * conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12  * of conditions and the following disclaimer in the documentation and/or other materials
13  * provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors may be used
16  * to endorse or promote products derived from this software without specific prior written
17  * permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 /* *
33  * @defgroup los_typedef Type define
34  * @ingroup kernel
35  */
36 
37 #ifndef _LOS_TYPEDEF_H
38 #define _LOS_TYPEDEF_H
39 
40 #include "stddef.h"
41 #include "stdbool.h"
42 #include "stdint.h"
43 
44 
45 #define OS_STRING(x) #x
46 #define X_STRING(x) OS_STRING(x)
47 
48 /* type definitions */
49 typedef unsigned char UINT8;
50 typedef unsigned short UINT16;
51 typedef unsigned int UINT32;
52 typedef signed char INT8;
53 typedef signed short INT16;
54 typedef signed int INT32;
55 typedef float FLOAT;
56 typedef double DOUBLE;
57 typedef char CHAR;
58 typedef unsigned long u_long;
59 typedef u_long ULong;
60 typedef long Long;
61 
62 #ifdef __LP64__
63 typedef long unsigned int UINT64;
64 typedef long signed int INT64;
65 typedef unsigned long UINTPTR;
66 typedef signed long INTPTR;
67 #else
68 typedef unsigned long long UINT64;
69 typedef signed long long INT64;
70 typedef unsigned int UINTPTR;
71 typedef signed int INTPTR;
72 #endif
73 
74 #ifdef __LP64__
75 typedef __uint128_t UINT128;
76 typedef INT64 ssize_t;
77 typedef UINT64 size_t;
78 #define LOSCFG_AARCH64
79 #else
80 typedef INT32 ssize_t;
81 typedef UINT32 size_t;
82 #endif
83 
84 typedef UINTPTR AARCHPTR;
85 typedef size_t BOOL;
86 
87 #define VOID void
88 #define STATIC static
89 
90 #ifndef FALSE
91 #define FALSE 0U
92 #endif
93 
94 #ifndef TRUE
95 #define TRUE 1U
96 #endif
97 
98 #ifndef NULL
99 #define NULL ((VOID *)0)
100 #endif
101 
102 #define OS_NULL_BYTE ((UINT8)0xFF)
103 #define OS_NULL_SHORT ((UINT16)0xFFFF)
104 #define OS_NULL_INT ((UINT32)0xFFFFFFFF)
105 
106 #ifndef USER
107 #define USER
108 #endif
109 
110 #ifndef LOS_OK
111 #define LOS_OK 0
112 #endif
113 
114 #ifndef LOS_NOK
115 #define LOS_NOK 1
116 #endif
117 
118 #ifndef LOS_EPERM
119 #define LOS_EPERM 1
120 #endif
121 
122 #ifndef LOS_ESRCH
123 #define LOS_ESRCH 3
124 #endif
125 
126 #ifndef LOS_ECHILD
127 #define LOS_ECHILD 10
128 #endif
129 
130 #ifndef LOS_EINVAL
131 #define LOS_EINVAL 22
132 #endif
133 
134 #ifndef LOS_EOPNOTSUPP
135 #define LOS_EOPNOTSUPP 95
136 #endif
137 
138 #define OS_FAIL 1
139 #define OS_ERROR (UINT32)(-1)
140 #define OS_INVALID (UINT32)(-1)
141 #define OS_INVALID_VALUE ((UINT32)0xFFFFFFFF)
142 
143 #define asm __asm
144 #ifdef typeof
145 #undef typeof
146 #endif
147 #define typeof __typeof__
148 
149 #ifndef LOS_LABEL_DEFN
150 #define LOS_LABEL_DEFN(label) label
151 #endif
152 
153 #ifndef LOSARC_ALIGNMENT
154 #define LOSARC_ALIGNMENT 8
155 #endif
156 /* And corresponding power of two alignment */
157 #ifndef LOSARC_P2ALIGNMENT
158 #ifdef LOSCFG_AARCH64
159 #define LOSARC_P2ALIGNMENT 3
160 #else
161 #define LOSARC_P2ALIGNMENT 2
162 #endif
163 #endif
164 
165 #define PAGE_SIZE_SHIFT (12)
166 
167 #ifndef PAGE_SIZE
168 #define PAGE_SIZE (1UL << PAGE_SIZE_SHIFT)
169 #endif
170 #define USER_PAGE_SIZE (1UL << 12)
171 
172 #if ARM64_CPU_CORTEX_A53 || ARM64_CPU_CORTEX_A57 || ARM64_CPU_CORTEX_A72
173 #define CACHE_LINE 64
174 #else
175 #define CACHE_LINE 32
176 #endif
177 
178 typedef int status_t;
179 typedef unsigned long vaddr_t;
180 typedef unsigned long paddr_t;
181 typedef unsigned int uint;
182 typedef unsigned long pte_t;
183 
184 /* Give a type or object explicit minimum alignment */
185 #if !defined(LOSBLD_ATTRIB_ALIGN)
186 #define LOSBLD_ATTRIB_ALIGN(__align__) __attribute__((aligned(__align__)))
187 #endif
188 
189 /* Assign a defined variable to a specific section */
190 #if !defined(LOSBLD_ATTRIB_SECTION)
191 #define LOSBLD_ATTRIB_SECTION(__sect__) __attribute__((section(__sect__)))
192 #endif
193 
194 /*
195  * Tell the compiler not to throw away a variable or function. Only known
196  * available on 3.3.2 or above. Old version's didn't throw them away,
197  * but using the unused attribute should stop warnings.
198  */
199 #define LOSBLD_ATTRIB_USED __attribute__((used))
200 
201 
202 #endif /* _LOS_TYPEDEF_H */
203