Migrate remaining machine-specific checks from internal name to init function

This commit is contained in:
RichardG867
2025-09-19 19:41:01 -03:00
parent 9b5f4ba7b1
commit 25146643f9
22 changed files with 47 additions and 45 deletions

View File

@@ -1222,7 +1222,7 @@ acpi_reg_write_intel(int size, uint16_t addr, uint8_t val, void *priv)
/* GPOREG - General Purpose Output Register (IO) */
if (size == 1) {
dev->regs.gporeg[addr & 3] = val;
if ((addr == 0x34) && !strcmp(machine_get_internal_name(), "cubx"))
if ((addr == 0x34) && (machines[machine].init == machine_at_cubx_init))
hdc_onboard_enabled = (val & 0x01);
}
break;
@@ -1749,7 +1749,7 @@ acpi_reg_write_sis_5595(int size, uint16_t addr, uint8_t val, void *priv)
break;
case 0x1c:
dev->regs.gpe_pin = ((dev->regs.gpe_pin & ~(0xff << shift32)) | ((val & 0xff) << shift32));
if (!strcmp(machine_get_internal_name(), "m747") && (val & 0x10) &&
if ((machines[machine].init == machine_at_m747_init) && (val & 0x10) &&
!(dev->regs.gpe_io & 0x00000010))
resetx86();
break;
@@ -2365,7 +2365,7 @@ acpi_reset(void *priv)
/* PC Chips M773:
- Bit 3: 80-conductor cable on unknown IDE channel (active low)
- Bit 1: 80-conductor cable on unknown IDE channel (active low) */
dev->regs.gpireg[0] = !strcmp(machine_get_internal_name(), "m773") ? 0xf5 : 0xff;
dev->regs.gpireg[0] = (machines[machine].init == machine_at_m773_init) ? 0xf5 : 0xff;
dev->regs.gpireg[1] = 0xff;
/* A-Trend ATC7020BXII:
- Bit 3: 80-conductor cable on secondary IDE channel (active low)
@@ -2399,9 +2399,9 @@ acpi_reset(void *priv)
- Bit 19: password cleared (active low).
*/
dev->regs.gpi_val = 0xfff57fc1;
if (!strcmp(machine_get_internal_name(), "ficva503a") || !strcmp(machine_get_internal_name(), "6via90ap"))
if ((machines[machine].init == machine_at_ficva503a_init) || (machines[machine].init == machine_at_6via90ap_init))
dev->regs.gpi_val |= 0x00000004;
else if (!strcmp(machine_get_internal_name(), "ficka6130"))
else if ((machines[machine].init == machine_at_ficka6130_init))
dev->regs.gpi_val |= 0x00080000;
/*
TriGem Delhi-III second GPI word:
@@ -2409,7 +2409,7 @@ acpi_reset(void *priv)
- Bit 6 = Password jumper (must be set);
- Bit 5 = Enable Setup (must be set).
*/
else if (!strcmp(machine_get_internal_name(), "delhi3"))
else if (machines[machine].init == machine_at_delhi3_init)
dev->regs.gpi_val |= 0x00008000;
}
@@ -2420,7 +2420,7 @@ acpi_reset(void *priv)
}
/* The Gateway Tomahawk requires the LID polarity bit to be set. */
if (!strcmp(machine_get_internal_name(), "tomahawk"))
if (machines[machine].init == machine_at_tomahawk_init)
dev->regs.glbctl |= 0x02000000;
acpi_rtc_status = 0;

View File

