source: uKadecot/trunk/ssp/arch/rx630_ccrx/prc_config.h@ 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: 17.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,2006 by Embedded and Real-Time Systems Laboratory
8 * Graduate School of Information Science, Nagoya Univ., JAPAN
9 * Copyright (C) 2008-2010 by Witz Corporation, JAPAN
10 * Copyright (C) 2013 by Mitsuhiro Matsuura
11 *
12 * ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì (1)`(4) ‚ÌðŒ‚©CFree Software Foundation
13 * ‚É‚æ‚Á‚ÄŒö•\‚³‚ê‚Ä‚¢‚é GNU General Public License ‚Ì Version 2 ‚É‹L
14 * q‚³‚ê‚Ä‚¢‚éðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒFƒAi–{ƒ\ƒtƒgƒEƒFƒA
15 * ‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü•ÏEÄ”z•ziˆÈ‰ºC
16 * —˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
17 * (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ì
18 * Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[
19 * ƒXƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
20 * (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
21 * —p‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
22ƒƒ“ƒgi—˜—p
23 * ŽÒƒ}ƒjƒ…
24ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L
25 * ‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
26 * (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
27 * —p‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±
28 * ‚ƁD
29 * (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
30ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
31ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜
32 * ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
33 * (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É
34 * •ñ‚·‚邱‚ƁD
35 * (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹
36 * ŠQ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
37 *
38 * –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨
39 * ‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC‚»‚Ì“K—p‰Â”\«‚à
40 * ŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼
41 * Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»‚̐ӔC‚𕉂í‚È‚¢D
42 *
43 */
44
45/*
46 * ƒvƒƒZƒbƒTˆË‘¶ƒ‚ƒWƒ…
47[ƒ‹iRX630—pj
48 *
49 * ‚±‚̃Cƒ“ƒNƒ‹[ƒhƒtƒ@ƒCƒ‹‚́Ctarget_config.hi‚Ü‚½‚́C‚»‚±‚©‚çƒCƒ“ƒN
50 * ƒ‹[ƒh‚³‚ê‚éƒtƒ@ƒCƒ‹j‚Ì‚Ý‚©‚çƒCƒ“ƒNƒ‹[ƒh‚³‚ê‚éD‘¼‚̃tƒ@ƒCƒ‹‚©‚ç
51 * ’¼ÚƒCƒ“ƒNƒ‹[ƒh‚µ‚Ä‚Í‚È‚ç‚È‚¢D
52 */
53
54#ifndef TOPPERS_PRC_CONFIG_H
55#define TOPPERS_PRC_CONFIG_H
56
57#ifndef TOPPERS_MACRO_ONLY
58
59/*
60 * ƒvƒƒZƒbƒT‚Ì“ÁŽê–½—߂̃Cƒ“ƒ‰ƒCƒ“ŠÖ”’è‹`
61 */
62#include "prc_insn.h"
63
64
65/*
66 * ”ñƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg—p‚̃Xƒ^ƒbƒN‰Šú’l
67 */
68
69//#define TOPPERS_ISTKPT( istk, istksz ) (( STK_T * )(( char * )( istk ) + ( istksz )))
70#define TOPPERS_ISTKPT( istk, istksz ) __secend("SI")
71
72/*
73 * ƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒgƒuƒƒbƒN‚Ì’è‹`
74 */
75typedef struct task_context_block {
76 void *sp; /* ƒXƒ^ƒbƒNƒ|ƒCƒ“ƒ^ */
77 FP pc; /* ƒvƒƒOƒ‰ƒ€ƒJƒEƒ“ƒ^ */
78} TSKCTXB;
79
80
81/*
82 * Š„ž‚Ý”­¶‰ñ”‚ð•Û‘¶‚·‚é•Ï”
83 */
84extern uint16_t intnest;
85
86
87/*
88 * CPUƒƒbƒNó‘Ô‚Å‚ÌŠ„ž‚Ý—Dæ“xƒ}ƒXƒN
89 *
90 * TIPM_LOCK‚́CCPUƒƒbƒNó‘Ô‚Å‚ÌŠ„ž‚Ý—Dæ“xƒ}ƒXƒNC‚·‚È‚í‚¿CƒJ[ƒl
91 * ƒ‹ŠÇ—ŠO‚Ì‚à‚Ì‚ðœ‚­‚·‚ׂĂ̊„ž‚Ý—v‹‚ðƒ}ƒXƒN‚·‚é’l‚É’è‹`‚·‚éD
92 *
93 * TMIN_INTPRI•ÏX‚·‚邱‚Æ‚ÅŠÇ—ŠOŠ„ž‚Ý‚Ì—L–³‚ðŒˆ’è‚·‚éD
94 * —Ⴆ‚ÎTMIN_INTPRI‚ð-14‚ɐݒ肷‚é‚ƁCƒŒƒxƒ‹15‚ÌŠ„ž‚Ý‚ªƒJ[ƒlƒ‹ŠÇ—ŠO‚Æ
95 * ‚È‚éDTMIN_INTPRI‚ð-15‚ɐݒ肷‚é‚ƁCNMIˆÈŠO‚ɃJ[ƒlƒ‹ŠÇ—ŠO‚ÌŠ„ž‚Ý‚ð
96 * Ý‚¯‚È‚¢‚±‚Æ‚É‚È‚éi‚±‚̏ꍇ‚É‚Í-15‚ɐݒ肷‚邱‚Ƃ𐄏§‚·‚éjD
97 */
98#ifndef TIPM_LOCK
99#define TIPM_LOCK TMIN_INTPRI
100#endif /* TIPM_LOCK */
101
102
103/*
104 * TOPPERS•W€Š„ž‚ݏˆ—ƒ‚ƒfƒ‹‚ÌŽÀŒ»
105 */
106/*
107 * ƒRƒ“ƒeƒLƒXƒg‚ÌŽQÆ
108 *
109 * RX‚ł́CŠ„ž‚Ý‚Ì–ß‚èæ‚ªƒ^ƒXƒN‚©‚Ç‚¤‚©‚ð”»’f‚·‚邽‚ß‚É intnest
110 * ‚ðŽg—p‚µ‚Ä‚¢‚éD‚±‚ê‚ð—p‚¢‚ăRƒ“ƒeƒLƒXƒg‚ð”»’f‚·‚éD
111 */
112Inline bool_t
113sense_context( void )
114{
115 /* ƒlƒXƒgƒJƒEƒ“ƒ^0‚æ‚è‘å‚È‚ç”ñƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg */
116 return ( intnest > 0U );
117}
118
119
120/*
121 * CPUƒƒbƒNƒtƒ‰ƒOŽÀŒ»‚Ì‚½‚߂̕ϐ”
122 *
123 * ‚±‚ê‚ç‚̕ϐ”‚́CCPUƒƒbƒNó‘Ô‚ÌŽž‚̂ݏ‘‚«Š·‚¦‚Ä‚æ‚¢‚à‚Ì‚Æ‚·‚éD
124 */
125#if TIPM_LOCK != -15
126extern bool_t lock_flag; /* CPUƒƒbƒNƒtƒ‰ƒO‚Ì’l‚ð•ÛŽ‚·‚é•Ï” */
127extern uint32_t saved_ipl; /* Š„ž‚Ý—Dæ“xƒŒƒxƒ‹‚ð•Û‘¶‚·‚é•Ï” */
128#endif /* TIPM_LOCK != -15 */
129
130#endif /* TOPPERS_MACRO_ONLY */
131
132
133/*
134 * Š„ž‚Ý—Dæ“xƒ}ƒXƒN‚ÌŠO•”•\Œ»‚Æ“à•”•\Œ»‚Ì•ÏŠ·
135 *
136 * RX630‚ł́CƒvƒƒZƒbƒTƒXƒe[ƒ^ƒXƒ[ƒhƒŒƒWƒXƒ^iPSWj‚̉º‚©‚ç
137 * 24`27ƒrƒbƒg–Ú‚Ì4ƒrƒbƒg‚ÉŠ„ž‚Ý—Dæ“xƒŒƒxƒ‹iIPLj‚ª’u‚©‚ê‚Ä‚¢‚éD
138 * ƒJ[ƒlƒ‹ŠÇ—ŠOŠ„ž‚Ý‚ðŽÀ‘•‚·‚éê‡‚ÉIPL‚ðŽg—p‚µ‚½§Œä‚ðs‚¤D
139 * ƒJ[ƒlƒ‹‚ÍŠ„ž‚Ý—Dæ“xƒ}ƒXƒNi-1‚©‚ç˜A‘±‚µ‚½•‰‚Ì’lj‚ÅŠÇ—‚³‚ê‚Ä
140 * ‚¢‚邽‚ßIPL‚Æ‚Ì•ÏŠ·‚ª•K—v‚Æ‚È‚éD
141 */
142#define IPL_TO_IPM( ipl ) (-(( PRI )(( ipl ) >> 24U ))) /* IPL‚ðIPM‚É */
143#define IPM_TO_IPL( ipm ) ((( uint32_t )(-( ipm ))) << 24U ) /* IPM‚ðIPL‚É */
144
145
146/*
147 * CPUƒƒbƒNó‘Ô‚Å‚ÌŠ„ž‚Ý—Dæ“xƒ}ƒXƒN‚ÌIPL
148 */
149#define IPL_LOCK ( IPM_TO_IPL( TIPM_LOCK ) )
150
151/*
152 * TIPM_ENAALLiŠ„ž‚Ý—Dæ“xƒ}ƒXƒN‘S‰ðœj‚ÌIPL
153 */
154#define IPL_ENAALL ( IPM_TO_IPL( TIPM_ENAALL ) )
155
156
157#ifndef TOPPERS_MACRO_ONLY
158
159/*
160 * Š„ž‚Ý—vˆö–ˆ‚̃Œƒxƒ‹ & ‘®«’è‹`ƒe[ƒuƒ‹
161 * (ƒeƒ“ƒvƒŒ[ƒgƒtƒ@ƒCƒ‹‚É‚æ‚éo—Í)
162 */
163typedef struct cfg_int_info {
164 PRI intpri;
165 ATR intatr;
166} CFG_INT_INFO;
167
168extern const CFG_INT_INFO cfg_int_table[];
169
170
171/*
172 * Š„ž‚ݔԍ†‚͈̔͂̔»’è
173 *
174 * Š„ž‚ݔԍ†‚ª—LŒø‚È’l‚©Œµ–§‚Ƀ`ƒFƒbƒN‚·‚邽‚ß,
175 * ƒRƒ“ƒtƒBƒMƒ…
176ƒŒ[ƒ^o—̓e[ƒuƒ‹‚ðŽQÆ‚·‚é.
177 */
178#define VALID_INTNO( intno ) \
179 ( cfg_int_table[( intno )].intpri > 0 )
180#define VALID_INTNO_DISINT( intno ) VALID_INTNO( intno )
181#define VALID_INTNO_CFGINT( intno ) VALID_INTNO( intno )
182
183/* cre_int‚Å—LŒø‚ÈŠ„ž‚ݔԍ†‚ÌŽw’è */
184#define VALID_INTNO_CREINT VALID_INTNO_CFGINT((intno))
185
186/* cre_isr‚Å—LŒø‚ÈŠ„ž‚ݔԍ†‚ÌŽw’è */
187#define VALID_INTNO_CREISR(intno) VALID_INTNO_CFGINT((intno))
188
189
190/*
191 * Š„ž‚ݐ§ŒäƒŒƒWƒXƒ^ŠÖ˜A‚Ì’è‹`
192 */
193#define IRQ_POSEDGE ( 0x08U )
194#define IRQ_NEGEDGE ( 0x04U )
195#define IRQ_BOTHEDGE ( 0x0CU )
196#define IRQ_LOWLEVEL ( 0x00U )
197
198
199/*
200 * CPUƒƒbƒNó‘Ԃւ̈ڍs
201 *
202 * IPMiƒn[ƒhƒEƒFƒA‚ÌŠ„ž‚Ý—Dæ“xƒ}ƒXƒNj‚ðCsaved_iipm‚É•Û‘¶‚µCƒJ[
203 * ƒlƒ‹ŠÇ—ŠO‚Ì‚à‚Ì‚ðœ‚­‚·‚ׂĂ̊„ž‚Ý—v‹‚ðƒ}ƒXƒN‚·‚é’liTIPM_LOCKj
204 * ‚ɐݒ肷‚éD‚Ü‚½Clock_flag‚ðTRUE‚É‚·‚éD
205 *
206 * IPM‚ªCÅ‰‚©‚çTIPM_LOCK‚Æ“¯‚¶‚©‚»‚ê‚æ‚荂‚¢ê‡‚ɂ́C‚»‚ê‚ð
207 * saved_iipm‚É•Û‘¶‚·‚é‚݂̂ŁCTIPM_LOCK‚ɂ͐ݒ肵‚È‚¢D‚±‚ê‚́Cƒ‚ƒfƒ‹
208 * ã‚ÌŠ„ž‚Ý—Dæ“xƒ}ƒXƒN‚ªCTIPM_LOCK‚Æ“¯‚¶‚©‚»‚ê‚æ‚荂‚¢ƒŒƒxƒ‹‚ɐݒè
209 * ‚³‚ê‚Ä‚¢‚éó‘Ô‚É‚ ‚½‚éD
210 *
211 * ‚±‚̊֐”‚́CCPUƒƒbƒNó‘ԁilock_flag‚ªTRUE‚̏ó‘ԁj‚ŌĂ΂ê‚邱‚Æ‚Í
212 * ‚È‚¢‚à‚Ì‚Æ‘z’肵‚Ä‚¢‚éD
213 */
214Inline void
215x_lock_cpu( void )
216{
217#if TIPM_LOCK == -15
218 disint();
219#else /* TIPM_LOCK == -15 */
220 uint32_t ipl;
221
222 /*
223 * current_ipl()‚Ì•Ô‚è’l‚𒼐Úsaved_ipl‚É•Û‘¶‚¹‚¸CˆêŽž•Ï”ipl
224 * ‚ð—p‚¢‚Ä‚¢‚é‚̂́Ccurrent_ipl()‚ðŒÄ‚ñ‚¾’¼Œã‚ÉŠ„ž‚Ý‚ª”­¶‚µC
225 * ‹N“®‚³‚ꂽŠ„ž‚ݏˆ—‚Åsaved_ipl‚ª•ÏX‚³‚ê‚é‰Â”\«‚ª‚ ‚邽‚ß‚Å
226 * ‚ ‚éD
227 */
228 ipl = current_ipl();
229 if( IPL_LOCK > ipl ){
230 set_ipl( IPL_LOCK );
231 }
232
233 saved_ipl = ipl;
234 lock_flag = true;
235#endif /* TIPM_LOCK == -15 */
236}
237
238#define t_lock_cpu() x_lock_cpu()
239#define i_lock_cpu() x_lock_cpu()
240
241
242/*
243 * CPUƒƒbƒNó‘Ԃ̉ðœ
244 *
245 * lock_flag‚ðFALSE‚É‚µCIPMiƒn[ƒhƒEƒFƒA‚ÌŠ„ž‚Ý—Dæ“xƒ}ƒXƒNj‚ðC
246 * saved_iipm‚É•Û‘¶‚µ‚½’l‚É–ß‚·D
247 *
248 * ‚±‚̊֐”‚́CCPUƒƒbƒNó‘ԁilock_flag‚ªtrue‚̏ó‘ԁj‚ł̂݌Ă΂ê‚é‚à
249 * ‚Ì‚Æ‘z’肵‚Ä‚¢‚éD
250 */
251Inline void
252x_unlock_cpu( void )
253{
254#if TIPM_LOCK == -15
255 enaint();
256#else /* TIPM_LOCK == -15 */
257 lock_flag = false;
258 set_ipl( saved_ipl );
259#endif /* TIPM_LOCK == -15 */
260}
261
262#define t_unlock_cpu() x_unlock_cpu()
263#define i_unlock_cpu() x_unlock_cpu()
264
265
266/*
267 * CPUƒƒbƒNó‘Ô‚ÌŽQÆ
268 */
269Inline bool_t
270x_sense_lock( void )
271{
272#if TIPM_LOCK == -15
273 return (( bool_t )(( current_psw() & PSW_I_MASK) == 0 ));
274#else /* TIPM_LOCK == -15 */
275 return lock_flag;
276#endif /* TIPM_LOCK == -15 */
277}
278
279#define t_sense_lock() x_sense_lock()
280#define i_sense_lock() x_sense_lock()
281
282
283/*
284 * iƒ‚ƒfƒ‹ã‚́jŠ„ž‚Ý—Dæ“xƒ}ƒXƒN‚̐ݒè
285 *
286 * CPUƒƒbƒNƒtƒ‰ƒO‚ªƒNƒŠƒA‚³‚ê‚Ä‚¢‚鎞‚́Cƒn[ƒhƒEƒFƒA‚ÌŠ„ž‚Ý—Dæ“xƒ}
287 * ƒXƒN‚ðÝ’è‚·‚éDCPUƒƒbƒNƒtƒ‰ƒO‚ªƒZƒbƒg‚³‚ê‚Ä‚¢‚鎞‚́Csaved_iipm
288 * ‚ðÝ’肵C‚³‚ç‚ɁCƒn[ƒhƒEƒFƒA‚ÌŠ„ž‚Ý—Dæ“xƒ}ƒXƒN‚ðCÝ’肵‚悤‚Æ
289 * ‚µ‚½iƒ‚ƒfƒ‹ã‚́jŠ„ž‚Ý—Dæ“xƒ}ƒXƒN‚ÆTIPM_LOCK‚̍‚‚¢•û‚ɐݒ肷‚éD
290 */
291Inline void
292x_set_ipm( PRI intpri )
293{
294 uint32_t ipl = IPM_TO_IPL( intpri );
295#if TIPM_LOCK == -15
296 set_ipl(ipl);
297#else /* TIPM_LOCK == -15 */
298 if( !lock_flag ){
299 set_ipl(ipl);
300 }
301 else {
302 saved_ipl = ipl;
303 set_ipl(ipl > IPL_LOCK ? ipl : IPL_LOCK);
304 }
305#endif /* TIPM_LOCK == -15 */
306}
307
308#define t_set_ipm( intpri ) x_set_ipm( intpri )
309#define i_set_ipm( intpri ) x_set_ipm( intpri )
310
311
312/*
313 * iƒ‚ƒfƒ‹ã‚́jŠ„ž‚Ý—Dæ“xƒ}ƒXƒN‚ÌŽQÆ
314 *
315 * CPUƒƒbƒNƒtƒ‰ƒO‚ªƒNƒŠƒA‚³‚ê‚Ä‚¢‚鎞‚̓n[ƒhƒEƒFƒA‚ÌŠ„ž‚Ý—Dæ“xƒ}
316 * ƒXƒN‚ðCƒZƒbƒg‚³‚ê‚Ä‚¢‚鎞‚Ísaved_iipm‚ðŽQÆ‚·‚éD
317 */
318Inline PRI
319x_get_ipm( void )
320{
321 uint32_t ipl;
322#if TIPM_LOCK == -15
323 ipl = current_ipl();
324#else /* TIPM_LOCK == -15 */
325 if (!lock_flag) {
326 ipl = current_ipl();
327 }
328 else {
329 ipl = saved_ipl;
330 }
331#endif /* TIPM_LOCK == -15 */
332 return IPL_TO_IPM( ipl );
333}
334
335#define t_get_ipm() x_get_ipm()
336#define i_get_ipm() x_get_ipm()
337
338
339/*
340 * Š„ž‚Ý—v‹‹ÖŽ~ƒtƒ‰ƒO‚̃Zƒbƒg
341 *
342 * Š„ž‚Ý‘®«‚ªÝ’肳‚ê‚Ä‚¢‚È‚¢Š„ž‚Ý—v‹ƒ‰ƒCƒ“‚ɑ΂µ‚ÄŠ„ž‚Ý—v‹‹ÖŽ~
343 * ƒtƒ‰ƒO‚ðƒZƒbƒg‚µ‚悤‚Æ‚µ‚½ê‡‚ɂ́CFALSE‚ð•Ô‚·D
344 */
345Inline bool_t
346x_disable_int( INTNO intno )
347{
348 /*
349 * ƒŒƒxƒ‹’è‹`‚ª0‚Å‚ ‚éê‡‚ÍCFG_INT‚³‚ê‚Ä‚¢‚È‚¢
350 */
351 if( cfg_int_table[intno].intpri == 0 ){
352 return ( false );
353 }
354
355 *ier_reg_addr[intno].addr &= ( ~ier_reg_addr[intno].offset );
356
357 return ( true );
358}
359
360#define t_disable_int( intno ) x_disable_int( intno )
361#define i_disable_int( intno ) x_disable_int( intno )
362
363
364/*
365 * Š„ž‚Ý—v‹‹ÖŽ~ƒtƒ‰ƒO‚̃NƒŠƒA
366 *
367 * Š„ž‚Ý‘®«‚ªÝ’肳‚ê‚Ä‚¢‚È‚¢Š„ž‚Ý—v‹ƒ‰ƒCƒ“‚ɑ΂µ‚ÄŠ„ž‚Ý—v‹‹ÖŽ~
368 * ƒtƒ‰ƒO‚ðƒNƒŠƒA‚µ‚悤‚Æ‚µ‚½ê‡‚ɂ́CFALSE‚ð•Ô‚·D
369 */
370Inline bool_t
371x_enable_int( INTNO intno )
372{
373 /*
374 * ƒŒƒxƒ‹’è‹`‚ª0‚Å‚ ‚éê‡‚ÍCFG_INT‚³‚ê‚Ä‚¢‚È‚¢
375 */
376 if( cfg_int_table[intno].intpri == 0 ){
377 return ( false );
378 }
379
380 *ier_reg_addr[intno].addr |= ier_reg_addr[intno].offset;
381
382 return ( true );
383}
384
385#define t_enable_int( intno ) x_enable_int( intno )
386#define i_enable_int( intno ) x_enable_int( intno )
387
388
389/*
390 * Š„ž‚Ý—v‹‚̃NƒŠƒA
391 */
392Inline void
393x_clear_int( INTNO intno )
394{
395 *IR_REG(intno) = 0U;
396}
397
398#define t_clear_int( intno ) x_clear_int( intno )
399#define i_clear_int( intno ) x_clear_int( intno )
400
401
402/*
403 * Š„ž‚Ý—v‹‚̃`ƒFƒbƒN
404 */
405Inline bool_t
406x_probe_int( INTNO intno )
407{
408 /*
409 * Š„ž‚Ý—v‹ƒŒƒWƒXƒ^‚Í0 or 1‚Å‚µ‚©‚È‚¢‚½‚ß,
410 * ‚»‚Ì‚Ü‚Ü‚Ì’l‚ð•Ô‚·.
411 */
412 return ( *IR_REG(intno) );
413}
414
415#define t_probe_int( intno ) x_probe_int( intno )
416#define i_probe_int( intno ) x_probe_int( intno )
417
418
419/*
420 * Š„ž‚Ý—v‹ƒ‰ƒCƒ“‚Ì‘®«‚̐ݒè
421 */
422extern void x_config_int( INTNO intno, ATR intatr, PRI intpri );
423
424
425/*
426 * Š„ž‚݃nƒ“ƒhƒ‰‚Ì“üŒû‚Å•K—v‚ÈIRC‘€ì
427 *
428 */
429Inline void
430i_begin_int( INTNO intno )
431{
432 volatile uint8_t reg;
433
434 /*
435 * ƒŒƒxƒ‹ŒŸo‚ÌŠ„ž‚݂ɑ΂µ‚Ä‚ÍŠ„ž‚݃Xƒe[ƒ^ƒX
436 * ƒtƒ‰ƒO‚ðƒNƒŠƒA‚·‚é.
437 */
438 if( ( cfg_int_table[intno].intatr & TA_LOWLEVEL ) > 0 ){
439 if( *IR_REG(intno) > 0U ){
440 /*
441 * ŠO•”Š„ž‚݂̏ꍇ, IRQ’[Žq‚ªHigh‚É–ß‚Á‚Ä‚¢‚é
442 * ‚±‚Æ‚ðŠm”F‚·‚éŽ|‚ª‹LÚ‚³‚ê‚Ä‚¢‚邪, È—ª‚·‚é.
443 */
444 // *ir_reg_addr[intno] = 0U;
445
446 /*
447 * ƒn[ƒhƒEƒFƒAƒ}ƒjƒ…
448ƒAƒ‹‚É0‚É‚È‚Á‚½‚±‚Æ‚ð
449 * Šm”F‚·‚éŽ|‚ª‹LÚ‚ ‚邽‚ß, ƒŒƒWƒXƒ^’l‚ð“ǂݏo‚·.
450 */
451 // reg = *ir_reg_addr[intno];
452 }
453 }
454}
455
456
457/*
458 * Š„ž‚݃nƒ“ƒhƒ‰‚̏oŒû‚Å•K—v‚ÈIRC‘€ì
459 *
460 */
461Inline void
462i_end_int( INTNO intno )
463{
464 /* “Á‚ɍs‚¤‚ׂ«ˆ—‚Í‚È‚¢ */
465}
466
467
468/*
469 * Å‚—Dæ‡ˆÊƒ^ƒXƒN‚ւ̃fƒBƒXƒpƒbƒ`iprc_support.a30j
470 *
471 * dispatch‚́Cƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg‚©‚çŒÄ‚яo‚³‚ꂽƒT[ƒrƒXƒR[ƒ‹ˆ—‚©
472 * ‚çŒÄ‚яo‚·‚ׂ«‚à‚̂ŁCƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒgECPUƒƒbƒNó‘ԁEƒfƒBƒXƒpƒb
473 * ƒ`‹–‰Âó‘ԁEiƒ‚ƒfƒ‹ã‚́jŠ„ž‚Ý—Dæ“xƒ}ƒXƒN‘S‰ðœó‘ԂŌĂяo‚³‚È
474 * ‚¯‚ê‚΂Ȃç‚È‚¢D
475 */
476extern void dispatch( void );
477
478/*
479 * ƒfƒBƒXƒpƒbƒ`ƒƒ‚Ì“®ìŠJŽniprc_support.a30j
480 *
481 * start_dispatch‚́CƒJ[ƒlƒ‹‹N“®Žž‚ɌĂяo‚·‚ׂ«‚à‚̂ŁC‚·‚ׂĂ̊„ž
482 * ‚Ý‚ð‹ÖŽ~‚µ‚½ó‘ԁi‘SŠ„ž‚݃ƒbƒNó‘Ô‚Æ“¯“™‚̏ó‘ԁj‚ŌĂяo‚³‚È‚¯‚ê‚Î
483 * ‚È‚ç‚È‚¢D
484 */
485extern void start_dispatch( void ) NoReturn;
486
487/*
488 * Œ»Ý‚̃Rƒ“ƒeƒLƒXƒg‚ðŽÌ‚ĂăfƒBƒXƒpƒbƒ`iprc_support.a30j
489 *
490 * exit_and_dispatch‚́Cext_tsk‚©‚çŒÄ‚яo‚·‚ׂ«‚à‚̂ŁCƒ^ƒXƒNƒRƒ“ƒeƒL
491 * ƒXƒgECPUƒƒbƒNó‘ԁEƒfƒBƒXƒpƒbƒ`‹–‰Âó‘ԁEiƒ‚ƒfƒ‹ã‚́jŠ„ž‚Ý—Dæ
492 * “xƒ}ƒXƒN‘S‰ðœó‘ԂŌĂяo‚³‚È‚¯‚ê‚΂Ȃç‚È‚¢D
493 */
494#define _kernel_exit_and_dispatch(); \
495 _exit_and_dispatch(); \
496 ercd = E_SYS;
497
498extern void _exit_and_dispatch( void ) NoReturn;
499
500/*
501 * ƒJ[ƒlƒ‹‚̏I—¹ˆ—‚̌ďo‚µiprc_support.a30j
502 *
503 * call_exit_kernel‚́CƒJ[ƒlƒ‹‚̏I—¹Žž‚ɌĂяo‚·‚ׂ«‚à‚̂ŁC”ñƒ^ƒXƒN
504 * ƒRƒ“ƒeƒLƒXƒg‚ɐ؂芷‚¦‚āCƒJ[ƒlƒ‹‚̏I—¹ˆ—iexit_kernelj‚ðŒÄ‚яo
505 * ‚·D
506 */
507extern void call_exit_kernel( void ) NoReturn;
508
509/*
510 * ƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg‚̏‰Šú‰»
511 *
512 * ƒ^ƒXƒN‚ª‹xŽ~ó‘Ô‚©‚çŽÀs‚Å‚«‚éó‘ԂɈڍs‚·‚鎞‚ɌĂ΂ê‚éD‚±‚ÌŽž“_
513 * ‚ŃXƒ^ƒbƒN—̈æ‚ðŽg‚Á‚Ä‚Í‚È‚ç‚È‚¢D
514 *
515 * activate_context‚ðCƒCƒ“ƒ‰ƒCƒ“ŠÖ”‚Å‚Í‚È‚­ƒ}ƒNƒ’è‹`‚Æ‚µ‚Ä‚¢‚é‚̂́C
516 * ‚±‚ÌŽž“_‚Å‚ÍTCB‚ª’è‹`‚³‚ê‚Ä‚¢‚È‚¢‚½‚ß‚Å‚ ‚éD
517 */
518extern void start_r( void );
519
520#define activate_context( p_tcb ) \
521{ \
522 { \
523 \
524 /* ƒXƒ^ƒbƒNƒ|ƒCƒ“ƒ^‰Šú’l‚̐ݒè */ \
525 ( p_tcb )->tskctxb.sp = ( void * )((( uint32_t ) ( p_tcb )->p_tinib->stk ) + \
526 ( p_tcb )->p_tinib->stksz ); \
527 /* ‹N“®”Ô’n‚̐ݒè */ \
528 ( p_tcb )->tskctxb.pc = ( FP ) start_r; \
529 } \
530}
531
532
533/*
534 * calltex‚ÍŽg—p‚µ‚È‚¢
535 */
536#define OMIT_CALLTEX
537
538
539/*
540 * Š„ž‚݃nƒ“ƒhƒ‰‚̐ݒè
541 *
542 * RX630‚ÍROM‚ÉŠ„ž‚݃xƒNƒ^‚ð”z’u‚·‚邽‚߁C–{ŠÖ”‚Í‹óŠÖ”‚ÅŽÀ‘•‚·‚éD
543 */
544Inline void
545x_define_inh( INHNO inhno, FP inthdr )
546{
547}
548
549
550/*
551 * CPU—áŠOƒnƒ“ƒhƒ‰‚̐ݒè
552 *
553 * RX630‚ÍROM‚É—áŠOƒxƒNƒ^‚ð”z’u‚·‚邽‚߁C–{ŠÖ”‚Í‹óŠÖ”‚ÅŽÀ‘•‚·‚éD
554 */
555Inline void
556x_define_exc( EXCNO excno, FP exchdr )
557{
558}
559
560
561/*
562 * Š„ž‚Ý/—áŠOƒnƒ“ƒhƒ‰‚Ì“üŒûˆ—‚̐¶¬ƒ}ƒNƒ
563 *
564 * ƒeƒ“ƒvƒŒ[ƒgƒtƒ@ƒCƒ‹‚É‚æ‚萶¬‚·‚邽‚ß‹óƒ}ƒNƒ‚Æ‚·‚éD
565 */
566#define HDR_ENTRY(hdr, intexc_num , tobejmp)
567
568/*
569 * Š„ž‚݃nƒ“ƒhƒ‰‚Ì“üŒûˆ—‚̐¶¬ƒ}ƒNƒ
570 */
571#define _INT_ENTRY(inhno, inthdr) _kernel_##inthdr##_##inhno##_entry
572#define INT_ENTRY(inhno, inthdr) _INT_ENTRY(inhno , inthdr)
573
574#define _INTHDR_ENTRY(inhno, inhno_num ,inthdr) \
575 extern _kernel_##inthdr##_##inhno##_entry(void);
576#define INTHDR_ENTRY(inhno, inhno_num ,inthdr) _INTHDR_ENTRY(inhno, inhno_num ,inthdr)
577
578
579/*
580 * CPU—áŠOƒnƒ“ƒhƒ‰‚Ì“üŒûˆ—‚̐¶¬ƒ}ƒNƒ
581 */
582#define _EXC_ENTRY(excno , exchdr) _kernel_##exchdr##_##excno##_entry
583#define EXC_ENTRY(excno , exchdr) _EXC_ENTRY(excno , exchdr)
584
585#define _EXCHDR_ENTRY(excno , excno_num , exchdr) \
586 extern _kernel_##exchdr##_##excno##_entry(void);
587#define EXCHDR_ENTRY(excno , excno_num , exchdr) _EXCHDR_ENTRY(excno , excno_num , exchdr)
588
589
590/*
591 * CPU—áŠO‚Ì”­¶‚µ‚½Žž‚̃Rƒ“ƒeƒLƒXƒg‚ÌŽQÆ
592 *
593 * CPU—áŠO‚Ì”­¶‚µ‚½Žž‚̃Rƒ“ƒeƒLƒXƒg‚ªCƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg‚ÌŽž‚ÉFALSEC
594 * ‚»‚¤‚Å‚È‚¢Žž‚Étrue‚ð•Ô‚·D
595 */
596Inline bool_t
597exc_sense_context( void *p_excinf )
598{
599 /*
600 * ƒlƒXƒgƒJƒEƒ“ƒ^‚ª1‚æ‚è‘å‚È‚ç”ñƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg
601 */
602 return( intnest > 1U );
603}
604
605
606/*
607 * CPU—áŠOî•ñ p_excinf ‚©‚ç PSW ‚Ì’l‚ðŽæ“¾‚·‚邽‚߂̃IƒtƒZƒbƒg’l
608 * EXCNO + ACC + FPSW + R1`R15 + PC
609 */
610#define EXC_GET_PSW_OFFSET (4+8+4+60+4)
611
612/*
613 * CPU—áŠO‚Ì”­¶‚µ‚½Žž‚ÌIPL‚ÌŽQÆ
614 */
615Inline uint32_t
616exc_get_ipl(void *p_excinf)
617{
618 return((*((uint32_t *)((uintptr_t)p_excinf+EXC_GET_PSW_OFFSET)))
619 & PSW_IPL_MASK);
620}
621
622Inline bool_t
623exc_sense_i(void *p_excinf)
624{
625 return((*(((uint32_t *)((uintptr_t)p_excinf+EXC_GET_PSW_OFFSET)))
626 & PSW_I_MASK) != 0u);
627}
628
629
630/*
631 * CPU—áŠO‚Ì”­¶‚µ‚½Žž‚̃Rƒ“ƒeƒLƒXƒg‚ÆŠ„ž‚݂̃}ƒXƒNó‘Ô‚ÌŽQÆ
632 *
633 * CPU—áŠO‚Ì”­¶‚µ‚½Žž‚̃VƒXƒeƒ€ó‘Ô‚ªCƒJ[ƒlƒ‹ŽÀs’†‚Å‚È‚­Cƒ^ƒXƒNƒR
634 * ƒ“ƒeƒLƒXƒg‚Å‚ ‚èC‘SŠ„ž‚݃ƒbƒNó‘Ô‚Å‚È‚­CCPUƒƒbƒNó‘Ô‚Å‚È‚­Ciƒ‚
635 * ƒfƒ‹ã‚́jŠ„ž‚Ý—Dæ“xƒ}ƒXƒN‘S‰ðœó‘Ô‚Å‚ ‚鎞‚ÉtrueC‚»‚¤‚Å‚È‚¢Žž
636 * ‚ÉFALSE‚ð•Ô‚·iCPU—áŠO‚ªƒJ[ƒlƒ‹ŠÇ—ŠO‚ÌŠ„ž‚ݏˆ—’†‚Å”­¶‚µ‚½ê‡
637 * ‚É‚àFALSE‚ð•Ô‚·jD
638 *
639 * ƒJ[ƒlƒ‹ŽÀs’†‚Å‚È‚¢¨ (TIPM_LOCK== -15) Iƒtƒ‰ƒO == 1
640 * (else) IPL < IPL_LOCK
641 * ƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg‚Å‚ ‚遨intnest == 0
642 * ‘SŠ„ž‚݃ƒbƒN‚Å‚È‚¢¨ Iƒtƒ‰ƒO == 1
643 * Š„ž‚Ý—Dæ“xƒ}ƒXƒN‚ª‘S‰ðœ¨IPL == 0
644 *
645 *
646 */
647Inline bool_t
648exc_sense_intmask(void *p_excinf)
649{
650 return((!exc_sense_context(p_excinf))
651 && exc_sense_i(p_excinf)
652 && (exc_get_ipl(p_excinf) == IPL_ENAALL));
653}
654
655/*
656 * CPU—áŠO‚Ì”­¶‚µ‚½Žž‚̃Rƒ“ƒeƒLƒXƒg‚ÆŠ„ž‚݁^CPUƒƒbƒNó‘Ô‚ÌŽQÆ
657 *
658 * CPU—áŠO‚Ì”­¶‚µ‚½Žž‚̃VƒXƒeƒ€ó‘Ô‚ªCƒJ[ƒlƒ‹ŽÀs’†‚Å‚È‚­Cƒ^ƒXƒNƒR
659 * ƒ“ƒeƒLƒXƒg‚Å‚ ‚èC‘SŠ„ž‚݃ƒbƒNó‘Ô‚Å‚È‚­CCPUƒƒbƒNó‘Ô‚Å‚È‚¢Žž‚É
660 * trueC‚»‚¤‚Å‚È‚¢Žž‚Éfalse‚ð•Ô‚·iCPU—áŠO‚ªƒJ[ƒlƒ‹ŠÇ—ŠO‚ÌŠ„ž‚ݏˆ
661 * —’†‚Å”­¶‚µ‚½ê‡‚É‚àfalse‚ð•Ô‚·jD
662 *
663 * ƒJ[ƒlƒ‹ŽÀs’†‚Å‚È‚¢¨ (TIPM_LOCK== -15) Iƒtƒ‰ƒO == 1
664 * (else) IPL < TIPM_LOCK
665 * ƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg‚Å‚ ‚遨intnest < 1
666 * ‘SŠ„ž‚݃ƒbƒN‚Å‚È‚¢¨ Iƒtƒ‰ƒO == 1
667 * CPUƒƒbƒNó‘Ô‚Å‚È‚¢¨(TIPM_LOCK== -15) Iƒtƒ‰ƒO == 1
668 * (else) IPL < TIPM_LOCK
669 */
670Inline bool_t
671exc_sense_unlock(void *p_excinf)
672{
673#if TIPM_LOCK == -15
674 return((!exc_sense_context(p_excinf))
675 && exc_sense_i(p_excinf));
676#else
677 return((!exc_sense_context(p_excinf))
678 && exc_sense_i(p_excinf)
679 && exc_get_ipl(p_excinf) < IPL_LOCK);
680#endif
681}
682
683Inline void
684idle_loop(void)
685{
686 t_unlock_cpu();
687 t_lock_cpu();
688}
689
690/*
691 * ƒvƒƒZƒbƒTˆË‘¶‚̏‰Šú‰»
692 */
693extern void prc_initialize( void );
694
695/*
696 * ƒvƒƒZƒbƒTˆË‘¶‚̏I—¹Žžˆ—
697 */
698extern void prc_terminate( void );
699
700
701#ifndef OMIT_DEFAULT_INT_HANDLER
702/*
703 * –¢“o˜^‚ÌŠ„ž‚Ý‚ª”­¶‚µ‚½ê‡‚ɌĂяo‚³‚ê‚é
704 */
705void default_int_handler( void );
706#endif /* OMIT_DEFAULT_INT_HANDLER */
707
708#ifndef OMIT_DEFAULT_EXC_HANDLER
709/*
710 * –¢“o˜^‚Ì—áŠO‚ª”­¶‚µ‚½ê‡‚ɌĂяo‚³‚ê‚é
711 */
712void default_exc_handler( void );
713#endif /* OMIT_DEFAULT_EXC_HANDLER */
714
715
716#endif /* TOPPERS_MACRO_ONLY */
717
718#endif /* TOPPERS_PRC_CONFIG_H */
719
Note: See TracBrowser for help on using the repository browser.