1 /* 2 Copyright (c) 2002, Thomas Kurschel 3 4 5 Part of Radeon driver 6 7 Fast logger 8 9 As syslog is very slow and tends to loose 10 data if its buffer overflows (which occurs much 11 too often), this module provides a fast (and memory- 12 wasting) logging mechanism. You need a seperate 13 application to retrieve the log. 14 15 Everything is thread-safe. 16 */ 17 18 19 #ifndef __LOG_COLL_H__ 20 #define __LOG_COLL_H__ 21 22 #include <SupportDefs.h> 23 24 // by undefining this flag, all logging functions 25 // are resolved to empty space, so don't add 26 // extra tests in your code 27 #undef ENABLE_LOGGING 28 //#define ENABLE_LOGGING 29 30 31 // add log entry with 0..3 (uint32) data 32 #define LOG( li, what ) log( li, what, 0 ) 33 #define LOG1( li, what, arg1 ) log( li, what, 1, arg1 ); 34 #define LOG2( li, what, arg1, arg2 ) log( li, what, 2, arg1, arg2 ); 35 #define LOG3( li, what, arg1, arg2, arg3 ) log( li, what, 3, arg1, arg2, arg3 ); 36 37 38 // one log entry 39 typedef struct log_entry_t { 40 uint64 tsc; 41 uint16 what; 42 uint8 num_args; 43 uint32 args[1]; 44 } log_entry; 45 46 struct log_info_t; 47 48 #if defined(__cplusplus) 49 extern "C" { 50 #endif 51 52 53 #ifdef ENABLE_LOGGING 54 void log( struct log_info_t *li, uint16 what, const uint8 num_args, ... ); 55 #else 56 #define log( a, b, c... ) 57 #endif 58 59 60 // define LOG_INCLUDE_STARTUP in your device driver 61 #ifdef LOG_INCLUDE_STARTUP 62 63 uint32 log_getsize( struct log_info_t *li ); 64 void log_getcopy( struct log_info_t *li, void *dest, uint32 max_size ); 65 66 #ifdef ENABLE_LOGGING 67 68 struct log_info_t *log_init( uint32 size ); 69 void log_exit( struct log_info_t *li ); 70 71 #else 72 73 #define log_init( a ) NULL 74 #define log_exit( a ) 75 76 #endif 77 78 #endif 79 80 #if defined(__cplusplus) 81 } 82 #endif 83 84 85 #endif 86