VBoxGuest-freebsd.c revision 4faf92053d9cec5599c0ab8577231df0f7d615b3
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync * VirtualBox Guest Additions Driver for FreeBSD.
772269936494ffaddd0750ba9e28e805ba81398cvboxsync * Copyright (C) 2007 Sun Microsystems, Inc.
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync * available from http://www.virtualbox.org. This file is free software;
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync * you can redistribute it and/or modify it under the terms of the GNU
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync * General Public License (GPL) as published by the Free Software
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync * additional information or have any questions.
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync/** @todo r=bird: This must merge with SUPDrv-freebsd.c before long. The two
69a9cf177999fa25fe3dd1fd131b47f76f8059dfvboxsync * source files should only differ on prefixes and the extra bits wrt to the
16acf57681289a6f8962cea292a28fd15030f420vboxsync * pci device. I.e. it should be diffable so that fixes to one can easily be
16acf57681289a6f8962cea292a28fd15030f420vboxsync * applied to the other. */
#include "VBoxGuestInternal.h"
struct VBoxGuestDeviceState
int iIOPortResId;
int iVMMDevMemResId;
void *pMMIOBase;
int iIrqResId;
void *pfnIrqHandler;
DECLVBGL(int) VBoxGuestFreeBSDServiceCall(void *pvSession, unsigned uCmd, void *pvData, size_t cbData, size_t *pcbDataReturned);
#ifndef D_NEEDMINOR
# define D_NEEDMINOR 0
static void VBoxGuestFreeBSDClone(void *pvArg, struct ucred *pCred, char *pszName, int cchName, struct cdev **ppDev)
int iUnit;
int rc;
if (!ppDev)
if (rc)
if (*ppDev)
int rc;
return EBUSY;
Log((DEVICE_NAME ":VBoxGuestFreeBSDOpen success: g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, (int)RTProcSelf()));
Log(("VBoxGuestFreeBSDClose: fFile=%#x iUnit=%d pSession=%p\n", fFile, minor2unit(minor(pDev)), pSession));
static int VBoxGuestFreeBSDIOCtl(struct cdev *pDev, u_long ulCmd, caddr_t pvData, int fFile, struct thread *pTd)
int rc = 0;
return EINVAL;
Log((DEVICE_NAME ": VBoxGuestFreeBSDIOCtl: bad request %lu size=%lu expected=%d\n", ulCmd, IOCPARM_LEN(ulCmd), sizeof(VBGLBIGREQ)));
return ENOTTY;
Log((DEVICE_NAME ": VBoxGuestFreeBSDIOCtl: bad magic %#x; pArg=%p Cmd=%lu.\n", ReqWrap->u32Magic, pvData, ulCmd));
return EINVAL;
printf(DEVICE_NAME ": VBoxGuestFreeBSDIOCtl: bad size %#x; pArg=%p Cmd=%lu.\n", ReqWrap->cbData, pvData, ulCmd);
return EINVAL;
Log((DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: RTMemTmpAlloc failed to alloc %d bytes.\n", ReqWrap->cbData));
return ENOMEM;
Log((DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: copyin failed; pvBuf=%p pArg=%p Cmd=%lu. rc=%d\n", pvBuf, pvData, ulCmd, rc));
return EFAULT;
return EINVAL;
rc = 0;
Log((DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: too much output data %d expected %d\n", cbDataReturned, ReqWrap->cbData));
if (cbDataReturned > 0)
Log((DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: copyout failed; pvBuf=%p pArg=%p Cmd=%lu. rc=%d\n", pvBuf, pvData, ulCmd, rc));
return rc;
int fEventsProcessed;
fEventsProcessed = 0;
return fEventsProcessed;
if (cUsers > 0)
return EBUSY;
RTR0Term();
int iResId = 0;
int rc = 0;
rc = bus_setup_intr(pDevice, pState->pIrqRes, INTR_TYPE_BIO | INTR_MPSAFE, NULL, (driver_intr_t *)VBoxGuestFreeBSDISR, pState,
rc = bus_setup_intr(pDevice, pState->pIrqRes, INTR_TYPE_BIO, (driver_intr_t *)VBoxGuestFreeBSDISR, pState, &pState->pfnIrqHandler);
if (rc)
return VERR_DEV_IO_ERROR;
return VINF_SUCCESS;
int iResId = 0;
cUsers = 0;
return ENXIO;
RTR0Term();
return ENXIO;
return ENXIO;
sizeof(struct VBoxGuestDeviceState),
#include "VBoxGuestIDC-unix.c.h"