From 166f64d422006fcffa8c9d7abd2bdfa42dbfbc28 Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 7 Jun 2021 00:06:17 +0200 Subject: [PATCH] Some CPU fixes, should fix compiling. --- src/cpu/cpu.c | 2 ++ src/cpu/cpu.h | 4 ++++ src/cpu/x86.c | 30 +++++++++++++++++++++++++----- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 62e497578..290c14a86 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -358,6 +358,8 @@ cpu_set(void) acycs = 0; #endif + soft_reset_pci = 0; + cpu_alt_reset = 0; unmask_a20_in_smm = 0; diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index d336b9a26..2aecdf13e 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -698,6 +698,10 @@ typedef struct extern uint32_t addr64, addr64_2; extern uint32_t addr64a[8], addr64a_2[8]; +extern int soft_reset_pci; + +extern int reset_on_hlt, hlt_reset_pending; + extern cyrix_t cyrix; extern void (*cpu_exec)(int cycs); diff --git a/src/cpu/x86.c b/src/cpu/x86.c index 539cea550..e652c5d27 100644 --- a/src/cpu/x86.c +++ b/src/cpu/x86.c @@ -31,6 +31,7 @@ #include <86box/rom.h> #include <86box/nmi.h> #include <86box/pic.h> +#include <86box/pci.h> #include <86box/ppi.h> #include <86box/timer.h> @@ -56,7 +57,7 @@ uint64_t xt_cpu_multi; int nmi = 0, nmi_auto_clear = 0; /* Was the CPU ever reset? */ -int x86_was_reset = 0; +int x86_was_reset = 0, soft_reset_pci = 0; /* Is the TRAP flag on? */ int trap = 0; @@ -64,6 +65,9 @@ int trap = 0; /* The current effective address's segment. */ uint32_t easeg; +/* This is for the OPTI 283 special reset handling mode. */ +int reset_on_hlt, hlt_reset_pending; + #ifdef ENABLE_X86_LOG void dumpregs(int); @@ -216,15 +220,28 @@ makeznptable(void) static void reset_common(int hard) { - /* Make sure to gracefully leave SMM. */ - if (in_smm) - leave_smm(); - #ifdef ENABLE_808X_LOG if (hard) x808x_log("x86 reset\n"); #endif + if (!hard && reset_on_hlt) { + hlt_reset_pending++; + pclog("hlt_reset_pending = %i\n", hlt_reset_pending); + if (hlt_reset_pending == 2) + hlt_reset_pending = 0; + else + return; + } + + /* Make sure to gracefully leave SMM. */ + if (in_smm) + leave_smm(); + + /* Needed for the ALi M1533. */ + if (soft_reset_pci && !hard) + pci_reset(); + use32 = 0; cpu_cur_status = 0; stack32 = 0; @@ -290,6 +307,9 @@ reset_common(int hard) shadowbios = shadowbios_write = 0; alt_access = cpu_end_block_after_ins = 0; + if (hard) + reset_on_hlt = hlt_reset_pending = 0; + if (!is286) reset_808x(hard); }