From: notaz Date: Wed, 29 Nov 2017 00:33:27 +0000 (+0200) Subject: more 32x tests X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=06d7984c0110c58104633dc4359fa7a8343bac11;p=megadrive.git more 32x tests --- diff --git a/testpico/asmtools.S b/testpico/asmtools.S index d6b9091..af34b41 100644 --- a/testpico/asmtools.S +++ b/testpico/asmtools.S @@ -244,6 +244,16 @@ x32x_enable: .global x32x_enable_end x32x_enable_end: +.global test_32x_b_c0 +test_32x_b_c0: + ldarg 0, 0, a1 + ldargw 1, 0, d0 + jsr (0xc0).l /* move.b d0, (a1); RV=0 */ + bset #0, (0xa15107).l + rts +.global test_32x_b_c0_end +test_32x_b_c0_end: + # some nastyness from Fatal Rewind .global test_h_v_2 test_h_v_2: diff --git a/testpico/asmtools.h b/testpico/asmtools.h index 10cd059..5b53023 100644 --- a/testpico/asmtools.h +++ b/testpico/asmtools.h @@ -32,3 +32,5 @@ extern const char test_f_vint[]; extern const char test_f_vint_end[]; extern const char x32x_enable[]; extern const char x32x_enable_end[]; +extern const char test_32x_b_c0[]; +extern const char test_32x_b_c0_end[]; diff --git a/testpico/common.h b/testpico/common.h index 944e7e4..e65c6d0 100644 --- a/testpico/common.h +++ b/testpico/common.h @@ -29,6 +29,12 @@ enum x32x_cmd { CMD_ECHO = 1, CMD_READ_FRT = 2, // read Free-Running Timer + CMD_READ8 = 3, + CMD_READ16 = 4, + CMD_READ32 = 5, + CMD_WRITE8 = 6, + CMD_WRITE16 = 7, + CMD_WRITE32 = 8, }; // vim:ts=4:sw=4:expandtab diff --git a/testpico/main.c b/testpico/main.c index c51181f..81ae471 100644 --- a/testpico/main.c +++ b/testpico/main.c @@ -1547,22 +1547,34 @@ static int t_32x_init(void) while (!read16(&r16[0x24/2])) ; expect(ok, r[0x24/4], S_OK); + write32(&r[0x20/4], 0); return ok; } -static void x32_cmd(enum x32x_cmd cmd, u16 is_slave) +static void x32_cmd(enum x32x_cmd cmd, u32 a0, u32 a1, u16 is_slave) { u16 v, *r = (u16 *)0xa15120; u16 cmd_s = cmd | (is_slave << 15); int i; + + write32(&r[4/2], a0); + write32(&r[8/2], a1); + mem_barrier(); write16(r, cmd_s); mem_barrier(); for (i = 0; i < 10000 && (v = read16(r)) == cmd_s; i++) burn10(1); if (v != 0) { printf("cmd clr: %x\n", v); + mem_barrier(); + printf("c, e: %02x %02x\n", r[0x0c/2], r[0x0e/2]); write16(r, 0); } + v = read16(&r[1]); + if (v != 0) { + printf("cmd err: %x\n", v); + write16(&r[1], 0); + } } static int t_32x_echo(void) @@ -1570,15 +1582,27 @@ static int t_32x_echo(void) u16 *r = (u16 *)0xa15120; int ok = 1; - write16(&r[0x02/2], 0x1234); - x32_cmd(CMD_ECHO, 0); - expect(ok, r[0x04/2], 0x1234); - write16(&r[0x02/2], 0x2345); - write16(&r[0x04/2], 0); - x32_cmd(CMD_ECHO, 1); - expect(ok, r[0x04/2], 0xa345); - expect(ok, r[0x0c/2], 0); - expect(ok, r[0x0e/2], 0); + x32_cmd(CMD_ECHO, 0x12340000, 0, 0); + expect(ok, r[0x06/2], 0x1234); + x32_cmd(CMD_ECHO, 0x23450000, 0, 1); + expect(ok, r[0x06/2], 0xa345); + return ok; +} + +static int t_32x_md_bios(void) +{ + void (*do_call_c0)(int a, int d) = (void *)0xff0040; + u8 *rmb = (u8 *)0xff0000; + u32 *rl = (u32 *)0; + int ok = 1; + + memcpy_(do_call_c0, test_32x_b_c0, + test_32x_b_c0_end - test_32x_b_c0); + write8(rmb, 0); + do_call_c0(0xff0000, 0x5a); + + expect(ok, rmb[0], 0x5a); + expect(ok, rl[0x04/4], 0x880200); return ok; } @@ -1601,6 +1625,55 @@ static int t_32x_md_rom(void) return ok; } +static int t_32x_md_fb(void) +{ + u8 *fbb = (u8 *)0x840000; + u16 *fbw = (u16 *)fbb; + u32 *fbl = (u32 *)fbb; + u8 *fob = (u8 *)0x860000; + u16 *fow = (u16 *)fob; + u32 *fol = (u32 *)fob; + int ok = 1; + + fbl[0] = 0x12345678; + fol[1] = 0x89abcdef; + mem_barrier(); + expect(ok, fbw[1], 0x5678); + expect(ok, fow[2], 0x89ab); + fbb[0] = 0; + fob[1] = 0; + fbw[1] = 0; + fow[2] = 0; + fow[3] = 1; + mem_barrier(); + fow[3] = 0x200; + mem_barrier(); + expect(ok, fol[0], 0x12340000); + expect(ok, fbl[1], 0x89ab0201); + return ok; +} + +static int t_32x_sh_fb(void) +{ + u32 *fbl = (u32 *)0x840000; + int ok = 1; + + fbl[0] = 0x12345678; + fbl[1] = 0x89abcdef; + mem_barrier(); + write8(0xa15100, 0x80); // FM=1 + x32_cmd(CMD_WRITE8, 0x24000000, 0, 0); + x32_cmd(CMD_WRITE8, 0x24020001, 0, 0); + x32_cmd(CMD_WRITE16, 0x24000002, 0, 0); + x32_cmd(CMD_WRITE16, 0x24020000, 0, 0); + x32_cmd(CMD_WRITE32, 0x24020004, 0x5a0000a5, 1); + write8(0xa15100, 0x00); // FM=0 + mem_barrier(); + expect(ok, fbl[0], 0x12340000); + expect(ok, fbl[1], 0x5aabcda5); + return ok; +} + enum { T_MD = 0, T_32 = 1, // 32X @@ -1653,10 +1726,14 @@ static const struct { { T_MD, t_irq_f_flag_h40, "irq f flag h40" }, { T_MD, t_irq_f_flag_h32, "irq f flag h32" }, - // the first one enables 32X, so should be kept + // the first one enables 32X, so must be kept + // all tests assume RV=1 FM=0 { T_32, t_32x_init, "32x init" }, { T_32, t_32x_echo, "32x echo" }, - { T_32, t_32x_md_rom, "32x rom" }, + { T_32, t_32x_md_bios, "32x md bios" }, + { T_32, t_32x_md_rom, "32x md rom" }, + { T_32, t_32x_md_fb, "32x md fb" }, + { T_32, t_32x_sh_fb, "32x sh fb" }, }; static void setup_z80(void) diff --git a/testpico/sh2_main.c b/testpico/sh2_main.c index 9c84b46..97ecd3a 100644 --- a/testpico/sh2_main.c +++ b/testpico/sh2_main.c @@ -3,9 +3,62 @@ void spin(int loops); u16 read_frt(void); +static void do_cmd(u16 cmd, u16 r[6], u32 is_slave) +{ + u32 *rl = (u32 *)r; + u32 a, d; + u16 v; + + switch (cmd) + { + case CMD_ECHO: + v = read16(&r[4/2]) ^ (is_slave << 15); + write16(&r[6/2], v); + break; + case CMD_READ_FRT: + v = read_frt(); + write16(&r[4/2], v); + break; + case CMD_READ8: + a = read32(&rl[4/4]); + d = read8(a); + write32(&rl[4/4], d); + break; + case CMD_READ16: + a = read32(&rl[4/4]); + d = read16(a); + write32(&rl[4/4], d); + break; + case CMD_READ32: + a = read32(&rl[4/4]); + d = read32(a); + write32(&rl[4/4], d); + break; + case CMD_WRITE8: + a = read32(&rl[4/4]); + d = read32(&rl[8/4]); + write8(a, d); + break; + case CMD_WRITE16: + a = read32(&rl[4/4]); + d = read32(&rl[8/4]); + write16(a, d); + break; + case CMD_WRITE32: + a = read32(&rl[4/4]); + d = read32(&rl[8/4]); + write32(a, d); + break; + default: + r[2/2]++; // error + mem_barrier(); + break; + } +} + void main_c(u32 is_slave) { - u16 v, *r = (u16 *)0x20004000; + u16 *r = (u16 *)0x20004000; for (;;) { @@ -15,27 +68,15 @@ void main_c(u32 is_slave) cmd = read16(&r[0x20/2]); mem_barrier(); cmdr = read16(&r[0x20/2]); - if (cmd != cmdr // documented as "normal" case - || ((cmd & 0x8000) ^ (is_slave << 15))) { + if (cmd == 0 + || cmd != cmdr // documented as "normal" case + || ((cmd & 0x8000) ^ (is_slave << 15)) + || cmd == 0x4d5f) { // 'M_' from BIOS spin(64); continue; } cmd &= 0x7fff; - switch (cmd) - { - case 0: - case 0x4d5f: // 'M_' from BIOS - spin(64); - continue; - case CMD_ECHO: - v = read16(&r[0x22/2]) ^ (is_slave << 15); - write16(&r[0x24/2], v); - break; - case CMD_READ_FRT: - v = read_frt(); - write16(&r[0x24/2], v); - break; - } + do_cmd(cmd, &r[0x20/2], is_slave); write16(&r[0x20/2], 0); } }