Ported the WinPcap thread's packet sanity checks to the SLiRP thread - SLiRP is now more stable;
Unified all three NIC families' DP8390 chip implementations in net_dp8390.c/h; Some fixes for the WD8013EBT NIC; Network status bar icon updating is now done at WinPcap/SLiRP handler level, not at the NIC level anymore.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Header of the emulation of the DP8390 Network Interface
|
||||||
|
* Controller used by the WD family, NE1000/NE2000 family, and
|
||||||
|
* 3Com 3C503 NIC's.
|
||||||
|
*
|
||||||
|
* Version: @(#)net_dp8390.h 1.0.0 2018/10/17
|
||||||
|
*
|
||||||
|
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||||
|
* Bochs project,
|
||||||
|
*
|
||||||
|
* Copyright 2016-2018 Miran Grca.
|
||||||
|
* Copyright 2008-2018 Bochs project.
|
||||||
|
*/
|
||||||
#ifndef NET_DP8390_H
|
#ifndef NET_DP8390_H
|
||||||
# define NET_DP8390_H
|
# define NET_DP8390_H
|
||||||
|
|
||||||
@@ -13,6 +31,11 @@
|
|||||||
#define DP8390_WORD_MEMSTART (8*1024)
|
#define DP8390_WORD_MEMSTART (8*1024)
|
||||||
#define DP8390_WORD_MEMEND (DP8390_WORD_MEMSTART+DP8390_WORD_MEMSIZ)
|
#define DP8390_WORD_MEMEND (DP8390_WORD_MEMSTART+DP8390_WORD_MEMSIZ)
|
||||||
|
|
||||||
|
#define DP8390_FLAG_DWORD_MEM 0x01
|
||||||
|
#define DP8390_FLAG_CHECK_CR 0x02
|
||||||
|
#define DP8390_FLAG_CLEAR_IRQ 0x04
|
||||||
|
#define DP8390_FLAG_NO_CHIPMEM 0x08
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* Page 0 */
|
/* Page 0 */
|
||||||
|
|
||||||
@@ -148,11 +171,45 @@ typedef struct {
|
|||||||
/* Novell ASIC state */
|
/* Novell ASIC state */
|
||||||
uint8_t mem[DP8390_DWORD_MEMSIZ]; /* on-chip packet memory */
|
uint8_t mem[DP8390_DWORD_MEMSIZ]; /* on-chip packet memory */
|
||||||
|
|
||||||
|
uint8_t macaddr[32]; /* ASIC ROM'd MAC address, even bytes */
|
||||||
|
uint8_t macaddr_size, /* Defaults to 16 but can be 32 */
|
||||||
|
flags, /* Flags affecting some behaviors. */
|
||||||
|
id0, /* 0x50 for the Realtek NIC's, otherwise
|
||||||
|
0xFF. */
|
||||||
|
id1; /* 0x70 for the RTL8019AS, 0x43 for the
|
||||||
|
RTL8029AS, otherwise 0xFF. */
|
||||||
|
int mem_size, mem_start, mem_end;
|
||||||
|
|
||||||
int tx_timer_index;
|
int tx_timer_index;
|
||||||
int tx_timer_active;
|
int tx_timer_active;
|
||||||
|
|
||||||
|
void *priv;
|
||||||
|
|
||||||
|
void (*interrupt)(void *priv, int set);
|
||||||
} dp8390_t;
|
} dp8390_t;
|
||||||
|
|
||||||
extern int mcast_index(const void *dst);
|
extern const device_t dp8390_device;
|
||||||
|
|
||||||
|
|
||||||
|
extern uint32_t dp8390_chipmem_read(dp8390_t *dev, uint32_t addr, unsigned int len);
|
||||||
|
extern void dp8390_chipmem_write(dp8390_t *dev, uint32_t addr, uint32_t val, unsigned len);
|
||||||
|
|
||||||
|
extern uint32_t dp8390_read_cr(dp8390_t *dev);
|
||||||
|
extern void dp8390_write_cr(dp8390_t *dev, uint32_t val);
|
||||||
|
|
||||||
|
extern void dp8390_rx(void *priv, uint8_t *buf, int io_len);
|
||||||
|
|
||||||
|
extern uint32_t dp8390_page0_read(dp8390_t *dev, uint32_t off, unsigned int len);
|
||||||
|
extern void dp8390_page0_write(dp8390_t *dev, uint32_t off, uint32_t val, unsigned len);
|
||||||
|
extern uint32_t dp8390_page1_read(dp8390_t *dev, uint32_t off, unsigned int len);
|
||||||
|
extern void dp8390_page1_write(dp8390_t *dev, uint32_t off, uint32_t val, unsigned len);
|
||||||
|
extern uint32_t dp8390_page2_read(dp8390_t *dev, uint32_t off, unsigned int len);
|
||||||
|
extern void dp8390_page2_write(dp8390_t *dev, uint32_t off, uint32_t val, unsigned len);
|
||||||
|
|
||||||
|
extern void dp8390_set_defaults(dp8390_t *dev, uint8_t flags);
|
||||||
|
extern void dp8390_set_id(dp8390_t *dev, uint8_t id0, uint8_t id1);
|
||||||
|
extern void dp8390_reset(dp8390_t *dev);
|
||||||
|
extern void dp8390_soft_reset(dp8390_t *dev);
|
||||||
|
|
||||||
|
|
||||||
#endif /*NET_DP8390_H*/
|
#endif /*NET_DP8390_H*/
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Handle WinPcap library processing.
|
* Handle WinPcap library processing.
|
||||||
*
|
*
|
||||||
* Version: @(#)net_pcap.c 1.0.5 2018/10/02
|
* Version: @(#)net_pcap.c 1.0.6 2018/10/17
|
||||||
*
|
*
|
||||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
*
|
*
|
||||||
@@ -55,6 +55,7 @@
|
|||||||
#include "../device.h"
|
#include "../device.h"
|
||||||
#include "../plat.h"
|
#include "../plat.h"
|
||||||
#include "../plat_dynld.h"
|
#include "../plat_dynld.h"
|
||||||
|
#include "../ui.h"
|
||||||
#include "network.h"
|
#include "network.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -138,22 +139,22 @@ static dllimp_t pcap_imports[] = {
|
|||||||
|
|
||||||
#ifdef ENABLE_PCAP_LOG
|
#ifdef ENABLE_PCAP_LOG
|
||||||
int pcap_do_log = ENABLE_PCAP_LOG;
|
int pcap_do_log = ENABLE_PCAP_LOG;
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pcap_log(const char *format, ...)
|
pcap_log(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_PCAP_LOG
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
if (pcap_do_log) {
|
if (pcap_do_log) {
|
||||||
va_start(ap, format);
|
va_start(ap, fmt);
|
||||||
pclog_ex(format, ap);
|
pclog_ex(fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#define pcap_log(fmt, ...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Handle the receiving of frames from the channel. */
|
/* Handle the receiving of frames from the channel. */
|
||||||
@@ -186,6 +187,8 @@ poll_thread(void *arg)
|
|||||||
/* Wait for the next packet to arrive. */
|
/* Wait for the next packet to arrive. */
|
||||||
data = (uint8_t *)f_pcap_next((void *)pcap, &h);
|
data = (uint8_t *)f_pcap_next((void *)pcap, &h);
|
||||||
if (data != NULL) {
|
if (data != NULL) {
|
||||||
|
ui_sb_update_icon(SB_NETWORK, 1);
|
||||||
|
|
||||||
/* Received MAC. */
|
/* Received MAC. */
|
||||||
mac_cmp32[0] = *(uint32_t *)(data+6);
|
mac_cmp32[0] = *(uint32_t *)(data+6);
|
||||||
mac_cmp16[0] = *(uint16_t *)(data+10);
|
mac_cmp16[0] = *(uint16_t *)(data+10);
|
||||||
@@ -204,8 +207,10 @@ poll_thread(void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If we did not get anything, wait a while. */
|
/* If we did not get anything, wait a while. */
|
||||||
if (data == NULL)
|
if (data == NULL) {
|
||||||
|
ui_sb_update_icon(SB_NETWORK, 0);
|
||||||
thread_wait_event(evt, 10);
|
thread_wait_event(evt, 10);
|
||||||
|
}
|
||||||
|
|
||||||
/* Release ownership of the device. */
|
/* Release ownership of the device. */
|
||||||
network_wait(0);
|
network_wait(0);
|
||||||
@@ -319,6 +324,8 @@ net_pcap_close(void)
|
|||||||
{
|
{
|
||||||
void *pc;
|
void *pc;
|
||||||
|
|
||||||
|
ui_sb_update_icon(SB_NETWORK, 0);
|
||||||
|
|
||||||
if (pcap == NULL) return;
|
if (pcap == NULL) return;
|
||||||
|
|
||||||
pcap_log("PCAP: closing.\n");
|
pcap_log("PCAP: closing.\n");
|
||||||
@@ -374,6 +381,8 @@ net_pcap_reset(const netcard_t *card, uint8_t *mac)
|
|||||||
char filter_exp[255];
|
char filter_exp[255];
|
||||||
struct bpf_program fp;
|
struct bpf_program fp;
|
||||||
|
|
||||||
|
ui_sb_update_icon(SB_NETWORK, 0);
|
||||||
|
|
||||||
/* Open a PCAP live channel. */
|
/* Open a PCAP live channel. */
|
||||||
if ((pcap = f_pcap_open_live(network_host, /* interface name */
|
if ((pcap = f_pcap_open_live(network_host, /* interface name */
|
||||||
1518, /* max packet size */
|
1518, /* max packet size */
|
||||||
@@ -422,9 +431,13 @@ net_pcap_in(uint8_t *bufp, int len)
|
|||||||
{
|
{
|
||||||
if (pcap == NULL) return;
|
if (pcap == NULL) return;
|
||||||
|
|
||||||
|
ui_sb_update_icon(SB_NETWORK, 1);
|
||||||
|
|
||||||
network_busy(1);
|
network_busy(1);
|
||||||
|
|
||||||
f_pcap_sendpacket((void *)pcap, bufp, len);
|
f_pcap_sendpacket((void *)pcap, bufp, len);
|
||||||
|
|
||||||
network_busy(0);
|
network_busy(0);
|
||||||
|
|
||||||
|
ui_sb_update_icon(SB_NETWORK, 0);
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Handle SLiRP library processing.
|
* Handle SLiRP library processing.
|
||||||
*
|
*
|
||||||
* Version: @(#)net_slirp.c 1.0.4 2018/10/02
|
* Version: @(#)net_slirp.c 1.0.5 2018/10/17
|
||||||
*
|
*
|
||||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
*
|
*
|
||||||
@@ -56,6 +56,7 @@
|
|||||||
#include "../86box.h"
|
#include "../86box.h"
|
||||||
#include "../device.h"
|
#include "../device.h"
|
||||||
#include "../plat.h"
|
#include "../plat.h"
|
||||||
|
#include "../ui.h"
|
||||||
#include "network.h"
|
#include "network.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -67,22 +68,22 @@ static event_t *poll_state;
|
|||||||
|
|
||||||
#ifdef ENABLE_SLIRP_LOG
|
#ifdef ENABLE_SLIRP_LOG
|
||||||
int slirp_do_log = ENABLE_SLIRP_LOG;
|
int slirp_do_log = ENABLE_SLIRP_LOG;
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
slirp_log(const char *format, ...)
|
slirp_log(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_SLIRP_LOG
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
if (slirp_do_log) {
|
if (slirp_do_log) {
|
||||||
va_start(ap, format);
|
va_start(ap, fmt);
|
||||||
pclog_ex(format, ap);
|
pclog_ex(fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#define slirp_log(fmt, ...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -116,10 +117,14 @@ slirp_tic(void)
|
|||||||
|
|
||||||
/* Handle the receiving of frames. */
|
/* Handle the receiving of frames. */
|
||||||
static void
|
static void
|
||||||
poll_thread(UNUSED(void *arg))
|
poll_thread(void *arg)
|
||||||
{
|
{
|
||||||
|
uint8_t *mac = (uint8_t *)arg;
|
||||||
struct queuepacket *qp;
|
struct queuepacket *qp;
|
||||||
|
uint32_t mac_cmp32[2];
|
||||||
|
uint16_t mac_cmp16[2];
|
||||||
event_t *evt;
|
event_t *evt;
|
||||||
|
int data_valid = 0;
|
||||||
|
|
||||||
slirp_log("SLiRP: polling started.\n");
|
slirp_log("SLiRP: polling started.\n");
|
||||||
thread_set_event(poll_state);
|
thread_set_event(poll_state);
|
||||||
@@ -141,18 +146,37 @@ poll_thread(UNUSED(void *arg))
|
|||||||
if (slirpq == NULL) break;
|
if (slirpq == NULL) break;
|
||||||
|
|
||||||
/* Wait for the next packet to arrive. */
|
/* Wait for the next packet to arrive. */
|
||||||
|
data_valid = 0;
|
||||||
|
|
||||||
if (QueuePeek(slirpq) != 0) {
|
if (QueuePeek(slirpq) != 0) {
|
||||||
/* Grab a packet from the queue. */
|
/* Grab a packet from the queue. */
|
||||||
|
ui_sb_update_icon(SB_NETWORK, 1);
|
||||||
|
|
||||||
qp = QueueDelete(slirpq);
|
qp = QueueDelete(slirpq);
|
||||||
slirp_log("SLiRP: inQ:%d got a %dbyte packet @%08lx\n",
|
slirp_log("SLiRP: inQ:%d got a %dbyte packet @%08lx\n",
|
||||||
QueuePeek(slirpq), qp->len, qp);
|
QueuePeek(slirpq), qp->len, qp);
|
||||||
|
|
||||||
poll_card->rx(poll_card->priv, (uint8_t *)qp->data, qp->len);
|
/* Received MAC. */
|
||||||
|
mac_cmp32[0] = *(uint32_t *)(((uint8_t *)qp->data)+6);
|
||||||
|
mac_cmp16[0] = *(uint16_t *)(((uint8_t *)qp->data)+10);
|
||||||
|
|
||||||
|
/* Local MAC. */
|
||||||
|
mac_cmp32[1] = *(uint32_t *)mac;
|
||||||
|
mac_cmp16[1] = *(uint16_t *)(mac+4);
|
||||||
|
if ((mac_cmp32[0] != mac_cmp32[1]) ||
|
||||||
|
(mac_cmp16[0] != mac_cmp16[1])) {
|
||||||
|
|
||||||
|
poll_card->rx(poll_card->priv, (uint8_t *)qp->data, qp->len);
|
||||||
|
data_valid = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Done with this one. */
|
/* Done with this one. */
|
||||||
free(qp);
|
free(qp);
|
||||||
} else {
|
}
|
||||||
/* If we did not get anything, wait a while. */
|
|
||||||
|
/* If we did not get anything, wait a while. */
|
||||||
|
if (!data_valid) {
|
||||||
|
ui_sb_update_icon(SB_NETWORK, 0);
|
||||||
thread_wait_event(evt, 10);
|
thread_wait_event(evt, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,6 +218,8 @@ net_slirp_init(void)
|
|||||||
int
|
int
|
||||||
net_slirp_reset(const netcard_t *card, uint8_t *mac)
|
net_slirp_reset(const netcard_t *card, uint8_t *mac)
|
||||||
{
|
{
|
||||||
|
ui_sb_update_icon(SB_NETWORK, 0);
|
||||||
|
|
||||||
/* Save the callback info. */
|
/* Save the callback info. */
|
||||||
poll_card = card;
|
poll_card = card;
|
||||||
|
|
||||||
@@ -211,6 +237,8 @@ net_slirp_close(void)
|
|||||||
{
|
{
|
||||||
queueADT sl;
|
queueADT sl;
|
||||||
|
|
||||||
|
ui_sb_update_icon(SB_NETWORK, 0);
|
||||||
|
|
||||||
if (slirpq == NULL) return;
|
if (slirpq == NULL) return;
|
||||||
|
|
||||||
slirp_log("SLiRP: closing.\n");
|
slirp_log("SLiRP: closing.\n");
|
||||||
@@ -245,11 +273,15 @@ net_slirp_in(uint8_t *pkt, int pkt_len)
|
|||||||
{
|
{
|
||||||
if (slirpq == NULL) return;
|
if (slirpq == NULL) return;
|
||||||
|
|
||||||
|
ui_sb_update_icon(SB_NETWORK, 1);
|
||||||
|
|
||||||
network_busy(1);
|
network_busy(1);
|
||||||
|
|
||||||
slirp_input((const uint8_t *)pkt, pkt_len);
|
slirp_input((const uint8_t *)pkt, pkt_len);
|
||||||
|
|
||||||
network_busy(0);
|
network_busy(0);
|
||||||
|
|
||||||
|
ui_sb_update_icon(SB_NETWORK, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -12,7 +12,7 @@
|
|||||||
* it should be malloc'ed and then linked to the NETCARD def.
|
* it should be malloc'ed and then linked to the NETCARD def.
|
||||||
* Will be done later.
|
* Will be done later.
|
||||||
*
|
*
|
||||||
* Version: @(#)network.c 1.0.7 2018/08/11
|
* Version: @(#)network.c 1.0.8 2018/10/17
|
||||||
*
|
*
|
||||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
*
|
*
|
||||||
@@ -116,22 +116,22 @@ static struct {
|
|||||||
|
|
||||||
#ifdef ENABLE_NETWORK_LOG
|
#ifdef ENABLE_NETWORK_LOG
|
||||||
int network_do_log = ENABLE_NETWORK_LOG;
|
int network_do_log = ENABLE_NETWORK_LOG;
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
network_log(const char *format, ...)
|
network_log(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_NETWORK_LOG
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
if (network_do_log) {
|
if (network_do_log) {
|
||||||
va_start(ap, format);
|
va_start(ap, fmt);
|
||||||
pclog_ex(format, ap);
|
pclog_ex(fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#define network_log(fmt, ...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Reference in New Issue
Block a user