From 2fd712d092465aaae7c25ec8734a75e8af87c470 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 16 Jul 2022 03:12:24 +0200 Subject: [PATCH] CPU changes. --- src/cpu/386_common.c | 34 ++++++++++++++++++++++++++++++++-- src/cpu/cpu.h | 4 ++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/cpu/386_common.c b/src/cpu/386_common.c index 1f5bfe3b5..d7544b351 100644 --- a/src/cpu/386_common.c +++ b/src/cpu/386_common.c @@ -22,6 +22,7 @@ #include <86box/fdd.h> #include <86box/fdc.h> #include <86box/keyboard.h> +#include <86box/timer.h> #include "386_common.h" #include "x86_flags.h" #include "x86seg.h" @@ -71,6 +72,9 @@ int smm_in_hlt = 0, smi_block = 0; uint32_t addr64, addr64_2; uint32_t addr64a[8], addr64a_2[8]; +static timer_t *cpu_fast_off_timer = NULL; +static double *cpu_fast_off_period = NULL; + #define AMD_SYSCALL_EIP (msr.star & 0xFFFFFFFF) #define AMD_SYSCALL_SB ((msr.star >> 32) & 0xFFFF) @@ -1837,11 +1841,37 @@ sysret(uint32_t fetchdat) } +void +cpu_register_fast_off_handler(void *timer, double *period) +{ + cpu_fast_off_timer = (timer_t *) timer; + cpu_fast_off_period = period; +} + + +void +cpu_fast_off_advance(void) +{ + if (cpu_fast_off_period && (*cpu_fast_off_period != 0.0)) + timer_on_auto(cpu_fast_off_timer, *cpu_fast_off_period); +} + + +void +cpu_fast_off_period_set(uint16_t val, double period) +{ + if (cpu_fast_off_period) { + *cpu_fast_off_period = ((double) (val + 1)) * period; + cpu_fast_off_advance(); + } +} + + void smi_raise(void) { if (is486 && (cpu_fast_off_flags & 0x80000000)) - cpu_fast_off_count = cpu_fast_off_val + 1; + cpu_fast_off_advance(); smi_line = 1; } @@ -1851,7 +1881,7 @@ void nmi_raise(void) { if (is486 && (cpu_fast_off_flags & 0x20000000)) - cpu_fast_off_count = cpu_fast_off_val + 1; + cpu_fast_off_advance(); } diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index 136a6c834..61fd700d9 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -733,6 +733,10 @@ extern uint8_t do_translate, do_translate2; extern void reset_808x(int hard); +extern void cpu_register_fast_off_handler(void *timer, double *period); +extern void cpu_fast_off_advance(void); +extern void cpu_fast_off_period_set(uint16_t vla, double period); + extern void smi_raise(); extern void nmi_raise();