From 151d8d486a53b4e907d7c06d9b7315c9f08bf032 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sun, 7 Jun 2020 16:03:15 -0300 Subject: [PATCH 1/5] Small indentation and header fixes --- src/chipset/intel_4x0.c | 4 ++-- src/include/86box/postcard.h | 1 + src/postcard.c | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/chipset/intel_4x0.c b/src/chipset/intel_4x0.c index aee40c3e5..779da0c03 100644 --- a/src/chipset/intel_4x0.c +++ b/src/chipset/intel_4x0.c @@ -43,8 +43,8 @@ enum INTEL_430VX, INTEL_430TX, INTEL_440FX, - INTEL_440LX, - INTEL_440EX, + INTEL_440LX, + INTEL_440EX, INTEL_440BX, INTEL_440ZX }; diff --git a/src/include/86box/postcard.h b/src/include/86box/postcard.h index 6bc8564cf..8cf1d1c54 100644 --- a/src/include/86box/postcard.h +++ b/src/include/86box/postcard.h @@ -11,6 +11,7 @@ * * * Author: RichardG, + * * Copyright 2020 RichardG. */ #ifndef POSTCARD_H diff --git a/src/postcard.c b/src/postcard.c index 683abb13b..92166cc97 100644 --- a/src/postcard.c +++ b/src/postcard.c @@ -11,6 +11,7 @@ * * * Author: RichardG, + * * Copyright 2020 RichardG. */ #include From f65b51b0f3dd46743631785dc823378a96f9b0bf Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sun, 7 Jun 2020 16:44:50 -0300 Subject: [PATCH 2/5] MPS table patcher for the ASUS P/I-P65UP5 --- src/include/86box/chipset.h | 2 + src/ioapic.c | 130 ++++++++++++++++++++++++++++++++++++ src/machine/m_at_socket8.c | 1 + src/win/Makefile.mingw | 2 +- src/win/Makefile_ndr.mingw | 2 +- 5 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 src/ioapic.c diff --git a/src/include/86box/chipset.h b/src/include/86box/chipset.h index ce78f0ec5..3c7cd91fa 100644 --- a/src/include/86box/chipset.h +++ b/src/include/86box/chipset.h @@ -47,6 +47,8 @@ extern const device_t i440ex_device; extern const device_t i440bx_device; extern const device_t i440zx_device; +extern const device_t ioapic_device; + /* OPTi */ extern const device_t opti495_device; extern const device_t opti5x7_device; diff --git a/src/ioapic.c b/src/ioapic.c new file mode 100644 index 000000000..52f217e8d --- /dev/null +++ b/src/ioapic.c @@ -0,0 +1,130 @@ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Skeleton I/O APIC implementation, currently housing the MPS + * table patcher for machines that require it. + * + * + * + * Author: RichardG, + * + * Copyright 2020 RichardG. + */ +#include +#include +#include +#include +#include +#define HAVE_STDARG_H +#include <86box/86box.h> +#include <86box/io.h> +#include <86box/device.h> +#include <86box/machine.h> +#include <86box/mem.h> +#include <86box/chipset.h> + + +typedef struct { + uint8_t dummy; +} ioapic_t; + +#define ENABLE_IOAPIC_LOG 1 +#ifdef ENABLE_IOAPIC_LOG +int ioapic_do_log = ENABLE_IOAPIC_LOG; + + +static void +ioapic_log(const char *fmt, ...) +{ + va_list ap; + + if (ioapic_do_log) { + va_start(ap, fmt); + pclog_ex(fmt, ap); + va_end(ap); + } +} +#else +#define ioapic_log(fmt, ...) +#endif + + +static void +ioapic_write(uint16_t port, uint8_t val, void *priv) +{ + uint32_t addr, pcmp; + + /* target POST FF, issued by Award before jumping to the bootloader */ + if (val != 0xff) + return; + + ioapic_log("IOAPIC: Caught POST %02X\n", val); + + /* The _MP_ table must be located in the BIOS area, the EBDA, or the last 1k of conventional + memory; at a 16-byte boundary in all cases. Award writes both tables to the BIOS area. */ + for (addr = 0xf0000; addr <= 0xfffff; addr += 16) { + /* check signature for the _MP_ table (Floating Point Structure) */ + if (mem_readl_phys(addr) != 0x5f504d5f) /* ASCII "_MP_" */ + continue; + + /* read and check pointer to the PCMP table (Configuration Table) */ + pcmp = mem_readl_phys(addr + 4); + if ((pcmp < 0xf0000) || (pcmp > 0xfffff) || (mem_readl_phys(pcmp) != 0x504d4350)) /* ASCII "PCMP" */ + continue; + + /* patch over the signature on both tables */ + ioapic_log("IOAPIC: Patching _MP_ [%08x] and PCMP [%08x] tables\n", addr, pcmp); + ram[addr] = ram[addr + 1] = ram[addr + 2] = ram[addr + 3] = 0xff; + ram[pcmp] = ram[pcmp + 1] = ram[pcmp + 2] = ram[pcmp + 3] = 0xff; + + break; + } +} + + +static void +ioapic_reset(ioapic_t *dev) +{ +} + + +static void +ioapic_close(void *priv) +{ + ioapic_t *dev = (ioapic_t *) priv; + + io_removehandler(0x80, 1, + NULL, NULL, NULL, ioapic_write, NULL, NULL, NULL); + + free(dev); +} + + +static void * +ioapic_init(const device_t *info) +{ + ioapic_t *dev = (ioapic_t *) malloc(sizeof(ioapic_t)); + memset(dev, 0, sizeof(ioapic_t)); + + ioapic_reset(dev); + + io_sethandler(0x80, 1, + NULL, NULL, NULL, ioapic_write, NULL, NULL, NULL); + + return dev; +} + + +const device_t ioapic_device = { + "I/O APIC", + DEVICE_AT, + 0, + ioapic_init, ioapic_close, NULL, + NULL, NULL, NULL, + NULL +}; diff --git a/src/machine/m_at_socket8.c b/src/machine/m_at_socket8.c index fd7b5bcea..be03a41fb 100644 --- a/src/machine/m_at_socket8.c +++ b/src/machine/m_at_socket8.c @@ -176,6 +176,7 @@ machine_at_p65up5_common_init(const machine_t *model, const device_t *northbridg device_add(&keyboard_ps2_ami_pci_device); device_add(&w83877f_device); device_add(&intel_flash_bxt_device); + device_add(&ioapic_device); } int diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index e50cdbf57..6600a7c0c 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -527,7 +527,7 @@ CPUOBJ := cpu.o cpu_table.o \ $(DYNARECOBJ) CHIPSETOBJ := acc2168.o acer_m3a.o cs8230.o ali1429.o headland.o \ - intel_4x0.o neat.o opti495.o opti5x7.o scamp.o scat.o \ + intel_4x0.o ioapic.o neat.o opti495.o opti5x7.o scamp.o scat.o \ rabbit.o sis_85c471.o sis_85c496.o \ via_apollo.o via_vpx.o wd76c10.o diff --git a/src/win/Makefile_ndr.mingw b/src/win/Makefile_ndr.mingw index 20ae9f98e..42caadcbe 100644 --- a/src/win/Makefile_ndr.mingw +++ b/src/win/Makefile_ndr.mingw @@ -531,7 +531,7 @@ CPUOBJ := cpu.o cpu_table.o \ $(DYNARECOBJ) CHIPSETOBJ := acc2168.o acer_m3a.o cs8230.o ali1429.o headland.o \ - intel_4x0.o neat.o opti495.o opti5x7.o scamp.o scat.o \ + intel_4x0.o ioapic.o neat.o opti495.o opti5x7.o scamp.o scat.o \ rabbit.o sis_85c471.o sis_85c496.o \ via_apollo.o via_vpx.o wd76c10.o From 25f5e96031ff6bf1d1d095eb7f9ed049c6bf26f7 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sun, 7 Jun 2020 16:56:22 -0300 Subject: [PATCH 3/5] Verbose I/O APIC name --- src/ioapic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ioapic.c b/src/ioapic.c index 52f217e8d..23221ce92 100644 --- a/src/ioapic.c +++ b/src/ioapic.c @@ -121,7 +121,7 @@ ioapic_init(const device_t *info) const device_t ioapic_device = { - "I/O APIC", + "I/O Advanced Programmable Interrupt Controller", DEVICE_AT, 0, ioapic_init, ioapic_close, NULL, From 8848e6e56ed2bf7e830a2f2e47f66ef4d1e6bd6c Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sun, 7 Jun 2020 17:00:55 -0300 Subject: [PATCH 4/5] Fix indentation --- src/ioapic.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ioapic.c b/src/ioapic.c index 23221ce92..a2e8bc742 100644 --- a/src/ioapic.c +++ b/src/ioapic.c @@ -7,7 +7,7 @@ * This file is part of the 86Box distribution. * * Skeleton I/O APIC implementation, currently housing the MPS - * table patcher for machines that require it. + * table patcher for machines that require it. * * * @@ -73,16 +73,16 @@ ioapic_write(uint16_t port, uint8_t val, void *priv) continue; /* read and check pointer to the PCMP table (Configuration Table) */ - pcmp = mem_readl_phys(addr + 4); - if ((pcmp < 0xf0000) || (pcmp > 0xfffff) || (mem_readl_phys(pcmp) != 0x504d4350)) /* ASCII "PCMP" */ - continue; + pcmp = mem_readl_phys(addr + 4); + if ((pcmp < 0xf0000) || (pcmp > 0xfffff) || (mem_readl_phys(pcmp) != 0x504d4350)) /* ASCII "PCMP" */ + continue; - /* patch over the signature on both tables */ - ioapic_log("IOAPIC: Patching _MP_ [%08x] and PCMP [%08x] tables\n", addr, pcmp); - ram[addr] = ram[addr + 1] = ram[addr + 2] = ram[addr + 3] = 0xff; - ram[pcmp] = ram[pcmp + 1] = ram[pcmp + 2] = ram[pcmp + 3] = 0xff; + /* patch over the signature on both tables */ + ioapic_log("IOAPIC: Patching _MP_ [%08x] and PCMP [%08x] tables\n", addr, pcmp); + ram[addr] = ram[addr + 1] = ram[addr + 2] = ram[addr + 3] = 0xff; + ram[pcmp] = ram[pcmp + 1] = ram[pcmp + 2] = ram[pcmp + 3] = 0xff; - break; + break; } } From f8bbe69dffbc4d324e63a57222d5c527d6881432 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sun, 7 Jun 2020 17:01:57 -0300 Subject: [PATCH 5/5] Disable IOAPIC logging --- src/ioapic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ioapic.c b/src/ioapic.c index a2e8bc742..a45ad14c7 100644 --- a/src/ioapic.c +++ b/src/ioapic.c @@ -33,7 +33,7 @@ typedef struct { uint8_t dummy; } ioapic_t; -#define ENABLE_IOAPIC_LOG 1 + #ifdef ENABLE_IOAPIC_LOG int ioapic_do_log = ENABLE_IOAPIC_LOG;