Reworked serial and LPT set up - they can now bet set to any I/O base address (though that capability is not used by anything yet);
The CD-ROM IOCTL direct pass through code now does sanity check on the requested data size before passing the command - fixes crashes with some DMA-only host DVD drives; The network poller is now in its own thread; The hack is back in the emulation of the National Semiconductors PC87306 Super I/O Chip - it's the only way right now to have serial working on that board; Fixed a part of the code that was still using NukedOPL even when OPL 3 was set to DOSBox OPL; Applied all mainline PCem commits.
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "ne2000.h"
|
||||
#include "timer.h"
|
||||
#include "thread.h"
|
||||
|
||||
int network_card_current = 0;
|
||||
static int network_card_last = 0;
|
||||
@@ -83,19 +84,95 @@ void vlan_handler(void (*poller)(void *p), void *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()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
void network_thread_reset()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
void vlan_poller(void *priv)
|
||||
{
|
||||
int c;
|
||||
|
||||
vlan_poller_time += (int)((double)TIMER_USEC * (1000000.0 / 8.0 / 3000.0));
|
||||
vlan_poller_time += (int)((double)TIMER_USEC * (1000000.0 / 8.0 / 15000.0));
|
||||
|
||||
for (c = 0; c < vlan_handlers_num; c++)
|
||||
vlan_handlers[c].poller(vlan_handlers[c].priv);
|
||||
if (network_thread_enable && vlan_handlers_num)
|
||||
{
|
||||
// pclog("Setting thread event...\n");
|
||||
thread_set_event(network_event);
|
||||
}
|
||||
}
|
||||
|
||||
void vlan_reset()
|
||||
{
|
||||
timer_add(vlan_poller, &vlan_poller_time, TIMER_ALWAYS_ENABLED, NULL);
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user