DevParallel.cpp revision 548ca31b6b47c36bacce49bed3339cb8075b9681
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * VirtualBox Parallel Device Emulation.
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * Contributed by: Alexander Eichner
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * Copyright (C) 2006-2007 Sun Microsystems, Inc.
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * This file is part of VirtualBox Open Source Edition (OSE), as
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * available from http://www.virtualbox.org. This file is free software;
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * you can redistribute it and/or modify it under the terms of the GNU
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * General Public License (GPL) as published by the Free Software
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * Foundation, in version 2 as it comes in the "COPYING" file of the
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * Clara, CA 95054 USA or visit http://www.sun.com if you need
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * additional information or have any questions.
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major/*******************************************************************************
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major* Header Files *
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major*******************************************************************************/
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major/* defines for accessing the register bits */
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major#define LPT_STATUS_BIT1 0x02 /* reserved (only for completeness) */
typedef struct ParallelState
int act_fifo_pos_write;
int act_fifo_pos_read;
int irq;
bool fGCEnabled;
bool fR0Enabled;
#ifndef VBOX_DEVICE_STRUCT_TESTCASE
#define PDMIHOSTPARALLELPORT_2_PARALLELSTATE(pInstance) ( (ParallelState *)((uintptr_t)(pInterface) - RT_OFFSETOF(ParallelState, IHostParallelPort)) )
#define PDMIHOSTDEVICEPORT_2_PARALLELSTATE(pInstance) ( (ParallelState *)((uintptr_t)(pInterface) - RT_OFFSETOF(ParallelState, IHostDevicePort)) )
#define PDMIBASE_2_PARALLELSTATE(pInstance) ( (ParallelState *)((uintptr_t)(pInterface) - RT_OFFSETOF(ParallelState, IBase)) )
PDMBOTHCBDECL(int) parallelIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb);
PDMBOTHCBDECL(int) parallelIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb);
PDMBOTHCBDECL(int) parallelIOPortReadECP(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb);
PDMBOTHCBDECL(int) parallelIOPortWriteECP(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb);
#ifdef IN_RING3
unsigned char ch;
switch(addr) {
#ifndef IN_RING3
return VINF_IOM_HC_IOPORT_WRITE;
#ifndef IN_RING3
return VINF_IOM_HC_IOPORT_WRITE;
return VINF_SUCCESS;
switch(addr) {
#ifndef IN_RING3
int rc = s->pDrvHostParallelConnector->pfnRead(s->pDrvHostParallelConnector, &s->reg_data, &cbRead);
#ifndef IN_RING3
return ret;
unsigned char ch;
switch(addr) {
s->act_fifo_pos_write++;
s->act_fifo_pos_write = 0;
s->act_fifo_pos_write = 0;
s->act_fifo_pos_read = 0;
return VINF_SUCCESS;
switch(addr) {
s->act_fifo_pos_read++;
return ret;
#ifdef IN_RING3
return VINF_SUCCESS;
return rc;
return rc;
return rc;
return rc;
#ifdef IN_RING3
int rc;
return rc;
if (u32 != ~0U)
return VINF_SUCCESS;
switch (enmInterface)
case PDMINTERFACE_BASE:
return NULL;
return VINF_SUCCESS;
int iInstance,
int rc;
return rc;
return rc;
return rc;
return rc;
return rc;
return rc;
return rc;
pThis->pDrvHostParallelConnector = (PDMIHOSTPARALLELCONNECTOR *)pThis->pDrvBase->pfnQueryInterface(pThis->pDrvBase,
return VERR_PDM_MISSING_INTERFACE;
pThis->pDrvHostParallelConnector->pfnSetMode(pThis->pDrvHostParallelConnector, PDM_PARALLEL_PORT_MODE_COMPAT);
pThis->pDrvHostParallelConnector->pfnReadControl(pThis->pDrvHostParallelConnector, &pThis->reg_control);
return rc;
return VINF_SUCCESS;
PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT | PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT | PDM_DEVREG_FLAGS_GC | PDM_DEVREG_FLAGS_R0,
sizeof(ParallelState),
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,