Commits

Bernhard Walle committed 7c7c969

vbox: Add patch to allow reading from the parport

This is necessary to use devices like Logic Analyzers that perform
low-level reads.

Signed-off-by: Bernhard Walle <bernhard@bwalle.de>

Comments (0)

Files changed (1)

vbox/vbox-parport-read.diff

+Index: include/VBox/vmm/pdmifs.h
+===================================================================
+--- include/VBox/vmm/pdmifs.h	(Revision 37161)
++++ include/VBox/vmm/pdmifs.h	(Arbeitskopie)
+@@ -1800,6 +1800,17 @@
+     DECLR3CALLBACKMEMBER(int, pfnWriteControl,(PPDMIHOSTPARALLELCONNECTOR pInterface, uint8_t fReg));
+ 
+     /**
++     * Sets the data direction of the parallel port.
++     *
++     *
++     * @returns VBox status code.
++     * @param   pInterface      Pointer to the interface structure containing the called function pointer.
++     * @param   dir             The new direction, 0 -> forward, != 0 -> reverse.
++     * @thread  Any thread.
++     */
++    DECLR3CALLBACKMEMBER(int, pfnSetDirection,(PPDMIHOSTPARALLELCONNECTOR pInterface, int direction));
++
++    /**
+      * Read control register bits.
+      *
+      * @returns VBox status code.
+Index: src/VBox/Devices/Parallel/DrvHostParallel.cpp
+===================================================================
+--- src/VBox/Devices/Parallel/DrvHostParallel.cpp	(Revision 37161)
++++ src/VBox/Devices/Parallel/DrvHostParallel.cpp	(Arbeitskopie)
+@@ -155,6 +155,18 @@
+     return VINF_SUCCESS;
+ }
+ 
++static DECLCALLBACK(int) drvHostParallelSetDirection(PPDMIHOSTPARALLELCONNECTOR pInterface, int dir)
++{
++    PDRVHOSTPARALLEL pThis = PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface);
++
++    LogFlow(("%s: dir=%d\n", __FUNCTION__, dir));
++
++    /* 0 -> forward, != 0 -> reverse */
++    ioctl(pThis->FileDevice, PPDATADIR, &dir);
++
++    return VINF_SUCCESS;
++}
++
+ static DECLCALLBACK(int) drvHostParallelReadControl(PPDMIHOSTPARALLELCONNECTOR pInterface, uint8_t *pfReg)
+ {
+     PDRVHOSTPARALLEL pThis = PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface);
+@@ -313,6 +325,7 @@
+     pThis->IHostParallelConnector.pfnRead          = drvHostParallelRead;
+     pThis->IHostParallelConnector.pfnSetMode       = drvHostParallelSetMode;
+     pThis->IHostParallelConnector.pfnWriteControl  = drvHostParallelWriteControl;
++    pThis->IHostParallelConnector.pfnSetDirection  = drvHostParallelSetDirection;
+     pThis->IHostParallelConnector.pfnReadControl   = drvHostParallelReadControl;
+     pThis->IHostParallelConnector.pfnReadStatus    = drvHostParallelReadStatus;
+ 
+Index: src/VBox/Devices/Parallel/DevParallel.cpp
+===================================================================
+--- src/VBox/Devices/Parallel/DevParallel.cpp	(Revision 37161)
++++ src/VBox/Devices/Parallel/DevParallel.cpp	(Arbeitskopie)
+@@ -216,7 +216,22 @@
+ #ifndef IN_RING3
+             return VINF_IOM_HC_IOPORT_WRITE;
+ #else
+-            int rc = s->pDrvHostParallelConnector->pfnWriteControl(s->pDrvHostParallelConnector, ch);
++            int rc;
++
++            /* direction changed? */
++            if (s->pDrvHostParallelConnector->pfnSetDirection)
++            {
++                if ((ch & LPT_CONTROL_ENABLE_BIDIRECT) != (s->reg_control & LPT_CONTROL_ENABLE_BIDIRECT))
++                {
++                    int dir = ch & LPT_CONTROL_ENABLE_BIDIRECT;
++                    rc = s->pDrvHostParallelConnector->pfnSetDirection(s->pDrvHostParallelConnector, dir);
++                }
++            }
++
++            /* something else changed? */
++            if ((ch & 0x1f) != (s->reg_control & 0x1f))
++                rc = s->pDrvHostParallelConnector->pfnWriteControl(s->pDrvHostParallelConnector, ch & 0x1f);
++
+             AssertRC(rc);
+             s->reg_control = val;
+ #endif