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