mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-12-26 08:32:20 +00:00
slirp now works on windows
This commit is contained in:
parent
08b783d52b
commit
08a6e383e8
@ -21,16 +21,26 @@ WANT_GTK = @WANT_GTK@
|
|||||||
GTK_CFLAGS = @GTK_CFLAGS@
|
GTK_CFLAGS = @GTK_CFLAGS@
|
||||||
GTK_LIBS = @GTK_LIBS@
|
GTK_LIBS = @GTK_LIBS@
|
||||||
|
|
||||||
|
SLIRP_CFLAGS = @SLIRP_CFLAGS@
|
||||||
|
SLIRP_SRCS = \
|
||||||
|
../slirp/bootp.c ../slirp/ip_output.c ../slirp/tcp_input.c \
|
||||||
|
../slirp/cksum.c ../slirp/mbuf.c ../slirp/tcp_output.c \
|
||||||
|
../slirp/debug.c ../slirp/misc.c ../slirp/tcp_subr.c \
|
||||||
|
../slirp/if.c ../slirp/sbuf.c ../slirp/tcp_timer.c \
|
||||||
|
../slirp/ip_icmp.c ../slirp/slirp.c ../slirp/tftp.c \
|
||||||
|
../slirp/ip_input.c ../slirp/socket.c ../slirp/udp.c
|
||||||
|
SLIRP_OBJS = $(SLIRP_SRCS:../slirp/%.c=$(OBJ_DIR)/slirp-%.o)
|
||||||
|
|
||||||
LN_S = @LN_S@
|
LN_S = @LN_S@
|
||||||
WINDRES = @WINDRES@
|
WINDRES = @WINDRES@
|
||||||
CC = @CC@
|
CC = @CC@
|
||||||
CXX = @CXX@
|
CXX = @CXX@
|
||||||
CFLAGS = @CFLAGS@ $(SDL_CFLAGS)
|
CFLAGS = @CFLAGS@ $(SDL_CFLAGS)
|
||||||
CXXFLAGS = @CXXFLAGS@ $(SDL_CFLAGS)
|
CXXFLAGS = @CXXFLAGS@ $(SDL_CFLAGS)
|
||||||
CPPFLAGS = @CPPFLAGS@ -I../include -I. @CPUINCLUDES@
|
CPPFLAGS = @CPPFLAGS@ -I../include -I. @CPUINCLUDES@ -I../slirp
|
||||||
DEFS = @DEFS@ @DEFINES@
|
DEFS = @DEFS@ @DEFINES@
|
||||||
LDFLAGS = @LDFLAGS@
|
LDFLAGS = @LDFLAGS@
|
||||||
LIBS = @LIBS@
|
LIBS = @LIBS@ -lwsock32 -liphlpapi
|
||||||
CPUSRCS = @CPUSRCS@
|
CPUSRCS = @CPUSRCS@
|
||||||
|
|
||||||
HOST_CC = gcc
|
HOST_CC = gcc
|
||||||
@ -58,7 +68,7 @@ SRCS = ../main.cpp main_windows.cpp ../prefs.cpp ../prefs_items.cpp prefs_window
|
|||||||
../extfs.cpp extfs_windows.cpp ../user_strings.cpp user_strings_windows.cpp \
|
../extfs.cpp extfs_windows.cpp ../user_strings.cpp user_strings_windows.cpp \
|
||||||
vm_alloc.cpp sigsegv.cpp posix_emu.cpp util_windows.cpp kernel_windows.cpp \
|
vm_alloc.cpp sigsegv.cpp posix_emu.cpp util_windows.cpp kernel_windows.cpp \
|
||||||
../dummy/prefs_editor_dummy.cpp BasiliskII.rc \
|
../dummy/prefs_editor_dummy.cpp BasiliskII.rc \
|
||||||
$(CDENABLESRCS) $(ROUTERSRCS) $(CPUSRCS)
|
$(CDENABLESRCS) $(ROUTERSRCS) $(CPUSRCS) $(SLIRP_OBJS)
|
||||||
|
|
||||||
UI_SRCS = ../prefs.cpp prefs_windows.cpp prefs_editor_gtk.cpp xpram_windows.cpp \
|
UI_SRCS = ../prefs.cpp prefs_windows.cpp prefs_editor_gtk.cpp xpram_windows.cpp \
|
||||||
../prefs_items.cpp ../user_strings.cpp user_strings_windows.cpp util_windows.cpp \
|
../prefs_items.cpp ../user_strings.cpp user_strings_windows.cpp util_windows.cpp \
|
||||||
@ -130,6 +140,8 @@ $(OBJ_DIR)/%.ho : %.c
|
|||||||
$(HOST_CC) $(CPPFLAGS) $(DEFS) $(HOST_CFLAGS) -c $< -o $@
|
$(HOST_CC) $(CPPFLAGS) $(DEFS) $(HOST_CFLAGS) -c $< -o $@
|
||||||
$(OBJ_DIR)/%.ho : %.cpp
|
$(OBJ_DIR)/%.ho : %.cpp
|
||||||
$(HOST_CXX) $(CPPFLAGS) $(DEFS) $(HOST_CXXFLAGS) -c $< -o $@
|
$(HOST_CXX) $(CPPFLAGS) $(DEFS) $(HOST_CXXFLAGS) -c $< -o $@
|
||||||
|
$(OBJ_DIR)/slirp-%.o : ../slirp/%.c
|
||||||
|
$(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) $(SLIRP_CFLAGS) -c $< -o $@
|
||||||
$(OBJ_DIR)/%.o : %.c
|
$(OBJ_DIR)/%.o : %.c
|
||||||
$(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) -c $< -o $@
|
$(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) -c $< -o $@
|
||||||
$(OBJ_DIR)/%.o : %.cpp
|
$(OBJ_DIR)/%.o : %.cpp
|
||||||
|
@ -105,6 +105,9 @@ AC_CHECK_TYPES(loff_t)
|
|||||||
AC_CHECK_TYPES(caddr_t)
|
AC_CHECK_TYPES(caddr_t)
|
||||||
AC_TYPE_SIZE_T
|
AC_TYPE_SIZE_T
|
||||||
|
|
||||||
|
dnl Checks for library functions.
|
||||||
|
AC_CHECK_FUNCS(strdup strerror)
|
||||||
|
|
||||||
dnl Define a macro that translates a yesno-variable into a C macro definition
|
dnl Define a macro that translates a yesno-variable into a C macro definition
|
||||||
dnl to be put into the config.h file
|
dnl to be put into the config.h file
|
||||||
dnl $1 -- the macro to define
|
dnl $1 -- the macro to define
|
||||||
@ -259,6 +262,19 @@ AC_EGREP_CPP(xyes,
|
|||||||
#endif
|
#endif
|
||||||
], [AC_MSG_RESULT(yes); HAVE_GCC30=yes], AC_MSG_RESULT(no))
|
], [AC_MSG_RESULT(yes); HAVE_GCC30=yes], AC_MSG_RESULT(no))
|
||||||
|
|
||||||
|
dnl Add -fno-strict-aliasing for slirp sources
|
||||||
|
if [[ "x$HAVE_GCC30" = "xyes" ]]; then
|
||||||
|
SAVED_CFLAGS="$CFLAGS"
|
||||||
|
CFLAGS="$CFLAGS -fno-strict-aliasing"
|
||||||
|
AC_CACHE_CHECK([whether the compiler supports -fno-strict-aliasing],
|
||||||
|
ac_cv_gcc_no_strict_aliasing, [
|
||||||
|
AC_TRY_COMPILE([],[],
|
||||||
|
[ac_cv_gcc_no_strict_aliasing=yes; AC_SUBST(SLIRP_CFLAGS, "-fno-strict-aliasing")],
|
||||||
|
[ac_cv_gcc_no_strict_aliasing=no])
|
||||||
|
])
|
||||||
|
CFLAGS="$SAVED_CFLAGS"
|
||||||
|
fi
|
||||||
|
|
||||||
dnl Select appropriate CPU source and REGPARAM define.
|
dnl Select appropriate CPU source and REGPARAM define.
|
||||||
ASM_OPTIMIZATIONS=none
|
ASM_OPTIMIZATIONS=none
|
||||||
CPUSRCS="cpuemu1.cpp cpuemu2.cpp cpuemu3.cpp cpuemu4.cpp cpuemu5.cpp cpuemu6.cpp cpuemu7.cpp cpuemu8.cpp"
|
CPUSRCS="cpuemu1.cpp cpuemu2.cpp cpuemu3.cpp cpuemu4.cpp cpuemu5.cpp cpuemu6.cpp cpuemu7.cpp cpuemu8.cpp"
|
||||||
|
@ -37,6 +37,10 @@
|
|||||||
#include "ether_windows.h"
|
#include "ether_windows.h"
|
||||||
#include "router/router.h"
|
#include "router/router.h"
|
||||||
#include "kernel_windows.h"
|
#include "kernel_windows.h"
|
||||||
|
#include "libslirp.h"
|
||||||
|
|
||||||
|
// Define to let the slirp library determine the right timeout for select()
|
||||||
|
#define USE_SLIRP_TIMEOUT 1
|
||||||
|
|
||||||
|
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
@ -53,6 +57,7 @@
|
|||||||
enum {
|
enum {
|
||||||
NET_IF_B2ETHER,
|
NET_IF_B2ETHER,
|
||||||
NET_IF_ROUTER,
|
NET_IF_ROUTER,
|
||||||
|
NET_IF_SLIRP,
|
||||||
NET_IF_FAKE,
|
NET_IF_FAKE,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -138,6 +143,7 @@ static HANDLE int_sig2 = 0;
|
|||||||
static HANDLE int_send_now = 0;
|
static HANDLE int_send_now = 0;
|
||||||
|
|
||||||
// Prototypes
|
// Prototypes
|
||||||
|
static WINAPI unsigned int slirp_receive_func(void *arg);
|
||||||
static WINAPI unsigned int ether_thread_feed_int(void *arg);
|
static WINAPI unsigned int ether_thread_feed_int(void *arg);
|
||||||
static WINAPI unsigned int ether_thread_get_packets_nt(void *arg);
|
static WINAPI unsigned int ether_thread_get_packets_nt(void *arg);
|
||||||
static WINAPI unsigned int ether_thread_write_packets(void *arg);
|
static WINAPI unsigned int ether_thread_write_packets(void *arg);
|
||||||
@ -194,6 +200,8 @@ bool ether_init(void)
|
|||||||
net_if_type = -1;
|
net_if_type = -1;
|
||||||
if (strcmp(name, "router") == 0)
|
if (strcmp(name, "router") == 0)
|
||||||
net_if_type = NET_IF_ROUTER;
|
net_if_type = NET_IF_ROUTER;
|
||||||
|
else if (strcmp(name, "slirp") == 0)
|
||||||
|
net_if_type = NET_IF_SLIRP;
|
||||||
else
|
else
|
||||||
net_if_type = NET_IF_B2ETHER;
|
net_if_type = NET_IF_B2ETHER;
|
||||||
|
|
||||||
@ -203,6 +211,15 @@ bool ether_init(void)
|
|||||||
net_if_type = NET_IF_FAKE;
|
net_if_type = NET_IF_FAKE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize slirp library
|
||||||
|
if (net_if_type == NET_IF_SLIRP) {
|
||||||
|
if (slirp_init() < 0) {
|
||||||
|
sprintf(str, GetString(STR_SLIRP_NO_DNS_FOUND_WARN));
|
||||||
|
WarningAlert(str);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Open ethernet device
|
// Open ethernet device
|
||||||
const char *dev_name;
|
const char *dev_name;
|
||||||
switch (net_if_type) {
|
switch (net_if_type) {
|
||||||
@ -244,6 +261,15 @@ bool ether_init(void)
|
|||||||
D(bug("Fake ethernet address %02x %02x %02x %02x %02x %02x\n", ether_addr[0], ether_addr[1], ether_addr[2], ether_addr[3], ether_addr[4], ether_addr[5]));
|
D(bug("Fake ethernet address %02x %02x %02x %02x %02x %02x\n", ether_addr[0], ether_addr[1], ether_addr[2], ether_addr[3], ether_addr[4], ether_addr[5]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (net_if_type == NET_IF_SLIRP) {
|
||||||
|
ether_addr[0] = 0x52;
|
||||||
|
ether_addr[1] = 0x54;
|
||||||
|
ether_addr[2] = 0x00;
|
||||||
|
ether_addr[3] = 0x12;
|
||||||
|
ether_addr[4] = 0x34;
|
||||||
|
ether_addr[5] = 0x56;
|
||||||
|
D(bug("Ethernet address %02x %02x %02x %02x %02x %02x\n", ether_addr[0], ether_addr[1], ether_addr[2], ether_addr[3], ether_addr[4], ether_addr[5]));
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
memcpy( ether_addr, router_mac_addr, 6 );
|
memcpy( ether_addr, router_mac_addr, 6 );
|
||||||
D(bug("Fake ethernet address (same as router) %02x %02x %02x %02x %02x %02x\n", ether_addr[0], ether_addr[1], ether_addr[2], ether_addr[3], ether_addr[4], ether_addr[5]));
|
D(bug("Fake ethernet address (same as router) %02x %02x %02x %02x %02x %02x\n", ether_addr[0], ether_addr[1], ether_addr[2], ether_addr[3], ether_addr[4], ether_addr[5]));
|
||||||
@ -311,7 +337,9 @@ bool ether_init(void)
|
|||||||
thread_active = true;
|
thread_active = true;
|
||||||
|
|
||||||
unsigned int dummy;
|
unsigned int dummy;
|
||||||
ether_th2 = (HANDLE)_beginthreadex( 0, 0, ether_thread_get_packets_nt, 0, 0, &dummy );
|
ether_th2 = (HANDLE)_beginthreadex( 0, 0,
|
||||||
|
net_if_type == NET_IF_SLIRP ? slirp_receive_func : ether_thread_get_packets_nt,
|
||||||
|
0, 0, &dummy );
|
||||||
ether_th1 = (HANDLE)_beginthreadex( 0, 0, ether_thread_write_packets, 0, 0, &dummy );
|
ether_th1 = (HANDLE)_beginthreadex( 0, 0, ether_thread_write_packets, 0, 0, &dummy );
|
||||||
|
|
||||||
// Everything OK
|
// Everything OK
|
||||||
@ -876,6 +904,11 @@ static unsigned int ether_thread_write_packets(void *arg)
|
|||||||
// already recycled if async
|
// already recycled if async
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case NET_IF_SLIRP:
|
||||||
|
slirp_input((uint8 *)Packet->Buffer, Packet->Length);
|
||||||
|
Packet->bIoComplete = TRUE;
|
||||||
|
recycle_write_packet(Packet);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -962,7 +995,7 @@ static void final_queue(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void enqueue_packet( uint8 *buf, int sz )
|
void enqueue_packet( const uint8 *buf, int sz )
|
||||||
{
|
{
|
||||||
EnterCriticalSection( &queue_csection );
|
EnterCriticalSection( &queue_csection );
|
||||||
if(queue[queue_inx].sz > 0) {
|
if(queue[queue_inx].sz > 0) {
|
||||||
@ -1026,6 +1059,61 @@ static bool set_wait_request(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SLIRP output buffer glue
|
||||||
|
*/
|
||||||
|
|
||||||
|
int slirp_can_output(void)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void slirp_output(const uint8 *packet, int len)
|
||||||
|
{
|
||||||
|
enqueue_packet(packet, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int slirp_receive_func(void *arg)
|
||||||
|
{
|
||||||
|
D(bug("slirp_receive_func\n"));
|
||||||
|
thread_active_2 = true;
|
||||||
|
|
||||||
|
while (thread_active) {
|
||||||
|
// Wait for packets to arrive
|
||||||
|
fd_set rfds, wfds, xfds;
|
||||||
|
int nfds, ret, timeout;
|
||||||
|
|
||||||
|
// ... in the output queue
|
||||||
|
nfds = -1;
|
||||||
|
FD_ZERO(&rfds);
|
||||||
|
FD_ZERO(&wfds);
|
||||||
|
FD_ZERO(&xfds);
|
||||||
|
timeout = slirp_select_fill(&nfds, &rfds, &wfds, &xfds);
|
||||||
|
#if ! USE_SLIRP_TIMEOUT
|
||||||
|
timeout = 10000;
|
||||||
|
#endif
|
||||||
|
if (nfds < 0) {
|
||||||
|
/* Windows does not honour the timeout if there is not
|
||||||
|
descriptor to wait for */
|
||||||
|
Delay_usec(timeout);
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
struct timeval tv;
|
||||||
|
tv.tv_sec = 0;
|
||||||
|
tv.tv_usec = timeout;
|
||||||
|
ret = select(0, &rfds, &wfds, &xfds, &tv);
|
||||||
|
}
|
||||||
|
if (ret >= 0)
|
||||||
|
slirp_select_poll(&rfds, &wfds, &xfds);
|
||||||
|
}
|
||||||
|
|
||||||
|
D(bug("slirp_receive_func exit\n"));
|
||||||
|
thread_active_2 = false;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Packet reception threads
|
* Packet reception threads
|
||||||
*/
|
*/
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef _ETHER_WINDOWS_H_
|
#ifndef _ETHER_WINDOWS_H_
|
||||||
#define _ETHER_WINDOWS_H_
|
#define _ETHER_WINDOWS_H_
|
||||||
|
|
||||||
void enqueue_packet( uint8 *buf, int sz );
|
void enqueue_packet( const uint8 *buf, int sz );
|
||||||
|
|
||||||
#ifdef SHEEPSHAVER
|
#ifdef SHEEPSHAVER
|
||||||
extern uint8 ether_addr[6];
|
extern uint8 ether_addr[6];
|
||||||
|
@ -36,6 +36,7 @@ user_string_def platform_strings[] = {
|
|||||||
{STR_VOSF_INIT_ERR, "Cannot initialize Video on SEGV signals."},
|
{STR_VOSF_INIT_ERR, "Cannot initialize Video on SEGV signals."},
|
||||||
{STR_SIG_INSTALL_ERR, "Cannot install %s handler (%s)."},
|
{STR_SIG_INSTALL_ERR, "Cannot install %s handler (%s)."},
|
||||||
{STR_TICK_THREAD_ERR, "Cannot create 60Hz thread (%s)."},
|
{STR_TICK_THREAD_ERR, "Cannot create 60Hz thread (%s)."},
|
||||||
|
{STR_SLIRP_NO_DNS_FOUND_WARN, "Cannot get DNS address. Ethernet will not be available."},
|
||||||
{STR_NO_AUDIO_WARN, "No audio device found, audio output will be disabled."},
|
{STR_NO_AUDIO_WARN, "No audio device found, audio output will be disabled."},
|
||||||
{STR_KEYCODE_FILE_WARN, "Cannot open keycode translation file %s (%s)."},
|
{STR_KEYCODE_FILE_WARN, "Cannot open keycode translation file %s (%s)."},
|
||||||
{STR_KEYCODE_VENDOR_WARN, "Cannot find vendor '%s' in keycode translation file %s."},
|
{STR_KEYCODE_VENDOR_WARN, "Cannot find vendor '%s' in keycode translation file %s."},
|
||||||
|
@ -26,6 +26,7 @@ enum {
|
|||||||
STR_VOSF_INIT_ERR,
|
STR_VOSF_INIT_ERR,
|
||||||
STR_SIG_INSTALL_ERR,
|
STR_SIG_INSTALL_ERR,
|
||||||
STR_TICK_THREAD_ERR,
|
STR_TICK_THREAD_ERR,
|
||||||
|
STR_SLIRP_NO_DNS_FOUND_WARN,
|
||||||
STR_NO_AUDIO_WARN,
|
STR_NO_AUDIO_WARN,
|
||||||
STR_KEYCODE_FILE_WARN,
|
STR_KEYCODE_FILE_WARN,
|
||||||
STR_KEYCODE_VENDOR_WARN,
|
STR_KEYCODE_VENDOR_WARN,
|
||||||
|
Loading…
Reference in New Issue
Block a user