Sanitize some old chipset code (Part 3)
Fixed the Indentation of the Intel 82335, removed useless includes and numerous bugfixes on the OPTi Python.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Implementation of the Intel 82335(KU82335) chipset.
|
||||
*
|
||||
* Copyright 2020 Tiseno100
|
||||
* Copyright 2021 Tiseno100
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -24,10 +24,7 @@
|
||||
#include <86box/timer.h>
|
||||
#include <86box/io.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/keyboard.h>
|
||||
#include <86box/mem.h>
|
||||
#include <86box/fdd.h>
|
||||
#include <86box/fdc.h>
|
||||
#include <86box/chipset.h>
|
||||
|
||||
/* Shadow capabilities */
|
||||
@@ -38,7 +35,7 @@
|
||||
|
||||
/* Granularity Register Enable & Recalc */
|
||||
#define EXTENDED_GRANULARITY_ENABLED (dev->regs[0x2c] & 0x01)
|
||||
#define GRANULARITY_RECALC ((dev->regs[0x2e] & (1 << (i+8))) ? ((dev->regs[0x2e] & (1 << i)) ? RO_SHADOW : RW_SHADOW) : DISABLED_SHADOW)
|
||||
#define GRANULARITY_RECALC ((dev->regs[0x2e] & (1 << (i + 8))) ? ((dev->regs[0x2e] & (1 << i)) ? RO_SHADOW : RW_SHADOW) : DISABLED_SHADOW)
|
||||
|
||||
/* R/W operator for the Video RAM region */
|
||||
#define DETERMINE_VIDEO_RAM_WRITE_ACCESS ((dev->regs[0x22] & (0x08 << 8)) ? RW_SHADOW : RO_SHADOW)
|
||||
@@ -61,8 +58,8 @@ typedef struct
|
||||
{
|
||||
|
||||
uint16_t regs[256],
|
||||
|
||||
cfg_locked;
|
||||
|
||||
cfg_locked;
|
||||
|
||||
} intel_82335_t;
|
||||
|
||||
@@ -73,10 +70,11 @@ intel_82335_log(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (intel_82335_do_log) {
|
||||
va_start(ap, fmt);
|
||||
pclog_ex(fmt, ap);
|
||||
va_end(ap);
|
||||
if (intel_82335_do_log)
|
||||
{
|
||||
va_start(ap, fmt);
|
||||
pclog_ex(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
#else
|
||||
@@ -86,92 +84,90 @@ intel_82335_log(const char *fmt, ...)
|
||||
static void
|
||||
intel_82335_write(uint16_t addr, uint16_t val, void *priv)
|
||||
{
|
||||
intel_82335_t *dev = (intel_82335_t *) priv;
|
||||
intel_82335_t *dev = (intel_82335_t *)priv;
|
||||
uint32_t romsize = 0, base = 0, i = 0, rc1_remap = 0, rc2_remap = 0;
|
||||
|
||||
dev->regs[addr] = val;
|
||||
|
||||
if(!dev->cfg_locked)
|
||||
if (!dev->cfg_locked)
|
||||
{
|
||||
|
||||
intel_82335_log("Register %02x: Write %04x\n", addr, val);
|
||||
intel_82335_log("Register %02x: Write %04x\n", addr, val);
|
||||
|
||||
switch (addr) {
|
||||
case 0x22: /* Memory Controller */
|
||||
switch (addr)
|
||||
{
|
||||
case 0x22: /* Memory Controller */
|
||||
|
||||
/* Check if the ROM chips are 256 or 512Kbit (Just for Shadowing sanity) */
|
||||
romsize = ROM_SIZE;
|
||||
/* Check if the ROM chips are 256 or 512Kbit (Just for Shadowing sanity) */
|
||||
romsize = ROM_SIZE;
|
||||
|
||||
if (!EXTENDED_GRANULARITY_ENABLED)
|
||||
{
|
||||
shadowbios = !!(dev->regs[0x22] & 0x01);
|
||||
shadowbios_write = !!(dev->regs[0x22] & 0x01);
|
||||
if (!EXTENDED_GRANULARITY_ENABLED)
|
||||
{
|
||||
shadowbios = !!(dev->regs[0x22] & 0x01);
|
||||
shadowbios_write = !!(dev->regs[0x22] & 0x01);
|
||||
|
||||
/* Base System 512/640KB set */
|
||||
mem_set_mem_state_both(0x80000, 0x20000, (dev->regs[0x22] & 0x08) ? ENABLE_TOP_128KB : DISABLE_TOP_128KB);
|
||||
/* Base System 512/640KB set */
|
||||
mem_set_mem_state_both(0x80000, 0x20000, (dev->regs[0x22] & 0x08) ? ENABLE_TOP_128KB : DISABLE_TOP_128KB);
|
||||
|
||||
/* Video RAM shadow*/
|
||||
mem_set_mem_state_both(0xa0000, 0x20000, (dev->regs[0x22] & (0x04 << 8)) ? DETERMINE_VIDEO_RAM_WRITE_ACCESS : DISABLED_SHADOW);
|
||||
/* Video RAM shadow*/
|
||||
mem_set_mem_state_both(0xa0000, 0x20000, (dev->regs[0x22] & (0x04 << 8)) ? DETERMINE_VIDEO_RAM_WRITE_ACCESS : DISABLED_SHADOW);
|
||||
|
||||
/* Option ROM shadow */
|
||||
mem_set_mem_state_both(0xc0000, 0x20000, (dev->regs[0x22] & (0x02 << 8)) ? ENABLED_SHADOW : DISABLED_SHADOW);
|
||||
/* Option ROM shadow */
|
||||
mem_set_mem_state_both(0xc0000, 0x20000, (dev->regs[0x22] & (0x02 << 8)) ? ENABLED_SHADOW : DISABLED_SHADOW);
|
||||
|
||||
/* System ROM shadow */
|
||||
mem_set_mem_state_both(0xe0000, 0x20000, (dev->regs[0x22] & 0x01) ? ENABLED_SHADOW : DISABLED_SHADOW);
|
||||
}
|
||||
break;
|
||||
/* System ROM shadow */
|
||||
mem_set_mem_state_both(0xe0000, 0x20000, (dev->regs[0x22] & 0x01) ? ENABLED_SHADOW : DISABLED_SHADOW);
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x24: /* Roll Compare (Just top remapping. Not followed according to datasheet!) */
|
||||
case 0x26:
|
||||
rc1_remap = (dev->regs[0x24] & 0x01) ? DEFINE_RC1_REMAP_SIZE : 0;
|
||||
rc2_remap = (dev->regs[0x26] & 0x01) ? DEFINE_RC2_REMAP_SIZE : 0;
|
||||
mem_remap_top(rc1_remap+rc2_remap);
|
||||
break;
|
||||
case 0x24: /* Roll Compare (Just top remapping. Not followed according to datasheet!) */
|
||||
case 0x26:
|
||||
rc1_remap = (dev->regs[0x24] & 0x01) ? DEFINE_RC1_REMAP_SIZE : 0;
|
||||
rc2_remap = (dev->regs[0x26] & 0x01) ? DEFINE_RC2_REMAP_SIZE : 0;
|
||||
mem_remap_top(rc1_remap + rc2_remap);
|
||||
break;
|
||||
|
||||
case 0x2e: /* Extended Granularity (Enabled if Bit 0 in Register 2Ch is set) */
|
||||
if(EXTENDED_GRANULARITY_ENABLED)
|
||||
{
|
||||
for(i=0; i<8; i++)
|
||||
{
|
||||
base = 0xc0000 + (i << 15);
|
||||
shadowbios = (dev->regs[0x2e] & (1 << (i+8))) && (base == romsize);
|
||||
shadowbios_write = (dev->regs[0x2e] & (1 << i)) && (base == romsize);
|
||||
mem_set_mem_state_both(base, 0x8000, GRANULARITY_RECALC);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
case 0x2e: /* Extended Granularity (Enabled if Bit 0 in Register 2Ch is set) */
|
||||
if (EXTENDED_GRANULARITY_ENABLED)
|
||||
{
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
base = 0xc0000 + (i << 15);
|
||||
shadowbios = (dev->regs[0x2e] & (1 << (i + 8))) && (base == romsize);
|
||||
shadowbios_write = (dev->regs[0x2e] & (1 << i)) && (base == romsize);
|
||||
mem_set_mem_state_both(base, 0x8000, GRANULARITY_RECALC);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Unlock/Lock configuration registers */
|
||||
dev->cfg_locked = LOCK_STATUS;
|
||||
}
|
||||
|
||||
|
||||
static uint16_t
|
||||
intel_82335_read(uint16_t addr, void *priv)
|
||||
{
|
||||
intel_82335_t *dev = (intel_82335_t *) priv;
|
||||
intel_82335_t *dev = (intel_82335_t *)priv;
|
||||
|
||||
intel_82335_log("Register %02x: Read %04x\n", addr, dev->regs[addr]);
|
||||
|
||||
return dev->regs[addr];
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
intel_82335_close(void *priv)
|
||||
{
|
||||
intel_82335_t *dev = (intel_82335_t *) priv;
|
||||
intel_82335_t *dev = (intel_82335_t *)priv;
|
||||
|
||||
free(dev);
|
||||
}
|
||||
|
||||
|
||||
static void *
|
||||
intel_82335_init(const device_t *info)
|
||||
{
|
||||
intel_82335_t *dev = (intel_82335_t *) malloc(sizeof(intel_82335_t));
|
||||
intel_82335_t *dev = (intel_82335_t *)malloc(sizeof(intel_82335_t));
|
||||
memset(dev, 0, sizeof(intel_82335_t));
|
||||
|
||||
memset(dev->regs, 0, sizeof(dev->regs));
|
||||
@@ -195,17 +191,19 @@ intel_82335_init(const device_t *info)
|
||||
io_sethandler(0x002c, 0x0001, NULL, intel_82335_read, NULL, NULL, intel_82335_write, NULL, dev);
|
||||
|
||||
/* Extended Granularity */
|
||||
io_sethandler(0x002e, 0x0001, NULL, intel_82335_read, NULL, NULL, intel_82335_write, NULL, dev);
|
||||
|
||||
io_sethandler(0x002e, 0x0001, NULL, intel_82335_read, NULL, NULL, intel_82335_write, NULL, dev);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
|
||||
const device_t intel_82335_device = {
|
||||
"Intel 82335",
|
||||
0,
|
||||
0,
|
||||
intel_82335_init, intel_82335_close, NULL,
|
||||
{ NULL }, NULL, NULL,
|
||||
NULL
|
||||
};
|
||||
intel_82335_init,
|
||||
intel_82335_close,
|
||||
NULL,
|
||||
{NULL},
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
|
||||
Reference in New Issue
Block a user