diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index 6d893e8ac..3fb3f5f9c 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -372,15 +372,18 @@ extern int machine_has_mouse(void); extern int machine_is_sony(void); extern uint8_t machine_get_p1(void); +extern void machine_set_p1_default(uint8_t val); extern void machine_set_p1(uint8_t val); extern void machine_init_p1(void); extern uint8_t machine_handle_p1(uint8_t write, uint8_t val); extern uint32_t machine_get_gpio(void); +extern void machine_set_gpio_default(uint32_t val); extern void machine_set_gpio(uint32_t val); extern void machine_init_gpio(void); extern uint32_t machine_handle_gpio(uint8_t write, uint32_t val); extern uint32_t machine_get_gpio_acpi(void); -extern void machine_set_gpio_acpi(uint32_t gpio_val); +extern void machine_set_gpio_acpi_default(uint32_t val); +extern void machine_set_gpio_acpi(uint32_t val); extern void machine_init_gpio_acpi(void); extern uint32_t machine_handle_gpio_acpi(uint8_t write, uint32_t val); diff --git a/src/machine/m_at_socket5.c b/src/machine/m_at_socket5.c index a75d87a96..8681c6995 100644 --- a/src/machine/m_at_socket5.c +++ b/src/machine/m_at_socket5.c @@ -158,6 +158,41 @@ machine_at_apollo_init(const machine_t *model) return ret; } +static void +machine_at_zappa_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: No Connect. */ + /* Bit 1: No Connect. */ + /* 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. */ + gpio = 0xffffe6ff; + + if (cpu_busspeed <= 50000000) + gpio |= 0xffff10ff; + else if ((cpu_busspeed > 50000000) && (cpu_busspeed <= 60000000)) + gpio |= 0xffff18ff; + else if (cpu_busspeed > 60000000) + gpio |= 0xffff00ff; + + if (cpu_dmulti <= 1.5) + gpio |= 0xffff01ff; + else + gpio |= 0xffff00ff; + + machine_set_gpio_default(gpio); +} + int machine_at_zappa_init(const machine_t *model) { @@ -171,6 +206,7 @@ machine_at_zappa_init(const machine_t *model) return ret; machine_at_common_init_ex(model, 2); + machine_at_zappa_gpio_init(); pci_init(PCI_CONFIG_TYPE_1); pci_register_slot(0x00, PCI_CARD_NORTHBRIDGE, 0, 0, 0, 0); diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 10b62c8fe..4df1985c7 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -13278,10 +13278,16 @@ machine_get_p1(void) return machine_p1; } +void +machine_set_p1_default(uint8_t val) +{ + machine_p1 = machine_p1_default = val; +} + void machine_set_p1(uint8_t val) { - machine_p1 = machines[machine].kbc_p1 & val; + machine_p1 = machine_p1_default & val; } @@ -13294,7 +13300,7 @@ machine_handle_p1(uint8_t write, uint8_t val) ret = machines[machine].p1_handler(write, val); else { if (write) - machine_p1 = machines[machine].kbc_p1 & val; + machine_p1 = machine_p1_default & val; else ret = machine_p1; } @@ -13314,10 +13320,16 @@ machine_get_gpio(void) return machine_gpio; } +void +machine_set_gpio_default(uint32_t val) +{ + machine_gpio = machine_gpio_default = val; +} + void machine_set_gpio(uint32_t val) { - machine_gpio = machines[machine].gpio & val; + machine_gpio = machine_gpio_default & val; } uint32_t @@ -13329,7 +13341,7 @@ machine_handle_gpio(uint8_t write, uint32_t val) ret = machines[machine].gpio_handler(write, val); else { if (write) - machine_gpio = machines[machine].gpio & val; + machine_gpio = machine_gpio_default & val; else ret = machine_gpio; } @@ -13349,10 +13361,16 @@ machine_get_gpio_acpi(void) return machine_gpio_acpi; } +void +machine_set_gpio_acpi_default(uint32_t val) +{ + machine_gpio_acpi = machine_gpio_acpi_default = val; +} + void machine_set_gpio_acpi(uint32_t val) { - machine_gpio_acpi = machines[machine].gpio_acpi & val; + machine_gpio_acpi = machine_gpio_acpi_default & val; } uint32_t @@ -13364,7 +13382,7 @@ machine_handle_gpio_acpi(uint8_t write, uint32_t val) ret = machines[machine].gpio_acpi_handler(write, val); else { if (write) - machine_gpio_acpi = machines[machine].gpio_acpi & val; + machine_gpio_acpi = machine_gpio_acpi_default & val; else ret = machine_gpio_acpi; }