• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010-2014 NXP Semiconductors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #if !defined(NXPLOG__H_INCLUDED)
18 #define NXPLOG__H_INCLUDED
19 #include <log/log.h>
20 
21 typedef struct nci_log_level {
22   uint8_t global_log_level;
23   uint8_t extns_log_level;
24   uint8_t hal_log_level;
25   uint8_t dnld_log_level;
26   uint8_t tml_log_level;
27   uint8_t ncix_log_level;
28   uint8_t ncir_log_level;
29 } nci_log_level_t;
30 
31 /* global log level Ref */
32 extern nci_log_level_t gLog_level;
33 extern bool nfc_debug_enabled;
34 /* define log module included when compile */
35 #define ENABLE_EXTNS_TRACES TRUE
36 #define ENABLE_HAL_TRACES TRUE
37 #define ENABLE_TML_TRACES TRUE
38 #define ENABLE_FWDNLD_TRACES TRUE
39 #define ENABLE_NCIX_TRACES TRUE
40 #define ENABLE_NCIR_TRACES TRUE
41 
42 #define ENABLE_HCPX_TRACES FALSE
43 #define ENABLE_HCPR_TRACES FALSE
44 
45 /* ####################### Set the log module name in .conf file
46  * ########################## */
47 #define NAME_NXPLOG_EXTNS_LOGLEVEL "NXPLOG_EXTNS_LOGLEVEL"
48 #define NAME_NXPLOG_HAL_LOGLEVEL "NXPLOG_NCIHAL_LOGLEVEL"
49 #define NAME_NXPLOG_NCIX_LOGLEVEL "NXPLOG_NCIX_LOGLEVEL"
50 #define NAME_NXPLOG_NCIR_LOGLEVEL "NXPLOG_NCIR_LOGLEVEL"
51 #define NAME_NXPLOG_FWDNLD_LOGLEVEL "NXPLOG_FWDNLD_LOGLEVEL"
52 #define NAME_NXPLOG_TML_LOGLEVEL "NXPLOG_TML_LOGLEVEL"
53 
54 /* ####################### Set the log module name by Android property
55  * ########################## */
56 #define PROP_NAME_NXPLOG_GLOBAL_LOGLEVEL "nfc.nxp_log_level_global"
57 #define PROP_NAME_NXPLOG_EXTNS_LOGLEVEL "nfc.nxp_log_level_extns"
58 #define PROP_NAME_NXPLOG_HAL_LOGLEVEL "nfc.nxp_log_level_hal"
59 #define PROP_NAME_NXPLOG_NCI_LOGLEVEL "nfc.nxp_log_level_nci"
60 #define PROP_NAME_NXPLOG_FWDNLD_LOGLEVEL "nfc.nxp_log_level_dnld"
61 #define PROP_NAME_NXPLOG_TML_LOGLEVEL "nfc.nxp_log_level_tml"
62 
63 /* ####################### Set the logging level for EVERY COMPONENT here
64  * ######################## :START: */
65 #define NXPLOG_LOG_SILENT_LOGLEVEL 0x00
66 #define NXPLOG_LOG_ERROR_LOGLEVEL 0x01
67 #define NXPLOG_LOG_WARN_LOGLEVEL 0x02
68 #define NXPLOG_LOG_DEBUG_LOGLEVEL 0x03
69 /* ####################### Set the default logging level for EVERY COMPONENT
70  * here ########################## :END: */
71 
72 /* The Default log level for all the modules. */
73 #define NXPLOG_DEFAULT_LOGLEVEL NXPLOG_LOG_ERROR_LOGLEVEL
74 
75 /* ################################################################################################################
76  */
77 /* ############################################### Component Names
78  * ################################################ */
79 /* ################################################################################################################
80  */
81 
82 extern const char* NXPLOG_ITEM_EXTNS;  /* Android logging tag for NxpExtns  */
83 extern const char* NXPLOG_ITEM_NCIHAL; /* Android logging tag for NxpNciHal */
84 extern const char* NXPLOG_ITEM_NCIX;   /* Android logging tag for NxpNciX   */
85 extern const char* NXPLOG_ITEM_NCIR;   /* Android logging tag for NxpNciR   */
86 extern const char* NXPLOG_ITEM_FWDNLD; /* Android logging tag for NxpFwDnld */
87 extern const char* NXPLOG_ITEM_TML;    /* Android logging tag for NxpTml    */
88 
89 #ifdef NXP_HCI_REQ
90 extern const char* NXPLOG_ITEM_HCPX; /* Android logging tag for NxpHcpX   */
91 extern const char* NXPLOG_ITEM_HCPR; /* Android logging tag for NxpHcpR   */
92 #endif                               /*NXP_HCI_REQ*/
93 
94 /* ######################################## Defines used for Logging data
95  * ######################################### */
96 #ifdef NXP_VRBS_REQ
97 #define NXPLOG_FUNC_ENTRY(COMP) \
98   LOG_PRI(ANDROID_LOG_VERBOSE, (COMP), "+:%s", (__func__))
99 #define NXPLOG_FUNC_EXIT(COMP) \
100   LOG_PRI(ANDROID_LOG_VERBOSE, (COMP), "-:%s", (__func__))
101 #endif /*NXP_VRBS_REQ*/
102 
103 /* ################################################################################################################
104  */
105 /* ######################################## Logging APIs of actual modules
106  * ######################################## */
107 /* ################################################################################################################
108  */
109 /* Logging APIs used by NxpExtns module */
110 #if (ENABLE_EXTNS_TRACES == TRUE)
111 #define NXPLOG_EXTNS_D(...)                                       \
112   {                                                               \
113      if ((nfc_debug_enabled) ||                                   \
114       (gLog_level.extns_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL))  \
115       LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_EXTNS, __VA_ARGS__); \
116   }
117 #define NXPLOG_EXTNS_W(...)                                      \
118   {                                                              \
119      if ((nfc_debug_enabled) ||                                  \
120       (gLog_level.extns_log_level >= NXPLOG_LOG_WARN_LOGLEVEL))  \
121       LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_EXTNS, __VA_ARGS__); \
122   }
123 #define NXPLOG_EXTNS_E(...)                                       \
124   {                                                               \
125     if (gLog_level.extns_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL)  \
126       LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_EXTNS, __VA_ARGS__); \
127   }
128 #else
129 #define NXPLOG_EXTNS_D(...)
130 #define NXPLOG_EXTNS_W(...)
131 #define NXPLOG_EXTNS_E(...)
132 #endif /* Logging APIs used by NxpExtns module */
133 
134 /* Logging APIs used by NxpNciHal module */
135 #if (ENABLE_HAL_TRACES == TRUE)
136 #define NXPLOG_NCIHAL_D(...)                                       \
137   {                                                                \
138     if ((nfc_debug_enabled) ||                                     \
139       (gLog_level.hal_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL))     \
140       LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_NCIHAL, __VA_ARGS__); \
141   }
142 #define NXPLOG_NCIHAL_W(...)                                      \
143   {                                                               \
144     if ((nfc_debug_enabled) ||                                    \
145       (gLog_level.hal_log_level >= NXPLOG_LOG_WARN_LOGLEVEL))     \
146       LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_NCIHAL, __VA_ARGS__); \
147   }
148 #define NXPLOG_NCIHAL_E(...)                                       \
149   {                                                                \
150     if (gLog_level.hal_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL)     \
151       LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_NCIHAL, __VA_ARGS__); \
152   }
153 #else
154 #define NXPLOG_NCIHAL_D(...)
155 #define NXPLOG_NCIHAL_W(...)
156 #define NXPLOG_NCIHAL_E(...)
157 #endif /* Logging APIs used by HAL module */
158 
159 /* Logging APIs used by NxpNciX module */
160 #if (ENABLE_NCIX_TRACES == TRUE)
161 #define NXPLOG_NCIX_D(...)                                       \
162   {                                                              \
163     if ((nfc_debug_enabled) ||                                   \
164       (gLog_level.ncix_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL))  \
165       LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_NCIX, __VA_ARGS__); \
166   }
167 #define NXPLOG_NCIX_W(...)                                      \
168   {                                                             \
169      if ((nfc_debug_enabled) ||                                 \
170       (gLog_level.ncix_log_level >= NXPLOG_LOG_WARN_LOGLEVEL))  \
171       LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_NCIX, __VA_ARGS__); \
172   }
173 #define NXPLOG_NCIX_E(...)                                       \
174   {                                                              \
175     if (gLog_level.ncix_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL)  \
176       LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_NCIX, __VA_ARGS__); \
177   }
178 #else
179 #define NXPLOG_NCIX_D(...)
180 #define NXPLOG_NCIX_W(...)
181 #define NXPLOG_NCIX_E(...)
182 #endif /* Logging APIs used by NCIx module */
183 
184 /* Logging APIs used by NxpNciR module */
185 #if (ENABLE_NCIR_TRACES == TRUE)
186 #define NXPLOG_NCIR_D(...)                                       \
187   {                                                              \
188      if ((nfc_debug_enabled) ||                                  \
189       (gLog_level.ncir_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL))  \
190       LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_NCIR, __VA_ARGS__); \
191   }
192 #define NXPLOG_NCIR_W(...)                                      \
193   {                                                             \
194      if ((nfc_debug_enabled) ||                                 \
195       (gLog_level.ncir_log_level >= NXPLOG_LOG_WARN_LOGLEVEL))  \
196       LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_NCIR, __VA_ARGS__); \
197   }
198 #define NXPLOG_NCIR_E(...)                                       \
199   {                                                              \
200     if (gLog_level.ncir_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL)  \
201       LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_NCIR, __VA_ARGS__); \
202   }
203 #else
204 #define NXPLOG_NCIR_D(...)
205 #define NXPLOG_NCIR_W(...)
206 #define NXPLOG_NCIR_E(...)
207 #endif /* Logging APIs used by NCIR module */
208 
209 /* Logging APIs used by NxpFwDnld module */
210 #if (ENABLE_FWDNLD_TRACES == TRUE)
211 #define NXPLOG_FWDNLD_D(...)                                       \
212   {                                                                \
213      if ((nfc_debug_enabled) ||                                    \
214       (gLog_level.dnld_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL))    \
215       LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \
216   }
217 #define NXPLOG_FWDNLD_W(...)                                      \
218   {                                                               \
219      if ((nfc_debug_enabled) ||                                   \
220       (gLog_level.dnld_log_level >= NXPLOG_LOG_WARN_LOGLEVEL))    \
221       LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \
222   }
223 #define NXPLOG_FWDNLD_E(...)                                       \
224   {                                                                \
225     if (gLog_level.dnld_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL)    \
226       LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \
227   }
228 #else
229 #define NXPLOG_FWDNLD_D(...)
230 #define NXPLOG_FWDNLD_W(...)
231 #define NXPLOG_FWDNLD_E(...)
232 #endif /* Logging APIs used by NxpFwDnld module */
233 
234 /* Logging APIs used by NxpTml module */
235 #if (ENABLE_TML_TRACES == TRUE)
236 #define NXPLOG_TML_D(...)                                       \
237   {                                                             \
238      if ((nfc_debug_enabled) ||                                 \
239       (gLog_level.tml_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL))  \
240       LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_TML, __VA_ARGS__); \
241   }
242 #define NXPLOG_TML_W(...)                                      \
243   {                                                            \
244      if ((nfc_debug_enabled) ||                                \
245       (gLog_level.tml_log_level >= NXPLOG_LOG_WARN_LOGLEVEL))  \
246       LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_TML, __VA_ARGS__); \
247   }
248 #define NXPLOG_TML_E(...)                                       \
249   {                                                             \
250     if (gLog_level.tml_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL)  \
251       LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_TML, __VA_ARGS__); \
252   }
253 #else
254 #define NXPLOG_TML_D(...)
255 #define NXPLOG_TML_W(...)
256 #define NXPLOG_TML_E(...)
257 #endif /* Logging APIs used by NxpTml module */
258 
259 #ifdef NXP_HCI_REQ
260 /* Logging APIs used by NxpHcpX module */
261 #if (ENABLE_HCPX_TRACES == TRUE)
262 #define NXPLOG_HCPX_D(...)                                         \
263   {                                                                \
264      if ((nfc_debug_enabled) ||                                    \
265       (gLog_level.dnld_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL))    \
266       LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \
267   }
268 #define NXPLOG_HCPX_W(...)                                        \
269   {                                                               \
270      if ((nfc_debug_enabled) ||                                   \
271       (gLog_level.dnld_log_level >= NXPLOG_LOG_WARN_LOGLEVEL))    \
272       LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \
273   }
274 #define NXPLOG_HCPX_E(...)                                         \
275   {                                                                \
276     if (gLog_level.dnld_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL)    \
277       LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \
278   }
279 #else
280 #define NXPLOG_HCPX_D(...)
281 #define NXPLOG_HCPX_W(...)
282 #define NXPLOG_HCPX_E(...)
283 #endif /* Logging APIs used by NxpHcpX module */
284 
285 /* Logging APIs used by NxpHcpR module */
286 #if (ENABLE_HCPR_TRACES == TRUE)
287 #define NXPLOG_HCPR_D(...)                                         \
288   {                                                                \
289      if ((nfc_debug_enabled) ||                                    \
290       (gLog_level.dnld_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL))    \
291       LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \
292   }
293 #define NXPLOG_HCPR_W(...)                                        \
294   {                                                               \
295      if ((nfc_debug_enabled) ||                                   \
296       (gLog_level.dnld_log_level >= NXPLOG_LOG_WARN_LOGLEVEL))    \
297       LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \
298   }
299 #define NXPLOG_HCPR_E(...)                                         \
300   {                                                                \
301     if (gLog_level.dnld_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL)    \
302       LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \
303   }
304 #else
305 #define NXPLOG_HCPR_D(...)
306 #define NXPLOG_HCPR_W(...)
307 #define NXPLOG_HCPR_E(...)
308 #endif /* Logging APIs used by NxpHcpR module */
309 #endif /* NXP_HCI_REQ */
310 
311 #ifdef NXP_VRBS_REQ
312 #if (ENABLE_EXTNS_TRACES == TRUE)
313 #define NXPLOG_EXTNS_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_EXTNS)
314 #define NXPLOG_EXTNS_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_EXTNS)
315 #else
316 #define NXPLOG_EXTNS_ENTRY()
317 #define NXPLOG_EXTNS_EXIT()
318 #endif
319 
320 #if (ENABLE_HAL_TRACES == TRUE)
321 #define NXPLOG_NCIHAL_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_NCIHAL)
322 #define NXPLOG_NCIHAL_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_NCIHAL)
323 #else
324 #define NXPLOG_NCIHAL_ENTRY()
325 #define NXPLOG_NCIHAL_EXIT()
326 #endif
327 
328 #if (ENABLE_NCIX_TRACES == TRUE)
329 #define NXPLOG_NCIX_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_NCIX)
330 #define NXPLOG_NCIX_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_NCIX)
331 #else
332 #define NXPLOG_NCIX_ENTRY()
333 #define NXPLOG_NCIX_EXIT()
334 #endif
335 
336 #if (ENABLE_NCIR_TRACES == TRUE)
337 #define NXPLOG_NCIR_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_NCIR)
338 #define NXPLOG_NCIR_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_NCIR)
339 #else
340 #define NXPLOG_NCIR_ENTRY()
341 #define NXPLOG_NCIR_EXIT()
342 #endif
343 
344 #ifdef NXP_HCI_REQ
345 
346 #if (ENABLE_HCPX_TRACES == TRUE)
347 #define NXPLOG_HCPX_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_HCPX)
348 #define NXPLOG_HCPX_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_HCPX)
349 #else
350 #define NXPLOG_HCPX_ENTRY()
351 #define NXPLOG_HCPX_EXIT()
352 #endif
353 
354 #if (ENABLE_HCPR_TRACES == TRUE)
355 #define NXPLOG_HCPR_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_HCPR)
356 #define NXPLOG_HCPR_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_HCPR)
357 #else
358 #define NXPLOG_HCPR_ENTRY()
359 #define NXPLOG_HCPR_EXIT()
360 #endif
361 #endif /* NXP_HCI_REQ */
362 
363 #endif /* NXP_VRBS_REQ */
364 
365 void phNxpLog_InitializeLogLevel(void);
366 
367 #endif /* NXPLOG__H_INCLUDED */
368