Applied a whole slew of patches, getting RAM usage down by a further 10 MB.
This commit is contained in:
@@ -1,6 +1,39 @@
|
||||
/* Copyright holders: neozeed
|
||||
see COPYING for more details
|
||||
*/
|
||||
/*
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Various definitions for portable byte-swapping.
|
||||
*
|
||||
* Version: @(#)bswap.h 1.0.2 2018/03/12
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* neozeed,
|
||||
*
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 neozeed.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#ifndef BSWAP_H
|
||||
#define BSWAP_H
|
||||
|
||||
@@ -138,7 +171,7 @@ static __inline void cpu_to_le16wu(uint16_t *p, uint16_t v)
|
||||
{
|
||||
uint8_t *p1 = (uint8_t *)p;
|
||||
|
||||
p1[0] = v;
|
||||
p1[0] = v & 0xff;
|
||||
p1[1] = v >> 8;
|
||||
}
|
||||
|
||||
@@ -169,7 +202,7 @@ static __inline void cpu_to_be16wu(uint16_t *p, uint16_t v)
|
||||
uint8_t *p1 = (uint8_t *)p;
|
||||
|
||||
p1[0] = v >> 8;
|
||||
p1[1] = v;
|
||||
p1[1] = v & 0xff;
|
||||
}
|
||||
|
||||
static __inline void cpu_to_be32wu(uint32_t *p, uint32_t v)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the following network controllers:
|
||||
* - Novell NE1000 (ISA 8-bit);
|
||||
@@ -12,21 +12,36 @@
|
||||
* - Realtek RTL8019AS (ISA 16-bit, PnP);
|
||||
* - Realtek RTL8029AS (PCI).
|
||||
*
|
||||
* NOTE: The file will also implement an NE1000 for 8-bit ISA systems.
|
||||
*
|
||||
* Version: @(#)net_ne2000.c 1.0.30 2018/02/09
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Peter Grehan, <grehan@iprg.nokia.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* SA1988
|
||||
* Version: @(#)net_ne2000.c 1.0.3 2018/03/15
|
||||
*
|
||||
* Based on @(#)ne2k.cc v1.56.2.1 2004/02/02 22:37:22 cbothamy
|
||||
*
|
||||
* Portions Copyright (C) 2002 MandrakeSoft S.A.
|
||||
* Portions Copyright (C) 2018 Sarah Walker.
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* TheCollector1995, <mariogplayer@gmail.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Peter Grehan, <grehan@iprg.nokia.com>
|
||||
*
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Portions Copyright (C) 2002 MandrakeSoft S.A.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -2362,7 +2377,7 @@ nic_rom_init(nic_t *dev, wchar_t *s)
|
||||
|
||||
|
||||
static void *
|
||||
nic_init(device_t *info)
|
||||
nic_init(const device_t *info)
|
||||
{
|
||||
uint32_t mac;
|
||||
wchar_t *rom;
|
||||
@@ -2370,9 +2385,9 @@ nic_init(device_t *info)
|
||||
#ifdef ENABLE_NIC_LOG
|
||||
int i;
|
||||
#endif
|
||||
int c;
|
||||
char *ansi_id = "REALTEK PLUG & PLAY ETHERNET CARD";
|
||||
uint64_t *eeprom_pnp_id;
|
||||
int c;
|
||||
char *ansi_id = "REALTEK PLUG & PLAY ETHERNET CARD";
|
||||
uint64_t *eeprom_pnp_id;
|
||||
|
||||
/* Get the desired debug level. */
|
||||
#ifdef ENABLE_NIC_LOG
|
||||
@@ -2388,6 +2403,8 @@ nic_init(device_t *info)
|
||||
switch(dev->board) {
|
||||
case NE2K_NE1000:
|
||||
dev->is_8bit = 1;
|
||||
/*FALLTHROUGH*/
|
||||
|
||||
case NE2K_NE2000:
|
||||
dev->maclocal[0] = 0x00; /* 00:00:D8 (Novell OID) */
|
||||
dev->maclocal[1] = 0x00;
|
||||
@@ -2430,8 +2447,11 @@ nic_init(device_t *info)
|
||||
/* See if we have a local MAC address configured. */
|
||||
mac = device_get_config_mac("mac", -1);
|
||||
|
||||
/* Make this device known to the I/O system. */
|
||||
if (dev->board < NE2K_RTL8019AS) /* PnP and PCI devices start with address spaces inactive. */
|
||||
/*
|
||||
* Make this device known to the I/O system.
|
||||
* PnP and PCI devices start with address spaces inactive.
|
||||
*/
|
||||
if (dev->board < NE2K_RTL8019AS)
|
||||
nic_ioset(dev, dev->base_address);
|
||||
|
||||
/* Set up our BIOS ROM space, if any. */
|
||||
@@ -2473,21 +2493,21 @@ nic_init(device_t *info)
|
||||
dev->pci_regs[0x02] = (PCI_DEVID&0xff);
|
||||
dev->pci_regs[0x03] = (PCI_DEVID>>8);
|
||||
|
||||
dev->pci_regs[0x04] = 0x03; /* IOEN */
|
||||
dev->pci_regs[0x04] = 0x03; /* IOEN */
|
||||
dev->pci_regs[0x05] = 0x00;
|
||||
dev->pci_regs[0x07] = 0x02; /* DST0, medium devsel */
|
||||
dev->pci_regs[0x07] = 0x02; /* DST0, medium devsel */
|
||||
|
||||
dev->pci_regs[0x09] = 0x00; /* PIFR */
|
||||
dev->pci_regs[0x09] = 0x00; /* PIFR */
|
||||
|
||||
dev->pci_regs[0x0B] = 0x02; /* BCR: Network Controller */
|
||||
dev->pci_regs[0x0A] = 0x00; /* SCR: Ethernet */
|
||||
dev->pci_regs[0x0B] = 0x02; /* BCR: Network Controller */
|
||||
dev->pci_regs[0x0A] = 0x00; /* SCR: Ethernet */
|
||||
|
||||
dev->pci_regs[0x2C] = (PCI_VENDID&0xff);
|
||||
dev->pci_regs[0x2D] = (PCI_VENDID>>8);
|
||||
dev->pci_regs[0x2E] = (PCI_DEVID&0xff);
|
||||
dev->pci_regs[0x2F] = (PCI_DEVID>>8);
|
||||
|
||||
dev->pci_regs[0x3D] = PCI_INTA; /* PCI_IPR */
|
||||
dev->pci_regs[0x3D] = PCI_INTA; /* PCI_IPR */
|
||||
|
||||
/* Enable our address space in PCI. */
|
||||
dev->pci_bar[0].addr_regs[0] = 0x01;
|
||||
@@ -2503,8 +2523,9 @@ nic_init(device_t *info)
|
||||
|
||||
mem_mapping_disable(&dev->bios_rom.mapping);
|
||||
|
||||
/* Insert this device onto the PCI bus, keep its slot number. */
|
||||
dev->card = pci_add_card(PCI_ADD_NORMAL, nic_pci_read, nic_pci_write, dev);
|
||||
/* Add device to the PCI bus, keep its slot number. */
|
||||
dev->card = pci_add_card(PCI_ADD_NORMAL,
|
||||
nic_pci_read, nic_pci_write, dev);
|
||||
} else {
|
||||
io_sethandler(0x0279, 1,
|
||||
NULL, NULL, NULL,
|
||||
@@ -2536,52 +2557,52 @@ nic_init(device_t *info)
|
||||
eeprom_pnp_id = (uint64_t *) &dev->eeprom[0x12];
|
||||
*eeprom_pnp_id = dev->pnp_id;
|
||||
|
||||
/* TAG: Plug and Play Version Number */
|
||||
dev->eeprom[0x1B] = 0x0A; /* Item byte */
|
||||
dev->eeprom[0x1C] = 0x10; /* PnP version */
|
||||
dev->eeprom[0x1D] = 0x10; /* Vendor version */
|
||||
/* TAG: Plug and Play Version Number. */
|
||||
dev->eeprom[0x1B] = 0x0A; /* Item byte */
|
||||
dev->eeprom[0x1C] = 0x10; /* PnP version */
|
||||
dev->eeprom[0x1D] = 0x10; /* Vendor version */
|
||||
|
||||
/* TAG: ANSI Identifier String */
|
||||
dev->eeprom[0x1E] = 0x82; /* Item byte */
|
||||
dev->eeprom[0x1F] = 0x22; /* Length bits 7-0 */
|
||||
dev->eeprom[0x20] = 0x00; /* Length bits 15-8 */
|
||||
memcpy(&dev->eeprom[0x21], ansi_id, 0x22); /* Identifier string */
|
||||
/* TAG: ANSI Identifier String. */
|
||||
dev->eeprom[0x1E] = 0x82; /* Item byte */
|
||||
dev->eeprom[0x1F] = 0x22; /* Length bits 7-0 */
|
||||
dev->eeprom[0x20] = 0x00; /* Length bits 15-8 */
|
||||
memcpy(&dev->eeprom[0x21], ansi_id, 0x22);
|
||||
|
||||
/* TAG: Logical Device ID */
|
||||
dev->eeprom[0x43] = 0x16; /* Item byte */
|
||||
dev->eeprom[0x44] = 0x4A; /* Logical device ID0 */
|
||||
dev->eeprom[0x45] = 0x8C; /* Logical device ID1 */
|
||||
dev->eeprom[0x46] = 0x80; /* Logical device ID2 */
|
||||
dev->eeprom[0x47] = 0x19; /* Logical device ID3 */
|
||||
dev->eeprom[0x48] = 0x02; /* Flag 0 (02 = BROM is disabled) */
|
||||
dev->eeprom[0x49] = 0x00; /* Flag 1 */
|
||||
/* TAG: Logical Device ID. */
|
||||
dev->eeprom[0x43] = 0x16; /* Item byte */
|
||||
dev->eeprom[0x44] = 0x4A; /* Logical device ID0 */
|
||||
dev->eeprom[0x45] = 0x8C; /* Logical device ID1 */
|
||||
dev->eeprom[0x46] = 0x80; /* Logical device ID2 */
|
||||
dev->eeprom[0x47] = 0x19; /* Logical device ID3 */
|
||||
dev->eeprom[0x48] = 0x02; /* Flag0 (02=BROM/disabled) */
|
||||
dev->eeprom[0x49] = 0x00; /* Flag 1 */
|
||||
|
||||
/* TAG: Compatible Device ID (NE2000) */
|
||||
dev->eeprom[0x4A] = 0x1C; /* Item byte */
|
||||
dev->eeprom[0x4B] = 0x41; /* Compatible ID0 */
|
||||
dev->eeprom[0x4C] = 0xD0; /* Compatible ID1 */
|
||||
dev->eeprom[0x4D] = 0x80; /* Compatible ID2 */
|
||||
dev->eeprom[0x4E] = 0xD6; /* Compatible ID3 */
|
||||
/* TAG: Compatible Device ID (NE2000) */
|
||||
dev->eeprom[0x4A] = 0x1C; /* Item byte */
|
||||
dev->eeprom[0x4B] = 0x41; /* Compatible ID0 */
|
||||
dev->eeprom[0x4C] = 0xD0; /* Compatible ID1 */
|
||||
dev->eeprom[0x4D] = 0x80; /* Compatible ID2 */
|
||||
dev->eeprom[0x4E] = 0xD6; /* Compatible ID3 */
|
||||
|
||||
/* TAG: I/O Format */
|
||||
dev->eeprom[0x4F] = 0x47; /* Item byte */
|
||||
dev->eeprom[0x50] = 0x00; /* I/O information */
|
||||
dev->eeprom[0x51] = 0x20; /* Min. I/O base bits 7-0 */
|
||||
dev->eeprom[0x52] = 0x02; /* Min. I/O base bits 15-8 */
|
||||
dev->eeprom[0x53] = 0x80; /* Max. I/O base bits 7-0 */
|
||||
dev->eeprom[0x54] = 0x03; /* Max. I/O base bits 15-8 */
|
||||
dev->eeprom[0x55] = 0x20; /* Base alignment */
|
||||
dev->eeprom[0x56] = 0x20; /* Range length */
|
||||
/* TAG: I/O Format */
|
||||
dev->eeprom[0x4F] = 0x47; /* Item byte */
|
||||
dev->eeprom[0x50] = 0x00; /* I/O information */
|
||||
dev->eeprom[0x51] = 0x20; /* Min. I/O base bits 7-0 */
|
||||
dev->eeprom[0x52] = 0x02; /* Min. I/O base bits 15-8 */
|
||||
dev->eeprom[0x53] = 0x80; /* Max. I/O base bits 7-0 */
|
||||
dev->eeprom[0x54] = 0x03; /* Max. I/O base bits 15-8 */
|
||||
dev->eeprom[0x55] = 0x20; /* Base alignment */
|
||||
dev->eeprom[0x56] = 0x20; /* Range length */
|
||||
|
||||
/* TAG: IRQ Format */
|
||||
dev->eeprom[0x57] = 0x23; /* Item byte */
|
||||
dev->eeprom[0x58] = 0x38; /* IRQ mask bits 7-0 */
|
||||
dev->eeprom[0x59] = 0x9E; /* IRQ mask bits 15-8 */
|
||||
dev->eeprom[0x5A] = 0x01; /* IRQ information */
|
||||
/* TAG: IRQ Format. */
|
||||
dev->eeprom[0x57] = 0x23; /* Item byte */
|
||||
dev->eeprom[0x58] = 0x38; /* IRQ mask bits 7-0 */
|
||||
dev->eeprom[0x59] = 0x9E; /* IRQ mask bits 15-8 */
|
||||
dev->eeprom[0x5A] = 0x01; /* IRQ information */
|
||||
|
||||
/* TAG: END Tag */
|
||||
dev->eeprom[0x5B] = 0x79; /* Item byte */
|
||||
for (c = 0x1B; c < 0x5C; c++) /* Checksum (2's complement) */
|
||||
/* TAG: END Tag */
|
||||
dev->eeprom[0x5B] = 0x79; /* Item byte */
|
||||
for (c = 0x1b; c < 0x5c; c++) /* Checksum (2's compl) */
|
||||
dev->eeprom[0x5C] += dev->eeprom[c];
|
||||
dev->eeprom[0x5C] = -dev->eeprom[0x5C];
|
||||
|
||||
@@ -2620,7 +2641,7 @@ nic_close(void *priv)
|
||||
}
|
||||
|
||||
|
||||
static device_config_t ne1000_config[] =
|
||||
static const device_config_t ne1000_config[] =
|
||||
{
|
||||
{
|
||||
"base", "Address", CONFIG_HEX16, "", 0x300,
|
||||
@@ -2679,7 +2700,7 @@ static device_config_t ne1000_config[] =
|
||||
}
|
||||
};
|
||||
|
||||
static device_config_t ne2000_config[] =
|
||||
static const device_config_t ne2000_config[] =
|
||||
{
|
||||
{
|
||||
"base", "Address", CONFIG_HEX16, "", 0x300,
|
||||
@@ -2764,7 +2785,7 @@ static device_config_t ne2000_config[] =
|
||||
}
|
||||
};
|
||||
|
||||
static device_config_t rtl8019as_config[] =
|
||||
static const device_config_t rtl8019as_config[] =
|
||||
{
|
||||
{
|
||||
"mac", "MAC Address", CONFIG_MAC, "", -1
|
||||
@@ -2774,7 +2795,7 @@ static device_config_t rtl8019as_config[] =
|
||||
}
|
||||
};
|
||||
|
||||
static device_config_t rtl8029as_config[] =
|
||||
static const device_config_t rtl8029as_config[] =
|
||||
{
|
||||
{
|
||||
"bios", "Enable BIOS", CONFIG_BINARY, "", 0
|
||||
@@ -2788,7 +2809,7 @@ static device_config_t rtl8029as_config[] =
|
||||
};
|
||||
|
||||
|
||||
device_t ne1000_device = {
|
||||
const device_t ne1000_device = {
|
||||
"Novell NE1000",
|
||||
DEVICE_ISA,
|
||||
NE2K_NE1000,
|
||||
@@ -2797,7 +2818,7 @@ device_t ne1000_device = {
|
||||
ne1000_config
|
||||
};
|
||||
|
||||
device_t ne2000_device = {
|
||||
const device_t ne2000_device = {
|
||||
"Novell NE2000",
|
||||
DEVICE_ISA | DEVICE_AT,
|
||||
NE2K_NE2000,
|
||||
@@ -2806,7 +2827,7 @@ device_t ne2000_device = {
|
||||
ne2000_config
|
||||
};
|
||||
|
||||
device_t rtl8019as_device = {
|
||||
const device_t rtl8019as_device = {
|
||||
"Realtek RTL8019AS",
|
||||
DEVICE_ISA | DEVICE_AT,
|
||||
NE2K_RTL8019AS,
|
||||
@@ -2815,7 +2836,7 @@ device_t rtl8019as_device = {
|
||||
rtl8019as_config
|
||||
};
|
||||
|
||||
device_t rtl8029as_device = {
|
||||
const device_t rtl8029as_device = {
|
||||
"Realtek RTL8029AS",
|
||||
DEVICE_PCI,
|
||||
NE2K_RTL8029AS,
|
||||
|
||||
@@ -1,34 +1,54 @@
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Definitions for the NE2000 ethernet controller.
|
||||
*
|
||||
* Version: @(#)net_ne2000.h 1.0.5 2018/01/28
|
||||
* Version: @(#)net_ne2000.h 1.0.2 2018/03/15
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#ifndef NET_NE2000_H
|
||||
# define NET_NE2000_H
|
||||
|
||||
|
||||
enum {
|
||||
NE2K_NONE = 0,
|
||||
NE2K_NE1000, /* 8-bit ISA NE1000 */
|
||||
NE2K_NE2000, /* 16-bit ISA NE2000 */
|
||||
NE2K_RTL8019AS, /* 16-bit ISA PnP Realtek 8019AS */
|
||||
NE2K_RTL8029AS /* 32-bit PCI Realtek 8029AS */
|
||||
NE2K_NONE = 0,
|
||||
NE2K_NE1000, /* 8-bit ISA NE1000 */
|
||||
NE2K_NE2000, /* 16-bit ISA NE2000 */
|
||||
NE2K_RTL8019AS, /* 16-bit ISA PnP Realtek 8019AS */
|
||||
NE2K_RTL8029AS /* 32-bit PCI Realtek 8029AS */
|
||||
};
|
||||
|
||||
|
||||
extern device_t ne1000_device;
|
||||
extern device_t ne2000_device;
|
||||
extern device_t rtl8019as_device;
|
||||
extern device_t rtl8029as_device;
|
||||
extern const device_t ne1000_device;
|
||||
extern const device_t ne2000_device;
|
||||
extern const device_t rtl8019as_device;
|
||||
extern const device_t rtl8029as_device;
|
||||
|
||||
|
||||
#endif /*NET_NE2000_H*/
|
||||
|
||||
@@ -1,25 +1,55 @@
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Handle WinPcap library processing.
|
||||
*
|
||||
* Version: @(#)net_pcap.c 1.0.14 2018/03/18
|
||||
* Version: @(#)net_pcap.c 1.0.3 2018/03/15
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with
|
||||
* or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the entire
|
||||
* above notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names
|
||||
* of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific
|
||||
* prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include <pcap.h>
|
||||
#include <pcap/pcap.h>
|
||||
#include "../86box.h"
|
||||
#include "../config.h"
|
||||
#include "../device.h"
|
||||
@@ -31,7 +61,7 @@
|
||||
static volatile void *pcap_handle; /* handle to WinPcap DLL */
|
||||
static volatile pcap_t *pcap; /* handle to WinPcap library */
|
||||
static volatile thread_t *poll_tid;
|
||||
static netcard_t *poll_card; /* netcard linked to us */
|
||||
static const netcard_t *poll_card; /* netcard linked to us */
|
||||
static event_t *poll_state;
|
||||
|
||||
|
||||
@@ -204,9 +234,7 @@ net_pcap_init(void)
|
||||
pclog("PCAP: initializing, %s\n", errbuf);
|
||||
|
||||
/* Get the value of our capture interface. */
|
||||
if ((network_pcap == NULL) ||
|
||||
(network_pcap[0] == '\0') ||
|
||||
!strcmp(network_pcap, "none")) {
|
||||
if ((network_host[0] == '\0') || !strcmp(network_host, "none")) {
|
||||
pclog("PCAP: no interface configured!\n");
|
||||
return(-1);
|
||||
}
|
||||
@@ -274,22 +302,22 @@ net_pcap_close(void)
|
||||
* tries to attach to the network module.
|
||||
*/
|
||||
int
|
||||
net_pcap_reset(netcard_t *card, uint8_t *mac)
|
||||
net_pcap_reset(const netcard_t *card, uint8_t *mac)
|
||||
{
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
char filter_exp[255];
|
||||
struct bpf_program fp;
|
||||
|
||||
/* Open a PCAP live channel. */
|
||||
if ((pcap = f_pcap_open_live(network_pcap, /* interface name */
|
||||
if ((pcap = f_pcap_open_live(network_host, /* interface name */
|
||||
1518, /* max packet size */
|
||||
1, /* promiscuous mode? */
|
||||
10, /* timeout in msec */
|
||||
errbuf)) == NULL) { /* error buffer */
|
||||
pclog(" Unable to open device: %s!\n", network_pcap);
|
||||
pclog(" Unable to open device: %s!\n", network_host);
|
||||
return(-1);
|
||||
}
|
||||
pclog("PCAP: interface: %s\n", network_pcap);
|
||||
pclog("PCAP: interface: %s\n", network_host);
|
||||
|
||||
/* Create a MAC address based packet filter. */
|
||||
pclog("PCAP: installing filter for MAC=%02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
|
||||
@@ -1,18 +1,48 @@
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Handle SLiRP library processing.
|
||||
*
|
||||
* Version: @(#)net_slirp.c 1.0.14 2018/03/18
|
||||
* Version: @(#)net_slirp.c 1.0.2 2018/03/15
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with
|
||||
* or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the entire
|
||||
* above notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names
|
||||
* of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific
|
||||
* prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -30,7 +60,7 @@
|
||||
|
||||
static volatile queueADT slirpq; /* SLiRP library handle */
|
||||
static volatile thread_t *poll_tid;
|
||||
static netcard_t *poll_card; /* netcard attached to us */
|
||||
static const netcard_t *poll_card; /* netcard attached to us */
|
||||
static event_t *poll_state;
|
||||
|
||||
|
||||
@@ -143,7 +173,7 @@ net_slirp_init(void)
|
||||
|
||||
/* Initialize SLiRP for use. */
|
||||
int
|
||||
net_slirp_reset(netcard_t *card, uint8_t *mac)
|
||||
net_slirp_reset(const netcard_t *card, uint8_t *mac)
|
||||
{
|
||||
/* Save the callback info. */
|
||||
poll_card = card;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the network module.
|
||||
*
|
||||
@@ -12,17 +12,50 @@
|
||||
* it should be malloc'ed and then linked to the NETCARD def.
|
||||
* Will be done later.
|
||||
*
|
||||
* Version: @(#)network.c 1.0.22 2018/03/18
|
||||
* Version: @(#)network.c 1.0.3 2018/03/15
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with
|
||||
* or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the entire
|
||||
* above notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names
|
||||
* of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific
|
||||
* prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#ifdef WALTJE
|
||||
# include <ctype.h>
|
||||
#endif
|
||||
#include "../86box.h"
|
||||
#include "../device.h"
|
||||
#include "../plat.h"
|
||||
@@ -32,18 +65,18 @@
|
||||
|
||||
|
||||
static netcard_t net_cards[] = {
|
||||
{ "None", "none", NULL,
|
||||
NULL, NULL },
|
||||
{ "None", "none", NULL,
|
||||
NULL },
|
||||
{ "[ISA] Novell NE1000", "ne1k", &ne1000_device,
|
||||
NULL, NULL },
|
||||
NULL },
|
||||
{ "[ISA] Novell NE2000", "ne2k", &ne2000_device,
|
||||
NULL, NULL },
|
||||
NULL },
|
||||
{ "[ISA] Realtek RTL8019AS", "ne2kpnp", &rtl8019as_device,
|
||||
NULL, NULL },
|
||||
NULL },
|
||||
{ "[PCI] Realtek RTL8029AS", "ne2kpci", &rtl8029as_device,
|
||||
NULL, NULL },
|
||||
{ "", "", NULL,
|
||||
NULL, NULL }
|
||||
NULL },
|
||||
{ "", "", NULL,
|
||||
NULL }
|
||||
};
|
||||
|
||||
|
||||
@@ -51,7 +84,7 @@ static netcard_t net_cards[] = {
|
||||
int network_type;
|
||||
int network_ndev;
|
||||
int network_card;
|
||||
char network_pcap[512];
|
||||
char network_host[512];
|
||||
netdev_t network_devs[32];
|
||||
#ifdef ENABLE_NIC_LOG
|
||||
int nic_do_log = ENABLE_NIC_LOG;
|
||||
@@ -70,6 +103,87 @@ static struct {
|
||||
} poll_data;
|
||||
|
||||
|
||||
#ifdef WALTJE
|
||||
# define is_print(c) (isalnum((int)(c)) || ((c) == ' '))
|
||||
|
||||
|
||||
#if 0
|
||||
/* Dump a buffer in hex, standard output. */
|
||||
static void
|
||||
hexdump(uint8_t *bufp, int len)
|
||||
{
|
||||
char asci[20];
|
||||
uint8_t c;
|
||||
int addr;
|
||||
|
||||
addr = 0;
|
||||
while (len-- > 0) {
|
||||
c = bufp[addr];
|
||||
if ((addr % 16) == 0) {
|
||||
printf("%06X %02X", addr, c);
|
||||
} else {
|
||||
printf(" %02X", c);
|
||||
}
|
||||
asci[(addr & 15)] = (char)((is_print(c) ? c : '.') & 0xff);
|
||||
if ((++addr % 16) == 0) {
|
||||
asci[16] = '\0';
|
||||
printf(" | %s |\n", asci);
|
||||
}
|
||||
}
|
||||
|
||||
if (addr % 16) {
|
||||
while (addr % 16) {
|
||||
printf(" ");
|
||||
asci[(addr & 15)] = ' ';
|
||||
addr++;
|
||||
}
|
||||
asci[16] = '\0';
|
||||
printf(" | %s |\n", asci);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Dump a buffer in hex to output buffer. */
|
||||
static void
|
||||
hexdump_p(char *ptr, uint8_t *bufp, int len)
|
||||
{
|
||||
char asci[20];
|
||||
uint8_t c;
|
||||
int addr;
|
||||
|
||||
addr = 0;
|
||||
while (len-- > 0) {
|
||||
c = bufp[addr];
|
||||
if ((addr % 16) == 0) {
|
||||
sprintf(ptr, "%06X %02X", addr, c);
|
||||
} else {
|
||||
sprintf(ptr, " %02X", c);
|
||||
}
|
||||
ptr += strlen(ptr);
|
||||
asci[(addr & 15)] = (char)((is_print(c) ? c : '.') & 0xff);
|
||||
if ((++addr % 16) == 0) {
|
||||
asci[16] = '\0';
|
||||
sprintf(ptr, " | %s |\n", asci);
|
||||
ptr += strlen(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (addr % 16) {
|
||||
while (addr % 16) {
|
||||
sprintf(ptr, " ");
|
||||
ptr += strlen(ptr);
|
||||
asci[(addr & 15)] = ' ';
|
||||
addr++;
|
||||
}
|
||||
asci[16] = '\0';
|
||||
sprintf(ptr, " | %s |\n", asci);
|
||||
ptr += strlen(ptr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
network_wait(uint8_t wait)
|
||||
{
|
||||
@@ -99,7 +213,7 @@ network_busy(uint8_t set)
|
||||
thread_set_event(poll_data.wake_poll_thread);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
network_end(void)
|
||||
{
|
||||
@@ -214,7 +328,13 @@ network_reset(void)
|
||||
{
|
||||
int i = -1;
|
||||
|
||||
pclog("NETWORK: reset (type=%d, card=%d)\n", network_type, network_card);
|
||||
#ifdef ENABLE_NIC_LOG
|
||||
pclog("NETWORK: reset (type=%d, card=%d) debug=%d\n",
|
||||
network_type, network_card, nic_do_log);
|
||||
#else
|
||||
pclog("NETWORK: reset (type=%d, card=%d)\n",
|
||||
network_type, network_card);
|
||||
#endif
|
||||
ui_sb_update_icon(SB_NETWORK, 0);
|
||||
|
||||
/* Just in case.. */
|
||||
@@ -223,7 +343,7 @@ network_reset(void)
|
||||
/* If no active card, we're done. */
|
||||
if ((network_type==NET_TYPE_NONE) || (network_card==0)) return;
|
||||
|
||||
network_mutex = thread_create_mutex(L"86Box.NetMutex");
|
||||
network_mutex = thread_create_mutex(L"VARCem.NetMutex");
|
||||
|
||||
/* Initialize the platform module. */
|
||||
switch(network_type) {
|
||||
@@ -269,6 +389,14 @@ network_tx(uint8_t *bufp, int len)
|
||||
{
|
||||
ui_sb_update_icon(SB_NETWORK, 1);
|
||||
|
||||
#ifdef WALTJE
|
||||
{
|
||||
char temp[4096];
|
||||
hexdump_p(temp, bufp, len);
|
||||
pclog("NETWORK: >> len=%d\n%s\n", len, temp);
|
||||
}
|
||||
#endif
|
||||
|
||||
switch(network_type) {
|
||||
case NET_TYPE_PCAP:
|
||||
net_pcap_in(bufp, len);
|
||||
@@ -289,7 +417,7 @@ network_dev_to_id(char *devname)
|
||||
int i = 0;
|
||||
|
||||
for (i=0; i<network_ndev; i++) {
|
||||
if (! strcmp((char *) network_devs[i].device, devname)) {
|
||||
if (! strcmp((char *)network_devs[i].device, devname)) {
|
||||
return(i);
|
||||
}
|
||||
}
|
||||
@@ -324,12 +452,12 @@ network_card_available(int card)
|
||||
char *
|
||||
network_card_getname(int card)
|
||||
{
|
||||
return((char *) net_cards[card].name);
|
||||
return((char *)net_cards[card].name);
|
||||
}
|
||||
|
||||
|
||||
/* UI */
|
||||
device_t *
|
||||
const device_t *
|
||||
network_card_getdevice(int card)
|
||||
{
|
||||
return(net_cards[card].device);
|
||||
@@ -350,7 +478,7 @@ network_card_has_config(int card)
|
||||
char *
|
||||
network_card_get_internal_name(int card)
|
||||
{
|
||||
return((char *) net_cards[card].internal_name);
|
||||
return((char *)net_cards[card].internal_name);
|
||||
}
|
||||
|
||||
|
||||
@@ -360,8 +488,8 @@ network_card_get_from_internal_name(char *s)
|
||||
{
|
||||
int c = 0;
|
||||
|
||||
while (strlen((char *) net_cards[c].internal_name)) {
|
||||
if (! strcmp((char *) net_cards[c].internal_name, s))
|
||||
while (strlen((char *)net_cards[c].internal_name)) {
|
||||
if (! strcmp((char *)net_cards[c].internal_name, s))
|
||||
return(c);
|
||||
c++;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,48 @@
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Definitions for the network module.
|
||||
*
|
||||
* Version: @(#)network.h 1.0.13 2018/03/18
|
||||
* Version: @(#)network.h 1.0.2 2018/03/15
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with
|
||||
* or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the entire
|
||||
* above notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names
|
||||
* of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific
|
||||
* prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef EMU_NETWORK_H
|
||||
# define EMU_NETWORK_H
|
||||
@@ -24,11 +56,11 @@
|
||||
|
||||
/* Supported network cards. */
|
||||
enum {
|
||||
NONE = 0,
|
||||
NE1000,
|
||||
NE2000,
|
||||
RTL8019AS,
|
||||
RTL8029AS
|
||||
NONE = 0,
|
||||
NE1000,
|
||||
NE2000,
|
||||
RTL8019AS,
|
||||
RTL8029AS
|
||||
};
|
||||
|
||||
|
||||
@@ -36,18 +68,17 @@ typedef void (*NETRXCB)(void *, uint8_t *, int);
|
||||
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const char *internal_name;
|
||||
device_t *device;
|
||||
void *priv;
|
||||
int (*poll)(void *);
|
||||
NETRXCB rx;
|
||||
uint8_t *mac;
|
||||
const char *name;
|
||||
const char *internal_name;
|
||||
const device_t *device;
|
||||
void *priv;
|
||||
int (*poll)(void *);
|
||||
NETRXCB rx;
|
||||
} netcard_t;
|
||||
|
||||
typedef struct {
|
||||
char device[128];
|
||||
char description[128];
|
||||
char device[128];
|
||||
char description[128];
|
||||
} netdev_t;
|
||||
|
||||
|
||||
@@ -57,9 +88,6 @@ extern "C" {
|
||||
|
||||
/* Global variables. */
|
||||
extern int nic_do_log; /* config */
|
||||
extern int network_card; /* config */
|
||||
extern int network_type; /* config */
|
||||
extern char network_pcap[512]; /* config */
|
||||
extern int network_ndev;
|
||||
extern netdev_t network_devs[32];
|
||||
|
||||
@@ -79,12 +107,12 @@ extern void network_tx(uint8_t *, int);
|
||||
|
||||
extern int net_pcap_prepare(netdev_t *);
|
||||
extern int net_pcap_init(void);
|
||||
extern int net_pcap_reset(netcard_t *, uint8_t *);
|
||||
extern int net_pcap_reset(const netcard_t *, uint8_t *);
|
||||
extern void net_pcap_close(void);
|
||||
extern void net_pcap_in(uint8_t *, int);
|
||||
|
||||
extern int net_slirp_init(void);
|
||||
extern int net_slirp_reset(netcard_t *, uint8_t *);
|
||||
extern int net_slirp_reset(const netcard_t *, uint8_t *);
|
||||
extern void net_slirp_close(void);
|
||||
extern void net_slirp_in(uint8_t *, int);
|
||||
|
||||
@@ -94,7 +122,7 @@ extern char *network_card_getname(int);
|
||||
extern int network_card_has_config(int);
|
||||
extern char *network_card_get_internal_name(int);
|
||||
extern int network_card_get_from_internal_name(char *);
|
||||
extern device_t *network_card_getdevice(int);
|
||||
extern const device_t *network_card_getdevice(int);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1,20 +1,50 @@
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Simple program to show usage of (Win)Pcap.
|
||||
*
|
||||
* Based on the "libpcap" examples.
|
||||
*
|
||||
* Version: @(#)pcap_if.c 1.0.7 2017/10/28
|
||||
* Version: @(#)pcap_if.c 1.0.10 2018/03/10
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2017 Fred N. van Kempen.
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with
|
||||
* or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the entire
|
||||
* above notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names
|
||||
* of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific
|
||||
* prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -22,7 +52,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <ctype.h>
|
||||
#include <pcap.h>
|
||||
#include <pcap/pcap.h>
|
||||
#include <time.h>
|
||||
#include "../86box.h"
|
||||
#include "../plat.h"
|
||||
|
||||
@@ -19,7 +19,9 @@ int dostats = 0;
|
||||
#endif
|
||||
int slirp_debug = 0;
|
||||
|
||||
#ifndef _MSC_VER
|
||||
extern char *strerror _P((int));
|
||||
#endif
|
||||
|
||||
/* Carry over one item from main.c so that the tty's restored.
|
||||
* Only done when the tty being used is /dev/tty --RedWolf */
|
||||
|
||||
Reference in New Issue
Block a user