VBoxDev-haiku.c revision cadd9de82d5169aad827fe8d68e41a78ebbc6410
/* $Id$ */
/** @file
* VBoxGuest kernel driver, Haiku Guest Additions, implementation.
*/
/*
* Copyright (C) 2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/*
* This code is based on:
*
* VirtualBox Guest Additions for Haiku.
* Copyright (c) 2011 Mike Smith <mike@scgtrp.net>
* Fran�ois Revol <revol@free.fr>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#define LOG_GROUP LOG_GROUP_SUP_DRV
//#undef LOG_DISABLED
//#define LOG_ENABLED
//#define LOG_ENABLE_FLOW
//#define DO_LOG
#include <OS.h>
#include <Drivers.h>
#include <KernelExport.h>
#include <PCI.h>
#include "VBoxGuest-haiku.h"
#include "VBoxGuestInternal.h"
#include <iprt/initterm.h>
#define DRIVER_NAME "vboxdev"
#define DEVICE_NAME "misc/vboxguest"
#define MODULE_NAME "generic/vboxguest"
static status_t VBoxGuestHaikuWrite(void *cookie, off_t position, const void *data, size_t *numBytes);
static device_hooks g_VBoxGuestHaikuDeviceHooks =
{
};
/**
* File open handler
*
*/
{
int rc;
/*
* Create a new session.
*/
if (RT_SUCCESS(rc))
{
Log((DRIVER_NAME ":VBoxGuestHaikuOpen success: g_DevExt=%p pSession=%p rc=%d pid=%d\n",&g_DevExt, pSession, rc,(int)RTProcSelf()));
return 0;
}
return RTErrConvertToErrno(rc);
}
/**
* File close handler
*
*/
{
/** @todo r=ramshankar: should we really be using the session spinlock here? */
//XXX: we don't know if it belongs to this session !
if (sState.selectSync)
{
}
return 0;
}
/**
* File free handler
*
*/
{
/*
* Close the session if it's still hanging on to the device...
*/
{
}
else
return 0;
}
/**
* IOCTL handler
*
*/
{
//Log(("VBoxGuestHaikuFree: pSession=%p\n", pSession));
//LogFlow((DRIVER_NAME ":VBoxGuestHaikuIOCtl(, 0x%08x, %p, %d)\n", op, data, len));
int rc = 0;
/*
* Validate the input.
*/
return EINVAL;
/*
* Validate the request wrapper.
*/
#if 0
{
Log((DRIVER_NAME ": VBoxGuestHaikuIOCtl: bad request %lu size=%lu expected=%d\n", ulCmd, IOCPARM_LEN(ulCmd), sizeof(VBGLBIGREQ)));
return ENOTTY;
}
#endif
{
dprintf(DRIVER_NAME ": VBoxGuestHaikuIOCtl: bad size %#x; pArg=%p Cmd=%lu.\n", (unsigned)len, data, op);
return EINVAL;
}
/*
* Read the request.
*/
{
if (RT_UNLIKELY(!pvBuf))
{
return ENOMEM;
}
if (RT_UNLIKELY(rc < 0))
{
LogRel((DRIVER_NAME ":VBoxGuestHaikuIOCtl: user_memcpy failed; pvBuf=%p data=%p op=%d. rc=%d\n", pvBuf, data, op, rc));
return EFAULT;
}
{
return EINVAL;
}
}
/*
* Process the IOCtl.
*/
if (RT_SUCCESS(rc))
{
rc = 0;
{
Log((DRIVER_NAME ":VBoxGuestHaikuIOCtl: too much output data %d expected %d\n", cbDataReturned, len));
}
if (cbDataReturned > 0)
{
if (RT_UNLIKELY(rc < 0))
{
Log((DRIVER_NAME ":VBoxGuestHaikuIOCtl: user_memcpy failed; pvBuf=%p pArg=%p Cmd=%lu. rc=%d\n", pvBuf, data, op, rc));
}
}
}
else
{
}
return rc;
#if 0
#endif
}
{
//dprintf(DRIVER_NAME "select(,%d,%p)\n", event, sync);
switch (event)
{
case B_SELECT_READ:
//case B_SELECT_ERROR:
break;
default:
return EINVAL;
}
{
//dprintf(DRIVER_NAME "select: notifying now: %p %x\n", sync, event);
}
{
//dprintf(DRIVER_NAME "select: caching: %p %x\n", sync, event);
}
else
{
//dprintf(DRIVER_NAME "select: dropping: %p %x\n", sync, event);
err = B_WOULD_BLOCK;
}
return err;
#if 0
int fEventsProcessed;
{
}
{
}
else
{
fEventsProcessed = 0;
}
return fEventsProcessed;
#endif
}
{
//dprintf(DRIVER_NAME "deselect(,%d,%p)\n", event, sync);
{
}
else
return err;
}
static status_t VBoxGuestHaikuWrite(void *cookie, off_t position, const void *data, size_t *numBytes)
{
*numBytes = 0;
return 0;
}
{
//dprintf(DRIVER_NAME "read(,,%d)\n", *numBytes);
if (*numBytes == 0)
return 0;
{
//dprintf(DRIVER_NAME "read: giving 1 byte\n");
*numBytes = 1;
return 0;
}
*numBytes = 0;
return 0;
}
{
}
{
return B_OK;
}
{
static device_hooks g_VBoxGuestHaikuDeviceHooks =
{
};
return &g_VBoxGuestHaikuDeviceHooks;
}
const char** publish_devices()
{
return devices;
}
void uninit_driver()
{
}