Changeset 6228 in vbox
- Timestamp:
- Jan 2, 2008 12:09:12 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Parallel/DrvHostParallel.cpp
r6223 r6228 131 131 } 132 132 133 static DECLCALLBACK(int) drvHostParallelSetMode(PPDMIHOSTPARALLELCONNECTOR pInterface, PDMPARALLELPORTMODE mode)133 static DECLCALLBACK(int) drvHostParallelSetMode(PPDMIHOSTPARALLELCONNECTOR pInterface, PDMPARALLELPORTMODE enmMode) 134 134 { 135 135 PDRVHOSTPARALLEL pData = PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface); 136 136 int ppdev_mode; 137 137 138 LogFlow(("%s: mode=%d\n", __FUNCTION__, mode));139 140 switch ( mode) {138 LogFlow(("%s: mode=%d\n", __FUNCTION__, enmMode)); 139 140 switch (enmMode) { 141 141 case PDM_PARALLEL_PORT_MODE_COMPAT: 142 142 ppdev_mode = IEEE1284_MODE_COMPAT; … … 155 155 } 156 156 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 *p vBuf)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 *p vBuf = val;178 179 return VINF_SUCCESS; 180 } 181 182 static DECLCALLBACK(int) drvHostParallelReadStatus(PPDMIHOSTPARALLELCONNECTOR pInterface, uint8_t *p vBuf)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 *p vBuf = val;157 static 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 168 static 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 182 static 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; 192 192 193 193 return VINF_SUCCESS; … … 272 272 273 273 /* 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 /* 274 281 * Init basic data members and interfaces. 275 282 */ … … 299 306 * Open the device 300 307 */ 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); 305 312 306 313 /* 307 314 * Try to get exclusive access to parallel port 308 315 */ 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); 311 322 312 323 /* 313 324 * Claim the parallel port 314 325 */ 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); 317 332 318 333 /* … … 359 374 static DECLCALLBACK(void) drvHostParallelDestruct(PPDMDRVINS pDrvIns) 360 375 { 361 PDRVHOSTPARALLEL 376 PDRVHOSTPARALLEL pData = PDMINS2DATA(pDrvIns, PDRVHOSTPARALLEL); 362 377 363 378 LogFlow(("%s: iInstance=%d\n", __FUNCTION__, pDrvIns->iInstance)); 364 379 365 380 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 } 367 400 } 368 401
Note:
See TracChangeset
for help on using the changeset viewer.