Updated network code to dynamically load WinPcap, and other cleanups.

This commit is contained in:
waltje
2017-05-22 01:08:10 -04:00
23 changed files with 175 additions and 93 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -1256,7 +1256,7 @@ uint8_t svga_read(uint32_t addr, void *p)
if (svga->chain4 || svga->fb_only) if (svga->chain4 || svga->fb_only)
{ {
if (addr >= svga->vram_limit) if (addr >= svga->vram_limit)
return 0x00; return 0xff;
return svga->vram[svga_mask_addr(addr, svga)]; return svga->vram[svga_mask_addr(addr, svga)];
} }
else if (svga->chain2_read) else if (svga->chain2_read)
@@ -1274,7 +1274,7 @@ uint8_t svga_read(uint32_t addr, void *p)
addr<<=2; addr<<=2;
if (addr >= svga->vram_limit) if (addr >= svga->vram_limit)
return 0x00; return 0xff;
addr = svga_mask_addr(addr, svga); addr = svga_mask_addr(addr, svga);

View File

@@ -664,6 +664,8 @@ END
163 ICON DISCARDABLE "ICONS/cdrom_atapi_dma_active.ico" 163 ICON DISCARDABLE "ICONS/cdrom_atapi_dma_active.ico"
164 ICON DISCARDABLE "ICONS/cdrom_scsi.ico" 164 ICON DISCARDABLE "ICONS/cdrom_scsi.ico"
165 ICON DISCARDABLE "ICONS/cdrom_scsi_active.ico" 165 ICON DISCARDABLE "ICONS/cdrom_scsi_active.ico"
176 ICON DISCARDABLE "ICONS/hard_disk_removable_scsi.ico"
177 ICON DISCARDABLE "ICONS/hard_disk_removable_scsi_active.ico"
192 ICON DISCARDABLE "ICONS/hard_disk_mfm.ico" 192 ICON DISCARDABLE "ICONS/hard_disk_mfm.ico"
193 ICON DISCARDABLE "ICONS/hard_disk_mfm_active.ico" 193 ICON DISCARDABLE "ICONS/hard_disk_mfm_active.ico"
194 ICON DISCARDABLE "ICONS/hard_disk.ico" 194 ICON DISCARDABLE "ICONS/hard_disk.ico"
@@ -702,6 +704,8 @@ END
419 ICON DISCARDABLE "ICONS/cdrom_atapi_dma_empty_active.ico" 419 ICON DISCARDABLE "ICONS/cdrom_atapi_dma_empty_active.ico"
420 ICON DISCARDABLE "ICONS/cdrom_scsi_empty.ico" 420 ICON DISCARDABLE "ICONS/cdrom_scsi_empty.ico"
421 ICON DISCARDABLE "ICONS/cdrom_scsi_empty_active.ico" 421 ICON DISCARDABLE "ICONS/cdrom_scsi_empty_active.ico"
432 ICON DISCARDABLE "ICONS/hard_disk_removable_scsi_empty.ico"
433 ICON DISCARDABLE "ICONS/hard_disk_removable_scsi_empty_active.ico"
512 ICON DISCARDABLE "ICONS/floppy_disabled.ico" 512 ICON DISCARDABLE "ICONS/floppy_disabled.ico"
514 ICON DISCARDABLE "ICONS/cdrom_disabled.ico" 514 ICON DISCARDABLE "ICONS/cdrom_disabled.ico"
@@ -1003,8 +1007,10 @@ BEGIN
2198 "Removable disk %i: %s" 2198 "Removable disk %i: %s"
2199 "USB is not yet supported" 2199 "USB is not yet supported"
2200 "Invalid PCap device" 2200 "Invalid PCap device"
2201 "English (United States)" 2201 "SCSI removable disk: %ws"
2202 "Pcap Library Not Available" 2202 "<Placeholder string>"
2203 "English (United States)"
2204 "Pcap Library Not Available"
END END

View File

