source: uKadecot/trunk/ssp/include/kernel.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: 7.6 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) 2004-2009 by Embedded and Real-Time Systems Laboratory
8 * Graduate School of Information Science, Nagoya Univ., JAPAN
9 * Copyright (C) 2010-2015 by Naoki Saito
10 * Nagoya Municipal Industrial Research Institute, JAPAN
11 * Copyright (C) 2010-2012 by Meika Sugimoto
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‰ü•ÏE
15 * Ä”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‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[ƒX
18 * ƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
19 * (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg—p
20 * ‚Å‚«‚éŒ`‚ōĔ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—p
26 * ‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±‚Ɓ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‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹ŠQ
34 * ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD‚Ü‚½C
35 * –{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝—R‚ÉŠî‚Ã
36 * ‚­¿‹‚©‚ç‚à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“Á’è‚ÌŽg—p–Ú“I‚ɑ΂·
40 * ‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p
41 * ‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»‚̐ӔC‚ð•‰
42 * ‚í‚È‚¢D
43 *
44 */
45
46/*
47 * TOPPERS/SSPƒJ[ƒlƒ‹ •W€ƒwƒbƒ_ƒtƒ@ƒCƒ‹
48 *
49 * TOPPERS/SSPƒJ[ƒlƒ‹‚ªƒTƒ|[ƒg‚·‚éƒT[ƒrƒXƒR[ƒ‹‚̐錾‚ƁC•K—v‚ȃf[
50 * ƒ^Œ^C’萔Cƒ}ƒNƒ‚Ì’è‹`‚ðŠÜ‚Þƒwƒbƒ_ƒtƒ@ƒCƒ‹D
51 *
52 * ƒAƒZƒ“ƒuƒŠŒ¾Œê‚̃\[ƒXƒtƒ@ƒCƒ‹‚©‚炱‚̃tƒ@ƒCƒ‹‚ðƒCƒ“ƒNƒ‹[ƒh‚·‚鎞
53 * ‚́CTOPPERS_MACRO_ONLY‚ð’è‹`‚µ‚Ä‚¨‚­D‚±‚ê‚É‚æ‚èCƒ}ƒNƒ’è‹`ˆÈŠO‚ð
54 * œ‚­‚悤‚É‚È‚Á‚Ä‚¢‚éD
55 *
56 * ‚±‚̃tƒ@ƒCƒ‹‚ðƒCƒ“ƒNƒ‹[ƒh‚·‚é‘O‚ɃCƒ“ƒNƒ‹[ƒh‚µ‚Ä‚¨‚­‚ׂ«ƒtƒ@ƒCƒ‹
57 * ‚Í‚È‚¢D
58 */
59
60#ifndef TOPPERS_KERNEL_H
61#define TOPPERS_KERNEL_H
62
63/*
64 * TOPPERS‹¤’ʂ̃f[ƒ^Œ^E’萔Eƒ}ƒNƒ
65 */
66#include <t_stddef.h>
67
68/*
69 * ƒ^[ƒQƒbƒgˆË‘¶•”
70 */
71#include "target_kernel.h"
72#ifndef TOPPERS_MACRO_ONLY
73
74/*
75 * ƒf[ƒ^Œ^‚Ì’è‹`
76 */
77
78/*
79 * ƒrƒbƒgƒpƒ^[ƒ“‚âƒIƒuƒWƒFƒNƒg”ԍ†‚ÌŒ^’è‹`
80 */
81typedef uint_t INTNO; /* Š„ž‚ݔԍ† */
82typedef uint_t INHNO; /* Š„ž‚݃nƒ“ƒhƒ‰”ԍ† */
83typedef uint_t EXCNO; /* CPU—áŠOƒnƒ“ƒhƒ‰”ԍ† */
84typedef unsigned long FLGPTN; /* ƒCƒxƒ“ƒgƒtƒ‰ƒOƒpƒ^[ƒ“ */
85
86
87/*
88 * ˆ—’PˆÊ‚ÌŒ^’è‹`
89 */
90typedef void (*TASK)(intptr_t exinf);
91typedef void (*ISR)(intptr_t exinf);
92typedef void (*INTHDR)(void);
93typedef void (*EXCHDR)(void *p_excinf);
94typedef void (*INIRTN)(intptr_t exinf);
95typedef void (*TERRTN)(intptr_t exinf);
96typedef void (*CYCHDR)(intptr_t exinf);
97typedef void (*ALMHDR)(intptr_t exinf);
98
99/*
100 * ƒƒ‚ƒŠ—̈æŠm•Û‚Ì‚½‚ß‚ÌŒ^’è‹`
101 */
102#ifndef TOPPERS_STK_T
103#define TOPPERS_STK_T intptr_t
104#endif /* TOPPERS_STK_T */
105typedef TOPPERS_STK_T STK_T; /* ƒXƒ^ƒbƒN—̈æ‚ðŠm•Û‚·‚邽‚ß‚ÌŒ^ */
106
107
108/*
109 * ƒT[ƒrƒXƒR[ƒ‹‚̐錾
110 */
111
112/*
113 * ƒ^ƒXƒNŠÇ—‹@”\
114 */
115extern ER act_tsk(ID tskid);
116extern ER iact_tsk(ID tskid);
117
118/*
119 * “¯ŠúE’ʐM‹@”\
120 */
121
122/* ƒf[ƒ^ƒLƒ…
123[ */
124extern ER psnd_dtq(ID dtqid, intptr_t data);
125extern ER ipsnd_dtq(ID dtqid, intptr_t data);
126extern ER prcv_dtq(ID dtqid, intptr_t *p_data);
127
128/* ƒCƒxƒ“ƒgƒtƒ‰ƒO */
129extern ER set_flg(ID flgid, FLGPTN setptn);
130extern ER iset_flg(ID flgid, FLGPTN setptn);
131extern ER clr_flg(ID flgid, FLGPTN clrptn);
132extern ER pol_flg(ID flgid, FLGPTN waiptn, MODE wfmode, FLGPTN *p_flgptn);
133
134/*
135 * ƒVƒXƒeƒ€ó‘ÔŠÇ—‹@”\
136 */
137extern ER loc_cpu(void);
138extern ER iloc_cpu(void);
139extern ER unl_cpu(void);
140extern ER iunl_cpu(void);
141extern ER dis_dsp(void);
142extern ER ena_dsp(void);
143extern bool_t sns_ctx(void);
144extern bool_t sns_loc(void);
145extern bool_t sns_dsp(void);
146extern bool_t sns_dpn(void);
147extern bool_t sns_ker(void);
148extern ER ext_ker(void);
149
150/*
151 * Š„ž‚ÝŠÇ—‹@”\
152 */
153extern ER dis_int(INTNO intno);
154extern ER ena_int(INTNO intno);
155
156/*
157 * ŽüŠúƒnƒ“ƒhƒ‰‹@”\
158 */
159extern ER sta_cyc(ID cycid);
160extern ER stp_cyc(ID cycid);
161
162/*
163 * ƒAƒ‰[ƒ€ƒnƒ“ƒhƒ‰‹@”\
164 */
165extern ER sta_alm(ID almid , RELTIM almtim);
166extern ER ista_alm(ID almid , RELTIM almtim);
167extern ER stp_alm(ID almid);
168extern ER istp_alm(ID almid);
169
170/*
171 * ƒVƒXƒeƒ€ŽžŠÇ—‹@”\
172 */
173extern ER get_tim(SYSTIM *p_systim);
174
175#endif /* TOPPERS_MACRO_ONLY */
176
177/*
178 * ƒIƒuƒWƒFƒNƒg‘®«‚Ì’è‹`
179 */
180#define TA_RSTR UINT_C(0x04) /* §–ñƒ^ƒXƒN */
181
182#define TA_CLR UINT_C(0x04) /* ƒCƒxƒ“ƒgƒtƒ‰ƒO‚̃NƒŠƒAŽw’è */
183
184#define TA_ACT UINT_C(0x02) /* ƒ^ƒXƒN‚ð‹N“®‚³‚ꂽó‘ԂŐ¶¬ */
185
186#define TA_STA UINT_C(0x02) /* ŽüŠúƒnƒ“ƒhƒ‰‚𓮍ìó‘ԂŐ¶¬ */
187
188#define TA_NONKERNEL UINT_C(0x02) /* ƒJ[ƒlƒ‹ŠÇ—ŠO‚ÌŠ„ž‚Ý */
189
190#define TA_ENAINT UINT_C(0x01) /* Š„ž‚Ý—v‹‹ÖŽ~ƒtƒ‰ƒO‚ðƒNƒŠƒA */
191#define TA_EDGE UINT_C(0x02) /* ƒGƒbƒWƒgƒŠƒK */
192
193/*
194 * ƒT[ƒrƒXƒR[ƒ‹‚Ì“®ìƒ‚[ƒh‚Ì’è‹`
195 */
196#define TWF_ORW UINT_C(0x01) /* ƒCƒxƒ“ƒgƒtƒ‰ƒO‚ÌOR‘Ò‚¿ */
197#define TWF_ANDW UINT_C(0x02) /* ƒCƒxƒ“ƒgƒtƒ‰ƒO‚ÌAND‘Ò‚¿ */
198
199/*
200 * ‚»‚Ì‘¼‚̒萔‚Ì’è‹`
201 */
202#define TSK_SELF 0 /* Ž©ƒ^ƒXƒNŽw’è */
203#define TSK_NONE 0 /* ŠY“–‚·‚éƒ^ƒXƒN‚ª‚È‚¢ */
204
205#define TPRI_INI 0 /* ƒ^ƒXƒN‚Ì‹N“®Žž—Dæ“x */
206
207#define TIPM_ENAALL 0 /* Š„ž‚Ý—Dæ“xƒ}ƒXƒN‘S‰ðœ */
208
209/*
210 * \¬’萔‚ƃ}ƒNƒ
211 */
212
213/*
214 * —Dæ“x‚͈̔Í
215 */
216#define TMIN_TPRI 1 /* ƒ^ƒXƒN—Dæ“x‚̍ŏ¬’liÅ‚’lj*/
217#ifndef TMAX_TPRI
218 #define TMAX_TPRI 16 /* ƒ^ƒXƒN—Dæ“x‚̍őå’liÅ’á’lj*/
219#elif (TMAX_TPRI != 8) && (TMAX_TPRI != 16)
220 #error "TMAX_TPRI must defined 8 or 16."
221#endif /* TMAX_TPRI */
222
223#define TMIN_ISRPRI 1 /* Š„ž‚݃T[ƒrƒXƒ‹[ƒ`ƒ“—Dæ“x‚̍ŏ¬’l */
224#ifndef TMAX_ISRPRI
225 #define TMAX_ISRPRI 16 /* Š„ž‚݃T[ƒrƒXƒ‹[ƒ`ƒ“—Dæ“x‚̍őå’l */
226#elif (TMAX_ISRPRI != 8) && (TMAX_ISRPRI != 16)
227 #error "TMAX_ISRPRI must defined 8 or 16."
228#endif /* TMAX_ISRPRI */
229
230/*
231 * ƒo[ƒWƒ‡ƒ“î•ñ
232 */
233#define TKERNEL_MAKER UINT_C(0x0118) /* ƒJ[ƒlƒ‹‚̃[ƒJ[ƒR[ƒh */
234#define TKERNEL_PRID UINT_C(0x0007) /* ƒJ[ƒlƒ‹‚ÌŽ¯•Ê”ԍ† */
235#define TKERNEL_SPVER UINT_C(0xf511) /* ƒJ[ƒlƒ‹Žd—l‚̃o[ƒWƒ‡ƒ“”ԍ† */
236#define TKERNEL_PRVER UINT_C(0x1030) /* ƒJ[ƒlƒ‹‚̃o[ƒWƒ‡ƒ“”ԍ† */
237
238/*
239 * ƒLƒ…
240[ƒCƒ“ƒO‰ñ”‚̍őå’l
241 */
242#define TMAX_ACTCNT UINT_C(1) /* ‹N“®—v‹ƒLƒ…
243[ƒCƒ“ƒO”‚̍őå’l */
244
245/*
246 * ƒrƒbƒgƒpƒ^[ƒ“‚̃rƒbƒg”
247 */
248#ifndef TBIT_FLGPTN /* ƒCƒxƒ“ƒgƒtƒ‰ƒO‚̃rƒbƒg” */
249#define TBIT_FLGPTN (sizeof(FLGPTN) * CHAR_BIT)
250#endif /* TBIT_FLGPTN */
251
252/*
253 * ƒƒ‚ƒŠ—̈æŠm•Û‚Ì‚½‚߂̃}ƒNƒ
254 *
255 * ˆÈ‰º‚ÌTOPPERS_COUNT_SZ‚ÆTOPPERS_ROUND_SZ‚Ì’è‹`‚́Cunit‚ª2‚̋Џæ‚Å‚ 
256 * ‚邱‚Æ‚ð‰¼’è‚µ‚Ä‚¢‚éD
257 */
258#ifndef TOPPERS_COUNT_SZ
259#define TOPPERS_COUNT_SZ(sz, unit) (((sz) + (unit) - 1) / (unit))
260#endif /* TOPPERS_COUNT_SZ */
261#ifndef TOPPERS_ROUND_SZ
262#define TOPPERS_ROUND_SZ(sz, unit) (((sz) + (unit) - 1) & ~((unit) - 1))
263#endif /* TOPPERS_ROUND_SZ */
264
265#define COUNT_STK_T(sz) TOPPERS_COUNT_SZ((sz), sizeof(STK_T))
266#define ROUND_STK_T(sz) TOPPERS_ROUND_SZ((sz), sizeof(STK_T))
267
268/*
269 * ‚»‚Ì‘¼‚̍\¬’萔
270 */
271#define TMAX_MAXCYC UINT_C(16) /* ŽüŠúƒnƒ“ƒhƒ‰‚̍ő吔 */
272#define TMAX_MAXALM UINT_C(16) /* ƒAƒ‰[ƒ€ƒnƒ“ƒhƒ‰‚̍ő吔 */
273
274#endif /* TOPPERS_KERNEL_H */
Note: See TracBrowser for help on using the repository browser.