source: ssp_qb_r5f100le_cs/trunk/arch/arm_m_gcc/prc_config.h@ 93

Last change on this file since 93 was 93, checked in by nmir-saito, 8 years ago

add Combined package of SSP kernel for QB-R5F100LE-TB(RL78 processor)

File size: 13.8 KB
Line 
1/*
2 * TOPPERS/SSP Kernel
3 * Smallest Set Profile Kernel
4 *
5 * Copyright (C) 2008 by Embedded and Real-Time Systems Laboratory
6 * Graduate School of Information Science, Nagoya Univ., JAPAN
7 * Copyright (C) 2015 by Naoki Saito
8 * Nagoya Municipal Industrial Research Institute, 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: prc_config.h 1304 2008-08-27 07:28:36Z ertl-honda $
44 */
45
46/*
47 * ƒvƒƒZƒbƒTˆË‘¶ƒ‚ƒWƒ…
48[ƒ‹iARM-M—pj
49 *
50 * ‚±‚̃Cƒ“ƒNƒ‹[ƒhƒtƒ@ƒCƒ‹‚́Ctarget_config.hi‚Ü‚½‚́C‚»‚±‚©‚çƒCƒ“ƒN
51 * ƒ‹[ƒh‚³‚ê‚éƒtƒ@ƒCƒ‹j‚Ì‚Ý‚©‚çƒCƒ“ƒNƒ‹[ƒh‚³‚ê‚éD‘¼‚̃tƒ@ƒCƒ‹‚©‚ç
52 * ’¼ÚƒCƒ“ƒNƒ‹[ƒh‚µ‚Ä‚Í‚È‚ç‚È‚¢D
53 */
54
55#ifndef TOPPERS_PRC_CONFIG_H
56#define TOPPERS_PRC_CONFIG_H
57
58#ifndef TOPPERS_MACRO_ONLY
59
60/*
61 * ƒvƒƒZƒbƒT‚Ì“ÁŽê–½—߂̃Cƒ“ƒ‰ƒCƒ“ŠÖ”’è‹`
62 */
63#include "prc_insn.h"
64
65/*
66 * ”ñƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg—p‚̃Xƒ^ƒbƒN‰Šú’l
67 */
68#define TOPPERS_ISTKPT(istk, istksz) ((STK_T *)((char *)(istk) + (istksz)))
69
70#endif /* TOPPERS_MACRO_ONLY */
71
72#ifndef TOPPERS_MACRO_ONLY
73
74/*
75 * Š„ž‚݃lƒXƒg”
76 */
77extern uint8_t intnest;
78
79/*
80 * ƒRƒ“ƒeƒLƒXƒg‚ÌŽQÆ
81 *
82 */
83Inline bool_t
84sense_context(void)
85{
86 bool_t tskctx;
87
88 if (intnest == 0u){
89 tskctx = false;
90 }
91 else {
92 tskctx = true;
93 }
94
95 return tskctx;
96}
97
98#endif /* TOPPERS_MACRO_ONLY */
99
100/*
101 * TOPPERS•W€Š„ž‚ݏˆ—ƒ‚ƒfƒ‹‚ÌŽÀŒ»
102 *
103 * Š„ž‚Ý—Dæ“xƒ}ƒXƒN‚Æ‚µ‚ẮCBASEPRI‚ð—p‚¢‚éD‘SŠ„ž‚Ý‚ð‹ÖŽ~‚·‚é
104 * ‹@”\‚Æ‚µ‚āCFAULTMASK‚âPRIMASK‚ª‚ ‚邪CƒJ[ƒlƒ‹ŠÇ—ŠO‚ÌŠ„ž‚Ý‚ð
105 * ƒTƒ|[ƒg‚·‚邽‚߁C‚±‚ê‚ç‚ÍCPUƒƒbƒN‚Ì‚½‚ß‚É—p‚¢‚È‚¢D
106 * ‚»‚Ì‚½‚߁CBASEPRI‚ð—p‚¢‚Ä‹[Ž—“I‚ÉCPUƒƒbƒNƒtƒ‰ƒO‚ðŽÀŒ»‚·‚éD
107 *
108 * ‚Ü‚¸CCPUƒƒbƒNó‘Ô‚ðŠÇ—‚·‚½‚߂̕ϐ”(lock_flag)‚ð—pˆÓ‚·‚éD
109 *
110 * CPUƒƒbƒNƒtƒ‰ƒO‚ªƒNƒŠƒA‚³‚ê‚Ä‚¢‚éŠÔ‚́CBASEPRI‚ðƒ‚ƒfƒ‹ã‚ÌŠ„ž‚Ý
111 * —Dæ“xƒ}ƒXƒN‚Ì’l‚ɐݒ肷‚éD‚±‚̊Ԃ́Cƒ‚ƒfƒ‹ã‚ÌŠ„ž‚Ý—Dæ“xƒ}ƒX
112 * ƒN‚́CBASEPRI‚ð—p‚¢‚éD
113 *
114 * ‚»‚ê‚ɑ΂µ‚ÄCPUƒƒbƒNƒtƒ‰ƒO‚ªƒZƒbƒg‚³‚ê‚¢‚éŠÔ‚́CBASEPRI‚ðCƒJ[ƒl
115 * ƒ‹ŠÇ—ŠO‚Ì‚à‚Ì‚ðœ‚­‚·‚ׂĂ̊„ž‚Ý—v‹‚ðƒ}ƒXƒN‚·‚é’l(TIPM_LOCK)‚ƁC
116 * ƒ‚ƒfƒ‹ã‚ÌŠ„ž‚Ý—Dæ“xƒ}ƒXƒN‚Ƃ̍‚‚¢•û‚ɐݒ肷‚éD‚±‚̊Ԃ̃‚ƒfƒ‹ã
117 * ‚ÌŠ„ž‚Ý—Dæ“xƒ}ƒXƒN‚́C‚»‚Ì‚½‚߂̕ϐ”(saved_iipm, “à•”•\Œ»‚Å•ÛŽ)
118 * ‚ð—pˆÓ‚µ‚Ä•ÛŽ‚·‚éD
119 */
120
121/*
122 * Š„ž‚Ý—Dæ“xƒ}ƒXƒN‚ÌŠO•”•\Œ»‚Æ“à•”•\Œ»‚Ì•ÏŠ·
123 *
124 * ƒAƒZƒ“ƒuƒŠŒ¾Œê‚̃\[ƒXƒtƒ@ƒCƒ‹‚©‚çƒCƒ“ƒNƒ‹[ƒh‚·‚éê‡‚Ì‚½‚߂ɁC
125 * CAST‚ðŽg—p
126 * Š„ž‚Ý—Dæ“x‚̃rƒbƒg•(TBITW_IPRI)‚ª 8 ‚̏ꍇ‚́C“à•”—Dæ“x 255
127 * ‚́CŠO•”—Dæ“x -1 ‚ɑΉž‚·‚éD
128 */
129#define EXT_IPM(iipm) (CAST(PRI,((iipm >> (8 - TBITW_IPRI)) - (1 << TBITW_IPRI)))) /* “à•”•\Œ»‚ðŠO•”•\Œ»‚É */
130#define INT_IPM(ipm) (((1 << TBITW_IPRI) - CAST(uint8_t, -(ipm))) << (8 - TBITW_IPRI)) /* ŠO•”•\Œ»‚ð“à•”•\Œ»‚É */
131
132/*
133 * CPUƒƒbƒNó‘Ô‚Å‚ÌŠ„ž‚Ý—Dæ“xƒ}ƒXƒN
134 */
135#define TIPM_LOCK TMIN_INTPRI
136
137/*
138 * CPUƒƒbƒNó‘Ô‚Å‚ÌŠ„ž‚Ý—Dæ“xƒ}ƒXƒN‚Ì“à•”•\Œ»
139 *
140 * TIPM_LOCK‚́CCPUƒƒbƒNó‘Ô‚Å‚ÌBASEPRI‚Ì’lDƒJ[ƒlƒ‹ŠÇ—ŠO‚Ì‚à‚Ì‚ð
141 * œ‚­‚·‚ׂĂ̊„ž‚Ý‚ðƒ}ƒXƒN‚·‚é’l‚É’è‹`‚·‚éD
142 */
143#define IIPM_LOCK INT_IPM(TIPM_LOCK)
144
145/*
146 * TIPM_ENAALLiŠ„ž‚Ý—Dæ“xƒ}ƒXƒN‘S‰ðœj‚Ì“à•”•\Œ»
147 *
148 * BASEPRI‚É '0' ‚ðÝ’è‚·‚邱‚ƂŁC‘SŠ„ž‚Ý‚ð‹–‰Â‚·‚éD
149 */
150#define IIPM_ENAALL (0)
151
152
153#ifndef TOPPERS_MACRO_ONLY
154
155/*
156 * CPUƒƒbƒNƒtƒ‰ƒOŽÀŒ»‚Ì‚½‚߂̕ϐ”
157 *
158 * ‚±‚ê‚ç‚̕ϐ”‚́CCPUƒƒbƒNó‘Ô‚ÌŽž‚̂ݏ‘‚«Š·‚¦‚Ä‚à‚æ‚¢‚Æ‚·‚éD
159 * ƒCƒ“ƒ‰ƒCƒ“ŠÖ”’†‚ŁCƒAƒNƒZƒX‚̏‡˜‚ª•Ï‰»‚µ‚È‚¢‚悤Cvolatile ‚ðŽw’èD
160 */
161extern volatile bool_t lock_flag; /* CPUƒƒbƒNƒtƒ‰ƒO‚Ì’l‚ð•ÛŽ‚·‚é•Ï” */
162extern volatile uint32_t saved_iipm; /* Š„ž‚Ý—Dæ“x‚ðƒ}ƒXƒN‚·‚é•Ï” */
163
164/*
165 * CPUƒƒbƒNó‘Ԃւ̈ڍs
166 *
167 * BASEPRIiƒn[ƒhƒEƒFƒA‚ÌŠ„ž‚Ý—Dæ“xƒ}ƒXƒNj‚ðCsaved_iipm‚É•Û‘¶‚µC
168 * ƒJ[ƒlƒ‹ŠÇ—ŠO‚Ì‚à‚Ì‚ðœ‚­‚·‚ׂĂ̊„ž‚Ý‚ðƒ}ƒXƒN‚·‚é’liTIPM_LOCKj
169 * ‚ɐݒ肷‚éD‚Ü‚½Clock_flag‚ðtrue‚É‚·‚éD
170 *
171 * BASEPRI‚ªCÅ‰‚©‚çTIPM_LOCK‚Æ“¯‚¶‚©‚»‚ê‚æ‚荂‚¢ê‡‚ɂ́C‚»‚ê‚ð
172 * saved_iipm‚É•Û‘¶‚·‚é‚݂̂ŁCTIPM_LOCK‚ɂ͐ݒ肵‚È‚¢D‚±‚ê‚́Cƒ‚ƒfƒ‹
173 * ã‚ÌŠ„ž‚Ý—Dæ“xƒ}ƒXƒN‚ªCTIPM_LOCK‚Æ“¯‚¶‚©‚»‚ê‚æ‚荂‚¢ƒŒƒxƒ‹‚ɐݒè
174 * ‚³‚ê‚Ä‚¢‚éó‘Ô‚É‚ ‚½‚éD
175 *
176 * ‚±‚̊֐”‚́CCPUƒƒbƒNó‘ԁilock_flag‚ªtrue‚̏ó‘ԁj‚ŌĂ΂ê‚邱‚Æ‚Í
177 * ‚È‚¢‚à‚Ì‚Æ‘z’肵‚Ä‚¢‚éD
178 */
179Inline void
180x_lock_cpu(void)
181{
182 uint32_t iipm;
183
184 /*
185 * current_iipm()‚Ì•Ô‚è’l‚𒼐Úsaved_iipm‚É•Û‘¶‚¹‚¸CˆêŽž•Ï”iipm
186 * ‚ð—p‚¢‚Ä‚¢‚é‚̂́Ccurrent_iipm()‚ðŒÄ‚ñ‚¾’¼Œã‚ÉŠ„ž‚Ý‚ª”­¶‚µC
187 * ‹N“®‚³‚ꂽŠ„ž‚ݏˆ—‚Åsaved_iipm‚ª•ÏX‚³‚ê‚é‰Â”\«‚ª‚ ‚邽‚ß‚Å
188 * ‚ ‚éD
189 */
190 iipm = get_basepri();
191 set_basepri(IIPM_LOCK);
192 saved_iipm = iipm;
193 lock_flag = true;
194 /* ƒNƒŠƒeƒBƒJƒ‹ƒZƒNƒVƒ‡ƒ“‚Ì‘OŒã‚сƒ‚ƒŠ‚ª‘‚«Š·‚í‚é‰Â”\«‚ª‚ ‚é */
195 Asm("":::"memory");
196}
197
198#define t_lock_cpu() x_lock_cpu()
199#define i_lock_cpu() x_lock_cpu()
200
201/*
202 * CPUƒƒbƒNó‘Ԃ̉ðœ
203 *
204 * lock_flag‚ðfalse‚É‚µCIPMiƒn[ƒhƒEƒFƒA‚ÌŠ„ž‚Ý—Dæ“xƒ}ƒXƒNj‚ðC
205 * saved_iipm‚É•Û‘¶‚µ‚½’l‚É–ß‚·D
206 *
207 * ‚±‚̊֐”‚́CCPUƒƒbƒNó‘ԁilock_flag‚ªtrue‚̏ó‘ԁj‚ł̂݌Ă΂ê‚é‚à
208 * ‚Ì‚Æ‘z’肵‚Ä‚¢‚éD
209 */
210Inline void
211x_unlock_cpu(void)
212{
213 /* ƒNƒŠƒeƒBƒJƒ‹ƒZƒNƒVƒ‡ƒ“‚Ì‘OŒã‚сƒ‚ƒŠ‚ª‘‚«Š·‚í‚é‰Â”\«‚ª‚ ‚é */
214 Asm("":::"memory");
215 lock_flag = false;
216 set_basepri(saved_iipm);
217}
218
219#define t_unlock_cpu() x_unlock_cpu()
220#define i_unlock_cpu() x_unlock_cpu()
221
222/*
223 * CPUƒƒbƒNó‘Ô‚ÌŽQÆ
224 */
225Inline bool_t
226x_sense_lock(void)
227{
228 return(lock_flag);
229}
230
231#define t_sense_lock() x_sense_lock()
232#define i_sense_lock() x_sense_lock()
233
234
235/*
236 * iƒ‚ƒfƒ‹ã‚́jŠ„ž‚Ý—Dæ“xƒ}ƒXƒN‚̐ݒè
237 *
238 * CPUƒƒbƒNƒtƒ‰ƒO‚ªƒNƒŠƒA‚³‚ê‚Ä‚¢‚鎞‚́Cƒn[ƒhƒEƒFƒA‚ÌŠ„ž‚Ý—Dæ“xƒ}
239 * ƒXƒN‚ðÝ’è‚·‚éDCPUƒƒbƒNƒtƒ‰ƒO‚ªƒZƒbƒg‚³‚ê‚Ä‚¢‚鎞‚́Csaved_iipm
240 * ‚ðÝ’肵C‚³‚ç‚ɁCƒn[ƒhƒEƒFƒA‚ÌŠ„ž‚Ý—Dæ“xƒ}ƒXƒN‚ðCÝ’肵‚悤‚Æ
241 * ‚µ‚½iƒ‚ƒfƒ‹ã‚́jŠ„ž‚Ý—Dæ“xƒ}ƒXƒN‚ÆTIPM_LOCK‚̍‚‚¢•û‚ɐݒ肷‚éD
242 */
243Inline void
244x_set_ipm(PRI intpri)
245{
246 uint8_t iipm = INT_IPM(intpri);
247
248 if (intpri == TIPM_ENAALL){
249 iipm = IIPM_ENAALL;
250 }
251
252 if (!lock_flag) {
253 set_basepri(iipm);
254 }
255 else {
256 saved_iipm = iipm;
257 set_basepri(iipm < IIPM_LOCK ? iipm : IIPM_LOCK);
258 }
259}
260
261#define t_set_ipm(intpri) x_set_ipm(intpri)
262#define i_set_ipm(intpri) x_set_ipm(intpri)
263
264/*
265 * iƒ‚ƒfƒ‹ã‚́jŠ„ž‚Ý—Dæ“xƒ}ƒXƒN‚ÌŽQÆ
266 *
267 * CPUƒƒbƒNƒtƒ‰ƒO‚ªƒNƒŠƒA‚³‚ê‚Ä‚¢‚鎞‚̓n[ƒhƒEƒFƒA‚ÌŠ„ž‚Ý—Dæ“xƒ}
268 * ƒXƒN‚ðCƒZƒbƒg‚³‚ê‚Ä‚¢‚鎞‚Ísaved_iipm‚ðŽQÆ‚·‚éD
269 */
270Inline PRI
271x_get_ipm(void)
272{
273 uint8_t iipm;
274
275 if (!lock_flag) {
276 iipm = get_basepri();
277 }
278 else {
279 iipm = saved_iipm;
280 }
281
282 if (iipm == IIPM_ENAALL) {
283 return(TIPM_ENAALL);
284 }
285 else {
286 return(EXT_IPM(iipm));
287 }
288}
289
290#define t_get_ipm() x_get_ipm()
291#define i_get_ipm() x_get_ipm()
292
293/*
294 * SVCƒnƒ“ƒhƒ‰iprc_support.Sj
295 */
296extern void svc_handler(void);
297
298/*
299 * ƒXƒ^[ƒgƒAƒbƒvƒ‹[ƒ`ƒ“istart.Sj
300 */
301extern void _start(void);
302
303/*
304 * ƒfƒBƒXƒpƒbƒ`ƒƒ‚Ì“®ìŠJŽniprc_support.Sj
305 *
306 * start_dispatch‚́CƒJ[ƒlƒ‹‹N“®Žž‚ɌĂяo‚·‚ׂ«‚à‚̂ŁC‚·‚ׂĂ̊„ž
307 * ‚Ý‚ð‹ÖŽ~‚µ‚½ó‘ԁiŠ„ž‚݃ƒbƒNó‘Ô‚Æ“¯“™‚̏ó‘ԁj‚ŌĂяo‚³‚È‚¯‚ê‚Î
308 * ‚È‚ç‚È‚¢D
309 */
310extern void start_dispatch(void) NoReturn;
311
312
313/*
314 * ƒJ[ƒlƒ‹‚̏I—¹ˆ—‚̌ďo‚µiprc_support.Sj
315 *
316 * call_exit_kernel‚́CƒJ[ƒlƒ‹‚̏I—¹Žž‚ɌĂяo‚·‚ׂ«‚à‚̂ŁC”ñƒ^ƒXƒN
317 * ƒRƒ“ƒeƒLƒXƒg‚ɐ؂芷‚¦‚āCƒJ[ƒlƒ‹‚̏I—¹ˆ—iexit_kernelj‚ðŒÄ‚яo
318 * ‚·D
319 */
320extern void call_exit_kernel(void) NoReturn;
321
322/*
323 * ƒAƒCƒhƒ‹ƒ‹[ƒv‚ÌŽÀ‘•
324 *
325 * ’P‚ÉCPUƒƒbƒNó‘Ô‚ÆCPUƒƒbƒN‰ðœó‘Ô‚ðŒÄ‚яo‚·ŽÀ‘•‚Æ‚·‚éD
326 * ƒXƒŠ[ƒvƒ‚[ƒh‚É“ü‚ê‚éê‡‚Í–{ˆ—‚ðwfi–½—ß‚ð—p‚¢‚ď‘‚«Š·‚¦‚ê‚Ηǂ¢D
327 */
328Inline void
329idle_loop(void)
330{
331 lock_flag = false;
332 /* CPUƒAƒ“ƒƒbƒN => CPUƒƒbƒN */
333 Asm("\tmsr BASEPRI , %0" : : "r"(0) : "memory");
334 Asm("\tmsr BASEPRI , %0" : : "r"(IIPM_LOCK) : "memory");
335 lock_flag = true;
336}
337
338/*
339 * Š„ž‚ݔԍ†EŠ„ž‚݃nƒ“ƒhƒ‰”ԍ†
340 *
341 * Š„ž‚݃nƒ“ƒhƒ‰”ԍ†(inhno)‚ÆŠ„ž‚ݔԍ†(intno)‚́CŠ„‚荞‚Ý”­¶Žž‚É
342 * EPSR‚ɐݒ肳‚ê‚é—áŠO”ԍ†‚Æ‚·‚éD
343 */
344
345/*
346 * Š„ž‚ݔԍ†‚͈̔͂̔»’è
347 */
348#define VALID_INTNO(intno) ((TMIN_INTNO <= (intno)) && ((intno) <= TMAX_INTNO))
349#define VALID_INTNO_DISINT(intno) VALID_INTNO(intno)
350#define VALID_INTNO_CFGINT(intno) VALID_INTNO(intno)
351
352/*
353 * Š„ž‚݃nƒ“ƒhƒ‰‚̐ݒè
354 *
355 * ƒxƒNƒgƒ‹”ԍ†inhno‚ÌŠ„ž‚݃nƒ“ƒhƒ‰‚Ì‹N“®”Ô’nint_entry‚ɐݒ肷‚éDŠ„ž‚Ý
356 * ƒnƒ“ƒhƒ‰ƒe[ƒuƒ‹
357 */
358Inline void
359x_define_inh(INHNO inhno, FP int_entry)
360{
361 /* “Á‚ɍs‚¤ˆ—‚Í‚È‚¢ */
362}
363
364/*
365 * Š„ž‚݃nƒ“ƒhƒ‰‚̏o“üŒûˆ—‚̐¶¬ƒ}ƒNƒ
366 *
367 */
368#define INT_ENTRY(inhno, inthdr) inthdr
369#define INTHDR_ENTRY(inhno, inhno_num, inthdr) extern void inthdr(void);
370
371/*
372 * Š„ž‚Ý—v‹‹ÖŽ~ƒtƒ‰ƒO
373 */
374
375/*
376 * Š„ž‚Ý‘®«‚ªÝ’肳‚ê‚Ä‚¢‚é‚©‚ð”»•Ê‚·‚邽‚߂̕ϐ”ikernel_cfg.cj
377 */
378extern const uint32_t bitpat_cfgint[];
379
380/*
381 * Š„ž‚Ý—v‹‹ÖŽ~ƒtƒ‰ƒO‚̃Zƒbƒg
382 *
383 * Š„ž‚Ý‘®«‚ªÝ’肳‚ê‚Ä‚¢‚È‚¢Š„ž‚Ý—v‹ƒ‰ƒCƒ“‚ɑ΂µ‚ÄŠ„ž‚Ý—v‹‹ÖŽ~
384 * ƒtƒ‰ƒO‚ðƒNƒŠƒA‚µ‚悤‚Æ‚µ‚½ê‡‚ɂ́Cfalse‚ð•Ô‚·D
385 */
386Inline bool_t
387x_disable_int(INTNO intno)
388{
389 uint32_t tmp;
390
391 /*
392 * Š„ž‚Ý‘®«‚ªÝ’肳‚ê‚Ä‚¢‚È‚¢ê‡
393 */
394 if ((bitpat_cfgint[intno >> 5] & (1 << (intno & 0x1f))) == 0x00) {
395 return(false);
396 }
397
398 if (intno == IRQNO_SYSTICK) {
399 tmp = sil_rew_mem((void *)SYSTIC_CONTROL_STATUS);
400 tmp &= ~SYSTIC_TICINT;
401 sil_wrw_mem((void *)SYSTIC_CONTROL_STATUS, tmp);
402 }else {
403 tmp = intno - 16;
404 sil_wrw_mem((void *)NVIC_CLRENA0 + (tmp >> 5), (1 << (tmp & 0x1f)));
405 }
406
407 return(true);
408}
409
410#define t_disable_int(intno) x_disable_int(intno)
411#define i_disable_int(intno) x_disable_int(intno)
412
413/*
414 * Š„ž‚Ý—v‹‹ÖŽ~ƒtƒ‰ƒO‚̉ðœ
415 *
416 * Š„ž‚Ý‘®«‚ªÝ’肳‚ê‚Ä‚¢‚È‚¢Š„ž‚Ý—v‹ƒ‰ƒCƒ“‚ɑ΂µ‚ÄŠ„ž‚Ý—v‹‹ÖŽ~
417 * ƒtƒ‰ƒO‚ðƒNƒŠƒA‚µ‚悤‚Æ‚µ‚½ê‡‚ɂ́Cfalse‚ð•Ô‚·D
418 */
419Inline bool_t
420x_enable_int(INTNO intno)
421{
422 uint32_t tmp;
423
424 /*
425 * Š„ž‚Ý‘®«‚ªÝ’肳‚ê‚Ä‚¢‚È‚¢ê‡
426 */
427 if ((bitpat_cfgint[intno >> 5] & (1 << (intno & 0x1f))) == 0x00) {
428 return(false);
429 }
430
431 if (intno == IRQNO_SYSTICK) {
432 tmp = sil_rew_mem((void *)SYSTIC_CONTROL_STATUS);
433 tmp |= SYSTIC_TICINT;
434 sil_wrw_mem((void *)SYSTIC_CONTROL_STATUS, tmp);
435 }else {
436 tmp = intno - 16;
437 sil_wrw_mem((void *)((uint32_t *)NVIC_SETENA0 + (tmp >> 5)),
438 (1 << (tmp & 0x1f)));
439 }
440
441 return(true);
442}
443
444#define t_enable_int(intno) x_enable_int(intno)
445#define i_enable_int(intno) x_enable_int(intno)
446
447Inline void
448x_clear_int(INTNO intno)
449{
450 uint32_t tmp;
451
452 if (intno != IRQNO_SYSTICK) {
453 tmp = intno - 16;
454 sil_wrw_mem((void *)((uint32_t *)NVIC_CLRENA0 + (tmp >> 5)),
455 (1 << (tmp & 0x1f)));
456 }
457}
458
459/*
460 * Š„ž‚Ý—v‹ƒ‰ƒCƒ“‚Ì‘®«‚̐ݒè
461 */
462extern void x_config_int(INTNO intno, ATR intatr, PRI intpri);
463
464/*
465 * Š„ž‚݃nƒ“ƒhƒ‰“üŒû‚Å•K—v‚ÈIRC‘€ì
466 */
467Inline void
468i_begin_int(INTNO intno)
469{
470 /* “Á‚ɍs‚¤ˆ—‚Í‚È‚¢ */
471}
472
473/*
474 * Š„ž‚݃nƒ“ƒhƒ‰‚̏oŒû‚Å•K—v‚ÈIRC‘€ì
475 */
476Inline void
477i_end_int(INTNO intno)
478{
479 /* “Á‚ɍs‚¤ˆ—‚Í‚È‚¢ */
480}
481
482/*
483 * CPU—áŠOƒnƒ“ƒhƒ‰ŠÖŒW
484 */
485
486/*
487 * CPU—áŠOƒnƒ“ƒhƒ‰”ԍ†
488 */
489#define VALID_EXCNO_DEFEXC(excno) (TMIN_EXCNO <= (excno) && (excno) <= TMAX_EXCNO)
490
491/*
492 * CPU—áŠOƒnƒ“ƒhƒ‰‚Ì‹–‰Â
493 */
494extern void enable_exc(EXCNO excno);
495
496/*
497 * CPU—áŠOƒnƒ“ƒhƒ‰‚Ì‹ÖŽ~
498 */
499extern void disable_exc(EXCNO excno);
500
501/*
502 * CPU—áŠOƒnƒ“ƒhƒ‰‚̐ݒè
503 */
504Inline void
505x_define_exc(EXCNO excno, FP exc_entry)
506{
507 /*
508 * ˆê•”‚Ì—áŠO‚Í‹–‰Â‚ðs‚¤•K—v‚ª‚ ‚é
509 */
510 enable_exc(excno);
511}
512
513/*
514 * CPU—áŠOƒnƒ“ƒhƒ‰‚Ì“üŒûˆ—‚̐¶¬ƒ}ƒNƒ
515 */
516#define EXC_ENTRY(excno, exchdr) exchdr
517#define EXCHDR_ENTRY(excno, excno_num, exchdr) extern void exchdr(void *p_excinf);
518
519
520/*
521 * CPU—áŠOƒGƒ“ƒgƒŠiprc_support.Sj
522 */
523extern void exc_entry(void);
524
525/*
526 * Š„ž‚݃Gƒ“ƒgƒŠiprc_support.Sj
527 */
528extern void int_entry(void);
529
530/*
531 * ƒvƒƒZƒbƒTˆË‘¶‚̏‰Šú‰»
532 */
533extern void prc_initialize(void);
534
535/*
536 * ƒvƒƒZƒbƒTˆË‘¶‚̏I—¹Žžˆ—
537 */
538extern void prc_terminate(void) NoReturn;
539
540/*
541 * atexit‚̏ˆ—‚ƃfƒXƒgƒ‰ƒNƒ^‚ÌŽÀs
542 */
543Inline void
544call_atexit(void)
545{
546 extern void software_term_hook(void);
547 void (*volatile fp)(void) = software_term_hook;
548
549 /*
550 * software_term_hook‚ւ̃|ƒCƒ“ƒ^‚ðCˆê’UvolatileŽw’è‚Ì‚ ‚éfp‚É‘ã
551 * “ü‚µ‚Ä‚©‚çŽg‚¤‚̂́C0‚Æ‚Ì”äŠr‚ªÅ“K‰»‚ō폜‚³‚ê‚È‚¢‚悤‚É‚·‚邽
552 * ‚ß‚Å‚ ‚éD
553 */
554 if (fp != 0) {
555 (*fp)();
556 }
557}
558
559/*
560 * “o˜^‚³‚ê‚Ä‚¢‚È‚¢—áŠO‚ª”­¶‚·‚é‚ƌĂяo‚³‚ê‚é
561 */
562extern void default_exc_handler(void *p_excinf);
563
564/*
565 * –¢“o˜^‚ÌŠ„ž‚Ý‚ª”­¶‚µ‚½ê‡‚ɌĂяo‚³‚ê‚é
566 */
567extern void default_int_handler(void *p_excinf);
568
569#endif /* TOPPERS_MACRO_ONLY */
570#endif /* TOPPERS_PRC_CONFIG_H */
Note: See TracBrowser for help on using the repository browser.