VirtualBox

Changeset 6228 in vbox


Ignore:
Timestamp:
Jan 2, 2008 12:09:12 PM (17 years ago)
Author:
vboxsync
Message:

Better error reporting

File:
1 edited

Legend:

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

    r6223 r6228  
    131131}
    132132
    133 static DECLCALLBACK(int) drvHostParallelSetMode(PPDMIHOSTPARALLELCONNECTOR pInterface, PDMPARALLELPORTMODE mode)
     133static DECLCALLBACK(int) drvHostParallelSetMode(PPDMIHOSTPARALLELCONNECTOR pInterface, PDMPARALLELPORTMODE enmMode)
    134134{
    135135    PDRVHOSTPARALLEL pData = PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface);
    136136    int ppdev_mode;
    137137
    138     LogFlow(("%s: mode=%d\n", __FUNCTION__, mode));
    139 
    140     switch (mode) {
     138    LogFlow(("%s: mode=%d\n", __FUNCTION__, enmMode));
     139
     140    switch (enmMode) {
    141141        case PDM_PARALLEL_PORT_MODE_COMPAT:
    142142            ppdev_mode = IEEE1284_MODE_COMPAT;
     
    155155}
    156156
    157 static DECLCALLBACK(int) drvHostParallelWriteControl(PPDMIHOSTPARALLELCONNECTOR pInterface, uint8_t val)
    158 {
    159     PDRVHOSTPARALLEL pData = PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface);
    160 
    161     LogFlow(("%s: val=%d\n", __FUNCTION__, val));
    162 
    163     ioctl(pData->FileDevice, PPWCONTROL, &val);
    164 
    165     return VINF_SUCCESS;
    166 }
    167 
    168 static DECLCALLBACK(int) drvHostParallelReadControl(PPDMIHOSTPARALLELCONNECTOR pInterface, uint8_t *pvBuf)
    169 {
    170     PDRVHOSTPARALLEL pData = PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface);
    171     uint8_t val;
    172 
    173     ioctl(pData->FileDevice, PPRCONTROL, &val);
    174 
    175     LogFlow(("%s: val=%d\n", __FUNCTION__, val));
    176 
    177     *pvBuf = val;
    178 
    179     return VINF_SUCCESS;
    180 }
    181 
    182 static DECLCALLBACK(int) drvHostParallelReadStatus(PPDMIHOSTPARALLELCONNECTOR pInterface, uint8_t *pvBuf)
    183 {
    184     PDRVHOSTPARALLEL pData = PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface);
    185     uint8_t val;
    186 
    187     ioctl(pData->FileDevice, PPRSTATUS, &val);
    188 
    189     LogFlow(("%s: val=%d\n", __FUNCTION__, val));
    190 
    191     *pvBuf = val;
     157static DECLCALLBACK(int) drvHostParallelWriteControl(PPDMIHOSTPARALLELCONNECTOR pInterface, uint8_t fReg)
     158{
     159    PDRVHOSTPARALLEL pData = PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface);
     160
     161    LogFlow(("%s: fReg=%d\n", __FUNCTION__, fReg));
     162
     163    ioctl(pData->FileDevice, PPWCONTROL, &fReg);
     164
     165    return VINF_SUCCESS;
     166}
     167
     168static DECLCALLBACK(int) drvHostParallelReadControl(PPDMIHOSTPARALLELCONNECTOR pInterface, uint8_t *pfReg)
     169{
     170    PDRVHOSTPARALLEL pData = PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface);
     171    uint8_t fReg;
     172
     173    ioctl(pData->FileDevice, PPRCONTROL, &fReg);
     174
     175    LogFlow(("%s: fReg=%d\n", __FUNCTION__, fReg));
     176
     177    *pfReg = fReg;
     178
     179    return VINF_SUCCESS;
     180}
     181
     182static DECLCALLBACK(int) drvHostParallelReadStatus(PPDMIHOSTPARALLELCONNECTOR pInterface, uint8_t *pfReg)
     183{
     184    PDRVHOSTPARALLEL pData = PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface);
     185    uint8_t fReg;
     186
     187    ioctl(pData->FileDevice, PPRSTATUS, &fReg);
     188
     189    LogFlow(("%s: fReg=%d\n", __FUNCTION__, fReg));
     190
     191    *pfReg = fReg;
    192192
    193193    return VINF_SUCCESS;
     
    272272
    273273    /*
     274     * Validate the config.
     275     */
     276    if (!CFGMR3AreValuesValid(pCfgHandle, "DevicePath\0"))
     277        return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES,
     278                                N_("Unknown host parallel configuration option, only supports DevicePath"));
     279
     280    /*
    274281     * Init basic data members and interfaces.
    275282     */
     
    299306     * Open the device
    300307     */
    301     pData->FileDevice = open(pData->pszDevicePath, O_RDWR | O_NONBLOCK);
    302     if (pData->FileDevice < 0) {
    303 
    304     }
     308    rc = RTFileOpen(&pData->FileDevice, pData->pszDevicePath, RTFILE_O_OPEN | RTFILE_O_READWRITE);
     309    if (VBOX_FAILURE(rc))
     310        return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("Parallel#%d could not open '%s'"),
     311                                   pDrvIns->iInstance, pData->pszDevicePath);
    305312
    306313    /*
    307314     * Try to get exclusive access to parallel port
    308315     */
    309     if (ioctl(pData->FileDevice, PPEXCL) < 0) {
    310     }
     316    rc = ioctl(pData->FileDevice, PPEXCL);     
     317    if (rc < 0)
     318        return PDMDrvHlpVMSetError(pDrvIns, RTErrConvertFromErrno(errno), RT_SRC_POS,
     319                                   N_("Parallel#%d could not get exclusive access for parallel port '%s'"
     320                                      "Be sure that no other process or driver accesses this port"),
     321                                   pDrvIns->iInstance, pData->pszDevicePath);
    311322
    312323    /*
    313324     * Claim the parallel port
    314325     */
    315     if (ioctl(pData->FileDevice, PPCLAIM) < 0) {
    316     }
     326    rc = ioctl(pData->FileDevice, PPCLAIM);
     327    if (rc < 0)
     328        return PDMDrvHlpVMSetError(pDrvIns, RTErrConvertFromErrno(errno), RT_SRC_POS,
     329                                   N_("Parallel#%d could not claim parallel port '%s'"
     330                                      "Be sure that no other process or driver accesses this port"),
     331                                   pDrvIns->iInstance, pData->pszDevicePath);
    317332
    318333    /*
     
    359374static DECLCALLBACK(void) drvHostParallelDestruct(PPDMDRVINS pDrvIns)
    360375{
    361     PDRVHOSTPARALLEL     pData = PDMINS2DATA(pDrvIns, PDRVHOSTPARALLEL);
     376    PDRVHOSTPARALLEL pData = PDMINS2DATA(pDrvIns, PDRVHOSTPARALLEL);
    362377
    363378    LogFlow(("%s: iInstance=%d\n", __FUNCTION__, pDrvIns->iInstance));
    364379
    365380    ioctl(pData->FileDevice, PPRELEASE);
    366     close(pData->FileDevice);
     381
     382    if (pData->WakeupPipeW != NIL_RTFILE)
     383    {
     384        int rc = RTFileClose(pData->WakeupPipeW);
     385        AssertRC(rc);
     386        pData->WakeupPipeW = NIL_RTFILE;
     387    }
     388    if (pData->WakeupPipeR != NIL_RTFILE)
     389    {
     390        int rc = RTFileClose(pData->WakeupPipeR);
     391        AssertRC(rc);
     392        pData->WakeupPipeR = NIL_RTFILE;
     393    }
     394    if (pData->FileDevice != NIL_RTFILE)
     395    {
     396        int rc = RTFileClose(pData->FileDevice);
     397        AssertRC(rc);
     398        pData->FileDevice = NIL_RTFILE;
     399    }
    367400}
    368401
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