source: uKadecot/trunk/ssp/arch/rx630_ccrx/prc_support.src@ 101

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

TOPPERS/uKadecotのソースコードを追加

File size: 17.7 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) 2007 by Embedded and Real-Time Systems Laboratory
8; Graduate School of Information Science, Nagoya Univ., JAPAN
9; Copyright (C) 2010 by Witz Corporation, JAPAN
10; Copyright (C) 2013 by Mitsuhiro Matsuura
11;
12; ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì(1)`(4)‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
13; ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü
14; •ÏEÄ”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
15; (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ì
16; Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[
17; ƒXƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
18; (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
19; —p‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
20ƒƒ“ƒgi—˜—p
21; ŽÒƒ}ƒjƒ…
22ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L
23; ‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
24; (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
25; —p‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±
26; ‚Ɓ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‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹
34; ŠQ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
35; ‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝
36; —R‚ÉŠî‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð
37; –Ɛӂ·‚邱‚ƁD
38;
39; –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨
40; ‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC“Á’è‚ÌŽg—p–Ú“I
41; ‚ɑ΂·‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒF
42; ƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»
43; ‚̐ӔC‚𕉂í‚È‚¢D
44;
45;
46
47;
48; ƒvƒƒZƒbƒTˆË‘¶ƒ‚ƒWƒ…
49[ƒ‹ ƒAƒZƒ“ƒuƒŠŒ¾Œê•”iRX630—pj
50;
51
52;
53; ƒfƒBƒXƒpƒbƒ`ƒƒ‚¨‚æ‚ÑŠ„ž‚Ý(CPU—áŠO)o“ü‚èŒû‚̃‹[ƒ‹:
54; “®ìƒ‚[ƒh‚ðˆÈ‰º‚̂悤‚É’è‹`‚·‚é.
55; ƒfƒBƒXƒpƒbƒ`ƒƒƒ‚[ƒh:
56; CPUƒƒbƒNó‘Ô, Š„ž‚Ý—Dæ“xƒ}ƒXƒN‘S‰ðœó‘Ô,
57; ƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg(intnest = 0), ƒ^ƒXƒNƒXƒ^ƒbƒN
58; Š„ž‚Ý(CPU—áŠO)ˆ—ƒ‚[ƒh
59; ‘SŠ„ž‚݃ƒbƒNó‘Ô(PSWƒŒƒWƒXƒ^Iƒrƒbƒg = 0),
60; Š„ž‚Ý—Dæ“xƒ}ƒXƒN‘S‰ðœ‚Å‚È‚¢ó‘Ô(IPL != 0)
61; Š„ž‚݃Rƒ“ƒeƒLƒXƒg(intnest != 0), Š„ž‚݃Xƒ^ƒbƒN
62;
63; ƒJ[ƒlƒ‹ŠÇ—ŠOŠ„ž‚݂̃Tƒ|[ƒg—L–³‚Æ, CPUƒƒbƒNó‘Ô, Š„ž‚Ý—Dæ“x
64; ƒ}ƒXƒN‘S‰ðœó‘Ô‚ÌŠÖŒW‚͈ȉº‚Ì’Ê‚è‚Å‚ ‚é.
65; ƒJ[ƒlƒ‹ŠÇ—ŠOŠ„ž‚Ý–¢ƒTƒ|[ƒgŽž:
66; CPUƒƒbƒNó‘Ô(PSWƒŒƒWƒXƒ^Iƒrƒbƒg = 0)
67; Š„ž‚Ý—Dæ“xƒ}ƒXƒN‘S‰ðœó‘Ô(IPL = 0)
68; ƒJ[ƒlƒ‹ŠÇ—ŠOŠ„ž‚݃Tƒ|[ƒgŽž:
69; CPUƒƒbƒNó‘Ô
70; (PSWƒŒƒWƒXƒ^Iƒrƒbƒg = 0, IPL = IPL_LOCK, lock_flag = true)
71; Š„ž‚Ý—Dæ“xƒ}ƒXƒN‘S‰ðœó‘Ô(saved_ipl = 0)
72;
73; Še\‘¢‘̃|ƒCƒ“ƒ^‚ðˆÈ‰º‚̂悤‚ÉŠeƒŒƒWƒXƒ^‚ɃAƒTƒCƒ“‚·‚é.
74; r15 = p_runtsk ‚½‚¾‚µƒfƒBƒXƒpƒbƒ`ƒƒ‚ÌŠeoŒû‚Å‚Í–³Œø
75; r14 = *p_runtsk dispatcher ‚Ì’†‚Å‚Í p_runtsk Šm’莞‚ɍĎ擾‚·‚é
76; Še“ü‚èŒû‚©‚çÅ‰‚ɕϐ”ƒAƒNƒZƒX‚·‚é‚Æ‚«‚ɏã‹LƒŒƒWƒXƒ^‚É•Û‘¶‚·‚é.
77;
78; \‘¢‘̃Aƒ‰ƒCƒƒ“ƒg‚ւ̑Ήž
79; \‘¢‘̃Aƒ‰ƒCƒƒ“ƒg‚ª4Byte(ƒAƒ“ƒpƒbƒN)‚̏ꍇ:
80; ˆê”Ê“I‚ȃŒƒWƒXƒ^‘Š‘΃AƒhƒŒƒbƒVƒ“ƒO‚ª‰Â”\
81; —á: mov.l #__kernel_p_runtsk, r15
82; mov.l r0, TCB_sp[r15]
83; \‘¢‘̃Aƒ‰ƒCƒƒ“ƒg‚ª4Byte‚Å‚Í‚È‚¢(ƒpƒbƒN)‚̏ꍇ:
84; mov.l‚̂悤‚Ƀƒ“ƒOƒTƒCƒYŽw’è‚̏ꍇA‘Š‘Î’l‚Í4‚Ì”{”‚Ì‚Ý—LŒø
85; ‚±‚Ì‚½‚ß, ˆê“x‘ΏۃAƒhƒŒƒX‚ð‹‚ß‚Ä‚©‚çƒAƒNƒZƒX‚·‚é•K—v‚ª‚ ‚é
86; —á: mov.l #__kernel_p_runtsk, r15
87; add #TCB_sp, r15, r5
88; mov.l r0, [r5]
89; ŠeƒIƒtƒZƒbƒg’l‚ð”»’f‚µ, ðŒƒAƒZƒ“ƒuƒ‹‚É‚æ‚èƒR[ƒh‚ðØ‚è‘Ö‚¦‚é
90;
91
92;
93; ŠeŽíEQU’è‹`(Hƒtƒ@ƒCƒ‹‚Ì#define’è‹`)
94;
95 .include asm_config.inc
96
97 .glb __kernel_istkpt
98
99 .glb __kernel_reqflg
100
101 .glb __kernel_search_schedtsk
102 .glb __kernel_run_task
103 .glb __kernel_dispatcher
104 .glb _kernel_interrupt
105 .glb _kernel_exception
106 .glb __kernel_intnest
107 .glb __kernel_call_exit_kernel
108 .glb __kernel_start_dispatch
109
110 .glb __kernel_exit_kernel
111
112.if TIPM_LOCK != -15
113 .glb __kernel_lock_flag
114 .glb __kernel_saved_ipl
115.endif
116
117 .glb _sil_dly_nse
118
119.if LOG_INH_ENTER_ENABLE == 1
120 .glb _kernel_log_inh_enter
121.endif ; LOG_INH_ENTER_ENABLE == 1
122.if LOG_INH_LEAVE_ENABLE == 1
123 .glb _kernel_log_inh_leave
124.endif ; LOG_INH_LEAVE_ENABLE == 1
125.if LOG_EXC_ENTER_ENABLE == 1
126 .glb _kernel_log_exc_enter
127.endif ; LOG_EXC_ENTER_ENABLE == 1
128.if LOG_EXC_LEAVE_ENABLE == 1
129 .glb _kernel_log_exc_leave
130.endif ; LOG_EXC_LEAVE_ENABLE == 1
131.if LOG_DSP_ENTER_ENABLE == 1
132 .glb _kernel_log_dsp_enter
133.endif ; LOG_DSP_ENTER_ENABLE == 1
134.if LOG_DSP_LEAVE_ENABLE == 1
135 .glb _kernel_log_dsp_leave
136.endif ; LOG_DSP_LEAVE_ENABLE == 1
137
138 .section P, CODE
139
140;
141; ƒJ[ƒlƒ‹‹N“®‚©‚ç‚̃^ƒXƒNƒfƒBƒXƒpƒbƒ`ƒƒ“üŒû
142;
143; ‚±‚̃‹[ƒ`ƒ“‚́CƒJ[ƒlƒ‹‹N“®Žž‚ɁC‚·‚ׂĂ̊„ž‚Ý‚ð‹ÖŽ~‚µ‚½ó‘Ô
144; iŠ„ž‚݃ƒbƒNó‘Ô‚Æ“¯“™j‚ŌĂяo‚³‚ê‚éD‚Ü‚½CŠ„ž‚݃‚[ƒhi”ñ
145; ƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg‚Æ“¯“™j‚ŌĂяo‚³‚ê‚邱‚Æ‚ð‘z’肵‚Ä‚¢‚éD
146;
147; ŒÄ‚яo‚µðŒ:
148; EŠ„ž‚Ý(CPU—áŠO)ˆ—ƒ‚[ƒh(ƒtƒ@ƒCƒ‹ƒwƒbƒ_ŽQÆ)
149;
150; ‚±‚±‚Å‚Í, ƒfƒBƒXƒpƒbƒ`ƒƒƒ‚[ƒh‚ɕύX‚·‚é.
151;
152__kernel_start_dispatch:
153 mov.l #__kernel_intnest, r5
154 mov.w #0, [r5] ; ƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg‚ɐ؊·‚¦
155.if TIPM_LOCK != -15
156 mvtc #(IPL_LOCK | 00010000H), psw ; ‘SŠ„ž‚݃ƒbƒN‰ðœó‘Ô
157 ; Š„ž‚Ý—Dæ“xƒ}ƒXƒN‘S‰ðœ‚Å‚È‚¢ó‘Ô
158.endif
159 bra __kernel_dispatcher
160
161
162;
163; ƒJ[ƒlƒ‹‚̏I—¹ˆ—‚̌ďo‚µ
164;
165; ƒ‚[ƒh‚ƃXƒ^ƒbƒN‚ð”ñƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg—p‚ɐ؂è‘Ö‚¦D
166;
167 .glb __kernel_call_exit_kernel
168__kernel_call_exit_kernel:
169.if TIPM_LOCK != -15
170 clrpsw i ; ‘SŠ„ž‚Ý‹ÖŽ~
171 mov.l #__kernel_lock_flag, r5 ; CPUƒƒbƒN‰ðœó‘Ô‚Ö
172 mov.l #0, [r5]
173.endif
174 mov.l #__kernel_istkpt, r5
175 mov.l [r5], r0 ; Š„ž‚Ý—p‚̃Xƒ^ƒbƒN‚֐ؑւ¦
176 mov.l #__kernel_intnest, r5
177 mov.w #1, [r5] ; ”ñƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg‚ɐ؊·‚¦
178 bsr __kernel_exit_kernel
179 bra __kernel_call_exit_kernel
180
181
182;
183; Š„ž‚Ý(CPU—áŠO)‚©‚ç‚̃^ƒXƒNƒfƒBƒXƒpƒbƒ`ƒƒ“üŒû
184;
185; ŒÄo‚µðŒ:
186; E‘SŠ„ž‚݃ƒbƒNó‘Ô(PSWƒŒƒWƒXƒ^Iƒrƒbƒg = 0)
187; EŠ„ž‚Ý—Dæ“xƒ}ƒXƒN‘S‰ðœ‚Å‚È‚¢ó‘Ô(IPL != 0)
188; Eƒ^ƒXƒNƒRƒ“ƒeƒLƒXƒg(intnest=0)
189; EŽg—pƒXƒ^ƒbƒN‚̓^ƒXƒNƒXƒ^ƒbƒN
190; Ereqflg = true
191;
192; ‚±‚±‚Å‚Í, ƒfƒBƒXƒpƒbƒ`ƒƒƒ‚[ƒh‚ɕύX‚µ, reqflg‚ðOFF‚É‚µ‚Ä‚©‚ç,
193; ’x‰„ƒfƒBƒXƒpƒbƒ`‚Ì—L–³‚ð”»’f‚·‚é.
194;
195
196;
197; ret_intæ“ª‚ŃXƒ^ƒbƒN‚ɐς܂ê‚Ä‚¢‚éPSWƒŒƒWƒXƒ^‚ւ̃IƒtƒZƒbƒg
198; ACC + FPSW + R14--R15 + R1--R5 + PC
199;
200 RET_INT_GET_PSW_OFFSET .equ (8+4+28+4)
201
202ret_int:
203.if TIPM_LOCK == -15
204 mov.l RET_INT_GET_PSW_OFFSET[r0], r5 ; Š„ž‚Ý/CPU—áŠO”­¶‘O‚ÌIPL’lŽæ“¾
205 and #PSW_IPL_MASK, r5
206 mvtc r5, psw ; ‘SŠ„ž‚݃ƒbƒN(CPUƒƒbƒN)ó‘Ô
207 ; Š„ž‚Ý/CPU—áŠO”­¶‘O‚ÌŠ„ž‚Ý—Dæ“x
208.else
209 mov.l #__kernel_lock_flag, r5 ; CPUƒƒbƒNó‘Ô‚Ö
210 mov.l #1, [r5]
211 mov.l RET_INT_GET_PSW_OFFSET[r0], r5 ; Š„ž‚Ý/CPU—áŠO”­¶‘O‚ÌIPL’lŽæ“¾
212 and #PSW_IPL_MASK, r5
213 mov.l #__kernel_saved_ipl, r4
214 mov.l r5, [r4]
215 mvtc #(IPL_LOCK | PSW_I_MASK), psw ; ‘SŠ„ž‚݃ƒbƒN‰ðœó‘Ô
216 ; Š„ž‚Ý—Dæ“xƒ}ƒXƒN‘S‰ðœ‚Å‚È‚¢ó‘Ô
217.endif
218 mov.l #__kernel_reqflg, r5
219 mov.l #0, [r5] ; reqflg <--- FALSE
220 bsr __kernel_search_schedtsk ; ƒ^ƒXƒN‚ðŽÀs
221 bsr __kernel_run_task ; search_schedtsk‚Ì•Ô‚è’l(R1)‚ª‚»‚Ì‚Ü‚Ürun_task‚̈ø”‚Æ‚È‚é
222
223;
224; Š„ž‚Ý(CPU—áŠO)‚ւ̃^ƒXƒNƒfƒBƒXƒpƒbƒ`ƒƒoŒû
225;
226; ŒÄ‚яo‚µðŒ:
227; EƒfƒBƒXƒpƒbƒ`ƒƒƒ‚[ƒh(ƒtƒ@ƒCƒ‹ƒwƒbƒ_ŽQÆ)
228;
229; ‚±‚±‚Å‚Í, ƒ^ƒXƒN—áŠOƒnƒ“ƒhƒ‰ŒÄo‚µ‚Æ, Š„ž‚Ý(CPU—áŠO)ˆ—ƒ‚[ƒh‚Ö‚Ì
230; •ÏX‚Æ, ƒRƒ“ƒeƒLƒXƒg‚Ì•œ‹A‚ðs‚¢, Š„ž‚Ý(CUP—áŠO)”­¶Œ³‚Ö–ß‚é.
231;
232ret_int_r_rte:
233.if TIPM_LOCK != -15
234 clrpsw i ; ‘SŠ„ž‚Ý‹ÖŽ~
235 mov.l #__kernel_lock_flag, r5 ; CPUƒƒbƒN‰ðœó‘Ô‚Ö
236 mov.l #0, [r5]
237.endif
238 popm r4-r5 ; ƒAƒLƒ…
239ƒ€ƒŒ[ƒ^•œ‹A
240 mvtaclo r5 ; ACCÅ‰ºˆÊ16bit‚Í0‚Å•œ‹A
241 mvtachi r4
242 popc fpsw ; FPUƒXƒe[ƒ^ƒXƒŒƒWƒXƒ^•œ‹A
243 popm r14-r15 ; ƒŒƒWƒXƒ^•œ‹A
244 popm r1-r5
245 rte ; Š„ž‚Ý‘O‚̏ˆ—‚É–ß‚é
246
247
248;
249; Š„ž‚݂̏o“üŒûˆ—(ƒAƒZƒ“ƒuƒŠŒ¾Œê‹Lq•”•ª)
250;
251; ŒÄo‚µðŒ:
252; EŠ„ž‚Ý”­¶Žž‚ÌH/Wˆ—‚É‚æ‚è, PSWƒŒƒWƒXƒ^‚ÌIƒrƒbƒg=0, IPL‚ÍŽó•t‚¯
253; ‚½Š„ž‚Ý‚ÌIPL.
254; EƒXƒ^ƒbƒN‚Í‘½dŠ„‚荞‚݂Ȃ犄ž‚݃Xƒ^ƒbƒN, ‚»‚¤‚Å‚È‚¯‚ê‚Î
255; ƒ^ƒXƒNƒXƒ^ƒbƒN
256; EŠ„ž‚Ý”­¶Žž‚ÌH/Wˆ—‚É‚æ‚è,ƒXƒ^ƒbƒN‚ÉŠ„ž‚Ý‚©‚ç‚Ì•œ‹APC‚ÆPSW‚ª
257; •Û‘¶‚³‚ê‚Ä‚¢‚é.
258; EƒxƒNƒ^ƒe[ƒuƒ‹‚É“o˜^‚³‚ꂽŒÂ•Ê‚Ì“ü‚èŒûˆ—‚É‚æ‚è, ƒXƒ^ƒbƒN‚É
259; ƒXƒNƒ‰ƒbƒ`ƒŒƒWƒXƒ^(R1-R5)‚ª•Û‘¶‚³‚ê‚Ä‚¢‚é.
260;
261; ˆø”:
262; Er1:Š„ž‚Ý—vˆö”ԍ†
263; Er2:Š„ž‚݃nƒ“ƒhƒ‰‚̃AƒhƒŒƒX
264;
265; ƒŒƒWƒXƒ^‚ªƒXƒ^ƒbƒNã‚ɂǂ̂悤‚É•Û‘¶‚³‚ê‚Ä‚¢‚é‚©‚ðˆÈ‰º‚ÉŽ¦‚·.
266; ‚±‚̐}‚ł͏オ’áˆÊ, ‰º‚ª‚ˆÊ‚̃AƒhƒŒƒX‚Å, ƒXƒ^ƒbƒN‚͉º‚©‚ç
267; ã•ûŒü‚ÉŒü‚©‚Á‚Đςݏグ‚ç‚ê‚é‚à‚Ì‚Æ‚·‚é.
268;
269; -------------------------
270; | ACC-HI(4byte) |
271; -------------------------(SP + 0)
272; | ACC-LO(4byte) |
273; -------------------------(SP + 4)
274; | FPSW(4byte) |
275; -------------------------(SP + 8)
276; | R14(4byte) |
277; -------------------------(SP + 12)
278; | R15(4byte) |
279; -------------------------(SP + 16)
280; | R1(4byte) |
281; -------------------------(SP + 20)
282; | R2(4byte) |
283; -------------------------(SP + 24)
284; | R3(4byte) |
285; -------------------------(SP + 28)
286; | R4(4byte) |
287; -------------------------(SP + 32)
288; | R5(4byte) |
289; -------------------------(SP + 36)
290; | PC(4byte) |
291; -------------------------(SP + 40)
292; | PSW(4byte) |
293; -------------------------(SP + 44)
294;
295; ‚±‚±‚Å‚Í, Š„ž‚ݏˆ—ƒ‚[ƒh‚ɕύX‚µ‚ănƒ“ƒhƒ‰‚ðŽÀs‚·‚é.
296;
297; ƒnƒ“ƒhƒ‰‚©‚烊ƒ^[ƒ“‚µ‚½Œã‚Í, ‘½dŠ„ž‚Ý‚Å‚È‚­, ‚©‚ reqflg ‚ª
298; TRUE ‚É‚È‚Á‚½Žž‚ɁCret_int ‚Ö•ªŠò(’x‰„ƒfƒBƒXƒpƒbƒ`)‚·‚éD
299;
300; ‘½dŠ„ž‚Ý‚©‚Ç‚¤‚©‚ÍŠ„ž‚݃lƒXƒgƒJƒEƒ“ƒ^‚Ì’l‚Å”»’è‚·‚é.
301; intnest != 0 ‚È‚ç‚Α½dŠ„ž‚Ý‚Å‚ ‚é‚Æ”»’è‚·‚é.
302;
303; reqflg ‚ÍCPUƒƒbƒNó‘ԂŃ`ƒFƒbƒN‚·‚é. ‚»‚¤‚Å‚È‚¢‚ƁC
304; reqflg ƒ`ƒFƒbƒNŒã‚É‹N“®‚³‚ꂽŠ„ž‚݃nƒ“ƒhƒ‰“à‚Å
305; ƒfƒBƒXƒpƒbƒ`‚ª—v‹‚³‚ꂽê‡‚ɁCƒfƒBƒXƒpƒbƒ`‚³‚ê‚È‚¢.
306;
307_kernel_interrupt:
308 pushm r14-r15 ; ƒXƒNƒ‰ƒbƒ`ƒŒƒWƒXƒ^‚ð‘Þ”ð
309 pushc fpsw ; FPUƒXƒe[ƒ^ƒXƒŒƒWƒXƒ^‘Þ”ð
310 mvfacmi r5
311 shll #16, r5 ; ACCÅ‰ºˆÊ16bit‚Í0‚Æ‚·‚é
312 mvfachi r4
313 pushm r4-r5 ; ƒAƒLƒ…
314ƒ€ƒŒ[ƒ^‘Þ”ð
315 mov.l #__kernel_intnest, r5
316 mov.w [r5], r4
317 add #1, r4 ; ƒlƒXƒg‰ñ”‚ðƒCƒ“ƒNƒŠƒƒ“ƒg
318 mov.w r4, [r5]
319 setpsw i ; Š„ž‚Ý‹–‰Â(CPUƒƒbƒN‰ðœó‘Ô)
320
321.if LOG_INH_LEAVE == 1
322 push.l r1 ; ƒƒOƒgƒŒ[ƒX‚̈ø”‚ð•ÛŽ
323.endif
324
325.if LOG_INH_ENTER == 1
326 push.l r2
327 bsr _kernel_log_inh_enter ; ƒƒOƒgƒŒ[ƒXŠÖ”‚̌ďo‚µ
328 ; ˆø”‚ÌŠ„ž‚Ý—vˆö”ԍ†‚ÍŠù‚Ér1‚É“ü‚Á‚Ä‚¢‚é
329 pop r2
330.endif
331
332 jsr r2 ; Cƒ‹[ƒ`ƒ“ŒÄ‚яo‚µ
333
334.if LOG_INH_LEAVE == 1
335 pop r1 ; ˆø”‚ÉŠ„ž‚Ý—vˆö”ԍ†‚ðÝ’è
336 bsr _kernel_log_inh_leave ; ƒƒOƒgƒŒ[ƒXŠÖ”‚̌ďo‚µ
337.endif
338
339 clrpsw i ; Š„ž‚Ý‹ÖŽ~(CPUƒƒbƒNó‘Ô)
340 mov.l #__kernel_intnest, r5
341 mov.w [r5], r4
342 sub #1, r4 ; ƒlƒXƒg‰ñ”‚ðƒfƒNƒŠƒƒ“ƒg
343 mov.w r4, [r5]
344 cmp #0, r4 ; ‘½dŠ„‚荞‚Ý‚©‚Ç‚¤‚©
345 bnz interrupt_return ; ‘½dŠ„‚荞‚݂Ȃ烊ƒ^[ƒ“
346 ; ‰’i‚ÌŠ„ž‚Ý
347 mov.l #__kernel_reqflg, r5 ; ƒfƒBƒXƒpƒbƒ`—v‹‚ª‚È‚¢‚©?
348 mov.l [r5], r5
349 cmp #1, r5
350 bz ret_int ; ‚ ‚ê‚Î ret_int ‚ÖƒWƒƒƒ“ƒv
351interrupt_return:
352 popm r4-r5 ; ƒAƒLƒ…
353ƒ€ƒŒ[ƒ^•œ‹A
354 mvtaclo r5 ; ACCÅ‰ºˆÊ16bit‚Í0‚Å•œ‹A
355 mvtachi r4
356 popc fpsw ; FPUƒXƒe[ƒ^ƒXƒŒƒWƒXƒ^•œ‹A
357 popm r14-r15 ; ƒŒƒWƒXƒ^•œ‹A
358 popm r1-r5
359 rte ; Š„ž‚Ý‘O‚̏ˆ—‚É–ß‚é
360
361
362;
363; CPU—áŠO‚̏o“üŒûˆ—(ƒAƒZƒ“ƒuƒŠŒ¾Œê‹Lq•”•ª)
364;
365; ŒÄo‚µðŒ:
366; ECPU—áŠO”­¶Žž‚ÌH/Wˆ—‚É‚æ‚è, PSWƒŒƒWƒXƒ^‚ÌIƒrƒbƒg=0, IPL=0.
367; EƒXƒ^ƒbƒN‚Í‘½dŠ„‚荞‚݂Ȃ犄ž‚݃Xƒ^ƒbƒN, ‚»‚¤‚Å‚È‚¯‚ê‚Î
368; ƒ^ƒXƒNƒXƒ^ƒbƒN
369; ECPU—áŠO”­¶Žž‚ÌH/Wˆ—‚É‚æ‚è,ƒXƒ^ƒbƒN‚ÉCPU—áŠO‚©‚ç‚Ì•œ‹APC‚Æ
370; PSW‚ª•Û‘¶‚³‚ê‚Ä‚¢‚é.
371; EƒxƒNƒ^ƒe[ƒuƒ‹‚É“o˜^‚³‚ꂽŒÂ•Ê‚Ì“ü‚èŒûˆ—‚É‚æ‚è, ƒXƒ^ƒbƒN‚É
372; ƒXƒNƒ‰ƒbƒ`ƒŒƒWƒXƒ^(R1-R5)‚ª•Û‘¶‚³‚ê‚Ä‚¢‚é.
373;
374; ˆø”:
375; Er1:CPU—áŠO—vˆö”ԍ†
376; Er2:CPU—áŠOƒnƒ“ƒhƒ‰‚̃AƒhƒŒƒX
377;
378; ƒŒƒWƒXƒ^‚ªƒXƒ^ƒbƒNã‚ɂǂ̂悤‚É•Û‘¶‚³‚ê‚Ä‚¢‚é‚©‚ðˆÈ‰º‚ÉŽ¦‚·.
379; ‚±‚̐}‚ł͏オ’áˆÊ, ‰º‚ª‚ˆÊ‚̃AƒhƒŒƒX‚Å, ƒXƒ^ƒbƒN‚͉º‚©‚ç
380; ã•ûŒü‚ÉŒü‚©‚Á‚Đςݏグ‚ç‚ê‚é‚à‚Ì‚Æ‚·‚é.
381; ‚È‚¨, CPU—áŠO—vˆö”ԍ†‚ÆR6-R13‚ÍCPU—áŠOƒnƒ“ƒhƒ‰“à‚ŏî•ñ‚ðŽæ“¾
382; ‚·‚é–Ú“I‚Å‘Þ”ð‚µ‚Ä‚¨‚è, oŒûˆ—‚Å‚Í•Û‘¶“à—e‚ð”jŠü‚·‚ê‚΂悢.
383;
384; -------------------------
385; | CPU—áŠO—vˆö”ԍ† | <----- p_excinf
386; ------------------------- (intptr_t)(p_excinf + 0)
387; | R6(4byte) |
388; ------------------------- (intptr_t)(p_excinf + 4)
389; | R7(4byte) |
390; ------------------------- (intptr_t)(p_excinf + 8)
391; | R8(4byte) |
392; ------------------------- (intptr_t)(p_excinf + 12)
393; | R9(4byte) |
394; ------------------------- (intptr_t)(p_excinf + 16)
395; | R10(4byte) |
396; ------------------------- (intptr_t)(p_excinf + 20)
397; | R11(4byte) |
398; ------------------------- (intptr_t)(p_excinf + 24)
399; | R12(4byte) |
400; ------------------------- (intptr_t)(p_excinf + 28)
401; | R13(4byte) |
402; ------------------------- (intptr_t)(p_excinf + 32)
403; | ACC-HI(4byte) |
404; ------------------------- (intptr_t)(p_excinf + 36)
405; | ACC-LO(4byte) |
406; ------------------------- (intptr_t)(p_excinf + 40)
407; | FPSW(4byte) |
408; ------------------------- (intptr_t)(p_excinf + 44)
409; | R14(4byte) |
410; ------------------------- (intptr_t)(p_excinf + 48)
411; | R15(4byte) |
412; ------------------------- (intptr_t)(p_excinf + 52)
413; | R1(4byte) |
414; ------------------------- (intptr_t)(p_excinf + 56)
415; | R2(4byte) |
416; ------------------------- (intptr_t)(p_excinf + 60)
417; | R3(4byte) |
418; ------------------------- (intptr_t)(p_excinf + 64)
419; | R4(4byte) |
420; ------------------------- (intptr_t)(p_excinf + 68)
421; | R5(4byte) |
422; ------------------------- (intptr_t)(p_excinf + 72)
423; | PC(4byte) |
424; ------------------------- (intptr_t)(p_excinf + 76)
425; | PSW(4byte) |
426; ------------------------- (intptr_t)(p_excinf + 80)
427;
428; ‚±‚±‚Å‚Í, Š„ž‚ݏˆ—ƒ‚[ƒh‚ɕύX‚µ‚ănƒ“ƒhƒ‰‚ðŽÀs‚·‚é.
429; CPU—áŠOƒnƒ“ƒhƒ‰‚É“n‚·VPŒ^‚̕ϐ” p_excinf ‚Æ‚µ‚ÄISP‚Ì’l“n‚·D
430;
431; ƒnƒ“ƒhƒ‰‚©‚烊ƒ^[ƒ“‚µ‚½Œã‚Í, ‘½dŠ„ž‚Ý‚Å‚È‚­, ‚©‚ reqflg ‚ª
432; TRUE ‚É‚È‚Á‚½Žž‚ɁCret_int ‚Ö•ªŠò(’x‰„ƒfƒBƒXƒpƒbƒ`)‚·‚éD
433;
434; ‘½dŠ„ž‚Ý‚©‚Ç‚¤‚©‚ÍŠ„ž‚݃lƒXƒgƒJƒEƒ“ƒ^‚Ì’l‚Å”»’è‚·‚é.
435; intnest != 0 ‚È‚ç‚Α½dŠ„ž‚Ý‚Å‚ ‚é‚Æ”»’è‚·‚é.
436;
437; reqflg ‚ÍCPUƒƒbƒNó‘ԂŃ`ƒFƒbƒN‚·‚é. ‚»‚¤‚Å‚È‚¢‚ƁC
438; reqflg ƒ`ƒFƒbƒNŒã‚É‹N“®‚³‚ꂽŠ„ž‚݃nƒ“ƒhƒ‰“à‚Å
439; ƒfƒBƒXƒpƒbƒ`‚ª—v‹‚³‚ꂽê‡‚ɁCƒfƒBƒXƒpƒbƒ`‚³‚ê‚È‚¢.
440;
441;
442; CPU—áŠO“üŒûˆ—
443;
444; ‚±‚±‚Å‚Í, Š„ž‚ݏˆ—ƒ‚[ƒh‚ɕύX‚µ‚ănƒ“ƒhƒ‰‚ðŽÀs‚·‚é.
445;
446
447;
448; CPU—áŠOƒnƒ“ƒhƒ‰ŒÄo‚µŒã‚É•s—v‚Æ‚È‚éƒXƒ^ƒbƒNî•ñ‚̃TƒCƒY
449; EXCNO + R6--R13
450;
451 EXCINF_REG_SIZE .equ (4+32)
452
453_kernel_exception:
454 pushm r14-r15 ; ƒXƒNƒ‰ƒbƒ`ƒŒƒWƒXƒ^‚ð‘Þ”ð
455 pushc fpsw
456 mvfacmi r5
457 shll #16, r5 ; ACCÅ‰ºˆÊ16bit‚Í0‚Æ‚·‚é
458 mvfachi r4
459 pushm r4-r5 ; ƒAƒLƒ…
460ƒ€ƒŒ[ƒ^‘Þ”ð
461 pushm r6-r13 ; ”ñƒXƒNƒ‰ƒbƒ`ƒŒƒWƒXƒ^•Û‘¶
462 push.l r1 ; CPU—áŠO—vˆö”ԍ†‚ð•ÛŽ
463 mov.l r0, r3 ; ƒXƒ^ƒbƒNƒ|ƒCƒ“ƒ^‚ðŽæ‚èo‚µ
464 mov.l EXC_GET_PSW_OFFSET[r3], r5
465 and #PSW_I_MASK, r5
466 bz exception_nonkernel ; ‘SŠ„ž‚Ý‹ÖŽ~(CPUƒƒbƒN)ó‘Ô‚È‚çŠÇ—ŠO
467.if TIPM_LOCK != -15
468 mov.l EXC_GET_PSW_OFFSET[r3], r5
469 and #PSW_IPL_MASK, r5
470 cmp #IPL_LOCK, r5
471 bgt exception_nonkernel ; IPL‚ªCPUƒƒbƒNƒŒƒxƒ‹ˆÈã‚È‚çŠÇ—ŠO
472.endif
473 mov.l #__kernel_intnest, r5
474 mov.w [r5], r4
475 add #1, r4 ; ƒlƒXƒg‰ñ”‚ðƒCƒ“ƒNƒŠƒƒ“ƒg
476 mov.w r4, [r5]
477 mov.l EXC_GET_PSW_OFFSET[r3], r5
478 mvtc r5, psw ; CPU—áŠO”­¶‘O‚̏ó‘Ô‚É–ß‚·
479.if LOG_EXC_LEAVE == 1
480 push.l r1 ; ƒƒOƒgƒŒ[ƒX‚̈ø”‚ð•ÛŽ
481.endif
482
483.if LOG_EXC_ENTER == 1
484 pushm r2-r3
485 bsr _kernel_log_exc_enter ; ƒƒOƒgƒŒ[ƒXŠÖ”‚̌ďo‚µ
486 ; ˆø”‚ÌŠ„ž‚Ý—vˆö”ԍ†‚ÍŠù‚Ér1‚É“ü‚Á‚Ä‚¢‚é
487 popm r2-r3
488.endif
489
490 mov.l r3, r1 ; ˆø”‚Ìp_excinf‚ðÝ’è
491 jsr r2 ; Cƒ‹[ƒ`ƒ“ŒÄ‚яo‚µ
492
493.if LOG_EXC_LEAVE == 1
494 pop r1 ; ˆø”‚ÉŠ„ž‚Ý—vˆö”ԍ†‚ðÝ’è
495 bsr _kernel_log_exc_leave ; ƒƒOƒgƒŒ[ƒXŠÖ”‚̌ďo‚µ
496.endif
497
498 clrpsw i ; ‚±‚±‚©‚ç‚Í•K‚¸Š„ž‚Ý‹ÖŽ~
499 mov.l #__kernel_intnest, r5
500 mov.w [r5], r4
501 sub #1, r4 ; ƒlƒXƒg‰ñ”‚ðƒfƒNƒŠƒƒ“ƒg
502 mov.w r4, [r5]
503 cmp #0, r4 ; ‘½dŠ„‚荞‚Ý‚©‚Ç‚¤‚©
504 bnz exception_return ; ‘½dŠ„‚荞‚݂Ȃ烊ƒ^[ƒ“
505 ; ‰’i‚ÌŠ„ž‚Ý
506 mov.l #__kernel_reqflg, r5 ; ƒfƒBƒXƒpƒbƒ`—v‹‚ª‚È‚¢‚©?
507 mov.l [r5], r5
508 cmp #1, r5
509 bnz exception_return ; ‚È‚¯‚ê‚΃Šƒ^[ƒ“
510 add #EXCINF_REG_SIZE, r0 ; CPU—áŠOî•ñ‚Ì”jŠü
511 bra ret_int ; ‚ ‚ê‚Î ret_int ‚ÖƒWƒƒƒ“ƒv
512
513exception_nonkernel:
514 mov.l #__kernel_intnest, r5
515 mov.w [r5], r4
516 add #1, r4 ; ƒlƒXƒg‰ñ”‚ðƒCƒ“ƒNƒŠƒƒ“ƒg
517 mov.w r4, [r5]
518 cmp #1, r4 ; ‘½dŠ„‚荞‚Ý‚©‚Ç‚¤‚©
519 bnz exception_from_nonkernelint ; ‰ÁŽZ‘O‚ª0‚Å‚È‚¯‚ê‚Α½dŠ„ž‚Ý
520 ; ‰’i‚ÌŠ„ž‚Ý
521 mov.l #__kernel_istkpt, r5 ; Š„ž‚Ý—p‚̃Xƒ^ƒbƒN‚֐ؑւ¦‚é
522 mov.l [r5], r0
523 push.l r3 ; ƒ^ƒXƒNƒXƒ^ƒbƒN‚ð•ÛŽ
524exception_from_nonkernelint: ; ‘½dŠ„ž‚Ý
525 mov.l EXC_GET_PSW_OFFSET[r3], r5
526 mvtc r5, psw ; CPU—áŠO”­¶‘O‚̏ó‘Ô‚É–ß‚·
527
528 mov.l r3, r1 ; ˆø”‚Ìp_excinf‚ðÝ’è
529 jsr r2 ; Cƒ‹[ƒ`ƒ“ŒÄ‚яo‚µ
530
531 clrpsw i ; ‚±‚±‚©‚ç‚Í•K‚¸Š„ž‚Ý‹ÖŽ~
532 mov.l #__kernel_intnest, r5
533 mov.w [r5], r4
534 sub #1, r4 ; ƒlƒXƒg‰ñ”‚ðƒfƒNƒŠƒƒ“ƒg
535 mov.w r4, [r5]
536 cmp #0, r4 ; ‘½dŠ„‚荞‚Ý‚©‚Ç‚¤‚©
537 bnz exception_return ; ‘½dŠ„‚荞‚݂Ȃ烊ƒ^[ƒ“
538 ; ‰’i‚ÌŠ„ž‚Ý
539 pop r0 ; ƒ^ƒXƒN‚̃Xƒ^ƒbƒN‚É–ß‚·
540
541exception_return:
542 add #EXCINF_REG_SIZE, r0 ; CPU—áŠOî•ñ‚Ì”jŠü
543 popm r4-r5 ; ƒAƒLƒ…
544ƒ€ƒŒ[ƒ^•œ‹A
545 mvtaclo r5 ; ACCÅ‰ºˆÊ16bit‚Í0‚Å•œ‹A
546 mvtachi r4
547 popc fpsw ; FPUƒXƒe[ƒ^ƒXƒŒƒWƒXƒ^•œ‹A
548 popm r14-r15 ; ƒŒƒWƒXƒ^•œ‹A
549 popm r1-r5
550 rte ; Š„ž‚Ý‘O‚̏ˆ—‚É–ß‚é
551
552
553;
554; ”÷­ŽžŠÔ‘Ò‚¿
555;
556_sil_dly_nse:
557 mov.l #SIL_DLY_TIM1, r5
558 sub r5, r1
559 ble sil_dly_nse_ret
560sil_dly_nse_loop:
561 mov.l #SIL_DLY_TIM2, r5
562 sub r5, r1
563 bgt sil_dly_nse_loop
564sil_dly_nse_ret:
565 rts
566
567 .end
568
Note: See TracBrowser for help on using the repository browser.