From 7506b4667e34af0c337f7bed398e0c33987e4452 Mon Sep 17 00:00:00 2001 From: OBattler Date: Tue, 21 Jan 2020 01:23:35 +0100 Subject: [PATCH] Fixed the HLT instruction on 286+ and Intel Flash aliasing. --- src/cpu/x86_ops_misc.h | 3 ++- src/cpu_new/x86_ops_misc.h | 3 ++- src/intel_flash.c | 7 +++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/cpu/x86_ops_misc.h b/src/cpu/x86_ops_misc.h index 08abe6790..91118211b 100644 --- a/src/cpu/x86_ops_misc.h +++ b/src/cpu/x86_ops_misc.h @@ -615,7 +615,8 @@ static int opHLT(uint32_t fetchdat) if (!((cpu_state.flags & I_FLAG) && pic_intpending)) { CLOCK_CYCLES_ALWAYS(100); - cpu_state.pc--; + if (!((cpu_state.flags & I_FLAG) && pic_intpending)) + cpu_state.pc--; } else CLOCK_CYCLES(5); diff --git a/src/cpu_new/x86_ops_misc.h b/src/cpu_new/x86_ops_misc.h index f8db6c592..e49825a5f 100644 --- a/src/cpu_new/x86_ops_misc.h +++ b/src/cpu_new/x86_ops_misc.h @@ -615,7 +615,8 @@ static int opHLT(uint32_t fetchdat) if (!((cpu_state.flags & I_FLAG) && pic_intpending)) { CLOCK_CYCLES_ALWAYS(100); - cpu_state.pc--; + if (!((cpu_state.flags & I_FLAG) && pic_intpending)) + cpu_state.pc--; } else CLOCK_CYCLES(5); diff --git a/src/intel_flash.c b/src/intel_flash.c index faddf4ec4..7530912f5 100644 --- a/src/intel_flash.c +++ b/src/intel_flash.c @@ -278,9 +278,12 @@ intel_flash_add_mappings(flash_t *dev) { int max = 2, i = 0; uint32_t base, fbase; + uint32_t sub = 0x20000; - if (biosmask == 0x3ffff) + if (biosmask == 0x3ffff) { + sub = 0x40000; max = 4; + } for (i = 0; i < max; i++) { if (biosmask == 0x3ffff) @@ -299,7 +302,7 @@ intel_flash_add_mappings(flash_t *dev) flash_write, flash_writew, flash_writel, dev->array + fbase, MEM_MAPPING_EXTERNAL|MEM_MAPPING_ROMCS, (void *) dev); } - mem_mapping_add(&(dev->mapping_h[i]), (base | 0xfff00000) - 0x40000, 0x10000, + mem_mapping_add(&(dev->mapping_h[i]), (base | 0xfff00000) - sub, 0x10000, flash_read, flash_readw, flash_readl, flash_write, flash_writew, flash_writel, dev->array + fbase, MEM_MAPPING_EXTERNAL|MEM_MAPPING_ROMCS, (void *) dev);