Fixed A20 reset issues. Patch from Greatpsycho.

This commit is contained in:
SarahW 2017-07-17 19:38:02 +01:00
commit 7531b95e83
5 changed files with 32 additions and 2 deletions

View file

@ -4,9 +4,12 @@
#include "mem.h"
#include "pit.h"
#include "timer.h"
#include "x86.h"
#include "intel.h"
static uint8_t batman_port_92;
uint8_t batman_brdconfig(uint16_t port, void *p)
{
// pclog("batman_brdconfig read port=%04x\n", port);
@ -16,12 +19,34 @@ uint8_t batman_brdconfig(uint16_t port, void *p)
return 0xff;
case 0x75:
return 0xdf;
case 0x92:
return batman_port_92;
}
return 0;
}
void batman_brdconfig_write(uint16_t port, uint8_t val, void *p)
{
switch (port)
{
case 0x92:
if ((mem_a20_alt ^ val) & 2)
{
mem_a20_alt = val & 2;
mem_a20_recalc();
}
if ((~batman_port_92 & val) & 1)
{
softresetx86();
cpu_set_edx();
}
batman_port_92 = val;
}
}
static uint16_t batman_timer_latch;
static int batman_timer = 0;
static void batman_timer_over(void *p)
{
batman_timer = 0;
@ -60,6 +85,8 @@ void intel_batman_init()
io_sethandler(0x0075, 0x0001, batman_brdconfig, NULL, NULL, NULL, NULL, NULL, NULL);
io_sethandler(0x0078, 0x0002, batman_timer_read, NULL, NULL, batman_timer_write, NULL, NULL, NULL);
io_sethandler(0x0092, 0x0001, batman_brdconfig, NULL, NULL, batman_brdconfig_write, NULL, NULL, NULL);
batman_port_92 = 0;
timer_add(batman_timer_over, &batman_timer, &batman_timer, NULL);
}