source: uKadecot/trunk/ssp/syssvc/syslog.c@ 101

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

TOPPERS/uKadecotのソースコードを追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/plain
File size: 5.7 KB
Line 
1/*
2 * TOPPERS/SSP Kernel
3 * Smallest Set Profile Kernel
4 *
5 * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
6 * Toyohashi Univ. of Technology, JAPAN
7 * Copyright (C) 2005-2010 by Embedded and Real-Time Systems Laboratory
8 * Graduate School of Information Science, Nagoya Univ., JAPAN
9 *
10 * ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì(1)`(4)‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
11 * ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü
12 * •ÏEÄ”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
13 * (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ì
14 * Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[
15 * ƒXƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
16 * (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
17 * —p‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
18ƒƒ“ƒgi—˜—p
19 * ŽÒƒ}ƒjƒ…
20ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L
21 * ‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
22 * (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
23 * —p‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±
24 * ‚ƁD
25 * (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
26ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
27ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜
28 * ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
29 * (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É
30 * •ñ‚·‚邱‚ƁD
31 * (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹
32 * ŠQ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
33 * ‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝
34 * —R‚ÉŠî‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð
35 * –Ɛӂ·‚邱‚ƁD
36 *
37 * –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨
38 * ‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC“Á’è‚ÌŽg—p–Ú“I
39 * ‚ɑ΂·‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒF
40 * ƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»
41 * ‚̐ӔC‚𕉂í‚È‚¢D
42 *
43 * $Id: syslog.c 101 2015-06-02 15:37:23Z coas-nagasima $
44 */
45
46/*
47 * ƒVƒXƒeƒ€ƒƒO‹@”\
48 */
49
50#include <sil.h>
51#undef TOPPERS_OMIT_SYSLOG
52#include <t_syslog.h>
53#include <log_output.h>
54#include "target_syssvc.h"
55#include "syslog.h"
56
57/*
58 * ƒgƒŒ[ƒXƒƒOƒ}ƒNƒ‚̃fƒtƒHƒ‹ƒg’è‹`
59 */
60#ifndef LOG_SYSLOG_WRI_LOG_ENTER
61#define LOG_SYSLOG_WRI_LOG_ENTER(prio, p_syslog)
62#endif /* LOG_SYSLOG_WRI_LOG_ENTER */
63
64#ifndef LOG_SYSLOG_WRI_LOG_LEAVE
65#define LOG_SYSLOG_WRI_LOG_LEAVE(ercd)
66#endif /* LOG_SYSLOG_WRI_LOG_LEAVE */
67
68#ifndef LOG_SYSLOG_REA_LOG_ENTER
69#define LOG_SYSLOG_REA_LOG_ENTER(p_syslog)
70#endif /* LOG_SYSLOG_REA_LOG_ENTER */
71
72#ifndef LOG_SYSLOG_REA_LOG_LEAVE
73#define LOG_SYSLOG_REA_LOG_LEAVE(ercd, p_syslog)
74#endif /* LOG_SYSLOG_REA_LOG_LEAVE */
75
76#ifndef LOG_SYSLOG_MSK_LOG_ENTER
77#define LOG_SYSLOG_MSK_LOG_ENTER(logmask, lowmask)
78#endif /* LOG_SYSLOG_MSK_LOG_ENTER */
79
80#ifndef LOG_SYSLOG_MSK_LOG_LEAVE
81#define LOG_SYSLOG_MSK_LOG_LEAVE(ercd)
82#endif /* LOG_SYSLOG_MSK_LOG_LEAVE */
83
84#ifndef LOG_SYSLOG_REF_LOG_ENTER
85#define LOG_SYSLOG_REF_LOG_ENTER(pk_rlog)
86#endif /* LOG_SYSLOG_REF_LOG_ENTER */
87
88#ifndef LOG_SYSLOG_REF_LOG_LEAVE
89#define LOG_SYSLOG_REF_LOG_LEAVE(pk_rlog)
90#endif /* LOG_SYSLOG_REF_LOG_LEAVE */
91
92/*
93 * Œ»Ý‚̃VƒXƒeƒ€Žž
94 *
95 * ƒƒOŽž‚ðŽæ‚èo‚·‚½‚߂ɁC‚â‚Þ‚È‚­CƒJ[ƒlƒ‹‚Ì“à•”•Ï”‚ðŽQÆ‚µ‚Ä‚¢
96 * ‚éD
97 */
98extern ulong_t _kernel_current_time;
99
100/*
101 * ƒƒOƒoƒbƒtƒ@‚Æ‚»‚ê‚ɃAƒNƒZƒX‚·‚邽‚߂̃|ƒCƒ“ƒ^
102 */
103static SYSLOG syslog_buffer[TCNT_SYSLOG_BUFFER]; /* ƒƒOƒoƒbƒtƒ@ */
104static uint_t syslog_count; /* ƒƒOƒoƒbƒtƒ@’†‚̃ƒO‚̐” */
105static uint_t syslog_head; /* æ“ª‚̃ƒO‚ÌŠi”[ˆÊ’u */
106static uint_t syslog_tail; /* ŽŸ‚̃ƒO‚ÌŠi”[ˆÊ’u */
107static uint_t syslog_lost; /* Ž¸‚í‚ꂽƒƒO‚̐” */
108
109/*
110 * o—Í‚·‚ׂ«ƒƒOî•ñ‚̏d—v“xiƒrƒbƒgƒ}ƒbƒvj
111 */
112static uint_t syslog_logmask; /* ƒƒOƒoƒbƒtƒ@‚É‹L˜^‚·‚ׂ«d—v“x */
113static uint_t syslog_lowmask_not; /* ’჌ƒxƒ‹o—Í‚·‚ׂ«d—v“xi”½“]j*/
114
115/*
116 * ƒVƒXƒeƒ€ƒƒO‹@”\‚̏‰Šú‰»
117 */
118void
119syslog_initialize(intptr_t exinf)
120{
121 syslog_count = 0U;
122 syslog_head = syslog_tail = 0U;
123 syslog_lost = 0U;
124 syslog_logmask = 0U;
125 syslog_lowmask_not = 0U;
126}
127
128/*
129 * ƒƒOî•ñ‚̏o—Í
130 *
131 * CPUƒƒbƒNó‘Ô‚âŽÀsƒRƒ“ƒeƒLƒXƒg‚É‚æ‚炸“®ì‚Å‚«‚é‚悤‚ÉŽÀ‘•‚µ‚Ä‚ ‚éD
132 */
133ER
134syslog_wri_log(uint_t prio, const SYSLOG *p_syslog)
135{
136 SIL_PRE_LOC;
137
138 LOG_SYSLOG_WRI_LOG_ENTER(prio, p_syslog);
139 SIL_LOC_INT();
140
141 /*
142 * ƒƒOŽž‚̐ݒè
143 */
144 ((SYSLOG *) p_syslog)->logtim = _kernel_current_time;
145
146 /*
147 * ƒƒOƒoƒbƒtƒ@‚É‹L˜^
148 */
149 if ((syslog_logmask & LOG_MASK(prio)) != 0U) {
150 syslog_buffer[syslog_tail] = *p_syslog;
151 syslog_tail++;
152 if (syslog_tail >= TCNT_SYSLOG_BUFFER) {
153 syslog_tail = 0U;
154 }
155 if (syslog_count < TCNT_SYSLOG_BUFFER) {
156 syslog_count++;
157 }
158 else {
159 syslog_head = syslog_tail;
160 syslog_lost++;
161 }
162 }
163
164 /*
165 * ’჌ƒxƒ‹o—Í
166 */
167 if (((~syslog_lowmask_not) & LOG_MASK(prio)) != 0U) {
168 syslog_print(p_syslog, target_fput_log);
169 (*target_fput_log)('\n');
170 }
171
172 SIL_UNL_INT();
173 LOG_SYSLOG_WRI_LOG_LEAVE(E_OK);
174 return(E_OK);
175}
176
177/*
178 * ƒƒOƒoƒbƒtƒ@‚©‚ç‚̓Ǐo‚µ
179 *
180 * CPUƒƒbƒNó‘Ô‚âŽÀsƒRƒ“ƒeƒLƒXƒg‚É‚æ‚炸“®ì‚Å‚«‚é‚悤‚ÉŽÀ‘•‚µ‚Ä‚ ‚éD
181 */
182ER_UINT
183syslog_rea_log(SYSLOG *p_syslog)
184{
185 ER_UINT ercd;
186 SIL_PRE_LOC;
187
188 LOG_SYSLOG_REA_LOG_ENTER(p_syslog);
189 SIL_LOC_INT();
190
191 /*
192 * ƒƒOƒoƒbƒtƒ@‚©‚ç‚ÌŽæo‚µ
193 */
194 if (syslog_count > 0U) {
195 *p_syslog = syslog_buffer[syslog_head];
196 syslog_count--;
197 syslog_head++;
198 if (syslog_head >= TCNT_SYSLOG_BUFFER) {
199 syslog_head = 0U;
200 }
201 ercd = (ER_UINT) syslog_lost;
202 syslog_lost = 0U;
203 }
204 else {
205 ercd = E_OBJ;
206 }
207
208 SIL_UNL_INT();
209 LOG_SYSLOG_REA_LOG_LEAVE(ercd, p_syslog);
210 return(ercd);
211}
212
213/*
214 * o—Í‚·‚ׂ«ƒƒOî•ñ‚̏d—v“x‚̐ݒè
215 */
216ER
217syslog_msk_log(uint_t logmask, uint_t lowmask)
218{
219 LOG_SYSLOG_MSK_LOG_ENTER(logmask, lowmask);
220 syslog_logmask = logmask;
221 syslog_lowmask_not = ~lowmask;
222 LOG_SYSLOG_MSK_LOG_LEAVE(E_OK);
223 return(E_OK);
224}
Note: See TracBrowser for help on using the repository browser.