source: ssp_qb_r5f100le_cs/trunk/arch/rl78_ca78k0r/prc_support.asm@ 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: 8.5 KB
Line 
1;
2; TOPPERS/SSP Kernel
3; Smallest Set Profile Kernel
4;
5; Copyright (C) 2014 by Naoki Saito
6; Nagoya Municipal Industrial Research Institute, JAPAN
7;
8; ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì (1)`(4) ‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
9; ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü•ÏE
10; Ä”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
11; (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ìŒ 
12; •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[ƒX
13; ƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
14; (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg—p
15; ‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
16ƒƒ“ƒgi—˜—pŽÒƒ}
17; ƒjƒ…
18ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•Û
19; Ø‹K’è‚ðŒfÚ‚·‚邱‚ƁD
20; (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg—p
21; ‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±‚ƁD
22; (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
23ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
24ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ì
25; Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
26; (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É•ñ
27; ‚·‚邱‚ƁD
28; (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹ŠQ
29; ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD‚Ü‚½C
30; –{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝—R‚ÉŠî‚Ã
31; ‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
32;
33; –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨‚æ
34; ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC“Á’è‚ÌŽg—p–Ú“I‚ɑ΂·
35; ‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p
36; ‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»‚̐ӔC‚ð•‰
37; ‚í‚È‚¢D
38;
39;
40
41;
42; ƒJ[ƒlƒ‹ŽÀ‘•‚̃vƒƒZƒbƒTˆË‘¶•”•ª
43;
44
45;
46; ƒ}ƒNƒ’è‹`‚̃Cƒ“ƒNƒ‹[ƒh
47;
48$INCLUDE(prc_support_def.inc)
49
50;
51; ƒOƒ[ƒoƒ‹ƒVƒ“ƒ{ƒ‹
52;
53 ; ƒRƒ“ƒpƒCƒ‰‚ªŽg—p‚·‚é saddr—̈æ‚̃ŒƒWƒXƒ^
54 extrn _@RTARG0,_@RTARG2,_@RTARG4,_@RTARG6,_@SEGAX,_@SEGDE
55 extrn _@NRARG0,_@NRARG1,_@NRARG2,_@NRARG3
56 extrn _@NRAT00,_@NRAT02,_@NRAT04,_@NRAT06
57 ; kernel_cfg.c
58 extrn __kernel_istkpt ; ƒXƒ^ƒbƒNƒ|ƒCƒ“ƒ^‚̏‰Šú’l
59 ; prc_config.c
60 extrn _t_lock_cpu ; CPUƒƒbƒNó‘Ԃւ̈ڍs
61 extrn __kernel_intnest ; Š„ž‚݂̃lƒXƒgƒJƒEƒ“ƒ^
62 extrn __kernel_lock_flag ; CPUƒƒbƒNƒtƒ‰ƒO
63 ; task.c
64 extrn __kernel_dispatcher ; ƒfƒBƒXƒpƒbƒ`ƒƒ
65 extrn __kernel_reqflg ; ƒfƒBƒXƒpƒbƒ`—v‹ƒtƒ‰ƒO
66 extrn __kernel_disdsp ; ƒfƒBƒXƒpƒbƒ`‹ÖŽ~ó‘Ô
67 extrn __kernel_search_schedtsk ; Å‚—Dæ“x‚̃T[ƒ`
68 extrn __kernel_run_task ; ƒ^ƒXƒN‚ÌŠJŽn
69 ; startup.c
70 extrn __kernel_exit_kernel ; ƒJ[ƒlƒ‹‚̏I—¹ˆ—
71
72 ; prc_support.asm
73 public __kernel_start_dispatch ; ƒfƒBƒXƒpƒbƒ`‚ÌŠJŽnˆ—
74 public __kernel_call_exit_kernel ; I—¹ˆ—‚̃R[ƒ‹
75 public __kernel_interrupt_entry ; Š„ž‚Ý‚Ì“üŒûˆ—(‹¤’Ê•”)
76 public __kernel_int_return ; ƒŒƒWƒXƒ^‚𕜋A‚µ‚ÄŠ„ž‚Ý”­¶Œ³‚ÖƒŠƒ^[ƒ“
77 public _unused_interrupt ; –¢Žg—pŠ„ž‚݂̏ˆ—
78
79;
80; ƒRƒ“ƒpƒCƒ‰‚ÅŽg—p‚·‚ésaddr—̈æ‚̃ŒƒWƒXƒ^‚ð•Û‘¶
81;
82restore_saddr_regs macro
83$if (ALLOC_REGVAR_TO_SADDR) ; -qr ƒIƒvƒVƒ‡ƒ“‚ðŽg—p‚·‚éê‡
84 pop ax ; ƒŒƒWƒXƒ^•œ‹A
85 movw _@NRAT06, ax ;
86 pop ax ;
87 movw _@NRAT04, ax ;
88 pop ax ;
89 movw _@NRAT02, ax ;
90 pop ax ;
91 movw _@NRAT00, ax ;
92 pop ax ;
93 movw _@NRARG3, ax ;
94 pop ax ;
95 movw _@NRARG2, ax ;
96 pop ax ;
97 movw _@NRARG1, ax ;
98 pop ax ;
99 movw _@NRARG0, ax ;
100$endif
101 pop ax ; ƒŒƒWƒXƒ^•œ‹A
102 movw _@SEGDE, ax ;
103 pop ax ;
104 movw _@SEGAX, ax ;
105 pop ax ;
106 movw _@RTARG6, ax ;
107 pop ax ;
108 movw _@RTARG4, ax ;
109 pop ax ;
110 movw _@RTARG2, ax ;
111 pop ax ;
112 movw _@RTARG0, ax ;
113 endm
114
115;
116; ƒXƒ^ƒbƒNƒ|ƒCƒ“ƒ^‚ð‰Šú‰»
117;
118reset_sp macro
119 movw de, #__kernel_istkpt
120 mov es, #00H
121 movw ax, es:[de]
122 movw sp, ax
123 endm
124
125;
126; PSW ‚Ì ISP1 = 1, ISP0 = 1 ‚É‚µ‚ÄŠ„ž‚݂̃}ƒXƒN‚ð‰ðœ‚·‚é
127;
128clear_pswisp_mask macro
129 mov a, psw
130 and a, #0f9h
131 or a, #06h ; PSW.ISP{1,0}=(1,1)
132 mov psw, a
133 endm
134
135@@CODE CSEG BASE
136
137;
138; ƒJ[ƒlƒ‹‚Ì“®ìŠJŽn‚É•K—v‚Æ‚³‚ê‚éŒãŽn––‚ðs‚¤‚½‚߂̊֐”
139; sta_ker(startup.c) ‚©‚çŒÄ‚яo‚³‚ê‚éD
140;
141__kernel_start_dispatch:
142 ;
143 ; CPUƒƒbƒNó‘Ô‚Æ‘SŠ„ž‚݃ƒbƒNó‘Ô‚Æ‚ð‹æ•Ê‚·‚é•K—v‚ª‚ ‚éê‡C
144 ; CPUƒƒbƒNó‘Ô‚É‚µC‘SŠ„ž‚݃ƒbƒN‘Š“–‚̏ó‘Ô‚ð‰ðœ‚·‚éD
145 ;
146 call !!_t_lock_cpu
147$_IF (TMIN_INTPRI_EQU_MINUS4)
148 clear_pswisp_mask
149$ELSE
150 ei
151$ENDIF
152 ;
153 ; ƒXƒ^ƒbƒNƒ|ƒCƒ“ƒ^‚ð‰Šú‰»‚·‚é
154 ; sta_ker ‚©‚ç start_dispatch ‚̊֐”ƒR[ƒ‹‚É‚æ‚éƒXƒ^ƒbƒNÁ”‚ð
155 ; ƒNƒŠƒA‚·‚邽‚߁CƒXƒ^ƒbƒNƒ|ƒCƒ“ƒ^‚ð‰Šú‰»‚·‚éD
156 ;
157 reset_sp
158
159 ;
160 ; dispatcher (task.c) ‚ÖƒWƒƒƒ“ƒv‚·‚é
161 ; ŠÖ”ƒR[ƒ‹‚É‚µ‚È‚¢‚̂̓Xƒ^ƒbƒN‚ðß–ñ‚·‚邽‚߁D
162 ;
163 ; dispatcher (kernel/task.c) ‚̌Ăяo‚µ
164 br !!__kernel_dispatcher
165
166
167;
168; I—¹ˆ—‚̌Ăяo‚µ
169; ƒXƒ^ƒbƒNƒ|ƒCƒ“ƒ^‚ð‰Šú‰»‚µCexit_kernel ‚ðŒÄ‚яo‚·D
170;
171 __kernel_call_exit_kernel:
172 reset_sp
173 br __kernel_exit_kernel
174
175
176@@BASE CSEG BASE
177
178;
179; Š„ž‚Ý/CPU—áŠO‚̏o“üŒûˆ—(‹¤’Ê•”)
180; ƒJ[ƒlƒ‹ŠÇ—‚ÌŠ„ž‚Ý‚Ü‚½‚ÍCPU—áŠO‚̏ꍇ‚ɃŒƒWƒXƒ^•Û‘¶ŒãCŒÄ‚яo‚³‚ê‚éD
181;
182; ‘O’ñðŒ
183; EPSWƒŒƒWƒXƒ^‚ÌIEƒrƒbƒg=0, ISP‚ÍŽó•t‚¯‚½Š„ž‚Ý‚ÌISP.
184; Eƒnƒ“ƒhƒ‰‚̃AƒhƒŒƒX‚ª bc ‚ÉŠi”[‚³‚ê‚Ä‚¢‚é.
185; ECPU—áŠOƒnƒ“ƒhƒ‰‚Ì“üŒû‚©‚ç—ˆ‚½ê‡CƒXƒ^ƒbƒNƒ|ƒCƒ“ƒ^‚Ì
186; æ“ª”Ô’n(p_excinf)‚ª ax ‚ÉŠi”[‚³‚ê‚Ä‚¨‚èC
187; ‚±‚ê‚ÍCPU—áŠOƒnƒ“ƒhƒ‰‚̈ø”(p_excinf)‚Æ‚µ‚Ä‚»‚Ì‚Ü‚Ü“n‚³‚ê‚éD
188;
189; ƒŒƒWƒXƒ^‚ªƒXƒ^ƒbƒNã‚ɂǂ̂悤‚É•Û‘¶‚³‚ê‚Ä‚¢‚é‚©‚ðˆÈ‰º‚ÉŽ¦‚·.
190; }‚Í•À‚я‡‚Ì‚Ý‚ð•\Œ»‚µ‚½‚à‚Ì‚Å‚ ‚èCƒTƒCƒY‚ðl—¶‚µ‚Ä‚¢‚È‚¢‚±‚Æ‚É’ˆÓ‚·‚éD
191; ³Šm‚ɂ̓f[ƒ^ƒV[ƒg‚ðŽQÆ‚Ì‚±‚ƁD
192; ‚±‚̐}‚ł͏オ’áˆÊ, ‰º‚ª‚ˆÊ‚̃AƒhƒŒƒX‚Å, ƒXƒ^ƒbƒN‚͐}‚̉º‘¤‚©‚ç
193; ã•ûŒü‚ÉŒü‚©‚Á‚Đςݏグ‚ç‚ê‚é‚à‚Ì‚Æ‚·‚é.
194;
195; ¦1 saddr—̈æ‚̃[ƒNƒGƒŠƒA‚̓Rƒ“ƒpƒCƒ‰ƒIƒvƒVƒ‡ƒ“ -qr ‚ðŽw’è‚·‚éê‡‚É
196; •Û‘¶‚ª•K—v‚Å‚ ‚èC’ʏí‚Í•Û‘¶‚µ‚È‚¢D•Û‘¶‚·‚éê‡‚̓AƒZƒ“ƒuƒ‰ƒIƒvƒVƒ‡ƒ“
197; ‚ɂāuALLOC_REGVAR_TO_SADDRv‚ð’è‹`‚·‚邱‚ƁD
198;
199; ¦2 CPU—áŠO‚Ì“üŒû‚ðŒo—R‚µ‚½ê‡‚Ì‚Ý•Û‘¶‚³‚ê‚é
200;
201;
202; ---------------<-- p_excinf(¦)
203; | saddr—̈æ |
204; |ƒ[ƒN—pƒGƒŠƒA|
205; | (16byte)¦1 |
206; ---------------<-- p_excinf
207; | saddr—̈æ |
208; |ƒZƒOƒƒ“ƒgî•ñ|
209; | Ši”[—pƒGƒŠƒA |
210; | (4byte) |
211; ---------------
212; | saddr—̈æ |
213; | ƒ‰ƒ“ƒ^ƒCƒ€ |
214; | ˆø”ƒGƒŠƒA |
215; | (8byte) |
216; ---------------
217; | ES,CS(2byte) |
218; ---------------
219; | HL(2byte) |
220; ---------------
221; | DE(2byte) |
222; ---------------
223; | BC(2byte) |
224; ---------------
225; | AX(2byte) |
226; ---------------
227; | PC(2byte) |
228; ---------------
229; | PSW(1byte) |
230; ---------------
231;
232; ƒnƒ“ƒhƒ‰‚©‚烊ƒ^[ƒ“‚µ‚½Œã‚Í, ‘½dŠ„ž‚Ý‚Å‚È‚­, ‚©‚C
233; reqflg ‚ª TRUEC‚©‚Cdisdsp ‚ª FALSE ‚ÌŽž‚ɁCinterrupt_dispatch ‚Ö•ªŠò‚·‚éD
234;
235; ‘½dŠ„ž‚Ý‚©‚Ç‚¤‚©‚ÍŠ„ž‚݃lƒXƒgƒJƒEƒ“ƒ^‚Ì’l‚Å”»’è‚·‚é.
236; intnest > 0 ‚È‚ç‚Α½dŠ„ž‚Ý‚Å‚ ‚é‚Æ”»’è‚·‚é.
237;
238
239__kernel_interrupt_entry:
240 inc !__kernel_intnest ; ƒlƒXƒgƒJƒEƒ“ƒ^‚ðƒCƒ“ƒNƒŠƒƒ“ƒg
241 ei ; Š„ž‚Ý‹–‰Â(IPL‚͎󂯕t‚¯‚ç‚ꂽŠ„ž‚݂̃Œƒxƒ‹)
242 call bc ; Š„ž‚݃nƒ“ƒhƒ‰ŒÄ‚яo‚µ
243 di ; Š„ž‚Ý‹ÖŽ~
244 dec !__kernel_intnest ; ƒlƒXƒgƒJƒEƒ“ƒ^‚ðƒfƒNƒŠƒƒ“ƒg
245 bnz $__kernel_int_return ; –ß‚èæ‚ª”ñƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg(”ñƒ[ƒ)‚È‚ç’P‚ɃŠƒ^[ƒ“
246 movw ax,!__kernel_reqflg ; ƒfƒBƒXƒpƒbƒ`—v‹‚ª‚ ‚é‚©‚Ç‚¤‚©
247 cmpw ax, #0
248 bz $__kernel_int_return ; ‚È‚¯‚ê‚΁C’P‚ɃŠƒ^[ƒ“
249 movw ax, #0
250 movw !__kernel_reqflg, ax ; reqflg = FALSE ‚É–ß‚µ‚Ä‚¨‚­
251 movw ax, !__kernel_disdsp ; ƒfƒBƒXƒpƒbƒ`‹ÖŽ~‚©‚Ç‚¤‚©
252 cmpw ax, #0
253 bnz $__kernel_int_return ; ‹ÖŽ~‚È‚çC’P‚ɃŠƒ^[ƒ“
254
255;
256; Š„ž‚݂̏oŒûˆ—(ƒfƒBƒXƒpƒbƒ`•t‚«)
257; CPU ƒƒbƒN‘Š“–‚̏ó‘ԂɈڍs‚µCV‹Kƒ^ƒXƒN‚ðŠJŽn‚·‚é
258;
259; ‘O’ñðŒF
260; PSWƒŒƒWƒXƒ^‚ÌIEƒtƒ‰ƒO = 0 (Š„ž‚Ý‹ÖŽ~)
261; PSWƒŒƒWƒXƒ^‚ÌISP{1,0} = Žó‚¯•t‚¯‚½Š„ž‚Ý‚ÌŠ„ž‚݃Œƒxƒ‹
262;
263__kernel_interrupt_dispatch:
264 call !!_t_lock_cpu
265$_IF (TMIN_INTPRI_EQU_MINUS4)
266 clear_pswisp_mask
267$ELSE
268 ei
269$ENDIF
270 call !!__kernel_search_schedtsk
271 movw ax, bc
272 call !!__kernel_run_task
273
274 ; run_task ‚©‚ç‚̃Šƒ^[ƒ“Œã‚̏ó‘Ô: CPUƒƒbƒNó‘Ô
275 ; __kernel_int_return ‚Ì reti ‚Å PSW ‚Ì IE, ISP ‚Í
276 ; Š„ž‚Ý”­¶‘O‚̏ó‘Ԃɖ߂邽‚߁Clock_flag ‚¾‚¯Œ³‚É–ß‚·D
277 movw ax, #0
278 movw !__kernel_lock_flag, ax ; lock_flag ‚ðƒNƒŠƒA
279
280;
281; ƒŒƒWƒXƒ^•œ‹A‚µ‚ÄŠ„ž‚Ý‚©‚烊ƒ^[ƒ“
282;
283__kernel_int_return:
284 restore_saddr_regs ; saddr—̈æ‚̃ŒƒWƒXƒ^•œ‹A
285 pop ax ; ES, CS ‚Ì•œ‹A
286 mov cs, a ;
287 mov a, x ;
288 mov es, a ;
289 pop hl ; ƒŒƒWƒXƒ^‚𕜋A
290 pop de
291 pop bc
292 pop ax
293 reti
294
295;
296; –³ŒÀƒ‹[ƒv(”O‚Ì‚½‚ß)
297;
298_loop:
299 br $_loop
300
301;
302; –¢Žg—pŠ„ž‚Ý
303;
304_unused_interrupt:
305 reti
306
307 end
Note: See TracBrowser for help on using the repository browser.