Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/next/external/cache/sources/wl/include/event_log.h
Views: 3959
/*1* EVENT_LOG system definitions2*3* $Copyright Open Broadcom Corporation$4*5* $Id: event_log.h 241182 2011-02-17 21:50:03Z $6*/78#ifndef _EVENT_LOG_H_9#define _EVENT_LOG_H_101112/* Set a maximum number of sets here. It is not dynamic for13* efficiency of the EVENT_LOG calls.14*/15#define NUM_EVENT_LOG_SETS 41617/* Define new event log tags here */18#define EVENT_LOG_TAG_NULL 0 /* Special null tag */19#define EVENT_LOG_TAG_TS 1 /* Special timestamp tag */20#define EVENT_LOG_TAG_BUS_OOB 221#define EVENT_LOG_TAG_BUS_STATE 322#define EVENT_LOG_TAG_BUS_PROTO 423#define EVENT_LOG_TAG_BUS_CTL 524#define EVENT_LOG_TAG_BUS_EVENT 625#define EVENT_LOG_TAG_BUS_PKT 726#define EVENT_LOG_TAG_BUS_FRAME 827#define EVENT_LOG_TAG_BUS_DESC 928#define EVENT_LOG_TAG_BUS_SETUP 1029#define EVENT_LOG_TAG_BUS_MISC 1130#define EVENT_LOG_TAG_MAX 113132/* Flags for tag control */33#define EVENT_LOG_TAG_FLAG_NONE 034#define EVENT_LOG_TAG_FLAG_LOG 0x8035#define EVENT_LOG_TAG_FLAG_PRINT 0x4036#define EVENT_LOG_TAG_FLAG_MASK 0x3f3738/* We make sure that the block size will fit in a single packet39* (allowing for a bit of overhead on each packet40*/41#define EVENT_LOG_MAX_BLOCK_SIZE 14004243/*44* There are multiple levels of objects define here:45* event_log_set - a set of buffers46* event log groups - every event log call is part of just one. All47* event log calls in a group are handled the48* same way. Each event log group is associated49* with an event log set or is off.50*/5152#ifndef __ASSEMBLER__5354/* On the external system where the dumper is we need to make sure55* that these types are the same size as they are on the ARM the56* produced them57*/58#ifdef EVENT_LOG_DUMPER59#define _EL_BLOCK_PTR uint3260#define _EL_TYPE_PTR uint3261#define _EL_SET_PTR uint3262#define _EL_TOP_PTR uint3263#else64#define _EL_BLOCK_PTR struct event_log_block *65#define _EL_TYPE_PTR uint32 *66#define _EL_SET_PTR struct event_log_set **67#define _EL_TOP_PTR struct event_log_top *68#endif /* EVENT_LOG_DUMPER */6970/* Each event log entry has a type. The type is the LAST word of the71* event log. The printing code walks the event entries in reverse72* order to find the first entry.73*/74typedef union event_log_hdr {75struct {76uint8 tag; /* Event_log entry tag */77uint8 count; /* Count of 4-byte entries */78uint16 fmt_num; /* Format number */79};80uint32 t; /* Type cheat */81} event_log_hdr_t;8283/* Event log sets (a logical circurlar buffer) consist of one or more84* event_log_blocks. The blocks themselves form a logical circular85* list. The log entries are placed in each event_log_block until it86* is full. Logging continues with the next event_log_block in the87* event_set until the last event_log_block is reached and then88* logging starts over with the first event_log_block in the89* event_set.90*/91typedef struct event_log_block {92_EL_BLOCK_PTR next_block;93_EL_BLOCK_PTR prev_block;94_EL_TYPE_PTR end_ptr;9596/* Start of packet sent for log tracing */97uint16 pktlen; /* Size of rest of block */98uint16 count; /* Logtrace counter */99uint32 timestamp; /* Timestamp at start of use */100uint32 event_logs;101} event_log_block_t;102103/* There can be multiple event_sets with each logging a set of104* associated events (i.e, "fast" and "slow" events).105*/106typedef struct event_log_set {107_EL_BLOCK_PTR first_block; /* Pointer to first event_log block */108_EL_BLOCK_PTR last_block; /* Pointer to last event_log block */109_EL_BLOCK_PTR logtrace_block; /* next block traced */110_EL_BLOCK_PTR cur_block; /* Pointer to current event_log block */111_EL_TYPE_PTR cur_ptr; /* Current event_log pointer */112uint32 blockcount; /* Number of blocks */113uint16 logtrace_count; /* Last count for logtrace */114uint16 blockfill_count; /* Fill count for logtrace */115uint32 timestamp; /* Last timestamp event */116uint32 cyclecount; /* Cycles at last timestamp event */117} event_log_set_t;118119/* Top data structure for access to everything else */120typedef struct event_log_top {121uint32 magic;122#define EVENT_LOG_TOP_MAGIC 0x474C8669 /* 'EVLG' */123uint32 version;124#define EVENT_LOG_VERSION 1125uint32 num_sets;126uint32 logstrs_size; /* Size of lognums + logstrs area */127uint32 timestamp; /* Last timestamp event */128uint32 cyclecount; /* Cycles at last timestamp event */129_EL_SET_PTR sets; /* Ptr to array of <num_sets> set ptrs */130} event_log_top_t;131132#ifndef EVENT_LOG_DUMPER133134#ifndef EVENT_LOG_COMPILE135136/* Null define if no tracing */137#define EVENT_LOG(format, ...)138139#else /* EVENT_LOG_COMPILE */140141/* The first few are special because they can be done more efficiently142* this way and they are the common case. Once there are too many143* parameters the code size starts to be an issue and a loop is better144*/145#define _EVENT_LOG0(tag, fmt_num) \146event_log0(tag, fmt_num)147#define _EVENT_LOG1(tag, fmt_num, t1) \148event_log1(tag, fmt_num, t1)149#define _EVENT_LOG2(tag, fmt_num, t1, t2) \150event_log2(tag, fmt_num, t1, t2)151#define _EVENT_LOG3(tag, fmt_num, t1, t2, t3) \152event_log3(tag, fmt_num, t1, t2, t3)153#define _EVENT_LOG4(tag, fmt_num, t1, t2, t3, t4) \154event_log4(tag, fmt_num, t1, t2, t3, t4)155156/* The rest call the generic routine that takes a count */157#define _EVENT_LOG5(tag, fmt_num, ...) event_logn(5, tag, fmt_num, __VA_ARGS__)158#define _EVENT_LOG6(tag, fmt_num, ...) event_logn(6, tag, fmt_num, __VA_ARGS__)159#define _EVENT_LOG7(tag, fmt_num, ...) event_logn(7, tag, fmt_num, __VA_ARGS__)160#define _EVENT_LOG8(tag, fmt_num, ...) event_logn(8, tag, fmt_num, __VA_ARGS__)161#define _EVENT_LOG9(tag, fmt_num, ...) event_logn(9, tag, fmt_num, __VA_ARGS__)162#define _EVENT_LOGa(tag, fmt_num, ...) event_logn(10, tag, fmt_num, __VA_ARGS__)163#define _EVENT_LOGb(tag, fmt_num, ...) event_logn(11, tag, fmt_num, __VA_ARGS__)164#define _EVENT_LOGc(tag, fmt_num, ...) event_logn(12, tag, fmt_num, __VA_ARGS__)165#define _EVENT_LOGd(tag, fmt_num, ...) event_logn(13, tag, fmt_num, __VA_ARGS__)166#define _EVENT_LOGe(tag, fmt_num, ...) event_logn(14, tag, fmt_num, __VA_ARGS__)167#define _EVENT_LOGf(tag, fmt_num, ...) event_logn(15, tag, fmt_num, __VA_ARGS__)168169/* Hack to make the proper routine call when variadic macros get170* passed. Note the max of 15 arguments. More than that can't be171* handled by the event_log entries anyways so best to catch it at compile172* time173*/174175#define _EVENT_LOG_VA_NUM_ARGS(F, _1, _2, _3, _4, _5, _6, _7, _8, _9, \176_A, _B, _C, _D, _E, _F, N, ...) F ## N177178#define _EVENT_LOG(tag, fmt, ...) \179static char logstr[] __attribute__ ((section(".logstrs"))) = fmt; \180static uint32 fmtnum __attribute__ ((section(".lognums"))) = (uint32) &logstr; \181_EVENT_LOG_VA_NUM_ARGS(_EVENT_LOG, ##__VA_ARGS__, \182F, E, D, C, B, A, 9, 8, \1837, 6, 5, 4, 3, 2, 1, 0) \184(tag, (int) &fmtnum , ## __VA_ARGS__); \185186187#define EVENT_LOG_FAST(tag, fmt, ...) \188if (event_log_tag_sets != NULL) { \189uint8 tag_flag = *(event_log_tag_sets + tag); \190if (tag_flag != 0) { \191_EVENT_LOG(tag, fmt , ## __VA_ARGS__); \192} \193}194195#define EVENT_LOG_COMPACT(tag, fmt, ...) \196if (1) { \197_EVENT_LOG(tag, fmt , ## __VA_ARGS__); \198}199200#define EVENT_LOG(tag, fmt, ...) EVENT_LOG_COMPACT(tag, fmt , ## __VA_ARGS__)201202extern uint8 *event_log_tag_sets;203204extern int event_log_init(si_t *sih);205extern int event_log_set_init(si_t *sih, int set_num, int size);206extern int event_log_set_expand(si_t *sih, int set_num, int size);207extern int event_log_set_shrink(si_t *sih, int set_num, int size);208extern int event_log_tag_start(int tag, int set_num, int flags);209extern int event_log_tag_stop(int tag);210extern int event_log_get(int set_num, int buflen, void *buf);211extern uint8 * event_log_next_logtrace(int set_num);212213extern void event_log0(int tag, int fmtNum);214extern void event_log1(int tag, int fmtNum, uint32 t1);215extern void event_log2(int tag, int fmtNum, uint32 t1, uint32 t2);216extern void event_log3(int tag, int fmtNum, uint32 t1, uint32 t2, uint32 t3);217extern void event_log4(int tag, int fmtNum, uint32 t1, uint32 t2, uint32 t3, uint32 t4);218extern void event_logn(int num_args, int tag, int fmtNum, ...);219220extern void event_log_time_sync(void);221222#endif /* EVENT_LOG_DUMPER */223224#endif /* EVENT_LOG_COMPILE */225226#endif /* __ASSEMBLER__ */227228#endif /* _EVENT_LOG_H */229230231