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_prim_defs.h" 15 #include "csr_msgconv.h" 16 17 /* 18 * Log filtering 19 */ 20 21 /*----------------------------------------------------*/ 22 /* Filtering on environment specific log levels */ 23 /*----------------------------------------------------*/ 24 typedef u32 CsrLogLevelEnvironment; 25 #define CSR_LOG_LEVEL_ENVIRONMENT_OFF ((CsrLogLevelEnvironment) 0x00000000) /* No environment data/events are logged */ 26 #define CSR_LOG_LEVEL_ENVIRONMENT_BCI_ACL ((CsrLogLevelEnvironment) 0x00000001) /* BlueCore Channel Interface HCI Acl data are logged */ 27 #define CSR_LOG_LEVEL_ENVIRONMENT_BCI_HCI ((CsrLogLevelEnvironment) 0x00000002) /* BlueCore Channel Interface HCI Cmd/Evt data are logged */ 28 #define CSR_LOG_LEVEL_ENVIRONMENT_BCI_SCO ((CsrLogLevelEnvironment) 0x00000004) /* BlueCore Channel Interface HCI Sco data are logged */ 29 #define CSR_LOG_LEVEL_ENVIRONMENT_BCI_VENDOR ((CsrLogLevelEnvironment) 0x00000008) /* BlueCore Channel Interface HCI Vendor specific data are logged (This includes BCCMD, HQ, VM etc) */ 30 #define CSR_LOG_LEVEL_ENVIRONMENT_TRANSPORTS ((CsrLogLevelEnvironment) 0x00000010) /* Transport protocol data is logged (This includes transport protocols like BCSP, H4 etc.) */ 31 #define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_REG ((CsrLogLevelEnvironment) 0x00000020) /* Background Interrupt registration events are logged */ 32 #define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_UNREG ((CsrLogLevelEnvironment) 0x00000040) /* Background Interrupt unregistration events are logged */ 33 #define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_SET ((CsrLogLevelEnvironment) 0x00000080) /* Background Interrupt set events are logged */ 34 #define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_START ((CsrLogLevelEnvironment) 0x00000100) /* Background Interrupt start events are logged */ 35 #define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_DONE ((CsrLogLevelEnvironment) 0x00000200) /* Background Interrupt done events are logged */ 36 #define CSR_LOG_LEVEL_ENVIRONMENT_PROTO ((CsrLogLevelEnvironment) 0x00000400) /* Transport protocol events are logged */ 37 #define CSR_LOG_LEVEL_ENVIRONMENT_PROTO_LOC ((CsrLogLevelEnvironment) 0x00000800) /* The Location where the transport protocol event occurred are logged NB: This is a supplement to CSR_LOG_LEVEL_ENVIRONMENT_PROTO, it has no effect without it */ 38 /* The bit masks between here are reserved for future usage */ 39 #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 */ 40 41 /*----------------------------------------------------*/ 42 /* Filtering on task specific log levels */ 43 /*----------------------------------------------------*/ 44 typedef u32 CsrLogLevelTask; 45 #define CSR_LOG_LEVEL_TASK_OFF ((CsrLogLevelTask) 0x00000000) /* No events are logged for this task */ 46 #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 */ 47 #define CSR_LOG_LEVEL_TASK_TEXT_LOC ((CsrLogLevelTask) 0x00000002) /* The locaction where the text string call occurred are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_TEXT, it has no effect without it */ 48 #define CSR_LOG_LEVEL_TASK_STATE ((CsrLogLevelTask) 0x00000004) /* FSM state transitions in a task are logged */ 49 #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 */ 50 #define CSR_LOG_LEVEL_TASK_STATE_LOC ((CsrLogLevelTask) 0x00000010) /* The location where the FSM state transition occurred are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_STATE, it has no effect without it */ 51 #define CSR_LOG_LEVEL_TASK_TASK_SWITCH ((CsrLogLevelTask) 0x00000020) /* Activation and deactiation of a task are logged */ 52 #define CSR_LOG_LEVEL_TASK_MESSAGE_PUT ((CsrLogLevelTask) 0x00000080) /* Message put operations are logged */ 53 #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 */ 54 #define CSR_LOG_LEVEL_TASK_MESSAGE_GET ((CsrLogLevelTask) 0x00000200) /* Message get operations are logged */ 55 #define CSR_LOG_LEVEL_TASK_MESSAGE_QUEUE_PUSH ((CsrLogLevelTask) 0x00000400) /* Message push operations are logged */ 56 #define CSR_LOG_LEVEL_TASK_MESSAGE_QUEUE_POP ((CsrLogLevelTask) 0x00000800) /* Message pop operations are logged */ 57 #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 */ 58 #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 */ 59 #define CSR_LOG_LEVEL_TASK_TIMER_IN ((CsrLogLevelTask) 0x00004000) /* TimedEventIn events are logged */ 60 #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 */ 61 #define CSR_LOG_LEVEL_TASK_TIMER_CANCEL ((CsrLogLevelTask) 0x00010000) /* TimedEventCancel events are logged */ 62 #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 */ 63 #define CSR_LOG_LEVEL_TASK_TIMER_FIRE ((CsrLogLevelTask) 0x00040000) /* TimedEventFire events are logged */ 64 #define CSR_LOG_LEVEL_TASK_TIMER_DONE ((CsrLogLevelTask) 0x00080000) /* TimedEventDone events are logged */ 65 /* The bit masks between here are reserved for future usage */ 66 #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 */ 67 68 u8 CsrLogEnvironmentIsFiltered(CsrLogLevelEnvironment level); 69 CsrLogLevelTask CsrLogTaskFilterGet(CsrSchedQid taskId); 70 u8 CsrLogTaskIsFiltered(CsrSchedQid taskId, CsrLogLevelTask level); 71 72 /* 73 * Logging stuff 74 */ 75 #define CSR_LOG_STRINGIFY_REAL(a) (#a) 76 #define CSR_LOG_STRINGIFY(a) CSR_LOG_STRINGIFY_REAL(a) 77 78 typedef struct { 79 u16 primitiveType; 80 const char *primitiveName; 81 CsrMsgConvMsgEntry *messageConv; /* Private - do not use */ 82 } CsrLogPrimitiveInformation; 83 84 typedef struct { 85 const char *techVer; 86 u32 primitiveInfoCount; 87 CsrLogPrimitiveInformation *primitiveInfo; 88 } CsrLogTechInformation; 89 90 /*---------------------------------*/ 91 /* Tech logging */ 92 /*---------------------------------*/ 93 typedef u8 bitmask8_t; 94 typedef u16 bitmask16_t; 95 typedef u32 bitmask32_t; 96 97 #ifdef CSR_LOG_ENABLE 98 #ifdef CSR_LOG_INCLUDE_FILE_NAME_AND_LINE_NUMBER 99 /* DEPRECATED - replaced by csr_log_text.h */ 100 #define CSR_LOG_TEXT(text) \ 101 do { \ 102 if (!CsrLogTaskIsFiltered(CsrSchedTaskQueueGet(), CSR_LOG_LEVEL_TASK_TEXT)) { \ 103 CsrLogTaskText(text, __LINE__, __FILE__); \ 104 } \ 105 } while (0) 106 #else 107 /* DEPRECATED - replaced by csr_log_text.h */ 108 #define CSR_LOG_TEXT(text) \ 109 do { \ 110 if (!CsrLogTaskIsFiltered(CsrSchedTaskQueueGet(), CSR_LOG_LEVEL_TASK_TEXT)) { \ 111 CsrLogTaskText(text, 0, NULL); \ 112 } \ 113 } while (0) 114 #endif 115 #else 116 #define CSR_LOG_TEXT(text) 117 #endif 118 119 /* DEPRECATED - replaced by csr_log_text.h */ 120 void CsrLogTaskText(const char *text, 121 u32 line, 122 const char *file); 123 124 #define CSR_LOG_STATE_TRANSITION_MASK_FSM_NAME (0x001) 125 #define CSR_LOG_STATE_TRANSITION_MASK_NEXT_STATE (0x002) 126 #define CSR_LOG_STATE_TRANSITION_MASK_NEXT_STATE_STR (0x004) 127 #define CSR_LOG_STATE_TRANSITION_MASK_PREV_STATE (0x008) 128 #define CSR_LOG_STATE_TRANSITION_MASK_PREV_STATE_STR (0x010) 129 #define CSR_LOG_STATE_TRANSITION_MASK_EVENT (0x020) 130 #define CSR_LOG_STATE_TRANSITION_MASK_EVENT_STR (0x040) 131 132 /* DEPRECATED - replaced by csr_log_text.h */ 133 void CsrLogStateTransition(bitmask16_t mask, 134 u32 identifier, 135 const char *fsm_name, 136 u32 prev_state, 137 const char *prev_state_str, 138 u32 in_event, 139 const char *in_event_str, 140 u32 next_state, 141 const char *next_state_str, 142 u32 line, 143 const char *file); 144 145 /*---------------------------------*/ 146 /* BSP logging */ 147 /*---------------------------------*/ 148 void CsrLogSchedInit(u8 thread_id); 149 void CsrLogSchedDeinit(u8 thread_id); 150 151 void CsrLogSchedStart(u8 thread_id); 152 void CsrLogSchedStop(u8 thread_id); 153 154 void CsrLogInitTask(u8 thread_id, CsrSchedQid tskid, const char *tskName); 155 void CsrLogDeinitTask(u16 task_id); 156 157 void CsrLogActivate(CsrSchedQid tskid); 158 void CsrLogDeactivate(CsrSchedQid tskid); 159 160 #define SYNERGY_SERIALIZER_TYPE_DUMP (0x000) 161 #define SYNERGY_SERIALIZER_TYPE_SER (0x001) 162 163 void CsrLogMessagePut(u32 line, 164 const char *file, 165 CsrSchedQid src_task_id, 166 CsrSchedQid dst_taskid, 167 CsrSchedMsgId msg_id, 168 u16 prim_type, 169 const void *msg); 170 171 void CsrLogMessageGet(CsrSchedQid src_task_id, 172 CsrSchedQid dst_taskid, 173 u8 get_res, 174 CsrSchedMsgId msg_id, 175 u16 prim_type, 176 const void *msg); 177 178 void CsrLogTimedEventIn(u32 line, 179 const char *file, 180 CsrSchedQid task_id, 181 CsrSchedTid tid, 182 u32 requested_delay, 183 u16 fniarg, 184 const void *fnvarg); 185 186 void CsrLogTimedEventFire(CsrSchedQid task_id, 187 CsrSchedTid tid); 188 189 void CsrLogTimedEventDone(CsrSchedQid task_id, 190 CsrSchedTid tid); 191 192 void CsrLogTimedEventCancel(u32 line, 193 const char *file, 194 CsrSchedQid task_id, 195 CsrSchedTid tid, 196 u8 cancel_res); 197 198 void CsrLogBgintRegister(u8 thread_id, 199 CsrSchedBgint irq, 200 const char *callback, 201 const void *ptr); 202 void CsrLogBgintUnregister(CsrSchedBgint irq); 203 void CsrLogBgintSet(CsrSchedBgint irq); 204 void CsrLogBgintServiceStart(CsrSchedBgint irq); 205 void CsrLogBgintServiceDone(CsrSchedBgint irq); 206 207 void CsrLogExceptionStateEvent(u16 prim_type, 208 CsrPrim msg_type, 209 u16 state, 210 u32 line, 211 const char *file); 212 void CsrLogExceptionGeneral(u16 prim_type, 213 u16 state, 214 const char *text, 215 u32 line, 216 const char *file); 217 void CsrLogExceptionWarning(u16 prim_type, 218 u16 state, 219 const char *text, 220 u32 line, 221 const char *file); 222 223 #endif 224