VirtualBox

Changeset 37596 in vbox for trunk/src/VBox/Devices/Parallel


Ignore:
Timestamp:
Jun 22, 2011 7:30:06 PM (13 years ago)
Author:
vboxsync
Message:

*: RTFILE becomes a pointer, RTFileOpen++ expands it's flags paramter from uint32_t to uint64_t.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Parallel/DrvHostParallel.cpp

    r35353 r37596  
    2727#include <iprt/assert.h>
    2828#include <iprt/file.h>
     29#include <iprt/pipe.h>
    2930#include <iprt/semaphore.h>
    3031#include <iprt/stream.h>
     
    6465    char                         *pszDevicePath;
    6566    /** Device Handle */
    66     RTFILE                        FileDevice;
     67    RTFILE                        hFileDevice;
    6768    /** Thread waiting for interrupts. */
    6869    PPDMTHREAD                    pMonitorThread;
    6970    /** Wakeup pipe read end. */
    70     RTFILE                        WakeupPipeR;
     71    RTPIPE                        hWakeupPipeR;
    7172    /** Wakeup pipe write end. */
    72     RTFILE                        WakeupPipeW;
     73    RTPIPE                        hWakeupPipeW;
    7374} DRVHOSTPARALLEL, *PDRVHOSTPARALLEL;
    7475
     
    102103    LogFlow(("%s: pvBuf=%#p cbWrite=%d\n", __FUNCTION__, pvBuf, *cbWrite));
    103104
    104     ioctl(pThis->FileDevice, PPWDATA, pBuffer);
     105    ioctl(RTFileToNative(pThis->hFileDevice), PPWDATA, pBuffer);
    105106    *cbWrite = 1;
    106107
     
    115116    LogFlow(("%s: pvBuf=%#p cbRead=%d\n", __FUNCTION__, pvBuf, cbRead));
    116117
    117     ioctl(pThis->FileDevice, PPRDATA, pBuffer);
     118    ioctl(RTFileToNative(pThis->hFileDevice), PPRDATA, pBuffer);
    118119    *cbRead = 1;
    119120
     
    140141    }
    141142
    142     ioctl(pThis->FileDevice, PPSETMODE, &ppdev_mode);
     143    ioctl(RTFileToNative(pThis->hFileDevice), PPSETMODE, &ppdev_mode);
    143144
    144145    return VINF_SUCCESS;
     
    150151
    151152    LogFlow(("%s: fReg=%d\n", __FUNCTION__, fReg));
    152 
    153     ioctl(pThis->FileDevice, PPWCONTROL, &fReg);
     153    ioctl(RTFileToNative(pThis->hFileDevice), PPWCONTROL, &fReg);
    154154
    155155    return VINF_SUCCESS;
     
    159159{
    160160    PDRVHOSTPARALLEL pThis = PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface);
    161     uint8_t fReg;
    162 
    163     ioctl(pThis->FileDevice, PPRCONTROL, &fReg);
    164 
     161
     162    uint8_t fReg = 0;
     163    ioctl(RTFileToNative(pThis->hFileDevice), PPRCONTROL, &fReg);
    165164    LogFlow(("%s: fReg=%d\n", __FUNCTION__, fReg));
    166 
    167165    *pfReg = fReg;
    168166
     
    173171{
    174172    PDRVHOSTPARALLEL pThis = PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface);
    175     uint8_t fReg;
    176 
    177     ioctl(pThis->FileDevice, PPRSTATUS, &fReg);
    178 
     173
     174    uint8_t fReg = 0;
     175    ioctl(RTFileToNative(pThis->hFileDevice), PPRSTATUS, &fReg);
    179176    LogFlow(("%s: fReg=%d\n", __FUNCTION__, fReg));
    180 
    181177    *pfReg = fReg;
    182178
     
    196192        int rc;
    197193
    198         aFDs[0].fd      = pThis->FileDevice;
     194        aFDs[0].fd      = RTFileToNative(pThis->hFileDevice);
    199195        aFDs[0].events  = POLLIN;
    200196        aFDs[0].revents = 0;
    201         aFDs[1].fd      = pThis->WakeupPipeR;
     197        aFDs[1].fd      = RTPipeToNative(pThis->hWakeupPipeR);
    202198        aFDs[1].events  = POLLIN | POLLERR | POLLHUP;
    203199        aFDs[1].revents = 0;
     
    218214            char ch;
    219215            size_t cbRead;
    220             RTFileRead(pThis->WakeupPipeR, &ch, 1, &cbRead);
     216            RTPipeRead(pThis->hWakeupPipeR, &ch, 1, &cbRead);
    221217            continue;
    222218        }
     
    240236{
    241237    PDRVHOSTPARALLEL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL);
    242 
    243     return RTFileWrite(pThis->WakeupPipeW, "", 1, NULL);
     238    size_t cbIgnored;
     239    return RTPipeWrite(pThis->hWakeupPipeW, "", 1, &cbIgnored);
    244240}
    245241
     
    257253    LogFlow(("%s: iInstance=%d\n", __FUNCTION__, pDrvIns->iInstance));
    258254    PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
    259 
    260     ioctl(pThis->FileDevice, PPRELEASE);
    261 
    262     if (pThis->WakeupPipeW != NIL_RTFILE)
    263     {
    264         int rc = RTFileClose(pThis->WakeupPipeW);
    265         AssertRC(rc);
    266         pThis->WakeupPipeW = NIL_RTFILE;
    267     }
    268     if (pThis->WakeupPipeR != NIL_RTFILE)
    269     {
    270         int rc = RTFileClose(pThis->WakeupPipeR);
    271         AssertRC(rc);
    272         pThis->WakeupPipeR = NIL_RTFILE;
    273     }
    274     if (pThis->FileDevice != NIL_RTFILE)
    275     {
    276         int rc = RTFileClose(pThis->FileDevice);
    277         AssertRC(rc);
    278         pThis->FileDevice = NIL_RTFILE;
    279     }
     255    int rc;
     256
     257    if (pThis->hFileDevice != NIL_RTFILE)
     258        ioctl(RTFileToNative(pThis->hFileDevice), PPRELEASE);
     259
     260    rc = RTPipeClose(pThis->hWakeupPipeW); AssertRC(rc);
     261    pThis->hWakeupPipeW = NIL_RTPIPE;
     262
     263    rc = RTPipeClose(pThis->hWakeupPipeR); AssertRC(rc);
     264    pThis->hWakeupPipeR = NIL_RTPIPE;
     265
     266    rc = RTFileClose(pThis->hFileDevice); AssertRC(rc);
     267    pThis->hFileDevice = NIL_RTFILE;
     268
    280269    if (pThis->pszDevicePath)
    281270    {
     
    297286
    298287    /*
    299      * Validate the config.
    300      */
    301     if (!CFGMR3AreValuesValid(pCfg, "DevicePath\0"))
    302         return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES,
    303                                 N_("Unknown host parallel configuration option, only supports DevicePath"));
    304 
    305     /*
    306288     * Init basic data members and interfaces.
    307      */
     289     *
     290     * Must be done before returning any failure because we've got a destructor.
     291     */
     292    pThis->hFileDevice  = NIL_RTFILE;
     293    pThis->hWakeupPipeR = NIL_RTPIPE;
     294    pThis->hWakeupPipeW = NIL_RTPIPE;
    308295
    309296    /* IBase. */
     
    318305
    319306    /*
     307     * Validate the config.
     308     */
     309    if (!CFGMR3AreValuesValid(pCfg, "DevicePath\0"))
     310        return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES,
     311                                N_("Unknown host parallel configuration option, only supports DevicePath"));
     312
     313    /*
    320314     * Query configuration.
    321315     */
     
    331325     * Open the device
    332326     */
    333     rc = RTFileOpen(&pThis->FileDevice, pThis->pszDevicePath, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
     327    rc = RTFileOpen(&pThis->hFileDevice, pThis->pszDevicePath, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    334328    if (RT_FAILURE(rc))
    335329        return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("Parallel#%d could not open '%s'"),
     
    339333     * Try to get exclusive access to parallel port
    340334     */
    341     rc = ioctl(pThis->FileDevice, PPEXCL);
     335    rc = ioctl(RTFileToNative(pThis->hFileDevice), PPEXCL);
    342336    if (rc < 0)
    343337        return PDMDrvHlpVMSetError(pDrvIns, RTErrConvertFromErrno(errno), RT_SRC_POS,
     
    349343     * Claim the parallel port
    350344     */
    351     rc = ioctl(pThis->FileDevice, PPCLAIM);
     345    rc = ioctl(RTFileToNative(pThis->hFileDevice), PPCLAIM);
    352346    if (rc < 0)
    353347        return PDMDrvHlpVMSetError(pDrvIns, RTErrConvertFromErrno(errno), RT_SRC_POS,
     
    367361     * Create wakeup pipe.
    368362     */
    369     int aFDs[2];
    370     if (pipe(aFDs) != 0)
    371     {
    372         rc = RTErrConvertFromErrno(errno);
    373         AssertRC(rc);
    374         return rc;
    375     }
    376     pThis->WakeupPipeR = aFDs[0];
    377     pThis->WakeupPipeW = aFDs[1];
     363    rc = RTPipeCreate(&pThis->hWakeupPipeR, &pThis->hWakeupPipeR, 0 /*fFlags*/);
     364    AssertRCReturn(rc, rc);
    378365
    379366    /*
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette