source: UsbWattMeter/trunk/asp_dcre/arch/rx630_ccrx/prc_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: 6.7 KB
Line 
1/*
2 * TOPPERS/ASP Kernel
3 * Toyohashi Open Platform for Embedded Real-Time Systems/
4 * Advanced Standard Profile Kernel
5 *
6 * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
7 * Toyohashi Univ. of Technology, JAPAN
8 * Copyright (C) 2005,2006 by Embedded and Real-Time Systems Laboratory
9 * Graduate School of Information Science, Nagoya Univ., JAPAN
10 * Copyright (C) 2008-2010 by Witz Corporation, JAPAN
11 *
12 * ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì(1)`(4)‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
13 * ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü
14 * •ÏEÄ”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
15 * (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ì
16 * Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[
17 * ƒXƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
18 * (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
19 * —p‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
20ƒƒ“ƒgi—˜—p
21 * ŽÒƒ}ƒjƒ…
22ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L
23 * ‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
24 * (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
25 * —p‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±
26 * ‚ƁD
27 * (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
28ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
29ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜
30 * ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
31 * (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É
32 * •ñ‚·‚邱‚ƁD
33 * (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹
34 * ŠQ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
35 * ‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝
36 * —R‚ÉŠî‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð
37 * –Ɛӂ·‚邱‚ƁD
38 *
39 * –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨
40 * ‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC“Á’è‚ÌŽg—p–Ú“I
41 * ‚ɑ΂·‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒF
42 * ƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»
43 * ‚̐ӔC‚𕉂í‚È‚¢D
44 *
45 * @(#) $Id: prc_config.c 164 2016-03-07 11:33:50Z coas-nagasima $
46 */
47
48/*
49 * ƒvƒƒZƒbƒTˆË‘¶ƒ‚ƒWƒ…
50[ƒ‹iRX630—pj
51 */
52
53#include "kernel_impl.h"
54#include "sil.h"
55
56
57/*
58 * Š„ž‚Ý”­¶‰ñ”‚ð•Û‘¶‚·‚é•Ï”
59 */
60uint16_t intnest;
61
62/*
63 * CPUƒƒbƒNƒtƒ‰ƒOŽÀŒ»‚Ì‚½‚߂̕ϐ”
64 */
65#if TIPM_LOCK != -15
66bool_t lock_flag; /* CPUƒƒbƒNƒtƒ‰ƒO‚Ì’l‚ð•ÛŽ‚·‚é•Ï” */
67uint32_t saved_ipl; /* Š„ž‚Ý—Dæ“xƒŒƒxƒ‹‚ð•Û‘¶‚·‚é•Ï” */
68#endif /* TIPM_LOCK != -15 */
69
70
71/*
72 * ƒvƒƒZƒbƒTˆË‘¶‚̏‰Šú‰»
73 */
74void
75prc_initialize( void )
76{
77 /*
78 * Š„ž‚Ý”­¶‰ñ”‚̏‰Šú‰»
79 *
80 * ƒXƒ^[ƒgƒAƒbƒv‚Í‘SŠ„ž‚݃ƒbƒNó‘Ô & ”ñƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg
81 * ‚É‚Ä“®ì‚·‚邽‚ß, ”ñƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg‚É‹U‘•‚·‚é.
82 */
83 intnest = 1U;
84
85#if TIPM_LOCK != -15
86 /*
87 * CPUƒƒbƒNƒtƒ‰ƒOŽÀŒ»‚Ì‚½‚߂̕ϐ”‚̏‰Šú‰»
88 */
89 lock_flag = true;
90 saved_ipl = IPL_ENAALL;
91#endif /* TIPM_LOCK != -15 */
92}
93
94
95/*
96 * ƒvƒƒZƒbƒTˆË‘¶‚̏I—¹ˆ—
97 */
98void
99prc_terminate( void )
100{
101 /*
102 * “Á‚É•K—v‚ȏˆ—‚Í‚È‚¢
103 */
104}
105
106
107/*
108 * CPU—áŠO‚Ì”­¶ó‹µ‚̃ƒOo—Í
109 *
110 * CPU—áŠOƒnƒ“ƒhƒ‰‚Ì’†‚©‚çCCPU—áŠOî•ñƒ|ƒCƒ“ƒ^ip_excinfj‚ðˆø”‚Æ‚µ
111 * ‚ČĂяo‚·‚±‚ƂŁCCPU—áŠO‚Ì”­¶ó‹µ‚ðƒVƒXƒeƒ€ƒƒO‚ɏo—Í‚·‚éD
112 */
113#ifdef SUPPORT_XLOG_SYS
114void
115xlog_sys( void *p_excinf )
116{
117 syslog(LOG_ERROR , "r1 = %u") , *((uint32_t*)((intptr_t)p_excinf + 14));
118 syslog(LOG_ERROR , "r2 = %u") , *((uint32_t*)((intptr_t)p_excinf + 15));
119 syslog(LOG_ERROR , "r3 = %u") , *((uint32_t*)((intptr_t)p_excinf + 16));
120 syslog(LOG_ERROR , "r4 = %u") , *((uint32_t*)((intptr_t)p_excinf + 17));
121 syslog(LOG_ERROR , "r5 = %u") , *((uint32_t*)((intptr_t)p_excinf + 18));
122 syslog(LOG_ERROR , "r6 = %u") , *((uint32_t*)((intptr_t)p_excinf + 1));
123 syslog(LOG_ERROR , "r7 = %u") , *((uint32_t*)((intptr_t)p_excinf + 2));
124 syslog(LOG_ERROR , "r8 = %u") , *((uint32_t*)((intptr_t)p_excinf + 3));
125 syslog(LOG_ERROR , "r9 = %u") , *((uint32_t*)((intptr_t)p_excinf + 4));
126 syslog(LOG_ERROR , "r10 = %u") , *((uint32_t*)((intptr_t)p_excinf + 5));
127 syslog(LOG_ERROR , "r11 = %u") , *((uint32_t*)((intptr_t)p_excinf + 6));
128 syslog(LOG_ERROR , "r12 = %u") , *((uint32_t*)((intptr_t)p_excinf + 7));
129 syslog(LOG_ERROR , "r13 = %u") , *((uint32_t*)((intptr_t)p_excinf + 8));
130 syslog(LOG_ERROR , "r14 = %u") , *((uint32_t*)((intptr_t)p_excinf + 12));
131 syslog(LOG_ERROR , "r15 = %u") , *((uint32_t*)((intptr_t)p_excinf + 13));
132 syslog(LOG_ERROR , "fpsw = %u") , *((uint32_t*)((intptr_t)p_excinf + 11));
133 syslog(LOG_ERROR , "acclo = %u") , *((uint32_t*)((intptr_t)p_excinf + 10));
134 syslog(LOG_ERROR , "acchi = %u") , *((uint32_t*)((intptr_t)p_excinf + 9));
135 syslog(LOG_ERROR , "pc = %x") , *((uint32_t*)((intptr_t)p_excinf + 19));
136 syslog(LOG_ERROR , "psw = %x") , *((uint32_t*)((intptr_t)p_excinf + 20));
137}
138#endif /* SUPPORT_XLOG_SYS */
139
140
141/*
142 * Š„ž‚Ý—v‹ƒ‰ƒCƒ“‚Ì‘®«‚̐ݒè
143 *
144 * ASPƒJ[ƒlƒ‹‚Å‚Ì—˜—p‚ð‘z’肵‚āCƒpƒ‰ƒ[ƒ^ƒGƒ‰[‚̓AƒT[ƒVƒ‡ƒ“‚Ń`ƒFƒb
145 * ƒN‚µ‚Ä‚¢‚éDcfg_intƒT[ƒrƒXƒR[ƒ‹‚ðÝ‚¯‚éê‡‚ɂ́CƒGƒ‰[‚ð•Ô‚·‚悤
146 * ‚É‚·‚ׂ«‚Å‚ ‚낤D
147 */
148void
149x_config_int( INTNO intno, ATR intatr, PRI intpri )
150{
151 uint8_t irq_offset;
152 uint8_t irq_val;
153
154 assert( VALID_INTNO_CFGINT(intno) );
155
156 assert( ( -15 <= intpri ) && ( intpri <= TMAX_INTPRI ) );
157#if TIPM_LOCK != -15
158 if( intatr == TA_NONKERNEL ){
159 assert( intpri < TMIN_INTPRI );
160 }
161 else{
162 assert( TMIN_INTPRI <= intpri );
163 }
164#endif
165
166 /*
167 * Š„ž‚݂̃}ƒXƒN
168 *
169 * Š„ž‚Ý‚ðŽó‚¯•t‚¯‚½‚܂܁CƒŒƒxƒ‹ƒgƒŠƒK^ƒGƒbƒWƒgƒŠƒK‚̐ݒè‚âCŠ„
170 * ž‚Ý—Dæ“x‚̐ݒè‚ðs‚¤‚̂͊댯‚È‚½‚߁CŠ„ž‚Ý‘®«‚É‚©‚©‚í‚炸C
171 * ˆê’Uƒ}ƒXƒN‚·‚éD
172 */
173 ( void )x_disable_int( intno );
174
175 /*
176 * ƒŒƒxƒ‹ƒgƒŠƒK/ƒGƒbƒWƒgƒŠƒK‚̐ݒè
177 *
178 * IRQ‚̂݃Tƒ|[ƒg‚·‚é
179 */
180 if( INTNO_IRQ( intno ) != 0U ){
181 irq_offset = INTNO_IRQ_OFFSET( intno );
182
183 if( ( intatr & TA_POSEDGE ) != 0U ){
184 irq_val = IRQ_POSEDGE;
185 }
186 else if( ( intatr & TA_NEGEDGE ) != 0U ){
187 irq_val = IRQ_NEGEDGE;
188 }
189 else if( ( intatr & TA_BOTHEDGE ) != 0U ){
190 irq_val = IRQ_BOTHEDGE;
191 }
192 else if( ( intatr & TA_LOWLEVEL ) != 0U ){
193 irq_val = IRQ_LOWLEVEL;
194 }
195 else{
196 /*
197 * ƒRƒ“ƒtƒBƒMƒ…
198ƒŒ[ƒ^‚ɂă`ƒFƒbƒN‚µ‚Ä‚¢‚邽‚ß,
199 * ‚±‚±‚Ö‚­‚邱‚Æ‚Í‚ ‚肦‚È‚¢.
200 */
201 irq_val = 0U;
202 }
203
204 sil_wrb_mem((uint8_t *)irqcr_reg_addr[irq_offset], irq_val);
205 }
206
207 /*
208 * Š„ž‚݃Œƒxƒ‹‚̐ݒè
209 *
210 * Š„ž‚ݔԍ†‚ɑΉž‚µ‚½IPR’l‚ðÝ’è‚·‚é.
211 */
212 sil_wrb_mem((uint8_t *)ipr_reg_addr[intno], cfg_int_table[intno].intpri);
213
214 /*
215 * Š„ž‚݂̃}ƒXƒN‰ðœ
216 */
217 if( ( intatr & TA_ENAINT ) != 0U ){
218 ( void )x_enable_int( intno );
219 }
220}
221
222
223#ifndef OMIT_DEFAULT_INT_HANDLER
224/*
225 * –¢“o˜^‚ÌŠ„ž‚Ý‚ª”­¶‚µ‚½ê‡‚ɌĂяo‚³‚ê‚é
226 */
227void
228default_int_handler( void )
229{
230 syslog(LOG_EMERG, "Unregistered Interrupt occurs.");
231}
232#endif /* OMIT_DEFAULT_INT_HANDLER */
233
234#ifndef OMIT_DEFAULT_EXC_HANDLER
235/*
236 * –¢“o˜^‚Ì—áŠO‚ª”­¶‚µ‚½ê‡‚ɌĂяo‚³‚ê‚é
237 */
238void
239default_exc_handler( void )
240{
241 syslog(LOG_EMERG, "Unregistered Expevt error occurs.");
242}
243#endif /* OMIT_DEFAULT_EXC_HANDLER */
244
Note: See TracBrowser for help on using the repository browser.