@@ -809,6 +809,23 @@ void create_cdrom_tip(int part)
} }
} }
void create_removable_hd_tip(int part)
{
WCHAR *szText;
WCHAR wtext[512];
int drive = sb_part_meanings[part] & 0xf;
if (wcslen(hdd_fn[drive]) == 0)
{
_swprintf(sbTips[part], win_language_get_string_from_id(2201), win_language_get_string_from_id(2185));
}
else
{
_swprintf(sbTips[part], win_language_get_string_from_id(2179), hdd_fn[drive]);
}
}
void create_hd_tip(int part) void create_hd_tip(int part)
{ {
WCHAR *szText; WCHAR *szText;
@@ -841,11 +858,9 @@ void update_tip(int meaning)
case 0x10: case 0x10:
create_cdrom_tip(part); create_cdrom_tip(part);
break; break;
#if 0
case 0x20: case 0x20:
create_removable_hd_tip(part); create_removable_hd_tip(part);
break; break;
#endif
case 0x30: case 0x30:
create_hd_tip(part); create_hd_tip(part);
break; break;
@@ -954,7 +969,6 @@ void update_status_bar_panes(HWND hwnds)
sb_parts++; sb_parts++;
} }
} }
#if 0
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
{ {
if (hdc[i].bus == 5) if (hdc[i].bus == 5)
@@ -965,7 +979,6 @@ void update_status_bar_panes(HWND hwnds)
sb_parts++; sb_parts++;
} }
} }
#endif
if (c_mfm && !(models[model].flags & MODEL_HAS_IDE) && !!memcmp(hdd_controller_name, "none", 4) && !!memcmp(hdd_controller_name, "xtide", 5)) if (c_mfm && !(models[model].flags & MODEL_HAS_IDE) && !!memcmp(hdd_controller_name, "none", 4) && !!memcmp(hdd_controller_name, "xtide", 5))
{ {
edge += sb_icon_width; edge += sb_icon_width;
@@ -1047,14 +1060,12 @@ void update_status_bar_panes(HWND hwnds)
sb_part_icons[i] = j | sb_icon_flags[i]; sb_part_icons[i] = j | sb_icon_flags[i];
create_cdrom_tip(i); create_cdrom_tip(i);
break; break;
#if 0
case 0x20: case 0x20:
/* Removable hard disk */ /* Removable hard disk */
sb_icon_flags[i] = (wcslen(discfns[sb_part_meanings[i] & 0xf]) == 0) ? 256 : 0; sb_icon_flags[i] = (wcslen(discfns[sb_part_meanings[i] & 0xf]) == 0) ? 256 : 0;
sb_part_icons[i] = 176 + sb_icon_flags[i]; sb_part_icons[i] = 176 + sb_icon_flags[i];
create_floppy_tip(i); create_removable_hd_tip(i);
break; break;
#endif
case 0x30: case 0x30:
/* Hard disk */ /* Hard disk */
sb_part_icons[i] = 192 + ((sb_part_meanings[i] & 0xf) << 1); sb_part_icons[i] = 192 + ((sb_part_meanings[i] & 0xf) << 1);
@@ -1107,12 +1118,10 @@ HWND EmulatorStatusBar(HWND hwndParent, int idStatus, HINSTANCE hinst)
hIcon[i] = LoadIconEx((PCTSTR) i); hIcon[i] = LoadIconEx((PCTSTR) i);
} }
#if 0
for (i = 176; i < 178; i++) for (i = 176; i < 178; i++)
{ {
hIcon[i] = LoadIconEx((PCTSTR) i); hIcon[i] = LoadIconEx((PCTSTR) i);
} }
#endif
for (i = 192; i < 200; i++) for (i = 192; i < 200; i++)
{ {
@@ -1139,12 +1148,10 @@ HWND EmulatorStatusBar(HWND hwndParent, int idStatus, HINSTANCE hinst)
hIcon[i] = LoadIconEx((PCTSTR) i); hIcon[i] = LoadIconEx((PCTSTR) i);
} }
#if 0
for (i = 432; i < 434; i++) for (i = 432; i < 434; i++)
{ {
hIcon[i] = LoadIconEx((PCTSTR) i); hIcon[i] = LoadIconEx((PCTSTR) i);
} }
#endif
GetWindowRect(hwndParent, &rectDialog); GetWindowRect(hwndParent, &rectDialog);
dw = rectDialog.right - rectDialog.left; dw = rectDialog.right - rectDialog.left;

View File

