--- BasiliskII/src/AmigaOS/asm_support.asm 2000/10/11 17:55:05 1.6 +++ BasiliskII/src/AmigaOS/asm_support.asm 2002/01/15 14:58:34 1.12 @@ -1,7 +1,7 @@ * * asm_support.asm - AmigaOS utility functions in assembly language * -* Basilisk II (C) 1997-1999 Christian Bauer +* Basilisk II (C) 1997-2002 Christian Bauer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,13 +28,11 @@ XDEF _AtomicAnd XDEF _AtomicOr XDEF _MoveVBR + XDEF _DisableSuperBypass XDEF _Execute68k XDEF _Execute68kTrap XDEF _TrapHandlerAsm XDEF _ExceptionHandlerAsm - XDEF _Scod060Patch1 - XDEF _Scod060Patch2 - XDEF _ThInitFPUPatch XDEF _AsmTriggerNMI XREF _OldTrapHandler @@ -47,10 +45,11 @@ XREF _MainTask XREF _SysBase XREF _quit_emulator - XREF _kprintf SECTION text,CODE + MACHINE 68020 + * * Atomic bit operations (don't trust the compiler) * @@ -108,6 +107,29 @@ setvbr movec d0,vbr rte * +* Disable 68060 Super Bypass mode +* + +_DisableSuperBypass + movem.l d0-d1/a0-a1/a5-a6,-(sp) + move.l _SysBase,a6 + + lea dissb,a5 + JSRLIB Supervisor + + movem.l (sp)+,d0-d1/a0-a1/a5-a6 + rts + + MACHINE 68060 + +dissb movec pcr,d0 + bset #5,d0 + movec d0,pcr + rte + + MACHINE 68020 + +* * Execute 68k subroutine (must be ended with rts) * r->a[7] and r->sr are unused! * @@ -219,63 +241,6 @@ _ExceptionHandlerAsm rts * -* Process Manager 68060 FPU patches -* - -_Scod060Patch1 fsave -(sp) ;Save FPU state - tst.b 2(sp) ;Null? - beq.s 1$ - fmovem.x fp0-fp7,-(sp) ;No, save FPU registers - fmove.l fpiar,-(sp) - fmove.l fpsr,-(sp) - fmove.l fpcr,-(sp) - pea -1 ;Push "FPU state saved" flag -1$ move.l d1,-(sp) - move.l d0,-(sp) - bsr.s 3$ ;Switch integer registers and stack - addq.l #8,sp - tst.b 2(sp) ;New FPU state null or "FPU state saved" flag set? - beq.s 2$ - addq.l #4,sp ;Flag set, skip it - fmove.l (sp)+,fpcr ;Restore FPU registers and state - fmove.l (sp)+,fpsr - fmove.l (sp)+,fpiar - fmovem.x (sp)+,fp0-fp7 -2$ frestore (sp)+ - movem.l (sp)+,d0-d1 - rts - -3$ move.l 4(sp),a0 ;Switch integer registers and stack - move sr,-(sp) - movem.l d2-d7/a2-a6,-(sp) - cmp.w #0,a0 - beq.s 4$ - move.l sp,(a0) -4$ move.l $36(sp),a0 - movem.l (a0)+,d2-d7/a2-a6 - move (a0)+,sr - move.l a0,sp - rts - -_Scod060Patch2 move.l d0,-(sp) ;Create 68060 null frame on stack - move.l d0,-(sp) - move.l d0,-(sp) - frestore (sp)+ ;and load it - rts - -* -* Thread Manager 68060 FPU patches -* - -_ThInitFPUPatch tst.b $40(a4) - bne.s 1$ - moveq #0,d0 ;Create 68060 null frame on stack - move.l d0,-(a3) - move.l d0,-(a3) - move.l d0,-(a3) -1$ rts - -* * Trap handler of main task * @@ -296,14 +261,14 @@ _TrapHandlerAsm: cmp.l #47,(sp) ble doTrapXX ; Vector 32-47 : TRAP #0 - 15 Instruction Vectors -1$: move.l _OldTrapHandler,-(sp) ;No, jump to old trap handler +1$ move.l _OldTrapHandler,-(sp) ;No, jump to old trap handler rts * * TRAP #0 - 15 Instruction Vectors * -doTrapXX: move.l a0,(sp) ;Save a0 +doTrapXX move.l a0,(sp) ;Save a0 move.l usp,a0 ;Get user stack pointer move.l 2*4(sp),-(a0) ;Copy 4-word stack frame to user stack move.l 1*4(sp),-(a0) @@ -321,7 +286,7 @@ doTrapXX: move.l a0,(sp) ;Save a0 * trace Vector * -dotrace: move.l a0,(sp) ;Save a0 +dotrace move.l a0,(sp) ;Save a0 move.l usp,a0 ;Get user stack pointer move.l 3*4(sp),-(a0) ;Copy 6-word stack frame to user stack @@ -351,32 +316,16 @@ doaline move.l a0,(sp) ;Save a0 addq.l #8,sp ;Remove exception frame from supervisor stack andi #$d8ff,sr ;Switch to user mode, enable interrupts - IFNE 0 - -; move.w ([2,sp]),($3800) - - cmp.w #$a9c3,([2,sp]) - bne 1$ - - move.l d0,-(sp) - move.l a0,-(sp) - pea afmt(pc) - jsr _kprintf - lea 3*4(sp),sp -1$: - ENDC + and.w #$d8ff,_EmulatedSR ;enable interrupts in EmulatedSR move.l $28.w,-(sp) ;Jump to MacOS exception handler rts -afmt: dc.b 'a0=%08lx d0=%08lx\n',0 - cnop 0,4 - * * Illegal address handler * -doilladdr: move.l a0,(sp) ;Save a0 +doilladdr move.l a0,(sp) ;Save a0 move.l usp,a0 ;Get user stack pointer move.l 3*4(sp),-(a0) ;Copy 6-word stack frame to user stack @@ -397,8 +346,7 @@ doilladdr: move.l a0,(sp) ;Save a0 * to execute extended opcodes (see emul_op.h) * -doillinstr - movem.l a0/d0,-(sp) +doillinstr movem.l a0/d0,-(sp) move.w ([6+2*4,sp]),d0 and.w #$ff00,d0 cmp.w #$7100,d0 @@ -418,8 +366,7 @@ doillinstr move.l $10.w,-(sp) ;Jump to MacOS exception handler rts -1$: - move.l a6,(sp) ;Save a6 +1$ move.l a6,(sp) ;Save a6 move.l usp,a6 ;Get user stack pointer move.l a6,-10(a6) ;Push USP (a7) @@ -690,38 +637,35 @@ movefromsrsp move.l a0,-(sp) ;Save a0 fsavepush move.l (sp),d0 ;Restore d0 move.l a0,(sp) ;Save a0 move.l usp,a0 ;Get user stack pointer - fsave -(a0) ;Push FP state + move.l #$41000000,-(a0) ;Push idle frame move.l a0,usp ;Update USP move.l (sp)+,a0 ;Restore a0 addq.l #2,2(sp) ;Skip instruction rte +; fsave xxx(a5) +fsavea5 move.l (sp),d0 ;Restore d0 + move.l a0,(sp) ;Save a0 + move.l a5,a0 ;Get base register + add.w ([6,sp],2),a0 ;Add offset to base register + move.l #$41000000,(a0) ;Push idle frame + move.l (sp)+,a0 ;Restore a0 + addq.l #4,2(sp) ;Skip instruction + rte + ; frestore (sp)+ frestorepop move.l (sp),d0 ;Restore d0 move.l a0,(sp) ;Save a0 move.l usp,a0 ;Get user stack pointer - frestore (a0)+ ;Restore FP state + addq.l #4,a0 ;Nothing to do... move.l a0,usp ;Update USP move.l (sp)+,a0 ;Restore a0 addq.l #2,2(sp) ;Skip instruction rte -; frestore xxx(a5) +jl+ +; frestore xxx(a5) frestorea5 move.l (sp),d0 ;Restore d0 move.l a0,(sp) ;Save a0 - move.l a5,a0 ;Get base register - add.w ([6,sp],2),a0 ;Add offset to base register - frestore (a0) ;Restore FP state from (a0) - move.l (sp)+,a0 ;Restore a0 - addq.l #4,2(sp) ;Skip instruction - rte - -; fsave xxx(a5) +jl+ -fsavea5: move.l (sp),d0 ;Restore d0 - move.l a0,(sp) ;Save a0 - move.l a5,a0 ;Get base register - add.w ([6,sp],2),a0 ;Add offset to base register - fsave (a0) ;Push FP state to (a0) move.l (sp)+,a0 ;Restore a0 addq.l #4,2(sp) ;Skip instruction rte @@ -746,8 +690,8 @@ pvrte movem.l a0/a1,-(sp) ;Save a0 and lea 16+4(sp),a1 ; destination address (in supervisor stack) bra 1$ -2$: move.w (a0)+,(a1)+ ; copy additional stack words back to supervisor stack -1$: dbf d0,2$ +2$ move.w (a0)+,(a1)+ ; copy additional stack words back to supervisor stack +1$ dbf d0,2$ move.l a0,usp ;Update USP movem.l (sp)+,a0/a1 ;Restore a0 and a1 @@ -951,23 +895,23 @@ movectcd1 move.l (sp)+,d0 ;Restore d0 rte ; movec sfc,d1 +jl+ -movecsfcd1: move.l (sp)+,d0 ;Restore d0 +movecsfcd1 move.l (sp)+,d0 ;Restore d0 moveq #0,d1 addq.l #4,2(sp) rte ; movec dfc,d1 +jl+ -movecdfcd1: move.l (sp)+,d0 ;Restore d0 +movecdfcd1 move.l (sp)+,d0 ;Restore d0 moveq #0,d1 addq.l #4,2(sp) rte -movecurpd0: ; movec urp,d0 +jl+ -movecsrpd0: ; movec srp,d0 -movecitt0d0: ; movec itt0,d0 -movecitt1d0: ; movec itt1,d0 -movecdtt0d0: ; movec dtt0,d0 -movecdtt1d0: ; movec dtt1,d0 +movecurpd0 ; movec urp,d0 +jl+ +movecsrpd0 ; movec srp,d0 +movecitt0d0 ; movec itt0,d0 +movecitt1d0 ; movec itt1,d0 +movecdtt0d0 ; movec dtt0,d0 +movecdtt1d0 ; movec dtt1,d0 addq.l #4,sp moveq.l #0,d0 ;MMU is always off addq.l #4,2(sp) ;skip instruction @@ -1022,19 +966,19 @@ cpushadcic movem.l d1/a0-a1/a6,-(sp) ;Cl rte ; move usp,a1 +jl+ -moveuspa1: move.l (sp)+,d0 +moveuspa1 move.l (sp)+,d0 move usp,a1 addq.l #2,2(sp) rte ; move usp,a0 +jl+ -moveuspa0: move.l (sp)+,d0 +moveuspa0 move.l (sp)+,d0 move usp,a0 addq.l #2,2(sp) rte ; move a1,usp +jl+ -moved1usp: move.l (sp)+,d0 +moved1usp move.l (sp)+,d0 move a1,usp addq.l #2,2(sp) rte @@ -1043,8 +987,7 @@ moved1usp: move.l (sp)+,d0 ; Trigger NMI (Pop up debugger) ; -_AsmTriggerNMI: - move.l d0,-(sp) ;Save d0 +_AsmTriggerNMI move.l d0,-(sp) ;Save d0 move.w #$007c,-(sp) ;Yes, fake NMI stack frame pea 1$ move.w _EmulatedSR,d0