CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
orangepi-xunlong

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: orangepi-xunlong/orangepi-build
Path: blob/next/external/cache/sources/wl/include/event_log.h
Views: 3959
1
/*
2
* EVENT_LOG system definitions
3
*
4
* $Copyright Open Broadcom Corporation$
5
*
6
* $Id: event_log.h 241182 2011-02-17 21:50:03Z $
7
*/
8
9
#ifndef _EVENT_LOG_H_
10
#define _EVENT_LOG_H_
11
12
13
/* Set a maximum number of sets here. It is not dynamic for
14
* efficiency of the EVENT_LOG calls.
15
*/
16
#define NUM_EVENT_LOG_SETS 4
17
18
/* Define new event log tags here */
19
#define EVENT_LOG_TAG_NULL 0 /* Special null tag */
20
#define EVENT_LOG_TAG_TS 1 /* Special timestamp tag */
21
#define EVENT_LOG_TAG_BUS_OOB 2
22
#define EVENT_LOG_TAG_BUS_STATE 3
23
#define EVENT_LOG_TAG_BUS_PROTO 4
24
#define EVENT_LOG_TAG_BUS_CTL 5
25
#define EVENT_LOG_TAG_BUS_EVENT 6
26
#define EVENT_LOG_TAG_BUS_PKT 7
27
#define EVENT_LOG_TAG_BUS_FRAME 8
28
#define EVENT_LOG_TAG_BUS_DESC 9
29
#define EVENT_LOG_TAG_BUS_SETUP 10
30
#define EVENT_LOG_TAG_BUS_MISC 11
31
#define EVENT_LOG_TAG_MAX 11
32
33
/* Flags for tag control */
34
#define EVENT_LOG_TAG_FLAG_NONE 0
35
#define EVENT_LOG_TAG_FLAG_LOG 0x80
36
#define EVENT_LOG_TAG_FLAG_PRINT 0x40
37
#define EVENT_LOG_TAG_FLAG_MASK 0x3f
38
39
/* We make sure that the block size will fit in a single packet
40
* (allowing for a bit of overhead on each packet
41
*/
42
#define EVENT_LOG_MAX_BLOCK_SIZE 1400
43
44
/*
45
* There are multiple levels of objects define here:
46
* event_log_set - a set of buffers
47
* event log groups - every event log call is part of just one. All
48
* event log calls in a group are handled the
49
* same way. Each event log group is associated
50
* with an event log set or is off.
51
*/
52
53
#ifndef __ASSEMBLER__
54
55
/* On the external system where the dumper is we need to make sure
56
* that these types are the same size as they are on the ARM the
57
* produced them
58
*/
59
#ifdef EVENT_LOG_DUMPER
60
#define _EL_BLOCK_PTR uint32
61
#define _EL_TYPE_PTR uint32
62
#define _EL_SET_PTR uint32
63
#define _EL_TOP_PTR uint32
64
#else
65
#define _EL_BLOCK_PTR struct event_log_block *
66
#define _EL_TYPE_PTR uint32 *
67
#define _EL_SET_PTR struct event_log_set **
68
#define _EL_TOP_PTR struct event_log_top *
69
#endif /* EVENT_LOG_DUMPER */
70
71
/* Each event log entry has a type. The type is the LAST word of the
72
* event log. The printing code walks the event entries in reverse
73
* order to find the first entry.
74
*/
75
typedef union event_log_hdr {
76
struct {
77
uint8 tag; /* Event_log entry tag */
78
uint8 count; /* Count of 4-byte entries */
79
uint16 fmt_num; /* Format number */
80
};
81
uint32 t; /* Type cheat */
82
} event_log_hdr_t;
83
84
/* Event log sets (a logical circurlar buffer) consist of one or more
85
* event_log_blocks. The blocks themselves form a logical circular
86
* list. The log entries are placed in each event_log_block until it
87
* is full. Logging continues with the next event_log_block in the
88
* event_set until the last event_log_block is reached and then
89
* logging starts over with the first event_log_block in the
90
* event_set.
91
*/
92
typedef struct event_log_block {
93
_EL_BLOCK_PTR next_block;
94
_EL_BLOCK_PTR prev_block;
95
_EL_TYPE_PTR end_ptr;
96
97
/* Start of packet sent for log tracing */
98
uint16 pktlen; /* Size of rest of block */
99
uint16 count; /* Logtrace counter */
100
uint32 timestamp; /* Timestamp at start of use */
101
uint32 event_logs;
102
} event_log_block_t;
103
104
/* There can be multiple event_sets with each logging a set of
105
* associated events (i.e, "fast" and "slow" events).
106
*/
107
typedef struct event_log_set {
108
_EL_BLOCK_PTR first_block; /* Pointer to first event_log block */
109
_EL_BLOCK_PTR last_block; /* Pointer to last event_log block */
110
_EL_BLOCK_PTR logtrace_block; /* next block traced */
111
_EL_BLOCK_PTR cur_block; /* Pointer to current event_log block */
112
_EL_TYPE_PTR cur_ptr; /* Current event_log pointer */
113
uint32 blockcount; /* Number of blocks */
114
uint16 logtrace_count; /* Last count for logtrace */
115
uint16 blockfill_count; /* Fill count for logtrace */
116
uint32 timestamp; /* Last timestamp event */
117
uint32 cyclecount; /* Cycles at last timestamp event */
118
} event_log_set_t;
119
120
/* Top data structure for access to everything else */
121
typedef struct event_log_top {
122
uint32 magic;
123
#define EVENT_LOG_TOP_MAGIC 0x474C8669 /* 'EVLG' */
124
uint32 version;
125
#define EVENT_LOG_VERSION 1
126
uint32 num_sets;
127
uint32 logstrs_size; /* Size of lognums + logstrs area */
128
uint32 timestamp; /* Last timestamp event */
129
uint32 cyclecount; /* Cycles at last timestamp event */
130
_EL_SET_PTR sets; /* Ptr to array of <num_sets> set ptrs */
131
} event_log_top_t;
132
133
#ifndef EVENT_LOG_DUMPER
134
135
#ifndef EVENT_LOG_COMPILE
136
137
/* Null define if no tracing */
138
#define EVENT_LOG(format, ...)
139
140
#else /* EVENT_LOG_COMPILE */
141
142
/* The first few are special because they can be done more efficiently
143
* this way and they are the common case. Once there are too many
144
* parameters the code size starts to be an issue and a loop is better
145
*/
146
#define _EVENT_LOG0(tag, fmt_num) \
147
event_log0(tag, fmt_num)
148
#define _EVENT_LOG1(tag, fmt_num, t1) \
149
event_log1(tag, fmt_num, t1)
150
#define _EVENT_LOG2(tag, fmt_num, t1, t2) \
151
event_log2(tag, fmt_num, t1, t2)
152
#define _EVENT_LOG3(tag, fmt_num, t1, t2, t3) \
153
event_log3(tag, fmt_num, t1, t2, t3)
154
#define _EVENT_LOG4(tag, fmt_num, t1, t2, t3, t4) \
155
event_log4(tag, fmt_num, t1, t2, t3, t4)
156
157
/* The rest call the generic routine that takes a count */
158
#define _EVENT_LOG5(tag, fmt_num, ...) event_logn(5, tag, fmt_num, __VA_ARGS__)
159
#define _EVENT_LOG6(tag, fmt_num, ...) event_logn(6, tag, fmt_num, __VA_ARGS__)
160
#define _EVENT_LOG7(tag, fmt_num, ...) event_logn(7, tag, fmt_num, __VA_ARGS__)
161
#define _EVENT_LOG8(tag, fmt_num, ...) event_logn(8, tag, fmt_num, __VA_ARGS__)
162
#define _EVENT_LOG9(tag, fmt_num, ...) event_logn(9, tag, fmt_num, __VA_ARGS__)
163
#define _EVENT_LOGa(tag, fmt_num, ...) event_logn(10, tag, fmt_num, __VA_ARGS__)
164
#define _EVENT_LOGb(tag, fmt_num, ...) event_logn(11, tag, fmt_num, __VA_ARGS__)
165
#define _EVENT_LOGc(tag, fmt_num, ...) event_logn(12, tag, fmt_num, __VA_ARGS__)
166
#define _EVENT_LOGd(tag, fmt_num, ...) event_logn(13, tag, fmt_num, __VA_ARGS__)
167
#define _EVENT_LOGe(tag, fmt_num, ...) event_logn(14, tag, fmt_num, __VA_ARGS__)
168
#define _EVENT_LOGf(tag, fmt_num, ...) event_logn(15, tag, fmt_num, __VA_ARGS__)
169
170
/* Hack to make the proper routine call when variadic macros get
171
* passed. Note the max of 15 arguments. More than that can't be
172
* handled by the event_log entries anyways so best to catch it at compile
173
* time
174
*/
175
176
#define _EVENT_LOG_VA_NUM_ARGS(F, _1, _2, _3, _4, _5, _6, _7, _8, _9, \
177
_A, _B, _C, _D, _E, _F, N, ...) F ## N
178
179
#define _EVENT_LOG(tag, fmt, ...) \
180
static char logstr[] __attribute__ ((section(".logstrs"))) = fmt; \
181
static uint32 fmtnum __attribute__ ((section(".lognums"))) = (uint32) &logstr; \
182
_EVENT_LOG_VA_NUM_ARGS(_EVENT_LOG, ##__VA_ARGS__, \
183
F, E, D, C, B, A, 9, 8, \
184
7, 6, 5, 4, 3, 2, 1, 0) \
185
(tag, (int) &fmtnum , ## __VA_ARGS__); \
186
187
188
#define EVENT_LOG_FAST(tag, fmt, ...) \
189
if (event_log_tag_sets != NULL) { \
190
uint8 tag_flag = *(event_log_tag_sets + tag); \
191
if (tag_flag != 0) { \
192
_EVENT_LOG(tag, fmt , ## __VA_ARGS__); \
193
} \
194
}
195
196
#define EVENT_LOG_COMPACT(tag, fmt, ...) \
197
if (1) { \
198
_EVENT_LOG(tag, fmt , ## __VA_ARGS__); \
199
}
200
201
#define EVENT_LOG(tag, fmt, ...) EVENT_LOG_COMPACT(tag, fmt , ## __VA_ARGS__)
202
203
extern uint8 *event_log_tag_sets;
204
205
extern int event_log_init(si_t *sih);
206
extern int event_log_set_init(si_t *sih, int set_num, int size);
207
extern int event_log_set_expand(si_t *sih, int set_num, int size);
208
extern int event_log_set_shrink(si_t *sih, int set_num, int size);
209
extern int event_log_tag_start(int tag, int set_num, int flags);
210
extern int event_log_tag_stop(int tag);
211
extern int event_log_get(int set_num, int buflen, void *buf);
212
extern uint8 * event_log_next_logtrace(int set_num);
213
214
extern void event_log0(int tag, int fmtNum);
215
extern void event_log1(int tag, int fmtNum, uint32 t1);
216
extern void event_log2(int tag, int fmtNum, uint32 t1, uint32 t2);
217
extern void event_log3(int tag, int fmtNum, uint32 t1, uint32 t2, uint32 t3);
218
extern void event_log4(int tag, int fmtNum, uint32 t1, uint32 t2, uint32 t3, uint32 t4);
219
extern void event_logn(int num_args, int tag, int fmtNum, ...);
220
221
extern void event_log_time_sync(void);
222
223
#endif /* EVENT_LOG_DUMPER */
224
225
#endif /* EVENT_LOG_COMPILE */
226
227
#endif /* __ASSEMBLER__ */
228
229
#endif /* _EVENT_LOG_H */
230
231