aboutsummaryrefslogtreecommitdiff
path: root/drivers/staging/csr/csr_log.h
blob: f86c49206288987de70bbee2f3e93f0f5498ddb5 (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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#ifndef CSR_LOG_H__
#define CSR_LOG_H__
/*****************************************************************************

            (c) Cambridge Silicon Radio Limited 2010
            All rights reserved and confidential information of CSR

            Refer to LICENSE.txt included with this source for details
            on the license terms.

*****************************************************************************/

#include "csr_types.h"
#include "csr_sched.h"
#include "csr_panic.h"
#include "csr_prim_defs.h"
#include "csr_msgconv.h"

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Log filtering
 */

/*----------------------------------------------------*/
/*  Filtering on environment specific log levels      */
/*----------------------------------------------------*/
typedef CsrUint32 CsrLogLevelEnvironment;
#define CSR_LOG_LEVEL_ENVIRONMENT_OFF          ((CsrLogLevelEnvironment) 0x00000000) /* No environment data/events are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_ACL      ((CsrLogLevelEnvironment) 0x00000001) /* BlueCore Channel Interface HCI Acl data are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_HCI      ((CsrLogLevelEnvironment) 0x00000002) /* BlueCore Channel Interface HCI Cmd/Evt data are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_SCO      ((CsrLogLevelEnvironment) 0x00000004) /* BlueCore Channel Interface HCI Sco data are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_VENDOR   ((CsrLogLevelEnvironment) 0x00000008) /* BlueCore Channel Interface HCI Vendor specific data are logged (This includes BCCMD, HQ, VM etc) */
#define CSR_LOG_LEVEL_ENVIRONMENT_TRANSPORTS   ((CsrLogLevelEnvironment) 0x00000010) /* Transport protocol data is logged (This includes transport protocols like BCSP, H4 etc.) */
#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_REG    ((CsrLogLevelEnvironment) 0x00000020) /* Background Interrupt registration events are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_UNREG  ((CsrLogLevelEnvironment) 0x00000040) /* Background Interrupt unregistration events are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_SET    ((CsrLogLevelEnvironment) 0x00000080) /* Background Interrupt set events are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_START  ((CsrLogLevelEnvironment) 0x00000100) /* Background Interrupt start events are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_DONE   ((CsrLogLevelEnvironment) 0x00000200) /* Background Interrupt done events are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_PROTO        ((CsrLogLevelEnvironment) 0x00000400) /* Transport protocol events are logged */
#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 */
/* The bit masks between here are reserved for future usage */
#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 */

/*----------------------------------------------------*/
/*  Filtering on task specific log levels             */
/*----------------------------------------------------*/
typedef CsrUint32 CsrLogLevelTask;
#define CSR_LOG_LEVEL_TASK_OFF                 ((CsrLogLevelTask) 0x00000000) /* No events are logged for this task */
#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 */
#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 */
#define CSR_LOG_LEVEL_TASK_STATE               ((CsrLogLevelTask) 0x00000004) /* FSM state transitions in a task are logged */
#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 */
#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 */
#define CSR_LOG_LEVEL_TASK_TASK_SWITCH         ((CsrLogLevelTask) 0x00000020) /* Activation and deactiation of a task are logged */
#define CSR_LOG_LEVEL_TASK_MESSAGE_PUT         ((CsrLogLevelTask) 0x00000080) /* Message put operations are logged */
#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 */
#define CSR_LOG_LEVEL_TASK_MESSAGE_GET         ((CsrLogLevelTask) 0x00000200) /* Message get operations are logged */
#define CSR_LOG_LEVEL_TASK_MESSAGE_QUEUE_PUSH  ((CsrLogLevelTask) 0x00000400) /* Message push operations are logged */
#define CSR_LOG_LEVEL_TASK_MESSAGE_QUEUE_POP   ((CsrLogLevelTask) 0x00000800) /* Message pop operations are logged */
#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 */
#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 */
#define CSR_LOG_LEVEL_TASK_TIMER_IN            ((CsrLogLevelTask) 0x00004000) /* TimedEventIn events are logged */
#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 */
#define CSR_LOG_LEVEL_TASK_TIMER_CANCEL        ((CsrLogLevelTask) 0x00010000) /* TimedEventCancel events are logged */
#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 */
#define CSR_LOG_LEVEL_TASK_TIMER_FIRE          ((CsrLogLevelTask) 0x00040000) /* TimedEventFire events are logged */
#define CSR_LOG_LEVEL_TASK_TIMER_DONE          ((CsrLogLevelTask) 0x00080000) /* TimedEventDone events are logged */
/* The bit masks between here are reserved for future usage */
#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 */

CsrBool CsrLogEnvironmentIsFiltered(CsrLogLevelEnvironment level);
CsrLogLevelTask CsrLogTaskFilterGet(CsrSchedQid taskId);
CsrBool CsrLogTaskIsFiltered(CsrSchedQid taskId, CsrLogLevelTask level);

/*
 * Logging stuff
 */
#define CSR_LOG_STRINGIFY_REAL(a) #a
#define CSR_LOG_STRINGIFY(a) CSR_LOG_STRINGIFY_REAL(a)

#ifdef CSR_LOG_ASSERT_ENABLE
#define CSR_LOG_ASSERT(cond)                        \
    do {                                                \
        if (!(cond))                                    \
        {                                               \
            CsrCharString *panic_arg = "[" __FILE__ ":" CSR_LOG_STRINGIFY(__LINE__) "] - " CSR_LOG_STRINGIFY(cond); \
            CsrPanic(CSR_TECH_FW, CSR_PANIC_FW_ASSERTION_FAIL, panic_arg); \
        }                                               \
    } while (0)
#else
#define CSR_LOG_ASSERT(cond)
#endif

typedef struct
{
    CsrUint16            primitiveType;
    const CsrCharString *primitiveName;
    CsrMsgConvMsgEntry  *messageConv; /* Private - do not use */
} CsrLogPrimitiveInformation;

typedef struct
{
    const CsrCharString        *techVer;
    CsrUint32                   primitiveInfoCount;
    CsrLogPrimitiveInformation *primitiveInfo;
} CsrLogTechInformation;

/*---------------------------------*/
/*  Tech logging */
/*---------------------------------*/
typedef u8 bitmask8_t;
typedef CsrUint16 bitmask16_t;
typedef CsrUint32 bitmask32_t;

#ifdef CSR_LOG_ENABLE
#ifdef CSR_LOG_INCLUDE_FILE_NAME_AND_LINE_NUMBER
/* DEPRECATED - replaced by csr_log_text.h */
#define CSR_LOG_TEXT(text) \
    do { \
        if (!CsrLogTaskIsFiltered(CsrSchedTaskQueueGet(), CSR_LOG_LEVEL_TASK_TEXT)) \
        { \
            CsrLogTaskText(text, __LINE__, __FILE__); \
        } \
    } while (0)
#else
/* DEPRECATED - replaced by csr_log_text.h */
#define CSR_LOG_TEXT(text) \
    do { \
        if (!CsrLogTaskIsFiltered(CsrSchedTaskQueueGet(), CSR_LOG_LEVEL_TASK_TEXT)) \
        { \
            CsrLogTaskText(text, 0, NULL); \
        } \
    } while (0)
#endif
#else
#define CSR_LOG_TEXT(text)
#endif

/* DEPRECATED - replaced by csr_log_text.h */
void CsrLogTaskText(const CsrCharString *text,
    CsrUint32 line,
    const CsrCharString *file);

#define CSR_LOG_STATE_TRANSITION_MASK_FSM_NAME          (0x001)
#define CSR_LOG_STATE_TRANSITION_MASK_NEXT_STATE        (0x002)
#define CSR_LOG_STATE_TRANSITION_MASK_NEXT_STATE_STR    (0x004)
#define CSR_LOG_STATE_TRANSITION_MASK_PREV_STATE        (0x008)
#define CSR_LOG_STATE_TRANSITION_MASK_PREV_STATE_STR    (0x010)
#define CSR_LOG_STATE_TRANSITION_MASK_EVENT             (0x020)
#define CSR_LOG_STATE_TRANSITION_MASK_EVENT_STR         (0x040)

/* DEPRECATED - replaced by csr_log_text.h */
void CsrLogStateTransition(bitmask16_t mask,
    CsrUint32 identifier,
    const CsrCharString *fsm_name,
    CsrUint32 prev_state,
    const CsrCharString *prev_state_str,
    CsrUint32 in_event,
    const CsrCharString *in_event_str,
    CsrUint32 next_state,
    const CsrCharString *next_state_str,
    CsrUint32 line,
    const CsrCharString *file);

/*---------------------------------*/
/*  BSP logging */
/*---------------------------------*/
void CsrLogSchedInit(u8 thread_id);
void CsrLogSchedDeinit(u8 thread_id);

void CsrLogSchedStart(u8 thread_id);
void CsrLogSchedStop(u8 thread_id);

void CsrLogInitTask(u8 thread_id, CsrSchedQid tskid, const CsrCharString *tskName);
void CsrLogDeinitTask(CsrUint16 task_id);

void CsrLogActivate(CsrSchedQid tskid);
void CsrLogDeactivate(CsrSchedQid tskid);

#define SYNERGY_SERIALIZER_TYPE_DUMP    (0x000)
#define SYNERGY_SERIALIZER_TYPE_SER     (0x001)

void CsrLogMessagePut(CsrUint32 line,
    const CsrCharString *file,
    CsrSchedQid src_task_id,
    CsrSchedQid dst_taskid,
    CsrSchedMsgId msg_id,
    CsrUint16 prim_type,
    const void *msg);

void CsrLogMessageGet(CsrSchedQid src_task_id,
    CsrSchedQid dst_taskid,
    CsrBool get_res,
    CsrSchedMsgId msg_id,
    CsrUint16 prim_type,
    const void *msg);

void CsrLogTimedEventIn(CsrUint32 line,
    const CsrCharString *file,
    CsrSchedQid task_id,
    CsrSchedTid tid,
    CsrTime requested_delay,
    CsrUint16 fniarg,
    const void *fnvarg);

void CsrLogTimedEventFire(CsrSchedQid task_id,
    CsrSchedTid tid);

void CsrLogTimedEventDone(CsrSchedQid task_id,
    CsrSchedTid tid);

void CsrLogTimedEventCancel(CsrUint32 line,
    const CsrCharString *file,
    CsrSchedQid task_id,
    CsrSchedTid tid,
    CsrBool cancel_res);

void CsrLogBgintRegister(u8 thread_id,
    CsrSchedBgint irq,
    const CsrCharString *callback,
    const void *ptr);
void CsrLogBgintUnregister(CsrSchedBgint irq);
void CsrLogBgintSet(CsrSchedBgint irq);
void CsrLogBgintServiceStart(CsrSchedBgint irq);
void CsrLogBgintServiceDone(CsrSchedBgint irq);

void CsrLogExceptionStateEvent(CsrUint16 prim_type,
    CsrPrim msg_type,
    CsrUint16 state,
    CsrUint32 line,
    const CsrCharString *file);
void CsrLogExceptionGeneral(CsrUint16 prim_type,
    CsrUint16 state,
    const CsrCharString *text,
    CsrUint32 line,
    const CsrCharString *file);
void CsrLogExceptionWarning(CsrUint16 prim_type,
    CsrUint16 state,
    const CsrCharString *text,
    CsrUint32 line,
    const CsrCharString *file);

#ifdef __cplusplus
}
#endif

#endif