Changeset 44702 in vbox
- Timestamp:
- Feb 14, 2013 8:21:35 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 83801
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Parallel/DevParallel.cpp
r44701 r44702 28 28 #include <iprt/string.h> 29 29 #include <iprt/semaphore.h> 30 #include <iprt/critsect.h>31 30 32 31 #include "VBoxDD.h" … … 97 96 typedef struct PARALLELPORT 98 97 { 99 /** Access critical section. */100 PDMCRITSECT CritSect;101 102 98 /** Pointer to the device instance - R3 Ptr */ 103 99 PPDMDEVINSR3 pDevInsR3; … … 310 306 PARALLELPORT *pThis = PDMIHOSTPARALLELPORT_2_PARALLELPORT(pInterface); 311 307 312 PDMCritSectEnter( &pThis->CritSect, VINF_SUCCESS);308 PDMCritSectEnter(pThis->pDevInsR3->pCritSectRoR3, VINF_SUCCESS); 313 309 parallelR3IrqSet(pThis); 314 PDMCritSectLeave( &pThis->CritSect);310 PDMCritSectLeave(pThis->pDevInsR3->pCritSectRoR3); 315 311 316 312 return VINF_SUCCESS; … … 329 325 if (cb == 1) 330 326 { 331 rc = PDMCritSectEnter(&pThis->CritSect, VINF_IOM_R3_IOPORT_WRITE); 332 if (rc == VINF_SUCCESS) 327 uint8_t u8 = u32; 328 329 Log2(("%s: port %#06x val %#04x\n", __FUNCTION__, Port, u32)); 330 331 Port &= 7; 332 switch (Port) 333 333 { 334 uint8_t u8 = u32; 335 336 Log2(("%s: port %#06x val %#04x\n", __FUNCTION__, Port, u32)); 337 338 Port &= 7; 339 switch (Port) 340 { 341 case 0: 334 case 0: 342 335 #ifndef IN_RING3 343 344 336 NOREF(u8); 337 rc = VINF_IOM_R3_IOPORT_WRITE; 345 338 #else 346 347 348 349 350 351 352 353 #endif 354 355 356 357 358 359 360 361 339 pThis->regData = u8; 340 if (RT_LIKELY(pThis->pDrvHostParallelConnector)) 341 { 342 LogFlowFunc(("Set data lines 0x%X\n", u8)); 343 rc = pThis->pDrvHostParallelConnector->pfnWrite(pThis->pDrvHostParallelConnector, &u8, 1, PDM_PARALLEL_PORT_MODE_SPP); 344 AssertRC(rc); 345 } 346 #endif 347 break; 348 case 1: 349 break; 350 case 2: 351 /* Set the reserved bits to one */ 352 u8 |= (LPT_CONTROL_BIT6 | LPT_CONTROL_BIT7); 353 if (u8 != pThis->regControl) 354 { 362 355 #ifndef IN_RING3 363 356 return VINF_IOM_R3_IOPORT_WRITE; 364 357 #else 365 366 367 368 369 370 371 372 373 374 375 376 #endif 377 378 379 358 /* Set data direction. */ 359 if (u8 & LPT_CONTROL_ENABLE_BIDIRECT) 360 rc = pThis->pDrvHostParallelConnector->pfnSetPortDirection(pThis->pDrvHostParallelConnector, false /* fForward */); 361 else 362 rc = pThis->pDrvHostParallelConnector->pfnSetPortDirection(pThis->pDrvHostParallelConnector, true /* fForward */); 363 AssertRC(rc); 364 u8 &= ~LPT_CONTROL_ENABLE_BIDIRECT; /* Clear bit. */ 365 366 rc = pThis->pDrvHostParallelConnector->pfnWriteControl(pThis->pDrvHostParallelConnector, u8); 367 AssertRC(rc); 368 pThis->regControl = u8; 369 #endif 370 } 371 break; 372 case 3: 380 373 #ifndef IN_RING3 381 382 374 NOREF(u8); 375 rc = VINF_IOM_R3_IOPORT_WRITE; 383 376 #else 384 385 386 387 388 389 390 391 #endif 392 393 377 pThis->regEppAddr = u8; 378 if (RT_LIKELY(pThis->pDrvHostParallelConnector)) 379 { 380 LogFlowFunc(("Write EPP address 0x%X\n", u8)); 381 rc = pThis->pDrvHostParallelConnector->pfnWrite(pThis->pDrvHostParallelConnector, &u8, 1, PDM_PARALLEL_PORT_MODE_EPP_ADDR); 382 AssertRC(rc); 383 } 384 #endif 385 break; 386 case 4: 394 387 #ifndef IN_RING3 395 396 388 NOREF(u8); 389 rc = VINF_IOM_R3_IOPORT_WRITE; 397 390 #else 398 pThis->regEppData = u8; 399 if (RT_LIKELY(pThis->pDrvHostParallelConnector)) 400 { 401 LogFlowFunc(("Write EPP data 0x%X\n", u8)); 402 rc = pThis->pDrvHostParallelConnector->pfnWrite(pThis->pDrvHostParallelConnector, &u8, 1, PDM_PARALLEL_PORT_MODE_EPP_DATA); 403 AssertRC(rc); 404 } 405 #endif 406 break; 407 case 5: 408 break; 409 case 6: 410 break; 411 case 7: 412 default: 413 break; 414 } 415 PDMCritSectLeave(&pThis->CritSect); 391 pThis->regEppData = u8; 392 if (RT_LIKELY(pThis->pDrvHostParallelConnector)) 393 { 394 LogFlowFunc(("Write EPP data 0x%X\n", u8)); 395 rc = pThis->pDrvHostParallelConnector->pfnWrite(pThis->pDrvHostParallelConnector, &u8, 1, PDM_PARALLEL_PORT_MODE_EPP_DATA); 396 AssertRC(rc); 397 } 398 #endif 399 break; 400 case 5: 401 break; 402 case 6: 403 break; 404 case 7: 405 default: 406 break; 416 407 } 417 408 } … … 433 424 if (cb == 1) 434 425 { 435 rc = PDMCritSectEnter(&pThis->CritSect, VINF_IOM_R3_IOPORT_READ);436 if (rc == VINF_SUCCESS)426 Port &= 7; 427 switch (Port) 437 428 { 438 Port &= 7; 439 switch (Port) 440 { 441 case 0: 442 if (!(pThis->regControl & LPT_CONTROL_ENABLE_BIDIRECT)) 443 *pu32 = pThis->regData; 444 else 445 { 446 #ifndef IN_RING3 447 rc = VINF_IOM_R3_IOPORT_READ; 448 #else 449 if (RT_LIKELY(pThis->pDrvHostParallelConnector)) 450 { 451 rc = pThis->pDrvHostParallelConnector->pfnRead(pThis->pDrvHostParallelConnector, &pThis->regData, 452 1, PDM_PARALLEL_PORT_MODE_SPP); 453 Log(("Read data lines 0x%X\n", pThis->regData)); 454 AssertRC(rc); 455 } 456 *pu32 = pThis->regData; 457 #endif 458 } 459 break; 460 case 1: 429 case 0: 430 if (!(pThis->regControl & LPT_CONTROL_ENABLE_BIDIRECT)) 431 *pu32 = pThis->regData; 432 else 433 { 461 434 #ifndef IN_RING3 462 435 rc = VINF_IOM_R3_IOPORT_READ; … … 464 437 if (RT_LIKELY(pThis->pDrvHostParallelConnector)) 465 438 { 466 rc = pThis->pDrvHostParallelConnector->pfnReadStatus(pThis->pDrvHostParallelConnector, &pThis->regStatus); 439 rc = pThis->pDrvHostParallelConnector->pfnRead(pThis->pDrvHostParallelConnector, &pThis->regData, 440 1, PDM_PARALLEL_PORT_MODE_SPP); 441 Log(("Read data lines 0x%X\n", pThis->regData)); 467 442 AssertRC(rc); 468 443 } 469 *pu32 = pThis->reg Status;470 parallelR3IrqClear(pThis); 471 #endif 472 473 case 2:444 *pu32 = pThis->regData; 445 #endif 446 } 447 break; 448 case 1: 474 449 #ifndef IN_RING3 475 450 rc = VINF_IOM_R3_IOPORT_READ; 476 451 #else 477 rc = pThis->pDrvHostParallelConnector->pfnReadControl(pThis->pDrvHostParallelConnector, &pThis->regControl); 478 AssertRC(rc); 479 pThis->regControl |= LPT_CONTROL_BIT6 | LPT_CONTROL_BIT7; 480 *pu32 = pThis->regControl; 481 #endif 482 break; 483 case 3: 452 if (RT_LIKELY(pThis->pDrvHostParallelConnector)) 453 { 454 rc = pThis->pDrvHostParallelConnector->pfnReadStatus(pThis->pDrvHostParallelConnector, &pThis->regStatus); 455 AssertRC(rc); 456 } 457 *pu32 = pThis->regStatus; 458 parallelR3IrqClear(pThis); 459 #endif 460 break; 461 case 2: 484 462 #ifndef IN_RING3 485 463 rc = VINF_IOM_R3_IOPORT_READ; 486 464 #else 487 if (RT_LIKELY(pThis->pDrvHostParallelConnector)) 488 { 489 rc = pThis->pDrvHostParallelConnector->pfnRead(pThis->pDrvHostParallelConnector, &pThis->regEppAddr, 490 1, PDM_PARALLEL_PORT_MODE_EPP_ADDR); 491 Log(("Read EPP address 0x%X\n", pThis->regEppAddr)); 492 AssertRC(rc); 493 } 494 *pu32 = pThis->regEppAddr; 495 #endif 496 break; 497 case 4: 465 rc = pThis->pDrvHostParallelConnector->pfnReadControl(pThis->pDrvHostParallelConnector, &pThis->regControl); 466 AssertRC(rc); 467 pThis->regControl |= LPT_CONTROL_BIT6 | LPT_CONTROL_BIT7; 468 *pu32 = pThis->regControl; 469 #endif 470 break; 471 case 3: 498 472 #ifndef IN_RING3 499 473 rc = VINF_IOM_R3_IOPORT_READ; 500 474 #else 501 if (RT_LIKELY(pThis->pDrvHostParallelConnector)) 502 { 503 rc = pThis->pDrvHostParallelConnector->pfnRead(pThis->pDrvHostParallelConnector, &pThis->regEppData, 504 1, PDM_PARALLEL_PORT_MODE_EPP_DATA); 505 Log(("Read EPP data 0x%X\n", pThis->regEppData)); 506 AssertRC(rc); 507 } 508 *pu32 = pThis->regEppData; 509 #endif 510 break; 511 case 5: 512 break; 513 case 6: 514 break; 515 case 7: 516 break; 517 } 518 PDMCritSectLeave(&pThis->CritSect); 475 if (RT_LIKELY(pThis->pDrvHostParallelConnector)) 476 { 477 rc = pThis->pDrvHostParallelConnector->pfnRead(pThis->pDrvHostParallelConnector, &pThis->regEppAddr, 478 1, PDM_PARALLEL_PORT_MODE_EPP_ADDR); 479 Log(("Read EPP address 0x%X\n", pThis->regEppAddr)); 480 AssertRC(rc); 481 } 482 *pu32 = pThis->regEppAddr; 483 #endif 484 break; 485 case 4: 486 #ifndef IN_RING3 487 rc = VINF_IOM_R3_IOPORT_READ; 488 #else 489 if (RT_LIKELY(pThis->pDrvHostParallelConnector)) 490 { 491 rc = pThis->pDrvHostParallelConnector->pfnRead(pThis->pDrvHostParallelConnector, &pThis->regEppData, 492 1, PDM_PARALLEL_PORT_MODE_EPP_DATA); 493 Log(("Read EPP data 0x%X\n", pThis->regEppData)); 494 AssertRC(rc); 495 } 496 *pu32 = pThis->regEppData; 497 #endif 498 break; 499 case 5: 500 break; 501 case 6: 502 break; 503 case 7: 504 break; 519 505 } 520 506 } … … 536 522 if (cb == 1) 537 523 { 538 rc = PDMCritSectEnter(&pThis->CritSect, VINF_IOM_R3_IOPORT_WRITE); 539 if (rc == VINF_SUCCESS) 540 { 541 Log2(("%s: ecp port %#06x val %#04x\n", __FUNCTION__, Port, u32)); 542 rc = parallel_ioport_write_ecp (pThis, Port, u32); 543 PDMCritSectLeave(&pThis->CritSect); 544 } 524 Log2(("%s: ecp port %#06x val %#04x\n", __FUNCTION__, Port, u32)); 525 rc = parallel_ioport_write_ecp (pThis, Port, u32); 545 526 } 546 527 else … … 560 541 if (cb == 1) 561 542 { 562 rc = PDMCritSectEnter(&pThis->CritSect, VINF_IOM_R3_IOPORT_READ); 563 if (rc == VINF_SUCCESS) 564 { 565 *pu32 = parallel_ioport_read_ecp (pThis, Port, &rc); 566 Log2(("%s: ecp port %#06x val %#04x\n", __FUNCTION__, Port, *pu32)); 567 PDMCritSectLeave(&pThis->CritSect); 568 } 543 *pu32 = parallel_ioport_read_ecp (pThis, Port, &rc); 544 Log2(("%s: ecp port %#06x val %#04x\n", __FUNCTION__, Port, *pu32)); 569 545 } 570 546 else … … 671 647 672 648 /** 673 * @interface_method_impl{PDMDEVREG,pfnDestruct}674 */675 static DECLCALLBACK(int) parallelR3Destruct(PPDMDEVINS pDevIns)676 {677 PARALLELPORT *pThis = PDMINS_2_DATA(pDevIns, PARALLELPORT *);678 PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns);679 680 PDMR3CritSectDelete(&pThis->CritSect);681 682 return VINF_SUCCESS;683 }684 685 686 /**687 649 * @interface_method_impl{PDMDEVREG,pfnConstruct} 688 650 */ … … 696 658 697 659 /* 698 * Init the data so parallelR3Destruct doesn't choke.660 * Init the data. 699 661 */ 700 662 pThis->pDevInsR3 = pDevIns; … … 740 702 return PDMDEV_SET_ERROR(pDevIns, rc, 741 703 N_("Configuration error: Failed to get the \"IOBase\" value")); 742 743 /*744 * Initialize critical section and event semaphore.745 * This must of course be done before attaching drivers or anything else which can call us back..746 */747 rc = PDMDevHlpCritSectInit(pDevIns, &pThis->CritSect, RT_SRC_POS, "Parallel#%u", iInstance);748 if (RT_FAILURE(rc))749 return rc;750 704 751 705 /* … … 862 816 parallelR3Construct, 863 817 /* pfnDestruct */ 864 parallelR3Destruct,818 NULL, 865 819 /* pfnRelocate */ 866 820 parallelR3Relocate,
Note:
See TracChangeset
for help on using the changeset viewer.