blob: e32906a63a7f14511cfab2258bfdbae4eff933ee [file] [log] [blame]
Wolfgang Denk4646d2a2006-05-30 15:56:48 +02001/**
2 * @file IxNpeDlMacros_p.h
3 *
4 * @author Intel Corporation
5 * @date 21 January 2002
6 *
7 * @brief This file contains the macros for the IxNpeDl component.
8 *
9 *
10 * @par
11 * IXP400 SW Release version 2.0
12 *
13 * -- Copyright Notice --
14 *
15 * @par
16 * Copyright 2001-2005, Intel Corporation.
17 * All rights reserved.
18 *
19 * @par
20 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions
22 * are met:
23 * 1. Redistributions of source code must retain the above copyright
24 * notice, this list of conditions and the following disclaimer.
25 * 2. Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in the
27 * documentation and/or other materials provided with the distribution.
28 * 3. Neither the name of the Intel Corporation nor the names of its contributors
29 * may be used to endorse or promote products derived from this software
30 * without specific prior written permission.
31 *
32 * @par
33 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
34 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
35 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
36 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
37 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
38 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
39 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
41 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
42 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43 * SUCH DAMAGE.
44 *
45 * @par
46 * -- End of Copyright Notice --
47*/
48
49/**
50 * @defgroup IxNpeDlMacros_p IxNpeDlMacros_p
51 *
52 * @brief Macros for the IxNpeDl component.
53 *
54 * @{
55 */
56
57#ifndef IXNPEDLMACROS_P_H
58#define IXNPEDLMACROS_P_H
59
60
61/*
62 * Put the user defined include files required.
63 */
64#if (CPU != XSCALE)
65/* To support IxNpeDl unit tests... */
66#include <stdio.h>
67#include "test/IxNpeDlTestReg.h"
68
69#else
70#include "IxOsal.h"
71
72#endif
73
74
75/*
76 * Typedefs
77 */
78
79/**
80 * @typedef IxNpeDlTraceTypes
81 * @brief Enumeration defining IxNpeDl trace levels
82 */
83typedef enum
84{
85 IX_NPEDL_TRACE_OFF, /**< no trace */
86 IX_NPEDL_DEBUG, /**< debug */
87 IX_NPEDL_FN_ENTRY_EXIT /**< function entry/exit */
88} IxNpeDlTraceTypes;
89
90
91/*
92 * #defines and macros.
93 */
94
95/* Implementation of the following macros for use with IxNpeDl unit test code */
96#if (CPU != XSCALE)
97
98
99/**
100 * @def IX_NPEDL_TRACE_LEVEL
101 *
102 * @brief IxNpeDl debug trace level
103 */
104#define IX_NPEDL_TRACE_LEVEL IX_NPEDL_FN_ENTRY_EXIT
105
106/**
107 * @def IX_NPEDL_ERROR_REPORT
108 *
109 * @brief Mechanism for reporting IxNpeDl software errors
110 *
111 * @param char* [in] STR - Error string to report
112 *
113 * This macro simply prints the error string passed.
114 * Intended for use with IxNpeDl unit test code.
115 *
116 * @return none
117 */
118#define IX_NPEDL_ERROR_REPORT(STR) printf ("IxNpeDl ERROR: %s\n", (STR));
119
120/**
121 * @def IX_NPEDL_WARNING_REPORT
122 *
123 * @brief Mechanism for reporting IxNpeDl software errors
124 *
125 * @param char* [in] STR - Error string to report
126 *
127 * This macro simply prints the error string passed.
128 * Intended for use with IxNpeDl unit test code.
129 *
130 * @return none
131 */
132#define IX_NPEDL_WARNING_REPORT(STR) printf ("IxNpeDl WARNING: %s\n", (STR));
133
134/**
135 * @def IX_NPEDL_TRACE0
136 *
137 * @brief Mechanism for tracing debug for the IxNpeDl component, for no arguments
138 *
139 * @param unsigned [in] LEVEL - one of IxNpeDlTraceTypes enumerated values
140 * @param char* [in] STR - Trace string
141 *
142 * This macro simply prints the trace string passed, if the level is supported.
143 * Intended for use with IxNpeDl unit test code.
144 *
145 * @return none
146 */
147#define IX_NPEDL_TRACE0(LEVEL, STR) \
148{ \
149 if (LEVEL <= IX_NPEDL_TRACE_LEVEL) \
150 { \
151 printf ("IxNpeDl TRACE: "); \
152 printf ((STR)); \
153 printf ("\n"); \
154 } \
155}
156
157 /**
158 * @def IX_NPEDL_TRACE1
159 *
160 * @brief Mechanism for tracing debug for the IxNpeDl component, with 1 argument
161 *
162 * @param unsigned [in] LEVEL - one of IxNpeDlTraceTypes enumerated values
163 * @param char* [in] STR - Trace string
164 * @param argType [in] ARG1 - Argument to trace
165 *
166 * This macro simply prints the trace string passed, if the level is supported.
167 * Intended for use with IxNpeDl unit test code.
168 *
169 * @return none
170 */
171#define IX_NPEDL_TRACE1(LEVEL, STR, ARG1) \
172{ \
173 if (LEVEL <= IX_NPEDL_TRACE_LEVEL) \
174 { \
175 printf ("IxNpeDl TRACE: "); \
176 printf (STR, ARG1); \
177 printf ("\n"); \
178 } \
179}
180
181/**
182 * @def IX_NPEDL_TRACE2
183 *
184 * @brief Mechanism for tracing debug for the IxNpeDl component, with 2 arguments
185 *
186 * @param unsigned [in] LEVEL - one of IxNpeDlTraceTypes enumerated values
187 * @param char* [in] STR - Trace string
188 * @param argType [in] ARG1 - Argument to trace
189 * @param argType [in] ARG2 - Argument to trace
190 *
191 * This macro simply prints the trace string passed, if the level is supported.
192 * Intended for use with IxNpeDl unit test code.
193 *
194 * @return none
195 */
196#define IX_NPEDL_TRACE2(LEVEL, STR, ARG1, ARG2) \
197{ \
198 if (LEVEL <= IX_NPEDL_TRACE_LEVEL) \
199 { \
200 printf ("IxNpeDl TRACE: "); \
201 printf (STR, ARG1, ARG2); \
202 printf ("\n"); \
203 } \
204}
205
206
207/**
208 * @def IX_NPEDL_REG_WRITE
209 *
210 * @brief Mechanism for writing to a memory-mapped register
211 *
212 * @param UINT32 [in] base - Base memory address for this NPE's registers
213 * @param UINT32 [in] offset - Offset from base memory address
214 * @param UINT32 [in] value - Value to write to register
215 *
216 * This macro calls a function from Unit Test code to write a register. This
217 * allows extra flexibility for unit testing of the IxNpeDl component.
218 *
219 * @return none
220 */
221#define IX_NPEDL_REG_WRITE(base, offset, value) \
222{ \
223 ixNpeDlTestRegWrite (base, offset, value); \
224}
225
226
227/**
228 * @def IX_NPEDL_REG_READ
229 *
230 * @brief Mechanism for reading from a memory-mapped register
231 *
232 * @param UINT32 [in] base - Base memory address for this NPE's registers
233 * @param UINT32 [in] offset - Offset from base memory address
234 * @param UINT32 *[out] value - Value read from register
235 *
236 * This macro calls a function from Unit Test code to read a register. This
237 * allows extra flexibility for unit testing of the IxNpeDl component.
238 *
239 * @return none
240 */
241#define IX_NPEDL_REG_READ(base, offset, value) \
242{ \
243 ixNpeDlTestRegRead (base, offset, value); \
244}
245
246
247/* Implementation of the following macros when integrated with IxOsal */
248#else /* #if (CPU != XSCALE) */
249
250
251/**
252 * @def IX_NPEDL_TRACE_LEVEL
253 *
254 * @brief IxNpeDl debug trace level
255 */
256#define IX_NPEDL_TRACE_LEVEL IX_NPEDL_DEBUG
257
258
259/**
260 * @def IX_NPEDL_ERROR_REPORT
261 *
262 * @brief Mechanism for reporting IxNpeDl software errors
263 *
264 * @param char* [in] STR - Error string to report
265 *
266 * This macro is used to report IxNpeDl software errors.
267 *
268 * @return none
269 */
270#define IX_NPEDL_ERROR_REPORT(STR) \
271 ixOsalLog (IX_OSAL_LOG_LVL_ERROR, IX_OSAL_LOG_DEV_STDERR, STR, 0, 0, 0, 0, 0, 0);
272
273/**
274 * @def IX_NPEDL_WARNING_REPORT
275 *
276 * @brief Mechanism for reporting IxNpeDl software warnings
277 *
278 * @param char* [in] STR - Warning string to report
279 *
280 * This macro is used to report IxNpeDl software warnings.
281 *
282 * @return none
283 */
284#define IX_NPEDL_WARNING_REPORT(STR) \
285 ixOsalLog (IX_OSAL_LOG_LVL_WARNING, IX_OSAL_LOG_DEV_STDOUT, STR, 0, 0, 0, 0, 0, 0);
286
287
288/**
289 * @def IX_NPEDL_TRACE0
290 *
291 * @brief Mechanism for tracing debug for the IxNpeDl component, for no arguments
292 *
293 * @param unsigned [in] LEVEL - one of IxNpeDlTraceTypes enumerated values
294 * @param char* [in] STR - Trace string
295 *
296 * This macro simply prints the trace string passed, if the level is supported.
297 *
298 * @return none
299 */
300#define IX_NPEDL_TRACE0(LEVEL, STR) \
301{ \
302 if (LEVEL <= IX_NPEDL_TRACE_LEVEL) \
303 { \
304 if (LEVEL == IX_NPEDL_FN_ENTRY_EXIT) \
305 { \
306 ixOsalLog (IX_OSAL_LOG_LVL_DEBUG3, IX_OSAL_LOG_DEV_STDOUT, STR, 0, 0, 0, 0, 0, 0); \
307 } \
308 else if (LEVEL == IX_NPEDL_DEBUG) \
309 { \
310 ixOsalLog (IX_OSAL_LOG_LVL_MESSAGE, IX_OSAL_LOG_DEV_STDOUT, STR, 0, 0, 0, 0, 0, 0); \
311 } \
312 } \
313}
314
315/**
316 * @def IX_NPEDL_TRACE1
317 *
318 * @brief Mechanism for tracing debug for the IxNpeDl component, with 1 argument
319 *
320 * @param unsigned [in] LEVEL - one of IxNpeDlTraceTypes enumerated values
321 * @param char* [in] STR - Trace string
322 * @param argType [in] ARG1 - Argument to trace
323 *
324 * This macro simply prints the trace string passed, if the level is supported.
325 *
326 * @return none
327 */
328#define IX_NPEDL_TRACE1(LEVEL, STR, ARG1) \
329{ \
330 if (LEVEL <= IX_NPEDL_TRACE_LEVEL) \
331 { \
332 if (LEVEL == IX_NPEDL_FN_ENTRY_EXIT) \
333 { \
334 ixOsalLog (IX_OSAL_LOG_LVL_DEBUG3, IX_OSAL_LOG_DEV_STDOUT, STR, ARG1, 0, 0, 0, 0, 0); \
335 } \
336 else if (LEVEL == IX_NPEDL_DEBUG) \
337 { \
338 ixOsalLog (IX_OSAL_LOG_LVL_MESSAGE, IX_OSAL_LOG_DEV_STDOUT, STR, ARG1, 0, 0, 0, 0, 0); \
339 } \
340 } \
341}
342
343/**
344 * @def IX_NPEDL_TRACE2
345 *
346 * @brief Mechanism for tracing debug for the IxNpeDl component, with 2 arguments
347 *
348 * @param unsigned [in] LEVEL - one of IxNpeDlTraceTypes enumerated values
349 * @param char* [in] STR - Trace string
350 * @param argType [in] ARG1 - Argument to trace
351 * @param argType [in] ARG2 - Argument to trace
352 *
353 * This macro simply prints the trace string passed, if the level is supported.
354 *
355 * @return none
356 */
357#define IX_NPEDL_TRACE2(LEVEL, STR, ARG1, ARG2) \
358{ \
359 if (LEVEL <= IX_NPEDL_TRACE_LEVEL) \
360 { \
361 if (LEVEL == IX_NPEDL_FN_ENTRY_EXIT) \
362 { \
363 ixOsalLog (IX_OSAL_LOG_LVL_DEBUG3, IX_OSAL_LOG_DEV_STDOUT, STR, ARG1, ARG2, 0, 0, 0, 0); \
364 } \
365 else if (LEVEL == IX_NPEDL_DEBUG) \
366 { \
367 ixOsalLog (IX_OSAL_LOG_LVL_MESSAGE, IX_OSAL_LOG_DEV_STDOUT, STR, ARG1, ARG2, 0, 0, 0, 0); \
368 } \
369 } \
370}
371
372/**
373 * @def IX_NPEDL_REG_WRITE
374 *
375 * @brief Mechanism for writing to a memory-mapped register
376 *
377 * @param UINT32 [in] base - Base memory address for this NPE's registers
378 * @param UINT32 [in] offset - Offset from base memory address
379 * @param UINT32 [in] value - Value to write to register
380 *
381 * This macro forms the address of the register from base address + offset, and
382 * dereferences that address to write the contents of the register.
383 *
384 * @return none
385 */
386#define IX_NPEDL_REG_WRITE(base, offset, value) \
387 IX_OSAL_WRITE_LONG(((base) + (offset)), (value))
388
389
390
391/**
392 * @def IX_NPEDL_REG_READ
393 *
394 * @brief Mechanism for reading from a memory-mapped register
395 *
396 * @param UINT32 [in] base - Base memory address for this NPE's registers
397 * @param UINT32 [in] offset - Offset from base memory address
398 * @param UINT32 *[out] value - Value read from register
399 *
400 * This macro forms the address of the register from base address + offset, and
401 * dereferences that address to read the register contents.
402 *
403 * @return none
404 */
405#define IX_NPEDL_REG_READ(base, offset, value) \
406 *(value) = IX_OSAL_READ_LONG(((base) + (offset)))
407
408#endif /* #if (CPU != XSCALE) */
409
410#endif /* IXNPEDLMACROS_P_H */
411
412/**
413 * @} defgroup IxNpeDlMacros_p
414 */