Numerous CD-ROM fixes (and disc changes now work correctly in Windows 98 SE);

Slight reworking in the mouse and network code (ported from VARCem) in preparation for a major change that will const a lot of things to further reduce RAM usage.
This commit is contained in:
OBattler
2018-03-18 20:48:10 +01:00
parent 0cb43db290
commit b6c393cc91
11 changed files with 196 additions and 191 deletions

View File

@@ -8,11 +8,11 @@
*
* Handle WinPcap library processing.
*
* Version: @(#)net_pcap.c 1.0.13 2017/11/04
* Version: @(#)net_pcap.c 1.0.14 2018/03/18
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
* Copyright 2017 Fred N. van Kempen.
* Copyright 2017,2018 Fred N. van Kempen.
*/
#include <stdio.h>
#include <stdint.h>
@@ -274,7 +274,7 @@ net_pcap_close(void)
* tries to attach to the network module.
*/
int
net_pcap_reset(netcard_t *card)
net_pcap_reset(netcard_t *card, uint8_t *mac)
{
char errbuf[PCAP_ERRBUF_SIZE];
char filter_exp[255];
@@ -293,14 +293,11 @@ net_pcap_reset(netcard_t *card)
/* Create a MAC address based packet filter. */
pclog("PCAP: installing filter for MAC=%02x:%02x:%02x:%02x:%02x:%02x\n",
card->mac[0], card->mac[1], card->mac[2],
card->mac[3], card->mac[4], card->mac[5]);
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
sprintf(filter_exp,
"( ((ether dst ff:ff:ff:ff:ff:ff) or (ether dst %02x:%02x:%02x:%02x:%02x:%02x)) and not (ether src %02x:%02x:%02x:%02x:%02x:%02x) )",
card->mac[0], card->mac[1], card->mac[2],
card->mac[3], card->mac[4], card->mac[5],
card->mac[0], card->mac[1], card->mac[2],
card->mac[3], card->mac[4], card->mac[5]);
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5],
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
if (f_pcap_compile((pcap_t *)pcap, &fp, filter_exp, 0, 0xffffffff) != -1) {
if (f_pcap_setfilter((pcap_t *)pcap, &fp) != 0) {
pclog("PCAP: error installing filter (%s) !\n", filter_exp);
@@ -318,7 +315,7 @@ net_pcap_reset(netcard_t *card)
pclog("PCAP: starting thread..\n");
poll_state = thread_create_event();
poll_tid = thread_create(poll_thread, card->mac);
poll_tid = thread_create(poll_thread, mac);
thread_wait_event(poll_state, -1);
return(0);

View File

@@ -8,11 +8,11 @@
*
* Handle SLiRP library processing.
*
* Version: @(#)net_slirp.c 1.0.13 2017/11/04
* Version: @(#)net_slirp.c 1.0.14 2018/03/18
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
* Copyright 2017 Fred N. van Kempen.
* Copyright 2017,2018 Fred N. van Kempen.
*/
#include <stdio.h>
#include <stdint.h>
@@ -143,14 +143,14 @@ net_slirp_init(void)
/* Initialize SLiRP for use. */
int
net_slirp_reset(netcard_t *card)
net_slirp_reset(netcard_t *card, uint8_t *mac)
{
/* Save the callback info. */
poll_card = card;
pclog("SLiRP: creating thread..\n");
poll_state = thread_create_event();
poll_tid = thread_create(poll_thread, card->mac);
poll_tid = thread_create(poll_thread, mac);
thread_wait_event(poll_state, -1);
return(0);

View File

@@ -12,7 +12,7 @@
* it should be malloc'ed and then linked to the NETCARD def.
* Will be done later.
*
* Version: @(#)network.c 1.0.21 2018/02/18
* Version: @(#)network.c 1.0.22 2018/03/18
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
@@ -51,12 +51,13 @@ static netcard_t net_cards[] = {
int network_type;
int network_ndev;
int network_card;
netdev_t network_devs[32];
char network_pcap[512];
netdev_t network_devs[32];
#ifdef ENABLE_NIC_LOG
int nic_do_log = ENABLE_NIC_LOG;
#endif
static mutex_t *network_mutex;
static uint8_t *network_mac;
static struct {
@@ -98,7 +99,7 @@ network_busy(uint8_t set)
thread_set_event(poll_data.wake_poll_thread);
}
void
network_end(void)
{
@@ -149,7 +150,7 @@ network_attach(void *dev, uint8_t *mac, NETRXCB rx)
/* Save the card's info. */
net_cards[network_card].priv = dev;
net_cards[network_card].rx = rx;
net_cards[network_card].mac = mac;
network_mac = mac;
/* Create the network events. */
poll_data.wake_poll_thread = thread_create_event();
@@ -158,11 +159,11 @@ network_attach(void *dev, uint8_t *mac, NETRXCB rx)
/* Activate the platform module. */
switch(network_type) {
case NET_TYPE_PCAP:
(void)net_pcap_reset(&net_cards[network_card]);
(void)net_pcap_reset(&net_cards[network_card], network_mac);
break;
case NET_TYPE_SLIRP:
(void)net_slirp_reset(&net_cards[network_card]);
(void)net_slirp_reset(&net_cards[network_card], network_mac);
break;
}
}
@@ -194,6 +195,7 @@ network_close(void)
/* Close the network thread mutex. */
thread_close_mutex(network_mutex);
network_mutex = NULL;
network_mac = NULL;
pclog("NETWORK: closed.\n");
}

View File

@@ -8,7 +8,7 @@
*
* Definitions for the network module.
*
* Version: @(#)network.h 1.0.12 2018/02/18
* Version: @(#)network.h 1.0.13 2018/03/18
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*/
@@ -79,12 +79,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 *);
extern int net_pcap_reset(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 *);
extern int net_slirp_reset(netcard_t *, uint8_t *);
extern void net_slirp_close(void);
extern void net_slirp_in(uint8_t *, int);