]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/xilinx/common/xbasic_types.c
patman: Allow use outside of u-boot tree
[karo-tx-uboot.git] / board / xilinx / common / xbasic_types.c
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-2004 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.c
43 *
44 * This file contains basic functions for Xilinx software IP.
45 *
46 * <pre>
47 * MODIFICATION HISTORY:
48 *
49 * Ver   Who    Date   Changes
50 * ----- ---- -------- -------------------------------------------------------
51 * 1.00a rpm  11/07/03 Added XNullHandler function as a stub interrupt handler
52 * </pre>
53 *
54 ******************************************************************************/
55
56 /***************************** Include Files *********************************/
57
58 #include "xbasic_types.h"
59
60 /************************** Constant Definitions *****************************/
61
62 /**************************** Type Definitions *******************************/
63
64 /***************** Macros (Inline Functions) Definitions *********************/
65
66 /************************** Variable Definitions *****************************/
67
68 /**
69  * This variable allows testing to be done easier with asserts. An assert
70  * sets this variable such that a driver can evaluate this variable
71  * to determine if an assert occurred.
72  */
73 unsigned int XAssertStatus;
74
75 /**
76  * This variable allows the assert functionality to be changed for testing
77  * such that it does not wait infinitely. Use the debugger to disable the
78  * waiting during testing of asserts.
79  */
80 u32 XWaitInAssert = TRUE;
81
82 /* The callback function to be invoked when an assert is taken */
83 static XAssertCallback XAssertCallbackRoutine = (XAssertCallback) NULL;
84
85 /************************** Function Prototypes ******************************/
86
87 /*****************************************************************************/
88 /**
89 *
90 * Implements assert. Currently, it calls a user-defined callback function
91 * if one has been set.  Then, it potentially enters an infinite loop depending
92 * on the value of the XWaitInAssert variable.
93 *
94 * @param    File is the name of the filename of the source
95 * @param    Line is the linenumber within File
96 *
97 * @return
98 *
99 * None.
100 *
101 * @note
102 *
103 * None.
104 *
105 ******************************************************************************/
106 void
107 XAssert(char *File, int Line)
108 {
109         /* if the callback has been set then invoke it */
110         if (XAssertCallbackRoutine != NULL) {
111                 (*XAssertCallbackRoutine) (File, Line);
112         }
113
114         /* if specified, wait indefinitely such that the assert will show up
115          * in testing
116          */
117         while (XWaitInAssert) {
118         }
119 }
120
121 /*****************************************************************************/
122 /**
123 *
124 * Sets up a callback function to be invoked when an assert occurs. If there
125 * was already a callback installed, then it is replaced.
126 *
127 * @param    Routine is the callback to be invoked when an assert is taken
128 *
129 * @return
130 *
131 * None.
132 *
133 * @note
134 *
135 * This function has no effect if NDEBUG is set
136 *
137 ******************************************************************************/
138 void
139 XAssertSetCallback(XAssertCallback Routine)
140 {
141         XAssertCallbackRoutine = Routine;
142 }
143
144 /*****************************************************************************/
145 /**
146 *
147 * Null handler function. This follows the XInterruptHandler signature for
148 * interrupt handlers. It can be used to assign a null handler (a stub) to an
149 * interrupt controller vector table.
150 *
151 * @param    NullParameter is an arbitrary void pointer and not used.
152 *
153 * @return
154 *
155 * None.
156 *
157 * @note
158 *
159 * None.
160 *
161 ******************************************************************************/
162 void
163 XNullHandler(void *NullParameter)
164 {
165 }