Added Intel Advanced/ZP; Added Commodore PC 60 III; Fixed Force 4:3 option when overscan is not enabled; Added option to scale (0.5x, 1x, 1.5x, 2x) the video output; Added ability to disable ATAPI DMA for CD-ROM drives; Applied all mainline PCem commits; Store network card in config file as name rather than number; Fixed NVR storing for IBM PS/2 Models 2121 and 2121+ISA.
204 lines
4.2 KiB
C
204 lines
4.2 KiB
C
/* Copyright holders: Sarah Walker, Tenshi
|
|
see COPYING for more details
|
|
*/
|
|
#include <windows.h>
|
|
#include <winsock2.h>
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <memory.h>
|
|
#include "nethandler.h"
|
|
|
|
#include "ibm.h"
|
|
#include "device.h"
|
|
|
|
#include "ne2000.h"
|
|
#include "timer.h"
|
|
#include "thread.h"
|
|
|
|
int network_card_current = 0;
|
|
static int network_card_last = 0;
|
|
|
|
typedef struct
|
|
{
|
|
char name[64];
|
|
char internal_name[32];
|
|
device_t *device;
|
|
} NETWORK_CARD;
|
|
|
|
static NETWORK_CARD network_cards[] =
|
|
{
|
|
{"None", "none", NULL},
|
|
{"Novell NE2000", "ne2k", &ne2000_device},
|
|
{"Realtek RTL8029AS", "ne2kpci", &rtl8029as_device},
|
|
{"", NULL}
|
|
};
|
|
|
|
int network_card_available(int card)
|
|
{
|
|
if (network_cards[card].device)
|
|
return device_available(network_cards[card].device);
|
|
|
|
return 1;
|
|
}
|
|
|
|
char *network_card_getname(int card)
|
|
{
|
|
return network_cards[card].name;
|
|
}
|
|
|
|
device_t *network_card_getdevice(int card)
|
|
{
|
|
return network_cards[card].device;
|
|
}
|
|
|
|
int network_card_has_config(int card)
|
|
{
|
|
if (!network_cards[card].device)
|
|
return 0;
|
|
return network_cards[card].device->config ? 1 : 0;
|
|
}
|
|
|
|
char *network_card_get_internal_name(int card)
|
|
{
|
|
return network_cards[card].internal_name;
|
|
}
|
|
|
|
int network_card_get_from_internal_name(char *s)
|
|
{
|
|
int c = 0;
|
|
|
|
while (strlen(network_cards[c].internal_name))
|
|
{
|
|
if (!strcmp(network_cards[c].internal_name, s))
|
|
return c;
|
|
c++;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void network_card_init()
|
|
{
|
|
if (network_cards[network_card_current].device)
|
|
device_add(network_cards[network_card_current].device);
|
|
network_card_last = network_card_current;
|
|
}
|
|
|
|
static struct
|
|
{
|
|
void (*poller)(void *p);
|
|
void *priv;
|
|
} vlan_handlers[8];
|
|
|
|
static int vlan_handlers_num;
|
|
|
|
static int vlan_poller_time = 0;
|
|
|
|
void vlan_handler(void (*poller)(void *p), void *p)
|
|
//void vlan_handler(int (*can_receive)(void *p), void (*receive)(void *p, const uint8_t *buf, int size), void *p)
|
|
{
|
|
/* vlan_handlers[vlan_handlers_num].can_receive = can_receive; */
|
|
vlan_handlers[vlan_handlers_num].poller = poller;
|
|
vlan_handlers[vlan_handlers_num].priv = p;
|
|
vlan_handlers_num++;
|
|
}
|
|
|
|
static thread_t *network_thread_h;
|
|
static event_t *network_event;
|
|
|
|
static int network_thread_initialized = 0;
|
|
static int network_thread_enable = 0;
|
|
|
|
static void network_thread(void *param)
|
|
{
|
|
int c;
|
|
|
|
// pclog("Network thread\n");
|
|
|
|
// while(1)
|
|
// {
|
|
// pclog("Waiting...\n");
|
|
// thread_wait_event(network_event, -1);
|
|
|
|
// pclog("Processing\n");
|
|
|
|
for (c = 0; c < vlan_handlers_num; c++)
|
|
vlan_handlers[c].poller(vlan_handlers[c].priv);
|
|
// }
|
|
}
|
|
|
|
void network_thread_init()
|
|
{
|
|
#if 0
|
|
pclog("network_thread_init()\n");
|
|
|
|
if (network_card_current)
|
|
{
|
|
pclog("Thread enabled...\n");
|
|
|
|
network_event = thread_create_event();
|
|
network_thread_h = thread_create(network_thread, NULL);
|
|
}
|
|
|
|
network_thread_enable = network_card_current ? 1 : 0;
|
|
network_thread_initialized = 1;
|
|
#endif
|
|
}
|
|
|
|
void network_thread_reset()
|
|
{
|
|
#if 0
|
|
if(!network_thread_initialized)
|
|
{
|
|
network_thread_init();
|
|
return;
|
|
}
|
|
|
|
pclog("network_thread_reset()\n");
|
|
if (network_card_current && !network_thread_enable)
|
|
{
|
|
pclog("Thread enabled (disabled before...\n");
|
|
network_event = thread_create_event();
|
|
network_thread_h = thread_create(network_thread, NULL);
|
|
}
|
|
else if (!network_card_current && network_thread_enable)
|
|
{
|
|
pclog("Thread disabled (enabled before...\n");
|
|
thread_destroy_event(network_event);
|
|
thread_kill(network_thread_h);
|
|
network_thread_h = NULL;
|
|
}
|
|
|
|
network_thread_enable = network_card_current ? 1 : 0;
|
|
#endif
|
|
}
|
|
|
|
void vlan_poller(void *priv)
|
|
{
|
|
int c;
|
|
|
|
vlan_poller_time += (int)((double)TIMER_USEC * (1000000.0 / 8.0 / 3000.0));
|
|
|
|
if (/*network_thread_enable && */ vlan_handlers_num)
|
|
{
|
|
// pclog("Setting thread event...\n");
|
|
// thread_set_event(network_event);
|
|
network_thread(priv);
|
|
}
|
|
}
|
|
|
|
void vlan_reset()
|
|
{
|
|
pclog("vlan_reset()\n");
|
|
|
|
if (network_card_current)
|
|
{
|
|
pclog("Adding timer...\n");
|
|
|
|
timer_add(vlan_poller, &vlan_poller_time, TIMER_ALWAYS_ENABLED, NULL);
|
|
}
|
|
|
|
vlan_handlers_num = 0;
|
|
}
|