]> git.sur5r.net Git - u-boot/blob - include/asm-microblaze/arch-microblaze/xbasic_types.h
Merge with pollux.denx.org:/home/git/u-boot/.git
[u-boot] / include / asm-microblaze / arch-microblaze / xbasic_types.h
1 /******************************************************************************
2 *
3 *     Author: Xilinx, Inc.
4 *
5 *
6 *     This program is free software; you can redistribute it and/or modify it
7 *     under the terms of the GNU General Public License as published by the
8 *     Free Software Foundation; either version 2 of the License, or (at your
9 *     option) any later version.
10 *
11 *
12 *     XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A
13 *     COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
14 *     ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR STANDARD,
15 *     XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION IS FREE
16 *     FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE FOR OBTAINING
17 *     ANY THIRD PARTY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.
18 *     XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO
19 *     THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY
20 *     WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM
21 *     CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND
22 *     FITNESS FOR A PARTICULAR PURPOSE.
23 *
24 *
25 *     Xilinx hardware products are not intended for use in life support
26 *     appliances, devices, or systems. Use in such applications is
27 *     expressly prohibited.
28 *
29 *
30 *     (c) Copyright 2002-2003 Xilinx Inc.
31 *     All rights reserved.
32 *
33 *
34 *     You should have received a copy of the GNU General Public License along
35 *     with this program; if not, write to the Free Software Foundation, Inc.,
36 *     675 Mass Ave, Cambridge, MA 02139, USA.
37 *
38 ******************************************************************************/
39 /*****************************************************************************/
40 /**
41 *
42 * @file xbasic_types.h
43 *
44 * This file contains basic types for Xilinx software IP.  These types do not
45 * follow the standard naming convention with respect to using the component
46 * name in front of each name because they are considered to be primitives.
47 *
48 * @note
49 *
50 * This file contains items which are architecture dependent.
51 *
52 * <pre>
53 * MODIFICATION HISTORY:
54 *
55 * Ver    Who    Date    Changes
56 * ----- ---- -------- -----------------------------------------------
57 * 1.00a rmm  12/14/01 First release
58 *       rmm  05/09/03 Added "xassert always" macros to rid ourselves of diab
59 *                     compiler warnings
60 * </pre>
61 *
62 ******************************************************************************/
63
64 #ifndef XBASIC_TYPES_H          /* prevent circular inclusions */
65 #define XBASIC_TYPES_H          /* by using protection macros */
66
67 /***************************** Include Files *********************************/
68
69 /************************** Constant Definitions *****************************/
70
71 #ifndef TRUE
72 #define TRUE 1
73 #endif
74 #ifndef FALSE
75 #define FALSE 0
76 #endif
77
78 #ifndef NULL
79 #define NULL 0
80 #endif
81 /** Null */
82
83 #define XCOMPONENT_IS_READY     0x11111111      /* component has been initialized */
84 #define XCOMPONENT_IS_STARTED   0x22222222      /* component has been started */
85
86 /* the following constants and declarations are for unit test purposes and are
87  * designed to be used in test applications.
88  */
89 #define XTEST_PASSED    0
90 #define XTEST_FAILED    1
91
92 #define XASSERT_NONE     0
93 #define XASSERT_OCCURRED 1
94
95 extern unsigned int XAssertStatus;
96 extern void XAssert(char *, int);
97
98 /**************************** Type Definitions *******************************/
99
100 /** @name Primitive types
101  * These primitive types are created for transportability.
102  * They are dependent upon the target architecture.
103  * @{
104  */
105 #include <linux/types.h>
106
107 typedef struct {
108         u32 Upper;
109         u32 Lower;
110 } Xuint64;
111
112 /* Xilinx's unsigned integer types */
113 typedef u32 Xuint32;
114 typedef u16 Xuint16;
115 typedef u8 Xuint8;
116
117 /* and signed integer types */
118 typedef s32 Xint32;
119 typedef s16 Xint16;
120 typedef s8 Xint8;
121
122 #ifndef NULL
123 #define NULL 0
124 #endif
125
126 typedef unsigned long Xboolean;
127 #define XNULL   NULL
128
129 #define XTRUE   1
130 #define XFALSE  0
131
132 /*@}*/
133
134 /**
135  * This data type defines an interrupt handler for a device.
136  * The argument points to the instance of the component
137  */
138 typedef void (*XInterruptHandler) (void *InstancePtr);
139
140 /**
141  * This data type defines a callback to be invoked when an
142  * assert occurs. The callback is invoked only when asserts are enabled
143  */
144 typedef void (*XAssertCallback) (char *FilenamePtr, int LineNumber);
145
146 /***************** Macros (Inline Functions) Definitions *********************/
147
148 /*****************************************************************************/
149 /**
150 * Return the most significant half of the 64 bit data type.
151 *
152 * @param x is the 64 bit word.
153 *
154 * @return
155 *
156 * The upper 32 bits of the 64 bit word.
157 *
158 * @note
159 *
160 * None.
161 *
162 ******************************************************************************/
163 #define XUINT64_MSW(x) ((x).Upper)
164
165 /*****************************************************************************/
166 /**
167 * Return the least significant half of the 64 bit data type.
168 *
169 * @param x is the 64 bit word.
170 *
171 * @return
172 *
173 * The lower 32 bits of the 64 bit word.
174 *
175 * @note
176 *
177 * None.
178 *
179 ******************************************************************************/
180 #define XUINT64_LSW(x) ((x).Lower)
181
182 #ifndef NDEBUG
183
184 /*****************************************************************************/
185 /**
186 * This assert macro is to be used for functions that do not return anything
187 * (void). This in conjunction with the XWaitInAssert boolean can be used to
188 * accomodate tests so that asserts which fail allow execution to continue.
189 *
190 * @param expression is the expression to evaluate. If it evaluates to false,
191 *        the assert occurs.
192 *
193 * @return
194 *
195 * Returns void unless the XWaitInAssert variable is true, in which case
196 * no return is made and an infinite loop is entered.
197 *
198 * @note
199 *
200 * None.
201 *
202 ******************************************************************************/
203 #define XASSERT_VOID(expression)                        \
204 {                                                       \
205         if (expression) {                               \
206                 XAssertStatus = XASSERT_NONE;           \
207         } else {                                        \
208                 XAssert(__FILE__, __LINE__);            \
209                 XAssertStatus = XASSERT_OCCURRED;       \
210                 return;                                 \
211         }                                               \
212 }
213
214 /*****************************************************************************/
215 /**
216 * This assert macro is to be used for functions that do return a value. This in
217 * conjunction with the XWaitInAssert boolean can be used to accomodate tests so
218 * that asserts which fail allow execution to continue.
219 *
220 * @param expression is the expression to evaluate. If it evaluates to false,
221 *        the assert occurs.
222 *
223 * @return
224 *
225 * Returns 0 unless the XWaitInAssert variable is true, in which case
226 * no return is made and an infinite loop is entered.
227 *
228 * @note
229 *
230 * None.
231 *
232 ******************************************************************************/
233 #define XASSERT_NONVOID(expression)                     \
234 {                                                       \
235         if (expression) {                               \
236                 XAssertStatus = XASSERT_NONE;           \
237         } else {                                        \
238                 XAssert(__FILE__, __LINE__);            \
239                 XAssertStatus = XASSERT_OCCURRED;       \
240                 return 0;                               \
241         }                                               \
242 }
243
244 /*****************************************************************************/
245 /**
246 * Always assert. This assert macro is to be used for functions that do not
247 * return anything (void). Use for instances where an assert should always
248 * occur.
249 *
250 * @return
251 *
252 * Returns void unless the XWaitInAssert variable is true, in which case
253 * no return is made and an infinite loop is entered.
254 *
255 * @note
256 *
257 * None.
258 *
259 ******************************************************************************/
260 #define XASSERT_VOID_ALWAYS()                           \
261 {                                                       \
262         XAssert(__FILE__, __LINE__);                    \
263         XAssertStatus = XASSERT_OCCURRED;               \
264         return;                                         \
265 }
266
267 /*****************************************************************************/
268 /**
269 * Always assert. This assert macro is to be used for functions that do return
270 * a value. Use for instances where an assert should always occur.
271 *
272 * @return
273 *
274 * Returns void unless the XWaitInAssert variable is true, in which case
275 * no return is made and an infinite loop is entered.
276 *
277 * @note
278 *
279 * None.
280 *
281 ******************************************************************************/
282 #define XASSERT_NONVOID_ALWAYS()                        \
283 {                                                       \
284         XAssert(__FILE__, __LINE__);                    \
285         XAssertStatus = XASSERT_OCCURRED;               \
286         return 0;                                       \
287 }
288
289 #else
290
291 #define XASSERT_VOID(expression)
292 #define XASSERT_VOID_ALWAYS()
293 #define XASSERT_NONVOID(expression)
294 #define XASSERT_NONVOID_ALWAYS()
295 #endif
296
297 /************************** Function Prototypes ******************************/
298
299 void XAssertSetCallback(XAssertCallback Routine);
300
301 #endif  /* end of protection macro */