summaryrefslogtreecommitdiff
path: root/lcmodule/source/cnh1605551_ldr_utilities/include/r_debug_macro.h
blob: 43f9e88bb69c3fec86449ab732a09c2b82bf9c9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/*******************************************************************************
 * Copyright (C) ST-Ericsson SA 2011
 * License terms: 3-clause BSD license
 ******************************************************************************/
#ifndef _R_DEBUG_MACRO_H_
#define _R_DEBUG_MACRO_H_

/**
 * @addtogroup ldr_utilities
 * @{
 *   @addtogroup debug_macro
 *   @{
 */

/*******************************************************************************
 * Includes
 ******************************************************************************/
#include "t_basicdefinitions.h"
#include "r_debug.h"
#ifdef CFG_ENABLE_PRINT_SERVER
#include "r_debug_subsystem.h"
#endif

#define IRQ_MASK 0x00000080
#define FIQ_MASK 0x00000040
#define INT_MASK (IRQ_MASK | FIQ_MASK)

#if !defined(UART_DEBUG_PORT) && defined(MACH_TYPE_STN8500)
#define UART_DEBUG_PORT 2
#endif

#if !defined(UART_DEBUG_PORT) && defined(MACH_TYPE_DB5700)
#define UART_DEBUG_PORT 0
#endif

/*******************************************************************************
 * Macro for disabling ARM interrupts. Do nothing for Windows and LINT target.
 ******************************************************************************/
#if (defined(WIN32) || defined(CFG_ENABLE_LINT_TARGET_BUILD) || defined(__linux__) || defined(__CYGWIN__))
#define INT_DISABLE()
#else
#ifdef MACH_TYPE_DB5700
#define INT_DISABLE() \
  register int r0; \
  __asm("MRS     r0, CPSR"); \
  __asm("ORR     r0, r0, #INT_MASK"); \
  __asm("MSR     CPSR_c, r0");
#else
#ifdef MACH_TYPE_STN8500
#define INT_DISABLE() \
  __asm__ __volatile__ ("MRS     r0, CPSR \n\t" \
          "ORR     r0, r0, %[mask] \n\t" \
          "MSR     CPSR_c, r0" \
      : :[mask]"r"(INT_MASK): "r0", "cc");
#endif
#endif
#endif

/*******************************************************************************
 * Macros for handling fatal and  non - fatal errors.
 ******************************************************************************/
#ifndef ENABLE_DEBUG
#define VERIFY(Condition,ErrorCode)\
  do \
  { \
    if(!(Condition)) \
    { \
     ReturnValue = (ErrorCode); \
     goto ErrorExit; \
    } \
  } while(0)

#define VERIFY_NO_DEBUG(Condition,ErrorCode) VERIFY(Condition,ErrorCode)

#ifndef CFG_ENABLE_ADBG_LOADER

#define ASSERT(Condition)\
    do \
    { \
      if(!(Condition)) \
      { \
        {\
          INT_DISABLE()\
        }\
        while(1); \
      } \
    } while(0)

#define ASSERT_NO_DEBUG(Condition) ASSERT(Condition)

#else//CFG_ENABLE_ADBG_LOADER

#define ASSERT(Condition)\
    do \
    { \
      if(!(Condition)) \
      { \
      } \
    } while(0)

#define ASSERT_NO_DEBUG(Condition) ASSERT(Condition)

#endif //CFG_ENABLE_ADBG_LOADER

#else //ENABLE_DEBUG

/* VERIFY macro definition
* Verifies the condition and sets the appropriate return value
* if needed before branching the execution to ErrorExit
* This macro prints out debug info string indicating
* verification failure */
#define VERIFY(Condition,ErrorCode)\
  do \
  { \
    if(!(Condition)) \
    { \
      ReturnValue = (ErrorCode); \
      A_(printf("%s (%d): ** Verification failed! Error:(%d) **\n",__FILE__,__LINE__,(ErrorCode));)\
      goto ErrorExit; \
    } \
  } while(0)

/* NO-DEBUG version of the VERIFY macro
 * Verifies the condition and sets the appropriate return value
 * if needed before branching the execution to ErrorExit
 * This macro does not print out debug info string indicating
 * verification failure */
#define VERIFY_NO_DEBUG(Condition,ErrorCode)\
  do \
  { \
    if(!(Condition)) \
    { \
     ReturnValue = (ErrorCode); \
     goto ErrorExit; \
    } \
  } while(0)

#ifndef CFG_ENABLE_ADBG_LOADER

#define ASSERT(Condition)\
    do \
    { \
      if(!(Condition)) \
      { \
        A_(printf("%s (%d): ** Assert failed **\n",__FILE__, __LINE__);)\
        {\
          INT_DISABLE()\
        }\
        while(1); \
      } \
    } while(0)

#define ASSERT_NO_DEBUG(Condition)\
    do \
    { \
      if(!(Condition)) \
      { \
        {\
          INT_DISABLE()\
        }\
        while(1); \
      } \
    } while(0)

#else//CFG_ENABLE_ADBG_LOADER

#define ASSERT(Condition)\
    do \
    { \
      if(!(Condition))\
      { \
        A_(printf("%s (%d): ** Assert failed **\n",__FILE__, __LINE__);)\
      } \
    } while(0)

#define ASSERT_NO_DEBUG(Condition)\
    do \
    { \
    } while(0)

#endif //CFG_ENABLE_ADBG_LOADER

#endif //ENABLE_DEBUG

/** @} */
/** @} */
#endif /*_R_DEBUG_MACRO_H_*/