• 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 
20 #include <cutils/log.h>
21 
22 typedef struct nci_log_level
23 {
24     uint8_t global_log_level;
25     uint8_t extns_log_level;
26     uint8_t hal_log_level;
27     uint8_t dnld_log_level;
28     uint8_t tml_log_level;
29     uint8_t ncix_log_level;
30     uint8_t ncir_log_level;
31 } nci_log_level_t;
32 
33 /* global log level Ref */
34 extern nci_log_level_t gLog_level;
35 
36 /* define log module included when compile */
37 #define ENABLE_EXTNS_TRACES   TRUE
38 #define ENABLE_HAL_TRACES     TRUE
39 #define ENABLE_TML_TRACES     TRUE
40 #define ENABLE_FWDNLD_TRACES  TRUE
41 #define ENABLE_NCIX_TRACES    TRUE
42 #define ENABLE_NCIR_TRACES    TRUE
43 
44 #define ENABLE_HCPX_TRACES    FALSE
45 #define ENABLE_HCPR_TRACES    FALSE
46 
47 /* ####################### Set the log module name in .conf file ########################## */
48 #define NAME_NXPLOG_EXTNS_LOGLEVEL          "NXPLOG_EXTNS_LOGLEVEL"
49 #define NAME_NXPLOG_HAL_LOGLEVEL            "NXPLOG_NCIHAL_LOGLEVEL"
50 #define NAME_NXPLOG_NCIX_LOGLEVEL           "NXPLOG_NCIX_LOGLEVEL"
51 #define NAME_NXPLOG_NCIR_LOGLEVEL           "NXPLOG_NCIR_LOGLEVEL"
52 #define NAME_NXPLOG_FWDNLD_LOGLEVEL         "NXPLOG_FWDNLD_LOGLEVEL"
53 #define NAME_NXPLOG_TML_LOGLEVEL            "NXPLOG_TML_LOGLEVEL"
54 
55 /* ####################### Set the log module name by Android property ########################## */
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 ######################## :START: */
64 #define NXPLOG_LOG_SILENT_LOGLEVEL             0x00
65 #define NXPLOG_LOG_ERROR_LOGLEVEL              0x01
66 #define NXPLOG_LOG_WARN_LOGLEVEL               0x02
67 #define NXPLOG_LOG_DEBUG_LOGLEVEL              0x03
68 /* ####################### Set the default logging level for EVERY COMPONENT here ########################## :END: */
69 
70 
71 /* The Default log level for all the modules. */
72 #define NXPLOG_DEFAULT_LOGLEVEL                NXPLOG_LOG_ERROR_LOGLEVEL
73 
74 
75 /* ################################################################################################################ */
76 /* ############################################### Component Names ################################################ */
77 /* ################################################################################################################ */
78 
79 extern const char * NXPLOG_ITEM_EXTNS;   /* Android logging tag for NxpExtns  */
80 extern const char * NXPLOG_ITEM_NCIHAL;  /* Android logging tag for NxpNciHal */
81 extern const char * NXPLOG_ITEM_NCIX;    /* Android logging tag for NxpNciX   */
82 extern const char * NXPLOG_ITEM_NCIR;    /* Android logging tag for NxpNciR   */
83 extern const char * NXPLOG_ITEM_FWDNLD;  /* Android logging tag for NxpFwDnld */
84 extern const char * NXPLOG_ITEM_TML;     /* Android logging tag for NxpTml    */
85 
86 #ifdef NXP_HCI_REQ
87 extern const char * NXPLOG_ITEM_HCPX;    /* Android logging tag for NxpHcpX   */
88 extern const char * NXPLOG_ITEM_HCPR;    /* Android logging tag for NxpHcpR   */
89 #endif /*NXP_HCI_REQ*/
90 
91 /* ######################################## Defines used for Logging data ######################################### */
92 #ifdef NXP_VRBS_REQ
93 #define NXPLOG_FUNC_ENTRY(COMP) \
94     LOG_PRI(ANDROID_LOG_VERBOSE,(COMP),"+:%s",(__FUNCTION__))
95 #define NXPLOG_FUNC_EXIT(COMP) \
96     LOG_PRI(ANDROID_LOG_VERBOSE,(COMP),"-:%s",(__FUNCTION__))
97 #endif /*NXP_VRBS_REQ*/
98 
99 /* ################################################################################################################ */
100 /* ######################################## Logging APIs of actual modules ######################################## */
101 /* ################################################################################################################ */
102 /* Logging APIs used by NxpExtns module */
103 #if (ENABLE_EXTNS_TRACES == TRUE )
104 #    define NXPLOG_EXTNS_D(...)  {if(gLog_level.extns_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL) LOG_PRI(ANDROID_LOG_DEBUG,NXPLOG_ITEM_EXTNS,__VA_ARGS__);}
105 #    define NXPLOG_EXTNS_W(...)  {if(gLog_level.extns_log_level >= NXPLOG_LOG_WARN_LOGLEVEL) LOG_PRI(ANDROID_LOG_WARN,NXPLOG_ITEM_EXTNS,__VA_ARGS__);}
106 #    define NXPLOG_EXTNS_E(...)  {if(gLog_level.extns_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) LOG_PRI(ANDROID_LOG_ERROR,NXPLOG_ITEM_EXTNS,__VA_ARGS__);}
107 #else
108 #    define NXPLOG_EXTNS_D(...)
109 #    define NXPLOG_EXTNS_W(...)
110 #    define NXPLOG_EXTNS_E(...)
111 #endif /* Logging APIs used by NxpExtns module */
112 
113 /* Logging APIs used by NxpNciHal module */
114 #if (ENABLE_HAL_TRACES == TRUE )
115 #    define NXPLOG_NCIHAL_D(...)  {if(gLog_level.hal_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL) LOG_PRI(ANDROID_LOG_DEBUG,NXPLOG_ITEM_NCIHAL,__VA_ARGS__);}
116 #    define NXPLOG_NCIHAL_W(...)  {if(gLog_level.hal_log_level >= NXPLOG_LOG_WARN_LOGLEVEL) LOG_PRI(ANDROID_LOG_WARN,NXPLOG_ITEM_NCIHAL,__VA_ARGS__);}
117 #    define NXPLOG_NCIHAL_E(...)  {if(gLog_level.hal_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) LOG_PRI(ANDROID_LOG_ERROR,NXPLOG_ITEM_NCIHAL,__VA_ARGS__);}
118 #else
119 #    define NXPLOG_NCIHAL_D(...)
120 #    define NXPLOG_NCIHAL_W(...)
121 #    define NXPLOG_NCIHAL_E(...)
122 #endif /* Logging APIs used by HAL module */
123 
124 /* Logging APIs used by NxpNciX module */
125 #if (ENABLE_NCIX_TRACES == TRUE )
126 #    define NXPLOG_NCIX_D(...)  {if(gLog_level.ncix_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL) LOG_PRI(ANDROID_LOG_DEBUG,NXPLOG_ITEM_NCIX,__VA_ARGS__);}
127 #    define NXPLOG_NCIX_W(...)  {if(gLog_level.ncix_log_level >= NXPLOG_LOG_WARN_LOGLEVEL) LOG_PRI(ANDROID_LOG_WARN,NXPLOG_ITEM_NCIX,__VA_ARGS__);}
128 #    define NXPLOG_NCIX_E(...)  {if(gLog_level.ncix_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) LOG_PRI(ANDROID_LOG_ERROR,NXPLOG_ITEM_NCIX,__VA_ARGS__);}
129 #else
130 #    define NXPLOG_NCIX_D(...)
131 #    define NXPLOG_NCIX_W(...)
132 #    define NXPLOG_NCIX_E(...)
133 #endif /* Logging APIs used by NCIx module */
134 
135 /* Logging APIs used by NxpNciR module */
136 #if (ENABLE_NCIR_TRACES == TRUE )
137 #    define NXPLOG_NCIR_D(...)  {if(gLog_level.ncir_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL) LOG_PRI(ANDROID_LOG_DEBUG,NXPLOG_ITEM_NCIR,__VA_ARGS__);}
138 #    define NXPLOG_NCIR_W(...)  {if(gLog_level.ncir_log_level >= NXPLOG_LOG_WARN_LOGLEVEL) LOG_PRI(ANDROID_LOG_WARN,NXPLOG_ITEM_NCIR,__VA_ARGS__);}
139 #    define NXPLOG_NCIR_E(...)  {if(gLog_level.ncir_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) LOG_PRI(ANDROID_LOG_ERROR,NXPLOG_ITEM_NCIR,__VA_ARGS__);}
140 #else
141 #    define NXPLOG_NCIR_D(...)
142 #    define NXPLOG_NCIR_W(...)
143 #    define NXPLOG_NCIR_E(...)
144 #endif /* Logging APIs used by NCIR module */
145 
146 /* Logging APIs used by NxpFwDnld module */
147 #if (ENABLE_FWDNLD_TRACES == TRUE )
148 #    define NXPLOG_FWDNLD_D(...)  {if(gLog_level.dnld_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL) LOG_PRI(ANDROID_LOG_DEBUG,NXPLOG_ITEM_FWDNLD,__VA_ARGS__);}
149 #    define NXPLOG_FWDNLD_W(...)  {if(gLog_level.dnld_log_level >= NXPLOG_LOG_WARN_LOGLEVEL) LOG_PRI(ANDROID_LOG_WARN,NXPLOG_ITEM_FWDNLD,__VA_ARGS__);}
150 #    define NXPLOG_FWDNLD_E(...)  {if(gLog_level.dnld_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) LOG_PRI(ANDROID_LOG_ERROR,NXPLOG_ITEM_FWDNLD,__VA_ARGS__);}
151 #else
152 #    define NXPLOG_FWDNLD_D(...)
153 #    define NXPLOG_FWDNLD_W(...)
154 #    define NXPLOG_FWDNLD_E(...)
155 #endif /* Logging APIs used by NxpFwDnld module */
156 
157 /* Logging APIs used by NxpTml module */
158 #if (ENABLE_TML_TRACES == TRUE )
159 #    define NXPLOG_TML_D(...)  {if(gLog_level.tml_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL) LOG_PRI(ANDROID_LOG_DEBUG,NXPLOG_ITEM_TML,__VA_ARGS__);}
160 #    define NXPLOG_TML_W(...)  {if(gLog_level.tml_log_level >= NXPLOG_LOG_WARN_LOGLEVEL) LOG_PRI(ANDROID_LOG_WARN,NXPLOG_ITEM_TML,__VA_ARGS__);}
161 #    define NXPLOG_TML_E(...)  {if(gLog_level.tml_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) LOG_PRI(ANDROID_LOG_ERROR,NXPLOG_ITEM_TML,__VA_ARGS__);}
162 #else
163 #    define NXPLOG_TML_D(...)
164 #    define NXPLOG_TML_W(...)
165 #    define NXPLOG_TML_E(...)
166 #endif /* Logging APIs used by NxpTml module */
167 
168 #ifdef NXP_HCI_REQ
169 /* Logging APIs used by NxpHcpX module */
170 #if (ENABLE_HCPX_TRACES == TRUE )
171 #    define NXPLOG_HCPX_D(...)  {if(gLog_level.dnld_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL) LOG_PRI(ANDROID_LOG_DEBUG,NXPLOG_ITEM_FWDNLD,__VA_ARGS__);}
172 #    define NXPLOG_HCPX_W(...)  {if(gLog_level.dnld_log_level >= NXPLOG_LOG_WARN_LOGLEVEL) LOG_PRI(ANDROID_LOG_WARN,NXPLOG_ITEM_FWDNLD,__VA_ARGS__);}
173 #    define NXPLOG_HCPX_E(...)  {if(gLog_level.dnld_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) LOG_PRI(ANDROID_LOG_ERROR,NXPLOG_ITEM_FWDNLD,__VA_ARGS__);}
174 #else
175 #    define NXPLOG_HCPX_D(...)
176 #    define NXPLOG_HCPX_W(...)
177 #    define NXPLOG_HCPX_E(...)
178 #endif /* Logging APIs used by NxpHcpX module */
179 
180 /* Logging APIs used by NxpHcpR module */
181 #if (ENABLE_HCPR_TRACES == TRUE )
182 #    define NXPLOG_HCPR_D(...)  {if(gLog_level.dnld_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL) LOG_PRI(ANDROID_LOG_DEBUG,NXPLOG_ITEM_FWDNLD,__VA_ARGS__);}
183 #    define NXPLOG_HCPR_W(...)  {if(gLog_level.dnld_log_level >= NXPLOG_LOG_WARN_LOGLEVEL) LOG_PRI(ANDROID_LOG_WARN,NXPLOG_ITEM_FWDNLD,__VA_ARGS__);}
184 #    define NXPLOG_HCPR_E(...)  {if(gLog_level.dnld_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) LOG_PRI(ANDROID_LOG_ERROR,NXPLOG_ITEM_FWDNLD,__VA_ARGS__);}
185 #else
186 #    define NXPLOG_HCPR_D(...)
187 #    define NXPLOG_HCPR_W(...)
188 #    define NXPLOG_HCPR_E(...)
189 #endif /* Logging APIs used by NxpHcpR module */
190 #endif /* NXP_HCI_REQ */
191 
192 #ifdef NXP_VRBS_REQ
193 #if (ENABLE_EXTNS_TRACES == TRUE )
194 #    define NXPLOG_EXTNS_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_EXTNS)
195 #    define NXPLOG_EXTNS_EXIT()  NXPLOG_FUNC_EXIT(NXPLOG_ITEM_EXTNS)
196 #else
197 #    define NXPLOG_EXTNS_ENTRY()
198 #    define NXPLOG_EXTNS_EXIT()
199 #endif
200 
201 #if (ENABLE_HAL_TRACES == TRUE )
202 #    define NXPLOG_NCIHAL_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_NCIHAL)
203 #    define NXPLOG_NCIHAL_EXIT()  NXPLOG_FUNC_EXIT(NXPLOG_ITEM_NCIHAL)
204 #else
205 #    define NXPLOG_NCIHAL_ENTRY()
206 #    define NXPLOG_NCIHAL_EXIT()
207 #endif
208 
209 #if (ENABLE_NCIX_TRACES == TRUE )
210 #    define NXPLOG_NCIX_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_NCIX)
211 #    define NXPLOG_NCIX_EXIT()  NXPLOG_FUNC_EXIT(NXPLOG_ITEM_NCIX)
212 #else
213 #    define NXPLOG_NCIX_ENTRY()
214 #    define NXPLOG_NCIX_EXIT()
215 #endif
216 
217 #if (ENABLE_NCIR_TRACES == TRUE )
218 #    define NXPLOG_NCIR_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_NCIR)
219 #    define NXPLOG_NCIR_EXIT()  NXPLOG_FUNC_EXIT(NXPLOG_ITEM_NCIR)
220 #else
221 #    define NXPLOG_NCIR_ENTRY()
222 #    define NXPLOG_NCIR_EXIT()
223 #endif
224 
225 #ifdef NXP_HCI_REQ
226 
227 #if (ENABLE_HCPX_TRACES == TRUE )
228 #    define NXPLOG_HCPX_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_HCPX)
229 #    define NXPLOG_HCPX_EXIT()  NXPLOG_FUNC_EXIT(NXPLOG_ITEM_HCPX)
230 #else
231 #    define NXPLOG_HCPX_ENTRY()
232 #    define NXPLOG_HCPX_EXIT()
233 #endif
234 
235 #if (ENABLE_HCPR_TRACES == TRUE )
236 #    define NXPLOG_HCPR_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_HCPR)
237 #    define NXPLOG_HCPR_EXIT()  NXPLOG_FUNC_EXIT(NXPLOG_ITEM_HCPR)
238 #else
239 #    define NXPLOG_HCPR_ENTRY()
240 #    define NXPLOG_HCPR_EXIT()
241 #endif
242 #endif /* NXP_HCI_REQ */
243 
244 #endif /* NXP_VRBS_REQ */
245 
246 void phNxpLog_InitializeLogLevel(void);
247 
248 #endif /* NXPLOG__H_INCLUDED */
249