source: uKadecot/trunk/ssp/syssvc/logtask.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: 4.2 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-2008 by Embedded and Real-Time Systems Laboratory
8 * Graduate School of Information Science, Nagoya Univ., JAPAN
9 * Copyright (C) 2010-2012 by Meika Sugimoto
10 * Copyright (C) 2015 by Naoki Saito
11 * Nagoya Municipal Industrial Research Institute, JAPAN
12 *
13 * ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì(1)`(4)‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
14 * ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü
15 * •ÏEÄ”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
16 * (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ì
17 * Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[
18 * ƒXƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
19 * (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
20 * —p‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
21ƒƒ“ƒgi—˜—p
22 * ŽÒƒ}ƒjƒ…
23ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L
24 * ‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
25 * (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
26 * —p‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±
27 * ‚ƁD
28 * (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
29ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
30ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜
31 * ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
32 * (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É
33 * •ñ‚·‚邱‚ƁD
34 * (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹
35 * ŠQ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
36 * ‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝
37 * —R‚ÉŠî‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð
38 * –Ɛӂ·‚邱‚ƁD
39 *
40 * –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨
41 * ‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC“Á’è‚ÌŽg—p–Ú“I
42 * ‚ɑ΂·‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒF
43 * ƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»
44 * ‚̐ӔC‚𕉂í‚È‚¢D
45 *
46 * @(#) $Id: logtask.c 101 2015-06-02 15:37:23Z coas-nagasima $
47 */
48
49/*
50 * ƒVƒXƒeƒ€ƒƒOƒ^ƒXƒN
51 */
52
53#include <kernel.h>
54#include <t_syslog.h>
55#include <log_output.h>
56#include "syssvc/serial.h"
57#include "syssvc/syslog.h"
58#include "logtask.h"
59
60/*
61 * ƒVƒXƒeƒ€ƒƒOƒ^ƒXƒN‚̏o—͐æ‚̃|[ƒgID
62 */
63static ID logtask_portid;
64
65/*
66 * ƒVƒŠƒAƒ‹ƒCƒ“ƒ^ƒtƒF[ƒX‚Ö‚Ì1•¶Žšo—Í
67 */
68static void
69logtask_putc(char c)
70{
71 serial_wri_dat(logtask_portid, &c, 1);
72}
73
74/*
75 * ƒƒOƒ^ƒXƒN‚̏‰Šú‰»ˆ—
76 */
77
78void logtask_initialize(ID log_portid)
79{
80 logtask_portid = log_portid;
81 serial_opn_por(logtask_portid);
82 syslog_msk_log(LOG_UPTO(LOG_INFO), LOG_UPTO(LOG_EMERG));
83 syslog_1(LOG_NOTICE, "System logging task is started on port %d.",
84 logtask_portid);
85}
86/*
87 * ƒVƒXƒeƒ€ƒƒOƒ^ƒXƒN‚Ì–{‘Ì
88 */
89void
90logtask_main(intptr_t exinf)
91{
92 SYSLOG syslog;
93 static uint_t lost = 0;
94 ER_UINT rercd;
95
96 while ((rercd = syslog_rea_log(&syslog)) >= 0) {
97 lost += (uint_t) rercd;
98 if (syslog.logtype >= LOG_TYPE_COMMENT) {
99 if (lost > 0U) {
100 syslog_lostmsg(lost, logtask_putc);
101 lost = 0U;
102 }
103 syslog_print(&syslog, logtask_putc);
104 logtask_putc('\n');
105 }
106 }
107 if (lost > 0U) {
108 syslog_lostmsg(lost, logtask_putc);
109 }
110}
111
112void cychdr_act_logtsk(intptr_t exinf)
113{
114 iact_tsk((ID)exinf);
115}
116
117/*
118 * ƒVƒXƒeƒ€ƒƒOƒ^ƒXƒN‚̏I—¹ˆ—
119 */
120void
121logtask_terminate(intptr_t exinf)
122{
123 char c;
124 SYSLOG syslog;
125 bool_t msgflg = false;
126 ER_UINT rercd;
127
128 /*
129 * ƒVƒŠƒAƒ‹ƒCƒ“ƒ^ƒtƒF[ƒXƒhƒ‰ƒCƒo‚Ì‘—Mƒoƒbƒtƒ@‚É’~Ï‚³‚ꂽƒf[ƒ^
130 * ‚ðC’჌ƒxƒ‹o—Í‹@”\‚ð—p‚¢‚ďo—Í‚·‚éD
131 */
132 while (serial_get_chr(logtask_portid, &c)) {
133 target_fput_log(c);
134 }
135
136 /*
137 * ƒƒOƒoƒbƒtƒ@‚É‹L˜^‚³‚ꂽƒƒOî•ñ‚ðC’჌ƒxƒ‹o—Í‹@”\‚ð—p‚¢‚ďo
138 * —Í‚·‚éD
139 */
140 while ((rercd = syslog_rea_log(&syslog)) >= 0) {
141 if (!msgflg) {
142 /*
143 * ƒƒOƒoƒbƒtƒ@‚ÉŽc‚Á‚½ƒƒOî•ñ‚Å‚ ‚邱‚Æ‚ðŽ¦‚·•¶Žš—ñ‚ðo
144 * —Í‚·‚éD
145 */
146 syslog_printf("-- buffered messages --\n", NULL, target_fput_log);
147 msgflg = true;
148 }
149 if (rercd > 0) {
150 syslog_lostmsg((uint_t) rercd, target_fput_log);
151 }
152 if (syslog.logtype >= LOG_TYPE_COMMENT) {
153 syslog_print(&syslog, target_fput_log);
154 target_fput_log('\n');
155 }
156 }
157}
Note: See TracBrowser for help on using the repository browser.