Merge remote-tracking branch 'seghaxx/master'

# Conflicts:
#	BasiliskII/src/MacOSX/extfs_macosx.cpp
#	BasiliskII/src/SDL/video_sdl2.cpp
#	BasiliskII/src/Unix/configure.ac
This commit is contained in:
kanjitalk755 2021-03-03 12:13:12 +09:00
commit 6d3fbba4cd
5 changed files with 150 additions and 29 deletions

View File

@ -785,10 +785,10 @@ static SDL_Surface * init_sdl_video(int width, int height, int bpp, Uint32 flags
SDL_SetHint(SDL_HINT_RENDER_DRIVER, render_driver);
}
else {
#ifdef __MACOSX__
SDL_SetHint(SDL_HINT_RENDER_DRIVER, window_flags & SDL_WINDOW_METAL ? "metal" : "opengl");
#elif defined(WIN32)
#ifdef WIN32
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software");
#elif defined(__MACOSX__) && SDL_VERSION_ATLEAST(2,0,14)
SDL_SetHint(SDL_HINT_RENDER_DRIVER, window_flags & SDL_WINDOW_METAL ? "metal" : "opengl");
#else
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "");
#endif

View File

@ -89,6 +89,11 @@ AC_ARG_WITH(bincue,
AC_ARG_WITH(libvhd,
AS_HELP_STRING([--with-libvhd], [Enable VHD disk images]))
AC_ARG_WITH(vdeplug,
AS_HELP_STRING([--with-vdeplug], [Enable VDE virtual network support]),
[],
[with_vdeplug=yes])
dnl Cross Compiling results in 'guesses' being made about the target system. These defaults are oftetimes incorrect.
dnl The following Environment variables allow you to configure the default guess value for each option in the configure script.
@ -585,7 +590,8 @@ dnl Check for headers and functions related to pty support (sshpty.c)
dnl From openssh-3.2.2p1 configure.ac
AC_CHECK_HEADERS(strings.h login.h sys/bsdtty.h sys/stat.h util.h pty.h)
AC_CHECK_FUNCS(_getpty vhangup strlcpy)
AC_SEARCH_LIBS([openpty], [util bsd])
AC_CHECK_FUNCS(_getpty openpty vhangup strlcpy)
case "$host" in
*-*-hpux10.26)
@ -721,6 +727,7 @@ AC_CHECK_FRAMEWORK(AppKit, [])
AC_CHECK_FRAMEWORK(Carbon, [#include <Carbon/Carbon.h>])
AC_CHECK_FRAMEWORK(IOKit, [#include <IOKit/IOKitLib.h>])
AC_CHECK_FRAMEWORK(CoreFoundation, [#include <CoreFoundation/CoreFoundation.h>])
AC_CHECK_FRAMEWORK(Metal, [])
dnl Select system-dependant source files.
SERIALSRC=serial_unix.cpp
@ -818,6 +825,13 @@ if [[ -n "$CAN_SLIRP" ]]; then
fi
AC_SUBST(SLIRP_SRCS)
dnl Is libvdeplug available?
have_vdeplug=no
AS_IF([test "x$with_vdeplug" = "xyes"], [
have_vdeplug=yes
AC_CHECK_LIB(vdeplug, vde_close, [], [have_vdeplug=no])
])
if [[ "x$WANT_MACOSX_GUI" = "xyes" ]]; then
CPPFLAGS="$CPPFLAGS -I../MacOSX"
LIBS="$LIBS -framework CoreAudio -framework AudioUnit -framework AudioToolbox"
@ -1374,7 +1388,6 @@ AC_PATH_PROG([BLESS], "true")
dnl Check for linker script support
case $target_os:$target_cpu in
linux*:i?86) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-i386.ld";;
linux*:x86_64) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-x86_64.ld";;
linux*:powerpc) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-ppc.ld";;
netbsd*:i?86) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-i386.ld";;
freebsd*:i?86) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/freebsd-i386.ld";;
@ -1640,7 +1653,7 @@ elif [[ "x$WANT_NATIVE_M68K" = "xyes" ]]; then
fi
dnl Enable JIT compiler, if possible.
if [[ "x$WANT_JIT" = "xyes" -a "x$CAN_JIT" ]]; then
if [[ "x$WANT_JIT" = "xyes" -a "x$CAN_JIT" = "xyes" ]]; then
JITSRCS="$JITSRCS ../uae_cpu/compiler/compemu_support.cpp ../uae_cpu/compiler/compemu_fpp.cpp compstbl.o cpustbl_nf.o"
DEFINES="$DEFINES -DUSE_JIT -DUSE_JIT_FPU"
@ -1888,6 +1901,7 @@ echo SDL support ............................ : $SDL_SUPPORT
echo SDL major-version ...................... : $WANT_SDL_VERSION_MAJOR
echo BINCUE support ......................... : $have_bincue
echo LIBVHD support ......................... : $have_libvhd
echo VDE support ............................ : $have_vdeplug
echo XFree86 DGA support .................... : $WANT_XF86_DGA
echo XFree86 VidMode support ................ : $WANT_XF86_VIDMODE
echo fbdev DGA support ...................... : $WANT_FBDEV_DGA

View File

@ -85,6 +85,12 @@
#include "ctl.h"
#endif
#ifdef HAVE_LIBVDEPLUG
extern "C" {
#include <libvdeplug.h>
}
#endif
#include "cpu_emulation.h"
#include "main.h"
#include "macos_util.h"
@ -110,6 +116,7 @@ enum {
NET_IF_ETHERTAP,
NET_IF_TUNTAP,
NET_IF_SLIRP,
NET_IF_VDE,
NET_IF_ETHERHELPER
};
@ -139,6 +146,9 @@ static pthread_t slirp_thread; // Slirp reception thread
static bool slirp_thread_active = false; // Flag: Slirp reception threadinstalled
static int slirp_output_fd = -1; // fd of slirp output pipe
static int slirp_input_fds[2] = { -1, -1 }; // fds of slirp input pipe
#ifdef HAVE_LIBVDEPLUG
static VDECONN *vde_conn;
#endif
#ifdef SHEEPSHAVER
static bool net_open = false; // Flag: initialization succeeded, network device open
static uint8 ether_addr[6]; // Our Ethernet address
@ -277,22 +287,36 @@ bool ether_init(void)
// Determine Ethernet device type
net_if_type = -1;
if (strncmp(name, "tap", 3) == 0)
if (strncmp(name, "tap", 3) == 0) {
net_if_type = NET_IF_ETHERTAP;
printf("selected Ethernet device type tap\n");
}
#if ENABLE_TUNTAP
else if (strcmp(name, "tun") == 0)
else if (strcmp(name, "tun") == 0) {
net_if_type = NET_IF_TUNTAP;
printf("selected Ethernet device type tun\n");
}
#endif
#ifdef HAVE_SLIRP
else if (strcmp(name, "slirp") == 0)
else if (strcmp(name, "slirp") == 0) {
net_if_type = NET_IF_SLIRP;
printf("selected Ethernet device type slirp\n");
}
#endif
#ifdef HAVE_LIBVDEPLUG
else if (strcmp(name, "vde") == 0) {
net_if_type = NET_IF_VDE;
printf("selected Ethernet device type VDE\n");
}
#endif
#ifdef ENABLE_MACOSX_ETHERHELPER
else if (strncmp(name, "etherhelper", 10) == 0)
net_if_type = NET_IF_ETHERHELPER;
#endif
else
else {
net_if_type = NET_IF_SHEEPNET;
printf("selected Ethernet device type sheep_net\n");
}
// Don't raise SIGPIPE, let errno be set to EPIPE
struct sigaction sigpipe_sa;
@ -361,7 +385,35 @@ bool ether_init(void)
#endif
}
if (net_if_type != NET_IF_SLIRP) {
#ifdef HAVE_LIBVDEPLUG
//vde switch information
int port = 0;
char *init_group = NULL;
mode_t mode = 0700;
struct vde_open_args args = {
.port = port,
.group = init_group,
.mode = mode,
};
if (net_if_type == NET_IF_VDE) {
/* calling vde open to open the vde connection to the vde switch */
vde_conn = vde_open(vde_sock, (char *)"macemu", &args);
if (!vde_conn) {
D(bug("VDE open failed\n"));
return -1;
} else {
/* for select/poll when this fd receive data, there are
* packets to recv(call vde_recv) */
fd = vde_datafd(vde_conn);
}
}
#endif
if (net_if_type != NET_IF_SLIRP && net_if_type != NET_IF_VDE) {
fd = open(dev_name, O_RDWR);
if (fd < 0) {
sprintf(str, GetString(STR_NO_SHEEP_NET_DRIVER_WARN), dev_name, strerror(errno));
@ -447,6 +499,15 @@ bool ether_init(void)
ether_addr[3] = 0x12;
ether_addr[4] = 0x34;
ether_addr[5] = 0x56;
#endif
#ifdef HAVE_LIBVDEPLUG
} else if (net_if_type == NET_IF_VDE) {
ether_addr[0] = 0x52;
ether_addr[1] = 0x54;
ether_addr[2] = 0x00;
ether_addr[3] = 0x12;
ether_addr[4] = 0x34;
ether_addr[5] = 0x56;
#endif
} else
ioctl(fd, SIOCGIFADDR, ether_addr);
@ -513,6 +574,11 @@ void ether_exit(void)
if (slirp_output_fd > 0)
close(slirp_output_fd);
#ifdef HAVE_LIBVDEPLUG
// Close vde_connection
if (net_if_type == NET_IF_VDE)
vde_close(vde_conn);
#endif
#if STATISTICS
// Show statistics
printf("%ld messages put on write queue\n", num_wput);
@ -811,6 +877,25 @@ static int16 ether_do_write(uint32 arg)
return noErr;
} else
#endif
#ifdef HAVE_LIBVDEPLUG
if (net_if_type == NET_IF_VDE) {
if (fd == -1) { // which means vde service is not running
D(bug("WARNING: Couldn't transmit VDE packet\n"));
return excessCollsns;
}
if (vde_conn == NULL) {
D(bug("WARNING: vde_conn is NULL\n"));
return -1;
}
do {
len = vde_send(vde_conn, packet, sizeof(packet), 0);
} while (len < 0);
return noErr;
} else
#endif
#ifdef ENABLE_MACOSX_ETHERHELPER
if (net_if_type == NET_IF_ETHERHELPER) {
unsigned short pkt_len;
@ -1019,13 +1104,20 @@ void ether_do_interrupt(void)
} else
#endif
{
// Read packet from sheep_net device
#if defined(__linux__)
length = read(fd, Mac2HostAddr(packet), net_if_type == NET_IF_ETHERTAP ? 1516 : 1514);
#else
length = read(fd, Mac2HostAddr(packet), 1514);
#ifdef HAVE_LIBVDEPLUG
if (net_if_type == NET_IF_VDE) {
length = vde_recv(vde_conn, Mac2HostAddr(packet), 1514, 0);
} else
#endif
{
// Read packet from sheep_net device
#if defined(__linux__)
length = read(fd, Mac2HostAddr(packet), net_if_type == NET_IF_ETHERTAP ? 1516 : 1514);
#else
length = read(fd, Mac2HostAddr(packet), 1514);
#endif
}
if (length < 14)
break;

View File

@ -211,6 +211,8 @@ static void sigill_handler(int sig, int code, struct sigcontext *scp);
extern "C" void EmulOpTrampoline(void);
#endif
// vde switch variable
char* vde_sock;
/*
* Ersatz functions
@ -378,7 +380,8 @@ static void usage(const char *prg_name)
" --display STRING\n X display to use\n"
" --break ADDRESS\n set ROM breakpoint in hexadecimal\n"
" --loadbreak FILE\n load breakpoint from FILE\n"
" --rominfo\n dump ROM information\n", prg_name
" --rominfo\n dump ROM information\n"
" --switch SWITCH_PATH\n vde_switch address\n", prg_name
);
LoadPrefs(NULL); // read the prefs file so PrefsPrintUsage() will print the correct default values
PrefsPrintUsage();
@ -443,19 +446,27 @@ int main(int argc, char **argv)
} else if (strcmp(argv[i], "--rominfo") == 0) {
argv[i] = NULL;
PrintROMInfo = true;
} else if (strcmp(argv[i], "--switch") == 0) {
argv[i] = NULL;
if (argv[++i] == NULL) {
printf("switch address not defined\n");
usage(argv[0]);
}
vde_sock = argv[i];
argv[i] = NULL;
}
#if defined(__APPLE__) && defined(__MACH__)
// Mac OS X likes to pass in various options of its own, when launching an app.
// Attempt to ignore these.
if (argv[i]) {
const char * mac_psn_prefix = "-psn_";
if (strcmp(argv[i], "-NSDocumentRevisionsDebugMode") == 0) {
argv[i] = NULL;
} else if (strncmp(mac_psn_prefix, argv[i], strlen(mac_psn_prefix)) == 0) {
argv[i] = NULL;
}
}
if (argv[i]) {
const char * mac_psn_prefix = "-psn_";
if (strcmp(argv[i], "-NSDocumentRevisionsDebugMode") == 0) {
argv[i] = NULL;
} else if (strncmp(mac_psn_prefix, argv[i], strlen(mac_psn_prefix)) == 0) {
argv[i] = NULL;
}
}
#endif
}
@ -665,9 +676,7 @@ int main(int argc, char **argv)
RAMBaseMac = Host2MacAddr(RAMBaseHost);
ROMBaseMac = Host2MacAddr(ROMBaseHost);
#endif
D(bug("Mac RAM starts at %p (%08x)\n", RAMBaseHost, RAMBaseMac));
D(bug("Mac ROM starts at %p (%08x)\n", ROMBaseHost, ROMBaseMac));
#if __MACOSX__
extern void set_current_directory();
set_current_directory();
@ -730,6 +739,9 @@ int main(int argc, char **argv)
QuitEmulator();
D(bug("Initialization complete\n"));
D(bug("Mac RAM starts at %p (%08x)\n", RAMBaseHost, RAMBaseMac));
D(bug("Mac ROM starts at %p (%08x)\n", ROMBaseHost, ROMBaseMac));
#if !EMULATED_68K
// (Virtual) supervisor mode, disable interrupts
EmulatedSR = 0x2700;

View File

@ -74,6 +74,9 @@ extern uint32 InterruptFlags; // Currently pending interrupts
extern void SetInterruptFlag(uint32 flag); // Set/clear interrupt flags
extern void ClearInterruptFlag(uint32 flag);
// vde switch variable
extern char* vde_sock;
// Array length
#if __cplusplus >= 201103L || (_MSC_VER >= 1900 && defined __cplusplus)
template <typename T, size_t size>