Skip to content

Commit

Permalink
Disable the debug registers on 486+.
Browse files Browse the repository at this point in the history
  • Loading branch information
OBattler committed Jan 14, 2024
1 parent d8330a0 commit f2971a1
Show file tree
Hide file tree
Showing 11 changed files with 1,165 additions and 200 deletions.
114 changes: 57 additions & 57 deletions src/cpu/386_common.h

Large diffs are not rendered by default.

37 changes: 6 additions & 31 deletions src/cpu/386_dynarec.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ fetch_ea_16_long(uint32_t rmdat)

#include "386_ops.h"

#define CACHE_ON() (!(cr0 & (1 << 30)) && !(cpu_state.flags & T_FLAG) && !(dr[7] & 0xFF))
#define CACHE_ON() (!(cr0 & (1 << 30)) && !(cpu_state.flags & T_FLAG))

#ifdef USE_DYNAREC
int32_t cycles_main = 0;
Expand Down Expand Up @@ -268,7 +268,7 @@ exec386_dynarec_int(void)
cpu_block_end = 0;
x86_was_reset = 0;

if (trap & 2) {
if (trap == 2) {
/* Handle the T bit in the new TSS first. */
CPU_BLOCK_END();
goto block_ended;
Expand All @@ -285,11 +285,6 @@ exec386_dynarec_int(void)
cpu_state.ea_seg = &cpu_state.seg_ds;
cpu_state.ssegs = 0;

if (UNLIKELY(cpu_386_check_instruction_fault())) {
x86gen();
goto block_ended;
}

fetchdat = fastreadl_fetch(cs + cpu_state.pc);
# ifdef ENABLE_386_DYNAREC_LOG
if (in_smm)
Expand All @@ -300,7 +295,7 @@ exec386_dynarec_int(void)
opcode = fetchdat & 0xFF;
fetchdat >>= 8;

trap |= !!(cpu_state.flags & T_FLAG);
trap = cpu_state.flags & T_FLAG;

cpu_state.pc++;
x86_opcodes[(opcode | cpu_state.op32) & 0x3ff](fetchdat);
Expand All @@ -311,14 +306,6 @@ exec386_dynarec_int(void)
cpu_state.pc &= 0xffff;
# endif

if (!cpu_state.abrt) {
if (!rf_flag_no_clear) {
cpu_state.eflags &= ~RF_FLAG;
}

rf_flag_no_clear = 0;
}

if (((cs + cpu_state.pc) >> 12) != pccache)
CPU_BLOCK_END();

Expand All @@ -342,10 +329,7 @@ exec386_dynarec_int(void)

block_ended:
if (!cpu_state.abrt && trap) {
//pclog("Debug trap 0x%X\n", trap);
if (trap & 2) dr[6] |= 0x8000;
if (trap & 1) dr[6] |= 0x4000;

dr[6] |= (trap == 2) ? 0x8000 : 0x4000;
trap = 0;
# ifndef USE_NEW_DYNAREC
oldcs = CS;
Expand Down Expand Up @@ -857,11 +841,6 @@ exec386(int32_t cycs)
cpu_state.ea_seg = &cpu_state.seg_ds;
cpu_state.ssegs = 0;

if (UNLIKELY(cpu_386_check_instruction_fault())) {
x86gen();
goto block_ended;
}

fetchdat = fastreadl_fetch(cs + cpu_state.pc);

if (!cpu_state.abrt) {
Expand All @@ -871,7 +850,7 @@ exec386(int32_t cycs)
#endif
opcode = fetchdat & 0xFF;
fetchdat >>= 8;
trap |= !!(cpu_state.flags & T_FLAG);
trap = cpu_state.flags & T_FLAG;

cpu_state.pc++;
x86_opcodes[(opcode | cpu_state.op32) & 0x3ff](fetchdat);
Expand All @@ -891,7 +870,6 @@ exec386(int32_t cycs)
if (cpu_end_block_after_ins)
cpu_end_block_after_ins--;

block_ended:
if (cpu_state.abrt) {
flags_rebuild();
tempi = cpu_state.abrt & ABRT_MASK;
Expand All @@ -916,15 +894,12 @@ exec386(int32_t cycs)
}
} else if (trap) {
flags_rebuild();
if (trap & 1)
dr[6] |= 0x4000;
if (trap & 2)
dr[6] |= 0x8000;
trap = 0;
#ifndef USE_NEW_DYNAREC
oldcs = CS;
#endif
cpu_state.oldpc = cpu_state.pc;
dr[6] |= 0x4000;
x86_int(1);
}

Expand Down
18 changes: 15 additions & 3 deletions src/cpu/386_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,11 @@ extern void x386_dynarec_log(const char *fmt, ...);
#ifndef OPS_286_386
# include "x86_ops_cyrix.h"
#endif
#include "x86_ops_flag.h"
#ifdef OPS_286_386
# include "x86_ops_flag_2386.h"
#else
# include "x86_ops_flag.h"
#endif
#include "x86_ops_fpu.h"
#include "x86_ops_inc_dec.h"
#include "x86_ops_int.h"
Expand All @@ -200,7 +204,11 @@ extern void x386_dynarec_log(const char *fmt, ...);
# include "x86_ops_mmx_shift.h"
#endif
#include "x86_ops_mov.h"
#include "x86_ops_mov_ctrl.h"
#ifdef OPS_286_386
# include "x86_ops_mov_ctrl_2386.h"
#else
# include "x86_ops_mov_ctrl.h"
#endif
#include "x86_ops_mov_seg.h"
#include "x86_ops_movx.h"
#ifndef OPS_286_386
Expand All @@ -218,7 +226,11 @@ extern void x386_dynarec_log(const char *fmt, ...);
# include "x86_ops_rep.h"
# endif
#endif
#include "x86_ops_ret.h"
#ifdef OPS_286_386
# include "x86_ops_ret_2386.h"
#else
# include "x86_ops_ret.h"
#endif
#include "x86_ops_set.h"
#include "x86_ops_stack.h"
#ifdef OPS_286_386
Expand Down
4 changes: 0 additions & 4 deletions src/cpu/x86_ops_flag.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ opPOPF_186(uint32_t fetchdat)
else
cpu_state.flags = (cpu_state.flags & 0x3200) | (tempw & 0x4dd5) | 2;
flags_extract();
rf_flag_no_clear = 1;

CLOCK_CYCLES(5);
PREFETCH_RUN(5, 1, -1, 1, 0, 0, 0, 0);
Expand Down Expand Up @@ -212,7 +211,6 @@ opPOPF_286(uint32_t fetchdat)
else
cpu_state.flags = (cpu_state.flags & 0x3200) | (tempw & 0x4dd5) | 2;
flags_extract();
rf_flag_no_clear = 1;

CLOCK_CYCLES(5);
PREFETCH_RUN(5, 1, -1, 1, 0, 0, 0, 0);
Expand Down Expand Up @@ -266,7 +264,6 @@ opPOPF(uint32_t fetchdat)
cpu_state.flags = (cpu_state.flags & 0x3200) | (tempw & 0x4dd5) | 2;
}
flags_extract();
rf_flag_no_clear = 1;

CLOCK_CYCLES(5);
PREFETCH_RUN(5, 1, -1, 1, 0, 0, 0, 0);
Expand Down Expand Up @@ -310,7 +307,6 @@ opPOPFD(uint32_t fetchdat)
cpu_state.eflags = (templ >> 16) & 3;

flags_extract();
rf_flag_no_clear = 1;

CLOCK_CYCLES(5);
PREFETCH_RUN(5, 1, -1, 0, 1, 0, 0, 0);
Expand Down
Loading

0 comments on commit f2971a1

Please sign in to comment.