Skip to content

Commit

Permalink
NE2000 PCMCIA
Browse files Browse the repository at this point in the history
It's not getting detected for some reason. Weird
  • Loading branch information
Cacodemon345 committed Jun 13, 2024
1 parent 7f145d7 commit 6430c5b
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 12 deletions.
4 changes: 3 additions & 1 deletion src/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,8 @@ device_get_name(const device_t *dev, int bus, char *name)
sbus = "COM";
else if (dev->flags & DEVICE_LPT)
sbus = "LPT";
else if (dev->flags & DEVICE_PCMCIA)
sbus = "PCMCIA";

if (sbus != NULL) {
/* First concatenate [<Bus>] before the device's name. */
Expand Down Expand Up @@ -758,7 +760,7 @@ device_is_valid(const device_t *device, int m)
if ((device->flags & DEVICE_CBUS) && !machine_has_bus(m, MACHINE_BUS_CBUS))
return 0;

if ((device->flags & DEVICE_PCMCIA) && !machine_has_bus(m, MACHINE_BUS_PCMCIA))
if ((device->flags & DEVICE_PCMCIA) && !machine_has_bus(m, MACHINE_BUS_PCMCIA) && !machine_has_bus(m, MACHINE_BUS_ISA))
return 0;

if ((device->flags & DEVICE_MCA) && !machine_has_bus(m, MACHINE_BUS_MCA))
Expand Down
1 change: 1 addition & 0 deletions src/include/86box/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ extern const device_t ne1000_device;
extern const device_t ne1000_compat_device;
extern const device_t ne2000_device;
extern const device_t ne2000_compat_device;
extern const device_t ne2000_compat_pcmcia_device;
extern const device_t ethernext_mc_device;
extern const device_t rtl8019as_device;
extern const device_t de220p_device;
Expand Down
2 changes: 1 addition & 1 deletion src/include/86box/pcmcia.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct pcmcia_socket_t {
void (*ready_changed)(bool ready, pcmcia_socket_t* socket);

/* Signals interrupt to the socket. */
void (*interrupt)(bool set, pcmcia_socket_t* socket);
void (*interrupt)(bool set, bool level, pcmcia_socket_t* socket);

/* Resets the card. */
void (*reset)(void *priv);
Expand Down
10 changes: 4 additions & 6 deletions src/network/net_ne2000.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ nic_interrupt(void *priv, int set)
nic_t *dev = (nic_t *) priv;

if (dev->pcmcia_socket) {
dev->pcmcia_socket->interrupt(!!set, dev->pcmcia_socket);
dev->pcmcia_socket->interrupt(!!set, !!(dev->pcmcia_config & (1 << 6)), dev->pcmcia_socket);
return;
}

Expand Down Expand Up @@ -990,10 +990,7 @@ nic_pcmcia_read(uint32_t addr, int reg, void* priv)
static uint16_t
nic_pcmcia_readw(uint32_t addr, int reg, void* priv)
{
if ((addr & 1) && !reg)
return nic_pcmcia_read(addr + 1, reg, priv) << 8;

return nic_pcmcia_read(addr, reg, priv);
return nic_pcmcia_read(addr, reg, priv) | (nic_pcmcia_read(addr + 1, reg, priv) << 8);
}

static void
Expand Down Expand Up @@ -1022,7 +1019,8 @@ nic_pcmcia_write(uint32_t addr, uint8_t val, int reg, void* priv)
static void
nic_pcmcia_writew(uint32_t addr, uint16_t val, int reg, void* priv)
{
nic_pcmcia_writew(addr, val, reg, priv);
nic_pcmcia_write(addr, val & 0xFF, reg, priv);
nic_pcmcia_write(addr + 1, (val >> 8) & 0xFF, reg, priv);
}

static void
Expand Down
1 change: 1 addition & 0 deletions src/network/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ static const device_t *net_cards[] = {
&de220p_device,
&ne1000_compat_device,
&ne2000_compat_device,
&ne2000_compat_pcmcia_device,
&ne1000_device,
&ne2000_device,
&pcnet_am79c960_eb_device,
Expand Down
6 changes: 6 additions & 0 deletions src/pcmcia.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
#define HAVE_STDARG_H
#include <86box/86box.h>
#include <86box/io.h>
#include <86box/device.h>
#include <86box/timer.h>
#include <86box/pcmcia.h>

static pcmcia_socket_t *pcmcia_sockets[4];
static uint8_t pcmcia_registered_sockets_num = 0;

extern const device_t pd6710_device;

void
pcmcia_reset(void)
{
Expand All @@ -35,6 +38,9 @@ pcmcia_socket_is_free(pcmcia_socket_t *socket)
pcmcia_socket_t *
pcmcia_search_for_slots(void)
{
if (!pcmcia_registered_sockets_num) {
device_add(&pd6710_device);
}
for (int i = 0; i < pcmcia_registered_sockets_num; i++) {
if (pcmcia_sockets[i] && !pcmcia_sockets[i]->card_priv)
return pcmcia_sockets[i];
Expand Down
16 changes: 12 additions & 4 deletions src/pcmcia/pcmcia_socket_pd6710.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,26 @@ pd67xx_mgmt_interrupt(pcmcia_socket_pd67xx *pd67xx, int set)

if (set && !!((pd67xx->management_interrupt_conf >> 4) & 0xF))
picint(1 << (pd67xx->management_interrupt_conf >> 4));
else if (!!((pd67xx->management_interrupt_conf >> 4) & 0xF)) {
picintc(1 << (pd67xx->management_interrupt_conf >> 4));
}
}

void
pd67xx_card_interrupt(bool set, pcmcia_socket_t *socket)
pd67xx_card_interrupt(bool set, bool level, pcmcia_socket_t *socket)
{
pcmcia_socket_pd67xx *pd67xx = socket->socket_priv;
bool level = !!(pd67xx->misc_control_1 & (1 << 3));
if (pd67xx->misc_control_1 & (1 << 3))
level = false;
if (set && !!(pd67xx->interrupt_general_control & 0xF)) {
if (level)
picintlevel(1 << (pd67xx->interrupt_general_control), &pd67xx->irq_state);
else
picint(1 << (pd67xx->interrupt_general_control));
} else if (!set && level)
picintclevel(1 << (pd67xx->interrupt_general_control), &pd67xx->irq_state);
else
picintc(1 << (pd67xx->interrupt_general_control));
}

void
Expand Down Expand Up @@ -198,7 +204,7 @@ pd67xx_ready_changed(bool status, pcmcia_socket_t *socket)
bool signal_change = false;

if (pd67xx->interrupt_general_control & (1 << 5)) {
pd67xx_card_interrupt(!status, socket);
pd67xx_card_interrupt(!status, true, socket);
return;
}

Expand Down Expand Up @@ -827,7 +833,8 @@ pd67xx_reset(void *priv)
pcmcia_socket_pd67xx *pd67xx = priv;
int i = 0;

pd67xx_card_interrupt(false, &pd67xx->socket);
pd67xx_card_interrupt(false, false, &pd67xx->socket);
pd67xx_card_interrupt(false, true, &pd67xx->socket);
pd67xx_mgmt_interrupt(pd67xx, false);

pd67xx->mapping_enable = 0;
Expand Down Expand Up @@ -881,6 +888,7 @@ pd6710_init(const device_t *info)
pd67xx->socket.card_inserted = pd67xx_card_inserted;
pd67xx->socket.ready_changed = pd67xx_ready_changed;
pd67xx->socket.status_changed = pd67xx_status_changed;
pd67xx->socket.socket_priv = pd67xx;

io_sethandler(0x3e0, 2, pd67xx_port_read, NULL, NULL, pd67xx_port_write, NULL, NULL, pd67xx);

Expand Down

0 comments on commit 6430c5b

Please sign in to comment.