Fixed the PS/2 keyboard and mouse latch initialization - now the mouse latch actually works, fixes mouse in AMI WinBios Setup and 8603 errors on MCA IBM PS/2's.

This commit is contained in:
OBattler
2023-04-12 20:23:31 +02:00
parent 958bd387c1
commit b753c675fb
2 changed files with 25 additions and 11 deletions

View File

@@ -619,6 +619,8 @@ static const scancode scancode_set3[512] = {
// clang-format on
};
#define USE_RESET_DELAY 1
// #define ENABLE_KEYBOARD_AT_LOG 1
#ifdef ENABLE_KEYBOARD_AT_LOG
int keyboard_at_do_log = ENABLE_KEYBOARD_AT_LOG;
@@ -1532,6 +1534,7 @@ write_output(atkbd_t *dev, uint8_t val)
uint8_t kbc_ven = dev->flags & KBC_VEN_MASK;
#if 0
/* PS/2: Handle IRQ's. */
if ((dev->flags & KBC_TYPE_MASK) >= KBC_TYPE_PS2_NOREF) {
/* IRQ 12 */
@@ -1540,6 +1543,7 @@ write_output(atkbd_t *dev, uint8_t val)
/* IRQ 1 */
picint_common(1 << 1, 0, val & 0x10);
}
#endif
/* AT, PS/2: Handle A20. */
if ((old ^ val) & 0x02) { /* A20 enable change */
@@ -2232,15 +2236,23 @@ kbd_key_reset(atkbd_t *dev, int do_fa)
dev->sc_or = 0;
if (do_fa)
if (do_fa) {
add_data_kbd_front(dev, 0xfa);
add_data_kbd_front(dev, 0xaa);
}
#ifdef USE_RESET_DELAY
dev->reset_delay = RESET_DELAY_TIME;
if (do_fa)
dev->kbd_state = DEV_STATE_MAIN_WANT_RESET;
else
dev->kbd_state = DEV_STATE_RESET;
#else
if (!do_fa)
dev->kbd_state = DEV_STATE_MAIN_1;
#endif
}
static void
@@ -2592,7 +2604,7 @@ kbc_process_cmd(void *priv)
case 0xdd: /* disable A20 address line */
case 0xdf: /* enable A20 address line */
kbd_log("ATkbc: %sable A20\n", (dev->ib == 0xdd) ? "dis" : "en");
write_output(dev, (dev->output_port & 0xfd) | (dev->ib & 0x02));
write_output_fast_a20(dev, (dev->output_port & 0xfd) | (dev->ib & 0x02));
break;
case 0xe0: /* read test inputs */
@@ -2827,8 +2839,10 @@ kbd_reset(void *priv)
/* Stage 1. */
dev->status = (dev->status & 0x0f) | (dev->input_port & 0xf0);
#ifdef USE_RESET_DELAY
/* Wait for command AA. */
dev->kbc_state = KBC_STATE_RESET;
#endif
/* Reset the keyboard. */
kbd_key_reset(dev, 0);

View File

@@ -395,7 +395,7 @@ pic_latch_read(uint16_t addr, void *priv)
{
uint8_t ret = 0xff;
pic_log("pic_latch_read(): %02X%02X\n", pic2.lines & 0x10, pic.lines & 0x02);
pic_log("pic_latch_read(%i, %i): %02X%02X\n", kbd_latch, mouse_latch, pic2.lines & 0x10, pic.lines & 0x02);
if (kbd_latch && (pic.lines & 0x02))
picintc(0x0002);
@@ -542,10 +542,10 @@ pic_kbd_latch(int enable)
{
pic_log("PIC keyboard latch now %sabled\n", enable ? "en" : "dis");
if ((enable | mouse_latch) != (kbd_latch | mouse_latch)) {
kbd_latch = enable;
io_handler(kbd_latch | mouse_latch, 0x0060, 0x0001, pic_latch_read, NULL, NULL, NULL, NULL, NULL, NULL);
}
if (!!(enable | mouse_latch) != !!(kbd_latch | mouse_latch))
io_handler(!!(enable | mouse_latch), 0x0060, 0x0001, pic_latch_read, NULL, NULL, NULL, NULL, NULL, NULL);
kbd_latch = !!enable;
if (!enable)
picintc(0x0002);
@@ -556,10 +556,10 @@ pic_mouse_latch(int enable)
{
pic_log("PIC mouse latch now %sabled\n", enable ? "en" : "dis");
if ((kbd_latch | enable) != (kbd_latch | mouse_latch)) {
mouse_latch = enable;
io_handler(kbd_latch | mouse_latch, 0x0060, 0x0001, pic_latch_read, NULL, NULL, NULL, NULL, NULL, NULL);
}
if (!!(kbd_latch | enable) != !!(kbd_latch | mouse_latch))
io_handler(!!(kbd_latch | enable), 0x0060, 0x0001, pic_latch_read, NULL, NULL, NULL, NULL, NULL, NULL);
mouse_latch = !!enable;
if (!enable)
picintc(0x1000);