mirror of
https://github.com/86Box/86Box.git
synced 2026-02-23 09:58:19 -07:00
Removed the file pointer from the hdd_t struct;
Partially split off the Logitech Serial Mouse emulation from Microsoft Serial Mouse; Slightly reworked serial port emulation (the two UART's are now device_t's, non-FIFO mode implemented and is now default, FIFO mode reimplemented from scratch so it's now actually correct); Added the emulation of the SiS 85c497 chip to the SiS 85c496/497 chipset; Bugfixes to the emulated Super I/O chips and made them all device_t's now.
This commit is contained in:
134
src/intel.c
134
src/intel.c
@@ -3,9 +3,11 @@
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include "cpu/cpu.h"
|
||||
#include "device.h"
|
||||
#include "machine/machine.h"
|
||||
#include "io.h"
|
||||
#include "mem.h"
|
||||
@@ -14,57 +16,113 @@
|
||||
#include "intel.h"
|
||||
|
||||
|
||||
uint8_t batman_brdconfig(uint16_t port, void *p)
|
||||
typedef struct {
|
||||
uint16_t timer_latch;
|
||||
|
||||
int64_t timer;
|
||||
} batman_t;
|
||||
|
||||
|
||||
static uint8_t
|
||||
batman_config_read(uint16_t port, void *priv)
|
||||
{
|
||||
switch (port)
|
||||
{
|
||||
case 0x73:
|
||||
return 0xff;
|
||||
case 0x75:
|
||||
return 0xdf;
|
||||
}
|
||||
return 0;
|
||||
uint8_t ret = 0x00;
|
||||
|
||||
switch (port & 0x000f) {
|
||||
case 3:
|
||||
ret = 0xff;
|
||||
break;
|
||||
case 5:
|
||||
ret = 0xdf;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static uint16_t batman_timer_latch;
|
||||
static int64_t batman_timer = 0;
|
||||
static void batman_timer_over(void *p)
|
||||
|
||||
static void
|
||||
batman_timer_over(void *priv)
|
||||
{
|
||||
batman_timer = 0;
|
||||
batman_t *dev = (batman_t *) priv;
|
||||
|
||||
dev->timer = 0;
|
||||
}
|
||||
|
||||
static void batman_timer_write(uint16_t addr, uint8_t val, void *p)
|
||||
|
||||
static void
|
||||
batman_timer_write(uint16_t addr, uint8_t val, void *priv)
|
||||
{
|
||||
if (addr & 1)
|
||||
batman_timer_latch = (batman_timer_latch & 0xff) | (val << 8);
|
||||
else
|
||||
batman_timer_latch = (batman_timer_latch & 0xff00) | val;
|
||||
batman_timer = batman_timer_latch * TIMER_USEC;
|
||||
batman_t *dev = (batman_t *) priv;
|
||||
|
||||
if (addr & 1)
|
||||
dev->timer_latch = (dev->timer_latch & 0xff) | (val << 8);
|
||||
else
|
||||
dev->timer_latch = (dev->timer_latch & 0xff00) | val;
|
||||
|
||||
dev->timer = dev->timer_latch * TIMER_USEC;
|
||||
}
|
||||
|
||||
static uint8_t batman_timer_read(uint16_t addr, void *p)
|
||||
|
||||
static uint8_t
|
||||
batman_timer_read(uint16_t addr, void *priv)
|
||||
{
|
||||
uint16_t batman_timer_latch;
|
||||
|
||||
cycles -= (int)PITCONST;
|
||||
|
||||
timer_clock();
|
||||
batman_t *dev = (batman_t *) priv;
|
||||
uint16_t batman_timer_latch;
|
||||
uint8_t ret;
|
||||
|
||||
if (batman_timer < 0)
|
||||
return 0;
|
||||
|
||||
batman_timer_latch = batman_timer / TIMER_USEC;
|
||||
cycles -= (int)PITCONST;
|
||||
|
||||
if (addr & 1)
|
||||
return batman_timer_latch >> 8;
|
||||
return batman_timer_latch & 0xff;
|
||||
timer_clock();
|
||||
|
||||
if (dev->timer < 0)
|
||||
return 0;
|
||||
|
||||
batman_timer_latch = dev->timer / TIMER_USEC;
|
||||
|
||||
if (addr & 1)
|
||||
ret = batman_timer_latch >> 8;
|
||||
else
|
||||
ret = batman_timer_latch & 0xff;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void intel_batman_init()
|
||||
{
|
||||
io_sethandler(0x0073, 0x0001, batman_brdconfig, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
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);
|
||||
timer_add(batman_timer_over, &batman_timer, &batman_timer, NULL);
|
||||
static void
|
||||
intel_batman_close(void *priv)
|
||||
{
|
||||
batman_t *dev = (batman_t *) priv;
|
||||
|
||||
free(dev);
|
||||
}
|
||||
|
||||
|
||||
static void *
|
||||
intel_batman_init(const device_t *info)
|
||||
{
|
||||
batman_t *dev = (batman_t *) malloc(sizeof(batman_t));
|
||||
memset(dev, 0, sizeof(batman_t));
|
||||
|
||||
io_sethandler(0x0073, 0x0001,
|
||||
batman_config_read, NULL, NULL, NULL, NULL, NULL, dev);
|
||||
io_sethandler(0x0075, 0x0001,
|
||||
batman_config_read, NULL, NULL, NULL, NULL, NULL, dev);
|
||||
|
||||
io_sethandler(0x0078, 0x0002,
|
||||
batman_timer_read, NULL, NULL, batman_timer_write, NULL, NULL, dev);
|
||||
|
||||
timer_add(batman_timer_over, &dev->timer, &dev->timer, dev);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
|
||||
const device_t intel_batman_device = {
|
||||
"Intel Batman board chip",
|
||||
0,
|
||||
0,
|
||||
intel_batman_init, intel_batman_close, NULL,
|
||||
NULL, NULL, NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user