mirror of
https://github.com/86Box/86Box.git
synced 2026-02-24 10:28:19 -07:00
Merge remote-tracking branch 'upstream/master' into feature/ich2
This commit is contained in:
@@ -74,14 +74,16 @@
|
||||
#define CTRL_RESET 0xff /* this resets the board */
|
||||
#define BUG_DATA 1
|
||||
|
||||
static uint8_t bug_ctrl, /* control register */
|
||||
bug_data, /* data register */
|
||||
bug_ledr, bug_ledg, /* RED and GREEN LEDs */
|
||||
bug_seg1, bug_seg2, /* LEFT and RIGHT 7SEG displays */
|
||||
bug_spcfg; /* serial port configuration */
|
||||
static uint8_t bug_ctrl; /* control register */
|
||||
static uint8_t bug_data; /* data register */
|
||||
static uint8_t bug_ledr; /* RED LEDs */
|
||||
static uint8_t bug_ledg; /* GREEN LEDs */
|
||||
static uint8_t bug_seg1;
|
||||
static uint8_t bug_seg2; /* LEFT and RIGHT 7SEG displays */
|
||||
static uint8_t bug_spcfg; /* serial port configuration */
|
||||
#define FIFO_LEN 256
|
||||
static uint8_t bug_buff[FIFO_LEN], /* serial port data buffer */
|
||||
*bug_bptr;
|
||||
static uint8_t bug_buff[FIFO_LEN]; /* serial port data buffer */
|
||||
static uint8_t *bug_bptr;
|
||||
#define UISTR_LEN 24
|
||||
static char bug_str[UISTR_LEN]; /* UI output string */
|
||||
|
||||
@@ -312,7 +314,7 @@ bug_read(uint16_t port, void *priv)
|
||||
break;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Initialize the ISA BusBugger emulator. */
|
||||
|
||||
@@ -175,15 +175,13 @@ cart_close(int drive)
|
||||
void
|
||||
cart_reset(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
cart_image_close(1);
|
||||
cart_image_close(0);
|
||||
|
||||
if (!machine_has_cartridge(machine))
|
||||
return;
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
for (uint8_t i = 0; i < 2; i++) {
|
||||
mem_mapping_add(&cart_mappings[i], 0x000d0000, 0x00002000,
|
||||
cart_read, NULL, NULL,
|
||||
NULL, NULL, NULL,
|
||||
|
||||
@@ -45,9 +45,11 @@ pc_cassette_t *cassette;
|
||||
|
||||
char cassette_fname[512];
|
||||
char cassette_mode[512];
|
||||
unsigned long cassette_pos, cassette_srate;
|
||||
unsigned long cassette_pos;
|
||||
unsigned long cassette_srate;
|
||||
int cassette_enable;
|
||||
int cassette_append, cassette_pcm;
|
||||
int cassette_append;
|
||||
int cassette_pcm;
|
||||
int cassette_ui_writeprot;
|
||||
|
||||
static int cassette_cycles = -1;
|
||||
@@ -138,7 +140,7 @@ pc_cas_new(void)
|
||||
|
||||
pc_cas_init(cas);
|
||||
|
||||
return (cas);
|
||||
return cas;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -172,7 +174,7 @@ pc_cas_set_fname(pc_cassette_t *cas, const char *fname)
|
||||
|
||||
if (fname == NULL) {
|
||||
ui_sb_update_icon_state(SB_CASSETTE, 1);
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
cas->fp = plat_fopen(fname, "r+b");
|
||||
@@ -182,7 +184,7 @@ pc_cas_set_fname(pc_cassette_t *cas, const char *fname)
|
||||
|
||||
if (cas->fp == NULL) {
|
||||
ui_sb_update_icon_state(SB_CASSETTE, 1);
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
cas->close = 1;
|
||||
@@ -215,14 +217,12 @@ pc_cas_set_fname(pc_cassette_t *cas, const char *fname)
|
||||
pc_cas_set_pcm(cas, 0);
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
pc_cas_reset(pc_cassette_t *cas)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
cas->clk_pcm = 0;
|
||||
|
||||
cas->clk_out = cas->clk;
|
||||
@@ -237,7 +237,7 @@ pc_cas_reset(pc_cassette_t *cas)
|
||||
cas->cas_inp_buf = 0;
|
||||
cas->cas_inp_bit = 0;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (uint8_t i = 0; i < 3; i++) {
|
||||
cas->pcm_inp_fir[i] = 0;
|
||||
}
|
||||
}
|
||||
@@ -344,18 +344,18 @@ int
|
||||
pc_cas_set_position(pc_cassette_t *cas, unsigned long pos)
|
||||
{
|
||||
if (cas->fp == NULL) {
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fseek(cas->fp, pos, SEEK_SET) != 0) {
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
cas->position = pos;
|
||||
|
||||
pc_cas_reset(cas);
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -394,17 +394,18 @@ pc_cas_read_bit(pc_cassette_t *cas)
|
||||
static int
|
||||
pc_cas_read_smp(pc_cassette_t *cas)
|
||||
{
|
||||
int smp, *fir;
|
||||
int smp;
|
||||
int *fir;
|
||||
|
||||
if (feof(cas->fp)) {
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
smp = fgetc(cas->fp);
|
||||
|
||||
if (smp == EOF) {
|
||||
cassette_log("cassette EOF at %lu\n", cas->position);
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
cas->position += 1;
|
||||
@@ -417,7 +418,7 @@ pc_cas_read_smp(pc_cassette_t *cas)
|
||||
|
||||
smp = (fir[0] + 2 * fir[1] + fir[2]) / 4;
|
||||
|
||||
return (smp);
|
||||
return smp;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -461,8 +462,6 @@ pc_cas_write_smp(pc_cassette_t *cas, int val)
|
||||
void
|
||||
pc_cas_set_motor(pc_cassette_t *cas, unsigned char val)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
val = (val != 0);
|
||||
|
||||
if (val == cas->motor) {
|
||||
@@ -470,7 +469,7 @@ pc_cas_set_motor(pc_cassette_t *cas, unsigned char val)
|
||||
}
|
||||
|
||||
if ((val == 0) && cas->save && cas->pcm) {
|
||||
for (i = 0; i < (cas->srate / 16); i++) {
|
||||
for (unsigned long i = 0; i < (cas->srate / 16); i++) {
|
||||
pc_cas_write_smp(cas, 0);
|
||||
}
|
||||
}
|
||||
@@ -553,7 +552,8 @@ pc_cas_print_state(const pc_cassette_t *cas)
|
||||
static void
|
||||
pc_cas_clock_pcm(pc_cassette_t *cas, unsigned long cnt)
|
||||
{
|
||||
unsigned long i, n;
|
||||
unsigned long i;
|
||||
unsigned long n;
|
||||
int v = 0;
|
||||
|
||||
n = cas->srate * cnt + cas->clk_pcm;
|
||||
|
||||
@@ -1147,7 +1147,8 @@ static uint8_t
|
||||
ics9xxx_find_bus_match(ics9xxx_t *dev, uint32_t bus, uint8_t preset_mask, uint8_t preset)
|
||||
{
|
||||
uint8_t best_match = 0;
|
||||
uint32_t delta, best_delta = -1;
|
||||
uint32_t delta;
|
||||
uint32_t best_delta = -1;
|
||||
|
||||
#ifdef ENABLE_ICS9xxx_DETECT
|
||||
if (dev->model_idx == ICS9xxx_xx)
|
||||
|
||||
@@ -328,7 +328,9 @@ lm78_i2c_start(void *bus, uint8_t addr, uint8_t read, void *priv)
|
||||
static uint8_t
|
||||
lm78_read(lm78_t *dev, uint8_t reg, uint8_t bank)
|
||||
{
|
||||
uint8_t ret = 0, masked_reg = reg, bankswitched = ((reg & 0xf8) == 0x50);
|
||||
uint8_t ret = 0;
|
||||
uint8_t masked_reg = reg;
|
||||
uint8_t bankswitched = ((reg & 0xf8) == 0x50);
|
||||
lm75_t *lm75;
|
||||
|
||||
if ((dev->local & LM78_AS99127F) && (bank == 3) && (reg != 0x4e)) {
|
||||
|
||||
@@ -77,14 +77,14 @@ i2c_addbus(char *name)
|
||||
void
|
||||
i2c_removebus(void *bus_handle)
|
||||
{
|
||||
int c;
|
||||
i2c_t *p, *q;
|
||||
i2c_t *p;
|
||||
i2c_t *q;
|
||||
i2c_bus_t *bus = (i2c_bus_t *) bus_handle;
|
||||
|
||||
if (!bus_handle)
|
||||
return;
|
||||
|
||||
for (c = 0; c < NADDRS; c++) {
|
||||
for (uint8_t c = 0; c < NADDRS; c++) {
|
||||
p = bus->devices[c];
|
||||
if (!p)
|
||||
continue;
|
||||
@@ -117,14 +117,14 @@ i2c_sethandler(void *bus_handle, uint8_t base, int size,
|
||||
void (*stop)(void *bus, uint8_t addr, void *priv),
|
||||
void *priv)
|
||||
{
|
||||
int c;
|
||||
i2c_t *p, *q = NULL;
|
||||
i2c_t *p;
|
||||
i2c_t *q = NULL;
|
||||
i2c_bus_t *bus = (i2c_bus_t *) bus_handle;
|
||||
|
||||
if (!bus_handle || ((base + size) > NADDRS))
|
||||
return;
|
||||
|
||||
for (c = 0; c < size; c++) {
|
||||
for (int c = 0; c < size; c++) {
|
||||
p = bus->last[base + c];
|
||||
q = (i2c_t *) malloc(sizeof(i2c_t));
|
||||
memset(q, 0, sizeof(i2c_t));
|
||||
@@ -156,14 +156,14 @@ i2c_removehandler(void *bus_handle, uint8_t base, int size,
|
||||
void (*stop)(void *bus, uint8_t addr, void *priv),
|
||||
void *priv)
|
||||
{
|
||||
int c;
|
||||
i2c_t *p, *q;
|
||||
i2c_t *p;
|
||||
i2c_t *q;
|
||||
i2c_bus_t *bus = (i2c_bus_t *) bus_handle;
|
||||
|
||||
if (!bus_handle || ((base + size) > NADDRS))
|
||||
return;
|
||||
|
||||
for (c = 0; c < size; c++) {
|
||||
for (int c = 0; c < size; c++) {
|
||||
p = bus->devices[base + c];
|
||||
if (!p)
|
||||
continue;
|
||||
@@ -209,7 +209,7 @@ i2c_start(void *bus_handle, uint8_t addr, uint8_t read)
|
||||
i2c_t *p;
|
||||
|
||||
if (!bus)
|
||||
return (ret);
|
||||
return ret;
|
||||
|
||||
p = bus->devices[addr];
|
||||
if (p) {
|
||||
@@ -223,7 +223,7 @@ i2c_start(void *bus_handle, uint8_t addr, uint8_t read)
|
||||
|
||||
i2c_log("I2C %s: start(%02X) = %d\n", bus->name, addr, ret);
|
||||
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
@@ -234,7 +234,7 @@ i2c_read(void *bus_handle, uint8_t addr)
|
||||
i2c_t *p;
|
||||
|
||||
if (!bus)
|
||||
return (ret);
|
||||
return ret;
|
||||
|
||||
p = bus->devices[addr];
|
||||
if (p) {
|
||||
@@ -249,7 +249,7 @@ i2c_read(void *bus_handle, uint8_t addr)
|
||||
|
||||
i2c_log("I2C %s: read(%02X) = %02X\n", bus->name, addr, ret);
|
||||
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
@@ -260,7 +260,7 @@ i2c_write(void *bus_handle, uint8_t addr, uint8_t data)
|
||||
i2c_bus_t *bus = (i2c_bus_t *) bus_handle;
|
||||
|
||||
if (!bus)
|
||||
return (ret);
|
||||
return ret;
|
||||
|
||||
p = bus->devices[addr];
|
||||
if (p) {
|
||||
@@ -274,7 +274,7 @@ i2c_write(void *bus_handle, uint8_t addr, uint8_t data)
|
||||
|
||||
i2c_log("I2C %s: write(%02X, %02X) = %d\n", bus->name, addr, data, ret);
|
||||
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -186,7 +186,7 @@ ram_readb(uint32_t addr, void *priv)
|
||||
/* Grab the data. */
|
||||
ret = *(uint8_t *) (dev->ptr + (addr - dev->base));
|
||||
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Read one word from onboard RAM. */
|
||||
@@ -199,7 +199,7 @@ ram_readw(uint32_t addr, void *priv)
|
||||
/* Grab the data. */
|
||||
ret = *(uint16_t *) (dev->ptr + (addr - dev->base));
|
||||
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Write one byte to onboard RAM. */
|
||||
@@ -230,13 +230,13 @@ ems_readb(uint32_t addr, void *priv)
|
||||
uint8_t ret = 0xff;
|
||||
|
||||
/* Grab the data. */
|
||||
ret = *(uint8_t *) (dev->ems[((addr & 0xffff) >> 14)].addr + (addr & 0x3fff));
|
||||
ret = *(uint8_t *) (dev->ems[(addr & 0xffff) >> 14].addr + (addr & 0x3fff));
|
||||
#if ISAMEM_DEBUG
|
||||
if ((addr % 4096) == 0)
|
||||
isamem_log("EMS readb(%06x) = %02x\n", addr - dev & 0x3fff, ret);
|
||||
#endif
|
||||
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Read one word from onboard paged RAM. */
|
||||
@@ -247,13 +247,13 @@ ems_readw(uint32_t addr, void *priv)
|
||||
uint16_t ret = 0xffff;
|
||||
|
||||
/* Grab the data. */
|
||||
ret = *(uint16_t *) (dev->ems[((addr & 0xffff) >> 14)].addr + (addr & 0x3fff));
|
||||
ret = *(uint16_t *) (dev->ems[(addr & 0xffff) >> 14].addr + (addr & 0x3fff));
|
||||
#if ISAMEM_DEBUG
|
||||
if ((addr % 4096) == 0)
|
||||
isamem_log("EMS readw(%06x) = %04x\n", addr - dev & 0x3fff, ret);
|
||||
#endif
|
||||
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Write one byte to onboard paged RAM. */
|
||||
@@ -267,7 +267,7 @@ ems_writeb(uint32_t addr, uint8_t val, void *priv)
|
||||
if ((addr % 4096) == 0)
|
||||
isamem_log("EMS writeb(%06x, %02x)\n", addr - dev & 0x3fff, val);
|
||||
#endif
|
||||
*(uint8_t *) (dev->ems[((addr & 0xffff) >> 14)].addr + (addr & 0x3fff)) = val;
|
||||
*(uint8_t *) (dev->ems[(addr & 0xffff) >> 14].addr + (addr & 0x3fff)) = val;
|
||||
}
|
||||
|
||||
/* Write one word to onboard paged RAM. */
|
||||
@@ -281,7 +281,7 @@ ems_writew(uint32_t addr, uint16_t val, void *priv)
|
||||
if ((addr % 4096) == 0)
|
||||
isamem_log("EMS writew(%06x, %04x)\n", addr & 0x3fff, val);
|
||||
#endif
|
||||
*(uint16_t *) (dev->ems[((addr & 0xffff) >> 14)].addr + (addr & 0x3fff)) = val;
|
||||
*(uint16_t *) (dev->ems[(addr & 0xffff) >> 14].addr + (addr & 0x3fff)) = val;
|
||||
}
|
||||
|
||||
/* Handle a READ operation from one of our registers. */
|
||||
@@ -311,7 +311,7 @@ ems_read(uint16_t port, void *priv)
|
||||
isamem_log("ISAMEM: read(%04x) = %02x)\n", port, ret);
|
||||
#endif
|
||||
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Handle a WRITE operation to one of our registers. */
|
||||
@@ -391,11 +391,11 @@ static void *
|
||||
isamem_init(const device_t *info)
|
||||
{
|
||||
memdev_t *dev;
|
||||
uint32_t k, t;
|
||||
uint32_t k;
|
||||
uint32_t t;
|
||||
uint32_t addr;
|
||||
uint32_t tot;
|
||||
uint8_t *ptr;
|
||||
int i;
|
||||
|
||||
/* Find our device and create an instance. */
|
||||
dev = (memdev_t *) malloc(sizeof(memdev_t));
|
||||
@@ -624,7 +624,7 @@ isamem_init(const device_t *info)
|
||||
* create, initialize and disable the mappings, and set
|
||||
* up the I/O control handler.
|
||||
*/
|
||||
for (i = 0; i < EMS_MAXPAGE; i++) {
|
||||
for (uint8_t i = 0; i < EMS_MAXPAGE; i++) {
|
||||
/* Create and initialize a page mapping. */
|
||||
mem_mapping_add(&dev->ems[i].mapping,
|
||||
dev->frame_addr + (EMS_PGSIZE * i), EMS_PGSIZE,
|
||||
@@ -655,10 +655,9 @@ static void
|
||||
isamem_close(void *priv)
|
||||
{
|
||||
memdev_t *dev = (memdev_t *) priv;
|
||||
int i;
|
||||
|
||||
if (dev->flags & FLAG_EMS) {
|
||||
for (i = 0; i < EMS_MAXPAGE; i++) {
|
||||
for (uint8_t i = 0; i < EMS_MAXPAGE; i++) {
|
||||
io_removehandler(dev->base_addr + (EMS_PGSIZE * i), 2,
|
||||
ems_read, NULL, NULL, ems_write, NULL, NULL, dev);
|
||||
}
|
||||
@@ -1566,12 +1565,12 @@ static const struct {
|
||||
void
|
||||
isamem_reset(void)
|
||||
{
|
||||
int k, i;
|
||||
int k;
|
||||
|
||||
/* We explicitly set to zero here or bad things happen */
|
||||
isa_mem_size = 0;
|
||||
|
||||
for (i = 0; i < ISAMEM_MAX; i++) {
|
||||
for (uint8_t i = 0; i < ISAMEM_MAX; i++) {
|
||||
k = isamem_type[i];
|
||||
if (k == 0)
|
||||
continue;
|
||||
@@ -1603,12 +1602,12 @@ isamem_get_from_internal_name(const char *s)
|
||||
|
||||
while (boards[c].dev != NULL) {
|
||||
if (!strcmp(boards[c].dev->internal_name, s))
|
||||
return (c);
|
||||
return c;
|
||||
c++;
|
||||
}
|
||||
|
||||
/* Not found. */
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const device_t *
|
||||
|
||||
@@ -121,7 +121,8 @@ isapnp_device_config_changed(isapnp_card_t *card, isapnp_device_t *ld)
|
||||
|
||||
/* Populate config structure, performing endianness conversion as needed. */
|
||||
card->config.activate = ld->regs[0x30] & 0x01;
|
||||
uint8_t i, reg_base;
|
||||
uint8_t i;
|
||||
uint8_t reg_base;
|
||||
for (i = 0; i < 4; i++) {
|
||||
reg_base = 0x40 + (8 * i);
|
||||
card->config.mem[i].base = (ld->regs[reg_base] << 16) | (ld->regs[reg_base + 1] << 8);
|
||||
@@ -168,7 +169,8 @@ isapnp_reset_ld_config(isapnp_device_t *ld)
|
||||
|
||||
/* Populate configuration registers. */
|
||||
ld->regs[0x30] = !!config->activate;
|
||||
uint8_t i, reg_base;
|
||||
uint8_t i;
|
||||
uint8_t reg_base;
|
||||
uint32_t size;
|
||||
for (i = 0; i < 4; i++) {
|
||||
reg_base = 0x40 + (8 * i);
|
||||
@@ -253,7 +255,9 @@ static uint8_t
|
||||
isapnp_read_data(uint16_t addr, void *priv)
|
||||
{
|
||||
isapnp_t *dev = (isapnp_t *) priv;
|
||||
uint8_t ret = 0xff, bit, next_shift;
|
||||
uint8_t ret = 0xff;
|
||||
uint8_t bit;
|
||||
uint8_t next_shift;
|
||||
isapnp_card_t *card;
|
||||
|
||||
switch (dev->reg) {
|
||||
@@ -450,7 +454,8 @@ isapnp_write_data(uint16_t addr, uint8_t val, void *priv)
|
||||
isapnp_t *dev = (isapnp_t *) priv;
|
||||
isapnp_card_t *card;
|
||||
isapnp_device_t *ld;
|
||||
uint16_t io_addr, reset_cards = 0;
|
||||
uint16_t io_addr;
|
||||
uint16_t reset_cards = 0;
|
||||
|
||||
isapnp_log("ISAPnP: write_data(%02X)\n", val);
|
||||
|
||||
@@ -701,8 +706,10 @@ static void
|
||||
isapnp_close(void *priv)
|
||||
{
|
||||
isapnp_t *dev = (isapnp_t *) priv;
|
||||
isapnp_card_t *card = dev->first_card, *next_card;
|
||||
isapnp_device_t *ld, *next_ld;
|
||||
isapnp_card_t *card = dev->first_card;
|
||||
isapnp_card_t *next_card;
|
||||
isapnp_device_t *ld;
|
||||
isapnp_device_t *next_ld;
|
||||
|
||||
while (card) {
|
||||
ld = card->first_ld;
|
||||
@@ -773,11 +780,22 @@ isapnp_update_card_rom(void *priv, uint8_t *rom, uint16_t rom_size)
|
||||
uint16_t vendor = (card->rom[0] << 8) | card->rom[1];
|
||||
isapnp_log("ISAPnP: Parsing ROM resources for card %c%c%c%02X%02X (serial %08X)\n", '@' + ((vendor >> 10) & 0x1f), '@' + ((vendor >> 5) & 0x1f), '@' + (vendor & 0x1f), card->rom[2], card->rom[3], (card->rom[7] << 24) | (card->rom[6] << 16) | (card->rom[5] << 8) | card->rom[4]);
|
||||
#endif
|
||||
uint16_t i = 9, j;
|
||||
uint8_t existing = 0, ldn = 0, res, in_df = 0;
|
||||
uint8_t irq = 0, io = 0, mem_range = 0, mem_range_32 = 0, irq_df = 0, io_df = 0, mem_range_df = 0, mem_range_32_df = 0;
|
||||
uint16_t i = 9;
|
||||
uint8_t existing = 0;
|
||||
uint8_t ldn = 0;
|
||||
uint8_t res;
|
||||
uint8_t in_df = 0;
|
||||
uint8_t irq = 0;
|
||||
uint8_t io = 0;
|
||||
uint8_t mem_range = 0;
|
||||
uint8_t mem_range_32 = 0;
|
||||
uint8_t irq_df = 0;
|
||||
uint8_t io_df = 0;
|
||||
uint8_t mem_range_df = 0;
|
||||
uint8_t mem_range_32_df = 0;
|
||||
uint32_t len;
|
||||
isapnp_device_t *ld = NULL, *prev_ld = NULL;
|
||||
isapnp_device_t *ld = NULL;
|
||||
isapnp_device_t *prev_ld = NULL;
|
||||
|
||||
/* Check if this is an existing card which already has logical devices.
|
||||
Any new logical devices will be added to the list after existing ones.
|
||||
@@ -994,7 +1012,7 @@ isapnp_update_card_rom(void *priv, uint8_t *rom, uint16_t rom_size)
|
||||
case 0x0f: /* end tag */
|
||||
/* Calculate checksum. */
|
||||
res = 0x00;
|
||||
for (j = 9; j <= i; j++)
|
||||
for (uint16_t j = 9; j <= i; j++)
|
||||
res += card->rom[j];
|
||||
card->rom[i + 1] = -res;
|
||||
|
||||
|
||||
@@ -193,7 +193,9 @@ mm67_tick(nvr_t *nvr)
|
||||
{
|
||||
rtcdev_t *dev = (rtcdev_t *) nvr->data;
|
||||
uint8_t *regs = nvr->regs;
|
||||
int mon, year, f = 0;
|
||||
int mon;
|
||||
int year;
|
||||
int f = 0;
|
||||
|
||||
/* Update and set interrupt if needed. */
|
||||
regs[MM67_SEC] = RTC_BCDINC(nvr->regs[MM67_SEC], 1);
|
||||
@@ -236,7 +238,10 @@ mm67_tick(nvr_t *nvr)
|
||||
regs[MM67_DOM] = RTC_BCDINC(regs[MM67_DOM], 1);
|
||||
mon = RTC_DCB(regs[MM67_MON]);
|
||||
if (dev->year != -1) {
|
||||
year = RTC_DCB(regs[dev->year]);
|
||||
if (dev->flags & FLAG_YEARBCD)
|
||||
year = RTC_DCB(regs[dev->year]);
|
||||
else
|
||||
year = regs[dev->year];
|
||||
if (dev->flags & FLAG_YEAR80)
|
||||
year += 80;
|
||||
} else
|
||||
@@ -369,10 +374,8 @@ mm67_start(nvr_t *nvr)
|
||||
static void
|
||||
mm67_reset(nvr_t *nvr)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Initialize the RTC to a known state. */
|
||||
for (i = MM67_MSEC; i <= MM67_MON; i++)
|
||||
for (uint8_t i = MM67_MSEC; i <= MM67_MON; i++)
|
||||
nvr->regs[i] = RTC_BCD(0);
|
||||
nvr->regs[MM67_DOW] = RTC_BCD(1);
|
||||
nvr->regs[MM67_DOM] = RTC_BCD(1);
|
||||
@@ -407,7 +410,7 @@ mm67_read(uint16_t port, void *priv)
|
||||
isartc_log("ISARTC: read(%04x) = %02x\n", port - dev->base_addr, ret);
|
||||
#endif
|
||||
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Handle a WRITE operation to one of our registers. */
|
||||
@@ -787,12 +790,12 @@ isartc_get_from_internal_name(char *s)
|
||||
|
||||
while (boards[c].dev != NULL) {
|
||||
if (!strcmp(boards[c].dev->internal_name, s))
|
||||
return (c);
|
||||
return c;
|
||||
c++;
|
||||
}
|
||||
|
||||
/* Not found. */
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const device_t *
|
||||
|
||||
@@ -795,7 +795,8 @@ static uint8_t
|
||||
write64_generic(void *priv, uint8_t val)
|
||||
{
|
||||
atkbc_t *dev = (atkbc_t *) priv;
|
||||
uint8_t current_drive, fixed_bits;
|
||||
uint8_t current_drive;
|
||||
uint8_t fixed_bits;
|
||||
uint8_t kbc_ven = 0x0;
|
||||
kbc_ven = dev->flags & KBC_VEN_MASK;
|
||||
|
||||
@@ -1276,7 +1277,7 @@ write64_olivetti(void *priv, uint8_t val)
|
||||
* bit 2: keyboard fuse present
|
||||
* bits 0-1: ???
|
||||
*/
|
||||
kbc_delay_to_ob(dev, (0x0c | ((is386) ? 0x00 : 0x80)) & 0xdf, 0, 0x00);
|
||||
kbc_delay_to_ob(dev, (0x0c | (is386 ? 0x00 : 0x80)) & 0xdf, 0, 0x00);
|
||||
dev->p1 = ((dev->p1 + 1) & 3) | (dev->p1 & 0xfc);
|
||||
return 0;
|
||||
}
|
||||
@@ -1413,8 +1414,9 @@ static void
|
||||
kbc_at_process_cmd(void *priv)
|
||||
{
|
||||
atkbc_t *dev = (atkbc_t *) priv;
|
||||
int i = 0, bad = 1;
|
||||
uint8_t mask, kbc_ven = dev->flags & KBC_VEN_MASK;
|
||||
int bad = 1;
|
||||
uint8_t mask;
|
||||
uint8_t kbc_ven = dev->flags & KBC_VEN_MASK;
|
||||
uint8_t cmd_ac_conv[16] = { 0x0b, 2, 3, 4, 5, 6, 7, 8, 9, 0x0a, 0x1e, 0x30, 0x2e, 0x20, 0x12, 0x21 };
|
||||
|
||||
if (dev->status & STAT_CD) {
|
||||
@@ -1449,6 +1451,7 @@ kbc_at_process_cmd(void *priv)
|
||||
/* TODO: Proper P1 implementation, with OR and AND flags in the machine table. */
|
||||
dev->p1 = dev->p1 & 0xff;
|
||||
write_p2(dev, 0x4b);
|
||||
picintc(0x1002);
|
||||
}
|
||||
|
||||
dev->status = (dev->status & 0x0f) | 0x60;
|
||||
@@ -1467,6 +1470,7 @@ kbc_at_process_cmd(void *priv)
|
||||
/* TODO: Proper P1 implementation, with OR and AND flags in the machine table. */
|
||||
dev->p1 = dev->p1 & 0xff;
|
||||
write_p2(dev, 0xcf);
|
||||
picintc(0x0002);
|
||||
}
|
||||
|
||||
dev->status = (dev->status & 0x0f) | 0x60;
|
||||
@@ -1506,7 +1510,7 @@ kbc_at_process_cmd(void *priv)
|
||||
dev->mem[0x32] = 0x00; /* T0 and T1. */
|
||||
dev->mem[0x33] = 0x00; /* PSW - Program Status Word - always return 0x00 because we do not emulate this byte. */
|
||||
/* 20 bytes in high nibble in set 1, low nibble in set 1, set 1 space format = 60 bytes. */
|
||||
for (i = 0; i < 20; i++) {
|
||||
for (uint8_t i = 0; i < 20; i++) {
|
||||
kbc_at_queue_add(dev, cmd_ac_conv[dev->mem[i + 0x20] >> 4]);
|
||||
kbc_at_queue_add(dev, cmd_ac_conv[dev->mem[i + 0x20] & 0x0f]);
|
||||
kbc_at_queue_add(dev, 0x39);
|
||||
@@ -1758,7 +1762,7 @@ kbc_at_read(uint16_t port, void *priv)
|
||||
|
||||
kbc_at_log("ATkbc: [%04X:%08X] read (%04X) = %02X\n", CS, cpu_state.pc, port, ret);
|
||||
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1814,14 +1818,14 @@ static void
|
||||
kbc_at_close(void *priv)
|
||||
{
|
||||
atkbc_t *dev = (atkbc_t *) priv;
|
||||
int i, max_ports = ((dev->flags & KBC_TYPE_MASK) >= KBC_TYPE_PS2_1) ? 2 : 1;
|
||||
int max_ports = ((dev->flags & KBC_TYPE_MASK) >= KBC_TYPE_PS2_1) ? 2 : 1;
|
||||
|
||||
kbc_at_reset(dev);
|
||||
|
||||
/* Stop timers. */
|
||||
timer_disable(&dev->send_delay_timer);
|
||||
|
||||
for (i = 0; i < max_ports; i++) {
|
||||
for (int i = 0; i < max_ports; i++) {
|
||||
if (kbc_at_ports[i] != NULL) {
|
||||
free(kbc_at_ports[i]);
|
||||
kbc_at_ports[i] = NULL;
|
||||
@@ -1835,7 +1839,7 @@ static void *
|
||||
kbc_at_init(const device_t *info)
|
||||
{
|
||||
atkbc_t *dev;
|
||||
int i, max_ports;
|
||||
int max_ports;
|
||||
|
||||
dev = (atkbc_t *) malloc(sizeof(atkbc_t));
|
||||
memset(dev, 0x00, sizeof(atkbc_t));
|
||||
@@ -1922,7 +1926,7 @@ kbc_at_init(const device_t *info)
|
||||
|
||||
max_ports = ((dev->flags & KBC_TYPE_MASK) >= KBC_TYPE_PS2_1) ? 2 : 1;
|
||||
|
||||
for (i = 0; i < max_ports; i++) {
|
||||
for (int i = 0; i < max_ports; i++) {
|
||||
kbc_at_ports[i] = (kbc_at_port_t *) malloc(sizeof(kbc_at_port_t));
|
||||
memset(kbc_at_ports[i], 0x00, sizeof(kbc_at_port_t));
|
||||
kbc_at_ports[i]->out_new = -1;
|
||||
@@ -1934,7 +1938,7 @@ kbc_at_init(const device_t *info)
|
||||
/* The actual keyboard. */
|
||||
device_add(&keyboard_at_generic_device);
|
||||
|
||||
return (dev);
|
||||
return dev;
|
||||
}
|
||||
|
||||
const device_t keyboard_at_device = {
|
||||
|
||||
@@ -75,7 +75,7 @@ kbc_at_dev_queue_pos(atkbc_dev_t *dev, uint8_t main)
|
||||
uint8_t ret;
|
||||
|
||||
if (main)
|
||||
ret = ((dev->queue_end - dev->queue_start) & 0xf);
|
||||
ret = ((dev->queue_end - dev->queue_start) & dev->fifo_mask);
|
||||
else
|
||||
ret = ((dev->cmd_queue_end - dev->cmd_queue_start) & 0xf);
|
||||
|
||||
@@ -88,7 +88,7 @@ kbc_at_dev_queue_add(atkbc_dev_t *dev, uint8_t val, uint8_t main)
|
||||
if (main) {
|
||||
kbc_at_dev_log("%s: dev->queue[%02X] = %02X;\n", dev->name, dev->queue_end, val);
|
||||
dev->queue[dev->queue_end] = val;
|
||||
dev->queue_end = (dev->queue_end + 1) & 0xf;
|
||||
dev->queue_end = (dev->queue_end + 1) & dev->fifo_mask;
|
||||
} else {
|
||||
kbc_at_dev_log("%s: dev->cmd_queue[%02X] = %02X;\n", dev->name, dev->cmd_queue_end, val);
|
||||
dev->cmd_queue[dev->cmd_queue_end] = val;
|
||||
@@ -121,7 +121,7 @@ kbc_at_dev_poll(void *priv)
|
||||
if (*dev->scan && (dev->port->out_new == -1) && (dev->queue_start != dev->queue_end)) {
|
||||
kbc_at_dev_log("%s: %02X (DATA) on channel 1\n", dev->name, dev->queue[dev->queue_start]);
|
||||
dev->port->out_new = dev->queue[dev->queue_start];
|
||||
dev->queue_start = (dev->queue_start + 1) & 0xf;
|
||||
dev->queue_start = (dev->queue_start + 1) & dev->fifo_mask;
|
||||
}
|
||||
if (!(*dev->scan) || dev->port->wantcmd)
|
||||
dev->state = DEV_STATE_MAIN_1;
|
||||
@@ -155,6 +155,20 @@ kbc_at_dev_poll(void *priv)
|
||||
dev->port->wantcmd = 0;
|
||||
}
|
||||
break;
|
||||
case DEV_STATE_EXECUTE_BAT:
|
||||
dev->state = DEV_STATE_MAIN_OUT;
|
||||
dev->execute_bat(dev);
|
||||
break;
|
||||
case DEV_STATE_MAIN_WANT_EXECUTE_BAT:
|
||||
/* Output command response and then return to main loop #2. */
|
||||
if ((dev->port->out_new == -1) && (dev->cmd_queue_start != dev->cmd_queue_end)) {
|
||||
kbc_at_dev_log("%s: %02X (CMD ) on channel 1\n", dev->name, dev->cmd_queue[dev->cmd_queue_start]);
|
||||
dev->port->out_new = dev->cmd_queue[dev->cmd_queue_start];
|
||||
dev->cmd_queue_start = (dev->cmd_queue_start + 1) & 0xf;
|
||||
}
|
||||
if (dev->cmd_queue_start == dev->cmd_queue_end)
|
||||
dev->state = DEV_STATE_EXECUTE_BAT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,12 +184,11 @@ kbc_at_dev_reset(atkbc_dev_t *dev, int do_fa)
|
||||
|
||||
*dev->scan = 1;
|
||||
|
||||
if (do_fa)
|
||||
if (do_fa) {
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||
|
||||
dev->state = DEV_STATE_MAIN_OUT;
|
||||
|
||||
dev->execute_bat(dev);
|
||||
dev->state = DEV_STATE_MAIN_WANT_EXECUTE_BAT;
|
||||
} else
|
||||
dev->state = DEV_STATE_EXECUTE_BAT;
|
||||
}
|
||||
|
||||
atkbc_dev_t *
|
||||
@@ -194,5 +207,5 @@ kbc_at_dev_init(uint8_t inst)
|
||||
}
|
||||
|
||||
/* Return our private data to the I/O layer. */
|
||||
return (dev);
|
||||
return dev;
|
||||
}
|
||||
|
||||
@@ -90,14 +90,18 @@ key_process(uint16_t scan, int down)
|
||||
scancode *codes = scan_table;
|
||||
int c;
|
||||
|
||||
if (!codes)
|
||||
return;
|
||||
|
||||
if (!keyboard_scan || (keyboard_send == NULL))
|
||||
return;
|
||||
|
||||
oldkey[scan] = down;
|
||||
if (down && codes[scan].mk[0] == 0)
|
||||
|
||||
if (down && (codes[scan].mk[0] == 0))
|
||||
return;
|
||||
|
||||
if (!down && codes[scan].brk[0] == 0)
|
||||
if (!down && (codes[scan].brk[0] == 0))
|
||||
return;
|
||||
|
||||
/* TODO: The keyboard controller needs to report the AT flag to us here. */
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#define FLAG_AT 0x00 /* dev is AT or PS/2 */
|
||||
#define FLAG_TYPE_MASK 0x07 /* mask for type */
|
||||
|
||||
#define FIFO_SIZE 16
|
||||
|
||||
enum {
|
||||
KBD_84_KEY = 0,
|
||||
KBD_101_KEY,
|
||||
@@ -507,9 +509,7 @@ keyboard_at_set_scancode_set(void)
|
||||
static void
|
||||
add_data_vals(atkbc_dev_t *dev, uint8_t *val, uint8_t len)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
for (uint8_t i = 0; i < len; i++)
|
||||
kbc_at_dev_queue_add(dev, val[i], 1);
|
||||
}
|
||||
|
||||
@@ -518,7 +518,8 @@ add_data_kbd(uint16_t val)
|
||||
{
|
||||
atkbc_dev_t *dev = SavedKbd;
|
||||
uint8_t fake_shift[4];
|
||||
uint8_t num_lock = 0, shift_states = 0;
|
||||
uint8_t num_lock = 0;
|
||||
uint8_t shift_states = 0;
|
||||
|
||||
keyboard_get_states(NULL, &num_lock, NULL);
|
||||
shift_states = keyboard_get_shift() & STATE_SHIFT_MASK;
|
||||
@@ -720,7 +721,7 @@ static void
|
||||
keyboard_at_write(void *priv)
|
||||
{
|
||||
atkbc_dev_t *dev = (atkbc_dev_t *) priv;
|
||||
uint8_t i, val;
|
||||
uint8_t val;
|
||||
|
||||
if (dev->port == NULL)
|
||||
return;
|
||||
@@ -824,7 +825,7 @@ keyboard_at_write(void *priv)
|
||||
/* TODO: After keyboard type selection is implemented, make this
|
||||
return the correct keyboard ID for the selected type. */
|
||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
if (id_bytes[dev->type][i] == 0)
|
||||
break;
|
||||
|
||||
@@ -960,6 +961,8 @@ keyboard_at_init(const device_t *info)
|
||||
|
||||
dev->scan = &keyboard_scan;
|
||||
|
||||
dev->fifo_mask = FIFO_SIZE - 1;
|
||||
|
||||
if (dev->port != NULL)
|
||||
kbc_at_dev_reset(dev, 0);
|
||||
|
||||
@@ -969,7 +972,7 @@ keyboard_at_init(const device_t *info)
|
||||
inv_cmd_response = (dev->type & FLAG_PS2) ? 0xfe : 0xfa;
|
||||
|
||||
/* Return our private data to the I/O layer. */
|
||||
return (dev);
|
||||
return dev;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -343,10 +343,11 @@ const scancode scancode_xt[512] = {
|
||||
};
|
||||
|
||||
static uint8_t key_queue[16];
|
||||
static int key_queue_start = 0,
|
||||
key_queue_end = 0;
|
||||
static int is_tandy = 0, is_t1x00 = 0,
|
||||
is_amstrad = 0;
|
||||
static int key_queue_start = 0;
|
||||
static int key_queue_end = 0;
|
||||
static int is_tandy = 0;
|
||||
static int is_t1x00 = 0;
|
||||
static int is_amstrad = 0;
|
||||
|
||||
#ifdef ENABLE_KEYBOARD_XT_LOG
|
||||
int keyboard_xt_do_log = ENABLE_KEYBOARD_XT_LOG;
|
||||
@@ -370,9 +371,9 @@ static uint8_t
|
||||
get_fdd_switch_settings(void)
|
||||
{
|
||||
|
||||
int i, fdd_count = 0;
|
||||
uint8_t fdd_count = 0;
|
||||
|
||||
for (i = 0; i < FDD_NUM; i++) {
|
||||
for (uint8_t i = 0; i < FDD_NUM; i++) {
|
||||
if (fdd_get_flags(i))
|
||||
fdd_count++;
|
||||
}
|
||||
@@ -467,7 +468,8 @@ kbd_adddata(uint16_t val)
|
||||
void
|
||||
kbd_adddata_process(uint16_t val, void (*adddata)(uint16_t val))
|
||||
{
|
||||
uint8_t num_lock = 0, shift_states = 0;
|
||||
uint8_t num_lock = 0;
|
||||
uint8_t shift_states = 0;
|
||||
|
||||
if (!adddata)
|
||||
return;
|
||||
@@ -515,7 +517,9 @@ static void
|
||||
kbd_write(uint16_t port, uint8_t val, void *priv)
|
||||
{
|
||||
xtkbd_t *kbd = (xtkbd_t *) priv;
|
||||
uint8_t bit, set, new_clock;
|
||||
uint8_t bit;
|
||||
uint8_t set;
|
||||
uint8_t new_clock;
|
||||
|
||||
switch (port) {
|
||||
case 0x61: /* Keyboard Control Register (aka Port B) */
|
||||
@@ -684,7 +688,7 @@ kbd_read(uint16_t port, void *priv)
|
||||
break;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -700,7 +704,7 @@ kbd_reset(void *priv)
|
||||
|
||||
keyboard_scan = 1;
|
||||
|
||||
key_queue_start = 0,
|
||||
key_queue_start = 0;
|
||||
key_queue_end = 0;
|
||||
}
|
||||
|
||||
@@ -873,7 +877,7 @@ kbd_init(const device_t *info)
|
||||
|
||||
is_amstrad = 0;
|
||||
|
||||
return (kbd);
|
||||
return kbd;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -36,16 +36,16 @@ typedef struct {
|
||||
} mouse_t;
|
||||
|
||||
int mouse_type = 0;
|
||||
int mouse_x,
|
||||
mouse_y,
|
||||
mouse_z,
|
||||
mouse_buttons,
|
||||
mouse_mode,
|
||||
mouse_tablet_in_proximity = 0,
|
||||
tablet_tool_type = 1; /* 0 = Puck/Cursor, 1 = Pen */
|
||||
int mouse_x;
|
||||
int mouse_y;
|
||||
int mouse_z;
|
||||
int mouse_buttons;
|
||||
int mouse_mode;
|
||||
int mouse_tablet_in_proximity = 0;
|
||||
int tablet_tool_type = 1; /* 0 = Puck/Cursor, 1 = Pen */
|
||||
|
||||
double mouse_x_abs,
|
||||
mouse_y_abs;
|
||||
double mouse_x_abs;
|
||||
double mouse_y_abs;
|
||||
|
||||
pc_timer_t mouse_timer; /* mouse event timer */
|
||||
|
||||
@@ -266,18 +266,18 @@ mouse_get_from_internal_name(char *s)
|
||||
|
||||
while (mouse_devices[c].device != NULL) {
|
||||
if (!strcmp((char *) mouse_devices[c].device->internal_name, s))
|
||||
return (c);
|
||||
return c;
|
||||
c++;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
mouse_has_config(int mouse)
|
||||
{
|
||||
if (mouse_devices[mouse].device == NULL)
|
||||
return (0);
|
||||
return 0;
|
||||
|
||||
return (mouse_devices[mouse].device->config ? 1 : 0);
|
||||
}
|
||||
@@ -291,7 +291,7 @@ mouse_get_device(int mouse)
|
||||
int
|
||||
mouse_get_buttons(void)
|
||||
{
|
||||
return (mouse_nbut);
|
||||
return mouse_nbut;
|
||||
}
|
||||
|
||||
/* Return number of MOUSE types we know about. */
|
||||
|
||||
@@ -455,11 +455,11 @@ bm_poll(int x, int y, int z, int b, double abs_x, double abs_y, void *priv)
|
||||
int xor ;
|
||||
|
||||
if (!(dev->flags & FLAG_ENABLED))
|
||||
return (1); /* Mouse is disabled, do nothing. */
|
||||
return 1; /* Mouse is disabled, do nothing. */
|
||||
|
||||
if (!x && !y && !((b ^ dev->mouse_buttons_last) & 0x07)) {
|
||||
dev->mouse_buttons_last = b;
|
||||
return (1); /* State has not changed, do nothing. */
|
||||
return 1; /* State has not changed, do nothing. */
|
||||
}
|
||||
|
||||
/* Converts button states from MRL to LMR. */
|
||||
@@ -512,7 +512,7 @@ bm_poll(int x, int y, int z, int b, double abs_x, double abs_y, void *priv)
|
||||
bm_log("DEBUG: Data Interrupt Fired...\n");
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The timer calls us on every tick if the mouse is in timer mode
|
||||
@@ -520,7 +520,8 @@ bm_poll(int x, int y, int z, int b, double abs_x, double abs_y, void *priv)
|
||||
static void
|
||||
bm_update_data(mouse_t *dev)
|
||||
{
|
||||
int delta_x, delta_y;
|
||||
int delta_x;
|
||||
int delta_y;
|
||||
int xor ;
|
||||
|
||||
/* If the counters are not frozen, update them. */
|
||||
|
||||
@@ -30,13 +30,15 @@ enum {
|
||||
MODE_ECHO
|
||||
};
|
||||
|
||||
#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 */
|
||||
#define FLAG_SCALED 0x20 /* enable delta scaling */
|
||||
#define FLAG_ENABLED 0x10 /* dev is enabled for use */
|
||||
#define FLAG_CTRLDAT 0x08 /* ctrl or data mode */
|
||||
#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 */
|
||||
#define FLAG_SCALED 0x20 /* enable delta scaling */
|
||||
#define FLAG_ENABLED 0x10 /* dev is enabled for use */
|
||||
#define FLAG_CTRLDAT 0x08 /* ctrl or data mode */
|
||||
|
||||
#define FIFO_SIZE 16
|
||||
|
||||
int mouse_scan = 0;
|
||||
|
||||
@@ -73,7 +75,7 @@ ps2_report_coordinates(atkbc_dev_t *dev, int main)
|
||||
int temp_z;
|
||||
|
||||
if (dev->x > 255) {
|
||||
dev->x = 255;
|
||||
dev->x = 255;
|
||||
buff[0] |= 0x40;
|
||||
}
|
||||
if (dev->x < -256) {
|
||||
@@ -97,14 +99,7 @@ ps2_report_coordinates(atkbc_dev_t *dev, int main)
|
||||
buff[0] |= 0x10;
|
||||
if (dev->y < 0)
|
||||
buff[0] |= 0x20;
|
||||
if (mouse_buttons & 0x01)
|
||||
buff[0] |= 0x01;
|
||||
if (mouse_buttons & 0x02)
|
||||
buff[0] |= 0x02;
|
||||
if (dev->flags & FLAG_INTELLI) {
|
||||
if (mouse_buttons & 0x04)
|
||||
buff[0] |= 0x04;
|
||||
}
|
||||
buff[0] |= (dev->b & ((dev->flags & FLAG_INTELLI) ? 0x07 : 0x03));
|
||||
buff[1] = (dev->x & 0xff);
|
||||
buff[2] = (dev->y & 0xff);
|
||||
|
||||
@@ -113,7 +108,7 @@ ps2_report_coordinates(atkbc_dev_t *dev, int 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)) {
|
||||
if (dev->flags & FLAG_5BTN) {
|
||||
if (mouse_buttons & 8)
|
||||
temp_z |= 0x10;
|
||||
if (mouse_buttons & 16)
|
||||
@@ -155,7 +150,8 @@ static void
|
||||
ps2_write(void *priv)
|
||||
{
|
||||
atkbc_dev_t *dev = (atkbc_dev_t *) priv;
|
||||
uint8_t temp, val;
|
||||
uint8_t temp;
|
||||
uint8_t val;
|
||||
static uint8_t last_data[6] = { 0x00 };
|
||||
|
||||
if (dev->port == NULL)
|
||||
@@ -317,20 +313,27 @@ static int
|
||||
ps2_poll(int x, int y, int z, int b, double abs_x, double abs_y, void *priv)
|
||||
{
|
||||
atkbc_dev_t *dev = (atkbc_dev_t *) priv;
|
||||
int packet_size = (dev->flags & FLAG_INTMODE) ? 4 : 3;
|
||||
|
||||
if (!mouse_scan || (!x && !y && !z && (b == dev->b)))
|
||||
return (0xff);
|
||||
return 0xff;
|
||||
|
||||
dev->x += x;
|
||||
dev->y -= y;
|
||||
dev->z -= z;
|
||||
if ((dev->mode == MODE_STREAM) && (kbc_at_dev_queue_pos(dev, 1) < 13)) {
|
||||
if ((dev->mode == MODE_STREAM) && (kbc_at_dev_queue_pos(dev, 1) < (FIFO_SIZE - packet_size))) {
|
||||
dev->x = x;
|
||||
dev->y = -y;
|
||||
dev->z = -z;
|
||||
dev->b = b;
|
||||
} else {
|
||||
dev->x += x;
|
||||
dev->y -= y;
|
||||
dev->z -= z;
|
||||
dev->b = b;
|
||||
|
||||
ps2_report_coordinates(dev, 1);
|
||||
}
|
||||
|
||||
return (0);
|
||||
if ((dev->mode == MODE_STREAM) && (kbc_at_dev_queue_pos(dev, 1) < (FIFO_SIZE - packet_size)))
|
||||
ps2_report_coordinates(dev, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -367,11 +370,13 @@ mouse_ps2_init(const device_t *info)
|
||||
|
||||
dev->scan = &mouse_scan;
|
||||
|
||||
dev->fifo_mask = FIFO_SIZE - 1;
|
||||
|
||||
if (dev->port != NULL)
|
||||
kbc_at_dev_reset(dev, 0);
|
||||
|
||||
/* Return our private data to the I/O layer. */
|
||||
return (dev);
|
||||
return dev;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -284,7 +284,7 @@ static uint8_t
|
||||
sermouse_data_hex(mouse_t *dev, int x, int y, int b)
|
||||
{
|
||||
char ret[6] = { 0, 0, 0, 0, 0, 0 };
|
||||
uint8_t i, but = 0x00;
|
||||
uint8_t but = 0x00;
|
||||
|
||||
but |= (b & 0x01) ? 0x04 : 0x00; /* left button */
|
||||
but |= (b & 0x04) ? 0x02 : 0x00; /* middle button */
|
||||
@@ -292,7 +292,7 @@ sermouse_data_hex(mouse_t *dev, int x, int y, int b)
|
||||
|
||||
sprintf(ret, "%02X%02X%01X", (int8_t) y, (int8_t) x, but & 0x0f);
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
for (uint8_t i = 0; i < 5; i++)
|
||||
dev->data[i] = ret[4 - i];
|
||||
|
||||
return 5;
|
||||
@@ -371,7 +371,8 @@ sermouse_last_button_status(mouse_t *dev)
|
||||
static void
|
||||
sermouse_update_delta(mouse_t *dev, int *local, int *global)
|
||||
{
|
||||
int min, max;
|
||||
int min;
|
||||
int max;
|
||||
|
||||
if (dev->format == 3) {
|
||||
min = -2048;
|
||||
@@ -397,7 +398,9 @@ static uint8_t
|
||||
sermouse_update_data(mouse_t *dev)
|
||||
{
|
||||
uint8_t ret = 0;
|
||||
int delta_x, delta_y, delta_z;
|
||||
int delta_x;
|
||||
int delta_y;
|
||||
int delta_z;
|
||||
|
||||
/* Update the deltas and the delays. */
|
||||
sermouse_update_delta(dev, &delta_x, &dev->rel_x);
|
||||
@@ -529,7 +532,7 @@ sermouse_poll(int x, int y, int z, int b, double abs_x, double abs_y, void *priv
|
||||
|
||||
if (!x && !y && !z && (b == dev->oldb)) {
|
||||
dev->oldb = b;
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
dev->oldb = b;
|
||||
@@ -568,7 +571,7 @@ sermouse_poll(int x, int y, int z, int b, double abs_x, double abs_y, void *priv
|
||||
dev->rel_y += y;
|
||||
dev->rel_z += z;
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -373,7 +373,8 @@ wacom_write(struct serial_s *serial, void *priv, uint8_t data)
|
||||
if (!memcmp(wacom->data_rec, "~*", 2)) {
|
||||
uint32_t settings_dword = wacom->settings;
|
||||
if (strstr((const char *) wacom->data_rec, ",")) {
|
||||
uint32_t x_res = wacom->x_res, y_res = wacom->y_res;
|
||||
uint32_t x_res = wacom->x_res;
|
||||
uint32_t y_res = wacom->y_res;
|
||||
uint32_t increment = wacom->increment;
|
||||
uint32_t interval = wacom->interval;
|
||||
|
||||
@@ -423,7 +424,7 @@ wacom_poll(int x, int y, int z, int b, double abs_x, double abs_y, void *priv)
|
||||
if (wacom->b != b)
|
||||
wacom->oldb = wacom->b;
|
||||
wacom->b = b;
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -532,7 +532,11 @@ pci_bridge_reset(void *priv)
|
||||
static void *
|
||||
pci_bridge_init(const device_t *info)
|
||||
{
|
||||
uint8_t interrupts[4], interrupt_count, interrupt_mask, slot_count, i;
|
||||
uint8_t interrupts[4];
|
||||
uint8_t interrupt_count;
|
||||
uint8_t interrupt_mask;
|
||||
uint8_t slot_count;
|
||||
uint8_t i;
|
||||
|
||||
pci_bridge_t *dev = (pci_bridge_t *) malloc(sizeof(pci_bridge_t));
|
||||
memset(dev, 0, sizeof(pci_bridge_t));
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
|
||||
static uint16_t postcard_port;
|
||||
static uint8_t postcard_written;
|
||||
static uint8_t postcard_code, postcard_prev_code;
|
||||
static uint8_t postcard_code;
|
||||
static uint8_t postcard_prev_code;
|
||||
#define UISTR_LEN 13
|
||||
static char postcard_str[UISTR_LEN]; /* UI output string */
|
||||
|
||||
|
||||
@@ -266,13 +266,11 @@ serial_transmit(serial_t *dev, uint8_t val)
|
||||
static void
|
||||
serial_move_to_txsr(serial_t *dev)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
if (dev->fifo_enabled) {
|
||||
dev->txsr = dev->xmit_fifo[0];
|
||||
if (dev->xmit_fifo_pos > 0) {
|
||||
/* Move the entire fifo forward by one byte. */
|
||||
for (i = 1; i < 16; i++)
|
||||
for (uint8_t i = 1; i < 16; i++)
|
||||
dev->xmit_fifo[i - 1] = dev->xmit_fifo[i];
|
||||
/* Decrease FIFO position. */
|
||||
dev->xmit_fifo_pos--;
|
||||
@@ -476,7 +474,8 @@ void
|
||||
serial_write(uint16_t addr, uint8_t val, void *p)
|
||||
{
|
||||
serial_t *dev = (serial_t *) p;
|
||||
uint8_t new_msr, old;
|
||||
uint8_t new_msr;
|
||||
uint8_t old;
|
||||
|
||||
// serial_log("UART: Write %02X to port %02X\n", val, addr);
|
||||
serial_log("UART: [%04X:%08X] Write %02X to port %02X\n", CS, cpu_state.pc, val, addr);
|
||||
|
||||
@@ -52,9 +52,7 @@ serial_passthrough_log(const char *fmt, ...)
|
||||
void
|
||||
serial_passthrough_init(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
for (c = 0; c < SERIAL_MAX; c++) {
|
||||
for (uint8_t c = 0; c < SERIAL_MAX; c++) {
|
||||
if (serial_passthrough_enabled[c]) {
|
||||
/* Instance n for COM n */
|
||||
device_add_inst(&serial_passthrough_device, c + 1);
|
||||
@@ -139,7 +137,7 @@ serial_passthrough_transmit_period(serial_t *serial, void *p, double transmit_pe
|
||||
|
||||
if (dev->mode != SERPT_MODE_HOSTSER)
|
||||
return;
|
||||
dev->baudrate = 1000000.0 / (transmit_period);
|
||||
dev->baudrate = 1000000.0 / transmit_period;
|
||||
|
||||
serial_passthrough_speed_changed(p);
|
||||
plat_serpt_set_params(dev);
|
||||
|
||||
@@ -90,7 +90,10 @@ static void
|
||||
smbus_ali7101_write(uint16_t addr, uint8_t val, void *priv)
|
||||
{
|
||||
smbus_ali7101_t *dev = (smbus_ali7101_t *) priv;
|
||||
uint8_t smbus_addr, cmd, read, prev_stat;
|
||||
uint8_t smbus_addr;
|
||||
uint8_t cmd;
|
||||
uint8_t read;
|
||||
uint8_t prev_stat;
|
||||
uint16_t timer_bytes = 0;
|
||||
|
||||
smbus_ali7101_log("SMBus ALI7101: write(%02X, %02X)\n", addr, val);
|
||||
|
||||
@@ -126,8 +126,13 @@ static void
|
||||
smbus_piix4_write(uint16_t addr, uint8_t val, void *priv)
|
||||
{
|
||||
smbus_piix4_t *dev = (smbus_piix4_t *) priv;
|
||||
uint8_t smbus_addr, cmd, read, block_len, prev_stat;
|
||||
uint16_t timer_bytes = 0, i = 0;
|
||||
uint8_t smbus_addr;
|
||||
uint8_t cmd;
|
||||
uint8_t read;
|
||||
uint8_t block_len;
|
||||
uint8_t prev_stat;
|
||||
uint16_t timer_bytes = 0;
|
||||
uint16_t i = 0;
|
||||
|
||||
smbus_piix4_log("SMBus PIIX4: write(%02X, %02X)\n", addr, val);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user