Keyboard controller file split and assorted clean-ups and fixes
This commit is contained in:
@@ -687,14 +687,13 @@ acpi_reg_write_common_regs(int size, uint16_t addr, uint8_t val, void *p)
|
||||
}
|
||||
|
||||
if (sus_typ & SUS_RESET_PCI)
|
||||
device_reset_all_pci();
|
||||
device_reset_all(DEVICE_PCI);
|
||||
|
||||
if (sus_typ & SUS_RESET_CPU)
|
||||
cpu_alt_reset = 0;
|
||||
|
||||
if (sus_typ & SUS_RESET_PCI) {
|
||||
pci_reset();
|
||||
keyboard_at_reset();
|
||||
|
||||
mem_a20_alt = 0;
|
||||
mem_a20_recalc();
|
||||
|
@@ -153,7 +153,7 @@ ali1533_write(int func, int addr, uint8_t val, void *priv)
|
||||
case 0x41:
|
||||
/* TODO: Bit 7 selects keyboard controller type:
|
||||
0 = AT, 1 = PS/2 */
|
||||
pic_kbd_latch(!!(val & 0x80));
|
||||
pic_kbd_latch(1);
|
||||
pic_mouse_latch(!!(val & 0x40));
|
||||
dev->pci_conf[addr] = val & 0xbf;
|
||||
break;
|
||||
|
@@ -780,8 +780,8 @@ smram_restore_state_p6(uint32_t *saved_state)
|
||||
cpu_state.seg_gs.ar_high = (saved_state[SMRAM_FIELD_P6_GS_SELECTOR_AR] >> 24) & 0xff;
|
||||
smm_seg_load(&cpu_state.seg_gs);
|
||||
|
||||
mem_a20_alt = 0;
|
||||
keyboard_at_set_a20_key(!saved_state[SMRAM_FIELD_P6_A20M]);
|
||||
mem_a20_alt = 0x00;
|
||||
mem_a20_key = saved_state[SMRAM_FIELD_P6_A20M] ? 0x00 : 0x02;
|
||||
mem_a20_recalc();
|
||||
|
||||
if (SMM_REVISION_ID & SMM_SMBASE_RELOCATION)
|
||||
|
@@ -245,7 +245,7 @@ reset_common(int hard)
|
||||
/* TODO: Hack, but will do for time being, because all AT machines currently are 286+,
|
||||
and vice-versa. */
|
||||
dma_set_at(is286);
|
||||
device_reset_all();
|
||||
device_reset_all(DEVICE_ALL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ reset_common(int hard)
|
||||
|
||||
/* If we have an AT or PS/2 keyboard controller, make sure the A20 state
|
||||
is correct. */
|
||||
kbc_at_a20_reset();
|
||||
device_reset_all(DEVICE_KBC);
|
||||
}
|
||||
|
||||
if (!is286)
|
||||
@@ -359,7 +359,7 @@ hardresetx86(void)
|
||||
/* TODO: Hack, but will do for time being, because all AT machines currently are 286+,
|
||||
and vice-versa. */
|
||||
dma_set_at(is286);
|
||||
device_reset_all();
|
||||
device_reset_all(DEVICE_ALL);
|
||||
|
||||
cpu_alt_reset = 0;
|
||||
|
||||
|
18
src/device.c
18
src/device.c
@@ -315,27 +315,13 @@ device_close_all(void)
|
||||
}
|
||||
|
||||
void
|
||||
device_reset_all(void)
|
||||
device_reset_all(uint32_t match_flags)
|
||||
{
|
||||
int c;
|
||||
|
||||
for (c = 0; c < DEVICE_MAX; c++) {
|
||||
if (devices[c] != NULL) {
|
||||
if (devices[c]->reset != NULL)
|
||||
devices[c]->reset(device_priv[c]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Reset all attached PCI devices - needed for PCI turbo reset control. */
|
||||
void
|
||||
device_reset_all_pci(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
for (c = 0; c < DEVICE_MAX; c++) {
|
||||
if (devices[c] != NULL) {
|
||||
if ((devices[c]->reset != NULL) && (devices[c]->flags & DEVICE_PCI))
|
||||
if ((devices[c]->reset != NULL) && (devices[c]->flags & match_flags))
|
||||
devices[c]->reset(device_priv[c]);
|
||||
}
|
||||
}
|
||||
|
@@ -18,7 +18,9 @@
|
||||
add_library(dev OBJECT bugger.c cassette.c cartridge.c hasp.c hwm.c hwm_lm75.c hwm_lm78.c hwm_gl518sm.c
|
||||
hwm_vt82c686.c ibm_5161.c isamem.c isartc.c ../lpt.c pci_bridge.c
|
||||
postcard.c serial.c clock_ics9xxx.c isapnp.c i2c.c i2c_gpio.c
|
||||
smbus_piix4.c smbus_ali7101.c keyboard.c keyboard_xt.c keyboard_at.c
|
||||
smbus_piix4.c smbus_ali7101.c keyboard.c keyboard_xt.c
|
||||
kbc_at.c kbc_at_dev.c
|
||||
keyboard_at.c
|
||||
mouse.c mouse_bus.c mouse_serial.c mouse_ps2.c phoenix_486_jumper.c
|
||||
mouse_wacom_tablet.c serial_passthrough.c)
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -30,22 +30,7 @@ enum {
|
||||
MODE_ECHO
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
const char *name; /* name of this device */
|
||||
int8_t type; /* type of this device */
|
||||
|
||||
int mode;
|
||||
|
||||
uint16_t flags;
|
||||
uint8_t resolution;
|
||||
uint8_t sample_rate;
|
||||
|
||||
uint8_t command;
|
||||
|
||||
int x, y, z, b;
|
||||
|
||||
uint8_t last_data[6];
|
||||
} mouse_t;
|
||||
#define FLAG_EXPLORER 0x200 /* Has 5 buttons */
|
||||
#define FLAG_5BTN 0x100 /* using Intellimouse Optical mode */
|
||||
#define FLAG_INTELLI 0x80 /* device is IntelliMouse */
|
||||
#define FLAG_INTMODE 0x40 /* using Intellimouse mode */
|
||||
@@ -76,13 +61,13 @@ mouse_ps2_log(const char *fmt, ...)
|
||||
void
|
||||
mouse_clear_data(void *priv)
|
||||
{
|
||||
mouse_t *dev = (mouse_t *) priv;
|
||||
atkbc_dev_t *dev = (atkbc_dev_t *) priv;
|
||||
|
||||
dev->flags &= ~FLAG_CTRLDAT;
|
||||
}
|
||||
|
||||
static void
|
||||
ps2_report_coordinates(mouse_t *dev, int cmd)
|
||||
ps2_report_coordinates(atkbc_dev_t *dev, int main)
|
||||
{
|
||||
uint8_t buff[3] = { 0x08, 0x00, 0x00 };
|
||||
int temp_z;
|
||||
@@ -123,15 +108,9 @@ ps2_report_coordinates(mouse_t *dev, int cmd)
|
||||
buff[1] = (dev->x & 0xff);
|
||||
buff[2] = (dev->y & 0xff);
|
||||
|
||||
if (cmd) {
|
||||
keyboard_at_adddata_mouse_cmd(buff[0]);
|
||||
keyboard_at_adddata_mouse_cmd(buff[1]);
|
||||
keyboard_at_adddata_mouse_cmd(buff[2]);
|
||||
} else {
|
||||
keyboard_at_adddata_mouse(buff[0]);
|
||||
keyboard_at_adddata_mouse(buff[1]);
|
||||
keyboard_at_adddata_mouse(buff[2]);
|
||||
}
|
||||
kbc_at_dev_queue_add(dev, buff[0], main);
|
||||
kbc_at_dev_queue_add(dev, buff[1], main);
|
||||
kbc_at_dev_queue_add(dev, buff[2], main);
|
||||
if (dev->flags & FLAG_INTMODE) {
|
||||
temp_z = dev->z & 0x0f;
|
||||
if ((dev->flags & FLAG_5BTN)) {
|
||||
@@ -144,62 +123,94 @@ ps2_report_coordinates(mouse_t *dev, int cmd)
|
||||
if (temp_z & 0x08)
|
||||
temp_z |= 0xf0;
|
||||
}
|
||||
if (cmd)
|
||||
keyboard_at_adddata_mouse_cmd(temp_z);
|
||||
else
|
||||
keyboard_at_adddata_mouse(temp_z);
|
||||
kbc_at_dev_queue_add(dev, temp_z, main);
|
||||
}
|
||||
|
||||
dev->x = dev->y = dev->z = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
ps2_write(uint8_t val, void *priv)
|
||||
ps2_set_defaults(atkbc_dev_t *dev)
|
||||
{
|
||||
mouse_t *dev = (mouse_t *) priv;
|
||||
uint8_t temp;
|
||||
dev->mode = MODE_STREAM;
|
||||
dev->rate = 1;
|
||||
dev->flags &= (0x88 | FLAG_ENABLED);
|
||||
}
|
||||
|
||||
static void
|
||||
ps2_bat(void *priv)
|
||||
{
|
||||
atkbc_dev_t *dev = (atkbc_dev_t *) priv;
|
||||
|
||||
ps2_set_defaults(dev);
|
||||
|
||||
mouse_scan = 1;
|
||||
dev->flags |= FLAG_ENABLED;
|
||||
|
||||
kbc_at_dev_queue_add(dev, 0xaa, 0);
|
||||
kbc_at_dev_queue_add(dev, 0x00, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
ps2_write(void *priv)
|
||||
{
|
||||
atkbc_dev_t *dev = (atkbc_dev_t *) priv;
|
||||
uint8_t temp, val;
|
||||
|
||||
if (dev->port == NULL)
|
||||
return;
|
||||
|
||||
val = dev->port->dat;
|
||||
|
||||
dev->state = DEV_STATE_MAIN_OUT;
|
||||
|
||||
if (dev->flags & FLAG_CTRLDAT) {
|
||||
dev->flags &= ~FLAG_CTRLDAT;
|
||||
|
||||
if (val == 0xff)
|
||||
goto mouse_reset;
|
||||
|
||||
switch (dev->command) {
|
||||
kbc_at_dev_reset(dev, 1);
|
||||
else switch (dev->command) {
|
||||
case 0xe8: /* set mouse resolution */
|
||||
dev->resolution = val;
|
||||
keyboard_at_adddata_mouse_cmd(0xfa);
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||
mouse_ps2_log("%s: Set mouse resolution [%02X]\n", dev->name, val);
|
||||
break;
|
||||
|
||||
case 0xf3: /* set sample rate */
|
||||
dev->sample_rate = val;
|
||||
keyboard_at_adddata_mouse_cmd(0xfa); /* Command response */
|
||||
dev->rate = val;
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0); /* Command response */
|
||||
mouse_ps2_log("%s: Set sample rate [%02X]\n", dev->name, val);
|
||||
break;
|
||||
|
||||
default:
|
||||
keyboard_at_adddata_mouse_cmd(0xfc);
|
||||
kbc_at_dev_queue_add(dev, 0xfc, 0);
|
||||
}
|
||||
} else {
|
||||
dev->command = val;
|
||||
|
||||
switch (dev->command) {
|
||||
case 0xe6: /* set scaling to 1:1 */
|
||||
mouse_ps2_log("%s: Set scaling to 1:1\n", dev->name);
|
||||
dev->flags &= ~FLAG_SCALED;
|
||||
keyboard_at_adddata_mouse_cmd(0xfa);
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||
break;
|
||||
|
||||
case 0xe7: /* set scaling to 2:1 */
|
||||
mouse_ps2_log("%s: Set scaling to 2:1\n", dev->name);
|
||||
dev->flags |= FLAG_SCALED;
|
||||
keyboard_at_adddata_mouse_cmd(0xfa);
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||
break;
|
||||
|
||||
case 0xe8: /* set mouse resolution */
|
||||
mouse_ps2_log("%s: Set mouse resolution\n", dev->name);
|
||||
dev->flags |= FLAG_CTRLDAT;
|
||||
keyboard_at_adddata_mouse_cmd(0xfa);
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||
dev->state = DEV_STATE_MAIN_WANT_IN;
|
||||
break;
|
||||
|
||||
case 0xe9: /* status request */
|
||||
keyboard_at_adddata_mouse_cmd(0xfa);
|
||||
mouse_ps2_log("%s: Status request\n", dev->name);
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||
temp = (dev->flags & 0x30);
|
||||
if (mouse_buttons & 1)
|
||||
temp |= 4;
|
||||
@@ -207,64 +218,68 @@ ps2_write(uint8_t val, void *priv)
|
||||
temp |= 1;
|
||||
if ((mouse_buttons & 4) && (dev->flags & FLAG_INTELLI))
|
||||
temp |= 2;
|
||||
keyboard_at_adddata_mouse_cmd(temp);
|
||||
keyboard_at_adddata_mouse_cmd(dev->resolution);
|
||||
keyboard_at_adddata_mouse_cmd(dev->sample_rate);
|
||||
kbc_at_dev_queue_add(dev, temp, 0);
|
||||
kbc_at_dev_queue_add(dev, dev->resolution, 0);
|
||||
kbc_at_dev_queue_add(dev, dev->rate, 0);
|
||||
break;
|
||||
|
||||
case 0xea: /* set stream */
|
||||
mouse_ps2_log("%s: Set stream\n", dev->name);
|
||||
dev->flags &= ~FLAG_CTRLDAT;
|
||||
mouse_scan = 1;
|
||||
keyboard_at_adddata_mouse_cmd(0xfa); /* ACK for command byte */
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0); /* ACK for command byte */
|
||||
break;
|
||||
|
||||
case 0xeb: /* Get mouse data */
|
||||
keyboard_at_adddata_mouse_cmd(0xfa);
|
||||
mouse_ps2_log("%s: Get mouse data\n", dev->name);
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||
|
||||
ps2_report_coordinates(dev, 1);
|
||||
ps2_report_coordinates(dev, 0);
|
||||
break;
|
||||
|
||||
case 0xf2: /* read ID */
|
||||
keyboard_at_adddata_mouse_cmd(0xfa);
|
||||
mouse_ps2_log("%s: Read ID\n", dev->name);
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||
if (dev->flags & FLAG_INTMODE)
|
||||
keyboard_at_adddata_mouse_cmd((dev->flags & FLAG_5BTN) ? 0x04 : 0x03);
|
||||
kbc_at_dev_queue_add(dev, (dev->flags & FLAG_5BTN) ? 0x04 : 0x03, 0);
|
||||
else
|
||||
keyboard_at_adddata_mouse_cmd(0x00);
|
||||
kbc_at_dev_queue_add(dev, 0x00, 0);
|
||||
break;
|
||||
|
||||
case 0xf3: /* set command mode */
|
||||
case 0xf3: /* set sample rate */
|
||||
mouse_ps2_log("%s: Set sample rate\n", dev->name);
|
||||
dev->flags |= FLAG_CTRLDAT;
|
||||
keyboard_at_adddata_mouse_cmd(0xfa); /* ACK for command byte */
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0); /* ACK for command byte */
|
||||
dev->state = DEV_STATE_MAIN_WANT_IN;
|
||||
break;
|
||||
|
||||
case 0xf4: /* enable */
|
||||
mouse_ps2_log("%s: Enable\n", dev->name);
|
||||
dev->flags |= FLAG_ENABLED;
|
||||
mouse_scan = 1;
|
||||
keyboard_at_adddata_mouse_cmd(0xfa);
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||
break;
|
||||
|
||||
case 0xf5: /* disable */
|
||||
mouse_ps2_log("%s: Disable\n", dev->name);
|
||||
dev->flags &= ~FLAG_ENABLED;
|
||||
mouse_scan = 0;
|
||||
keyboard_at_adddata_mouse_cmd(0xfa);
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||
break;
|
||||
|
||||
case 0xf6: /* set defaults */
|
||||
mouse_ps2_log("%s: Set defaults\n", dev->name);
|
||||
ps2_set_defaults(dev);
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||
break;
|
||||
|
||||
case 0xff: /* reset */
|
||||
mouse_reset:
|
||||
dev->mode = MODE_STREAM;
|
||||
dev->flags &= 0x88;
|
||||
mouse_scan = 1;
|
||||
keyboard_at_mouse_reset();
|
||||
keyboard_at_adddata_mouse_cmd(0xfa);
|
||||
if (dev->command == 0xff) {
|
||||
keyboard_at_adddata_mouse_cmd(0xaa);
|
||||
keyboard_at_adddata_mouse_cmd(0x00);
|
||||
}
|
||||
mouse_ps2_log("%s: Reset\n", dev->name);
|
||||
kbc_at_dev_reset(dev, 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
keyboard_at_adddata_mouse_cmd(0xfe);
|
||||
kbc_at_dev_queue_add(dev, 0xfe, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +294,8 @@ mouse_reset:
|
||||
(dev->last_data[4] == 0xf3) && (dev->last_data[5] == 0x50))
|
||||
dev->flags |= FLAG_INTMODE;
|
||||
|
||||
if ((dev->flags & FLAG_INTMODE) && (dev->last_data[0] == 0xf3) && (dev->last_data[1] == 0xc8) &&
|
||||
if ((dev->flags & FLAG_EXPLORER) && (dev->flags & FLAG_INTMODE) &&
|
||||
(dev->last_data[0] == 0xf3) && (dev->last_data[1] == 0xc8) &&
|
||||
(dev->last_data[2] == 0xf3) && (dev->last_data[3] == 0xc8) &&
|
||||
(dev->last_data[4] == 0xf3) && (dev->last_data[5] == 0x50))
|
||||
dev->flags |= FLAG_5BTN;
|
||||
@@ -289,30 +305,18 @@ mouse_reset:
|
||||
static int
|
||||
ps2_poll(int x, int y, int z, int b, double abs_x, double abs_y, void *priv)
|
||||
{
|
||||
mouse_t *dev = (mouse_t *) priv;
|
||||
atkbc_dev_t *dev = (atkbc_dev_t *) priv;
|
||||
|
||||
if (!x && !y && !z && (b == dev->b))
|
||||
return (0xff);
|
||||
|
||||
#if 0
|
||||
if (!(dev->flags & FLAG_ENABLED))
|
||||
return(0xff);
|
||||
#endif
|
||||
|
||||
if (!mouse_scan)
|
||||
if (!mouse_scan || (!x && !y && !z && (b == dev->b)))
|
||||
return (0xff);
|
||||
|
||||
dev->x += x;
|
||||
dev->y -= y;
|
||||
dev->z -= z;
|
||||
#if 0
|
||||
if ((dev->mode == MODE_STREAM) && (dev->flags & FLAG_ENABLED) && (keyboard_at_mouse_pos() < 13)) {
|
||||
#else
|
||||
if ((dev->mode == MODE_STREAM) && (keyboard_at_mouse_pos() < 13)) {
|
||||
#endif
|
||||
if ((dev->mode == MODE_STREAM) && (kbc_at_dev_queue_pos(dev, 1) < 13)) {
|
||||
dev->b = b;
|
||||
|
||||
ps2_report_coordinates(dev, 0);
|
||||
ps2_report_coordinates(dev, 1);
|
||||
}
|
||||
|
||||
return (0);
|
||||
@@ -326,11 +330,9 @@ ps2_poll(int x, int y, int z, int b, double abs_x, double abs_y, void *priv)
|
||||
void *
|
||||
mouse_ps2_init(const device_t *info)
|
||||
{
|
||||
mouse_t *dev;
|
||||
atkbc_dev_t *dev = kbc_at_dev_init(DEV_AUX);
|
||||
int i;
|
||||
|
||||
dev = (mouse_t *) malloc(sizeof(mouse_t));
|
||||
memset(dev, 0x00, sizeof(mouse_t));
|
||||
dev->name = info->name;
|
||||
dev->type = info->local;
|
||||
|
||||
@@ -338,18 +340,25 @@ mouse_ps2_init(const device_t *info)
|
||||
i = device_get_config_int("buttons");
|
||||
if (i > 2)
|
||||
dev->flags |= FLAG_INTELLI;
|
||||
if (i > 4)
|
||||
dev->flags |= FLAG_EXPLORER;
|
||||
|
||||
if (i == 4)
|
||||
if (i >= 4)
|
||||
i = 3;
|
||||
|
||||
/* Hook into the general AT Keyboard driver. */
|
||||
keyboard_at_set_mouse(ps2_write, dev);
|
||||
|
||||
mouse_ps2_log("%s: buttons=%d\n", dev->name, i);
|
||||
|
||||
/* Tell them how many buttons we have. */
|
||||
mouse_set_buttons(i);
|
||||
|
||||
dev->process_cmd = ps2_write;
|
||||
dev->execute_bat = ps2_bat;
|
||||
|
||||
dev->scan = &mouse_scan;
|
||||
|
||||
if (dev->port != NULL)
|
||||
kbc_at_dev_reset(dev, 0);
|
||||
|
||||
/* Return our private data to the I/O layer. */
|
||||
return (dev);
|
||||
}
|
||||
@@ -357,10 +366,7 @@ mouse_ps2_init(const device_t *info)
|
||||
static void
|
||||
ps2_close(void *priv)
|
||||
{
|
||||
mouse_t *dev = (mouse_t *) priv;
|
||||
|
||||
/* Unhook from the general AT Keyboard driver. */
|
||||
keyboard_at_set_mouse(NULL, NULL);
|
||||
atkbc_dev_t *dev = (atkbc_dev_t *) priv;
|
||||
|
||||
free(dev);
|
||||
}
|
||||
|
@@ -57,21 +57,24 @@
|
||||
#define CONFIG_SERPORT 12
|
||||
|
||||
enum {
|
||||
DEVICE_PCJR = 2, /* requires an IBM PCjr */
|
||||
DEVICE_AT = 4, /* requires an AT-compatible system */
|
||||
DEVICE_PS2 = 8, /* requires a PS/1 or PS/2 system */
|
||||
DEVICE_ISA = 0x10, /* requires the ISA bus */
|
||||
DEVICE_CBUS = 0x20, /* requires the C-BUS bus */
|
||||
DEVICE_MCA = 0x40, /* requires the MCA bus */
|
||||
DEVICE_EISA = 0x80, /* requires the EISA bus */
|
||||
DEVICE_VLB = 0x100, /* requires the PCI bus */
|
||||
DEVICE_PCI = 0x200, /* requires the VLB bus */
|
||||
DEVICE_AGP = 0x400, /* requires the AGP bus */
|
||||
DEVICE_AC97 = 0x800, /* requires the AC'97 bus */
|
||||
DEVICE_COM = 0x1000, /* requires a serial port */
|
||||
DEVICE_LPT = 0x2000, /* requires a parallel port */
|
||||
DEVICE_PCJR = 2, /* requires an IBM PCjr */
|
||||
DEVICE_AT = 4, /* requires an AT-compatible system */
|
||||
DEVICE_PS2 = 8, /* requires a PS/1 or PS/2 system */
|
||||
DEVICE_ISA = 0x10, /* requires the ISA bus */
|
||||
DEVICE_CBUS = 0x20, /* requires the C-BUS bus */
|
||||
DEVICE_MCA = 0x40, /* requires the MCA bus */
|
||||
DEVICE_EISA = 0x80, /* requires the EISA bus */
|
||||
DEVICE_VLB = 0x100, /* requires the PCI bus */
|
||||
DEVICE_PCI = 0x200, /* requires the VLB bus */
|
||||
DEVICE_AGP = 0x400, /* requires the AGP bus */
|
||||
DEVICE_AC97 = 0x800, /* requires the AC'97 bus */
|
||||
DEVICE_COM = 0x1000, /* requires a serial port */
|
||||
DEVICE_LPT = 0x2000, /* requires a parallel port */
|
||||
DEVICE_KBC = 0x4000, /* is a keyboard controller */
|
||||
|
||||
DEVICE_EXTPARAMS = 0x40000000 /* accepts extended parameters */
|
||||
DEVICE_EXTPARAMS = 0x40000000, /* accepts extended parameters */
|
||||
|
||||
DEVICE_ALL = 0xffffffff /* match all devices */
|
||||
};
|
||||
|
||||
#define BIOS_NORMAL 0
|
||||
@@ -171,8 +174,7 @@ extern void *device_cadd_inst_parameters(const device_t *d, const device_t *cd,
|
||||
extern void device_cadd_inst_ex(const device_t *d, const device_t *cd, void *priv, int inst);
|
||||
extern void device_cadd_inst_ex_parameters(const device_t *d, const device_t *cd, void *priv, int inst, void *params);
|
||||
extern void device_close_all(void);
|
||||
extern void device_reset_all(void);
|
||||
extern void device_reset_all_pci(void);
|
||||
extern void device_reset_all(uint32_t match_flags);
|
||||
extern void *device_get_priv(const device_t *d);
|
||||
extern int device_available(const device_t *d);
|
||||
extern int device_poll(const device_t *d, int x, int y, int z, int b);
|
||||
|
@@ -27,6 +27,15 @@ enum {
|
||||
DEV_AUX
|
||||
};
|
||||
|
||||
enum {
|
||||
DEV_STATE_MAIN_1 = 0,
|
||||
DEV_STATE_MAIN_2,
|
||||
DEV_STATE_MAIN_CMD,
|
||||
DEV_STATE_MAIN_OUT,
|
||||
DEV_STATE_MAIN_WANT_IN,
|
||||
DEV_STATE_MAIN_IN
|
||||
};
|
||||
|
||||
/* Used by the AT / PS/2 keyboard controller, common device, keyboard, and mouse. */
|
||||
typedef struct {
|
||||
uint8_t wantcmd, dat, pad, pad0;
|
||||
@@ -36,7 +45,7 @@ typedef struct {
|
||||
void *priv;
|
||||
|
||||
void (*poll)(void *priv);
|
||||
} kbc_port_t;
|
||||
} kbc_at_port_t;
|
||||
|
||||
/* Used by the AT / PS/2 common device, keyboard, and mouse. */
|
||||
typedef struct {
|
||||
@@ -65,7 +74,7 @@ typedef struct {
|
||||
void (*process_cmd)(void *priv);
|
||||
void (*execute_bat)(void *priv);
|
||||
|
||||
kbc_port_t *port;
|
||||
kbc_at_port_t *port;
|
||||
} atkbc_dev_t;
|
||||
|
||||
typedef struct {
|
||||
@@ -188,7 +197,7 @@ extern int mouse_queue_start, mouse_queue_end;
|
||||
extern int mouse_cmd_queue_start, mouse_cmd_queue_end;
|
||||
extern int mouse_scan;
|
||||
|
||||
extern kbc_port_t *kbc_ports[2];
|
||||
extern kbc_at_port_t *kbc_at_ports[2];
|
||||
|
||||
#ifdef EMU_DEVICE_H
|
||||
extern const device_t keyboard_pc_device;
|
||||
@@ -228,6 +237,8 @@ extern const device_t keyboard_ps2_intel_ami_pci_device;
|
||||
extern const device_t keyboard_ps2_acer_pci_device;
|
||||
extern const device_t keyboard_ps2_ali_pci_device;
|
||||
extern const device_t keyboard_ps2_tg_ami_pci_device;
|
||||
|
||||
extern const device_t keyboard_at_generic_device;
|
||||
#endif /*EMU_DEVICE_H*/
|
||||
|
||||
extern void keyboard_init(void);
|
||||
@@ -249,14 +260,10 @@ extern int keyboard_isfsexit_down(void);
|
||||
extern int keyboard_ismsexit(void);
|
||||
extern void keyboard_set_is_amstrad(int ams);
|
||||
|
||||
extern void keyboard_at_adddata_mouse(uint8_t val);
|
||||
extern void keyboard_at_adddata_mouse_cmd(uint8_t val);
|
||||
extern void keyboard_at_mouse_reset(void);
|
||||
extern uint8_t keyboard_at_mouse_pos(void);
|
||||
extern void keyboard_at_set_mouse(void (*mouse_write)(uint8_t val, void *), void *);
|
||||
extern void keyboard_at_set_a20_key(int state);
|
||||
extern void keyboard_at_reset(void);
|
||||
extern void kbc_at_a20_reset(void);
|
||||
extern uint8_t kbc_at_dev_queue_pos(atkbc_dev_t *dev, uint8_t main);
|
||||
extern void kbc_at_dev_queue_add(atkbc_dev_t *dev, uint8_t val, uint8_t main);
|
||||
extern void kbc_at_dev_reset(atkbc_dev_t *dev, int do_fa);
|
||||
extern atkbc_dev_t *kbc_at_dev_init(uint8_t inst);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
25
src/io.c
25
src/io.c
@@ -56,7 +56,6 @@ typedef struct {
|
||||
int initialized = 0;
|
||||
io_t *io[NPORTS], *io_last[NPORTS];
|
||||
|
||||
// #define ENABLE_IO_LOG 1
|
||||
#ifdef ENABLE_IO_LOG
|
||||
int io_do_log = ENABLE_IO_LOG;
|
||||
|
||||
@@ -311,9 +310,7 @@ inb(uint16_t port)
|
||||
/* if (port == 0x1ed)
|
||||
ret = 0xfe; */
|
||||
|
||||
if (port == 0x92) {
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) in b(%04X) = %02X\n", CS, cpu_state.pc, in_smm, found, qfound, port, ret);
|
||||
}
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) in b(%04X) = %02X\n", CS, cpu_state.pc, in_smm, found, qfound, port, ret);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
@@ -344,9 +341,7 @@ outb(uint16_t port, uint8_t val)
|
||||
#endif
|
||||
}
|
||||
|
||||
if (port == 0x92) {
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) outb(%04X, %02X)\n", CS, cpu_state.pc, in_smm, found, qfound, port, val);
|
||||
}
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) outb(%04X, %02X)\n", CS, cpu_state.pc, in_smm, found, qfound, port, val);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -400,9 +395,7 @@ inw(uint16_t port)
|
||||
if (!found)
|
||||
cycles -= io_delay;
|
||||
|
||||
if (port == 0x92) {
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) in w(%04X) = %04X\n", CS, cpu_state.pc, in_smm, found, qfound, port, ret);
|
||||
}
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) in w(%04X) = %04X\n", CS, cpu_state.pc, in_smm, found, qfound, port, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -447,9 +440,7 @@ outw(uint16_t port, uint16_t val)
|
||||
#endif
|
||||
}
|
||||
|
||||
if (port == 0x92) {
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) outw(%04X, %04X)\n", CS, cpu_state.pc, in_smm, found, qfound, port, val);
|
||||
}
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) outw(%04X, %04X)\n", CS, cpu_state.pc, in_smm, found, qfound, port, val);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -531,9 +522,7 @@ inl(uint16_t port)
|
||||
if (!found)
|
||||
cycles -= io_delay;
|
||||
|
||||
if (port == 0x92) {
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) in l(%04X) = %08X\n", CS, cpu_state.pc, in_smm, found, qfound, port, ret);
|
||||
}
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) in l(%04X) = %08X\n", CS, cpu_state.pc, in_smm, found, qfound, port, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -593,9 +582,7 @@ outl(uint16_t port, uint32_t val)
|
||||
#endif
|
||||
}
|
||||
|
||||
if (port == 0x92) {
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) outl(%04X, %08X)\n", CS, cpu_state.pc, in_smm, found, qfound, port, val);
|
||||
}
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) outl(%04X, %08X)\n", CS, cpu_state.pc, in_smm, found, qfound, port, val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@@ -922,12 +922,11 @@ trc_reset(uint8_t val)
|
||||
dma_reset();
|
||||
dma_set_at(1);
|
||||
|
||||
device_reset_all();
|
||||
device_reset_all(DEVICE_ALL);
|
||||
|
||||
cpu_alt_reset = 0;
|
||||
|
||||
pci_reset();
|
||||
keyboard_at_reset();
|
||||
|
||||
mem_a20_alt = 0;
|
||||
mem_a20_recalc();
|
||||
|
@@ -209,6 +209,9 @@ endif
|
||||
ifndef MINITRACE
|
||||
MINITRACE := n
|
||||
endif
|
||||
ifndef AVX
|
||||
AVX := n
|
||||
endif
|
||||
ifeq ($(DYNAREC), y)
|
||||
ifeq ($(ARM), y)
|
||||
ifeq ($(NEW_DYNAREC), n)
|
||||
@@ -314,7 +317,11 @@ else
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
AFLAGS := -msse2 -mfpmath=sse
|
||||
ifeq ($(AVX), y)
|
||||
AFLAGS := -msse2 -msse3 -mssse3 -msse4 -msse4a -mavx -mavx2 -mfpmath=sse
|
||||
else
|
||||
AFLAGS := -msse2 -mfpmath=sse
|
||||
endif
|
||||
ifeq ($(ARM), y)
|
||||
DFLAGS := -march=armv7-a
|
||||
AOPTIM :=
|
||||
@@ -581,11 +588,8 @@ MCHOBJ := machine.o machine_table.o \
|
||||
m_at_socket8.o m_at_slot1.o m_at_slot2.o m_at_socket370.o \
|
||||
m_at_misc.o
|
||||
|
||||
ifeq ($(NEW_KBC), y)
|
||||
KBCOBJ := kbc_at.o kbd_at.o
|
||||
else
|
||||
KBCOBJ := keyboard_at.o
|
||||
endif
|
||||
KBCOBJ := kbc_at.o kbc_at_dev.o \
|
||||
keyboard_at.o
|
||||
|
||||
DEVOBJ := bugger.o cartridge.o cassette.o hasp.o hwm.o hwm_lm75.o hwm_lm78.o hwm_gl518sm.o hwm_vt82c686.o \
|
||||
ibm_5161.o isamem.o isartc.o lpt.o pci_bridge.o postcard.o serial.o \
|
||||
|
Reference in New Issue
Block a user