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{\tgEF
|
---|
13 | * Ai{\tgEFAðüϵ½àÌðÜÞDȺ¯¶jðgpE¡»Eü
|
---|
14 | * ÏEÄzziȺCpÆÄÔj·é±Æð³Åø·éD
|
---|
15 | * (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
|
---|
16 | * \¦C±Ìpð¨æѺL̳ÛØKèªC»ÌÜÜÌ`Å\[
|
---|
17 | * XR[hÉÜÜêÄ¢é±ÆD
|
---|
18 | * (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJÉg
|
---|
19 | * pÅ«é`ÅÄzz·éêÉÍCÄzzɺ¤hL
|
---|
20 | gip
|
---|
21 | * Ò}j
|
---|
22 | AÈÇjÉCãLÌì \¦C±Ìpð¨æѺL
|
---|
23 | * ̳ÛØKèðfÚ·é±ÆD
|
---|
24 | * (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJÉg
|
---|
25 | * pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
|
---|
26 | * ÆD
|
---|
27 | * (a) Äzzɺ¤hL
|
---|
28 | gipÒ}j
|
---|
29 | AÈÇjÉCãLÌ
|
---|
30 | * ì \¦C±Ìpð¨æѺL̳ÛØKèðfÚ·é±ÆD
|
---|
31 | * (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
|
---|
32 | * ñ·é±ÆD
|
---|
33 | * (4) {\tgEFAÌpÉæè¼ÚIܽÍÔÚIɶ¶é¢©Èé¹
|
---|
34 | * Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
|
---|
35 | * ܽC{\tgEFAÌ[UܽÍGh[U©çÌ¢©Èé
|
---|
36 | * RÉîÿ©çàCãLì Ò¨æÑTOPPERSvWFNgð
|
---|
37 | * ÆÓ·é±ÆD
|
---|
38 | *
|
---|
39 | * {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
|
---|
40 | * æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
|
---|
41 | * ÉηéK«àÜßÄC¢©ÈéÛØàsíÈ¢DܽC{\tgEF
|
---|
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 | * vZbT˶W
|
---|
50 | [iRX630pj
|
---|
51 | */
|
---|
52 |
|
---|
53 | #include "kernel_impl.h"
|
---|
54 | #include "sil.h"
|
---|
55 |
|
---|
56 |
|
---|
57 | /*
|
---|
58 | * ݶñðÛ¶·éÏ
|
---|
59 | */
|
---|
60 | uint16_t intnest;
|
---|
61 |
|
---|
62 | /*
|
---|
63 | * CPUbNtOÀ»Ì½ßÌÏ
|
---|
64 | */
|
---|
65 | #if TIPM_LOCK != -15
|
---|
66 | bool_t lock_flag; /* CPUbNtOÌlðÛ·éÏ */
|
---|
67 | uint32_t saved_ipl; /* ÝDæxxðÛ¶·éÏ */
|
---|
68 | #endif /* TIPM_LOCK != -15 */
|
---|
69 |
|
---|
70 |
|
---|
71 | /*
|
---|
72 | * vZbT˶Ìú»
|
---|
73 | */
|
---|
74 | void
|
---|
75 | prc_initialize( void )
|
---|
76 | {
|
---|
77 | /*
|
---|
78 | * ݶñÌú»
|
---|
79 | *
|
---|
80 | * X^[gAbvÍSÝbNóÔ & ñ^XNReLXg
|
---|
81 | * ÉÄ®ì·é½ß, ñ^XNReLXgÉU·é.
|
---|
82 | */
|
---|
83 | intnest = 1U;
|
---|
84 |
|
---|
85 | #if TIPM_LOCK != -15
|
---|
86 | /*
|
---|
87 | * CPUbNtOÀ»Ì½ßÌÏÌú»
|
---|
88 | */
|
---|
89 | lock_flag = true;
|
---|
90 | saved_ipl = IPL_ENAALL;
|
---|
91 | #endif /* TIPM_LOCK != -15 */
|
---|
92 | }
|
---|
93 |
|
---|
94 |
|
---|
95 | /*
|
---|
96 | * vZbT˶ÌI¹
|
---|
97 | */
|
---|
98 | void
|
---|
99 | prc_terminate( void )
|
---|
100 | {
|
---|
101 | /*
|
---|
102 | * ÁÉKvÈÍÈ¢
|
---|
103 | */
|
---|
104 | }
|
---|
105 |
|
---|
106 |
|
---|
107 | /*
|
---|
108 | * CPUáO̶óµÌOoÍ
|
---|
109 | *
|
---|
110 | * CPUáOnhÌ©çCCPUáOîñ|C^ip_excinfjðøƵ
|
---|
111 | * ÄÄÑo·±ÆÅCCPUáO̶óµðVXeOÉoÍ·éD
|
---|
112 | */
|
---|
113 | #ifdef SUPPORT_XLOG_SYS
|
---|
114 | void
|
---|
115 | xlog_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 | * ÝvCÌ®«ÌÝè
|
---|
143 | *
|
---|
144 | * ASPJ[lÅÌpðzèµÄCp[^G[ÍAT[VÅ`Fb
|
---|
145 | * NµÄ¢éDcfg_intT[rXR[ðݯéêÉÍCG[ðÔ·æ¤
|
---|
146 | * ɷ׫Šë¤D
|
---|
147 | */
|
---|
148 | void
|
---|
149 | x_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 | * ÝÌ}XN
|
---|
168 | *
|
---|
169 | * Ýðó¯t¯½ÜÜCxgK^GbWgKÌÝèâC
|
---|
170 | * ÝDæxÌÝèðs¤ÌÍë¯È½ßCÝ®«É©©íç¸C
|
---|
171 | * êU}XN·éD
|
---|
172 | */
|
---|
173 | ( void )x_disable_int( intno );
|
---|
174 |
|
---|
175 | /*
|
---|
176 | * xgK/GbWgKÌÝè
|
---|
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 | * RtBM
|
---|
198 | [^ÉÄ`FbNµÄ¢é½ß,
|
---|
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 | * ÝÔÉε½IPRlðÝè·é.
|
---|
211 | */
|
---|
212 | sil_wrb_mem((uint8_t *)ipr_reg_addr[intno], cfg_int_table[intno].intpri);
|
---|
213 |
|
---|
214 | /*
|
---|
215 | * ÝÌ}XNð
|
---|
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 | */
|
---|
227 | void
|
---|
228 | default_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 | */
|
---|
238 | void
|
---|
239 | default_exc_handler( void )
|
---|
240 | {
|
---|
241 | syslog(LOG_EMERG, "Unregistered Expevt error occurs.");
|
---|
242 | }
|
---|
243 | #endif /* OMIT_DEFAULT_EXC_HANDLER */
|
---|
244 |
|
---|