DrvHostParallel.cpp revision 2e00eb43f4c5beb9652e4411370a0f41f8fe8ac9
/* $Id$ */
/** @file
* VirtualBox Host Parallel Port Driver.
*/
/*
* Copyright (C) 2006-2007 innotek GmbH
*
* 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 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.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_DRV_HOST_PARALLEL
#include <iprt/semaphore.h>
#ifdef RT_OS_LINUX
#include <fcntl.h>
#include <unistd.h>
#endif
#include "Builtins.h"
#include "ParallelIOCtlCmd.h"
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* Host parallel port driver instance data.
*/
typedef struct DRVHOSTPARALLEL
{
/** Pointer to the driver instance structure. */
/** Our host device interface. */
/** Our host device port interface. */
/** Device Path */
char *pszDevicePath;
/** Device Handle */
/** Flag to notify the receive thread it should terminate. */
volatile bool fShutdown;
/** Receive thread ID. */
/** Send thread ID. */
/** Send event semephore */
/** Converts a pointer to DRVHOSTPARALLEL::IHostDeviceConnector to a PDRHOSTPARALLEL. */
#define PDMIHOSTDEVICECONNECTOR_2_DRVHOSTPARALLEL(pInterface) ( (PDRVHOSTPARALLEL)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTPARALLEL, IHostDeviceConnector)) )
/** Converts a pointer to DRVHOSTPARALLEL::IHostDevicePort to a PDRHOSTPARALLEL. */
#define PDMIHOSTDEVICEPORT_2_DRVHOSTPARALLEL(pInterface) ( (PDRVHOSTPARALLEL)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTPARALLEL, IHostDevicePort)) )
/* -=-=-=-=- IBase -=-=-=-=- */
/**
* Queries an interface to the driver.
*
* @returns Pointer to interface.
* @returns NULL if the interface was not supported by the driver.
* @param pInterface Pointer to this interface structure.
* @param enmInterface The requested interface identification.
*/
static DECLCALLBACK(void *) drvHostParallelQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface)
{
switch (enmInterface)
{
case PDMINTERFACE_BASE:
return &pData->IHostDeviceConnector;
default:
return NULL;
}
}
/* -=-=-=-=- IHostDeviceConnector -=-=-=-=- */
/** @copydoc PDMICHAR::pfnWrite */
static DECLCALLBACK(int) drvHostParallelWrite(PPDMIHOSTDEVICECONNECTOR pInterface, const void *pvBuf, size_t *cbWrite)
{
return VINF_SUCCESS;
}
static DECLCALLBACK(int) drvHostParallelRead(PPDMIHOSTDEVICECONNECTOR pInterface, void *pvBuf, size_t *cbRead)
{
*cbRead = 1;
return VINF_SUCCESS;
}
void *pvData)
{
unsigned long ioctlCommand;
switch (uCommand) {
break;
break;
}
return VINF_SUCCESS;
}
/**
* Construct a host parallel driver instance.
*
* @returns VBox status.
* @param pDrvIns The driver instance data.
* If the registration structure is needed,
* pDrvIns->pDrvReg points to it.
* @param pCfgHandle Configuration node handle for the driver. Use this to
* obtain the configuration of the driver instance. It's
* also found in pDrvIns->pCfgHandle as it's expected to
* be used frequently in this function.
*/
{
/*
* Init basic data members and interfaces.
*/
/* IBase. */
/* IChar. */
/*
* Query configuration.
*/
/* Device */
if (VBOX_FAILURE(rc))
{
return rc;
}
/*
* Open the device
*/
if (pData->FileDevice < 0) {
}
/*
* Try to get exclusive access to parallel port
*/
}
/*
* Claim the parallel port
*/
}
/*
*/
pData->pDrvHostDevicePort = (PPDMIHOSTDEVICEPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_HOST_DEVICE_PORT);
if (!pData->pDrvHostDevicePort)
return PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_MISSING_INTERFACE_ABOVE, RT_SRC_POS, N_("Parallel#%d has no parallel port interface above"), pDrvIns->iInstance);
return VINF_SUCCESS;
}
/**
* Destruct a host parallel driver instance.
*
* Most VM resources are freed by the VM. This callback is provided so that
* any non-VM resources can be freed correctly.
*
* @param pDrvIns The driver instance data.
*/
{
if (pData->ReceiveThread)
{
}
if (pData->SendThread)
{
}
}
/**
* Char driver registration record.
*/
const PDMDRVREG g_DrvHostParallel =
{
/* u32Version */
/* szDriverName */
"HostParallel",
/* pszDescription */
"Parallel host driver.",
/* fFlags */
/* fClass. */
/* cMaxInstances */
~0,
/* cbInstance */
sizeof(DRVHOSTPARALLEL),
/* pfnConstruct */
/* pfnDestruct */
/* pfnIOCtl */
NULL,
/* pfnPowerOn */
NULL,
/* pfnReset */
NULL,
/* pfnSuspend */
NULL,
/* pfnResume */
NULL,
/* pfnDetach */
NULL,
/** pfnPowerOff */
};