From f46181db7800d36fbca5410f1702038365198095 Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 13 May 2020 03:43:02 +0200 Subject: [PATCH] Several fixes - the MR BIOS'es now work on the recompiler (thank you, port EBh!), so they have been moved out of the Dev branch. --- src/cpu_common/386_dynarec.c | 36 +++++++++++++++++++++++++++++------ src/cpu_common/cpu.h | 1 + src/include/86box/machine.h | 4 ---- src/io.c | 15 ++++++++++++--- src/machine/m_at_386dx_486.c | 2 -- src/machine/m_at_socket7_s7.c | 2 -- src/machine/machine_table.c | 6 ------ src/pit.c | 2 +- src/postcard.c | 4 ++++ src/win/Makefile.mingw | 20 ------------------- src/win/Makefile_ndr.mingw | 20 ------------------- 11 files changed, 48 insertions(+), 64 deletions(-) diff --git a/src/cpu_common/386_dynarec.c b/src/cpu_common/386_dynarec.c index 70df8e8a3..f341efab9 100644 --- a/src/cpu_common/386_dynarec.c +++ b/src/cpu_common/386_dynarec.c @@ -275,6 +275,15 @@ static void prefetch_flush() #ifdef USE_DYNAREC static int cycles_main = 0; +void update_tsc(int cycs) +{ + if (cycs > 0) { + tsc += cycs; + + if (TIMER_VAL_LESS_THAN_VAL(timer_target, (uint32_t)tsc)) + timer_process(); + } +} void exec386_dynarec(int cycs) { @@ -282,7 +291,9 @@ void exec386_dynarec(int cycs) uint32_t addr; int tempi; int cycdiff; - int oldcyc; + int oldcyc, oldtsc; + int oldcyc2; + int delta; uint32_t start_pc = 0; int cyc_period = cycs / 2000; /*5us*/ @@ -305,7 +316,8 @@ void exec386_dynarec(int cycs) cycdiff=0; #endif - oldcyc=cycles; + oldcyc = oldcyc2 = cycles; + oldtsc = tsc; if (!CACHE_ON()) /*Interpret block*/ { cpu_block_end = 0; @@ -699,8 +711,18 @@ void exec386_dynarec(int cycs) #endif } - cycdiff=oldcyc-cycles; - tsc += cycdiff; + cycdiff = oldcyc - cycles; + delta = tsc - oldtsc; + if (delta > 0) { + /* TSC has changed, this means interim timer processing has happened, + see how much we still need to add. */ + cycdiff -= delta; + if (cycdiff > 0) + tsc += cycdiff; + } else { + /* TSC has not changed. */ + tsc += cycdiff; + } if (cpu_state.abrt) { @@ -799,8 +821,10 @@ void exec386_dynarec(int cycs) } } - if (TIMER_VAL_LESS_THAN_VAL(timer_target, (uint32_t)tsc)) - timer_process(); + if (cycdiff > 0) { + if (TIMER_VAL_LESS_THAN_VAL(timer_target, (uint32_t)tsc)) + timer_process(); + } } cycles_main -= (cycles_start - cycles); diff --git a/src/cpu_common/cpu.h b/src/cpu_common/cpu.h index 19fa6bce4..9129a7ab0 100644 --- a/src/cpu_common/cpu.h +++ b/src/cpu_common/cpu.h @@ -565,6 +565,7 @@ extern int cpu_effective, cpu_alt_reset; extern void cpu_dynamic_switch(int new_cpu); extern void cpu_ven_reset(void); +extern void update_tsc(int cycs); extern int sysenter(uint32_t fetchdat); extern int sysexit(uint32_t fetchdat); diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 47b2acea3..c0cad810d 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -222,9 +222,7 @@ extern int machine_at_winbios1429_init(const machine_t *); extern int machine_at_opti495_init(const machine_t *); extern int machine_at_opti495_ami_init(const machine_t *); -#if defined(DEV_BRANCH) && defined(USE_MR495) extern int machine_at_opti495_mr_init(const machine_t *); -#endif extern int machine_at_ami471_init(const machine_t *); extern int machine_at_dtk486_init(const machine_t *); @@ -281,9 +279,7 @@ extern const device_t *at_endeavor_get_device(void); extern int machine_at_chariot_init(const machine_t *); extern int machine_at_mr586_init(const machine_t *); extern int machine_at_thor_init(const machine_t *); -#if defined(DEV_BRANCH) && defined(USE_MRTHOR) extern int machine_at_mrthor_init(const machine_t *); -#endif extern int machine_at_pb640_init(const machine_t *); extern int machine_at_acerm3a_init(const machine_t *); diff --git a/src/io.c b/src/io.c index 5896a54de..89d341f76 100644 --- a/src/io.c +++ b/src/io.c @@ -328,8 +328,11 @@ outb(uint16_t port, uint8_t val) p = p->next; } - if (!found) + if (!found) { sub_cycles(io_delay); + if (cpu_use_dynarec && (port == 0xeb)) + update_tsc(io_delay); + } io_log("(%i, %i, %04i) outb(%04X, %02X)\n", in_smm, found, qfound, port, val); @@ -418,8 +421,11 @@ outw(uint16_t port, uint16_t val) } } - if (!found) + if (!found) { sub_cycles(io_delay); + if (cpu_use_dynarec && (port == 0xeb)) + update_tsc(io_delay); + } io_log("(%i, %i, %04i) outw(%04X, %04X)\n", in_smm, found, qfound, port, val); @@ -542,8 +548,11 @@ outl(uint16_t port, uint32_t val) } } - if (!found) + if (!found) { sub_cycles(io_delay); + if (cpu_use_dynarec && (port == 0xeb)) + update_tsc(io_delay); + } io_log("(%i, %i, %04i) outl(%04X, %08X)\n", in_smm, found, qfound, port, val); diff --git a/src/machine/m_at_386dx_486.c b/src/machine/m_at_386dx_486.c index 8cb014f2b..4bed55f9c 100644 --- a/src/machine/m_at_386dx_486.c +++ b/src/machine/m_at_386dx_486.c @@ -205,7 +205,6 @@ machine_at_opti495_ami_init(const machine_t *model) } -#if defined(DEV_BRANCH) && defined(USE_MR495) int machine_at_opti495_mr_init(const machine_t *model) { @@ -221,7 +220,6 @@ machine_at_opti495_mr_init(const machine_t *model) return ret; } -#endif static void diff --git a/src/machine/m_at_socket7_s7.c b/src/machine/m_at_socket7_s7.c index ace9a7d9a..d0cadb632 100644 --- a/src/machine/m_at_socket7_s7.c +++ b/src/machine/m_at_socket7_s7.c @@ -143,7 +143,6 @@ machine_at_thor_init(const machine_t *model) } -#if defined(DEV_BRANCH) && defined(USE_MRTHOR) int machine_at_mrthor_init(const machine_t *model) { @@ -159,7 +158,6 @@ machine_at_mrthor_init(const machine_t *model) return ret; } -#endif int diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 2e4314ebb..02d0f653e 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -166,9 +166,7 @@ const machine_t machines[] = { /* 386DX machines which utilize the VLB bus */ { "[386DX VLB] Award 386DX clone", "award386dx", {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 1, 32, 1, 127, machine_at_opti495_init, NULL }, { "[386DX VLB] Dataexpert SX495 (386DX)", "ami386dx", {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 1, 32, 1, 127, machine_at_opti495_ami_init, NULL }, -#if defined(DEV_BRANCH) && defined(USE_MR495) { "[386DX VLB] MR 386DX clone", "mr386dx", {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 1, 32, 1, 127, machine_at_opti495_mr_init, NULL }, -#endif /* 386DX machines which utilize the MCA bus */ { "[386DX MCA] IBM PS/2 model 70 (type 3)", "ibmps2_m70_type3", {{"Intel", cpus_i386DX}, {"AMD", cpus_Am386DX}, {"Cyrix", cpus_486DLC}, {"IBM",cpus_IBM486BL},{"", NULL}}, MACHINE_MCA | MACHINE_AT | MACHINE_PS2 | MACHINE_VIDEO, 2, 16, 2, 63, machine_ps2_model_70_type3_init, NULL }, @@ -191,9 +189,7 @@ const machine_t machines[] = { #endif { "[486 VLB] DTK PKM-0038S E-2", "dtk486", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 1, 64, 1, 127, machine_at_dtk486_init, NULL }, -#if defined(DEV_BRANCH) && defined(USE_MR495) { "[486 VLB] MR 486 clone", "mr486", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 1, 32, 1, 127, machine_at_opti495_mr_init, NULL }, -#endif { "[486 VLB] Phoenix SiS 471", "px471", {{"Intel", cpus_i486}, {"AMD", cpus_Am486}, {"Cyrix", cpus_Cx486}, {"", NULL}, {"", NULL}}, MACHINE_ISA | MACHINE_VLB | MACHINE_AT | MACHINE_HDC, 1, 128, 1, 127, machine_at_px471_init, NULL }, #if defined(DEV_BRANCH) && defined(USE_PS2M70T4) @@ -238,9 +234,7 @@ const machine_t machines[] = { { "[Socket 7-3V FX] MR 430FX clone", "mr586", MACHINE_CPUS_PENTIUM_S73V, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 8, 128, 8, 127, machine_at_mr586_init, NULL }, { "[Socket 7-3V FX] Intel Advanced/ATX", "thor", MACHINE_CPUS_PENTIUM_S73V, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 128, 8, 127, machine_at_thor_init, NULL }, { "[Socket 7-3V FX] Intel Advanced/EV", "endeavor", MACHINE_CPUS_PENTIUM_S73V, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC | MACHINE_VIDEO, 8, 128, 8, 127, machine_at_endeavor_init, at_endeavor_get_device }, -#if defined(DEV_BRANCH) && defined(USE_MRTHOR) { "[Socket 7-3V FX] MR Intel Advanced/ATX", "mrthor", MACHINE_CPUS_PENTIUM_S73V, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC, 8, 128, 8, 127, machine_at_mrthor_init, NULL }, -#endif { "[Socket 7-3V FX] Packard Bell PB640", "pb640", MACHINE_CPUS_PENTIUM_S73V, MACHINE_PCI | MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC | MACHINE_VIDEO, 8, 128, 8, 127, machine_at_pb640_init, at_pb640_get_device }, /* 430HX */ diff --git a/src/pit.c b/src/pit.c index b04f23001..688bc9210 100644 --- a/src/pit.c +++ b/src/pit.c @@ -1017,7 +1017,7 @@ pit_set_clock(int clock) xt_cpu_multi <<= 32ULL; /* Delay for empty I/O ports. */ - io_delay = (int) round(((double) machines[machine].cpu[cpu_manufacturer].cpus[cpu_effective].rspeed) / 1000000.0); + io_delay = (int) round(((double) machines[machine].cpu[cpu_manufacturer].cpus[cpu_effective].rspeed) / 2000000.0); MDACONST = (uint64_t) (cpuclock / 2032125.0 * (double)(1ull << 32)); HERCCONST = MDACONST; diff --git a/src/postcard.c b/src/postcard.c index 134af04b7..91275ee16 100644 --- a/src/postcard.c +++ b/src/postcard.c @@ -26,6 +26,7 @@ #include <86box/plat.h> #include <86box/ui.h> #include <86box/postcard.h> +#include "cpu.h" static uint16_t postcard_port; @@ -98,6 +99,9 @@ postcard_write(uint16_t port, uint8_t val, void *priv) if (postcard_written && val == postcard_code) return; + if (val == 0x13) + pclog("[%04X:%08X] POST 13\n", CS, cpu_state.pc); + postcard_prev_code = postcard_code; postcard_code = val; if (postcard_written < 2) diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index b213b0882..e7051e244 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -47,12 +47,6 @@ ifeq ($(DEV_BUILD), y) ifndef MGA MGA := y endif - ifndef MR495 - MR495 := y - endif - ifndef MRTHOR - MRTHOR := y - endif ifndef PAS16 PAS16 := n endif @@ -111,12 +105,6 @@ else ifndef MGA MGA := n endif - ifndef MR495 - MR495 := n - endif - ifndef MRTHOR - MRTHOR := n - endif ifndef PAS16 PAS16 := n endif @@ -434,14 +422,6 @@ OPTS += -DUSE_MGA DEVBROBJ += vid_mga.o endif -ifeq ($(MR495), y) -OPTS += -DUSE_MR495 -endif - -ifeq ($(MRTHOR), y) -OPTS += -DUSE_MRTHOR -endif - ifeq ($(PAS16), y) OPTS += -DUSE_PAS16 DEVBROBJ += snd_pas16.o diff --git a/src/win/Makefile_ndr.mingw b/src/win/Makefile_ndr.mingw index 47b7fa776..d501f1b82 100644 --- a/src/win/Makefile_ndr.mingw +++ b/src/win/Makefile_ndr.mingw @@ -47,12 +47,6 @@ ifeq ($(DEV_BUILD), y) ifndef MGA MGA := y endif - ifndef MR495 - MR495 := y - endif - ifndef MRTHOR - MRTHOR := y - endif ifndef PAS16 PAS16 := n endif @@ -111,12 +105,6 @@ else ifndef MGA MGA := n endif - ifndef MR495 - MR495 := n - endif - ifndef MRTHOR - MRTHOR := n - endif ifndef PAS16 PAS16 := n endif @@ -443,14 +431,6 @@ OPTS += -DUSE_MGA DEVBROBJ += vid_mga.o endif -ifeq ($(MR495), y) -OPTS += -DUSE_MR495 -endif - -ifeq ($(MRTHOR), y) -OPTS += -DUSE_MRTHOR -endif - ifeq ($(PAS16), y) OPTS += -DUSE_PAS16 DEVBROBJ += snd_pas16.o