Root/drivers/staging/csr/csr_log.h

1#ifndef CSR_LOG_H__
2#define CSR_LOG_H__
3/*****************************************************************************
4
5            (c) Cambridge Silicon Radio Limited 2010
6            All rights reserved and confidential information of CSR
7
8            Refer to LICENSE.txt included with this source for details
9            on the license terms.
10
11*****************************************************************************/
12
13#include "csr_sched.h"
14#include "csr_panic.h"
15#include "csr_prim_defs.h"
16#include "csr_msgconv.h"
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22/*
23 * Log filtering
24 */
25
26/*----------------------------------------------------*/
27/* Filtering on environment specific log levels */
28/*----------------------------------------------------*/
29typedef u32 CsrLogLevelEnvironment;
30#define CSR_LOG_LEVEL_ENVIRONMENT_OFF ((CsrLogLevelEnvironment) 0x00000000) /* No environment data/events are logged */
31#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_ACL ((CsrLogLevelEnvironment) 0x00000001) /* BlueCore Channel Interface HCI Acl data are logged */
32#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_HCI ((CsrLogLevelEnvironment) 0x00000002) /* BlueCore Channel Interface HCI Cmd/Evt data are logged */
33#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_SCO ((CsrLogLevelEnvironment) 0x00000004) /* BlueCore Channel Interface HCI Sco data are logged */
34#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_VENDOR ((CsrLogLevelEnvironment) 0x00000008) /* BlueCore Channel Interface HCI Vendor specific data are logged (This includes BCCMD, HQ, VM etc) */
35#define CSR_LOG_LEVEL_ENVIRONMENT_TRANSPORTS ((CsrLogLevelEnvironment) 0x00000010) /* Transport protocol data is logged (This includes transport protocols like BCSP, H4 etc.) */
36#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_REG ((CsrLogLevelEnvironment) 0x00000020) /* Background Interrupt registration events are logged */
37#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_UNREG ((CsrLogLevelEnvironment) 0x00000040) /* Background Interrupt unregistration events are logged */
38#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_SET ((CsrLogLevelEnvironment) 0x00000080) /* Background Interrupt set events are logged */
39#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_START ((CsrLogLevelEnvironment) 0x00000100) /* Background Interrupt start events are logged */
40#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_DONE ((CsrLogLevelEnvironment) 0x00000200) /* Background Interrupt done events are logged */
41#define CSR_LOG_LEVEL_ENVIRONMENT_PROTO ((CsrLogLevelEnvironment) 0x00000400) /* Transport protocol events are logged */
42#define CSR_LOG_LEVEL_ENVIRONMENT_PROTO_LOC ((CsrLogLevelEnvironment) 0x00000800) /* The Location where the transport protocol event occured are logged NB: This is a supplement to CSR_LOG_LEVEL_ENVIRONMENT_PROTO, it has no effect without it */
43/* The bit masks between here are reserved for future usage */
44#define CSR_LOG_LEVEL_ENVIRONMENT_ALL ((CsrLogLevelEnvironment) 0xFFFFFFFF) /* All possible environment data/events are logged WARNING: By using this define the application also accepts future possible environment data/events in the logs */
45
46/*----------------------------------------------------*/
47/* Filtering on task specific log levels */
48/*----------------------------------------------------*/
49typedef u32 CsrLogLevelTask;
50#define CSR_LOG_LEVEL_TASK_OFF ((CsrLogLevelTask) 0x00000000) /* No events are logged for this task */
51#define CSR_LOG_LEVEL_TASK_TEXT ((CsrLogLevelTask) 0x00000001) /* Text strings printed by a task are logged NB: This bit does not affect the CSR_LOG_TEXT_LEVEL interface. This has to be configured separately */
52#define CSR_LOG_LEVEL_TASK_TEXT_LOC ((CsrLogLevelTask) 0x00000002) /* The locaction where the text string call occured are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_TEXT, it has no effect without it */
53#define CSR_LOG_LEVEL_TASK_STATE ((CsrLogLevelTask) 0x00000004) /* FSM state transitions in a task are logged */
54#define CSR_LOG_LEVEL_TASK_STATE_NAME ((CsrLogLevelTask) 0x00000008) /* The name of each state in a FSM state transition are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_STATE, it has no effect without it */
55#define CSR_LOG_LEVEL_TASK_STATE_LOC ((CsrLogLevelTask) 0x00000010) /* The location where the FSM state transition occured are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_STATE, it has no effect without it */
56#define CSR_LOG_LEVEL_TASK_TASK_SWITCH ((CsrLogLevelTask) 0x00000020) /* Activation and deactiation of a task are logged */
57#define CSR_LOG_LEVEL_TASK_MESSAGE_PUT ((CsrLogLevelTask) 0x00000080) /* Message put operations are logged */
58#define CSR_LOG_LEVEL_TASK_MESSAGE_PUT_LOC ((CsrLogLevelTask) 0x00000100) /* The location where a message was sent are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_MESSAGE_PUT, it has no effect without it */
59#define CSR_LOG_LEVEL_TASK_MESSAGE_GET ((CsrLogLevelTask) 0x00000200) /* Message get operations are logged */
60#define CSR_LOG_LEVEL_TASK_MESSAGE_QUEUE_PUSH ((CsrLogLevelTask) 0x00000400) /* Message push operations are logged */
61#define CSR_LOG_LEVEL_TASK_MESSAGE_QUEUE_POP ((CsrLogLevelTask) 0x00000800) /* Message pop operations are logged */
62#define CSR_LOG_LEVEL_TASK_PRIM_ONLY_TYPE ((CsrLogLevelTask) 0x00001000) /* Only the type of primitives in messages are logged. By default the entire primitive is serialized and logged */
63#define CSR_LOG_LEVEL_TASK_PRIM_APPLY_LIMIT ((CsrLogLevelTask) 0x00002000) /* An upper limit (defined by CSR_LOG_PRIM_SIZE_UPPER_LIMIT) is applied to how much of a primitive in a message are logged. NB: This limit is only applied if CSR_LOG_LEVEL_TASK_PRIM_ONLY_TYPE is _not_ defined */
64#define CSR_LOG_LEVEL_TASK_TIMER_IN ((CsrLogLevelTask) 0x00004000) /* TimedEventIn events are logged */
65#define CSR_LOG_LEVEL_TASK_TIMER_IN_LOC ((CsrLogLevelTask) 0x00008000) /* The location where a timer was started are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_TIMER_IN, it has no effect without it */
66#define CSR_LOG_LEVEL_TASK_TIMER_CANCEL ((CsrLogLevelTask) 0x00010000) /* TimedEventCancel events are logged */
67#define CSR_LOG_LEVEL_TASK_TIMER_CANCEL_LOC ((CsrLogLevelTask) 0x00020000) /* The location where a timer was cancelled are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_TIMER_CANCEL, it has no effect without it */
68#define CSR_LOG_LEVEL_TASK_TIMER_FIRE ((CsrLogLevelTask) 0x00040000) /* TimedEventFire events are logged */
69#define CSR_LOG_LEVEL_TASK_TIMER_DONE ((CsrLogLevelTask) 0x00080000) /* TimedEventDone events are logged */
70/* The bit masks between here are reserved for future usage */
71#define CSR_LOG_LEVEL_TASK_ALL ((CsrLogLevelTask) 0xFFFFFFFF & ~(CSR_LOG_LEVEL_TASK_PRIM_ONLY_TYPE | CSR_LOG_LEVEL_TASK_PRIM_APPLY_LIMIT)) /* All info possible to log for a task are logged. WARNING: By using this define the application also accepts future possible task data/events in the logs */
72
73u8 CsrLogEnvironmentIsFiltered(CsrLogLevelEnvironment level);
74CsrLogLevelTask CsrLogTaskFilterGet(CsrSchedQid taskId);
75u8 CsrLogTaskIsFiltered(CsrSchedQid taskId, CsrLogLevelTask level);
76
77/*
78 * Logging stuff
79 */
80#define CSR_LOG_STRINGIFY_REAL(a) #a
81#define CSR_LOG_STRINGIFY(a) CSR_LOG_STRINGIFY_REAL(a)
82
83#ifdef CSR_LOG_ASSERT_ENABLE
84#define CSR_LOG_ASSERT(cond) \
85    do { \
86        if (!(cond)) \
87        { \
88            char *panic_arg = "[" __FILE__ ":" CSR_LOG_STRINGIFY(__LINE__) "] - " CSR_LOG_STRINGIFY(cond); \
89            CsrPanic(CSR_TECH_FW, CSR_PANIC_FW_ASSERTION_FAIL, panic_arg); \
90        } \
91    } while (0)
92#else
93#define CSR_LOG_ASSERT(cond)
94#endif
95
96typedef struct
97{
98    u16 primitiveType;
99    const char *primitiveName;
100    CsrMsgConvMsgEntry *messageConv; /* Private - do not use */
101} CsrLogPrimitiveInformation;
102
103typedef struct
104{
105    const char *techVer;
106    u32 primitiveInfoCount;
107    CsrLogPrimitiveInformation *primitiveInfo;
108} CsrLogTechInformation;
109
110/*---------------------------------*/
111/* Tech logging */
112/*---------------------------------*/
113typedef u8 bitmask8_t;
114typedef u16 bitmask16_t;
115typedef u32 bitmask32_t;
116
117#ifdef CSR_LOG_ENABLE
118#ifdef CSR_LOG_INCLUDE_FILE_NAME_AND_LINE_NUMBER
119/* DEPRECATED - replaced by csr_log_text.h */
120#define CSR_LOG_TEXT(text) \
121    do { \
122        if (!CsrLogTaskIsFiltered(CsrSchedTaskQueueGet(), CSR_LOG_LEVEL_TASK_TEXT)) \
123        { \
124            CsrLogTaskText(text, __LINE__, __FILE__); \
125        } \
126    } while (0)
127#else
128/* DEPRECATED - replaced by csr_log_text.h */
129#define CSR_LOG_TEXT(text) \
130    do { \
131        if (!CsrLogTaskIsFiltered(CsrSchedTaskQueueGet(), CSR_LOG_LEVEL_TASK_TEXT)) \
132        { \
133            CsrLogTaskText(text, 0, NULL); \
134        } \
135    } while (0)
136#endif
137#else
138#define CSR_LOG_TEXT(text)
139#endif
140
141/* DEPRECATED - replaced by csr_log_text.h */
142void CsrLogTaskText(const char *text,
143    u32 line,
144    const char *file);
145
146#define CSR_LOG_STATE_TRANSITION_MASK_FSM_NAME (0x001)
147#define CSR_LOG_STATE_TRANSITION_MASK_NEXT_STATE (0x002)
148#define CSR_LOG_STATE_TRANSITION_MASK_NEXT_STATE_STR (0x004)
149#define CSR_LOG_STATE_TRANSITION_MASK_PREV_STATE (0x008)
150#define CSR_LOG_STATE_TRANSITION_MASK_PREV_STATE_STR (0x010)
151#define CSR_LOG_STATE_TRANSITION_MASK_EVENT (0x020)
152#define CSR_LOG_STATE_TRANSITION_MASK_EVENT_STR (0x040)
153
154/* DEPRECATED - replaced by csr_log_text.h */
155void CsrLogStateTransition(bitmask16_t mask,
156    u32 identifier,
157    const char *fsm_name,
158    u32 prev_state,
159    const char *prev_state_str,
160    u32 in_event,
161    const char *in_event_str,
162    u32 next_state,
163    const char *next_state_str,
164    u32 line,
165    const char *file);
166
167/*---------------------------------*/
168/* BSP logging */
169/*---------------------------------*/
170void CsrLogSchedInit(u8 thread_id);
171void CsrLogSchedDeinit(u8 thread_id);
172
173void CsrLogSchedStart(u8 thread_id);
174void CsrLogSchedStop(u8 thread_id);
175
176void CsrLogInitTask(u8 thread_id, CsrSchedQid tskid, const char *tskName);
177void CsrLogDeinitTask(u16 task_id);
178
179void CsrLogActivate(CsrSchedQid tskid);
180void CsrLogDeactivate(CsrSchedQid tskid);
181
182#define SYNERGY_SERIALIZER_TYPE_DUMP (0x000)
183#define SYNERGY_SERIALIZER_TYPE_SER (0x001)
184
185void CsrLogMessagePut(u32 line,
186    const char *file,
187    CsrSchedQid src_task_id,
188    CsrSchedQid dst_taskid,
189    CsrSchedMsgId msg_id,
190    u16 prim_type,
191    const void *msg);
192
193void CsrLogMessageGet(CsrSchedQid src_task_id,
194    CsrSchedQid dst_taskid,
195    u8 get_res,
196    CsrSchedMsgId msg_id,
197    u16 prim_type,
198    const void *msg);
199
200void CsrLogTimedEventIn(u32 line,
201    const char *file,
202    CsrSchedQid task_id,
203    CsrSchedTid tid,
204    CsrTime requested_delay,
205    u16 fniarg,
206    const void *fnvarg);
207
208void CsrLogTimedEventFire(CsrSchedQid task_id,
209    CsrSchedTid tid);
210
211void CsrLogTimedEventDone(CsrSchedQid task_id,
212    CsrSchedTid tid);
213
214void CsrLogTimedEventCancel(u32 line,
215    const char *file,
216    CsrSchedQid task_id,
217    CsrSchedTid tid,
218    u8 cancel_res);
219
220void CsrLogBgintRegister(u8 thread_id,
221    CsrSchedBgint irq,
222    const char *callback,
223    const void *ptr);
224void CsrLogBgintUnregister(CsrSchedBgint irq);
225void CsrLogBgintSet(CsrSchedBgint irq);
226void CsrLogBgintServiceStart(CsrSchedBgint irq);
227void CsrLogBgintServiceDone(CsrSchedBgint irq);
228
229void CsrLogExceptionStateEvent(u16 prim_type,
230    CsrPrim msg_type,
231    u16 state,
232    u32 line,
233    const char *file);
234void CsrLogExceptionGeneral(u16 prim_type,
235    u16 state,
236    const char *text,
237    u32 line,
238    const char *file);
239void CsrLogExceptionWarning(u16 prim_type,
240    u16 state,
241    const char *text,
242    u32 line,
243    const char *file);
244
245#ifdef __cplusplus
246}
247#endif
248
249#endif
250

Archive Download this file



interactive