driver.cpp revision 91f895d27453d2a92c6489a0c6b20021bf5f298d
/* $Id$ */
/** @file
* VBoxVideo 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.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <KernelExport.h>
#include <PCI.h>
#include <malloc.h>
#include <stdio.h>
#include <string.h>
#include <graphic_driver.h>
#include <VBoxGuest-haiku.h>
#include <VBox/VBoxVideoGuest.h>
#include "../common/VBoxVideo_common.h"
#define VENDOR_ID 0x80ee
#define DEVICE_ID 0xbeef
#define DRIVER_NAME "VBoxVideoDriver"
#define DEVICE_FORMAT "vd_%04X_%04X_%02X%02X%02X"
/** @todo r=ramshankar: pretty sure IPRT has something for page rounding,
* replace with IPRT version later. */
#define ENABLE_DEBUG_TRACE
#ifdef ENABLE_DEBUG_TRACE
#else
#define TRACE(x...) ;
#endif
struct Benaphore
{
{
count = 0;
}
{
return acquire_sem(sem);
return B_OK;
}
{
return release_sem(sem);
return B_OK;
}
void Delete()
{
}
};
struct DeviceInfo
{
};
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
/*******************************************************************************
* Globals *
*******************************************************************************/
/* At most one virtual video card ever appears, no reason for this to be an array */
static DeviceInfo gDeviceInfo;
static bool gCanHasDevice = false; /* is the device present? */
static pci_module_info *gPCI;
static device_hooks gDeviceHooks =
{
NULL, /* select */
NULL, /* deselect */
NULL, /* read_pages */
NULL /* write_pages */
};
{
LogFlowFunc(("init_hardware\n"));
{
return B_OK;
}
else
LogRel((DRIVER_NAME ":_init_hardware() get_module(%s) failed. err=%08lx\n", VBOXGUEST_MODULE_NAME, err));
return B_ERROR;
}
{
LogFlowFunc(("init_driver\n"));
{
{
gCanHasDevice = true;
gDeviceInfo.openCount = 0;
/* Not used, but this makes a reasonable-sounding refresh rate show in screen prefs: */
/* Map the PCI memory space */
break;
}
pciIndex++;
}
return B_OK;
}
const char** publish_devices()
{
LogFlowFunc(("publish_devices\n"));
if (gCanHasDevice)
return (const char **)gDeviceNames;
return NULL;
}
{
LogFlowFunc(a("find_device\n"));
return &gDeviceHooks;
return NULL;
}
void uninit_driver()
{
LogFlowFunc(("uninit_driver\n"));
}
{
LogFlowFunc(("device_open\n"));
return B_BAD_VALUE;
/* @todo init device! */
*cookie = (void *)&gDeviceInfo;
return B_OK;
}
{
LogFlowFunc(("device_close\n"));
return B_ERROR;
}
{
LogFlowFunc(("device_free\n"));
{
// TODO deinit device!
}
return B_OK;
}
{
LogFlowFunc(("device_read\n"));
return B_NOT_ALLOWED;
}
{
LogFlowFunc(("device_write\n"));
return B_NOT_ALLOWED;
}
{
LogFlowFunc(("device_ioctl\n"));
switch (msg)
{
{
return B_OK;
}
{
/** @todo r=ramshankar: implement RTR0MemUserCopyFrom for haiku. */
}
{
/** @todo r=ramshankar: implement RTR0MemUserCopyFrom for haiku. */
return B_BAD_ADDRESS;
return B_OK;
}
{
return B_OK;
}
default:
return B_BAD_VALUE;
}
}