source: UsbWattMeter/trunk/asp_dcre/arch/logtrace/trace_config.c@ 164

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

TOPPERS/ECNLサンプルアプリ「USB充電器電力計」を追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-csrc
File size: 5.2 KB
Line 
1/*
2 * TOPPERS Software
3 * Toyohashi Open Platform for Embedded Real-Time Systems
4 *
5 * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
6 * Toyohashi Univ. of Technology, JAPAN
7 * Copyright (C) 2005-2011 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: trace_config.c 164 2016-03-07 11:33:50Z coas-nagasima $
44 */
45
46/*
47 * ƒgƒŒ[ƒXƒƒO‹@”\
48 */
49
50#include "kernel_impl.h"
51#include "task.h"
52#include "time_event.h"
53#include <sil.h>
54
55/*
56 * ƒgƒŒ[ƒXƒƒOƒoƒbƒtƒ@‚Æ‚»‚ê‚ɃAƒNƒZƒX‚·‚邽‚߂̃|ƒCƒ“ƒ^
57 */
58SYSLOG trace_buffer[TCNT_TRACE_BUFFER]; /* ƒgƒŒ[ƒXƒƒOƒoƒbƒtƒ@ */
59uint_t trace_count; /* ƒgƒŒ[ƒXƒƒOƒoƒbƒtƒ@’†‚̃ƒO‚̐” */
60uint_t trace_head; /* æ“ª‚̃gƒŒ[ƒXƒƒO‚ÌŠi”[ˆÊ’u */
61uint_t trace_tail; /* ŽŸ‚̃gƒŒ[ƒXƒƒO‚ÌŠi”[ˆÊ’u */
62MODE trace_mode; /* ƒgƒŒ[ƒXƒ‚[ƒh */
63
64/*
65 * ƒgƒŒ[ƒXƒƒO‹@”\‚̏‰Šú‰»
66 */
67void
68trace_initialize(intptr_t exinf)
69{
70 MODE mode = ((MODE) exinf);
71
72 trace_count = 0U;
73 trace_head = 0U;
74 trace_tail = 0U;
75 trace_mode = mode;
76}
77
78/*
79 * ƒgƒŒ[ƒXƒƒO‚ÌŠJŽn
80 */
81ER
82trace_sta_log(MODE mode)
83{
84 if ((mode & TRACE_CLEAR) != 0U) {
85 trace_count = 0U;
86 trace_head = 0U;
87 trace_tail = 0U;
88 }
89 trace_mode = mode;
90 return(E_OK);
91}
92
93/*
94 * ƒgƒŒ[ƒXƒƒO‚̏‘ž‚Ý
95 */
96ER
97trace_wri_log(TRACE *p_trace)
98{
99 SIL_PRE_LOC;
100
101 if (trace_mode != TRACE_STOP) {
102 SIL_LOC_INT();
103
104 /*
105 * ƒgƒŒ[ƒXŽž‚̐ݒè
106 *
107 * LOG_WRI_LOG_ENTER‚©‚çŒÄ‚΂ꂽê‡‚Ép_trace->logtim‚ð‘‚«Š·
108 * ‚¦‚Ä‚µ‚Ü‚¤‚Ì‚Í‹CŽ‚¿‚ªˆ«‚¢‚ªCwri_log‚Ì•û‚ŏ㏑‚«‚·‚邽‚ß–â
109 * ‘è‚Í‚È‚¢D
110 */
111 p_trace->logtim = TRACE_GET_TIM();
112
113 /*
114 * ƒgƒŒ[ƒXƒoƒbƒtƒ@‚É‹L˜^
115 */
116 trace_buffer[trace_tail] = *p_trace;
117 trace_tail++;
118 if (trace_tail >= TCNT_TRACE_BUFFER) {
119 trace_tail = 0U;
120 }
121 if (trace_count < TCNT_TRACE_BUFFER) {
122 trace_count++;
123 if (trace_count >= TCNT_TRACE_BUFFER
124 && (trace_mode & TRACE_AUTOSTOP) != 0U) {
125 trace_mode = TRACE_STOP;
126 }
127 }
128 else {
129 trace_head = trace_tail;
130 }
131
132 SIL_UNL_INT();
133 }
134 return(E_OK);
135}
136
137/*
138 * ƒgƒŒ[ƒXƒƒO‚̓Ǐo‚µ
139 */
140ER
141trace_rea_log(TRACE *p_trace)
142{
143 ER_UINT ercd;
144 SIL_PRE_LOC;
145
146 SIL_LOC_INT();
147
148 /*
149 * ƒgƒŒ[ƒXƒƒOƒoƒbƒtƒ@‚©‚ç‚ÌŽæo‚µ
150 */
151 if (trace_count > 0U) {
152 *p_trace = trace_buffer[trace_head];
153 trace_count--;
154 trace_head++;
155 if (trace_head >= TCNT_TRACE_BUFFER) {
156 trace_head = 0U;
157 }
158 ercd = E_OK;
159 }
160 else {
161 ercd = E_OBJ;
162 }
163
164 SIL_UNL_INT();
165 return(ercd);
166}
167
168/*
169 * ƒgƒŒ[ƒXƒƒO‚ðo—Í‚·‚邽‚߂̃‰ƒCƒuƒ‰ƒŠŠÖ”
170 */
171
172void
173trace_write_0(uint_t type)
174{
175 TRACE trace;
176
177 trace.logtype = type;
178 (void) trace_wri_log(&trace);
179}
180
181void
182trace_write_1(uint_t type, intptr_t arg1)
183{
184 TRACE trace;
185
186 trace.logtype = type;
187 trace.loginfo[0] = arg1;
188 (void) trace_wri_log(&trace);
189}
190
191void
192trace_write_2(uint_t type, intptr_t arg1, intptr_t arg2)
193{
194 TRACE trace;
195
196 trace.logtype = type;
197 trace.loginfo[0] = arg1;
198 trace.loginfo[1] = arg2;
199 (void) trace_wri_log(&trace);
200}
201
202void
203trace_write_3(uint_t type, intptr_t arg1, intptr_t arg2, intptr_t arg3)
204{
205 TRACE trace;
206
207 trace.logtype = type;
208 trace.loginfo[0] = arg1;
209 trace.loginfo[1] = arg2;
210 trace.loginfo[2] = arg3;
211 (void) trace_wri_log(&trace);
212}
213
214/*
215 * ƒAƒZƒ“ƒuƒŠŒ¾Œê‚Å‹Lq‚³‚ê‚éƒR[ƒh‚©‚çƒgƒŒ[ƒXƒƒO‚ðo—Í‚·‚邽‚ß‚ÌŠÖ
216 * ”
217 */
218
219void
220log_dsp_enter(TCB *p_tcb)
221{
222 trace_1(LOG_TYPE_DSP|LOG_ENTER, p_tcb);
223}
224
225void
226log_dsp_leave(TCB *p_tcb)
227{
228 trace_1(LOG_TYPE_DSP|LOG_LEAVE, p_tcb);
229}
230
231void
232log_inh_enter(INHNO inhno)
233{
234 trace_1(LOG_TYPE_INH|LOG_ENTER, inhno);
235}
236
237void
238log_inh_leave(INHNO inhno)
239{
240 trace_1(LOG_TYPE_INH|LOG_LEAVE, inhno);
241}
242
243void
244log_exc_enter(EXCNO excno)
245{
246 trace_1(LOG_TYPE_EXC|LOG_ENTER, excno);
247}
248
249void
250log_exc_leave(EXCNO excno)
251{
252 trace_1(LOG_TYPE_EXC|LOG_LEAVE, excno);
253}
Note: See TracBrowser for help on using the repository browser.