@@ -21,7 +21,7 @@ LCID dwLanguage;
uint32_t dwLangID, dwSubLangID; uint32_t dwLangID, dwSubLangID;
#define STRINGS_NUM 155 /* FIXME: should be in resource.h !! --FvK */ #define STRINGS_NUM 157 /* FIXME: should be in resource.h !! --FvK */
WCHAR lpResourceString[STRINGS_NUM][512]; WCHAR lpResourceString[STRINGS_NUM][512];

View File

@@ -626,6 +626,8 @@ void fdc_implied_seek()
} }
} }
int fifo_count = 0;
void fdc_write(uint16_t addr, uint8_t val, void *priv) void fdc_write(uint16_t addr, uint8_t val, void *priv)
{ {
int drive, i, drive_num; int drive, i, drive_num;
@@ -805,6 +807,7 @@ void fdc_write(uint16_t addr, uint8_t val, void *priv)
case 0x19: /*Scan low or equal*/ case 0x19: /*Scan low or equal*/
case 0x16: /*Verify*/ case 0x16: /*Verify*/
case 0x1D: /*Scan high or equal*/ case 0x1D: /*Scan high or equal*/
fifo_count = 0;
fdc.satisfying_sectors=0; fdc.satisfying_sectors=0;
fdc.sc=0; fdc.sc=0;
fdc.wrong_am=0; fdc.wrong_am=0;
@@ -1261,11 +1264,10 @@ uint8_t fdc_read(uint16_t addr, void *priv)
{ {
uint8_t temp; uint8_t temp;
int drive; int drive;
fdc_log("Read FDC %04X\n",addr);
switch (addr&7) switch (addr&7)
{ {
case 0: /* STA */ case 0: /* STA */
return 0xff; temp = 0xff;
break; break;
case 1: /* STB */ case 1: /* STB */
if (is486) if (is486)
@@ -1274,7 +1276,9 @@ uint8_t fdc_read(uint16_t addr, void *priv)
} }
drive = real_drive(fdc.dor & 3); drive = real_drive(fdc.dor & 3);
if (!fdc.enable_3f1) if (!fdc.enable_3f1)
return 0xff; {
temp = 0xff;
}
temp = 0x70; temp = 0x70;
if (drive) if (drive)
temp &= ~0x40; temp &= ~0x40;
@@ -1314,7 +1318,8 @@ uint8_t fdc_read(uint16_t addr, void *priv)
case 4: /*Status*/ case 4: /*Status*/
if (!(fdc.dor & 4) & !fdc.pcjr) if (!(fdc.dor & 4) & !fdc.pcjr)
{ {
return 0; temp = 0;
break;
} }
temp=fdc.stat; temp=fdc.stat;
break; break;
@@ -1373,6 +1378,7 @@ uint8_t fdc_read(uint16_t addr, void *priv)
default: default:
temp=0xFF; temp=0xFF;
} }
fdc_log("Read FDC %04X %02X\n",addr, temp);
return temp; return temp;
} }
@@ -1430,6 +1436,7 @@ void fdc_poll_common_finish(int compare, int st5)
fdc.res[8]=fdc.head; fdc.res[8]=fdc.head;
fdc.res[9]=fdc.sector; fdc.res[9]=fdc.sector;
fdc.res[10]=fdc.params[4]; fdc.res[10]=fdc.params[4];
fdc_log("Read/write finish (%02X %02X %02X %02X %02X %02X %02X)\n" , fdc.res[4], fdc.res[5], fdc.res[6], fdc.res[7], fdc.res[8], fdc.res[9], fdc.res[10]);
update_status_bar_icon(fdc.drive, 0); update_status_bar_icon(fdc.drive, 0);
paramstogo=7; paramstogo=7;
} }
@@ -1541,7 +1548,31 @@ void fdc_callback()
old_sector = fdc.sector; old_sector = fdc.sector;
if (fdc.tc) if (fdc.tc)
{ {
fdc.sector++; /* This is needed so that the correct results are returned
in case of TC. */
if (fdc.sector == fdc.params[5])
{
if (!(fdc.command & 0x80))
{
fdc.rw_track++;
fdc.sector = 1;
}
else
{
if (fdc.head)
{
fdc.rw_track++;
}
fdc.head ^= 1;
fdd_set_head(fdc.drive, fdc.head);
fdc.sector = 1;
}
}
else
{
fdc.sector++;
}
fdc_poll_readwrite_finish(compare); fdc_poll_readwrite_finish(compare);
return; return;
} }
@@ -1777,7 +1808,7 @@ void fdc_callback()
fdc.config = fdc.params[1]; fdc.config = fdc.params[1];
fdc.pretrk = fdc.params[2]; fdc.pretrk = fdc.params[2];
fdc.fifo = (fdc.params[1] & 0x20) ? 0 : 1; fdc.fifo = (fdc.params[1] & 0x20) ? 0 : 1;
fdc.tfifo = (fdc.params[1] & 0xF) + 1; fdc.tfifo = (fdc.params[1] & 0xF);
fdc.stat = 0x80; fdc.stat = 0x80;
disctime = 0; disctime = 0;
return; return;
@@ -1889,7 +1920,7 @@ int fdc_data(uint8_t data)
return -1; return -1;
} }
if (fdc.pcjr || !fdc.fifo || (fdc.tfifo <= 1)) if (fdc.pcjr || !fdc.fifo || (fdc.tfifo < 1))
{ {
fdc.dat = data; fdc.dat = data;
fdc.data_ready = 1; fdc.data_ready = 1;
@@ -1909,6 +1940,36 @@ int fdc_data(uint8_t data)
} }
else else
{ {
if (fdc.tc)
{
fdc_log("FDC read: TC\n");
return 0;
}
if (dma_channel_write(2, data) & DMA_OVER)
{
fdc_log("FDC read: DMA over\n");
fdc.tc = 1;
}
if (!fdc.fifo)
{
fdc.data_ready = 1;
fdc.stat = 0xd0;
}
else
{
fdc_fifo_buf_advance();
if (fdc.fifobufpos == 0)
{
/* We have wrapped around, means FIFO is over */
fifo_count++;
fdc_log("%04X: FIFO wrap around (threshold == %02X), DRQ sent\n", fifo_count, fdc.tfifo);
fdc.data_ready = 1;
fdc.stat = 0xd0;
}
}
#if 0
result = dma_channel_write(2, data); result = dma_channel_write(2, data);
if (fdc.tc) if (fdc.tc)
@@ -1922,7 +1983,7 @@ int fdc_data(uint8_t data)
return -1; return -1;
} }
if (!fdc.fifo || (fdc.tfifo <= 1)) if (!fdc.fifo || (fdc.tfifo < 1))
{ {
fdc.data_ready = 1; fdc.data_ready = 1;
fdc.stat = 0xd0; fdc.stat = 0xd0;
@@ -1937,6 +1998,7 @@ int fdc_data(uint8_t data)
fdc.stat = 0xd0; fdc.stat = 0xd0;
} }
} }
#endif
} }
return 0; return 0;

View File

@@ -31,7 +31,7 @@ static void write_lock(uint8_t val)
static void ide_handler() static void ide_handler()
{ {
uint16_t or_value = 0; uint16_t or_value = 0;
if (romset == ROM_440FX) if ((romset == ROM_440FX) || (romset == ROM_R418))
{ {
return; return;
} }
@@ -50,10 +50,6 @@ static void ide_handler()
ide_set_side(0, 0x376 | or_value); ide_set_side(0, 0x376 | or_value);
ide_pri_enable_ex(); ide_pri_enable_ex();
} }
else
{
pclog("Disabling IDE...\n");
}
} }
static void set_com34_addr() static void set_com34_addr()

View File

@@ -137,7 +137,7 @@ void i430fx_reset(void)
void i430fx_pci_reset(void) void i430fx_pci_reset(void)
{ {
i430fx_write(0, 0x59, 0xf, NULL); i430fx_write(0, 0x59, 0x00, NULL);
} }
void i430fx_init() void i430fx_init()

View File

@@ -124,7 +124,7 @@ void i430hx_reset(void)
void i430hx_pci_reset(void) void i430hx_pci_reset(void)
{ {
i430hx_write(0, 0x59, 0xf, NULL); i430hx_write(0, 0x59, 0x00, NULL);
} }
void i430hx_init() void i430hx_init()

View File

