1 /*
2  * Copyright (C) 2010-2020 Xilinx, Inc.
3  * Copyright (c) 2020-2021, WangHuachen
4  * All rights reserved.
5  * SPDX-License-Identifier: MIT
6  *
7  * Change Logs:
8  * Date           Author       Notes
9  * 2020-11-30     WangHuachen  the first version
10  */
11 #ifndef XIL_TYPES_H    /* prevent circular inclusions */
12 #define XIL_TYPES_H    /* by using protection macros */
13 
14 #include <rtdef.h>
15 #include <stdint.h>
16 #include <stddef.h>
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 /************************** Constant Definitions *****************************/
23 
24 #ifndef TRUE
25 #  define TRUE        1U
26 #endif
27 
28 #ifndef FALSE
29 #  define FALSE        0U
30 #endif
31 
32 #ifndef NULL
33 #define NULL        0U
34 #endif
35 
36 #define XIL_COMPONENT_IS_READY     0x11111111U  /**< In device drivers, This macro will be
37                                                  assigend to "IsReady" member of driver
38                                                  instance to indicate that driver
39                                                  instance is initialized and ready to use. */
40 #define XIL_COMPONENT_IS_STARTED   0x22222222U  /**< In device drivers, This macro will be assigend to
41                                                  "IsStarted" member of driver instance
42                                                  to indicate that driver instance is
43                                                  started and it can be enabled. */
44 
45 typedef rt_uint8_t u8;
46 typedef rt_uint16_t u16;
47 typedef rt_uint32_t u32;
48 
49 typedef char char8;
50 typedef rt_int8_t s8;
51 typedef rt_int16_t s16;
52 typedef rt_int32_t s32;
53 typedef rt_int64_t s64;
54 typedef rt_uint64_t u64;
55 typedef int sint32;
56 
57 typedef intptr_t INTPTR;
58 typedef uintptr_t UINTPTR;
59 typedef ptrdiff_t PTRDIFF;
60 
61 
62 #if !defined(LONG) || !defined(ULONG)
63 typedef long LONG;
64 typedef unsigned long ULONG;
65 #endif
66 
67 #define ULONG64_HI_MASK    0xFFFFFFFF00000000U
68 #define ULONG64_LO_MASK    ~ULONG64_HI_MASK
69 
70 /** @{ */
71 /**
72  * This data type defines an interrupt handler for a device.
73  * The argument points to the instance of the component
74  */
75 typedef void (*XInterruptHandler) (void *InstancePtr);
76 
77 /**
78  * This data type defines an exception handler for a processor.
79  * The argument points to the instance of the component
80  */
81 typedef void (*XExceptionHandler) (void *InstancePtr);
82 
83 /**
84  * @brief  Returns 32-63 bits of a number.
85  * @param  n : Number being accessed.
86  * @return Bits 32-63 of number.
87  *
88  * @note    A basic shift-right of a 64- or 32-bit quantity.
89  *          Use this to suppress the "right shift count >= width of type"
90  *          warning when that quantity is 32-bits.
91  */
92 #if defined (__aarch64__) || defined (__arch64__)
93 #define UPPER_32_BITS(n) ((u32)(((n) >> 16) >> 16))
94 #else
95 #define UPPER_32_BITS(n) 0U
96 #endif
97 /**
98  * @brief  Returns 0-31 bits of a number
99  * @param  n : Number being accessed.
100  * @return Bits 0-31 of number
101  */
102 #define LOWER_32_BITS(n) ((u32)(n))
103 
104 
105 
106 
107 /************************** Constant Definitions *****************************/
108 
109 #ifndef TRUE
110 #define TRUE        1U
111 #endif
112 
113 #ifndef FALSE
114 #define FALSE        0U
115 #endif
116 
117 #ifndef NULL
118 #define NULL        0U
119 #endif
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
125 
126 #ifdef __cplusplus
127 }
128 #endif
129 
130 #endif    /* end of protection macro */
131 /**
132 * @} End of "addtogroup common_types".
133 */
134