source: uKadecot/trunk/ssp/include/t_syslog.h@ 108

Last change on this file since 108 was 108, checked in by coas-nagasima, 9 years ago

MIMEプロパティの変更

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-chdr; charset=SHIFT_JIS
File size: 9.0 KB
RevLine 
[101]1/*
2 * TOPPERS/ASP Kernel
3 * Toyohashi Open Platform for Embedded Real-Time Systems/
4 * Advanced Standard Profile Kernel
5 *
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
10 *
11 * 上記著作権者は,以下の(1)〜(4)の条件を満たす場合に限り,本ソフトウェ
12 * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
13 * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
14 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
15 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
16 * スコード中に含まれていること.
17 * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
18 * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
19 * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
20 * の無保証規定を掲載すること.
21 * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
22 * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
23 * と.
24 * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
25 * 作権表示,この利用条件および下記の無保証規定を掲載すること.
26 * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
27 * 報告すること.
28 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
29 * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
30 * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
31 * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
32 * 免責すること.
33 *
34 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
35 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
36 * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
37 * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
38 * の責任を負わない.
39 *
40 * @(#) $Id: t_syslog.h 108 2015-06-11 09:15:46Z coas-nagasima $
41 */
42
43/*
44 * システムログ出力を行うための定義
45 *
46 * システムログサービスは,システムのログ情報を出力するためのサービス
47 * である.カーネルからのログ情報の出力にも用いるため,内部で待ち状態
48 * にはいることはない.
49 *
50 * ログ情報は,カーネル内のログバッファに書き込むか,低レベルの文字出
51 * 力関数を用いて出力する.どちらを使うかは,拡張サービスコールで切り
52 * 換えることができる.
53 *
54 * ログバッファ領域がオーバフローした場合には,古いログ情報を消して上
55 * 書きする.
56 *
57 * アセンブリ言語のソースファイルからこのファイルをインクルードする時
58 * は,TOPPERS_MACRO_ONLYを定義しておくことで,マクロ定義以外の記述を
59 * 除くことができる.
60 *
61 * このファイルをインクルードする前に,t_stddef.hをインクルードしてお
62 * くことが必要である.
63 */
64
65#ifndef TOPPERS_T_SYSLOG_H
66#define TOPPERS_T_SYSLOG_H
67
68#ifdef __cplusplus
69extern "C" {
70#endif
71
72/*
73 * ログ情報の種別の定義
74 */
75#define LOG_TYPE_COMMENT UINT_C(0x01) /* コメント */
76#define LOG_TYPE_ASSERT UINT_C(0x02) /* アサーションの失敗 */
77
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) /* サービスコール */
88
89#define LOG_ENTER UINT_C(0x00) /* 入口/開始 */
90#define LOG_LEAVE UINT_C(0x80) /* 出口/終了 */
91
92/*
93 * ログ情報の重要度の定義
94 */
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) /* デバッグ用メッセージ */
103
104#ifndef TOPPERS_MACRO_ONLY
105
106/*
107 * ログ情報のデータ構造
108 */
109
110#define TMAX_LOGINFO 6
111
112typedef struct {
113 uint_t logtype; /* ログ情報の種別 */
114 SYSTIM logtim; /* ログ時刻 */
115 intptr_t loginfo[TMAX_LOGINFO]; /* その他のログ情報 */
116} SYSLOG;
117
118/*
119 * ログ情報の重要度のビットマップを作るためのマクロ
120 */
121#define LOG_MASK(prio) (1U << (prio))
122#define LOG_UPTO(prio) ((1U << ((prio) + 1)) - 1)
123
124/*
125 * ログ情報を出力するためのライブラリ関数
126 */
127
128#ifndef TOPPERS_OMIT_SYSLOG
129
130extern ER syslog_wri_log(uint_t prio, const SYSLOG *p_syslog) throw();
131
132Inline void
133_syslog_0(uint_t prio, uint_t type)
134{
135 SYSLOG syslog;
136
137 syslog.logtype = type;
138 (void) syslog_wri_log(prio, &syslog);
139}
140
141Inline void
142_syslog_1(uint_t prio, uint_t type, intptr_t arg1)
143{
144 SYSLOG syslog;
145
146 syslog.logtype = type;
147 syslog.loginfo[0] = arg1;
148 (void) syslog_wri_log(prio, &syslog);
149}
150
151Inline void
152_syslog_2(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2)
153{
154 SYSLOG syslog;
155
156 syslog.logtype = type;
157 syslog.loginfo[0] = arg1;
158 syslog.loginfo[1] = arg2;
159 (void) syslog_wri_log(prio, &syslog);
160}
161
162Inline void
163_syslog_3(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
164 intptr_t arg3)
165{
166 SYSLOG syslog;
167
168 syslog.logtype = type;
169 syslog.loginfo[0] = arg1;
170 syslog.loginfo[1] = arg2;
171 syslog.loginfo[2] = arg3;
172 (void) syslog_wri_log(prio, &syslog);
173}
174
175Inline void
176_syslog_4(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
177 intptr_t arg3, intptr_t arg4)
178{
179 SYSLOG syslog;
180
181 syslog.logtype = type;
182 syslog.loginfo[0] = arg1;
183 syslog.loginfo[1] = arg2;
184 syslog.loginfo[2] = arg3;
185 syslog.loginfo[3] = arg4;
186 (void) syslog_wri_log(prio, &syslog);
187}
188
189Inline void
190_syslog_5(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
191 intptr_t arg3, intptr_t arg4, intptr_t arg5)
192{
193 SYSLOG syslog;
194
195 syslog.logtype = type;
196 syslog.loginfo[0] = arg1;
197 syslog.loginfo[1] = arg2;
198 syslog.loginfo[2] = arg3;
199 syslog.loginfo[3] = arg4;
200 syslog.loginfo[4] = arg5;
201 (void) syslog_wri_log(prio, &syslog);
202}
203
204Inline void
205_syslog_6(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
206 intptr_t arg3, intptr_t arg4, intptr_t arg5, intptr_t arg6)
207{
208 SYSLOG syslog;
209
210 syslog.logtype = type;
211 syslog.loginfo[0] = arg1;
212 syslog.loginfo[1] = arg2;
213 syslog.loginfo[2] = arg3;
214 syslog.loginfo[3] = arg4;
215 syslog.loginfo[4] = arg5;
216 syslog.loginfo[5] = arg6;
217 (void) syslog_wri_log(prio, &syslog);
218}
219
220/*
221 * ログ情報(コメント)を出力するためのライブラリ関数(vasyslog.c)
222 */
223extern void syslog(uint_t prio, const char *format, ...) throw();
224
225#else /* TOPPERS_OMIT_SYSLOG */
226
227/*
228 * システムログ出力を抑止する場合
229 */
230
231Inline void
232_syslog_0(uint_t prio, uint_t type)
233{
234}
235
236Inline void
237_syslog_1(uint_t prio, uint_t type, intptr_t arg1)
238{
239}
240
241Inline void
242_syslog_2(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2)
243{
244}
245
246Inline void
247_syslog_3(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
248 intptr_t arg3)
249{
250}
251
252Inline void
253_syslog_4(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
254 intptr_t arg3, intptr_t arg4)
255{
256}
257
258Inline void
259_syslog_5(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
260 intptr_t arg3, intptr_t arg4, intptr_t arg5)
261{
262}
263
264Inline void
265_syslog_6(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
266 intptr_t arg3, intptr_t arg4, intptr_t arg5, intptr_t arg6)
267{
268}
269
270Inline void
271syslog(uint_t prio, const char *format, ...)
272{
273}
274
275#endif /* TOPPERS_OMIT_SYSLOG */
276
277/*
278 * ログ情報(コメント)を出力するためのマクロ
279 *
280 * formatおよび後続の引数から作成したメッセージを,重大度prioでログ情
281 * 報として出力するためのマクロ.arg1〜argnはintptr_t型にキャストする
282 * ため,intptr_t型に型変換できる任意の型でよい.
283 */
284
285#define syslog_0(prio, format) \
286 _syslog_1(prio, LOG_TYPE_COMMENT, (intptr_t) format)
287
288#define syslog_1(prio, format, arg1) \
289 _syslog_2(prio, LOG_TYPE_COMMENT, (intptr_t) format, \
290 (intptr_t)(arg1))
291
292#define syslog_2(prio, format, arg1, arg2) \
293 _syslog_3(prio, LOG_TYPE_COMMENT, (intptr_t) format, \
294 (intptr_t)(arg1), (intptr_t)(arg2))
295
296#define syslog_3(prio, format, arg1, arg2, arg3) \
297 _syslog_4(prio, LOG_TYPE_COMMENT, (intptr_t) format, \
298 (intptr_t)(arg1), (intptr_t)(arg2), (intptr_t)(arg3))
299
300#define syslog_4(prio, format, arg1, arg2, arg3, arg4) \
301 _syslog_5(prio, LOG_TYPE_COMMENT, (intptr_t) format, \
302 (intptr_t)(arg1), (intptr_t)(arg2), (intptr_t)(arg3), \
303 (intptr_t)(arg4))
304
305#define syslog_5(prio, format, arg1, arg2, arg3, arg4, arg5) \
306 _syslog_6(prio, LOG_TYPE_COMMENT, (intptr_t) format, \
307 (intptr_t)(arg1), (intptr_t)(arg2), (intptr_t)(arg3), \
308 (intptr_t)(arg4), (intptr_t)(arg5))
309
310/*
311 * ログ情報(アサーションの失敗)を出力するためのマクロ
312 */
313#ifndef TOPPERS_assert_fail
314#define TOPPERS_assert_fail(exp, file, line) \
315 _syslog_3(LOG_EMERG, LOG_TYPE_ASSERT, (intptr_t)(file), \
316 (intptr_t)(line), (intptr_t)(exp))
317#endif /* TOPPERS_assert_fail */
318
319#endif /* TOPPERS_MACRO_ONLY */
320
321#ifdef __cplusplus
322}
323#endif
324
325#endif /* TOPPERS_T_SYSLOG_H */
Note: See TracBrowser for help on using the repository browser.