@@ -122,7 +122,7 @@ void i430lx_reset(void)
void i430lx_pci_reset(void) void i430lx_pci_reset(void)
{ {
i430lx_write(0, 0x59, 0xf, NULL); i430lx_write(0, 0x59, 0x00, NULL);
} }
void i430lx_init() void i430lx_init()

View File

@@ -120,7 +120,7 @@ void i430nx_reset(void)
void i430nx_pci_reset(void) void i430nx_pci_reset(void)
{ {
i430nx_write(0, 0x59, 0xf, NULL); i430nx_write(0, 0x59, 0x00, NULL);
} }
void i430nx_init() void i430nx_init()

View File

@@ -127,7 +127,7 @@ void i430vx_reset(void)
void i430vx_pci_reset(void) void i430vx_pci_reset(void)
{ {
i430vx_write(0, 0x59, 0xf, NULL); i430vx_write(0, 0x59, 0x00, NULL);
} }
void i430vx_init() void i430vx_init()

View File

@@ -131,7 +131,7 @@ void i440fx_reset(void)
void i440fx_pci_reset(void) void i440fx_pci_reset(void)
{ {
i440fx_write(0, 0x59, 0xf, NULL); i440fx_write(0, 0x59, 0x00, NULL);
} }
void i440fx_init() void i440fx_init()

View File

@@ -581,7 +581,8 @@ void at_sis496_init()
at_ide_init(); at_ide_init();
memregs_init(); memregs_init();
pci_init(PCI_CONFIG_TYPE_1, 0, 31); pci_init(PCI_CONFIG_TYPE_1, 0, 31);
device_add(&sis496_device); sis496_init();
trc_init();
} }
void at_r418_init() void at_r418_init()

View File

