t_syslog.h

説明を見る。
00001 /*
00002  *  TOPPERS/ASP Kernel
00003  *      Toyohashi Open Platform for Embedded Real-Time Systems/
00004  *      Advanced Standard Profile Kernel
00005  * 
00006  *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
00007  *                              Toyohashi Univ. of Technology, JAPAN
00008  *  Copyright (C) 2004-2008 by Embedded and Real-Time Systems Laboratory
00009  *              Graduate School of Information Science, Nagoya Univ., JAPAN
00010  * 
00011  *  上記著作権者は,以下の(1)〜(4)の条件を満たす場合に限り,本ソフトウェ
00012  *  ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
00013  *  変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
00014  *  (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
00015  *      権表示,この利用条件および下記の無保証規定が,そのままの形でソー
00016  *      スコード中に含まれていること.
00017  *  (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
00018  *      用できる形で再配布する場合には,再配布に伴うドキュメント(利用
00019  *      者マニュアルなど)に,上記の著作権表示,この利用条件および下記
00020  *      の無保証規定を掲載すること.
00021  *  (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
00022  *      用できない形で再配布する場合には,次のいずれかの条件を満たすこ
00023  *      と.
00024  *    (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
00025  *        作権表示,この利用条件および下記の無保証規定を掲載すること.
00026  *    (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
00027  *        報告すること.
00028  *  (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
00029  *      害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
00030  *      また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
00031  *      由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
00032  *      免責すること.
00033  * 
00034  *  本ソフトウェアは,無保証で提供されているものである.上記著作権者お
00035  *  よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
00036  *  に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
00037  *  アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
00038  *  の責任を負わない.
00039  * 
00040  *  @(#) $Id: t_syslog.h 775 2008-03-08 06:36:44Z hiro $
00041  */
00042 
00043 /*
00044  *      システムログ出力を行うための定義
00045  *
00046  *  システムログサービスは,システムのログ情報を出力するためのサービス
00047  *  である.カーネルからのログ情報の出力にも用いるため,内部で待ち状態
00048  *  にはいることはない.
00049  *
00050  *  ログ情報は,カーネル内のログバッファに書き込むか,低レベルの文字出
00051  *  力関数を用いて出力する.どちらを使うかは,拡張サービスコールで切り
00052  *  換えることができる.
00053  *
00054  *  ログバッファ領域がオーバフローした場合には,古いログ情報を消して上
00055  *  書きする.
00056  *
00057  *  アセンブリ言語のソースファイルからこのファイルをインクルードする時
00058  *  は,TOPPERS_MACRO_ONLYを定義しておくことで,マクロ定義以外の記述を
00059  *  除くことができる.
00060  *
00061  *  このファイルをインクルードする前に,t_stddef.hをインクルードしてお
00062  *  くことが必要である.
00063  */
00064 
00065 #ifndef TOPPERS_T_SYSLOG_H
00066 #define TOPPERS_T_SYSLOG_H
00067 
00068 #ifdef __cplusplus
00069 extern "C" {
00070 #endif
00071 
00072 /*
00073  *  ログ情報の種別の定義
00074  */
00075 #define LOG_TYPE_COMMENT    UINT_C(0x01)    /* コメント */
00076 #define LOG_TYPE_ASSERT     UINT_C(0x02)    /* アサーションの失敗 */
00077 
00078 #define LOG_TYPE_INH        UINT_C(0x11)    /* 割込みハンドラ */
00079 #define LOG_TYPE_ISR        UINT_C(0x12)    /* 割込みサービスルーチン */
00080 #define LOG_TYPE_CYC        UINT_C(0x13)    /* 周期ハンドラ */
00081 #define LOG_TYPE_ALM        UINT_C(0x14)    /* アラームハンドラ */
00082 #define LOG_TYPE_OVR        UINT_C(0x15)    /* オーバランハンドラ */
00083 #define LOG_TYPE_EXC        UINT_C(0x16)    /* CPU例外ハンドラ */
00084 #define LOG_TYPE_TEX        UINT_C(0x17)    /* タスク例外処理ルーチン */
00085 #define LOG_TYPE_TSKSTAT    UINT_C(0x18)    /* タスク状態変化 */
00086 #define LOG_TYPE_DSP        UINT_C(0x19)    /* ディスパッチャ */
00087 #define LOG_TYPE_SVC        UINT_C(0x1a)    /* サービスコール */
00088 
00089 #define LOG_ENTER           UINT_C(0x00)    /* 入口/開始 */
00090 #define LOG_LEAVE           UINT_C(0x80)    /* 出口/終了 */
00091 
00092 /*
00093  *  ログ情報の重要度の定義
00094  */
00095 #define LOG_EMERG           UINT_C(0)       /* シャットダウンに値するエラー */
00096 #define LOG_ALERT           UINT_C(1)
00097 #define LOG_CRIT            UINT_C(2)
00098 #define LOG_ERROR           UINT_C(3)       /* システムエラー */
00099 #define LOG_WARNING         UINT_C(4)       /* 警告メッセージ */
00100 #define LOG_NOTICE          UINT_C(5)
00101 #define LOG_INFO            UINT_C(6)
00102 #define LOG_DEBUG           UINT_C(7)       /* デバッグ用メッセージ */
00103 
00104 #ifndef TOPPERS_MACRO_ONLY
00105 
00106 /*
00107  *  ログ情報のデータ構造
00108  */
00109 
00110 #define TMAX_LOGINFO    6
00111 
00112 typedef struct {
00113     uint_t      logtype;                /* ログ情報の種別 */
00114     SYSTIM      logtim;                 /* ログ時刻 */
00115     intptr_t    loginfo[TMAX_LOGINFO];  /* その他のログ情報 */
00116 } SYSLOG;
00117 
00118 /*
00119  *  ログ情報の重要度のビットマップを作るためのマクロ
00120  */
00121 #define LOG_MASK(prio)      (1U << (prio))
00122 #define LOG_UPTO(prio)      ((1U << ((prio) + 1)) - 1)
00123 
00124 /*
00125  *  パケット形式の定義
00126  */
00127 typedef struct t_syslog_rlog {
00128     uint_t  count;      /* ログバッファ中のログの数 */
00129     uint_t  lost;       /* 失われたログの数 */
00130     uint_t  logmask;    /* ログバッファに記録すべき重要度 */
00131     uint_t  lowmask;    /* 低レベル出力すべき重要度 */
00132 } T_SYSLOG_RLOG;
00133 
00134 #ifndef TOPPERS_OMIT_SYSLOG
00135 
00136 /*
00137  *  ログ情報を出力するためのライブラリ関数
00138  */
00139 
00140 extern ER   syslog_wri_log(uint_t prio, SYSLOG *p_syslog) throw();
00141 
00142 Inline void
00143 _syslog_0(uint_t prio, uint_t type)
00144 {
00145     SYSLOG  syslog;
00146 
00147     syslog.logtype = type;
00148     (void) syslog_wri_log(prio, &syslog);
00149 }
00150 
00151 Inline void
00152 _syslog_1(uint_t prio, uint_t type, intptr_t arg1)
00153 {
00154     SYSLOG  syslog;
00155 
00156     syslog.logtype = type;
00157     syslog.loginfo[0] = arg1;
00158     (void) syslog_wri_log(prio, &syslog);
00159 }
00160 
00161 Inline void
00162 _syslog_2(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2)
00163 {
00164     SYSLOG  syslog;
00165 
00166     syslog.logtype = type;
00167     syslog.loginfo[0] = arg1;
00168     syslog.loginfo[1] = arg2;
00169     (void) syslog_wri_log(prio, &syslog);
00170 }
00171 
00172 Inline void
00173 _syslog_3(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
00174                                                         intptr_t arg3)
00175 {
00176     SYSLOG  syslog;
00177 
00178     syslog.logtype = type;
00179     syslog.loginfo[0] = arg1;
00180     syslog.loginfo[1] = arg2;
00181     syslog.loginfo[2] = arg3;
00182     (void) syslog_wri_log(prio, &syslog);
00183 }
00184 
00185 Inline void
00186 _syslog_4(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
00187                                         intptr_t arg3, intptr_t arg4)
00188 {
00189     SYSLOG  syslog;
00190 
00191     syslog.logtype = type;
00192     syslog.loginfo[0] = arg1;
00193     syslog.loginfo[1] = arg2;
00194     syslog.loginfo[2] = arg3;
00195     syslog.loginfo[3] = arg4;
00196     (void) syslog_wri_log(prio, &syslog);
00197 }
00198 
00199 Inline void
00200 _syslog_5(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
00201                             intptr_t arg3, intptr_t arg4, intptr_t arg5)
00202 {
00203     SYSLOG  syslog;
00204 
00205     syslog.logtype = type;
00206     syslog.loginfo[0] = arg1;
00207     syslog.loginfo[1] = arg2;
00208     syslog.loginfo[2] = arg3;
00209     syslog.loginfo[3] = arg4;
00210     syslog.loginfo[4] = arg5;
00211     (void) syslog_wri_log(prio, &syslog);
00212 }
00213 
00214 Inline void
00215 _syslog_6(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
00216                 intptr_t arg3, intptr_t arg4, intptr_t arg5, intptr_t arg6)
00217 {
00218     SYSLOG  syslog;
00219 
00220     syslog.logtype = type;
00221     syslog.loginfo[0] = arg1;
00222     syslog.loginfo[1] = arg2;
00223     syslog.loginfo[2] = arg3;
00224     syslog.loginfo[3] = arg4;
00225     syslog.loginfo[4] = arg5;
00226     syslog.loginfo[5] = arg6;
00227     (void) syslog_wri_log(prio, &syslog);
00228 }
00229 
00230 /*
00231  *  ログ情報(コメント)を出力するためのライブラリ関数(vasyslog.c)
00232  */
00233 extern void syslog(uint_t prio, const char *format, ...) throw();
00234 
00235 #else /* TOPPERS_OMIT_SYSLOG */
00236 
00237 /*
00238  *  システムログ出力を抑止する場合
00239  */
00240 
00241 Inline void
00242 _syslog_0(uint_t prio, uint_t type)
00243 {
00244 }
00245 
00246 Inline void
00247 _syslog_1(uint_t prio, uint_t type, intptr_t arg1)
00248 {
00249 }
00250 
00251 Inline void
00252 _syslog_2(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2)
00253 {
00254 }
00255 
00256 Inline void
00257 _syslog_3(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
00258                                                         intptr_t arg3)
00259 {
00260 }
00261 
00262 Inline void
00263 _syslog_4(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
00264                                         intptr_t arg3, intptr_t arg4)
00265 {
00266 }
00267 
00268 Inline void
00269 _syslog_5(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
00270                             intptr_t arg3, intptr_t arg4, intptr_t arg5)
00271 {
00272 }
00273 
00274 Inline void
00275 _syslog_6(uint_t prio, uint_t type, intptr_t arg1, intptr_t arg2,
00276                 intptr_t arg3, intptr_t arg4, intptr_t arg5, intptr_t arg6)
00277 {
00278 }
00279 
00280 Inline void
00281 syslog(uint_t prio, const char *format, ...)
00282 {
00283 }
00284 
00285 #endif /* TOPPERS_OMIT_SYSLOG */
00286 
00287 /*
00288  *  ログ情報(コメント)を出力するためのマクロ
00289  *
00290  *  formatおよび後続の引数から作成したメッセージを,重大度prioでログ情
00291  *  報として出力するためのマクロ.arg1〜argnはintptr_t型にキャストする
00292  *  ため,intptr_t型に型変換できる任意の型でよい.
00293  */
00294 
00295 #define syslog_0(prio, format) \
00296                 _syslog_1(prio, LOG_TYPE_COMMENT, (intptr_t) format)
00297 
00298 #define syslog_1(prio, format, arg1) \
00299                 _syslog_2(prio, LOG_TYPE_COMMENT, (intptr_t) format, \
00300                                                         (intptr_t)(arg1))
00301 
00302 #define syslog_2(prio, format, arg1, arg2) \
00303                 _syslog_3(prio, LOG_TYPE_COMMENT, (intptr_t) format, \
00304                                         (intptr_t)(arg1), (intptr_t)(arg2))
00305 
00306 #define syslog_3(prio, format, arg1, arg2, arg3) \
00307                 _syslog_4(prio, LOG_TYPE_COMMENT, (intptr_t) format, \
00308                         (intptr_t)(arg1), (intptr_t)(arg2), (intptr_t)(arg3))
00309 
00310 #define syslog_4(prio, format, arg1, arg2, arg3, arg4) \
00311                 _syslog_5(prio, LOG_TYPE_COMMENT, (intptr_t) format, \
00312                         (intptr_t)(arg1), (intptr_t)(arg2), (intptr_t)(arg3), \
00313                                                         (intptr_t)(arg4))
00314 
00315 #define syslog_5(prio, format, arg1, arg2, arg3, arg4, arg5) \
00316                 _syslog_6(prio, LOG_TYPE_COMMENT, (intptr_t) format, \
00317                         (intptr_t)(arg1), (intptr_t)(arg2), (intptr_t)(arg3), \
00318                                         (intptr_t)(arg4), (intptr_t)(arg5))
00319 
00320 /*
00321  *  ログ情報(アサーションの失敗)を出力するためのマクロ
00322  */
00323 #ifndef TOPPERS_assert_fail
00324 #define TOPPERS_assert_fail(exp, file, line) \
00325                 _syslog_3(LOG_EMERG, LOG_TYPE_ASSERT, (intptr_t)(file), \
00326                                         (intptr_t)(line), (intptr_t)(exp))
00327 #endif /* TOPPERS_assert_fail */
00328 
00329 #endif /* TOPPERS_MACRO_ONLY */
00330 
00331 #ifdef __cplusplus
00332 }
00333 #endif
00334 
00335 #endif /* TOPPERS_T_SYSLOG_H */

Copyright © 2008 by Kijineko Inc.

ホームページ制作