From 3b54f1f8de9177885f286f0de2bd85adaeed83f2 Mon Sep 17 00:00:00 2001 From: cebix <> Date: Thu, 29 Mar 2001 14:20:55 +0000 Subject: [PATCH] - FreeBSD configure script cleanups [Michael Alyn Miller] - ether_linux.cpp moved and renamed to ether_unix.cpp, now also works with the tap driver under FreeBSD [Michael Alyn Miller] - fpu_x86_asm.h: fixed problem in with newer GCC pre-processors --- BasiliskII/ChangeLog | 3 ++ BasiliskII/README | 5 +++ BasiliskII/src/Unix/configure.in | 35 +++++-------------- .../{Linux/ether_linux.cpp => ether_unix.cpp} | 21 +++++++++-- BasiliskII/src/uae_cpu/fpu/fpu_x86_asm.h | 4 +-- 5 files changed, 37 insertions(+), 31 deletions(-) rename BasiliskII/src/Unix/{Linux/ether_linux.cpp => ether_unix.cpp} (96%) diff --git a/BasiliskII/ChangeLog b/BasiliskII/ChangeLog index 8f619123..311257e0 100644 --- a/BasiliskII/ChangeLog +++ b/BasiliskII/ChangeLog @@ -4,6 +4,9 @@ V0.9 - - Unix: -Ofast option is supplied to MIPSPro compiler [Brian J. Johnson] - Unix: workaround for IRIX pthreads bug in Delay_usec() [Brian J. Johnson] + - Unix: FreeBSD configure script cleanups [Michael Alyn Miller] + - Unix: ether_linux.cpp moved and renamed to ether_unix.cpp, now + also works with the tap driver under FreeBSD [Michael Alyn Miller] V0.9 (snapshot) - 17.Feb.2001 - adapted for mon V3.0 which is now the required minimum diff --git a/BasiliskII/README b/BasiliskII/README index 5f490ce5..e270a8bd 100644 --- a/BasiliskII/README +++ b/BasiliskII/README @@ -382,6 +382,11 @@ ether your network administrator about the nets and zones you can use (instead of the ones given in the example above). + FreeBSD: + The "ethertap" method described above also works under FreeBSD, but since + no-one has found the time to write a section for this manual, you're on + your own here... + AmigaOS: You have to specify the name of the SANA-II Ethernet device and the device unit as "/" (e.g. "ariadne.device/0"). If the given diff --git a/BasiliskII/src/Unix/configure.in b/BasiliskII/src/Unix/configure.in index 55264bb6..5559ce1b 100644 --- a/BasiliskII/src/Unix/configure.in +++ b/BasiliskII/src/Unix/configure.in @@ -222,50 +222,33 @@ EXTRASYSSRCS= CAN_NATIVE_M68K=no case "$target_os" in linux*) - ETHERSRC=Linux/ether_linux.cpp - SCSISRC=Linux/scsi_linux.cpp + ETHERSRC=ether_unix.cpp AUDIOSRC=audio_oss_esd.cpp + SCSISRC=Linux/scsi_linux.cpp ;; -freebsd*3.*) +freebsd*) + ETHERSRC=ether_unix.cpp AUDIOSRC=audio_oss_esd.cpp DEFINES="$DEFINES -DBSD_COMP" + CXXFLAGS="$CXXFLAGS -fpermissive" dnl Check for the CAM library AC_CHECK_LIB(cam, cam_open_btl, HAVE_LIBCAM=yes, HAVE_LIBCAM=no) if [[ "x$HAVE_LIBCAM" = "xno" ]]; then AC_MSG_WARN([Cannot find libcam for SCSI management, disabling SCSI support.]) else dnl Check for the sys kernel includes - AC_CHECK_HEADER(/sys/cam/cam.h) - if [[ "x$ac_cv_header__sys_cam_cam_h" = "xno" ]]; then + AC_CHECK_HEADER(camlib.h) + if [[ "x$ac_cv_header_camlib_h" = "xno" ]]; then dnl In this case I should fix this thing including a "patch" dnl to access directly to the functions in the kernel :) --Orlando - AC_MSG_WARN([Cannot find kernel includes for CAM library, disabling SCSI support.]) + AC_MSG_WARN([Cannot find includes for CAM library, disabling SCSI support.]) else SCSISRC=FreeBSD/scsi_freebsd.cpp - CXXFLAGS="$CXXFLAGS -I/sys" - CFLAGS="$CFLAGS -I/sys" LIBS="$LIBS -lcam" DEFINES="$DEFINES -DCAM" fi fi ;; -freebsd*) - DEFINES="$DEFINES -DBSD_COMP" - dnl Check for the SCSI library - AC_CHECK_LIB(scsi, scsi_open, HAVE_LIBSCSI=yes, HAVE_LIBSCSI=no) - if [[ "x$HAVE_LIBSCSI" = "xno" ]]; then - AC_MSG_WARN([Cannot find libscsi for SCSI management, disabling SCSI support.]) - else - dnl Check for the sys kernel includes - AC_CHECK_HEADER(scsi.h sys/scsiio.h) - if [[ "x$ac_cv_header_scsi_h" = "xno" ]]; then - AC_MSG_WARN([Cannot find includes for the SCSI library, disabling SCSI support.]) - else - SCSISRC=FreeBSD/scsi_freebsd.cpp - LIBS="$LIBS -lscsi" - fi - fi - ;; netbsd*) CAN_NATIVE_M68K=yes ;; @@ -585,7 +568,7 @@ dnl Select appropriate CPU source and REGPARAM define. ASM_OPTIMIZATIONS=none CPUSRCS="cpuemu1.cpp cpuemu2.cpp cpuemu3.cpp cpuemu4.cpp cpuemu5.cpp cpuemu6.cpp cpuemu7.cpp cpuemu8.cpp" FPUSRCS="../uae_cpu/fpp.cpp" -if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" ]]; then +if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" -a "x$OS_TYPE" != "xfreebsd" ]]; then dnl i386 CPU DEFINES="$DEFINES -DREGPARAM=\"__attribute__((regparm(3)))\"" if [[ "x$HAVE_GAS" = "xyes" ]]; then diff --git a/BasiliskII/src/Unix/Linux/ether_linux.cpp b/BasiliskII/src/Unix/ether_unix.cpp similarity index 96% rename from BasiliskII/src/Unix/Linux/ether_linux.cpp rename to BasiliskII/src/Unix/ether_unix.cpp index a9472831..aa9ba80f 100644 --- a/BasiliskII/src/Unix/Linux/ether_linux.cpp +++ b/BasiliskII/src/Unix/ether_unix.cpp @@ -1,5 +1,5 @@ /* - * ether_unix.cpp - Ethernet device driver, Unix specific stuff + * ether_unix.cpp - Ethernet device driver, Unix specific stuff (Linux and FreeBSD) * * Basilisk II (C) 1997-2001 Christian Bauer * @@ -27,6 +27,11 @@ #include #include +#if defined(__FreeBSD__) +#include +#include +#endif + #include "cpu_emulation.h" #include "main.h" #include "macos_util.h" @@ -131,12 +136,14 @@ void EtherInit(void) goto open_error; } +#if defined(__linux__) // Attach sheep_net to selected Ethernet card if (!is_ethertap && ioctl(fd, SIOCSIFLINK, name) < 0) { sprintf(str, GetString(STR_SHEEP_NET_ATTACH_WARN), strerror(errno)); WarningAlert(str); goto open_error; } +#endif // Set nonblocking I/O ioctl(fd, FIONBIO, &nonblock); @@ -320,11 +327,13 @@ int16 ether_write(uint32 wds) // Copy packet to buffer uint8 packet[1516], *p = packet; int len = 0; +#if defined(__linux__) if (is_ethertap) { - *p++ = 0; // Ethertap discards the first 2 bytes + *p++ = 0; // Linux ethertap discards the first 2 bytes *p++ = 0; len += 2; } +#endif for (;;) { int w = ReadMacInt16(wds); if (w == 0) @@ -391,7 +400,11 @@ void EtherInterrupt(void) for (;;) { // Read packet from sheep_net device +#if defined(__linux__) ssize_t length = read(fd, packet, is_ethertap ? 1516 : 1514); +#else + ssize_t length = read(fd, packet, 1514); +#endif if (length < 14) break; @@ -405,10 +418,12 @@ void EtherInterrupt(void) // Pointer to packet data (Ethernet header) uint8 *p = packet; +#if defined(__linux__) if (is_ethertap) { - p += 2; // Ethertap has two random bytes before the packet + p += 2; // Linux ethertap has two random bytes before the packet length -= 2; } +#endif // Get packet type uint16 type = ntohs(*(uint16 *)(p + 12)); diff --git a/BasiliskII/src/uae_cpu/fpu/fpu_x86_asm.h b/BasiliskII/src/uae_cpu/fpu/fpu_x86_asm.h index 8ad18b3c..5a15b3ac 100644 --- a/BasiliskII/src/uae_cpu/fpu/fpu_x86_asm.h +++ b/BasiliskII/src/uae_cpu/fpu/fpu_x86_asm.h @@ -2,7 +2,7 @@ static void fpu_emit_macro_definitions() { # define DEFINE_MACRO(name, value) \ - __asm__ __volatile__ (#name ## " = " #value) + __asm__ __volatile__ (#name " = " #value) DEFINE_MACRO(BSUN, 0x00008000); DEFINE_MACRO(SNAN, 0x00004000); DEFINE_MACRO(OPERR, 0x00002000); @@ -96,7 +96,7 @@ cat > $ofile << EOF static void fpu_emit_macro_definitions() { # define DEFINE_MACRO(name, value) \\ - __asm__ __volatile__ (#name ## " = " #value) + __asm__ __volatile__ (#name " = " #value) EOF # processing with awk