@@ -1809,12 +1809,13 @@ nic_init(int board)
mac = device_get_config_int_ex("mac", -1); mac = device_get_config_int_ex("mac", -1);
/* Set up our MAC address. */ /* Set up our MAC address. */
#if 1
if (dev->is_rtl8029as) { if (dev->is_rtl8029as) {
dev->maclocal[0] = 0x00; /* 00:20:18 (RTL 8029AS PCI vendor prefix). */ dev->maclocal[0] = 0xDE /* 0x00 */; /* 00:20:18 (RTL 8029AS PCI vendor prefix). */
dev->maclocal[1] = 0x20; dev->maclocal[1] = 0x20;
dev->maclocal[2] = 0x18; dev->maclocal[2] = 0x18;
} else { } else {
dev->maclocal[0] = 0x00; /* 00:00:D8 (NE2000 ISA vendor prefix). */ dev->maclocal[0] = 0xDE /* 0x00 */; /* 00:00:D8 (NE2000 ISA vendor prefix). */
dev->maclocal[1] = 0x00; dev->maclocal[1] = 0x00;
dev->maclocal[2] = 0xD8; dev->maclocal[2] = 0xD8;
} }
@@ -1833,6 +1834,14 @@ nic_init(int board)
dev->maclocal[5] = (mac & 0xff) | 1; dev->maclocal[5] = (mac & 0xff) | 1;
#endif #endif
} }
#else
dev->maclocal[0] = 0xac;
dev->maclocal[1] = 0xde;
dev->maclocal[2] = 0x48;
dev->maclocal[3] = 0x88;
dev->maclocal[4] = 0xbb;
dev->maclocal[5] = 0xaa;
#endif
memcpy(dev->physaddr, dev->maclocal, sizeof(dev->maclocal)); memcpy(dev->physaddr, dev->maclocal, sizeof(dev->maclocal));
pclog(1,"%s: I/O=%04x, IRQ=%d, MAC=%02x:%02x:%02x:%02x:%02x:%02x BIOS=%d\n", pclog(1,"%s: I/O=%04x, IRQ=%d, MAC=%02x:%02x:%02x:%02x:%02x:%02x BIOS=%d\n",

View File

@@ -8,7 +8,7 @@
* *
* Handle SLiRP library processing. * Handle SLiRP library processing.
* *
* Version: @(#)net_slirp.c 1.0.2 2017/05/17 * Version: @(#)net_slirp.c 1.0.3 2017/05/21
* *
* Author: Fred N. van Kempen, <decwiz@yahoo.com> * Author: Fred N. van Kempen, <decwiz@yahoo.com>
*/ */
@@ -63,7 +63,7 @@ slirp_tic(void)
} }
/* Check if the interface has a packet for us. */ /* Handle the receiving of frames. */
static void static void
poll_thread(void *arg) poll_thread(void *arg)
{ {
@@ -75,7 +75,6 @@ poll_thread(void *arg)
/* Create a waitable event. */ /* Create a waitable event. */
evt = thread_create_event(); evt = thread_create_event();
pclog("SLiRP: poll event is %08lx\n", evt);
while (slirpq != NULL) { while (slirpq != NULL) {
/* See if there is any work. */ /* See if there is any work. */
@@ -90,8 +89,10 @@ poll_thread(void *arg)
/* Grab a packet from the queue. */ /* Grab a packet from the queue. */
qp = QueueDelete(slirpq); qp = QueueDelete(slirpq);
#if 0
pclog("SLiRP: inQ:%d got a %dbyte packet @%08lx\n", pclog("SLiRP: inQ:%d got a %dbyte packet @%08lx\n",
QueuePeek(slirpq), qp->len, qp); QueuePeek(slirpq), qp->len, qp);
#endif
if (poll_rx != NULL) if (poll_rx != NULL)
poll_rx(poll_arg, (uint8_t *)&qp->data, qp->len); poll_rx(poll_arg, (uint8_t *)&qp->data, qp->len);
@@ -113,7 +114,7 @@ network_slirp_setup(uint8_t *mac, NETRXCB func, void *arg)
{ {
int rc; int rc;
pclog("Initializing SLiRP\n"); pclog("SLiRP: initializing..\n");
if (slirp_init() != 0) { if (slirp_init() != 0) {
pclog("SLiRP could not be initialized!\n"); pclog("SLiRP could not be initialized!\n");
@@ -127,7 +128,7 @@ network_slirp_setup(uint8_t *mac, NETRXCB func, void *arg)
poll_rx = func; poll_rx = func;
poll_arg = arg; poll_arg = arg;
pclog("SLiRP: creating thread..\n"); pclog("SLiRP: starting thread..\n");
poll_tid = thread_create(poll_thread, mac); poll_tid = thread_create(poll_thread, mac);
return(0); return(0);

View File

@@ -142,7 +142,7 @@ void trc_write(uint16_t port, uint8_t val, void *priv)
trc_reg = val & 0xfd; trc_reg = val & 0xfd;
} }
void trc_init() void trc_init(void)
{ {
trc_reg = 0; trc_reg = 0;

View File

@@ -1,4 +1,5 @@
/* Copyright holders: Tenshi /* Copyright holders: Tenshi
see COPYING for more details see COPYING for more details
*/ */
void trc_init(void);
void sio_init(int card); void sio_init(int card);

View File

@@ -15,16 +15,18 @@ typedef struct sis496_t
uint8_t pci_conf[256]; uint8_t pci_conf[256];
} sis496_t; } sis496_t;
void sis496_recalcmapping(sis496_t *sis496) sis496_t sis496;
void sis496_recalcmapping(void)
{ {
int c; int c;
for (c = 0; c < 8; c++) for (c = 0; c < 8; c++)
{ {
uint32_t base = 0xc0000 + (c << 15); uint32_t base = 0xc0000 + (c << 15);
if (sis496->pci_conf[0x44] & (1 << c)) if (sis496.pci_conf[0x44] & (1 << c))
{ {
switch (sis496->pci_conf[0x45] & 3) switch (sis496.pci_conf[0x45] & 3)
{ {
case 0: case 0:
mem_set_mem_state(base, 0x8000, MEM_READ_EXTERNAL | MEM_WRITE_INTERNAL); mem_set_mem_state(base, 0x8000, MEM_READ_EXTERNAL | MEM_WRITE_INTERNAL);
@@ -45,68 +47,77 @@ void sis496_recalcmapping(sis496_t *sis496)
} }
flushmmucache(); flushmmucache();
shadowbios = (sis496->pci_conf[0x44] & 0xf0); shadowbios = (sis496.pci_conf[0x44] & 0xf0);
} }
void sis496_write(int func, int addr, uint8_t val, void *p) void sis496_write(int func, int addr, uint8_t val, void *p)
{ {
sis496_t *sis496 = (sis496_t *)p;
switch (addr) switch (addr)
{ {
case 0x44: /*Shadow configure*/ case 0x44: /*Shadow configure*/
if ((sis496->pci_conf[0x44] & val) ^ 0xf0) if ((sis496.pci_conf[0x44] & val) ^ 0xf0)
{ {
sis496->pci_conf[0x44] = val; sis496.pci_conf[0x44] = val;
sis496_recalcmapping(sis496); sis496_recalcmapping();
} }
break; break;
case 0x45: /*Shadow configure*/ case 0x45: /*Shadow configure*/
if ((sis496->pci_conf[0x45] & val) ^ 0x01) if ((sis496.pci_conf[0x45] & val) ^ 0x01)
{ {
sis496->pci_conf[0x45] = val; sis496.pci_conf[0x45] = val;
sis496_recalcmapping(sis496); sis496_recalcmapping();
} }
break; break;
} }
if ((addr >= 4 && addr < 8) || addr >= 0x40) if ((addr >= 4 && addr < 8) || addr >= 0x40)
sis496->pci_conf[addr] = val; sis496.pci_conf[addr] = val;
} }
uint8_t sis496_read(int func, int addr, void *p) uint8_t sis496_read(int func, int addr, void *p)
{ {
sis496_t *sis496 = (sis496_t *)p; return sis496.pci_conf[addr];
return sis496->pci_conf[addr];
} }
void *sis496_init() void sis496_reset(void)
{ {
sis496_t *sis496 = malloc(sizeof(sis496_t)); memset(&sis496, 0, sizeof(sis496_t));
memset(sis496, 0, sizeof(sis496_t));
pci_add_specific(5, sis496_read, sis496_write, sis496); sis496.pci_conf[0x00] = 0x39; /*SiS*/
sis496.pci_conf[0x01] = 0x10;
sis496.pci_conf[0x02] = 0x96; /*496/497*/
sis496.pci_conf[0x03] = 0x04;
sis496.pci_conf[0x04] = 7;
sis496.pci_conf[0x05] = 0;
sis496.pci_conf[0x06] = 0x80;
sis496.pci_conf[0x07] = 0x02;
sis496->pci_conf[0x00] = 0x39; /*SiS*/ sis496.pci_conf[0x08] = 2; /*Device revision*/
sis496->pci_conf[0x01] = 0x10;
sis496->pci_conf[0x02] = 0x96; /*496/497*/
sis496->pci_conf[0x03] = 0x04;
sis496->pci_conf[0x04] = 7; sis496.pci_conf[0x09] = 0x00; /*Device class (PCI bridge)*/
sis496->pci_conf[0x05] = 0; sis496.pci_conf[0x0a] = 0x00;
sis496.pci_conf[0x0b] = 0x06;
sis496->pci_conf[0x06] = 0x80; sis496.pci_conf[0x0e] = 0x00; /*Single function device*/
sis496->pci_conf[0x07] = 0x02; }
sis496->pci_conf[0x08] = 2; /*Device revision*/
sis496->pci_conf[0x09] = 0x00; /*Device class (PCI bridge)*/ void sis496_pci_reset(void)
sis496->pci_conf[0x0a] = 0x00; {
sis496->pci_conf[0x0b] = 0x06; uint8_t val = 0;
sis496->pci_conf[0x0e] = 0x00; /*Single function device*/
return sis496; val = sis496_read(0, 0x44, NULL); /* Read current value of 0x44. */
sis496_write(0, 0x44, val & 0xf, NULL); /* Turn off shadow BIOS but keep the lower 4 bits. */
}
void sis496_init(void)
{
pci_add_specific(5, sis496_read, sis496_write, NULL);
sis496_reset();
pci_reset_handler.pci_master_reset = sis496_pci_reset;
} }
void sis496_close(void *p) void sis496_close(void *p)
@@ -115,15 +126,3 @@ void sis496_close(void *p)
free(sis496); free(sis496);
} }
device_t sis496_device =
{
"SiS 496/497",
0,
sis496_init,
sis496_close,
NULL,
NULL,
NULL,
NULL
};

View File

@@ -1,4 +1,4 @@
/* Copyright holders: Sarah Walker /* Copyright holders: Kotori
see COPYING for more details see COPYING for more details
*/ */
extern device_t sis496_device; void sis496_init(void);