@@ -160,7 +160,7 @@ cs8220_init(UNUSED(const device_t *info))
/*
Dell System 200: 640 kB soldered on-board, any other RAM is expansion.
*/
if (!strcmp(machine_get_internal_name(), "dells200")) switch (mem_size) {
if ((machines[machine].init == machine_at_dells200_init)) switch (mem_size) {
default:
dev->ram_banks[2].virt = 0x00100000;
dev->ram_banks[2].phys = 0x000a0000;

View File

@@ -1549,7 +1549,7 @@ i4x0_read(int func, int addr, void *priv)
with the addition of bits 3 and 0. */
if ((func == 0) && (addr == 0x93) && ((dev->type == INTEL_440FX) || (dev->type == INTEL_440LX) || (dev->type == INTEL_440EX)))
ret = (ret & 0xf9) | (pci_read(0x0cf9, NULL) & 0x06);
else if ((func == 0) && (addr == 0x52) && (dev->type == INTEL_430TX) && !strcmp(machine_get_internal_name(), "tomahawk"))
else if ((func == 0) && (addr == 0x52) && (dev->type == INTEL_430TX) && (machines[machine].init == machine_at_tomahawk_init))
ret = 0xb2;
}

View File

@@ -1595,7 +1595,7 @@ piix_init(const device_t *info)
- Bit 4: CMOS clear jumper, must be clear;
- Bit 0: Password switch, must be clear.
*/
if (!strcmp(machine_get_internal_name(), "richmond"))
if (machines[machine].init == machine_at_richmond_init)
acpi_set_gpireg2_default(dev->acpi, 0xee);
else
acpi_set_gpireg2_default(dev->acpi, (dev->type > 4) ? 0xf1 : 0xdd);

View File

@@ -368,7 +368,7 @@ sio_config_read(uint16_t port, UNUSED(void *priv))
- 1, 0 = M;
- 1, 1 = M.
*/
if (!strcmp(machine_get_internal_name(), "opti560l"))
if (machines[machine].init == machine_at_opti560l_init)
ret = 0x20;
else
ret = 0xd3;

View File

@@ -766,7 +766,7 @@ sis_85c4xx_reset(void *priv)
if (dev->is_471) {
dev->regs[0x09] = 0x40;
if (!strcmp(machine_get_internal_name(), "vli486sv2g")) {
if (machines[machine].init == machine_at_vli486sv2g_init) {
if (mem_size_mb == 64)
dev->regs[0x09] |= 0x1f;
else
@@ -784,7 +784,7 @@ sis_85c4xx_reset(void *priv)
dev->regs[0x09] |= 0x34;
else
dev->regs[0x09] |= 0x35;
} else if (!strcmp(machine_get_internal_name(), "tg486g"))
} else if (machines[machine].init == machine_at_tg486g_init)
dev->regs[0x09] |= ram_tg486g[mem_size_mb];
else
dev->regs[0x09] |= ram_471[mem_size_mb];

View File

@@ -30,6 +30,8 @@
#include <86box/port_92.h>
#include <86box/chipset.h>
#define machine_at_prolineamt_init NULL /* checks for a removed machine */
typedef struct vl82c480_t {
uint8_t idx;
uint8_t regs[256];
@@ -132,8 +134,8 @@ vl82c480_write(uint16_t addr, uint8_t val, void *priv)
break;
case 0x02: case 0x03:
dev->regs[dev->idx] = val;
if (!strcmp(machine_get_internal_name(), "martin") ||
!strcmp(machine_get_internal_name(), "prolineamt"))
if ((machines[machine].init == machine_at_martin_init) ||
(machines[machine].init == machine_at_prolineamt_init))
vl82c480_recalc_banks(dev);
break;
case 0x04:
@@ -220,9 +222,9 @@ vl82c480_init(const device_t *info)
vl82c480_t *dev = (vl82c480_t *) calloc(1, sizeof(vl82c480_t));
uint32_t sizes[8] = { 0, 0, 1024, 2048, 4096, 8192, 16384, 32768 };
uint32_t ms = mem_size;
uint8_t min_i = !strcmp(machine_get_internal_name(), "prolineamt") ? 1 : 0;
uint8_t min_j = !strcmp(machine_get_internal_name(), "prolineamt") ? 4 : 2;
uint8_t max_j = !strcmp(machine_get_internal_name(), "prolineamt") ? 8 : 7;
uint8_t min_i = (machines[machine].init == machine_at_prolineamt_init) ? 1 : 0;
uint8_t min_j = (machines[machine].init == machine_at_prolineamt_init) ? 4 : 2;
uint8_t max_j = (machines[machine].init == machine_at_prolineamt_init) ? 8 : 7;
dev->regs[0x00] = info->local;
dev->regs[0x01] = 0xff;
@@ -233,7 +235,7 @@ vl82c480_init(const device_t *info)
dev->regs[0x07] = 0x21;
dev->regs[0x08] = 0x38;
if (!strcmp(machine_get_internal_name(), "prolineamt")) {
if (machines[machine].init == machine_at_prolineamt_init) {
dev->banks[0] = 4096;
/* Bank 0 is ignored if 64 MB is installed. */

View File

@@ -572,7 +572,7 @@ load_input_devices(void)
p = ini_section_get_string(cat, "keyboard_type", NULL);
if (p != NULL)
keyboard_type = keyboard_get_from_internal_name(p);
else if (strstr(machine_get_internal_name(), "pc5086"))
else if (machines[machine].init == machine_xt_pc5086_init)
keyboard_type = KEYBOARD_TYPE_PC_XT;
else if (machine_has_bus(machine, MACHINE_BUS_PS2_PORTS)) {
if (machine_has_flags(machine, MACHINE_KEYBOARD_JIS))

View File

@@ -523,7 +523,7 @@ isartc_init(const device_t *info)
{
rtcdev_t *dev;
int is_at = IS_AT(machine);
is_at = is_at || !strcmp(machine_get_internal_name(), "xi8088");
is_at = is_at || (machines[machine].init == machine_xt_xi8088_init);
/* Create a device instance. */
dev = (rtcdev_t *) calloc(1, sizeof(rtcdev_t));

View File

@@ -806,15 +806,15 @@ write_p2(atkbc_t *dev, uint8_t val)
cpu_set_edx();
flushmmucache();
if ((kbc_ven == KBC_VEN_ALI) ||
!strcmp(machine_get_internal_name(), "spc7700plw") ||
!strcmp(machine_get_internal_name(), "pl4600c"))
(machines[machine].init == machine_at_spc7700plw_init) ||
(machines[machine].init == machine_at_pl4600c_init))
smbase = 0x00030000;
/* Yes, this is a hack, but until someone gets ahold of the real PCD-2L
and can find out what they actually did to make it boot from FFFFF0
correctly despite A20 being gated when the CPU is reset, this will
have to do. */
if ((kbc_ven == KBC_VEN_SIEMENS) || !strcmp(machine_get_internal_name(), "acera1g"))
if ((kbc_ven == KBC_VEN_SIEMENS) || (machines[machine].init == machine_at_acera1g_init))
is486 ? loadcs(0xf000) : loadcs_2386(0xf000);
}
}
@@ -1187,7 +1187,7 @@ write_cmd_ami(void *priv, uint8_t val)
kbc_at_log("ATkbc: set KBC lines P22-P23 (P2 bits 2-3) low\n");
if (!(dev->flags & DEVICE_PCI))
write_p2(dev, dev->p2 & ~(4 << (val & 0x01)));
if (strstr(machine_get_internal_name(), "sb486pv") != NULL)
if (machines[machine].init == machine_at_sb486pv_init)
kbc_delay_to_ob(dev, 0x03, 0, 0x00);
else
kbc_delay_to_ob(dev, dev->ob, 0, 0x00);
@@ -2627,7 +2627,7 @@ kbc_at_process_cmd(void *priv)
if (dev->ib == 0xbb)
break;
if (strstr(machine_get_internal_name(), "pb41") != NULL)
if (machines[machine].init == machine_at_pb410a_init)
cpu_override_dynarec = 1;
if (dev->misc_flags & FLAG_PS2) {
@@ -2759,7 +2759,7 @@ kbc_at_port_1_read(uint16_t port, void *priv)
*/
if (!(dev->misc_flags & FLAG_PS2) && (dev->irq[0] != 0xffff))
picintclevel(1 << dev->irq[0], &dev->irq_state);
if ((strstr(machine_get_internal_name(), "pb41") != NULL) && (cpu_override_dynarec == 1))
if ((machines[machine].init == machine_at_pb410a_init) && (cpu_override_dynarec == 1))
cpu_override_dynarec = 0;
kbc_at_log("ATkbc: [%04X:%08X] read (%04X) = %02X\n", CS, cpu_state.pc, port, ret);

View File

@@ -1008,7 +1008,7 @@ dma_page_read(uint16_t addr, UNUSED(void *priv))
if (((addr & 0xfffc) == 0x80) && (CS == 0xf000) &&
((cpu_state.pc & 0xfffffff8) == 0x00007278) &&
!strcmp(machine_get_internal_name(), "megapc")) switch (addr) {
(machines[machine].init == machine_at_wd76c10_init)) switch (addr) {
/* The Amstrad MegaPC Quadtel BIOS times a sequence of:
mov ax,di
div bx

View File

@@ -2402,10 +2402,10 @@ fdc_reset(void *priv)
need to use a dual-RPM 5.25" drive - but hey, that finally gets those
drives some usage as well.
*/
fdc_update_drvrate(fdc, 0, !strcmp(machine_get_internal_name(), "if386sx"));
fdc_update_drvrate(fdc, 1, !strcmp(machine_get_internal_name(), "if386sx"));
fdc_update_drvrate(fdc, 2, !strcmp(machine_get_internal_name(), "if386sx"));
fdc_update_drvrate(fdc, 3, !strcmp(machine_get_internal_name(), "if386sx"));
fdc_update_drvrate(fdc, 0, (machines[machine].init == machine_at_if386sx_init));
fdc_update_drvrate(fdc, 1, (machines[machine].init == machine_at_if386sx_init));
fdc_update_drvrate(fdc, 2, (machines[machine].init == machine_at_if386sx_init));
fdc_update_drvrate(fdc, 3, (machines[machine].init == machine_at_if386sx_init));
fdc_update_drv2en(fdc, 1);
fdc_update_rates(fdc);

View File

@@ -19531,7 +19531,7 @@ machine_has_bus(int m, int bus_flags)
if ((bus_flags & MACHINE_BUS_XT_KBD) &&
!(machines[m].bus_flags & MACHINE_BUS_ISA16) &&
(!(machines[m].bus_flags & MACHINE_BUS_PS2_PORTS) ||
!(strcmp(machine_get_internal_name(), "pc5086"))))
(machines[m].init == machine_xt_pc5086_init)))
ret |= MACHINE_BUS_XT_KBD;
#ifdef ONLY_AT_KBD_ON_AT_KBC

View File

@@ -524,7 +524,7 @@ sst_init(const device_t *info)
dev->is_39 = 1;
dev->size = info->local & 0xffff0000;
if ((dev->size == 0x20000) && (strstr(machine_get_internal_name_ex(machine), "xi8088")) && !xi8088_bios_128kb())
if ((dev->size == 0x20000) && ((machines[machine].init == machine_xt_xi8088_init) && !xi8088_bios_128kb()))
dev->size = 0x10000;
dev->mask = dev->size - 1;

View File

@@ -1213,7 +1213,7 @@ nvr_at_init(const device_t *info)
}
/* This is a hack but it is required for the machine to boot properly, no idea why. */
if (nvr->is_new && !strcmp(machine_get_internal_name(), "spitfire"))
if (nvr->is_new && (machines[machine].init == machine_at_spitfire_init))
nvr->regs[0x33] = nvr->regs[0x34] = 0xff;
return nvr;

View File

@@ -254,7 +254,7 @@ void
pic_reset(void)
{
int is_at = IS_AT(machine);
is_at = is_at || !strcmp(machine_get_internal_name(), "xi8088");
is_at = is_at || (machines[machine].init == machine_xt_xi8088_init);
memset(&pic, 0, sizeof(pic_t));
memset(&pic2, 0, sizeof(pic_t));

View File

@@ -123,7 +123,7 @@ SettingsInput::onCurrentMachineChanged(int machineId)
int ikbd = (i == KEYBOARD_TYPE_INTERNAL);
int pc5086_filter = (strstr(keyboard_get_internal_name(i), "ps") &&
strstr(machine_get_internal_name_ex(machineId), "pc5086"));
machines[machineId].init == machine_xt_pc5086_init);
if ((ikbd != has_int_kbd) || !device_is_valid(dev, machineId) || pc5086_filter)
continue;

View File

@@ -349,7 +349,7 @@ f82c710_init(const device_t *info)
{
upc_t *dev = (upc_t *) calloc(1, sizeof(upc_t));
if (strstr(machine_get_internal_name(), "5086") != NULL)
if (machines[machine].init == machine_xt_pc5086_init)
dev->fdc = device_add(&fdc_at_actlow_device);
else
dev->fdc = device_add(&fdc_at_device);

View File

@@ -143,7 +143,7 @@ static __inline uint8_t
fdc37c93x_do_read_gp(fdc37c93x_t *dev, int reg, int bit)
{
/* Update bit 2 on the Acer V35N according to the selected graphics card type. */
if ((reg == 2) && (strstr(machine_get_internal_name(), "acer") != NULL))
if ((reg == 2) && !strncmp(machine_get_internal_name(), "acer", 4))
dev->gpio_pulldn[reg] = (dev->gpio_pulldn[reg] & 0xfb) | (video_is_mda() ? 0x00 : 0x04);
return dev->gpio_regs[reg] & dev->gpio_pulldn[reg] & (1 << bit);
@@ -1812,7 +1812,7 @@ fdc37c93x_reset(void *priv)
memset(dev->gpio_pulldn, 0xff, 8);
/* Acer V62X requires bit 0 to be clear to not be stuck in "clear password" mode. */
if (!strcmp(machine_get_internal_name(), "vectra54")) {
if (machines[machine].init == machine_at_vectra54_init) {
dev->gpio_pulldn[1] = 0x40;
/*
@@ -1850,12 +1850,12 @@ fdc37c93x_reset(void *priv)
dev->gpio_pulldn[1] |= 0x00;
else if (cpu_dmulti > 2.5)
dev->gpio_pulldn[1] |= 0x80;
} else if (!strcmp(machine_get_internal_name(), "acerv62x"))
} else if (machines[machine].init == machine_at_acerv62x_init)
dev->gpio_pulldn[1] = 0xfe;
else
dev->gpio_pulldn[1] = (dev->chip_id == 0x30) ? 0xff : 0xfd;
if (strstr(machine_get_internal_name(), "acer") != NULL)
if (!strncmp(machine_get_internal_name(), "acer", 4))
/* Bit 2 on the Acer V35N is the text/graphics toggle, bits 1 and 3 = ????. */
dev->gpio_pulldn[2] = 0x10;

View File

@@ -134,7 +134,7 @@ vl82c113_init(UNUSED(const device_t *info))
{
vl82c113_t *dev = (vl82c113_t *) calloc(1, sizeof(vl82c113_t));
if (!strcmp(machine_get_internal_name(), "martin"))
if (machines[machine].init == machine_at_martin_init)
dev->nvr = device_add(&martin_nvr_device);
else
dev->nvr = device_add(&amstrad_megapc_nvr_device);

View File

@@ -527,7 +527,7 @@ w83877_init(const device_t *info)
dev->has_ide = (info->local >> 16) & 0xff;
if (!strcmp(machine_get_internal_name(), "ficpa2012")) {
if (machines[machine].init == machine_at_ficpa2012_init) {
dev->dma_map[0] = 4;
dev->dma_map[1] = 3;
dev->dma_map[2] = 1;

View File

@@ -4339,7 +4339,7 @@ gd54xx_init(const device_t *info)
case CIRRUS_ID_CLGD5436:
if ((info->local & 0x200) &&
!strstr(machine_get_internal_name(), "sb486pv")) {
(machines[machine].init == machine_at_sb486pv_init)) {
romfn = NULL;
gd54xx->has_bios = 0;
} else