1 |
|
* |
2 |
|
* asm_support.asm - AmigaOS utility functions in assembly language |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-1999 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2002 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
28 |
|
XDEF _AtomicAnd |
29 |
|
XDEF _AtomicOr |
30 |
|
XDEF _MoveVBR |
31 |
+ |
XDEF _DisableSuperBypass |
32 |
|
XDEF _Execute68k |
33 |
|
XDEF _Execute68kTrap |
34 |
|
XDEF _TrapHandlerAsm |
35 |
|
XDEF _ExceptionHandlerAsm |
35 |
– |
XDEF _Scod060Patch1 |
36 |
– |
XDEF _Scod060Patch2 |
37 |
– |
XDEF _ThInitFPUPatch |
36 |
|
XDEF _AsmTriggerNMI |
37 |
|
|
38 |
|
XREF _OldTrapHandler |
48 |
|
|
49 |
|
SECTION text,CODE |
50 |
|
|
51 |
+ |
MACHINE 68020 |
52 |
+ |
|
53 |
|
* |
54 |
|
* Atomic bit operations (don't trust the compiler) |
55 |
|
* |
107 |
|
rte |
108 |
|
|
109 |
|
* |
110 |
+ |
* Disable 68060 Super Bypass mode |
111 |
+ |
* |
112 |
+ |
|
113 |
+ |
_DisableSuperBypass |
114 |
+ |
movem.l d0-d1/a0-a1/a5-a6,-(sp) |
115 |
+ |
move.l _SysBase,a6 |
116 |
+ |
|
117 |
+ |
lea dissb,a5 |
118 |
+ |
JSRLIB Supervisor |
119 |
+ |
|
120 |
+ |
movem.l (sp)+,d0-d1/a0-a1/a5-a6 |
121 |
+ |
rts |
122 |
+ |
|
123 |
+ |
MACHINE 68060 |
124 |
+ |
|
125 |
+ |
dissb movec pcr,d0 |
126 |
+ |
bset #5,d0 |
127 |
+ |
movec d0,pcr |
128 |
+ |
rte |
129 |
+ |
|
130 |
+ |
MACHINE 68020 |
131 |
+ |
|
132 |
+ |
* |
133 |
|
* Execute 68k subroutine (must be ended with rts) |
134 |
|
* r->a[7] and r->sr are unused! |
135 |
|
* |
241 |
|
rts |
242 |
|
|
243 |
|
* |
221 |
– |
* Process Manager 68060 FPU patches |
222 |
– |
* |
223 |
– |
|
224 |
– |
_Scod060Patch1 fsave -(sp) ;Save FPU state |
225 |
– |
tst.b 2(sp) ;Null? |
226 |
– |
beq.s 1$ |
227 |
– |
fmovem.x fp0-fp7,-(sp) ;No, save FPU registers |
228 |
– |
fmove.l fpiar,-(sp) |
229 |
– |
fmove.l fpsr,-(sp) |
230 |
– |
fmove.l fpcr,-(sp) |
231 |
– |
pea -1 ;Push "FPU state saved" flag |
232 |
– |
1$ move.l d1,-(sp) |
233 |
– |
move.l d0,-(sp) |
234 |
– |
bsr.s 3$ ;Switch integer registers and stack |
235 |
– |
addq.l #8,sp |
236 |
– |
tst.b 2(sp) ;New FPU state null or "FPU state saved" flag set? |
237 |
– |
beq.s 2$ |
238 |
– |
addq.l #4,sp ;Flag set, skip it |
239 |
– |
fmove.l (sp)+,fpcr ;Restore FPU registers and state |
240 |
– |
fmove.l (sp)+,fpsr |
241 |
– |
fmove.l (sp)+,fpiar |
242 |
– |
fmovem.x (sp)+,fp0-fp7 |
243 |
– |
2$ frestore (sp)+ |
244 |
– |
movem.l (sp)+,d0-d1 |
245 |
– |
rts |
246 |
– |
|
247 |
– |
3$ move.l 4(sp),a0 ;Switch integer registers and stack |
248 |
– |
move sr,-(sp) |
249 |
– |
movem.l d2-d7/a2-a6,-(sp) |
250 |
– |
cmp.w #0,a0 |
251 |
– |
beq.s 4$ |
252 |
– |
move.l sp,(a0) |
253 |
– |
4$ move.l $36(sp),a0 |
254 |
– |
movem.l (a0)+,d2-d7/a2-a6 |
255 |
– |
move (a0)+,sr |
256 |
– |
move.l a0,sp |
257 |
– |
rts |
258 |
– |
|
259 |
– |
_Scod060Patch2 move.l d0,-(sp) ;Create 68060 null frame on stack |
260 |
– |
move.l d0,-(sp) |
261 |
– |
move.l d0,-(sp) |
262 |
– |
frestore (sp)+ ;and load it |
263 |
– |
rts |
264 |
– |
|
265 |
– |
* |
266 |
– |
* Thread Manager 68060 FPU patches |
267 |
– |
* |
268 |
– |
|
269 |
– |
_ThInitFPUPatch tst.b $40(a4) |
270 |
– |
bne.s 1$ |
271 |
– |
moveq #0,d0 ;Create 68060 null frame on stack |
272 |
– |
move.l d0,-(a3) |
273 |
– |
move.l d0,-(a3) |
274 |
– |
move.l d0,-(a3) |
275 |
– |
1$ rts |
276 |
– |
|
277 |
– |
* |
244 |
|
* Trap handler of main task |
245 |
|
* |
246 |
|
|
316 |
|
addq.l #8,sp ;Remove exception frame from supervisor stack |
317 |
|
andi #$d8ff,sr ;Switch to user mode, enable interrupts |
318 |
|
|
319 |
+ |
and.w #$d8ff,_EmulatedSR ;enable interrupts in EmulatedSR |
320 |
+ |
|
321 |
|
move.l $28.w,-(sp) ;Jump to MacOS exception handler |
322 |
|
rts |
323 |
|
|
637 |
|
fsavepush move.l (sp),d0 ;Restore d0 |
638 |
|
move.l a0,(sp) ;Save a0 |
639 |
|
move.l usp,a0 ;Get user stack pointer |
640 |
< |
fsave -(a0) ;Push FP state |
640 |
> |
move.l #$41000000,-(a0) ;Push idle frame |
641 |
|
move.l a0,usp ;Update USP |
642 |
|
move.l (sp)+,a0 ;Restore a0 |
643 |
|
addq.l #2,2(sp) ;Skip instruction |
644 |
|
rte |
645 |
|
|
646 |
+ |
; fsave xxx(a5) |
647 |
+ |
fsavea5 move.l (sp),d0 ;Restore d0 |
648 |
+ |
move.l a0,(sp) ;Save a0 |
649 |
+ |
move.l a5,a0 ;Get base register |
650 |
+ |
add.w ([6,sp],2),a0 ;Add offset to base register |
651 |
+ |
move.l #$41000000,(a0) ;Push idle frame |
652 |
+ |
move.l (sp)+,a0 ;Restore a0 |
653 |
+ |
addq.l #4,2(sp) ;Skip instruction |
654 |
+ |
rte |
655 |
+ |
|
656 |
|
; frestore (sp)+ |
657 |
|
frestorepop move.l (sp),d0 ;Restore d0 |
658 |
|
move.l a0,(sp) ;Save a0 |
659 |
|
move.l usp,a0 ;Get user stack pointer |
660 |
< |
frestore (a0)+ ;Restore FP state |
660 |
> |
addq.l #4,a0 ;Nothing to do... |
661 |
|
move.l a0,usp ;Update USP |
662 |
|
move.l (sp)+,a0 ;Restore a0 |
663 |
|
addq.l #2,2(sp) ;Skip instruction |
664 |
|
rte |
665 |
|
|
666 |
< |
; frestore xxx(a5) +jl+ |
666 |
> |
; frestore xxx(a5) |
667 |
|
frestorea5 move.l (sp),d0 ;Restore d0 |
668 |
|
move.l a0,(sp) ;Save a0 |
691 |
– |
move.l a5,a0 ;Get base register |
692 |
– |
add.w ([6,sp],2),a0 ;Add offset to base register |
693 |
– |
frestore (a0) ;Restore FP state from (a0) |
694 |
– |
move.l (sp)+,a0 ;Restore a0 |
695 |
– |
addq.l #4,2(sp) ;Skip instruction |
696 |
– |
rte |
697 |
– |
|
698 |
– |
; fsave xxx(a5) +jl+ |
699 |
– |
fsavea5 move.l (sp),d0 ;Restore d0 |
700 |
– |
move.l a0,(sp) ;Save a0 |
701 |
– |
move.l a5,a0 ;Get base register |
702 |
– |
add.w ([6,sp],2),a0 ;Add offset to base register |
703 |
– |
fsave (a0) ;Push FP state to (a0) |
669 |
|
move.l (sp)+,a0 ;Restore a0 |
670 |
|
addq.l #4,2(sp) ;Skip instruction |
671 |
|
rte |