1 | /****************************************************************************** |
---|
2 | * Copyright (c) 2010 - 2020 Xilinx, Inc. All rights reserved. |
---|
3 | * SPDX-License-Identifier: MIT |
---|
4 | ******************************************************************************/ |
---|
5 | |
---|
6 | /*****************************************************************************/ |
---|
7 | /** |
---|
8 | * |
---|
9 | * @file xil_types.h |
---|
10 | * |
---|
11 | * @addtogroup common_types Basic Data types for Xilinx® Software IP |
---|
12 | * |
---|
13 | * The xil_types.h file contains basic types for Xilinx software IP. These data types |
---|
14 | * are applicable for all processors supported by Xilinx. |
---|
15 | * @{ |
---|
16 | * <pre> |
---|
17 | * MODIFICATION HISTORY: |
---|
18 | * |
---|
19 | * Ver Who Date Changes |
---|
20 | * ----- ---- -------- ------------------------------------------------------- |
---|
21 | * 1.00a hbm 07/14/09 First release |
---|
22 | * 3.03a sdm 05/30/11 Added Xuint64 typedef and XUINT64_MSW/XUINT64_LSW macros |
---|
23 | * 5.00 pkp 05/29/14 Made changes for 64 bit architecture |
---|
24 | * srt 07/14/14 Use standard definitions from stdint.h and stddef.h |
---|
25 | * Define LONG and ULONG datatypes and mask values |
---|
26 | * 7.00 mus 01/07/19 Add cpp extern macro |
---|
27 | * 7.1 aru 08/19/19 Shift the value in UPPER_32_BITS only if it |
---|
28 | * is 64-bit processor |
---|
29 | * </pre> |
---|
30 | * |
---|
31 | ******************************************************************************/ |
---|
32 | |
---|
33 | #ifndef XIL_TYPES_H /* prevent circular inclusions */ |
---|
34 | #define XIL_TYPES_H /* by using protection macros */ |
---|
35 | |
---|
36 | #ifdef __cplusplus |
---|
37 | extern "C" { |
---|
38 | #endif |
---|
39 | |
---|
40 | #include <stdint.h> |
---|
41 | #include <stddef.h> |
---|
42 | |
---|
43 | /************************** Constant Definitions *****************************/ |
---|
44 | |
---|
45 | #ifndef TRUE |
---|
46 | # define TRUE 1U |
---|
47 | #endif |
---|
48 | |
---|
49 | #ifndef FALSE |
---|
50 | # define FALSE 0U |
---|
51 | #endif |
---|
52 | |
---|
53 | #ifndef NULL |
---|
54 | #define NULL 0U |
---|
55 | #endif |
---|
56 | |
---|
57 | #define XIL_COMPONENT_IS_READY 0x11111111U /**< In device drivers, This macro will be |
---|
58 | assigend to "IsReady" member of driver |
---|
59 | instance to indicate that driver |
---|
60 | instance is initialized and ready to use. */ |
---|
61 | #define XIL_COMPONENT_IS_STARTED 0x22222222U /**< In device drivers, This macro will be assigend to |
---|
62 | "IsStarted" member of driver instance |
---|
63 | to indicate that driver instance is |
---|
64 | started and it can be enabled. */ |
---|
65 | |
---|
66 | /* @name New types |
---|
67 | * New simple types. |
---|
68 | * @{ |
---|
69 | */ |
---|
70 | #ifndef __KERNEL__ |
---|
71 | #ifndef XBASIC_TYPES_H |
---|
72 | /* |
---|
73 | * guarded against xbasic_types.h. |
---|
74 | */ |
---|
75 | typedef uint8_t u8; |
---|
76 | typedef uint16_t u16; |
---|
77 | typedef uint32_t u32; |
---|
78 | /** @}*/ |
---|
79 | #define __XUINT64__ |
---|
80 | typedef struct |
---|
81 | { |
---|
82 | u32 Upper; |
---|
83 | u32 Lower; |
---|
84 | } Xuint64; |
---|
85 | |
---|
86 | |
---|
87 | /*****************************************************************************/ |
---|
88 | /** |
---|
89 | * @brief Return the most significant half of the 64 bit data type. |
---|
90 | * |
---|
91 | * @param x is the 64 bit word. |
---|
92 | * |
---|
93 | * @return The upper 32 bits of the 64 bit word. |
---|
94 | * |
---|
95 | ******************************************************************************/ |
---|
96 | #define XUINT64_MSW(x) ((x).Upper) |
---|
97 | |
---|
98 | /*****************************************************************************/ |
---|
99 | /** |
---|
100 | * @brief Return the least significant half of the 64 bit data type. |
---|
101 | * |
---|
102 | * @param x is the 64 bit word. |
---|
103 | * |
---|
104 | * @return The lower 32 bits of the 64 bit word. |
---|
105 | * |
---|
106 | ******************************************************************************/ |
---|
107 | #define XUINT64_LSW(x) ((x).Lower) |
---|
108 | |
---|
109 | #endif /* XBASIC_TYPES_H */ |
---|
110 | |
---|
111 | /* |
---|
112 | * xbasic_types.h does not typedef s* or u64 |
---|
113 | */ |
---|
114 | /** @{ */ |
---|
115 | typedef char char8; |
---|
116 | typedef int8_t s8; |
---|
117 | typedef int16_t s16; |
---|
118 | typedef int32_t s32; |
---|
119 | typedef int64_t s64; |
---|
120 | typedef uint64_t u64; |
---|
121 | typedef int sint32; |
---|
122 | |
---|
123 | typedef intptr_t INTPTR; |
---|
124 | typedef uintptr_t UINTPTR; |
---|
125 | typedef ptrdiff_t PTRDIFF; |
---|
126 | /** @}*/ |
---|
127 | #if !defined(LONG) || !defined(ULONG) |
---|
128 | typedef long LONG; |
---|
129 | typedef unsigned long ULONG; |
---|
130 | #endif |
---|
131 | |
---|
132 | #define ULONG64_HI_MASK 0xFFFFFFFF00000000U |
---|
133 | #define ULONG64_LO_MASK ~ULONG64_HI_MASK |
---|
134 | |
---|
135 | #else |
---|
136 | #include <linux/types.h> |
---|
137 | #endif |
---|
138 | |
---|
139 | /** @{ */ |
---|
140 | /** |
---|
141 | * This data type defines an interrupt handler for a device. |
---|
142 | * The argument points to the instance of the component |
---|
143 | */ |
---|
144 | typedef void (*XInterruptHandler) (void *InstancePtr); |
---|
145 | |
---|
146 | /** |
---|
147 | * This data type defines an exception handler for a processor. |
---|
148 | * The argument points to the instance of the component |
---|
149 | */ |
---|
150 | typedef void (*XExceptionHandler) (void *InstancePtr); |
---|
151 | |
---|
152 | /** |
---|
153 | * @brief Returns 32-63 bits of a number. |
---|
154 | * @param n : Number being accessed. |
---|
155 | * @return Bits 32-63 of number. |
---|
156 | * |
---|
157 | * @note A basic shift-right of a 64- or 32-bit quantity. |
---|
158 | * Use this to suppress the "right shift count >= width of type" |
---|
159 | * warning when that quantity is 32-bits. |
---|
160 | */ |
---|
161 | #if defined (__aarch64__) || defined (__arch64__) |
---|
162 | #define UPPER_32_BITS(n) ((u32)(((n) >> 16) >> 16)) |
---|
163 | #else |
---|
164 | #define UPPER_32_BITS(n) 0U |
---|
165 | #endif |
---|
166 | /** |
---|
167 | * @brief Returns 0-31 bits of a number |
---|
168 | * @param n : Number being accessed. |
---|
169 | * @return Bits 0-31 of number |
---|
170 | */ |
---|
171 | #define LOWER_32_BITS(n) ((u32)(n)) |
---|
172 | |
---|
173 | |
---|
174 | |
---|
175 | |
---|
176 | /************************** Constant Definitions *****************************/ |
---|
177 | |
---|
178 | #ifndef TRUE |
---|
179 | #define TRUE 1U |
---|
180 | #endif |
---|
181 | |
---|
182 | #ifndef FALSE |
---|
183 | #define FALSE 0U |
---|
184 | #endif |
---|
185 | |
---|
186 | #ifndef NULL |
---|
187 | #define NULL 0U |
---|
188 | #endif |
---|
189 | |
---|
190 | #ifdef __cplusplus |
---|
191 | } |
---|
192 | #endif |
---|
193 | |
---|
194 | #endif /* end of protection macro */ |
---|
195 | /** |
---|
196 | * @} End of "addtogroup common_types". |
---|
197 | */ |
---|