Merge pull request #5198 from jriwanek-forks/cleanups
Cleanups and a bugfix
This commit is contained in:
@@ -27,16 +27,20 @@
|
||||
* modern boards even have multiple 'copies' of those registers,
|
||||
* which can be switched very fast, to allow for multitasking.
|
||||
*
|
||||
* TODO: The EV159 is supposed to support 16b EMS transfers, but the
|
||||
* TODO: The EV-159 is supposed to support 16b EMS transfers, but the
|
||||
* EMM.sys driver for it doesn't seem to want to do that..
|
||||
*
|
||||
* EV-125 (It supports backfill)
|
||||
* https://theretroweb.com/expansioncard/documentation/50250.pdf
|
||||
*
|
||||
* EV-158 (RAM 10000)
|
||||
* http://web.archive.org/web/19961104093221/http://www.everex.com/supp/techlib/memmem.html
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Jasmine Iwanek <jriwanek@gmail.com>
|
||||
*
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Copyright 2022-2024 Jasmine Iwanek.
|
||||
* Copyright 2022-2025 Jasmine Iwanek.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with
|
||||
* or without modification, are permitted provided that the
|
||||
@@ -102,7 +106,7 @@
|
||||
#define ISAMEM_BRXT_CARD 13
|
||||
#define ISAMEM_BRAT_CARD 14
|
||||
#define ISAMEM_EV165A_CARD 15
|
||||
#define ISAMEM_LOTECH_CARD 16
|
||||
#define ISAMEM_LOTECH_EMS_CARD 16
|
||||
|
||||
#define ISAMEM_DEBUG 0
|
||||
|
||||
@@ -304,16 +308,13 @@ ems_writew(uint32_t addr, uint16_t val, void *priv)
|
||||
static uint8_t
|
||||
ems_in(uint16_t port, void *priv)
|
||||
{
|
||||
const emsreg_t *dev = (emsreg_t *) priv;
|
||||
uint8_t ret = 0xff;
|
||||
#ifdef ENABLE_ISAMEM_LOG
|
||||
int vpage;
|
||||
#endif
|
||||
|
||||
const emsreg_t *dev = (emsreg_t *) priv;
|
||||
uint8_t ret = 0xff;
|
||||
/* Get the viewport page number. */
|
||||
#ifdef ENABLE_ISAMEM_LOG
|
||||
vpage = (port / EMS_PGSIZE);
|
||||
int vpage = (port / EMS_PGSIZE);
|
||||
#endif
|
||||
|
||||
port &= (EMS_PGSIZE - 1);
|
||||
|
||||
switch (port & 0x0001) {
|
||||
@@ -339,13 +340,11 @@ ems_in(uint16_t port, void *priv)
|
||||
static uint8_t
|
||||
consecutive_ems_in(uint16_t port, void *priv)
|
||||
{
|
||||
const memdev_t *dev = (memdev_t *) priv;
|
||||
uint8_t ret = 0xff;
|
||||
int vpage;
|
||||
|
||||
const memdev_t *dev = (memdev_t *) priv;
|
||||
uint8_t ret = 0xff;
|
||||
/* Get the viewport page number. */
|
||||
vpage = (port - dev->base_addr[0]);
|
||||
|
||||
int vpage = (port - dev->base_addr[0]);
|
||||
|
||||
ret = dev->ems[vpage].page;
|
||||
if (dev->ems[vpage].enabled)
|
||||
ret |= 0x80;
|
||||
@@ -359,11 +358,10 @@ consecutive_ems_in(uint16_t port, void *priv)
|
||||
static void
|
||||
ems_out(uint16_t port, uint8_t val, void *priv)
|
||||
{
|
||||
emsreg_t *dev = (emsreg_t *) priv;
|
||||
int vpage;
|
||||
|
||||
emsreg_t *dev = (emsreg_t *) priv;
|
||||
/* Get the viewport page number. */
|
||||
vpage = (port / EMS_PGSIZE);
|
||||
int vpage = (port / EMS_PGSIZE);
|
||||
|
||||
port &= (EMS_PGSIZE - 1);
|
||||
|
||||
switch (port & 0x0001) {
|
||||
@@ -433,11 +431,9 @@ ems_out(uint16_t port, uint8_t val, void *priv)
|
||||
static void
|
||||
consecutive_ems_out(uint16_t port, uint8_t val, void *priv)
|
||||
{
|
||||
memdev_t *dev = (memdev_t *) priv;
|
||||
int vpage;
|
||||
|
||||
memdev_t *dev = (memdev_t *) priv;
|
||||
/* Get the viewport page number. */
|
||||
vpage = (port - dev->base_addr[0]);
|
||||
int vpage = (port - dev->base_addr[0]);
|
||||
|
||||
isamem_log("ISAMEM: write(%04x, %02x) to page mapping registers! (page=%d)\n", port, val, vpage);
|
||||
|
||||
@@ -578,7 +574,7 @@ isamem_init(const device_t *info)
|
||||
dev->flags |= FLAG_FAST;
|
||||
break;
|
||||
|
||||
case ISAMEM_LOTECH_CARD: /* Lotech EMS */
|
||||
case ISAMEM_LOTECH_EMS_CARD: /* Lotech EMS */
|
||||
/* The Lotech EMS cannot have more than 4096KB per board. */
|
||||
ems_max = EMS_LOTECH_MAXSIZE;
|
||||
fallthrough;
|
||||
@@ -800,7 +796,7 @@ isamem_init(const device_t *info)
|
||||
mem_mapping_disable(&dev->ems[i].mapping);
|
||||
|
||||
/* Set up an I/O port handler. */
|
||||
if (dev->board != ISAMEM_LOTECH_CARD)
|
||||
if (dev->board != ISAMEM_LOTECH_EMS_CARD)
|
||||
io_sethandler(dev->base_addr[0] + (EMS_PGSIZE * i), 2,
|
||||
ems_in, NULL, NULL, ems_out, NULL, NULL, &(dev->ems[i]));
|
||||
|
||||
@@ -831,7 +827,7 @@ isamem_init(const device_t *info)
|
||||
}
|
||||
}
|
||||
|
||||
if (dev->board == ISAMEM_LOTECH_CARD)
|
||||
if (dev->board == ISAMEM_LOTECH_EMS_CARD)
|
||||
io_sethandler(dev->base_addr[0], 4,
|
||||
consecutive_ems_in, NULL, NULL, consecutive_ems_out, NULL, NULL, dev);
|
||||
}
|
||||
@@ -1030,6 +1026,7 @@ static const device_config_t genericxt_config[] = {
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
// This also nicely accounts for the Everex EV-138
|
||||
static const device_t genericxt_device = {
|
||||
.name = "Generic PC/XT Memory Expansion",
|
||||
.internal_name = "genericxt",
|
||||
@@ -1236,6 +1233,7 @@ static const device_config_t genericat_config[] = {
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
// This also nicely accounts for the Everex EV-135
|
||||
static const device_t genericat_device = {
|
||||
.name = "Generic PC/AT Memory Expansion",
|
||||
.internal_name = "genericat",
|
||||
@@ -1856,11 +1854,11 @@ static const device_config_t lotech_config[] = {
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static const device_t lotech_device = {
|
||||
static const device_t lotech_ems_device = {
|
||||
.name = "Lo-tech EMS Board",
|
||||
.internal_name = "lotechems",
|
||||
.flags = DEVICE_ISA,
|
||||
.local = ISAMEM_LOTECH_CARD,
|
||||
.local = ISAMEM_LOTECH_EMS_CARD,
|
||||
.init = isamem_init,
|
||||
.close = isamem_close,
|
||||
.reset = NULL,
|
||||
@@ -2071,7 +2069,7 @@ static const struct {
|
||||
#ifdef USE_ISAMEM_IAB
|
||||
{ &iab_device },
|
||||
#endif /* USE_ISAMEM_IAB */
|
||||
{ &lotech_device },
|
||||
{ &lotech_ems_device },
|
||||
{ NULL }
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
@@ -44,7 +44,7 @@ enum {
|
||||
NE2K_NE2000_COMPAT = 4, /* 16-bit ISA NE2000-Compatible */
|
||||
NE2K_NE2000_COMPAT_8BIT = 5, /* 8-bit ISA NE2000-Compatible, like: https://github.com/skiselev/isa8_eth */
|
||||
NE2K_ETHERNEXT_MC = 6, /* 16-bit MCA EtherNext/MC */
|
||||
NE2K_RTL8019AS = 7, /* 16-bit ISA PnP Realtek 8019AS */
|
||||
NE2K_RTL8019AS_PNP = 7, /* 16-bit ISA PnP Realtek 8019AS */
|
||||
NE2K_DE220P = 8, /* 16-bit ISA PnP D-Link DE-220P */
|
||||
NE2K_RTL8029AS = 9, /* 32-bit PCI Realtek 8029AS */
|
||||
/* Check nic_init() if adding items after this point. */
|
||||
|
||||
@@ -213,7 +213,7 @@ extern const device_t ne2000_device;
|
||||
extern const device_t ne2000_compat_device;
|
||||
extern const device_t ne2000_compat_8bit_device;
|
||||
extern const device_t ethernext_mc_device;
|
||||
extern const device_t rtl8019as_device;
|
||||
extern const device_t rtl8019as_pnp_device;
|
||||
extern const device_t de220p_device;
|
||||
extern const device_t rtl8029as_device;
|
||||
|
||||
|
||||
@@ -312,7 +312,7 @@ asic_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len)
|
||||
static uint32_t
|
||||
page3_read(nic_t *dev, uint32_t off, UNUSED(unsigned int len))
|
||||
{
|
||||
if (dev->board >= NE2K_RTL8019AS)
|
||||
if (dev->board >= NE2K_RTL8019AS_PNP)
|
||||
switch (off) {
|
||||
case 0x1: /* 9346CR */
|
||||
return (dev->_9346cr);
|
||||
@@ -327,7 +327,7 @@ page3_read(nic_t *dev, uint32_t off, UNUSED(unsigned int len))
|
||||
return (dev->config3 & 0x46);
|
||||
|
||||
case 0x8: /* CSNSAV */
|
||||
return ((dev->board == NE2K_RTL8019AS) ? dev->pnp_csnsav : 0x00);
|
||||
return ((dev->board == NE2K_RTL8019AS_PNP) ? dev->pnp_csnsav : 0x00);
|
||||
|
||||
case 0xe: /* 8029ASID0 */
|
||||
if (dev->board == NE2K_RTL8029AS)
|
||||
@@ -350,7 +350,7 @@ page3_read(nic_t *dev, uint32_t off, UNUSED(unsigned int len))
|
||||
static void
|
||||
page3_write(nic_t *dev, uint32_t off, uint32_t val, UNUSED(unsigned len))
|
||||
{
|
||||
if (dev->board >= NE2K_RTL8019AS) {
|
||||
if (dev->board >= NE2K_RTL8019AS_PNP) {
|
||||
nelog(3, "%s: Page2 write to register 0x%02x, len=%u, value=0x%04x\n",
|
||||
dev->name, off, len, val);
|
||||
|
||||
@@ -919,7 +919,7 @@ nic_init(const device_t *info)
|
||||
dev->name = info->name;
|
||||
dev->board = info->local;
|
||||
|
||||
if (dev->board >= NE2K_RTL8019AS) {
|
||||
if (dev->board >= NE2K_RTL8019AS_PNP) {
|
||||
dev->base_address = 0x340;
|
||||
dev->base_irq = 12;
|
||||
if (dev->board == NE2K_RTL8029AS) {
|
||||
@@ -1042,18 +1042,18 @@ nic_init(const device_t *info)
|
||||
dp8390_mem_alloc(dev->dp8390, 0x4000, 0x8000);
|
||||
break;
|
||||
|
||||
case NE2K_RTL8019AS:
|
||||
case NE2K_RTL8019AS_PNP:
|
||||
case NE2K_RTL8029AS:
|
||||
dev->is_pci = (dev->board == NE2K_RTL8029AS) ? 1 : 0;
|
||||
dev->maclocal[0] = 0x00; /* 00:E0:4C (Realtek OID) */
|
||||
dev->maclocal[1] = 0xE0;
|
||||
dev->maclocal[2] = 0x4C;
|
||||
rom = (dev->board == NE2K_RTL8019AS) ? ROM_PATH_RTL8019 : ROM_PATH_RTL8029;
|
||||
rom = (dev->board == NE2K_RTL8019AS_PNP) ? ROM_PATH_RTL8019 : ROM_PATH_RTL8029;
|
||||
if (dev->is_pci)
|
||||
dp8390_set_defaults(dev->dp8390, DP8390_FLAG_EVEN_MAC);
|
||||
else
|
||||
dp8390_set_defaults(dev->dp8390, DP8390_FLAG_EVEN_MAC | DP8390_FLAG_CLEAR_IRQ);
|
||||
dp8390_set_id(dev->dp8390, 0x50, (dev->board == NE2K_RTL8019AS) ? 0x70 : 0x43);
|
||||
dp8390_set_id(dev->dp8390, 0x50, (dev->board == NE2K_RTL8019AS_PNP) ? 0x70 : 0x43);
|
||||
dp8390_mem_alloc(dev->dp8390, 0x4000, 0x8000);
|
||||
break;
|
||||
|
||||
@@ -1090,13 +1090,13 @@ nic_init(const device_t *info)
|
||||
* Make this device known to the I/O system.
|
||||
* PnP and PCI devices start with address spaces inactive.
|
||||
*/
|
||||
if ((dev->board < NE2K_RTL8019AS) && (dev->board != NE2K_ETHERNEXT_MC))
|
||||
if ((dev->board < NE2K_RTL8019AS_PNP) && (dev->board != NE2K_ETHERNEXT_MC))
|
||||
nic_ioset(dev, dev->base_address);
|
||||
|
||||
/* Set up our BIOS ROM space, if any. */
|
||||
nic_rom_init(dev, rom);
|
||||
|
||||
if (dev->board >= NE2K_RTL8019AS) {
|
||||
if (dev->board >= NE2K_RTL8019AS_PNP) {
|
||||
if (dev->is_pci) {
|
||||
/*
|
||||
* Configure the PCI space registers.
|
||||
@@ -1144,7 +1144,7 @@ nic_init(const device_t *info)
|
||||
pci_add_card(PCI_ADD_NORMAL, nic_pci_read, nic_pci_write, dev, &dev->pci_slot);
|
||||
}
|
||||
|
||||
/* Initialize the RTL8029 EEPROM. */
|
||||
/* Initialize the RTL80x9 EEPROM. */
|
||||
memset(dev->eeprom, 0x00, sizeof(dev->eeprom));
|
||||
|
||||
if (dev->board == NE2K_RTL8029AS) {
|
||||
@@ -1158,7 +1158,7 @@ nic_init(const device_t *info)
|
||||
const char *pnp_rom_file = NULL;
|
||||
int pnp_rom_len = 0x4a;
|
||||
switch (dev->board) {
|
||||
case NE2K_RTL8019AS:
|
||||
case NE2K_RTL8019AS_PNP:
|
||||
pnp_rom_file = "roms/network/rtl8019as/RTL8019A.BIN";
|
||||
break;
|
||||
|
||||
@@ -1182,7 +1182,7 @@ nic_init(const device_t *info)
|
||||
}
|
||||
|
||||
switch (info->local) {
|
||||
case NE2K_RTL8019AS:
|
||||
case NE2K_RTL8019AS_PNP:
|
||||
case NE2K_DE220P:
|
||||
dev->pnp_card = isapnp_add_card(pnp_rom, pnp_rom_len,
|
||||
nic_pnp_config_changed, nic_pnp_csn_changed,
|
||||
@@ -1706,11 +1706,11 @@ const device_t ethernext_mc_device = {
|
||||
.config = mca_mac_config
|
||||
};
|
||||
|
||||
const device_t rtl8019as_device = {
|
||||
const device_t rtl8019as_pnp_device = {
|
||||
.name = "Realtek RTL8019AS",
|
||||
.internal_name = "ne2kpnp",
|
||||
.flags = DEVICE_ISA | DEVICE_AT,
|
||||
.local = NE2K_RTL8019AS,
|
||||
.local = NE2K_RTL8019AS_PNP,
|
||||
.init = nic_init,
|
||||
.close = nic_close,
|
||||
.reset = NULL,
|
||||
|
||||
@@ -96,7 +96,7 @@ static const NETWORK_CARD net_cards[] = {
|
||||
{ &ne1000_device },
|
||||
{ &ne2000_device },
|
||||
{ &pcnet_am79c960_eb_device },
|
||||
{ &rtl8019as_device },
|
||||
{ &rtl8019as_pnp_device },
|
||||
{ &wd8003e_device },
|
||||
{ &wd8003eb_device },
|
||||
{ &wd8013ebt_device },
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <wchar.h>
|
||||
#include <86box/cdrom.h>
|
||||
#include <86box/log.h>
|
||||
|
||||
Reference in New Issue
Block a user