1 /******************************************************************************
4 Lantiq Deutschland GmbH
6 For licensing information, see the file 'LICENSE' in the root folder of
9 ******************************************************************************/
14 * Written by: Andriy Fidrya
21 /* RTLOGGER compilation time options (RTLOG_FLAGS) */
22 #define RTLF_REMOTE_ENABLED 0x00000001
23 #define RTLF_CONSOLE_ENABLED 0x00000002
25 /* RTLOGGER special logs compilation control Debug Levels
26 Used to enable/disable logs by debug level in compile time
29 #define RTLOG_ERROR_DLEVEL -2
30 #define RTLOG_WARNING_DLEVEL -1
32 #ifndef RTLOG_FLAGS /* combination of RTLF_... flags */
33 #error RTLOG_FLAGS must be defined!
36 #ifndef RTLOG_MAX_DLEVEL
37 #error RTLOG_MAX_DLEVEL must be defined!
40 #ifdef FMT_NO_ATTR_CHK
41 #define __attribute__(x)
44 #define LOG_TARGET_CONSOLE (1 << 0)
45 #define LOG_TARGET_REMOTE (1 << 1)
51 typedef struct _mtlk_log_buf_entry_t mtlk_log_buf_entry_t
;
53 typedef struct _mtlk_log_multi_buffer_t
55 mtlk_log_buf_entry_t
*buf
;
58 } mtlk_log_multi_buffer_t
;
60 // --------------------
61 // Functions and macros
62 // --------------------
64 * \fn BOOL mtlk_log_check_version(uint16 major, uint16 minor)
65 * \brief Check logger version.
67 * Checks logger version of a component that wants to log using this log driver.
69 * \return TRUE if verion is supported, FALSE otherwise.
71 extern BOOL
mtlk_log_check_version(uint16 major
, uint16 minor
);
74 * \fn int mtlk_log_get_flags(int level, int oid, int gid)
75 * \brief Query log settings.
77 * Queries log settings for level, gid and sid combination.
79 * \return bitmask specifying log targets.
80 * Bitmask is 0 if logger is not initialized or no log targets
82 * LOG_TARGET_CONSOLE - console logging requested.
83 * LOG_TARGET_REMOTE - remote logging requested.
85 extern int mtlk_log_get_flags(int level
, int oid
, int gid
);
88 * \fn mtlk_log_buf_entry_t *mtlk_log_new_pkt_reserve(uint32 pkt_size,
90 * \brief Reserve space for a new packet in active buffer.
92 * Returns a pointer to active buffer (as return value) and a pointer to
93 * beginning of free space in this buffer (ppdata).
95 * Caller writes packet contents to ppdata, then releases the buffer by
96 * calling mtlk_log_new_pkt_release.
98 * Caller must silently ignore errors; reporting is done by
99 * mtlk_log_new_pkt_reserve function itself via CERROR.
101 * Implementation details:
102 * - If enough space is available in current active buffer, it's refcount
103 * is increased by 1 and size by pkt_size. Buffer is protected by refcount
104 * so it won't move to ready buffers pool before packet creation is
106 * - If not enough space is available and active buffer's refcount is 0,
107 * sends active buffer to ready buffers pool and requests another free
109 * - If not enough space is available, but active buffer's refcount is
110 * greater than 0, requests another free buffer, then replaces pointer
111 * to active buffer with a pointer to the newly obtained buffer.
112 * Note: in this case old buffer will not be lost:
113 * mtlk_log_new_pkt_release will move it to ready buffers pool after
114 * refcount reaches zero.
116 * \return pointer to a buffer on success, ppdata points to beginning of
118 * \return NULL if error has occured. Do not report this error to user.
120 extern mtlk_log_buf_entry_t
*mtlk_log_new_pkt_reserve(uint32 pkt_size
,
124 * \fn void __MTLK_IFUNC mtlk_log_new_pkt_release(mtlk_log_buf_entry_t *buf)
125 * \brief Release a buffer captured with mtlk_log_new_pkt_reserve call.
127 * Implementation details:
128 * - Decreases buf's refcount. After this:
129 * - If refcount is zero and buf is active buffer, does nothing (this buffer
130 * still can accept data as active buffer).
131 * - If refcount is zero, but buf is not an active buffer, sends the buffer
132 * to ready buffers pool. Note that the buffer was already invalidated by
133 * mtlk_log_new_pkt_reserve.
134 * - If refcount is not zero, no more actions are taken.
136 extern void mtlk_log_new_pkt_release(mtlk_log_buf_entry_t
*buf
);
140 #include "logmacro_mixins.h"
141 #include "loggroups.h"
143 extern BOOL
mtlk_log_new_pkt_reserve_multi(uint32 pkt_size
, mtlk_log_multi_buffer_t
**ppdata
);
145 extern void mtlk_log_new_pkt_release_multi(mtlk_log_multi_buffer_t
*ppdata
);
147 /* There is a strange behaviour of GCC compiler */
148 /* when it is used to generate source file */
149 /* dependencies. It ignores compilation errors */
150 /* like "unknown symbol/function/macros" but */
151 /* does not ignore "incorrect number of */
152 /* parameters passed to function". When user */
153 /* changes number of parameters of printout */
154 /* without changing the macro itself GCC fails */
155 /* to generate list of dependencies and */
156 /* and without list of dependencies LOGPREP can */
157 /* not update the MACRO used in printout being */
158 /* changed. The workaround is to hide RTLOGGER */
159 /* macro definitions during dependencies */
160 /* generation, so GCC will be happy silently */
161 /* ignoring "undefined function" error. */
163 #ifndef __MTLK_DEPENDENCY_GENERATION_PATH
165 #include "logmacros.h"
166 #ifdef MTCFG_RT_LOGGER_INLINES
167 #include "logmacros.c"
170 #endif /* __MTLK_DEPENDENCY_GENERATION_PATH */
172 #endif /* __LOG_H__ */