3 * Toyohashi Open Platform for Embedded Real-Time Systems/
4 * Advanced Standard Profile Kernel
6 * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
7 * Toyohashi Univ. of Technology, JAPAN
8 * Copyright (C) 2004-2008 by Embedded and Real-Time Systems Laboratory
9 * Graduate School of Information Science, Nagoya Univ., JAPAN
11 * 上記著作権者は,以下の(1)〜(4)の条件を満たす場合に限り,本ソフトウェ
12 * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
13 * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
14 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
15 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
17 * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
18 * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
19 * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
21 * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
22 * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
24 * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
25 * 作権表示,この利用条件および下記の無保証規定を掲載すること.
26 * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
28 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
29 * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
30 * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
31 * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
34 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
35 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
36 * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
37 * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
40 * @(#) $Id: t_syslog.h 1900 2010-08-14 02:31:44Z ertl-hiro $
46 * システムログサービスは,システムのログ情報を出力するためのサービス
47 * である.カーネルからのログ情報の出力にも用いるため,内部で待ち状態
50 * ログ情報は,カーネル内のログバッファに書き込むか,低レベルの文字出
51 * 力関数を用いて出力する.どちらを使うかは,拡張サービスコールで切り
54 * ログバッファ領域がオーバフローした場合には,古いログ情報を消して上
57 * アセンブリ言語のソースファイルからこのファイルをインクルードする時
58 * は,TOPPERS_MACRO_ONLYを定義しておくことで,マクロ定義以外の記述を
61 * このファイルをインクルードする前に,t_stddef.hをインクルードしてお
65 #ifndef TOPPERS_T_SYSLOG_H
66 #define TOPPERS_T_SYSLOG_H
75 #define LOG_TYPE_COMMENT UINT_C(0x01) /* コメント */
76 #define LOG_TYPE_ASSERT UINT_C(0x02) /* アサーションの失敗 */
78 #define LOG_TYPE_INH UINT_C(0x11) /* 割込みハンドラ */
79 #define LOG_TYPE_ISR UINT_C(0x12) /* 割込みサービスルーチン */
80 #define LOG_TYPE_CYC UINT_C(0x13) /* 周期ハンドラ */
81 #define LOG_TYPE_ALM UINT_C(0x14) /* アラームハンドラ */
82 #define LOG_TYPE_OVR UINT_C(0x15) /* オーバランハンドラ */
83 #define LOG_TYPE_EXC UINT_C(0x16) /* CPU例外ハンドラ */
84 #define LOG_TYPE_TEX UINT_C(0x17) /* タスク例外処理ルーチン */
85 #define LOG_TYPE_TSKSTAT UINT_C(0x18) /* タスク状態変化 */
86 #define LOG_TYPE_DSP UINT_C(0x19) /* ディスパッチャ */
87 #define LOG_TYPE_SVC UINT_C(0x1a) /* サービスコール */
89 #define LOG_ENTER UINT_C(0x00) /* 入口/開始 */
90 #define LOG_LEAVE UINT_C(0x80) /* 出口/終了 */
95 #define LOG_EMERG UINT_C(0) /* シャットダウンに値するエラー */
96 #define LOG_ALERT UINT_C(1)
97 #define LOG_CRIT UINT_C(2)
98 #define LOG_ERROR UINT_C(3) /* システムエラー */
99 #define LOG_WARNING UINT_C(4) /* 警告メッセージ */
100 #define LOG_NOTICE UINT_C(5)
101 #define LOG_INFO UINT_C(6)
102 #define LOG_DEBUG UINT_C(7) /* デバッグ用メッセージ */
104 #ifndef TOPPERS_MACRO_ONLY
110 #define TMAX_LOGINFO 6
113 uint_t logtype; /* ログ情報の種別 */
114 SYSTIM logtim; /* ログ時刻 */
115 intptr_t loginfo[TMAX_LOGINFO]; /* その他のログ情報 */
119 * ログ情報の重要度のビットマップを作るためのマクロ
121 #define LOG_MASK(prio) (1U << (prio))
122 #define LOG_UPTO(prio) ((1U << ((prio) + 1)) - 1)
127 typedef struct t_syslog_rlog {
128 uint_t count; /* ログバッファ中のログの数 */
129 uint_t lost; /* 失われたログの数 */
130 uint_t logmask; /* ログバッファに記録すべき重要度 */
131 uint_t lowmask; /* 低レベル出力すべき重要度 */
135 * ログ情報を出力するためのライブラリ関数
138 #ifndef TOPPERS_OMIT_SYSLOG
140 extern ER syslog_wri_log(uint_t prio, const SYSLOG *p_syslog) throw();
143 _syslog_0(uint_t prio, uint_t type)
147 syslog.logtype = type;
148 (void) syslog_wri_log(prio, &syslog);
152 _syslog_1(uint_t prio, uint_t type, intptr_t arg1)
156 syslog.logtype = type;
157 syslog.loginfo[0] = arg1;
158 (void) syslog_wri_log(prio, &syslog);
162 _syslog_2(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2)
166 syslog.logtype = type;
167 syslog.loginfo[0] = arg1;
168 syslog.loginfo[1] = arg2;
169 (void) syslog_wri_log(prio, &syslog);
173 _syslog_3(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
178 syslog.logtype = type;
179 syslog.loginfo[0] = arg1;
180 syslog.loginfo[1] = arg2;
181 syslog.loginfo[2] = arg3;
182 (void) syslog_wri_log(prio, &syslog);
186 _syslog_4(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
187 intptr_t arg3, intptr_t arg4)
191 syslog.logtype = type;
192 syslog.loginfo[0] = arg1;
193 syslog.loginfo[1] = arg2;
194 syslog.loginfo[2] = arg3;
195 syslog.loginfo[3] = arg4;
196 (void) syslog_wri_log(prio, &syslog);
200 _syslog_5(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
201 intptr_t arg3, intptr_t arg4, intptr_t arg5)
205 syslog.logtype = type;
206 syslog.loginfo[0] = arg1;
207 syslog.loginfo[1] = arg2;
208 syslog.loginfo[2] = arg3;
209 syslog.loginfo[3] = arg4;
210 syslog.loginfo[4] = arg5;
211 (void) syslog_wri_log(prio, &syslog);
215 _syslog_6(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
216 intptr_t arg3, intptr_t arg4, intptr_t arg5, intptr_t arg6)
220 syslog.logtype = type;
221 syslog.loginfo[0] = arg1;
222 syslog.loginfo[1] = arg2;
223 syslog.loginfo[2] = arg3;
224 syslog.loginfo[3] = arg4;
225 syslog.loginfo[4] = arg5;
226 syslog.loginfo[5] = arg6;
227 (void) syslog_wri_log(prio, &syslog);
231 * ログ情報(コメント)を出力するためのライブラリ関数(vasyslog.c)
233 extern void syslog(uint_t prio, const char *format, ...) throw();
235 #else /* TOPPERS_OMIT_SYSLOG */
242 _syslog_0(uint_t prio, uint_t type)
247 _syslog_1(uint_t prio, uint_t type, intptr_t arg1)
252 _syslog_2(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2)
257 _syslog_3(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
263 _syslog_4(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
264 intptr_t arg3, intptr_t arg4)
269 _syslog_5(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
270 intptr_t arg3, intptr_t arg4, intptr_t arg5)
275 _syslog_6(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
276 intptr_t arg3, intptr_t arg4, intptr_t arg5, intptr_t arg6)
281 syslog(uint_t prio, const char *format, ...)
285 #endif /* TOPPERS_OMIT_SYSLOG */
288 * ログ情報(コメント)を出力するためのマクロ
290 * formatおよび後続の引数から作成したメッセージを,重大度prioでログ情
291 * 報として出力するためのマクロ.arg1〜argnはintptr_t型にキャストする
292 * ため,intptr_t型に型変換できる任意の型でよい.
295 #define syslog_0(prio, format) \
296 _syslog_1(prio, LOG_TYPE_COMMENT, (intptr_t) format)
298 #define syslog_1(prio, format, arg1) \
299 _syslog_2(prio, LOG_TYPE_COMMENT, (intptr_t) format, \
302 #define syslog_2(prio, format, arg1, arg2) \
303 _syslog_3(prio, LOG_TYPE_COMMENT, (intptr_t) format, \
304 (intptr_t)(arg1), (intptr_t)(arg2))
306 #define syslog_3(prio, format, arg1, arg2, arg3) \
307 _syslog_4(prio, LOG_TYPE_COMMENT, (intptr_t) format, \
308 (intptr_t)(arg1), (intptr_t)(arg2), (intptr_t)(arg3))
310 #define syslog_4(prio, format, arg1, arg2, arg3, arg4) \
311 _syslog_5(prio, LOG_TYPE_COMMENT, (intptr_t) format, \
312 (intptr_t)(arg1), (intptr_t)(arg2), (intptr_t)(arg3), \
315 #define syslog_5(prio, format, arg1, arg2, arg3, arg4, arg5) \
316 _syslog_6(prio, LOG_TYPE_COMMENT, (intptr_t) format, \
317 (intptr_t)(arg1), (intptr_t)(arg2), (intptr_t)(arg3), \
318 (intptr_t)(arg4), (intptr_t)(arg5))
321 * ログ情報(アサーションの失敗)を出力するためのマクロ
323 #ifndef TOPPERS_assert_fail
324 #define TOPPERS_assert_fail(exp, file, line) \
325 _syslog_3(LOG_EMERG, LOG_TYPE_ASSERT, (intptr_t)(file), \
326 (intptr_t)(line), (intptr_t)(exp))
327 #endif /* TOPPERS_assert_fail */
329 #endif /* TOPPERS_MACRO_ONLY */
335 #endif /* TOPPERS_T_SYSLOG_H */