[93] | 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{\tgEF
|
---|
| 14 | * Ai{\tgEFAðüϵ½àÌðÜÞDȺ¯¶jðgpE¡»Eü
|
---|
| 15 | * ÏEÄzziȺCpÆÄÔj·é±Æð³Åø·éD
|
---|
| 16 | * (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
|
---|
| 17 | * \¦C±Ìpð¨æѺL̳ÛØKèªC»ÌÜÜÌ`Å\[
|
---|
| 18 | * XR[hÉÜÜêÄ¢é±ÆD
|
---|
| 19 | * (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJÉg
|
---|
| 20 | * pÅ«é`ÅÄzz·éêÉÍCÄzzɺ¤hL
|
---|
| 21 | gip
|
---|
| 22 | * Ò}j
|
---|
| 23 | AÈÇjÉCãLÌì \¦C±Ìpð¨æѺL
|
---|
| 24 | * ̳ÛØKèðfÚ·é±ÆD
|
---|
| 25 | * (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJÉg
|
---|
| 26 | * pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
|
---|
| 27 | * ÆD
|
---|
| 28 | * (a) Äzzɺ¤hL
|
---|
| 29 | gipÒ}j
|
---|
| 30 | AÈÇjÉCãLÌ
|
---|
| 31 | * ì \¦C±Ìpð¨æѺL̳ÛØKèðfÚ·é±ÆD
|
---|
| 32 | * (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
|
---|
| 33 | * ñ·é±ÆD
|
---|
| 34 | * (4) {\tgEFAÌpÉæè¼ÚIܽÍÔÚIɶ¶é¢©Èé¹
|
---|
| 35 | * Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
|
---|
| 36 | * ܽC{\tgEFAÌ[UܽÍGh[U©çÌ¢©Èé
|
---|
| 37 | * RÉîÿ©çàCãLì Ò¨æÑTOPPERSvWFNgð
|
---|
| 38 | * ÆÓ·é±ÆD
|
---|
| 39 | *
|
---|
| 40 | * {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
|
---|
| 41 | * æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
|
---|
| 42 | * ÉηéK«àÜßÄC¢©ÈéÛØàsíÈ¢DܽC{\tgEF
|
---|
| 43 | * AÌpÉæè¼ÚIܽÍÔÚIɶ¶½¢©Èé¹QÉÖµÄàC»
|
---|
| 44 | * ÌÓCðíÈ¢D
|
---|
| 45 | *
|
---|
| 46 | * @(#) $Id: logtask.c 1111 2008-06-12 08:42:26Z ertl-hiro $
|
---|
| 47 | */
|
---|
| 48 |
|
---|
| 49 | /*
|
---|
| 50 | * VXeO^XN
|
---|
| 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 | * VXeO^XNÌoÍæÌ|[gID
|
---|
| 62 | */
|
---|
| 63 | static ID logtask_portid;
|
---|
| 64 |
|
---|
| 65 | /*
|
---|
| 66 | * VAC^tF[XÖÌ1¶oÍ
|
---|
| 67 | */
|
---|
| 68 | static void
|
---|
| 69 | logtask_putc(char c)
|
---|
| 70 | {
|
---|
| 71 | serial_wri_dat(logtask_portid, &c, 1);
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | /*
|
---|
| 75 | * O^XNÌú»
|
---|
| 76 | */
|
---|
| 77 |
|
---|
| 78 | void 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 | * VXeO^XNÌ{Ì
|
---|
| 88 | */
|
---|
| 89 | void
|
---|
| 90 | logtask_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 |
|
---|
| 112 | void cychdr_act_logtsk(intptr_t exinf)
|
---|
| 113 | {
|
---|
| 114 | iact_tsk((ID)exinf);
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | /*
|
---|
| 118 | * VXeO^XNÌI¹
|
---|
| 119 | */
|
---|
| 120 | void
|
---|
| 121 | logtask_terminate(intptr_t exinf)
|
---|
| 122 | {
|
---|
| 123 | char c;
|
---|
| 124 | SYSLOG syslog;
|
---|
| 125 | bool_t msgflg = false;
|
---|
| 126 | ER_UINT rercd;
|
---|
| 127 |
|
---|
| 128 | /*
|
---|
| 129 | * VAC^tF[XhCoÌMobt@É~ϳê½f[^
|
---|
| 130 | * ðCáxoÍ@\ðp¢ÄoÍ·éD
|
---|
| 131 | */
|
---|
| 132 | while (serial_get_chr(logtask_portid, &c)) {
|
---|
| 133 | target_fput_log(c);
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 | /*
|
---|
| 137 | * Oobt@ÉL^³ê½OîñðCáxoÍ@\ðp¢Äo
|
---|
| 138 | * Í·éD
|
---|
| 139 | */
|
---|
| 140 | while ((rercd = syslog_rea_log(&syslog)) >= 0) {
|
---|
| 141 | if (!msgflg) {
|
---|
| 142 | /*
|
---|
| 143 | * Oobt@É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 | }
|
---|