Changes since v0.7 : - Major CPU reorganisation. This has possibly broken some stuff, though I fixed all the regressions I could find - Lazy flags. This brought 10% speed improvement at one point, but that's probably been lost now - 430 VX chipset emulation - IDT Winchip emulation (currently sans MMX). Timing is probably wrong - Fixed a few FPU bugs - Timer reorganisation - Sound reorganisation - Other general reorganisation - AdLib Gold emulation - Windows Sound System emulation - Pro Audio Spectrum 16 emulation. This currently works with most DOS stuff, but not in Windows - Major improvements to GUS emulation. Has the downside that it now conflicts with SB emulation, so probably best to not enable both simultaneously - New graphics cards : - ATI-18800 (VGA Edge-16) - ATI-28800 (VGA Charger) - ATI Mach64GX (Graphics Pro Turbo). Quite a few features missing, but Windows doesn't seem to use half the features of this card - Cirrus Logic CL-GD5429. Blitter is a bit broken - Oak OTI-067 - S3 Trio64 (Number Nine 9FX) - S3 Virge. Only framebuffer stuff at the minute, Windows won't recognise the card - Trident TGUI-9440 - VGA. Doesn't work yet - Beginnings of 3DFX emulation, however this is in extremely early stages and doesn't do anything useful - Fixed DMA bug stopping floppy drives working in Windows 3.x - Fixed some other stuff probably - Broke some other stuff probably as well
100 lines
3.2 KiB
C
100 lines
3.2 KiB
C
#include "ibm.h"
|
|
#include "io.h"
|
|
#include "mem.h"
|
|
|
|
#include "pci.h"
|
|
|
|
void (*pci_card_write[32])(int func, int addr, uint8_t val, void *priv);
|
|
uint8_t (*pci_card_read[32])(int func, int addr, void *priv);
|
|
void *pci_priv[32];
|
|
static int pci_index, pci_func, pci_card, pci_bus, pci_enable;
|
|
|
|
void pci_write(uint16_t port, uint8_t val, void *priv)
|
|
{
|
|
switch (port)
|
|
{
|
|
case 0xcf8:
|
|
pci_index = val;
|
|
break;
|
|
case 0xcf9:
|
|
pci_func = val & 7;
|
|
pci_card = val >> 3;
|
|
break;
|
|
case 0xcfa:
|
|
pci_bus = val;
|
|
break;
|
|
case 0xcfb:
|
|
pci_enable = val & 0x80;
|
|
break;
|
|
|
|
case 0xcfc: case 0xcfd: case 0xcfe: case 0xcff:
|
|
if (!pci_enable)
|
|
return;
|
|
|
|
// pclog("PCI write bus %i card %i func %i index %02X val %02X %04X:%04X\n", pci_bus, pci_card, pci_func, pci_index | (port & 3), val, CS, pc);
|
|
|
|
if (!pci_bus && pci_card_write[pci_card])
|
|
pci_card_write[pci_card](pci_func, pci_index | (port & 3), val, pci_priv[pci_card]);
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
uint8_t pci_read(uint16_t port, void *priv)
|
|
{
|
|
switch (port)
|
|
{
|
|
case 0xcf8:
|
|
return pci_index;
|
|
case 0xcf9:
|
|
return pci_card << 3;
|
|
case 0xcfa:
|
|
return pci_bus;
|
|
case 0xcfb:
|
|
return pci_enable;
|
|
|
|
case 0xcfc: case 0xcfd: case 0xcfe: case 0xcff:
|
|
if (!pci_enable)
|
|
return 0xff;
|
|
|
|
// pclog("PCI read bus %i card %i func %i index %02X\n", pci_bus, pci_card, pci_func, pci_index | (port & 3));
|
|
|
|
if (!pci_bus && pci_card_read[pci_card])
|
|
return pci_card_read[pci_card](pci_func, pci_index | (port & 3), pci_priv[pci_card]);
|
|
|
|
return 0xff;
|
|
}
|
|
}
|
|
|
|
void pci_init()
|
|
{
|
|
int c;
|
|
|
|
io_sethandler(0x0cf8, 0x0008, pci_read, NULL, NULL, pci_write, NULL, NULL, NULL);
|
|
|
|
for (c = 0; c < 32; c++)
|
|
pci_card_read[c] = pci_card_write[c] = pci_priv[c] = NULL;
|
|
}
|
|
|
|
void pci_add_specific(int card, uint8_t (*read)(int func, int addr, void *priv), void (*write)(int func, int addr, uint8_t val, void *priv), void *priv)
|
|
{
|
|
pci_card_read[card] = read;
|
|
pci_card_write[card] = write;
|
|
pci_priv[card] = priv;
|
|
}
|
|
|
|
void pci_add(uint8_t (*read)(int func, int addr, void *priv), void (*write)(int func, int addr, uint8_t val, void *priv), void *priv)
|
|
{
|
|
int c;
|
|
|
|
for (c = 0; c < 32; c++)
|
|
{
|
|
if (!pci_card_read[c] && !pci_card_write[c])
|
|
{
|
|
pci_card_read[c] = read;
|
|
pci_card_write[c] = write;
|
|
pci_priv[c] = priv;
|
|
return;
|
|
}
|
|
}
|
|
}
|