source: UsbWattMeter/trunk/asp_dcre/arch/rx630_ccrx/prc_support.src@ 164

Last change on this file since 164 was 164, checked in by coas-nagasima, 6 years ago

TOPPERS/ECNLサンプルアプリ「USB充電器電力計」を追加

File size: 25.2 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) 2007 by Embedded and Real-Time Systems Laboratory
9; Graduate School of Information Science, Nagoya Univ., JAPAN
10; Copyright (C) 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_support.src 536 2014-10-09 23:11:40Z coas-nagasima $
47;
48
49;
50; ƒvƒƒZƒbƒTˆË‘¶ƒ‚ƒWƒ…
51[ƒ‹ ƒAƒZƒ“ƒuƒŠŒ¾Œê•”iRX630—pj
52;
53
54;
55; ƒfƒBƒXƒpƒbƒ`ƒƒ‚¨‚æ‚ÑŠ„ž‚Ý(CPU—áŠO)o“ü‚èŒû‚̃‹[ƒ‹:
56; “®ìƒ‚[ƒh‚ðˆÈ‰º‚̂悤‚É’è‹`‚·‚é.
57; ƒfƒBƒXƒpƒbƒ`ƒƒƒ‚[ƒh:
58; CPUƒƒbƒNó‘Ô, Š„ž‚Ý—Dæ“xƒ}ƒXƒN‘S‰ðœó‘Ô,
59; ƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg(intnest = 0), ƒ^ƒXƒNƒXƒ^ƒbƒN
60; Š„ž‚Ý(CPU—áŠO)ˆ—ƒ‚[ƒh
61; ‘SŠ„ž‚݃ƒbƒNó‘Ô(PSWƒŒƒWƒXƒ^Iƒrƒbƒg = 0),
62; Š„ž‚Ý—Dæ“xƒ}ƒXƒN‘S‰ðœ‚Å‚È‚¢ó‘Ô(IPL != 0)
63; Š„ž‚݃Rƒ“ƒeƒLƒXƒg(intnest != 0), Š„ž‚݃Xƒ^ƒbƒN
64;
65; ƒJ[ƒlƒ‹ŠÇ—ŠOŠ„ž‚݂̃Tƒ|[ƒg—L–³‚Æ, CPUƒƒbƒNó‘Ô, Š„ž‚Ý—Dæ“x
66; ƒ}ƒXƒN‘S‰ðœó‘Ô‚ÌŠÖŒW‚͈ȉº‚Ì’Ê‚è‚Å‚ ‚é.
67; ƒJ[ƒlƒ‹ŠÇ—ŠOŠ„ž‚Ý–¢ƒTƒ|[ƒgŽž:
68; CPUƒƒbƒNó‘Ô(PSWƒŒƒWƒXƒ^Iƒrƒbƒg = 0)
69; Š„ž‚Ý—Dæ“xƒ}ƒXƒN‘S‰ðœó‘Ô(IPL = 0)
70; ƒJ[ƒlƒ‹ŠÇ—ŠOŠ„ž‚݃Tƒ|[ƒgŽž:
71; CPUƒƒbƒNó‘Ô
72; (PSWƒŒƒWƒXƒ^Iƒrƒbƒg = 0, IPL = IPL_LOCK, lock_flag = true)
73; Š„ž‚Ý—Dæ“xƒ}ƒXƒN‘S‰ðœó‘Ô(saved_ipl = 0)
74;
75; Še\‘¢‘̃|ƒCƒ“ƒ^‚ðˆÈ‰º‚̂悤‚ÉŠeƒŒƒWƒXƒ^‚ɃAƒTƒCƒ“‚·‚é.
76; r15 = p_runtsk ‚½‚¾‚µƒfƒBƒXƒpƒbƒ`ƒƒ‚ÌŠeoŒû‚Å‚Í–³Œø
77; r14 = *p_runtsk dispatcher ‚Ì’†‚Å‚Í p_runtsk Šm’莞‚ɍĎ擾‚·‚é
78; Še“ü‚èŒû‚©‚çÅ‰‚ɕϐ”ƒAƒNƒZƒX‚·‚é‚Æ‚«‚ɏã‹LƒŒƒWƒXƒ^‚É•Û‘¶‚·‚é.
79;
80; \‘¢‘̃Aƒ‰ƒCƒƒ“ƒg‚ւ̑Ήž
81; \‘¢‘̃Aƒ‰ƒCƒƒ“ƒg‚ª4Byte(ƒAƒ“ƒpƒbƒN)‚̏ꍇ:
82; ˆê”Ê“I‚ȃŒƒWƒXƒ^‘Š‘΃AƒhƒŒƒbƒVƒ“ƒO‚ª‰Â”\
83; —á: mov.l #__kernel_p_runtsk, r15
84; mov.l r0, TCB_sp[r15]
85; \‘¢‘̃Aƒ‰ƒCƒƒ“ƒg‚ª4Byte‚Å‚Í‚È‚¢(ƒpƒbƒN)‚̏ꍇ:
86; mov.l‚̂悤‚Ƀƒ“ƒOƒTƒCƒYŽw’è‚̏ꍇA‘Š‘Î’l‚Í4‚Ì”{”‚Ì‚Ý—LŒø
87; ‚±‚Ì‚½‚ß, ˆê“x‘ΏۃAƒhƒŒƒX‚ð‹‚ß‚Ä‚©‚çƒAƒNƒZƒX‚·‚é•K—v‚ª‚ ‚é
88; —á: mov.l #__kernel_p_runtsk, r15
89; add #TCB_sp, r15, r5
90; mov.l r0, [r5]
91; ŠeƒIƒtƒZƒbƒg’l‚ð”»’f‚µ, ðŒƒAƒZƒ“ƒuƒ‹‚É‚æ‚èƒR[ƒh‚ðØ‚è‘Ö‚¦‚é
92;
93
94;
95; \‘¢‘̃AƒNƒZƒX‚̃IƒtƒZƒbƒg’è‹`
96;
97 .include offset.inc
98
99;
100; ŠeŽíEQU’è‹`(Hƒtƒ@ƒCƒ‹‚Ì#define’è‹`)
101;
102 .include asm_config.inc
103
104 .glb __kernel_istkpt
105
106 .glb __kernel_p_runtsk
107 .glb __kernel_p_schedtsk
108 .glb __kernel_reqflg
109 .glb __kernel_dspflg
110
111 .glb __kernel_dispatch
112 .glb __exit_and_dispatch
113 .glb __kernel_start_r
114 .glb __kernel_call_texrtn
115 .glb _kernel_interrupt
116 .glb _kernel_exception
117 .glb __kernel_intnest
118 .glb __kernel_call_exit_kernel
119 .glb __kernel_start_dispatch
120
121 .glb _ext_tsk
122 .glb __kernel_exit_kernel
123
124.if TIPM_LOCK != -15
125 .glb __kernel_lock_flag
126 .glb __kernel_saved_ipl
127.endif
128
129 .glb __kernel_break_wait
130 .glb _sil_dly_nse
131
132.if LOG_INH_ENTER_ENABLE == 1
133 .glb _kernel_log_inh_enter
134.endif ; LOG_INH_ENTER_ENABLE == 1
135.if LOG_INH_LEAVE_ENABLE == 1
136 .glb _kernel_log_inh_leave
137.endif ; LOG_INH_LEAVE_ENABLE == 1
138.if LOG_EXC_ENTER_ENABLE == 1
139 .glb _kernel_log_exc_enter
140.endif ; LOG_EXC_ENTER_ENABLE == 1
141.if LOG_EXC_LEAVE_ENABLE == 1
142 .glb _kernel_log_exc_leave
143.endif ; LOG_EXC_LEAVE_ENABLE == 1
144.if LOG_DSP_ENTER_ENABLE == 1
145 .glb _kernel_log_dsp_enter
146.endif ; LOG_DSP_ENTER_ENABLE == 1
147.if LOG_DSP_LEAVE_ENABLE == 1
148 .glb _kernel_log_dsp_leave
149.endif ; LOG_DSP_LEAVE_ENABLE == 1
150
151;
152; TCB_sp ‚ւ̏‘ž‚݃}ƒNƒ
153;
154st_TCB_sp .macro src, tcb, tmp
155.if (TCB_sp % 4) == 0
156 mov.l src, TCB_sp[tcb]
157.else
158 add #TCB_sp, tcb, tmp
159 mov.l src, [tmp]
160.endif
161.endm
162
163;
164; TCB_sp ‚©‚ç‚̓Ǐo‚µƒ}ƒNƒ
165;
166ld_TCB_sp .macro dst, tcb, tmp
167.if (TCB_sp % 4) == 0
168 mov.l TCB_sp[tcb], dst
169.else
170 add #TCB_sp, tcb, tmp
171 mov.l [tmp], dst
172.endif
173.endm
174
175;
176; TCB_pc ‚ւ̏‘ž‚݃}ƒNƒ
177;
178st_TCB_pc .macro src, tcb, tmp
179.if (TCB_pc % 4) == 0
180 mov.l src, TCB_pc[tcb]
181.else
182 add #TCB_pc, tcb, tmp
183 mov.l src, [tmp]
184.endif
185.endm
186
187;
188; TCB_pc ‚©‚ç‚̓Ǐo‚µƒ}ƒNƒ
189;
190ld_TCB_pc .macro dst, tcb, tmp
191.if (TCB_pc % 4) == 0
192 mov.l TCB_pc[tcb], dst
193.else
194 add #TCB_pc, tcb, tmp
195 mov.l [tmp], dst
196.endif
197.endm
198
199;
200; TCB_texptn ‚©‚ç‚̓Ǐo‚µƒ}ƒNƒ
201;
202ld_TCB_texptn .macro dst, tcb, tmp
203.if (TCB_texptn % 4) == 0
204 mov.l TCB_texptn[tcb], dst
205.else
206 add #TCB_texptn, tcb, tmp
207 mov.l [tmp], dst
208.endif
209.endm
210
211;
212; TCB_p_tinib ‚©‚ç‚̓Ǐo‚µƒ}ƒNƒ
213;
214ld_TCB_p_tinib .macro dst, tcb, tmp
215.if (TCB_p_tinib % 4) == 0
216 mov.l TCB_p_tinib[tcb], dst
217.else
218 add #TCB_p_tinib, tcb, tmp
219 mov.l [tmp], dst
220.endif
221.endm
222
223;
224; TINIB_exinf ‚©‚ç‚̓Ǐo‚µƒ}ƒNƒ
225;
226ld_TINIB_exinf .macro dst, tinib, tmp
227.if (TINIB_exinf % 4) == 0
228 mov.l TINIB_exinf[tinib], dst
229.else
230 add #TINIB_exinf, tinib, tmp
231 mov.l [tmp], dst
232.endif
233.endm
234
235;
236; TINIB_task ‚©‚ç‚̓Ǐo‚µƒ}ƒNƒ
237;
238ld_TINIB_task .macro dst, tinib, tmp
239.if (TINIB_task % 4) == 0
240 mov.l TINIB_task[tinib], dst
241.else
242 add #TINIB_task, tinib, tmp
243 mov.l [tmp], dst
244.endif
245.endm
246
247
248 .section P, CODE
249
250;
251; API‚©‚ç‚̃^ƒXƒNƒfƒBƒXƒpƒbƒ`ƒƒ“üŒû
252;
253; ŒÄ‚яo‚µðŒ:
254; EƒfƒBƒXƒpƒbƒ`ƒƒƒ‚[ƒh(ƒtƒ@ƒCƒ‹ƒwƒbƒ_ŽQÆ)
255;
256; ‚±‚±‚Å‚Í, ƒRƒ“ƒeƒLƒXƒg‚Ì‘Þ”ð‚Æ, ŽÀsÄŠJ”Ô’n‚̐ݒè‚ð‚·‚é.
257;
258__kernel_dispatch:
259 pushm r6-r13 ; ”ñƒXƒNƒ‰ƒbƒ`ƒŒƒWƒXƒ^•Û‘¶
260 mov.l #__kernel_p_runtsk, r15
261 mov.l [r15], r14
262 st_TCB_sp r0, r14, r5 ; ƒXƒ^ƒbƒNƒ|ƒCƒ“ƒ^‚ðTCB‚É•Û‘¶
263 st_TCB_pc #dispatch_r, r14, r5 ; ŽÀsÄŠJ”Ô’n‚ðTCB‚É•Û‘¶
264 bra dispatcher
265
266;
267; API‚ւ̃^ƒXƒNƒfƒBƒXƒpƒbƒ`ƒƒoŒû
268;
269; ŒÄ‚яo‚µðŒ:
270; EƒfƒBƒXƒpƒbƒ`ƒƒƒ‚[ƒh(ƒtƒ@ƒCƒ‹ƒwƒbƒ_ŽQÆ)
271;
272; ‚±‚±‚Å‚Í, ƒ^ƒXƒN—áŠOƒnƒ“ƒhƒ‰ŒÄo‚µ‚Æ, ƒRƒ“ƒeƒLƒXƒg‚Ì•œ‹A‚ð‚·‚é.
273;
274dispatch_r:
275 btst #TCB_enatex_bit, TCB_enatex[r14] ; ƒ^ƒXƒN—áŠOˆ—‹–‰Â?
276 bz dispatch_r_rts
277 ld_TCB_texptn r5, r14, r4 ; •Û—¯—áŠO—vˆö‚ª‚ ‚é‚©H
278 cmp #0, r5
279 bz dispatch_r_rts
280 bsr __kernel_call_texrtn ; ƒ^ƒXƒN—áŠOƒnƒ“ƒhƒ‰ŒÄo‚µˆ—ŽÀs
281dispatch_r_rts:
282 popm r6-r13 ; ”ñƒXƒNƒ‰ƒbƒ`ƒŒƒWƒXƒ^•œ‹A
283 rts ; dispatch ŒÄ‚яo‚µŒ³‚Ö–ß‚é.
284
285;
286; ƒ^ƒXƒN‹N“®ˆ—(ƒ^ƒXƒNæ“ª‚ւ̃^ƒXƒNƒfƒBƒXƒpƒbƒ`ƒƒoŒû)
287;
288; ŒÄ‚яo‚µðŒ:
289; EƒfƒBƒXƒpƒbƒ`ƒƒƒ‚[ƒh(ƒtƒ@ƒCƒ‹ƒwƒbƒ_ŽQÆ)
290;
291; ‚±‚±‚Å‚Í, CPUƒƒbƒN‰ðœó‘Ô‚É‚µ, ƒ^ƒXƒN‚ð‹N“®‚·‚é.
292;
293__kernel_start_r:
294 mov.l #_ext_tsk, r5
295 push.l r5 ; –ß‚è”Ô’n‚ðƒXƒ^ƒbƒN‚ɐςÞ
296 ld_TCB_p_tinib r5, r14, r4
297 ld_TINIB_exinf r1, r5, r4 ; Šg’£î•ñ‚ð‘æˆêˆø”‚ɐݒè
298 ld_TINIB_task r5, r5, r4 ; ƒ^ƒXƒN‚Ì‹N“®”Ô’n‚ðŽæ“¾
299.if TIPM_LOCK == -15
300 setpsw i ; Š„ž‚Ý‹–‰Â(CPUƒƒbƒN‰ðœó‘Ô)
301.else
302 mov.l #__kernel_lock_flag, r4 ; CPUƒƒbƒN‰ðœó‘Ô‚Ö
303 mov.l #0, [r4] ; ‚±‚±‚É—ˆ‚é‚Æ‚«‚Í•K‚¸ saved_ipl ‚Ì
304 mvtc #00010000H, psw ; ’l‚Í 0 ‚Ì‚½‚ß, ’¼’l‚ðÝ’è‚·‚é.
305 ; ‘SŠ„ž‚݃ƒbƒN‰ðœó‘Ô( I = 1 )
306 ; Š„ž‚Ý—Dæ“xƒ}ƒXƒN‘S‰ðœó‘Ô( IPL = 0 )
307.endif
308 jmp r5
309
310;
311; ƒJ[ƒlƒ‹‹N“®‚©‚ç‚̃^ƒXƒNƒfƒBƒXƒpƒbƒ`ƒƒ“üŒû
312;
313; ‚±‚̃‹[ƒ`ƒ“‚́CƒJ[ƒlƒ‹‹N“®Žž‚ɁC‚·‚ׂĂ̊„ž‚Ý‚ð‹ÖŽ~‚µ‚½ó‘Ô
314; iŠ„ž‚݃ƒbƒNó‘Ô‚Æ“¯“™j‚ŌĂяo‚³‚ê‚éD‚Ü‚½CŠ„ž‚݃‚[ƒhi”ñ
315; ƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg‚Æ“¯“™j‚ŌĂяo‚³‚ê‚邱‚Æ‚ð‘z’肵‚Ä‚¢‚éD
316;
317; ŒÄ‚яo‚µðŒ:
318; EŠ„ž‚Ý(CPU—áŠO)ˆ—ƒ‚[ƒh(ƒtƒ@ƒCƒ‹ƒwƒbƒ_ŽQÆ)
319;
320; ‚±‚±‚Å‚Í, ƒfƒBƒXƒpƒbƒ`ƒƒƒ‚[ƒh‚ɕύX‚·‚é.
321;
322__kernel_start_dispatch:
323 mov.l #__kernel_intnest, r5
324 mov.w #0, [r5] ; ƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg‚ɐ؊·‚¦
325.if TIPM_LOCK != -15
326 mvtc #(IPL_LOCK | 00010000H), psw ; ‘SŠ„ž‚݃ƒbƒN‰ðœó‘Ô
327 ; Š„ž‚Ý—Dæ“xƒ}ƒXƒN‘S‰ðœ‚Å‚È‚¢ó‘Ô
328.endif
329
330;
331; ƒ^ƒXƒNI—¹(Œ»Ý‚̃Rƒ“ƒeƒLƒXƒg‚ðŽÌ‚Ä‚é)‚©‚ç‚̃^ƒXƒNƒfƒBƒXƒpƒbƒ`ƒƒ“üŒû
332;
333; ŒÄ‚яo‚µðŒ:
334; EƒfƒBƒXƒpƒbƒ`ƒƒƒ‚[ƒh(ƒtƒ@ƒCƒ‹ƒwƒbƒ_ŽQÆ)
335;
336; ‚±‚±‚Å‚Í, ‰½‚à‚·‚邱‚Æ‚Í‚È‚¢.
337; ‚È‚¨, p_runtsk ‚̃AƒhƒŒƒXŽæ“¾‚¾‚¯‚͍s‚È‚¤.
338;
339__exit_and_dispatch:
340 mov.l #__kernel_p_runtsk, r15
341
342;
343; ƒfƒBƒXƒpƒbƒ`ƒƒ–{‘Ì
344;
345; ŒÄ‚яo‚µðŒ:
346; E‚·‚ׂẴ^ƒXƒN‚̃Rƒ“ƒeƒLƒXƒg‚Í•Û‘¶‚³‚ê‚Ä‚¢‚é.
347;
348; dispatcher ŒÄoŽž‚̃Xƒ^ƒbƒN:
349; E__kernel_dispatch ‚©‚ç‚«‚½ê‡ : ƒ^ƒXƒNƒXƒ^ƒbƒN
350; Eexit_and_dispatch ‚©‚ç‚«‚½ê‡:
351; exit_task ‚©‚ç‚«‚½ê‡ : ƒ^ƒXƒNƒXƒ^ƒbƒN
352; ƒJ[ƒlƒ‹‹N“®Žž(__kernel_start_dispatch) : Š„ž‚݃Xƒ^ƒbƒN
353; Eret_int ‚©‚ç‚«‚½ê‡ : ƒ^ƒXƒNƒXƒ^ƒbƒN
354; Edispatcher_idle_loop ‚©‚ç‚«‚½ê‡ : Š„ž‚݃Xƒ^ƒbƒN
355;
356dispatcher:
357.if LOG_DSP_ENTER == 1
358 push.l r15
359 mov.l r14, r1 ; ˆø”(ƒfƒBƒXƒpƒbƒ`Œ³TCB)‚ðÝ’è
360 bsr _kernel_log_dsp_enter
361 pop.l r15
362.endif
363 mov.l #__kernel_p_schedtsk, r5
364 mov.l [r5], [r15] ; p_schedtsk ‚ð p_runtsk ‚É
365 mov.l [r15], r14
366 cmp #0, r14
367 bz dispatcher_pre_idle ; schedtsk ‚ª‚È‚¯‚ê‚΃AƒCƒhƒ‹ƒ‹[ƒv‚Ö
368 ld_TCB_sp r0, r14, r5 ; ƒ^ƒXƒNƒXƒ^ƒbƒNƒ|ƒCƒ“ƒ^‚𕜋A
369.if LOG_DSP_LEAVE == 1
370 push.l r14
371 mov.l r14, r1 ; ˆø”(ƒfƒBƒXƒpƒbƒ`æTCB)‚ðÝ’è
372 bsr _kernel_log_dsp_leave
373 pop.l r14
374.endif
375 ld_TCB_pc r5, r14, r4
376 jmp r5 ; ŽÀsÄŠJ”Ô’n‚ÖƒWƒƒƒ“ƒv
377
378;
379; schdedtsk‚ªNULL‚̏ꍇ‚̓AƒCƒhƒ‹ƒ‹[ƒv‚É“ü‚é
380; ƒAƒCƒhƒ‹ƒ‹[ƒv‚ÍŠ„ž‚ݏˆ—ƒ‚[ƒh‚Å“®ì‚³‚¹‚é
381;
382; ‚±‚±‚ÅŠ„ž‚݃‚[ƒh‚ɐ؂芷‚¦‚é‚̂́C‚±‚±‚Å”­¶‚·‚銄ž‚ݏˆ—‚É
383; ‚ǂ̃Xƒ^ƒbƒN‚ðŽg‚¤‚©‚Æ‚¢‚¤–â‘è‚Ì‰ðŒˆ‚ÆCŠ„ž‚݃nƒ“ƒhƒ‰“à‚ł̃^
384; ƒXƒNƒfƒBƒXƒpƒbƒ`‚Ì–hŽ~‚Æ‚¢‚¤2‚‚̈Ӗ¡‚ª‚ ‚éD
385;
386dispatcher_pre_idle:
387 mov.l #__kernel_istkpt,r5
388 mov.l [r5], r0 ; Š„ž‚Ý—p‚̃Xƒ^ƒbƒN‚֐ؑւ¦
389 mov.l #__kernel_intnest, r5
390 mov.w #1, [r5] ; ”ñƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg‚ɐ؊·‚¦
391.if TIPM_LOCK != -15
392 mov.l #__kernel_lock_flag, r5 ; CPUƒƒbƒN‰ðœó‘Ô‚Ö
393 mov.l #0, [r5]
394 mvtc #0, psw ; —Dæ“x0‚ÌŠ„ž‚ݏˆ—’†‚ð‹U‘•
395.endif
396
397dispatcher_idle_loop:
398 setpsw i ; ‘SŠ„ž‚Ý‹–‰Â
399 clrpsw i ; ‘SŠ„ž‚Ý‹ÖŽ~
400
401 mov.l #__kernel_reqflg, r5 ; reqflg ‚ª FALSE ‚È‚ç
402 mov.l [r5], r4
403 cmp #0, r4
404 bz dispatcher_idle_loop ; ƒAƒCƒhƒ‹ƒ‹[ƒv‚ðŒJ‚è•Ô‚·
405 mov.l #0, [r5] ; reqflg‚ªtrue‚È‚çfalse‚É‚·‚é
406 mov.l #__kernel_intnest, r5
407 mov.w #0, [r5] ; ƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg‚ɐ؊·‚¦
408.if TIPM_LOCK != -15
409 mov.l #__kernel_lock_flag, r5 ; CPUƒƒbƒNó‘Ô‚Ö
410 mov.l #1, [r5]
411 mov.l #__kernel_saved_ipl, r5
412 mov.l #0, [r5]
413 mvtc #(IPL_LOCK | PSW_I_MASK), psw ; ‘SŠ„ž‚݃ƒbƒN‰ðœó‘Ô
414 ; Š„ž‚Ý—Dæ“xƒ}ƒXƒN‘S‰ðœ‚Å‚È‚¢ó‘Ô
415.endif
416 bra dispatcher ; dispatcher ‚Ö–ß‚é
417
418
419;
420; ƒJ[ƒlƒ‹‚̏I—¹ˆ—‚̌ďo‚µ
421;
422; ƒ‚[ƒh‚ƃXƒ^ƒbƒN‚ð”ñƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg—p‚ɐ؂è‘Ö‚¦D
423;
424 .glb __kernel_call_exit_kernel
425__kernel_call_exit_kernel:
426.if TIPM_LOCK != -15
427 clrpsw i ; ‘SŠ„ž‚Ý‹ÖŽ~
428 mov.l #__kernel_lock_flag, r5 ; CPUƒƒbƒN‰ðœó‘Ô‚Ö
429 mov.l #0, [r5]
430.endif
431 mov.l #__kernel_istkpt, r5
432 mov.l [r5], r0 ; Š„ž‚Ý—p‚̃Xƒ^ƒbƒN‚֐ؑւ¦
433 mov.l #__kernel_intnest, r5
434 mov.w #1, [r5] ; ”ñƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg‚ɐ؊·‚¦
435 bsr __kernel_exit_kernel
436 bra __kernel_call_exit_kernel
437
438
439;
440; Š„ž‚Ý(CPU—áŠO)‚©‚ç‚̃^ƒXƒNƒfƒBƒXƒpƒbƒ`ƒƒ“üŒû
441;
442; ŒÄo‚µðŒ:
443; E‘SŠ„ž‚݃ƒbƒNó‘Ô(PSWƒŒƒWƒXƒ^Iƒrƒbƒg = 0)
444; EŠ„ž‚Ý—Dæ“xƒ}ƒXƒN‘S‰ðœ‚Å‚È‚¢ó‘Ô(IPL != 0)
445; Eƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg(intnest=0)
446; EŽg—pƒXƒ^ƒbƒN‚̓^ƒXƒNƒXƒ^ƒbƒN
447; Ereqflg = true
448;
449; ‚±‚±‚Å‚Í, ƒfƒBƒXƒpƒbƒ`ƒƒƒ‚[ƒh‚ɕύX‚µ, reqflg‚ðOFF‚É‚µ‚Ä‚©‚ç,
450; ’x‰„ƒfƒBƒXƒpƒbƒ`‚Ì—L–³‚ð”»’f‚·‚é.
451;
452
453;
454; ret_intæ“ª‚ŃXƒ^ƒbƒN‚ɐς܂ê‚Ä‚¢‚éPSWƒŒƒWƒXƒ^‚ւ̃IƒtƒZƒbƒg
455; ACC + FPSW + R14--R15 + R1--R5 + PC
456;
457 RET_INT_GET_PSW_OFFSET .equ (8+4+28+4)
458
459ret_int:
460.if TIPM_LOCK == -15
461 mov.l RET_INT_GET_PSW_OFFSET[r0], r5 ; Š„ž‚Ý/CPU—áŠO”­¶‘O‚ÌIPL’lŽæ“¾
462 and #PSW_IPL_MASK, r5
463 mvtc r5, psw ; ‘SŠ„ž‚݃ƒbƒN(CPUƒƒbƒN)ó‘Ô
464 ; Š„ž‚Ý/CPU—áŠO”­¶‘O‚ÌŠ„ž‚Ý—Dæ“x
465.else
466 mov.l #__kernel_lock_flag, r5 ; CPUƒƒbƒNó‘Ô‚Ö
467 mov.l #1, [r5]
468 mov.l RET_INT_GET_PSW_OFFSET[r0], r5 ; Š„ž‚Ý/CPU—áŠO”­¶‘O‚ÌIPL’lŽæ“¾
469 and #PSW_IPL_MASK, r5
470 mov.l #__kernel_saved_ipl, r4
471 mov.l r5, [r4]
472 mvtc #(IPL_LOCK | PSW_I_MASK), psw ; ‘SŠ„ž‚݃ƒbƒN‰ðœó‘Ô
473 ; Š„ž‚Ý—Dæ“xƒ}ƒXƒN‘S‰ðœ‚Å‚È‚¢ó‘Ô
474.endif
475 mov.l #__kernel_reqflg, r5
476 mov.l #0, [r5] ; reqflg <--- FALSE
477 mov.l #__kernel_p_runtsk, r15
478 mov.l [r15], r14
479 mov.l #__kernel_dspflg, r5 ; dspflg ‚ª FALSE ‚È‚ç ret_int_r ‚Ö
480 mov.l [r5], r5
481 cmp #0, r5
482 bz ret_int_r_call_tex
483 mov.l #__kernel_p_schedtsk, r5
484 mov.l [r5], r5
485 cmp r5, r14 ; p_schedtsk ‚Æ p_runtsk ‚ª“¯‚¶‚È‚ç
486 beq ret_int_r_call_tex ; ret_int_r_call_tex ‚Ö
487 pushm r6-r13 ; ”ñƒXƒNƒ‰ƒbƒ`ƒŒƒWƒXƒ^•Û‘¶
488 st_TCB_sp r0, r14, r5 ; ƒXƒ^ƒbƒNƒ|ƒCƒ“ƒ^‚ðTCB‚É•Û‘¶
489 st_TCB_pc #ret_int_r, r14, r5 ; ŽÀsÄŠJ”Ô’n‚ðTCB‚É•Û‘¶
490 bra dispatcher
491
492;
493; Š„ž‚Ý(CPU—áŠO)‚ւ̃^ƒXƒNƒfƒBƒXƒpƒbƒ`ƒƒoŒû
494;
495; ŒÄ‚яo‚µðŒ:
496; EƒfƒBƒXƒpƒbƒ`ƒƒƒ‚[ƒh(ƒtƒ@ƒCƒ‹ƒwƒbƒ_ŽQÆ)
497;
498; ‚±‚±‚Å‚Í, ƒ^ƒXƒN—áŠOƒnƒ“ƒhƒ‰ŒÄo‚µ‚Æ, Š„ž‚Ý(CPU—áŠO)ˆ—ƒ‚[ƒh‚Ö‚Ì
499; •ÏX‚Æ, ƒRƒ“ƒeƒLƒXƒg‚Ì•œ‹A‚ðs‚¢, Š„ž‚Ý(CUP—áŠO)”­¶Œ³‚Ö–ß‚é.
500;
501__kernel_break_wait: ;ƒ^ƒXƒNƒ‚ƒjƒ^—pƒ‰ƒxƒ‹
502ret_int_r:
503 popm r6-r13 ; ”ñƒXƒNƒ‰ƒbƒ`ƒŒƒWƒXƒ^•œ‹A
504ret_int_r_call_tex:
505 btst #TCB_enatex_bit, TCB_enatex[r14] ; ƒ^ƒXƒN—áŠOˆ—‹–‰Â?
506 bz ret_int_r_rte
507 ld_TCB_texptn r5, r14, r4 ; •Û—¯—áŠO—vˆö‚ª‚ ‚é‚©H
508 cmp #0, r5
509 bz ret_int_r_rte
510 bsr __kernel_call_texrtn ; ƒ^ƒXƒN—áŠOƒnƒ“ƒhƒ‰ŒÄo‚µˆ—ŽÀs
511ret_int_r_rte:
512.if TIPM_LOCK != -15
513 clrpsw i ; ‘SŠ„ž‚Ý‹ÖŽ~
514 mov.l #__kernel_lock_flag, r5 ; CPUƒƒbƒN‰ðœó‘Ô‚Ö
515 mov.l #0, [r5]
516.endif
517 popm r4-r5 ; ƒAƒLƒ…
518ƒ€ƒŒ[ƒ^•œ‹A
519 mvtaclo r5 ; ACCÅ‰ºˆÊ16bit‚Í0‚Å•œ‹A
520 mvtachi r4
521 popc fpsw ; FPUƒXƒe[ƒ^ƒXƒŒƒWƒXƒ^•œ‹A
522 popm r14-r15 ; ƒŒƒWƒXƒ^•œ‹A
523 popm r1-r5
524 rte ; Š„ž‚Ý‘O‚̏ˆ—‚É–ß‚é
525
526
527;
528; Š„ž‚݂̏o“üŒûˆ—(ƒAƒZƒ“ƒuƒŠŒ¾Œê‹Lq•”•ª)
529;
530; ŒÄo‚µðŒ:
531; EŠ„ž‚Ý”­¶Žž‚ÌH/Wˆ—‚É‚æ‚è, PSWƒŒƒWƒXƒ^‚ÌIƒrƒbƒg=0, IPL‚ÍŽó•t‚¯
532; ‚½Š„ž‚Ý‚ÌIPL.
533; EƒXƒ^ƒbƒN‚Í‘½dŠ„‚荞‚݂Ȃ犄ž‚݃Xƒ^ƒbƒN, ‚»‚¤‚Å‚È‚¯‚ê‚Î
534; ƒ^ƒXƒNƒXƒ^ƒbƒN
535; EŠ„ž‚Ý”­¶Žž‚ÌH/Wˆ—‚É‚æ‚è,ƒXƒ^ƒbƒN‚ÉŠ„ž‚Ý‚©‚ç‚Ì•œ‹APC‚ÆPSW‚ª
536; •Û‘¶‚³‚ê‚Ä‚¢‚é.
537; EƒxƒNƒ^ƒe[ƒuƒ‹‚É“o˜^‚³‚ꂽŒÂ•Ê‚Ì“ü‚èŒûˆ—‚É‚æ‚è, ƒXƒ^ƒbƒN‚É
538; ƒXƒNƒ‰ƒbƒ`ƒŒƒWƒXƒ^(R1-R5)‚ª•Û‘¶‚³‚ê‚Ä‚¢‚é.
539;
540; ˆø”:
541; Er1:Š„ž‚Ý—vˆö”ԍ†
542; Er2:Š„ž‚݃nƒ“ƒhƒ‰‚̃AƒhƒŒƒX
543;
544; ƒŒƒWƒXƒ^‚ªƒXƒ^ƒbƒNã‚ɂǂ̂悤‚É•Û‘¶‚³‚ê‚Ä‚¢‚é‚©‚ðˆÈ‰º‚ÉŽ¦‚·.
545; ‚±‚̐}‚ł͏オ’áˆÊ, ‰º‚ª‚ˆÊ‚̃AƒhƒŒƒX‚Å, ƒXƒ^ƒbƒN‚͉º‚©‚ç
546; ã•ûŒü‚ÉŒü‚©‚Á‚Đςݏグ‚ç‚ê‚é‚à‚Ì‚Æ‚·‚é.
547;
548; -------------------------
549; | ACC-HI(4byte) |
550; -------------------------(SP + 0)
551; | ACC-LO(4byte) |
552; -------------------------(SP + 4)
553; | FPSW(4byte) |
554; -------------------------(SP + 8)
555; | R14(4byte) |
556; -------------------------(SP + 12)
557; | R15(4byte) |
558; -------------------------(SP + 16)
559; | R1(4byte) |
560; -------------------------(SP + 20)
561; | R2(4byte) |
562; -------------------------(SP + 24)
563; | R3(4byte) |
564; -------------------------(SP + 28)
565; | R4(4byte) |
566; -------------------------(SP + 32)
567; | R5(4byte) |
568; -------------------------(SP + 36)
569; | PC(4byte) |
570; -------------------------(SP + 40)
571; | PSW(4byte) |
572; -------------------------(SP + 44)
573;
574; ‚±‚±‚Å‚Í, Š„ž‚ݏˆ—ƒ‚[ƒh‚ɕύX‚µ‚ănƒ“ƒhƒ‰‚ðŽÀs‚·‚é.
575;
576; ƒnƒ“ƒhƒ‰‚©‚烊ƒ^[ƒ“‚µ‚½Œã‚Í, ‘½dŠ„ž‚Ý‚Å‚È‚­, ‚©‚ reqflg ‚ª
577; TRUE ‚É‚È‚Á‚½Žž‚ɁCret_int ‚Ö•ªŠò(’x‰„ƒfƒBƒXƒpƒbƒ`)‚·‚éD
578;
579; ‘½dŠ„ž‚Ý‚©‚Ç‚¤‚©‚ÍŠ„ž‚݃lƒXƒgƒJƒEƒ“ƒ^‚Ì’l‚Å”»’è‚·‚é.
580; intnest != 0 ‚È‚ç‚Α½dŠ„ž‚Ý‚Å‚ ‚é‚Æ”»’è‚·‚é.
581;
582; reqflg ‚ÍCPUƒƒbƒNó‘ԂŃ`ƒFƒbƒN‚·‚é. ‚»‚¤‚Å‚È‚¢‚ƁC
583; reqflg ƒ`ƒFƒbƒNŒã‚É‹N“®‚³‚ꂽŠ„ž‚݃nƒ“ƒhƒ‰“à‚Å
584; ƒfƒBƒXƒpƒbƒ`‚ª—v‹‚³‚ꂽê‡‚ɁCƒfƒBƒXƒpƒbƒ`‚³‚ê‚È‚¢.
585;
586_kernel_interrupt:
587 pushm r14-r15 ; ƒXƒNƒ‰ƒbƒ`ƒŒƒWƒXƒ^‚ð‘Þ”ð
588 pushc fpsw ; FPUƒXƒe[ƒ^ƒXƒŒƒWƒXƒ^‘Þ”ð
589 mvfacmi r5
590 shll #16, r5 ; ACCÅ‰ºˆÊ16bit‚Í0‚Æ‚·‚é
591 mvfachi r4
592 pushm r4-r5 ; ƒAƒLƒ…
593ƒ€ƒŒ[ƒ^‘Þ”ð
594 mov.l #__kernel_intnest, r5
595 mov.w [r5], r4
596 add #1, r4 ; ƒlƒXƒg‰ñ”‚ðƒCƒ“ƒNƒŠƒƒ“ƒg
597 mov.w r4, [r5]
598 cmp #1, r4 ; ‘½dŠ„‚荞‚Ý‚©‚Ç‚¤‚©
599 bnz interrupt_from_int ; ‰ÁŽZ‘O‚ª0‚Å‚È‚¯‚ê‚Α½dŠ„ž‚Ý
600 ; ‰’i‚ÌŠ„ž‚Ý
601 mov.l r0, r3 ; ƒXƒ^ƒbƒNƒ|ƒCƒ“ƒ^‚ðŽæ‚èo‚µ
602 mov.l #__kernel_istkpt, r5 ; Š„ž‚Ý—p‚̃Xƒ^ƒbƒN‚֐ؑւ¦‚é
603 mov.l [r5], r0
604 push.l r3 ; ƒ^ƒXƒNƒXƒ^ƒbƒN‚ð•ÛŽ
605interrupt_from_int: ; ‘½dŠ„ž‚Ý
606 setpsw i ; Š„ž‚Ý‹–‰Â(CPUƒƒbƒN‰ðœó‘Ô)
607
608.if LOG_INH_LEAVE == 1
609 push.l r1 ; ƒƒOƒgƒŒ[ƒX‚̈ø”‚ð•ÛŽ
610.endif
611
612.if LOG_INH_ENTER == 1
613 push.l r2
614 bsr _kernel_log_inh_enter ; ƒƒOƒgƒŒ[ƒXŠÖ”‚̌ďo‚µ
615 ; ˆø”‚ÌŠ„ž‚Ý—vˆö”ԍ†‚ÍŠù‚Ér1‚É“ü‚Á‚Ä‚¢‚é
616 pop r2
617.endif
618
619 jsr r2 ; Cƒ‹[ƒ`ƒ“ŒÄ‚яo‚µ
620
621.if LOG_INH_LEAVE == 1
622 pop r1 ; ˆø”‚ÉŠ„ž‚Ý—vˆö”ԍ†‚ðÝ’è
623 bsr _kernel_log_inh_leave ; ƒƒOƒgƒŒ[ƒXŠÖ”‚̌ďo‚µ
624.endif
625
626 clrpsw i ; Š„ž‚Ý‹ÖŽ~(CPUƒƒbƒNó‘Ô)
627 mov.l #__kernel_intnest, r5
628 mov.w [r5], r4
629 sub #1, r4 ; ƒlƒXƒg‰ñ”‚ðƒfƒNƒŠƒƒ“ƒg
630 mov.w r4, [r5]
631 cmp #0, r4 ; ‘½dŠ„‚荞‚Ý‚©‚Ç‚¤‚©
632 bnz interrupt_return ; ‘½dŠ„‚荞‚݂Ȃ烊ƒ^[ƒ“
633 ; ‰’i‚ÌŠ„ž‚Ý
634 pop r0 ; ƒ^ƒXƒN‚̃Xƒ^ƒbƒN‚É–ß‚·
635 mov.l #__kernel_reqflg, r5 ; ƒfƒBƒXƒpƒbƒ`—v‹‚ª‚È‚¢‚©?
636 mov.l [r5], r5
637 cmp #1, r5
638 bz ret_int ; ‚ ‚ê‚Î ret_int ‚ÖƒWƒƒƒ“ƒv
639interrupt_return:
640 popm r4-r5 ; ƒAƒLƒ…
641ƒ€ƒŒ[ƒ^•œ‹A
642 mvtaclo r5 ; ACCÅ‰ºˆÊ16bit‚Í0‚Å•œ‹A
643 mvtachi r4
644 popc fpsw ; FPUƒXƒe[ƒ^ƒXƒŒƒWƒXƒ^•œ‹A
645 popm r14-r15 ; ƒŒƒWƒXƒ^•œ‹A
646 popm r1-r5
647 rte ; Š„ž‚Ý‘O‚̏ˆ—‚É–ß‚é
648
649
650;
651; CPU—áŠO‚̏o“üŒûˆ—(ƒAƒZƒ“ƒuƒŠŒ¾Œê‹Lq•”•ª)
652;
653; ŒÄo‚µðŒ:
654; ECPU—áŠO”­¶Žž‚ÌH/Wˆ—‚É‚æ‚è, PSWƒŒƒWƒXƒ^‚ÌIƒrƒbƒg=0, IPL=0.
655; EƒXƒ^ƒbƒN‚Í‘½dŠ„‚荞‚݂Ȃ犄ž‚݃Xƒ^ƒbƒN, ‚»‚¤‚Å‚È‚¯‚ê‚Î
656; ƒ^ƒXƒNƒXƒ^ƒbƒN
657; ECPU—áŠO”­¶Žž‚ÌH/Wˆ—‚É‚æ‚è,ƒXƒ^ƒbƒN‚ÉCPU—áŠO‚©‚ç‚Ì•œ‹APC‚Æ
658; PSW‚ª•Û‘¶‚³‚ê‚Ä‚¢‚é.
659; EƒxƒNƒ^ƒe[ƒuƒ‹‚É“o˜^‚³‚ꂽŒÂ•Ê‚Ì“ü‚èŒûˆ—‚É‚æ‚è, ƒXƒ^ƒbƒN‚É
660; ƒXƒNƒ‰ƒbƒ`ƒŒƒWƒXƒ^(R1-R5)‚ª•Û‘¶‚³‚ê‚Ä‚¢‚é.
661;
662; ˆø”:
663; Er1:CPU—áŠO—vˆö”ԍ†
664; Er2:CPU—áŠOƒnƒ“ƒhƒ‰‚̃AƒhƒŒƒX
665;
666; ƒŒƒWƒXƒ^‚ªƒXƒ^ƒbƒNã‚ɂǂ̂悤‚É•Û‘¶‚³‚ê‚Ä‚¢‚é‚©‚ðˆÈ‰º‚ÉŽ¦‚·.
667; ‚±‚̐}‚ł͏オ’áˆÊ, ‰º‚ª‚ˆÊ‚̃AƒhƒŒƒX‚Å, ƒXƒ^ƒbƒN‚͉º‚©‚ç
668; ã•ûŒü‚ÉŒü‚©‚Á‚Đςݏグ‚ç‚ê‚é‚à‚Ì‚Æ‚·‚é.
669; ‚È‚¨, CPU—áŠO—vˆö”ԍ†‚ÆR6-R13‚ÍCPU—áŠOƒnƒ“ƒhƒ‰“à‚ŏî•ñ‚ðŽæ“¾
670; ‚·‚é–Ú“I‚Å‘Þ”ð‚µ‚Ä‚¨‚è, oŒûˆ—‚Å‚Í•Û‘¶“à—e‚ð”jŠü‚·‚ê‚΂悢.
671;
672; -------------------------
673; | CPU—áŠO—vˆö”ԍ† | <----- p_excinf
674; ------------------------- (intptr_t)(p_excinf + 0)
675; | R6(4byte) |
676; ------------------------- (intptr_t)(p_excinf + 4)
677; | R7(4byte) |
678; ------------------------- (intptr_t)(p_excinf + 8)
679; | R8(4byte) |
680; ------------------------- (intptr_t)(p_excinf + 12)
681; | R9(4byte) |
682; ------------------------- (intptr_t)(p_excinf + 16)
683; | R10(4byte) |
684; ------------------------- (intptr_t)(p_excinf + 20)
685; | R11(4byte) |
686; ------------------------- (intptr_t)(p_excinf + 24)
687; | R12(4byte) |
688; ------------------------- (intptr_t)(p_excinf + 28)
689; | R13(4byte) |
690; ------------------------- (intptr_t)(p_excinf + 32)
691; | ACC-HI(4byte) |
692; ------------------------- (intptr_t)(p_excinf + 36)
693; | ACC-LO(4byte) |
694; ------------------------- (intptr_t)(p_excinf + 40)
695; | FPSW(4byte) |
696; ------------------------- (intptr_t)(p_excinf + 44)
697; | R14(4byte) |
698; ------------------------- (intptr_t)(p_excinf + 48)
699; | R15(4byte) |
700; ------------------------- (intptr_t)(p_excinf + 52)
701; | R1(4byte) |
702; ------------------------- (intptr_t)(p_excinf + 56)
703; | R2(4byte) |
704; ------------------------- (intptr_t)(p_excinf + 60)
705; | R3(4byte) |
706; ------------------------- (intptr_t)(p_excinf + 64)
707; | R4(4byte) |
708; ------------------------- (intptr_t)(p_excinf + 68)
709; | R5(4byte) |
710; ------------------------- (intptr_t)(p_excinf + 72)
711; | PC(4byte) |
712; ------------------------- (intptr_t)(p_excinf + 76)
713; | PSW(4byte) |
714; ------------------------- (intptr_t)(p_excinf + 80)
715;
716; ‚±‚±‚Å‚Í, Š„ž‚ݏˆ—ƒ‚[ƒh‚ɕύX‚µ‚ănƒ“ƒhƒ‰‚ðŽÀs‚·‚é.
717; CPU—áŠOƒnƒ“ƒhƒ‰‚É“n‚·VPŒ^‚̕ϐ” p_excinf ‚Æ‚µ‚ÄISP‚Ì’l“n‚·D
718;
719; ƒnƒ“ƒhƒ‰‚©‚烊ƒ^[ƒ“‚µ‚½Œã‚Í, ‘½dŠ„ž‚Ý‚Å‚È‚­, ‚©‚ reqflg ‚ª
720; TRUE ‚É‚È‚Á‚½Žž‚ɁCret_int ‚Ö•ªŠò(’x‰„ƒfƒBƒXƒpƒbƒ`)‚·‚éD
721;
722; ‘½dŠ„ž‚Ý‚©‚Ç‚¤‚©‚ÍŠ„ž‚݃lƒXƒgƒJƒEƒ“ƒ^‚Ì’l‚Å”»’è‚·‚é.
723; intnest != 0 ‚È‚ç‚Α½dŠ„ž‚Ý‚Å‚ ‚é‚Æ”»’è‚·‚é.
724;
725; reqflg ‚ÍCPUƒƒbƒNó‘ԂŃ`ƒFƒbƒN‚·‚é. ‚»‚¤‚Å‚È‚¢‚ƁC
726; reqflg ƒ`ƒFƒbƒNŒã‚É‹N“®‚³‚ꂽŠ„ž‚݃nƒ“ƒhƒ‰“à‚Å
727; ƒfƒBƒXƒpƒbƒ`‚ª—v‹‚³‚ꂽê‡‚ɁCƒfƒBƒXƒpƒbƒ`‚³‚ê‚È‚¢.
728;
729;
730; CPU—áŠO“üŒûˆ—
731;
732; ‚±‚±‚Å‚Í, Š„ž‚ݏˆ—ƒ‚[ƒh‚ɕύX‚µ‚ănƒ“ƒhƒ‰‚ðŽÀs‚·‚é.
733;
734
735;
736; CPU—áŠOƒnƒ“ƒhƒ‰ŒÄo‚µŒã‚É•s—v‚Æ‚È‚éƒXƒ^ƒbƒNî•ñ‚̃TƒCƒY
737; EXCNO + R6--R13
738;
739 EXCINF_REG_SIZE .equ (4+32)
740
741_kernel_exception:
742 pushm r14-r15 ; ƒXƒNƒ‰ƒbƒ`ƒŒƒWƒXƒ^‚ð‘Þ”ð
743 pushc fpsw
744 mvfacmi r5
745 shll #16, r5 ; ACCÅ‰ºˆÊ16bit‚Í0‚Æ‚·‚é
746 mvfachi r4
747 pushm r4-r5 ; ƒAƒLƒ…
748ƒ€ƒŒ[ƒ^‘Þ”ð
749 pushm r6-r13 ; ”ñƒXƒNƒ‰ƒbƒ`ƒŒƒWƒXƒ^•Û‘¶
750 push.l r1 ; CPU—áŠO—vˆö”ԍ†‚ð•ÛŽ
751 mov.l r0, r3 ; ƒXƒ^ƒbƒNƒ|ƒCƒ“ƒ^‚ðŽæ‚èo‚µ
752 mov.l EXC_GET_PSW_OFFSET[r3], r5
753 and #PSW_I_MASK, r5
754 bz exception_nonkernel ; ‘SŠ„ž‚Ý‹ÖŽ~(CPUƒƒbƒN)ó‘Ô‚È‚çŠÇ—ŠO
755.if TIPM_LOCK != -15
756 mov.l EXC_GET_PSW_OFFSET[r3], r5
757 and #PSW_IPL_MASK, r5
758 cmp #IPL_LOCK, r5
759 bgt exception_nonkernel ; IPL‚ªCPUƒƒbƒNƒŒƒxƒ‹ˆÈã‚È‚çŠÇ—ŠO
760.endif
761 mov.l #__kernel_intnest, r5
762 mov.w [r5], r4
763 add #1, r4 ; ƒlƒXƒg‰ñ”‚ðƒCƒ“ƒNƒŠƒƒ“ƒg
764 mov.w r4, [r5]
765 cmp #1, r4 ; ‘½dŠ„‚荞‚Ý‚©‚Ç‚¤‚©
766 bnz exception_from_int ; ‰ÁŽZ‘O‚ª0‚Å‚È‚¯‚ê‚Α½dŠ„ž‚Ý
767 ; ‰’i‚ÌŠ„ž‚Ý
768 mov.l #__kernel_istkpt, r5 ; Š„ž‚Ý—p‚̃Xƒ^ƒbƒN‚֐ؑւ¦‚é
769 mov.l [r5], r0
770 push.l r3 ; ƒ^ƒXƒNƒXƒ^ƒbƒN‚ð•ÛŽ
771exception_from_int: ; ‘½dŠ„ž‚Ý
772 mov.l EXC_GET_PSW_OFFSET[r3], r5
773 mvtc r5, psw ; CPU—áŠO”­¶‘O‚̏ó‘Ô‚É–ß‚·
774.if LOG_EXC_LEAVE == 1
775 push.l r1 ; ƒƒOƒgƒŒ[ƒX‚̈ø”‚ð•ÛŽ
776.endif
777
778.if LOG_EXC_ENTER == 1
779 pushm r2-r3
780 bsr _kernel_log_exc_enter ; ƒƒOƒgƒŒ[ƒXŠÖ”‚̌ďo‚µ
781 ; ˆø”‚ÌŠ„ž‚Ý—vˆö”ԍ†‚ÍŠù‚Ér1‚É“ü‚Á‚Ä‚¢‚é
782 popm r2-r3
783.endif
784
785 mov.l r3, r1 ; ˆø”‚Ìp_excinf‚ðÝ’è
786 jsr r2 ; Cƒ‹[ƒ`ƒ“ŒÄ‚яo‚µ
787
788.if LOG_EXC_LEAVE == 1
789 pop r1 ; ˆø”‚ÉŠ„ž‚Ý—vˆö”ԍ†‚ðÝ’è
790 bsr _kernel_log_exc_leave ; ƒƒOƒgƒŒ[ƒXŠÖ”‚̌ďo‚µ
791.endif
792
793 clrpsw i ; ‚±‚±‚©‚ç‚Í•K‚¸Š„ž‚Ý‹ÖŽ~
794 mov.l #__kernel_intnest, r5
795 mov.w [r5], r4
796 sub #1, r4 ; ƒlƒXƒg‰ñ”‚ðƒfƒNƒŠƒƒ“ƒg
797 mov.w r4, [r5]
798 cmp #0, r4 ; ‘½dŠ„‚荞‚Ý‚©‚Ç‚¤‚©
799 bnz exception_return ; ‘½dŠ„‚荞‚݂Ȃ烊ƒ^[ƒ“
800 ; ‰’i‚ÌŠ„ž‚Ý
801 pop r0 ; ƒ^ƒXƒN‚̃Xƒ^ƒbƒN‚É–ß‚·
802 mov.l #__kernel_reqflg, r5 ; ƒfƒBƒXƒpƒbƒ`—v‹‚ª‚È‚¢‚©?
803 mov.l [r5], r5
804 cmp #1, r5
805 bnz exception_return ; ‚È‚¯‚ê‚΃Šƒ^[ƒ“
806 add #EXCINF_REG_SIZE, r0 ; CPU—áŠOî•ñ‚Ì”jŠü
807 bra ret_int ; ‚ ‚ê‚Î ret_int ‚ÖƒWƒƒƒ“ƒv
808
809exception_nonkernel:
810 mov.l #__kernel_intnest, r5
811 mov.w [r5], r4
812 add #1, r4 ; ƒlƒXƒg‰ñ”‚ðƒCƒ“ƒNƒŠƒƒ“ƒg
813 mov.w r4, [r5]
814 cmp #1, r4 ; ‘½dŠ„‚荞‚Ý‚©‚Ç‚¤‚©
815 bnz exception_from_nonkernelint ; ‰ÁŽZ‘O‚ª0‚Å‚È‚¯‚ê‚Α½dŠ„ž‚Ý
816 ; ‰’i‚ÌŠ„ž‚Ý
817 mov.l #__kernel_istkpt, r5 ; Š„ž‚Ý—p‚̃Xƒ^ƒbƒN‚֐ؑւ¦‚é
818 mov.l [r5], r0
819 push.l r3 ; ƒ^ƒXƒNƒXƒ^ƒbƒN‚ð•ÛŽ
820exception_from_nonkernelint: ; ‘½dŠ„ž‚Ý
821 mov.l EXC_GET_PSW_OFFSET[r3], r5
822 mvtc r5, psw ; CPU—áŠO”­¶‘O‚̏ó‘Ô‚É–ß‚·
823
824 mov.l r3, r1 ; ˆø”‚Ìp_excinf‚ðÝ’è
825 jsr r2 ; Cƒ‹[ƒ`ƒ“ŒÄ‚яo‚µ
826
827 clrpsw i ; ‚±‚±‚©‚ç‚Í•K‚¸Š„ž‚Ý‹ÖŽ~
828 mov.l #__kernel_intnest, r5
829 mov.w [r5], r4
830 sub #1, r4 ; ƒlƒXƒg‰ñ”‚ðƒfƒNƒŠƒƒ“ƒg
831 mov.w r4, [r5]
832 cmp #0, r4 ; ‘½dŠ„‚荞‚Ý‚©‚Ç‚¤‚©
833 bnz exception_return ; ‘½dŠ„‚荞‚݂Ȃ烊ƒ^[ƒ“
834 ; ‰’i‚ÌŠ„ž‚Ý
835 pop r0 ; ƒ^ƒXƒN‚̃Xƒ^ƒbƒN‚É–ß‚·
836
837exception_return:
838 add #EXCINF_REG_SIZE, r0 ; CPU—áŠOî•ñ‚Ì”jŠü
839 popm r4-r5 ; ƒAƒLƒ…
840ƒ€ƒŒ[ƒ^•œ‹A
841 mvtaclo r5 ; ACCÅ‰ºˆÊ16bit‚Í0‚Å•œ‹A
842 mvtachi r4
843 popc fpsw ; FPUƒXƒe[ƒ^ƒXƒŒƒWƒXƒ^•œ‹A
844 popm r14-r15 ; ƒŒƒWƒXƒ^•œ‹A
845 popm r1-r5
846 rte ; Š„ž‚Ý‘O‚̏ˆ—‚É–ß‚é
847
848
849;
850; ”÷­ŽžŠÔ‘Ò‚¿
851;
852_sil_dly_nse:
853 mov.l #SIL_DLY_TIM1, r5
854 sub r5, r1
855 ble sil_dly_nse_ret
856sil_dly_nse_loop:
857 mov.l #SIL_DLY_TIM2, r5
858 sub r5, r1
859 bgt sil_dly_nse_loop
860sil_dly_nse_ret:
861 rts
862
863 .end
864
Note: See TracBrowser for help on using the repository browser.