DrvHostParallel.cpp revision b24513b23eda586d306777728716be1df3327e86
dc311b529996345ea65d51c87b60b6849642d894vboxsync * VirtualBox Host Parallel Port Driver.
dc311b529996345ea65d51c87b60b6849642d894vboxsync * Initial Linux-only code contributed by: Alexander Eichner
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync * Copyright (C) 2006-2012 Oracle Corporation
dc311b529996345ea65d51c87b60b6849642d894vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
dc311b529996345ea65d51c87b60b6849642d894vboxsync * available from http://www.virtualbox.org. This file is free software;
dc311b529996345ea65d51c87b60b6849642d894vboxsync * you can redistribute it and/or modify it under the terms of the GNU
dc311b529996345ea65d51c87b60b6849642d894vboxsync * General Public License (GPL) as published by the Free Software
dc311b529996345ea65d51c87b60b6849642d894vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
dc311b529996345ea65d51c87b60b6849642d894vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
dc311b529996345ea65d51c87b60b6849642d894vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
dc311b529996345ea65d51c87b60b6849642d894vboxsync/*******************************************************************************
dc311b529996345ea65d51c87b60b6849642d894vboxsync* Header Files *
dc311b529996345ea65d51c87b60b6849642d894vboxsync*******************************************************************************/
dc311b529996345ea65d51c87b60b6849642d894vboxsync/** @def VBOX_WITH_WIN_PARPORT_SUP *
dc311b529996345ea65d51c87b60b6849642d894vboxsync * Indicates whether to use the generic direct hardware access or host specific
dc311b529996345ea65d51c87b60b6849642d894vboxsync * code to access the parallel port.
ac5a71f3624a4c51d2a9323f8c88ead9c4d34582vboxsync#if defined(VBOX_WITH_WIN_PARPORT_SUP) && defined(IN_RING0)
dc311b529996345ea65d51c87b60b6849642d894vboxsync#if defined(VBOX_WITH_WIN_PARPORT_SUP) && defined(IN_RING3)
c2029891dc7fbce0f08a378d0335568cf9cbb4c5vboxsync/*******************************************************************************
dc311b529996345ea65d51c87b60b6849642d894vboxsync* Structures and Typedefs *
dc311b529996345ea65d51c87b60b6849642d894vboxsync*******************************************************************************/
dc311b529996345ea65d51c87b60b6849642d894vboxsync * Host parallel port driver instance data.
dc311b529996345ea65d51c87b60b6849642d894vboxsync * @implements PDMIHOSTPARALLELCONNECTOR
dc311b529996345ea65d51c87b60b6849642d894vboxsync /** Pointer to the driver instance structure. */
dc311b529996345ea65d51c87b60b6849642d894vboxsync /** Pointer to the driver instance. */
dc311b529996345ea65d51c87b60b6849642d894vboxsync /** Pointer to the char port interface of the driver/device above us. */
dc311b529996345ea65d51c87b60b6849642d894vboxsync /** Our host device interface. */
dc311b529996345ea65d51c87b60b6849642d894vboxsync /** Our host device interface. */
dc311b529996345ea65d51c87b60b6849642d894vboxsync PDMIHOSTPARALLELCONNECTOR IHostParallelConnectorR3;
char *pszDevicePath;
#ifndef VBOX_WITH_WIN_PARPORT_SUP
#ifdef VBOX_WITH_WIN_PARPORT_SUP
bool fParportAvail;
typedef enum DRVHOSTPARALLELR0OP
#define PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface) ( (PDRVHOSTPARALLEL)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTPARALLEL, CTX_SUFF(IHostParallelConnector))) )
#ifdef VBOX_WITH_WIN_PARPORT_SUP
# ifdef IN_RING0
return VINF_SUCCESS;
return VINF_SUCCESS;
return VINF_SUCCESS;
return VINF_SUCCESS;
return VINF_SUCCESS;
if (u64Arg)
return VINF_SUCCESS;
PDMBOTHCBDECL(int) drvR0HostParallelReqHandler(PPDMDRVINS pDrvIns, uint32_t uOperation, uint64_t u64Arg)
int rc;
case DRVHOSTPARALLELR0OP_READ:
return rc;
#ifdef IN_RING3
# ifdef VBOX_WITH_WIN_PARPORT_SUP
short wHeaderSize;
u32Size = 0;
if (pBuf)
rdPrevResDes = 0;
return u32ParportAddr;
return VERR_INVALID_HANDLE;
if (pBuf)
if(pBuf)
if (u32ParportAddr)
return VERR_NOT_FOUND;
return VERR_NOT_FOUND;
return VERR_NOT_FOUND;
return VERR_NOT_FOUND;
return VERR_NOT_FOUND;
if (pBuf)
return rc;
int iMode = 0;
# ifndef VBOX_WITH_WIN_PARPORT_SUP
int rcLnx;
switch (enmMode)
return VERR_NOT_SUPPORTED;
return rc;
return VINF_SUCCESS;
PDMIBASE_RETURN_INTERFACE(pszIID, PDMIHOSTPARALLELCONNECTOR, &pThis->CTX_SUFF(IHostParallelConnector));
return NULL;
static DECLCALLBACK(int) drvHostParallelWrite(PPDMIHOSTPARALLELCONNECTOR pInterface, const void *pvBuf, size_t cbWrite, PDMPARALLELPORTMODE enmMode)
PDRVHOSTPARALLEL pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPARALLEL, CTX_SUFF(IHostParallelConnector));
int rcLnx = 0;
return rc;
# ifndef VBOX_WITH_WIN_PARPORT_SUP
return rc;
static DECLCALLBACK(int) drvHostParallelRead(PPDMIHOSTPARALLELCONNECTOR pInterface, void *pvBuf, size_t cbRead, PDMPARALLELPORTMODE enmMode)
PDRVHOSTPARALLEL pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPARALLEL, CTX_SUFF(IHostParallelConnector));
# ifndef VBOX_WITH_WIN_PARPORT_SUP
int rcLnx = 0;
return rc;
return rc;
static DECLCALLBACK(int) drvHostParallelSetPortDirection(PPDMIHOSTPARALLELCONNECTOR pInterface, bool fForward)
PDRVHOSTPARALLEL pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPARALLEL, CTX_SUFF(IHostParallelConnector));
int iMode = 0;
if (!fForward)
# ifndef VBOX_WITH_WIN_PARPORT_SUP
return rc;
static DECLCALLBACK(int) drvHostParallelWriteControl(PPDMIHOSTPARALLELCONNECTOR pInterface, uint8_t fReg)
PDRVHOSTPARALLEL pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPARALLEL, CTX_SUFF(IHostParallelConnector));
int rcLnx = 0;
# ifndef VBOX_WITH_WIN_PARPORT_SUP
return rc;
static DECLCALLBACK(int) drvHostParallelReadControl(PPDMIHOSTPARALLELCONNECTOR pInterface, uint8_t *pfReg)
PDRVHOSTPARALLEL pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPARALLEL, CTX_SUFF(IHostParallelConnector));
int rcLnx = 0;
# ifndef VBOX_WITH_WIN_PARPORT_SUP
return rc;
static DECLCALLBACK(int) drvHostParallelReadStatus(PPDMIHOSTPARALLELCONNECTOR pInterface, uint8_t *pfReg)
PDRVHOSTPARALLEL pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPARALLEL, CTX_SUFF(IHostParallelConnector));
int rcLnx = 0;
# ifndef VBOX_WITH_WIN_PARPORT_SUP
return rc;
# ifndef VBOX_WITH_WIN_PARPORT_SUP
int rc;
if (rc < 0)
char ch;
return VINF_SUCCESS;
int rc;
#ifndef VBOX_WITH_WIN_PARPORT_SUP
static DECLCALLBACK(int) drvHostParallelConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
#ifndef VBOX_WITH_WIN_PARPORT_SUP
#ifdef VBOX_WITH_DRVINTNET_IN_R0
return rc;
rc = RTFileOpen(&pThis->hFileDevice, pThis->pszDevicePath, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
#ifndef VBOX_WITH_WIN_PARPORT_SUP
if (rc < 0)
if (rc < 0)
return PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_MISSING_INTERFACE_ABOVE, RT_SRC_POS, N_("Parallel#%d has no parallel port interface above"),
return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("HostParallel#%d cannot change mode of parallel mode to SPP"), pDrvIns->iInstance);
rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pMonitorThread, pThis, drvHostParallelMonitorThread, drvHostParallelWakeupMonitorThread, 0,
return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("HostParallel#%d cannot create monitor thread"), pDrvIns->iInstance);
/* If we have the char port availabe use it , else I am not getting exclusive access to parallel port.
return VINF_SUCCESS;
# if defined(VBOX_WITH_WIN_PARPORT_SUP)
sizeof(DRVHOSTPARALLEL),
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,