/* * 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. * * This file is part of the 86Box distribution. * * Implementation of the network module. * * Version: @(#)network.c 1.0.2 2017/05/09 * * Authors: Kotori, * Fred N. van Kempen, */ #include #include #include #include #include "ibm.h" #include "device.h" #include "timer.h" #include "thread.h" #include "network.h" #include "net_ne2000.h" typedef struct { char name[64]; char internal_name[32]; device_t *device; } NETCARD; typedef struct { void (*poller)(void *); void *priv; } NETPOLL; static int net_handlers_num; static int net_poll_time = 0; static int net_poll_time; static NETPOLL net_handlers[8]; static NETCARD net_cards[] = { { "None", "none", NULL }, { "Novell NE2000", "ne2k", &ne2000_device }, { "Realtek RTL8029AS", "ne2kpci", &rtl8029as_device }, { "", "", NULL } }; int network_card_current = 0; uint8_t ethif; int inum; static void net_poll(void *priv) { int c; /* Reset the poll timer. */ net_poll_time += (int)((double)TIMER_USEC * (1000000.0/8.0/3000.0)); /* If we have active cards.. */ if (net_handlers_num) { /* .. poll each of them. */ for (c=0; cconfig ? 1 : 0); } char * network_card_get_internal_name(int card) { return(net_cards[card].internal_name); } int network_card_get_from_internal_name(char *s) { int c = 0; while (strlen(net_cards[c].internal_name)) { if (! strcmp(net_cards[c].internal_name, s)) return(c); c++; } return(0); }