Major changes to NVR, system initialization (pc.c), and what goes on in the Windows startup (win.c.) Not fully done yet, but good enough for a first commit.

This commit is contained in:
waltje
2017-10-07 00:46:54 -04:00
parent 95fe21b651
commit 2b37b7fbfb
108 changed files with 5628 additions and 5912 deletions

View File

@@ -10,7 +10,7 @@
*
* NOTE: The file will also implement an NE1000 for 8-bit ISA systems.
*
* Version: @(#)net_ne2000.c 1.0.15 2017/09/24
* Version: @(#)net_ne2000.c 1.0.16 2017/10/05
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Peter Grehan, grehan@iprg.nokia.com>
@@ -35,6 +35,7 @@
#include "../pic.h"
#include "../random.h"
#include "../device.h"
#include "../win/win.h"
#include "network.h"
#include "net_ne2000.h"
#include "bswap.h"
@@ -497,6 +498,7 @@ asic_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len)
{
nelog(3, "%s: ASIC write addr=0x%02x, value=0x%04x\n",
dev->name, (unsigned)off, (unsigned) val);
switch(off) {
case 0x00: /* Data register - see asic_read for a description */
if ((len > 1) && (dev->DCR.wdsize == 0)) {
@@ -504,30 +506,25 @@ asic_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len)
dev->name, len);
break;
}
if (dev->remote_bytes == 0) {
if (dev->remote_bytes == 0)
nelog(3, "%s: DMA write, byte count 0\n", dev->name);
}
chipmem_write(dev, dev->remote_dma, val, len);
if (len == 4) {
if (len == 4)
dev->remote_dma += len;
} else {
else
dev->remote_dma += (dev->DCR.wdsize + 1);
}
if (dev->remote_dma == dev->page_stop << 8) {
if (dev->remote_dma == dev->page_stop << 8)
dev->remote_dma = dev->page_start << 8;
}
if (len == 4) {
if (len == 4)
dev->remote_bytes -= len;
} else {
else
dev->remote_bytes -= (dev->DCR.wdsize + 1);
}
if (dev->remote_bytes > NE2K_MEMSIZ) {
if (dev->remote_bytes > NE2K_MEMSIZ)
dev->remote_bytes = 0;
}
/* If all bytes have been written, signal remote-DMA complete */
if (dev->remote_bytes == 0) {
@@ -1423,13 +1420,10 @@ nic_update_bios(nic_t *dev)
reg_bios_enable = 1;
if (!dev->has_bios) {
return;
}
if (! dev->has_bios) return;
if (PCI && dev->is_pci) {
if (PCI && dev->is_pci)
reg_bios_enable = dev->pci_bar[1].addr_regs[0] & 0x01;
}
/* PCI BIOS stuff, just enable_disable. */
if (reg_bios_enable) {
@@ -1654,26 +1648,22 @@ static int
mcast_index(const void *dst)
{
#define POLYNOMIAL 0x04c11db6
unsigned long crc = 0xffffffffL;
int carry, i, j;
unsigned char b;
unsigned char *ep = (unsigned char *) dst;
uint32_t crc = 0xffffffffL;
int carry, i, j;
uint8_t b;
uint8_t *ep = (uint8_t *)dst;
for (i = 6; --i >= 0;)
{
b = *ep++;
for (j = 8; --j >= 0;)
{
carry = ((crc & 0x80000000L) ? 1 : 0) ^ (b & 0x01);
crc <<= 1;
b >>= 1;
if (carry)
{
crc = ((crc ^ POLYNOMIAL) | carry);
}
}
for (i=6; --i>=0;) {
b = *ep++;
for (j = 8; --j >= 0;) {
carry = ((crc & 0x80000000L) ? 1 : 0) ^ (b & 0x01);
crc <<= 1;
b >>= 1;
if (carry)
crc = ((crc ^ POLYNOMIAL) | carry);
}
return (crc >> 26);
}
return(crc >> 26);
#undef POLYNOMIAL
}
@@ -1681,7 +1671,7 @@ mcast_index(const void *dst)
static void
nic_tx(nic_t *dev, uint32_t val)
{
update_status_bar_icon(SB_NETWORK, 1);
StatusBarUpdateIcon(SB_NETWORK, 1);
dev->CR.tx_packet = 0;
dev->TSR.tx_ok = 1;
@@ -1692,7 +1682,7 @@ nic_tx(nic_t *dev, uint32_t val)
nic_interrupt(dev, 1);
dev->tx_timer_active = 0;
update_status_bar_icon(SB_NETWORK, 0);
StatusBarUpdateIcon(SB_NETWORK, 0);
}
@@ -1713,7 +1703,7 @@ nic_rx(void *priv, uint8_t *buf, int io_len)
int idx, nextpage;
int endbytes;
update_status_bar_icon(SB_NETWORK, 1);
StatusBarUpdateIcon(SB_NETWORK, 1);
if (io_len != 60)
nelog(2, "%s: rx_frame with length %d\n", dev->name, io_len);
@@ -1744,14 +1734,14 @@ nic_rx(void *priv, uint8_t *buf, int io_len)
) {
nelog(1, "%s: no space\n", dev->name);
update_status_bar_icon(SB_NETWORK, 0);
StatusBarUpdateIcon(SB_NETWORK, 0);
return;
}
if ((io_len < 40/*60*/) && !dev->RCR.runts_ok) {
nelog(1, "%s: rejected small packet, length %d\n", dev->name, io_len);
update_status_bar_icon(SB_NETWORK, 0);
StatusBarUpdateIcon(SB_NETWORK, 0);
return;
}
@@ -1773,7 +1763,7 @@ nic_rx(void *priv, uint8_t *buf, int io_len)
if (! dev->RCR.broadcast) {
nelog(2, "%s: RX BC disabled\n", dev->name);
update_status_bar_icon(SB_NETWORK, 0);
StatusBarUpdateIcon(SB_NETWORK, 0);
return;
}
}
@@ -1786,7 +1776,7 @@ nic_rx(void *priv, uint8_t *buf, int io_len)
nelog(2, "%s: RX MC disabled\n", dev->name);
#endif
update_status_bar_icon(SB_NETWORK, 0);
StatusBarUpdateIcon(SB_NETWORK, 0);
return;
}
@@ -1795,7 +1785,7 @@ nic_rx(void *priv, uint8_t *buf, int io_len)
if (! (dev->mchash[idx>>3] & (1<<(idx&0x7)))) {
nelog(2, "%s: RX MC not listed\n", dev->name);
update_status_bar_icon(SB_NETWORK, 0);
StatusBarUpdateIcon(SB_NETWORK, 0);
return;
}
}
@@ -1841,7 +1831,7 @@ nic_rx(void *priv, uint8_t *buf, int io_len)
if (dev->IMR.rx_inte)
nic_interrupt(dev, 1);
update_status_bar_icon(SB_NETWORK, 0);
StatusBarUpdateIcon(SB_NETWORK, 0);
}
@@ -1851,35 +1841,32 @@ nic_rom_init(nic_t *dev, wchar_t *s)
uint32_t temp;
FILE *f;
if (s == NULL)
{
if (s == NULL) return;
if (dev->bios_addr == 0) return;
if ((f = rom_fopen(s, L"rb")) != NULL) {
fseek(f, 0L, SEEK_END);
temp = ftell(f);
fclose(f);
dev->bios_size = 0x10000;
if (temp <= 0x8000)
dev->bios_size = 0x8000;
if (temp <= 0x4000)
dev->bios_size = 0x4000;
if (temp <= 0x2000)
dev->bios_size = 0x2000;
dev->bios_mask = (dev->bios_size >> 8) & 0xff;
dev->bios_mask = (0x100 - dev->bios_mask) & 0xff;
} else {
dev->bios_addr = 0x00000;
dev->bios_size = 0;
return;
}
if (dev->bios_addr > 0) {
if ((f = rom_fopen(s, L"rb")) != NULL) {
fseek(f, 0L, SEEK_END);
temp = ftell(f);
fclose(f);
dev->bios_size = 0x10000;
if (temp <= 0x8000)
dev->bios_size = 0x8000;
if (temp <= 0x4000)
dev->bios_size = 0x4000;
if (temp <= 0x2000)
dev->bios_size = 0x2000;
dev->bios_mask = (dev->bios_size >> 8) & 0xff;
dev->bios_mask = (0x100 - dev->bios_mask) & 0xff;
} else {
dev->bios_addr = 0x00000;
dev->bios_size = 0;
return;
}
/* Create a memory mapping for the space. */
rom_init(&dev->bios_rom, s, dev->bios_addr,
dev->bios_size, dev->bios_size-1, 0, MEM_MAPPING_EXTERNAL);
}
/* Create a memory mapping for the space. */
rom_init(&dev->bios_rom, s, dev->bios_addr,
dev->bios_size, dev->bios_size-1, 0, MEM_MAPPING_EXTERNAL);
nelog(1, "%s: BIOS configured at %06lX (size %ld)\n",
dev->name, dev->bios_addr, dev->bios_size);
@@ -1939,13 +1926,9 @@ nic_init(int board)
dev->bios_addr = device_get_config_hex20("bios_addr");
if (dev->bios_addr)
{
dev->has_bios = 1;
}
else
{
else
dev->has_bios = 0;
}
/* See if we have a local MAC address configured. */
mac = device_get_config_mac("mac", -1);
@@ -2083,21 +2066,21 @@ nic_close(void *priv)
static void *
ne1000_init(void)
ne1000_init(device_t *info)
{
return(nic_init(NE2K_NE1000));
}
static void *
ne2000_init(void)
ne2000_init(device_t *info)
{
return(nic_init(NE2K_NE2000));
}
static void *
rtl8029as_init(void)
rtl8029as_init(device_t *info)
{
return(nic_init(NE2K_RTL8029AS));
}
@@ -2296,35 +2279,26 @@ static device_config_t rtl8029as_config[] =
device_t ne1000_device = {
"Novell NE1000",
0,
ne1000_init,
nic_close,
NULL,
NULL,
NULL,
NULL,
NE2K_NE1000,
ne1000_init, nic_close, NULL,
NULL, NULL, NULL, NULL,
ne1000_config
};
device_t ne2000_device = {
"Novell NE2000",
0,
ne2000_init,
nic_close,
NULL,
NULL,
NULL,
NULL,
DEVICE_AT,
NE2K_NE2000,
ne2000_init, nic_close, NULL,
NULL, NULL, NULL, NULL,
ne2000_config
};
device_t rtl8029as_device = {
"Realtek RTL8029AS",
0,
rtl8029as_init,
nic_close,
NULL,
NULL,
NULL,
NULL,
NE2K_RTL8029AS,
rtl8029as_init, nic_close, NULL,
NULL, NULL, NULL, NULL,
rtl8029as_config
};