1/*******************************************************************************
2*Copyright (c) 2014 PMC-Sierra, Inc.  All rights reserved.
3*
4*Redistribution and use in source and binary forms, with or without modification, are permitted provided
5*that the following conditions are met:
6*1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
7*following disclaimer.
8*2. Redistributions in binary form must reproduce the above copyright notice,
9*this list of conditions and the following disclaimer in the documentation and/or other materials provided
10*with the distribution.
11*
12*THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
13*WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
15*FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16*NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
17*BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19*SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
20*
21* $FreeBSD$
22*
23*******************************************************************************/
24/***************************************************************************
25
26Version Control Information:
27
28$RCSfile: osdebug.h,v $
29$Revision: 114125 $
30
31Note:
32***************************************************************************/
33
34#ifndef __OSDEBUG_H__
35#define __OSDEBUG_H__
36
37#ifdef AGTIAPI_KDB_ENABLE
38#include <linux/kdb.h>
39#endif
40
41/***************************************************************************
42OS_ASSERT : This macro is used when an internal error is detected.
43***************************************************************************/
44#ifdef  AGTIAPI_KDB_ENABLE
45#define OS_ASSERT(expr, message)                                  \
46do {                                                              \
47          if (!(expr))                                            \
48          {                                                       \
49            printf("ASSERT: %s", message);                        \
50            printf(" - file %s, line %d\n", __FILE__, __LINE__);  \
51            BUG_ON(1);                                            \
52            KDB_ENTER();                                          \
53          }                                                       \
54} while (0)
55#else
56#define OS_ASSERT(expr, message)                                  \
57do {                                                              \
58          if (!(expr))                                            \
59          {                                                       \
60            printf("ASSERT: %s", message);                        \
61            printf(" - file %s, line %d\n", __FILE__, __LINE__);  \
62          }                                                       \
63} while (0)
64#endif
65
66#define AG_ERROR_MSG(mask, val, format) \
67do {                                    \
68          if (mask)                     \
69          {                             \
70            if (mask >= val)            \
71              printf format;            \
72          }                             \
73          else                          \
74            printf format;              \
75} while (0)
76
77#ifdef  TD_DEBUG_ENABLE
78#define TIDEBUG_MSG(mask, val, format)  \
79do {                                    \
80          if (mask)                     \
81          {                             \
82            if (!val)                   \
83              printf format ;           \
84            else                        \
85              if (!(mask & 0x80000000)) \
86              {                         \
87                if (mask >= val)        \
88                  printf format ;       \
89              }                         \
90              else                      \
91              {                         \
92                if (mask & val)         \
93                  printf format ;       \
94              }                         \
95          }                             \
96} while (0)
97
98#define TIDEBUG_MSG0(format)            \
99do {                                    \
100              printf format ;           \
101} while (0)
102#else
103#define TIDEBUG_MSG(mask, val, format)
104#define TIDEBUG_MSG0(format)
105#endif
106
107/***************************************************************************
108FC debug - The following is used for FC specific debug.
109**************************************************************************/
110#ifdef AG_PROTOCOL_FC
111#ifndef fcEnableTraceFunctions
112#define fcEnableTraceFunctions 1
113#endif
114#else
115#ifndef fcEnableTraceFunctions
116#define fcEnableTraceFunctions 0
117#endif
118
119#endif /* AG_PROTOCOL_FC */
120
121#endif /* #ifndef __OSDEBUG_H__ */
122
123