From: Toni Wilen Date: Sat, 28 Sep 2019 08:15:16 +0000 (+0300) Subject: Atari ST port. X-Git-Tag: 4300~98 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=4235e29b99347275f8889f1ae19a35f26826afac;p=francis%2Fwinuae.git Atari ST port. --- diff --git a/cputest/amiga.S b/cputest/amiga.S index 488e0096..a088abd1 100644 --- a/cputest/amiga.S +++ b/cputest/amiga.S @@ -1,6 +1,8 @@ .text + .equ ACTIVITYREG,0xdff180 + .globl _allocate_absolute .globl _free_absolute .globl _touser @@ -99,3 +101,5 @@ illg: move.l d1,0x10(a0) move.l a1,sp rte + + .include "asm.S" diff --git a/cputest/asm.S b/cputest/asm.S index 8fa532b0..022dcf3c 100644 --- a/cputest/asm.S +++ b/cputest/asm.S @@ -119,7 +119,7 @@ _execute_test000: move.w (a1)+,d0 move.w (a1),d1 eor.w d1,d0 - move.w d0,0xdff180 | opcode^first param = background color + move.w d0,ACTIVITYREG | opcode^first param = background color move.w S_SR+2(a0),-(sp) move.l S_AREG+7*4(a0),a1 move.l a1,USP @@ -141,7 +141,7 @@ _execute_test010: move.w (a1)+,d0 move.w (a1),d1 eor.w d1,d0 - move.w d0,0xdff180 | opcode^first param = background color + move.w d0,ACTIVITYREG | opcode^first param = background color move.w S_SR+2(a0),-(sp) move.l S_AREG+7*4(a0),a1 move.l a1,USP @@ -163,7 +163,7 @@ _execute_test020: move.w (a1)+,d0 move.w (a1),d1 eor.w d1,d0 - move.w d0,0xdff180 | opcode^first param = background color + move.w d0,ACTIVITYREG | opcode^first param = background color move.w S_SR+2(a0),-(sp) move.l S_AREG+7*4(a0),a1 move.l a1,USP @@ -190,7 +190,7 @@ _execute_testfpu: move.w (a1)+,d0 move.w (a1),d1 eor.w d1,d0 - move.w d0,0xdff180 | opcode^first param = background color + move.w d0,ACTIVITYREG | opcode^first param = background color move.w S_SR+2(a0),-(sp) move.l S_AREG+7*4(a0),a1 move.l a1,USP diff --git a/cputest/atari.S b/cputest/atari.S new file mode 100644 index 00000000..e2871f01 --- /dev/null +++ b/cputest/atari.S @@ -0,0 +1,147 @@ +| cputester's machine specific support for Atari's STF/STE/TT/Falcon +| +| 2019/09 Nicolas Pomarede + + .text + + .equ ACTIVITYREG,0xff8240 + + .globl _allocate_absolute + .globl _free_absolute + .globl _touser + .globl _tosuper + .globl _testexit + .globl _get_cpu_model + + | check "space" key is pressed +_testexit: + moveq #0,d0 + cmp.b #0x39,0xfffc02 + bne.s .done + moveq #1,d0 +.done: + | d0 != 0: -> exit + rts + + | super mode, disable MFP interrupts + | save hbl and vbl vectors and set them to a 'RTE' +_tosuper: + move.l #0,-(sp) + move.w #0x20,-(sp) + trap #1 + addq.l #6,sp + move.l d0,old_ssp + + move.l 0x68,save_hbl + move.l 0x70,save_vbl + move.l #int_rte,0x68 + move.l #int_rte,0x70 + + move.b 0xfffa13,save_imra + move.b 0xfffa15,save_imrb + clr.b 0xfffa13 + clr.b 0xfffa15 + + move.w 0xff8240,save_color0 + + move.w #0x2500,sr | disable HBL/VBL + rts + + | back to user mode, enable MFP interrupts + | and restore hbl/vbl vectors + | keep the value of A7/SSP into USP +_touser: + move.w save_color0,0xff8240 + + move.b save_imra,0xfffa13 + move.b save_imrb,0xfffa15 + + move.l save_hbl,0x68 + move.l save_vbl,0x70 + + move.l old_ssp(pc),-(sp) + move.w #0x20,-(sp) + | we must keep the same value of A7 when going back to user mode + | else the main C program will crash later + move.l a7,usp + trap #1 + addq.l #6,sp + rts + + | free absolute allocated test memory + | -> not supported for now +_free_absolute: + rts + + | allocate absolute memory + | -> not supported by TOS, assume memory can always be used + | (requires 4 MB RAM) + | in : 4(sp) absolute memory address to allocate + | in : 8(sp) size of absolute memory address to allocate + | out : d0=absolute memory address if success, or 0 if error +_allocate_absolute: + move.l 4(sp),d0 | success + rts + + | return CPU model (68000=0, 68010=1, 68020=2, 68030=3, 68040=4, 68060=5) + | we read TOS' cookie jar at $5A0, or return 0 it cpu is not found +_get_cpu_model: + move.l #0,-(sp) + move.w #0x20,-(sp) + trap #1 + addq.l #6,sp + move.l d0,old_ssp + + move.q #0,d0 + move.l 0x5a0,d1 + beq.s .cpudone | no cookie jar, assume 68000 + + move.l d1,a0 +.loop: + move.l (a0),d0 + beq.s .cpudone | end of cookie list, assume 68000 + cmp.l #0x5f435055,d0 | '_CPU' + beq.s .found + addq.w #8,a0 | next cookie + bra.s .loop +.found: + move.l 4(a0),d0 | _CPU value : 0, 10, 20, 30, 40 or 60 + divu #10,d0 + ext.l d0 + cmp.w #6,d0 + bne.s .cpudone + moveq #5,d0 | 68060 -> d0=5 + +.cpudone: + move.l d0,cpu_level + + move.l old_ssp(pc),-(sp) + move.w #0x20,-(sp) + trap #1 + addq.l #6,sp + + move.l cpu_level,d0 + rts + + + | empty interrupt function to replace TOS' HBL/VBL +int_rte: + rte + + +old_ssp: + dc.l 0 +save_hbl: + dc.l 0 +save_vbl: + dc.l 0 +save_imra: + dc.b 0 +save_imrb: + dc.b 0 +save_color0: + dc.w 0 +cpu_level: + dc.l 0 + + .include "asm.S" diff --git a/cputest/makefile b/cputest/makefile index 67c5f999..7f364f04 100644 --- a/cputest/makefile +++ b/cputest/makefile @@ -8,7 +8,7 @@ AS=/opt/amiga/bin/m68k-amigaos-as CFLAGS = -mcrt=nix13 -O2 -m68000 -fomit-frame-pointer -msmall-code -msoft-float -DREVDATE=$(NOWDATE) -DREVTIME=$(NOWTIME) -DAMIGA -DM68K LINK_CFLAGS = -mcrt=nix13 -lm -s -OBJS = main.o asm.o asm040.o amiga.o \ +OBJS = main.o asm040.o amiga.o \ decode_ea.o globals.o opcode_handler_cpu.o opcode_handler_fpu.o \ opcode_handler_mmu.o opcodes_cpu.o opcodes_fpu.o opcodes_mmu.o util.o @@ -45,9 +45,6 @@ opcodes_mmu.o: adis/opcodes_mmu.c util.o: adis/util.c $(CC) $(CFLAGS) -I. -c -o $@ adis/util.c -asm.o: asm.S - $(AS) -m68020 -o $@ asm.S - asm040.o: asm040.S $(AS) -m68020 -o $@ asm040.S diff --git a/cputest/makefile.st b/cputest/makefile.st new file mode 100644 index 00000000..141aa0f1 --- /dev/null +++ b/cputest/makefile.st @@ -0,0 +1,52 @@ + +NOWDATE := "\"$(shell date "+%-d.%-m.%Y")\"" +NOWTIME := "\"$(shell date "+%T")\"" + +CC=/opt/m68k-atari/bin/m68k-atari-mint-gcc +AS=/opt/m68k-atari/bin/m68k-atari-mint-as + +CFLAGS = -O2 -m68000 -fomit-frame-pointer -msoft-float -DREVDATE=$(NOWDATE) -DREVTIME=$(NOWTIME) -DM68K +LINK_CFLAGS = -lm -s + +OBJS = main.o asm040.o atari.o \ + decode_ea.o globals.o opcode_handler_cpu.o opcode_handler_fpu.o \ + opcode_handler_mmu.o opcodes_cpu.o opcodes_fpu.o opcodes_mmu.o util.o + +all: $(OBJS) + $(CC) $(LINK_CFLAGS) -o cputest $^ + +main.o: main.c + $(CC) $(CFLAGS) -I. -c -o $@ main.c + +decode_ea.o: adis/decode_ea.c + $(CC) $(CFLAGS) -I. -c -o $@ adis/decode_ea.c + +globals.o: adis/globals.c + $(CC) $(CFLAGS) -I. -c -o $@ adis/globals.c + +opcode_handler_cpu.o: adis/opcode_handler_cpu.c + $(CC) $(CFLAGS) -I. -c -o $@ adis/opcode_handler_cpu.c + +opcode_handler_fpu.o: adis/opcode_handler_fpu.c + $(CC) $(CFLAGS) -I. -c -o $@ adis/opcode_handler_fpu.c + +opcode_handler_mmu.o: adis/opcode_handler_mmu.c + $(CC) $(CFLAGS) -I. -c -o $@ adis/opcode_handler_mmu.c + +opcodes_cpu.o: adis/opcodes_cpu.c + $(CC) $(CFLAGS) -I. -c -o $@ adis/opcodes_cpu.c + +opcodes_fpu.o: adis/opcodes_fpu.c + $(CC) $(CFLAGS) -I. -c -o $@ adis/opcodes_fpu.c + +opcodes_mmu.o: adis/opcodes_mmu.c + $(CC) $(CFLAGS) -I. -c -o $@ adis/opcodes_mmu.c + +util.o: adis/util.c + $(CC) $(CFLAGS) -I. -c -o $@ adis/util.c + +asm040.o: asm040.S + $(AS) -m68020 -o $@ asm040.S + +atari.o: atari.S + $(AS) -m68020 -o $@ atari.S