From 881579f15aa0fcf8b97b7bb3466c4101fecf4873 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 8 Oct 2023 06:11:32 +0200 Subject: [PATCH] Last machines and more fixes. --- src/chipset/intel_piix.c | 40 +--------- src/include/86box/machine.h | 1 + src/include/86box/sound.h | 2 + src/machine/m_at_socket5.c | 4 +- src/machine/m_at_socket7.c | 142 +++++++++++++++++++++++++++++++++- src/machine/m_at_socket7_3v.c | 14 ++-- src/machine/machine_table.c | 25 +++--- src/sound/snd_sb.c | 14 ++++ 8 files changed, 177 insertions(+), 65 deletions(-) diff --git a/src/chipset/intel_piix.c b/src/chipset/intel_piix.c index 4066abe31..f588910f5 100644 --- a/src/chipset/intel_piix.c +++ b/src/chipset/intel_piix.c @@ -68,7 +68,6 @@ typedef struct _piix_ { uint8_t no_mirq0; uint8_t regs[4][256]; uint8_t readout_regs[256]; - uint8_t board_config[2]; uint16_t func0_id; uint16_t nvr_io_base; uint16_t acpi_io_base; @@ -1189,9 +1188,7 @@ board_write(uint16_t port, uint8_t val, void *priv) { piix_t *dev = (piix_t *) priv; - if (port == 0x0078) - dev->board_config[0] = val; - else if (port == 0x00e0) + if (port == 0x00e0) dev->cur_readout_reg = val; else if (port == 0x00e1) dev->readout_regs[dev->cur_readout_reg] = val; @@ -1203,11 +1200,7 @@ board_read(uint16_t port, void *priv) const piix_t *dev = (piix_t *) priv; uint8_t ret = 0x64; - if (port == 0x0078) - ret = dev->board_config[0]; - else if (port == 0x0079) - ret = dev->board_config[1]; - else if (port == 0x00e0) + if (port == 0x00e0) ret = dev->cur_readout_reg; else if (port == 0x00e1) ret = dev->readout_regs[dev->cur_readout_reg]; @@ -1662,37 +1655,8 @@ piix_init(const device_t *info) else if (cpu_dmulti > 2.5) dev->readout_regs[1] |= 0x80; - io_sethandler(0x0078, 0x0002, board_read, NULL, NULL, board_write, NULL, NULL, dev); io_sethandler(0x00e0, 0x0002, board_read, NULL, NULL, board_write, NULL, NULL, dev); - dev->board_config[0] = 0xff; - /* Register 0x0079: */ - /* Bit 7: 0 = Clear password, 1 = Keep password. */ - /* Bit 6: 0 = NVRAM cleared by jumper, 1 = NVRAM normal. */ - /* Bit 5: 0 = CMOS Setup disabled, 1 = CMOS Setup enabled. */ - /* Bit 4: External CPU clock (Switch 8). */ - /* Bit 3: External CPU clock (Switch 7). */ - /* 50 MHz: Switch 7 = Off, Switch 8 = Off. */ - /* 60 MHz: Switch 7 = On, Switch 8 = Off. */ - /* 66 MHz: Switch 7 = Off, Switch 8 = On. */ - /* Bit 2: 0 = On-board audio absent, 1 = On-board audio present. */ - /* Bit 1: 0 = Soft-off capable power supply present, 1 = Soft-off capable power supply absent. */ - /* Bit 0: 0 = 1.5x multiplier, 1 = 2x multiplier (Switch 6). */ - /* NOTE: A bit is read as 1 if switch is off, and as 0 if switch is on. */ - dev->board_config[1] = 0xe0; - - if (cpu_busspeed <= 50000000) - dev->board_config[1] |= 0x10; - else if ((cpu_busspeed > 50000000) && (cpu_busspeed <= 60000000)) - dev->board_config[1] |= 0x18; - else if (cpu_busspeed > 60000000) - dev->board_config[1] |= 0x00; - - if (cpu_dmulti <= 1.5) - dev->board_config[1] |= 0x01; - else - dev->board_config[1] |= 0x00; - #if 0 device_add(&i8254_sec_device); #endif diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 7d6a89bcd..29df64713 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -647,6 +647,7 @@ extern int machine_at_p55t2p4_init(const machine_t *); extern int machine_at_m7shi_init(const machine_t *); extern int machine_at_tc430hx_init(const machine_t *); extern int machine_at_infinia7200_init(const machine_t *); +extern uint32_t machine_at_cu430hx_gpio_handler(uint8_t write, uint32_t val); extern int machine_at_equium5200_init(const machine_t *); extern int machine_at_pcv90_init(const machine_t *); extern int machine_at_p65up5_cp55t2d_init(const machine_t *); diff --git a/src/include/86box/sound.h b/src/include/86box/sound.h index e2914c2c1..2d9d7b6bc 100644 --- a/src/include/86box/sound.h +++ b/src/include/86box/sound.h @@ -81,6 +81,7 @@ extern void inital(void); extern void givealbuffer(void *buf); extern void givealbuffer_cd(void *buf); +#define sb_vibra16c_onboard_relocate_base sb_vibra16s_onboard_relocate_base extern void sb_vibra16s_onboard_relocate_base(uint16_t new_addr, void *priv); #ifdef EMU_DEVICE_H @@ -131,6 +132,7 @@ extern const device_t sb_pro_mcv_device; extern const device_t sb_pro_compat_device; extern const device_t sb_16_device; extern const device_t sb_vibra16s_onboard_device; +extern const device_t sb_vibra16c_onboard_device; extern const device_t sb_16_pnp_device; extern const device_t sb_16_compat_device; extern const device_t sb_16_compat_nompu_device; diff --git a/src/machine/m_at_socket5.c b/src/machine/m_at_socket5.c index b7d6cf8ef..9c5228e7f 100644 --- a/src/machine/m_at_socket5.c +++ b/src/machine/m_at_socket5.c @@ -161,7 +161,7 @@ machine_at_apollo_init(const machine_t *model) static void machine_at_zappa_gpio_init(void) { - uint32_t gpio = 0xffffffff; + uint32_t gpio = 0xffffe6ff; /* Register 0x0079: */ /* Bit 7: 0 = Clear password, 1 = Keep password. */ @@ -176,8 +176,6 @@ machine_at_zappa_gpio_init(void) /* Bit 1: No Connect. */ /* Bit 0: 2x multiplier, 1 = 1.5x multiplier (Switch 6). */ /* NOTE: A bit is read as 1 if switch is off, and as 0 if switch is on. */ - gpio = 0xffffe6ff; - if (cpu_busspeed <= 50000000) gpio |= 0xffff10ff; else if ((cpu_busspeed > 50000000) && (cpu_busspeed <= 60000000)) diff --git a/src/machine/m_at_socket7.c b/src/machine/m_at_socket7.c index 1fee61b88..71c14e096 100644 --- a/src/machine/m_at_socket7.c +++ b/src/machine/m_at_socket7.c @@ -171,6 +171,44 @@ machine_at_m7shi_init(const machine_t *model) return ret; } +/* The Sony VAIO is an AG430HX, I'm assuming it has the same configuration bits + as the TC430HX, hence the #define. */ +#define machine_at_ag430hx_gpio_init machine_at_tc430hx_gpio_init + +/* The PB680 is a NV430VX, I'm assuming it has the same configuration bits as + the TC430HX, hence the #define. */ +#define machine_at_nv430vx_gpio_init machine_at_tc430hx_gpio_init + +static void +machine_at_tc430hx_gpio_init(void) +{ + uint32_t gpio = 0xffffffff; + + /* Register 0x0079: */ + /* Bit 7: 0 = Clear password, 1 = Keep password. */ + /* Bit 6: 0 = NVRAM cleared by jumper, 1 = NVRAM normal. */ + /* Bit 5: 0 = CMOS Setup disabled, 1 = CMOS Setup enabled. */ + /* Bit 4: External CPU clock (Switch 8). */ + /* Bit 3: External CPU clock (Switch 7). */ + /* 50 MHz: Switch 7 = Off, Switch 8 = Off. */ + /* 60 MHz: Switch 7 = On, Switch 8 = Off. */ + /* 66 MHz: Switch 7 = Off, Switch 8 = On. */ + /* Bit 2: 0 = On-board audio absent, 1 = On-board audio present. */ + /* Bit 1: 0 = Soft-off capable power supply present, 1 = Soft-off capable power supply absent. */ + /* Bit 0: 0 = Reserved. */ + /* NOTE: A bit is read as 1 if switch is off, and as 0 if switch is on. */ + gpio = 0xffffe1ff; + + if (cpu_busspeed <= 50000000) + gpio |= 0xffff10ff; + else if ((cpu_busspeed > 50000000) && (cpu_busspeed <= 60000000)) + gpio |= 0xffff18ff; + else if (cpu_busspeed > 60000000) + gpio |= 0xffff00ff; + + machine_set_gpio_default(gpio); +} + int machine_at_tc430hx_init(const machine_t *model) { @@ -187,6 +225,7 @@ machine_at_tc430hx_init(const machine_t *model) return ret; machine_at_common_init_ex(model, 2); + machine_at_tc430hx_gpio_init(); pci_init(PCI_CONFIG_TYPE_1); pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); @@ -196,7 +235,10 @@ machine_at_tc430hx_init(const machine_t *model) pci_register_slot(0x0F, PCI_CARD_NORMAL, 3, 4, 1, 2); pci_register_slot(0x10, PCI_CARD_NORMAL, 4, 1, 2, 3); pci_register_slot(0x07, PCI_CARD_SOUTHBRIDGE, 0, 0, 0, 0); - device_add(&s3_virge_375_pci_device); + + if (gfxcard[0] == VID_INTERNAL) + device_add(machine_get_vid_device(machine)); + device_add(&i430hx_device); device_add(&piix3_device); device_add(&keyboard_ps2_ami_pci_device); @@ -222,6 +264,7 @@ machine_at_infinia7200_init(const machine_t *model) return ret; machine_at_common_init_ex(model, 2); + machine_at_tc430hx_gpio_init(); pci_init(PCI_CONFIG_TYPE_1); pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); @@ -231,7 +274,10 @@ machine_at_infinia7200_init(const machine_t *model) pci_register_slot(0x0F, PCI_CARD_NORMAL, 3, 4, 1, 2); pci_register_slot(0x10, PCI_CARD_NORMAL, 4, 1, 2, 3); pci_register_slot(0x07, PCI_CARD_SOUTHBRIDGE, 0, 0, 0, 0); - device_add(&s3_virge_375_pci_device); + + if (gfxcard[0] == VID_INTERNAL) + device_add(machine_get_vid_device(machine)); + device_add(&i430hx_device); device_add(&piix3_device); device_add(&keyboard_ps2_ami_pci_device); @@ -241,6 +287,87 @@ machine_at_infinia7200_init(const machine_t *model) return ret; } +static void +machine_at_cu430hx_gpio_init(void) +{ + uint32_t gpio = 0xffffe1cf; + uint16_t addr; + + /* Register 0x0078: */ + /* Bit 5,4: Vibra 16C base address: 0 = 220h, 1 = 260h, 2 = 240h, 3 = 280h. */ + device_context(machine_get_snd_device(machine)); + addr = device_get_config_hex16("base"); + switch (addr) { + case 0x0220: + gpio |= 0xffff00cf; + break; + case 0x0240: + gpio |= 0xffff00ef; + break; + case 0x0260: + gpio |= 0xffff00df; + break; + case 0x0280: + gpio |= 0xffff00ff; + break; + } + device_context_restore(); + + /* Register 0x0079: */ + /* Bit 7: 0 = Clear password, 1 = Keep password. */ + /* Bit 6: 0 = NVRAM cleared by jumper, 1 = NVRAM normal. */ + /* Bit 5: 0 = CMOS Setup disabled, 1 = CMOS Setup enabled. */ + /* Bit 4: External CPU clock (Switch 8). */ + /* Bit 3: External CPU clock (Switch 7). */ + /* 50 MHz: Switch 7 = Off, Switch 8 = Off. */ + /* 60 MHz: Switch 7 = On, Switch 8 = Off. */ + /* 66 MHz: Switch 7 = Off, Switch 8 = On. */ + /* Bit 2: 0 = On-board audio absent, 1 = On-board audio present. */ + /* Bit 1: 0 = Soft-off capable power supply present, 1 = Soft-off capable power supply absent. */ + /* Bit 0: 0 = Reserved. */ + /* NOTE: A bit is read as 1 if switch is off, and as 0 if switch is on. */ + if (cpu_busspeed <= 50000000) + gpio |= 0xffff10cf; + else if ((cpu_busspeed > 50000000) && (cpu_busspeed <= 60000000)) + gpio |= 0xffff18cf; + else if (cpu_busspeed > 60000000) + gpio |= 0xffff00cf; + + if (sound_card_current[0] == SOUND_INTERNAL) + gpio |= 0xffff04cf; + + machine_set_gpio_default(gpio); +} + +uint32_t +machine_at_cu430hx_gpio_handler(uint8_t write, uint32_t val) +{ + uint32_t ret = machine_get_gpio_default(); + + if (write) { + ret &= (val | 0xffff00ff); + ret = (ret & 0xffffffcf) | (val & 0x0000ff30); + if (machine_snd != NULL) switch ((val >> 4) & 0x03) { + case 0x00: + sb_vibra16c_onboard_relocate_base(0x0220, machine_snd); + break; + case 0x01: + sb_vibra16c_onboard_relocate_base(0x0260, machine_snd); + break; + case 0x02: + sb_vibra16c_onboard_relocate_base(0x0240, machine_snd); + break; + case 0x03: + sb_vibra16c_onboard_relocate_base(0x0280, machine_snd); + break; + } + machine_set_gpio(ret); + } else + ret = machine_get_gpio(); + + return ret; +} + /* Information about that machine on machine.h */ int machine_at_equium5200_init(const machine_t *model) @@ -258,6 +385,7 @@ machine_at_equium5200_init(const machine_t *model) return ret; machine_at_common_init_ex(model, 2); + machine_at_cu430hx_gpio_init(); pci_init(PCI_CONFIG_TYPE_1); pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); @@ -267,6 +395,10 @@ machine_at_equium5200_init(const machine_t *model) pci_register_slot(0x0B, PCI_CARD_NORMAL, 3, 4, 1, 2); pci_register_slot(0x07, PCI_CARD_SOUTHBRIDGE, 0, 0, 0, 0); pci_register_slot(0x0A, PCI_CARD_NORMAL, 3, 0, 0, 0); // riser + + if (sound_card_current[0] == SOUND_INTERNAL) + machine_snd = device_add(machine_get_snd_device(machine)); + device_add(&i430hx_device); device_add(&piix3_device); device_add(&keyboard_ps2_ami_pci_device); @@ -292,6 +424,7 @@ machine_at_pcv90_init(const machine_t *model) return ret; machine_at_common_init_ex(model, 2); + machine_at_ag430hx_gpio_init(); pci_init(PCI_CONFIG_TYPE_1); pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); @@ -548,6 +681,7 @@ machine_at_pb680_init(const machine_t *model) return ret; machine_at_common_init_ex(model, 2); + machine_at_nv430vx_gpio_init(); pci_init(PCI_CONFIG_TYPE_1); pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); @@ -556,6 +690,10 @@ machine_at_pb680_init(const machine_t *model) pci_register_slot(0x13, PCI_CARD_NORMAL, 2, 3, 4, 1); pci_register_slot(0x0B, PCI_CARD_NORMAL, 3, 4, 1, 2); pci_register_slot(0x07, PCI_CARD_SOUTHBRIDGE, 0, 0, 0, 0); + + if (gfxcard[0] == VID_INTERNAL) + device_add(machine_get_vid_device(machine)); + device_add(&i430vx_device); device_add(&piix3_device); device_add(&keyboard_ps2_ami_pci_device); diff --git a/src/machine/m_at_socket7_3v.c b/src/machine/m_at_socket7_3v.c index bc9ceed0a..7f090ca51 100644 --- a/src/machine/m_at_socket7_3v.c +++ b/src/machine/m_at_socket7_3v.c @@ -46,7 +46,7 @@ static void machine_at_thor_gpio_init(void) { - uint32_t gpio = 0xffffffff; + uint32_t gpio = 0xffffe1ff; /* Register 0x0079: */ /* Bit 7: 0 = Clear password, 1 = Keep password. */ @@ -61,8 +61,6 @@ machine_at_thor_gpio_init(void) /* Bit 1: 0 = Soft-off capable power supply present, 1 = Soft-off capable power supply absent. */ /* Bit 0: 0 = Reserved. */ /* NOTE: A bit is read as 1 if switch is off, and as 0 if switch is on. */ - gpio = 0xffffe1ff; - if (cpu_busspeed <= 50000000) gpio |= 0xffff10ff; else if ((cpu_busspeed > 50000000) && (cpu_busspeed <= 60000000)) @@ -74,7 +72,7 @@ machine_at_thor_gpio_init(void) } static void -machine_at_thor_common_init(const machine_t *model, UNUSED(int mr)) +machine_at_thor_common_init(const machine_t *model, int has_video) { machine_at_common_init_ex(model, 2); machine_at_thor_gpio_init(); @@ -88,8 +86,8 @@ machine_at_thor_common_init(const machine_t *model, UNUSED(int mr)) pci_register_slot(0x10, PCI_CARD_NORMAL, 4, 3, 2, 1); pci_register_slot(0x07, PCI_CARD_SOUTHBRIDGE, 0, 0, 0, 0); - if (gfxcard[0] == VID_INTERNAL) - device_add(&s3_phoenix_trio64vplus_onboard_pci_device); + if (has_video && (gfxcard[0] == VID_INTERNAL)) + device_add(machine_get_vid_device(machine)); device_add(&keyboard_ps2_intel_ami_pci_device); device_add(&i430fx_device); @@ -207,7 +205,7 @@ machine_at_thor_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_at_thor_common_init(model, 0); + machine_at_thor_common_init(model, 1); return ret; } @@ -223,7 +221,7 @@ machine_at_mrthor_init(const machine_t *model) if (bios_only || !ret) return ret; - machine_at_thor_common_init(model, 1); + machine_at_thor_common_init(model, 0); return ret; } diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 5c1486fa0..4a8a2a757 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -9071,7 +9071,7 @@ const machine_t machines[] = { .device = NULL, .fdc_device = NULL, .sio_device = NULL, - .vid_device = &s3_phoenix_trio64vplus_onboard_pci_device, + .vid_device = NULL, .snd_device = NULL, .net_device = NULL }, @@ -9099,7 +9099,7 @@ const machine_t machines[] = { .max_multi = 3.0 }, .bus_flags = MACHINE_PS2_PCI, - .flags = MACHINE_IDE_DUAL | MACHINE_VIDEO | MACHINE_APM | MACHINE_ACPI, + .flags = MACHINE_IDE_DUAL | MACHINE_VIDEO | MACHINE_SOUND | MACHINE_APM | MACHINE_ACPI, .ram = { .min = 8192, .max = 131072, @@ -9770,12 +9770,11 @@ const machine_t machines[] = { .device = NULL, .fdc_device = NULL, .sio_device = NULL, - .vid_device = NULL, + .vid_device = &s3_virge_375_pci_device, .snd_device = NULL, .net_device = NULL }, - /* OEM version of Intel TC430HX, has AMI MegaKey KBC firmware on the PC87306 - Super I/O chip */ + /* OEM version of Intel TC430HX, has AMI MegaKey KBC firmware on the PC87306 Super I/O chip. */ { .name = "[i430HX] Toshiba Infinia 7200", .internal_name = "infinia7200", @@ -9811,13 +9810,11 @@ const machine_t machines[] = { .device = NULL, .fdc_device = NULL, .sio_device = NULL, - .vid_device = NULL, + .vid_device = &s3_virge_375_pci_device, .snd_device = NULL, .net_device = NULL }, - /* According to tests from real hardware: This has AMI MegaKey KBC firmware on the - PC87306 Super I/O chip, command 0xA1 returns '5'. - Command 0xA0 copyright string: (C)1994 AMI . */ + /* OEM-only Intel CU430HX, has AMI MegaKey KBC firmware on the PC87306 Super I/O chip. */ { .name = "[i430HX] Toshiba Equium 5200D", .internal_name = "equium5200", @@ -9825,7 +9822,7 @@ const machine_t machines[] = { .chipset = MACHINE_CHIPSET_INTEL_430HX, .init = machine_at_equium5200_init, .p1_handler = NULL, - .gpio_handler = NULL, + .gpio_handler = machine_at_cu430hx_gpio_handler, .available_flag = MACHINE_AVAILABLE, .gpio_acpi_handler = NULL, .cpu = { @@ -9839,7 +9836,7 @@ const machine_t machines[] = { .max_multi = 3.0 }, .bus_flags = MACHINE_PS2_PCI, - .flags = MACHINE_IDE_DUAL | MACHINE_APM | MACHINE_ACPI, + .flags = MACHINE_IDE_DUAL | MACHINE_SOUND | MACHINE_APM | MACHINE_ACPI, .ram = { .min = 8192, .max = 196608, @@ -9854,7 +9851,7 @@ const machine_t machines[] = { .fdc_device = NULL, .sio_device = NULL, .vid_device = NULL, - .snd_device = NULL, + .snd_device = &sb_vibra16c_onboard_device, .net_device = NULL }, /* According to tests from real hardware: This has AMI MegaKey KBC firmware on the @@ -10288,7 +10285,7 @@ const machine_t machines[] = { .max_multi = 3.0 }, .bus_flags = MACHINE_PS2_PCI, - .flags = MACHINE_IDE_DUAL | MACHINE_APM | MACHINE_ACPI, + .flags = MACHINE_VIDEO | MACHINE_IDE_DUAL | MACHINE_APM | MACHINE_ACPI, .ram = { .min = 8192, .max = 131072, @@ -10302,7 +10299,7 @@ const machine_t machines[] = { .device = NULL, .fdc_device = NULL, .sio_device = NULL, - .vid_device = NULL, + .vid_device = &s3_phoenix_trio64vplus_onboard_pci_device, .snd_device = NULL, .net_device = NULL }, diff --git a/src/sound/snd_sb.c b/src/sound/snd_sb.c index a488110df..0f94cbaff 100644 --- a/src/sound/snd_sb.c +++ b/src/sound/snd_sb.c @@ -3690,6 +3690,20 @@ const device_t sb_vibra16s_onboard_device = { .config = sb_16_config }; +const device_t sb_vibra16c_onboard_device = { + .name = "Sound Blaster Vibra 16C (On-Board)", + .internal_name = "sb_vibra16c_onboard", + .flags = DEVICE_ISA | DEVICE_AT, + .local = 0, + .init = sb_16_init, + .close = sb_close, + .reset = NULL, + { .available = NULL }, + .speed_changed = sb_speed_changed, + .force_redraw = NULL, + .config = sb_16_config +}; + const device_t sb_16_reply_mca_device = { .name = "Sound Blaster 16 Reply MCA", .internal_name = "sb16_reply_mca",