From owner-freebsd-emulation@FreeBSD.ORG Wed Sep 9 19:24:18 2009 Return-Path: Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 85FF010656A8 for ; Wed, 9 Sep 2009 19:24:18 +0000 (UTC) (envelope-from fli@shapeshifter.se) Received: from mx1.h3q.net (mx1.h3q.net [IPv6:2001:16d8:ffe5:1::f1]) by mx1.freebsd.org (Postfix) with ESMTP id 046CE8FC23 for ; Wed, 9 Sep 2009 19:24:18 +0000 (UTC) Received: from smtp-auth.h3q.net (smtp-auth.h3q.net [127.0.0.1]) (Authenticated sender: hidden) by mx1.h3q.net (Postfix) with ESMTPSA id E334933D7E ; Wed, 9 Sep 2009 21:24:15 +0200 (CEST) Message-ID: <4AA800DF.2090904@shapeshifter.se> Date: Wed, 09 Sep 2009 21:24:15 +0200 From: Fredrik Lindberg User-Agent: Thunderbird 2.0.0.22 (X11/20090801) MIME-Version: 1.0 To: vbox-dev@virtualbox.org, freebsd-emulation@freebsd.org Content-Type: multipart/mixed; boundary="------------090606070406050409060306" Cc: Subject: Enable DrvHostSerial on FreeBSD X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2009 19:24:18 -0000 This is a multi-part message in MIME format. --------------090606070406050409060306 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit The existing code for the host serial device (DrvHostSerial.cpp) works on FreeBSD, it's just disabled by ifdefs. Attached is a patch to enable it, MIT license or whatever you want. Compile-tested on FreeBSD 7 and 8, runtime tested on FreeBSD 8. I've tested it with a cross-over serial cable (null modem) connected between two (physical) machines. Used cu and minicom inside guest to connect to another cu/minicom-instance running on the second machine. My testing has been limited to this as I really don't have any other fancy serial equipment :) Notes to people trying this with the ports version, the patch does not apply cleanly and you'll have to modify src/VBox/Devices/Makefile.kmk by hand. Fredrik --------------090606070406050409060306 Content-Type: text/plain; name="vbox-drvhostserial-freebsd-20090909.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="vbox-drvhostserial-freebsd-20090909.patch" Index: src/VBox/Devices/Builtins.cpp =================================================================== --- src/VBox/Devices/Builtins.cpp (revision 22813) +++ src/VBox/Devices/Builtins.cpp (working copy) @@ -269,7 +269,7 @@ return rc; #endif -#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) || defined(RT_OS_WINDOWS) +#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) || defined(RT_OS_WINDOWS) || defined(RT_OS_FREEBSD) rc = pCallbacks->pfnRegister(pCallbacks, &g_DrvHostSerial); if (RT_FAILURE(rc)) return rc; Index: src/VBox/Devices/Serial/DrvHostSerial.cpp =================================================================== --- src/VBox/Devices/Serial/DrvHostSerial.cpp (revision 22864) +++ src/VBox/Devices/Serial/DrvHostSerial.cpp (working copy) @@ -37,7 +37,7 @@ #include #include -#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) +#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) # include # ifdef RT_OS_SOLARIS # include @@ -113,7 +113,7 @@ /** the device path */ char *pszDevicePath; -#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) +#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) /** the device handle */ RTFILE DeviceFile; # ifdef RT_OS_DARWIN @@ -244,7 +244,7 @@ static DECLCALLBACK(int) drvHostSerialSetParameters(PPDMICHAR pInterface, unsigned Bps, char chParity, unsigned cDataBits, unsigned cStopBits) { PDRVHOSTSERIAL pThis = PDMICHAR_2_DRVHOSTSERIAL(pInterface); -#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) +#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) struct termios *termiosSetup; int baud_rate; #elif defined(RT_OS_WINDOWS) @@ -253,7 +253,7 @@ LogFlow(("%s: Bps=%u chParity=%c cDataBits=%u cStopBits=%u\n", __FUNCTION__, Bps, chParity, cDataBits, cStopBits)); -#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) +#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) termiosSetup = (struct termios *)RTMemTmpAllocZ(sizeof(struct termios)); /* Enable receiver */ @@ -517,7 +517,7 @@ #ifdef DEBUG uint64_t volatile u64Now = RTTimeNanoTS(); NOREF(u64Now); #endif -#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) +#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) size_t cbWritten; rc = RTFileWrite(pThis->DeviceFile, abBuf, cb, &cbWritten); @@ -598,7 +598,7 @@ uint8_t abBuf[1]; abBuf[0] = pThis->aSendQueue[iTail]; -#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) +#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) rc = RTFileWrite(pThis->DeviceFile, abBuf, cbProcessed, NULL); @@ -763,7 +763,7 @@ } cbRemaining = cbRead; -#elif defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) +#elif defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) size_t cbRead; struct pollfd aFDs[2]; @@ -923,7 +923,7 @@ static DECLCALLBACK(int) drvHostSerialWakeupRecvThread(PPDMDRVINS pDrvIns, PPDMTHREAD pThread) { PDRVHOSTSERIAL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTSERIAL); -#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) +#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) return RTFileWrite(pThis->WakeupPipeW, "", 1, NULL); #elif defined(RT_OS_WINDOWS) if (!SetEvent(pThis->hHaltEventSem)) @@ -934,7 +934,7 @@ #endif } -#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) +#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) /* -=-=-=-=- Monitor thread -=-=-=-=- */ /** @@ -1139,7 +1139,7 @@ { PDRVHOSTSERIAL pThis = PDMICHAR_2_DRVHOSTSERIAL(pInterface); -#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) +#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) int modemStateSet = 0; int modemStateClear = 0; @@ -1188,7 +1188,7 @@ /* * Init basic data members and interfaces. */ -#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) +#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) pThis->DeviceFile = NIL_RTFILE; # ifdef RT_OS_DARWIN pThis->DeviceFileR = NIL_RTFILE; @@ -1269,7 +1269,7 @@ { case VERR_ACCESS_DENIED: return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, -#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) +#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) N_("Cannot open host device '%s' for read/write access. Check the permissions " "of that device ('/bin/ls -l %s'): Most probably you need to be member " "of the device group. Make sure that you logout/login after changing " @@ -1287,7 +1287,7 @@ } /* Set to non blocking I/O */ -#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) +#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) fcntl(pThis->DeviceFile, F_SETFL, O_NONBLOCK); # ifdef RT_OS_DARWIN @@ -1339,7 +1339,7 @@ if (RT_FAILURE(rc)) return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("HostSerial#%d cannot create send thread"), pDrvIns->iInstance); -#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) +#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) /* Linux & darwin needs a separate thread which monitors the status lines. */ # ifndef RT_OS_LINUX ioctl(pThis->DeviceFile, TIOCMGET, &pThis->fStatusLines); @@ -1382,7 +1382,7 @@ RTSemEventDestroy(pThis->SendSem); pThis->SendSem = NIL_RTSEMEVENT; -#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) +#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) if (pThis->WakeupPipeW != NIL_RTFILE) { Index: src/VBox/Devices/Makefile.kmk =================================================================== --- src/VBox/Devices/Makefile.kmk (revision 22813) +++ src/VBox/Devices/Makefile.kmk (working copy) @@ -803,7 +803,8 @@ , $(Drivers_SOURCES)) \ Audio/ossaudio.c Drivers_SOURCES.freebsd = \ - Network/DrvTAP.cpp + Network/DrvTAP.cpp \ + Serial/DrvHostSerial.cpp endif # freebsd --------------090606070406050409060306--