driver.cpp revision 8e9d8c088aac57bedb558d3164bb681a582e4474
/* $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.
*/
#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 DEVICE_FORMAT "vd_%04X_%04X_%02X%02X%02X"
#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
{
};
// 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 =
{
device_open, // open
device_close, // close
device_free, // free
device_ioctl, // control
device_read, // read
device_write, // write
NULL, // select
NULL, // deselect
NULL, // read_pages
NULL // write_pages
};
{
TRACE("init_hardware\n");
{
return B_ERROR;
}
{
return B_ERROR;
}
return B_OK;
}
{
TRACE("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()
{
TRACE("publish_devices\n");
if (gCanHasDevice)
return (const char **)gDeviceNames;
return NULL;
}
{
TRACE("find_device\n");
return &gDeviceHooks;
return NULL;
}
void uninit_driver()
{
TRACE("uninit_driver\n");
}
{
TRACE("device_open\n");
return B_BAD_VALUE;
// TODO init device!
*cookie = (void *)&gDeviceInfo;
return B_OK;
}
{
TRACE("device_close\n");
return B_ERROR;
}
{
TRACE("device_free\n");
{
// TODO deinit device!
}
return B_OK;
}
{
TRACE("device_read\n");
return B_NOT_ALLOWED;
}
{
TRACE("device_write\n");
return B_NOT_ALLOWED;
}
{
TRACE("device_ioctl\n");
switch (msg)
{
return B_OK;
return B_BAD_ADDRESS;
else
return B_OK;
{
return B_OK;
}
default:
return B_BAD_VALUE;
}
}