Changeset 82121 in vbox
- Timestamp:
- Nov 22, 2019 11:55:59 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 134931
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Parallel/DevParallel.cpp
r82120 r82121 25 25 #define LOG_GROUP LOG_GROUP_DEV_PARALLEL 26 26 #include <VBox/vmm/pdmdev.h> 27 #include <VBox/AssertGuest.h> 27 28 #include <iprt/assert.h> 28 29 #include <iprt/uuid.h> … … 144 145 int32_t act_fifo_pos_read; 145 146 #endif 147 /** Handle to the regular I/O ports. */ 148 IOMIOPORTHANDLE hIoPorts; 149 /** Handle to the ECP I/O ports. */ 150 IOMIOPORTHANDLE hIoPortsEcp; 146 151 } PARALLELPORT; 147 152 /** Pointer to the shared parallel device state. */ … … 153 158 #define PDMIHOSTDEVICEPORT_2_PARALLELPORT(pInstance) ( (PARALLELPORT *)((uintptr_t)(pInterface) - RT_UOFFSETOF(PARALLELPORT, IHostDevicePort)) ) 154 159 #define PDMIBASE_2_PARALLELPORT(pInstance) ( (PARALLELPORT *)((uintptr_t)(pInterface) - RT_UOFFSETOF(PARALLELPORT, IBase)) ) 155 156 157 /*********************************************************************************************************************************158 * Internal Functions *159 *********************************************************************************************************************************/160 RT_C_DECLS_BEGIN161 PDMBOTHCBDECL(int) parallelIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t *pu32, unsigned cb);162 PDMBOTHCBDECL(int) parallelIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t u32, unsigned cb);163 #if 0164 PDMBOTHCBDECL(int) parallelIOPortReadECP(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb);165 PDMBOTHCBDECL(int) parallelIOPortWriteECP(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb);166 #endif167 RT_C_DECLS_END168 160 169 161 … … 316 308 317 309 /** 318 * @callback_method_impl{FNIOMIOPORTOUT} 319 */ 320 PDMBOTHCBDECL(int) parallelIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t u32, unsigned cb) 310 * @callback_method_impl{FNIOMIOPORTNEWOUT} 311 */ 312 static DECLCALLBACK(VBOXSTRICTRC) 313 parallelIoPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb) 321 314 { 322 315 PARALLELPORT *pThis = PDMDEVINS_2_DATA(pDevIns, PPARALLELPORT); 323 int rc= VINF_SUCCESS;316 VBOXSTRICTRC rc = VINF_SUCCESS; 324 317 RT_NOREF_PV(pvUser); 325 318 … … 328 321 uint8_t u8 = u32; 329 322 330 Log2(("%s: port %#06x val %#04x\n", __FUNCTION__, uPort, u32));331 332 uPort &= 7;333 switch ( uPort)323 Log2(("%s: Port=%#06x+%x val %#04x\n", __FUNCTION__, pThis->IOBase, offPort, u32)); 324 325 offPort &= 7; 326 switch (offPort) 334 327 { 335 328 case 0: … … 416 409 } 417 410 else 418 A ssertMsgFailed(("Port=%#x cb=%d u32=%#x\n", uPort, cb, u32));411 ASSERT_GUEST_MSG_FAILED(("Port=%#x+%x cb=%d u32=%#x\n", pThis->IOBase, offPort, cb, u32)); 419 412 420 413 return rc; … … 423 416 424 417 /** 425 * @callback_method_impl{FNIOMIOPORTIN} 426 */ 427 PDMBOTHCBDECL(int) parallelIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t *pu32, unsigned cb) 418 * @callback_method_impl{FNIOMIOPORTNEWIN} 419 */ 420 static DECLCALLBACK(VBOXSTRICTRC) 421 parallelIoPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb) 428 422 { 429 423 PPARALLELPORT pThis = PDMDEVINS_2_DATA(pDevIns, PPARALLELPORT); 430 int rc= VINF_SUCCESS;424 VBOXSTRICTRC rc = VINF_SUCCESS; 431 425 RT_NOREF_PV(pvUser); 432 426 433 427 if (cb == 1) 434 428 { 435 uPort &= 7;436 switch ( uPort)429 offPort &= 7; 430 switch (offPort) 437 431 { 438 432 case 0: … … 449 443 1, PDM_PARALLEL_PORT_MODE_SPP); 450 444 Log(("Read data lines 0x%X\n", pThis->regData)); 451 AssertRC( rc);445 AssertRC(VBOXSTRICTRC_VAL(rc)); 452 446 } 453 447 *pu32 = pThis->regData; … … 462 456 { 463 457 rc = pThis->pDrvHostParallelConnector->pfnReadStatus(pThis->pDrvHostParallelConnector, &pThis->regStatus); 464 AssertRC( rc);458 AssertRC(VBOXSTRICTRC_VAL(rc)); 465 459 } 466 460 *pu32 = pThis->regStatus; … … 475 469 { 476 470 rc = pThis->pDrvHostParallelConnector->pfnReadControl(pThis->pDrvHostParallelConnector, &pThis->regControl); 477 AssertRC( rc);471 AssertRC(VBOXSTRICTRC_VAL(rc)); 478 472 pThis->regControl |= LPT_CONTROL_BIT6 | LPT_CONTROL_BIT7; 479 473 } … … 491 485 1, PDM_PARALLEL_PORT_MODE_EPP_ADDR); 492 486 Log(("Read EPP address 0x%X\n", pThis->regEppAddr)); 493 AssertRC( rc);487 AssertRC(VBOXSTRICTRC_VAL(rc)); 494 488 } 495 489 *pu32 = pThis->regEppAddr; … … 505 499 1, PDM_PARALLEL_PORT_MODE_EPP_DATA); 506 500 Log(("Read EPP data 0x%X\n", pThis->regEppData)); 507 AssertRC( rc);501 AssertRC(VBOXSTRICTRC_VAL(rc)); 508 502 } 509 503 *pu32 = pThis->regEppData; … … 526 520 #if 0 527 521 /** 528 * @callback_method_impl{FNIOMIOPORTOUT, ECP registers.} 529 */ 530 PDMBOTHCBDECL(int) parallelIOPortWriteECP(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb) 531 { 532 PPARALLELPORT pThis = PDMDEVINS_2_DATA(pDevIns, PPARALLELPORT); 533 int rc = VINF_SUCCESS; 522 * @callback_method_impl{FNIOMIOPORTNEWOUT, ECP registers.} 523 */ 524 static DECLCALLBACK(VBOXSTRICTRC) 525 parallelIoPortWriteECP(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb) 526 { 527 PPARALLELPORT pThis = PDMDEVINS_2_DATA(pDevIns, PPARALLELPORT); 528 VBOXSTRICTRC rc = VINF_SUCCESS; 534 529 535 530 if (cb == 1) 536 531 { 537 Log2(("%s: ecp port %#06x val %#04x\n", __FUNCTION__,Port, u32));538 rc = parallel_ioport_write_ecp 532 Log2(("%s: ecp port %#06x+%x val %#04x\n", __FUNCTION__, pThis->IOBase + 0x400, offPort, u32)); 533 rc = parallel_ioport_write_ecp(pThis, Port, u32); 539 534 } 540 535 else 541 A ssertMsgFailed(("Port=%#x cb=%d u32=%#x\n", Port, cb, u32));536 ASSERT_GUEST_MSG_FAILED(("Port=%#x cb=%d u32=%#x\n", Port, cb, u32)); 542 537 543 538 return rc; … … 545 540 546 541 /** 547 * @callback_method_impl{FNIOMIOPORTOUT, ECP registers.} 548 */ 549 PDMBOTHCBDECL(int) parallelIOPortReadECP(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb) 550 { 551 PPARALLELPORT pThis = PDMDEVINS_2_DATA(pDevIns, PPARALLELPORT); 552 int rc = VINF_SUCCESS; 542 * @callback_method_impl{FNIOMIOPORTNEWOUT, ECP registers.} 543 */ 544 static DECLCALLBACK(VBOXSTRICTRC) 545 parallelIoPortReadECP(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb) 546 { 547 PPARALLELPORT pThis = PDMDEVINS_2_DATA(pDevIns, PPARALLELPORT); 548 VBOXSTRICTRC rc = VINF_SUCCESS; 553 549 554 550 if (cb == 1) 555 551 { 556 *pu32 = parallel_ioport_read_ecp 557 Log2(("%s: ecp port %#06x val %#04x\n", __FUNCTION__,Port, *pu32));552 *pu32 = parallel_ioport_read_ecp(pThis, Port, &rc); 553 Log2(("%s: ecp port %#06x+%x val %#04x\n", __FUNCTION__, pThis->IOBase + 0x400, offPort, *pu32)); 558 554 } 559 555 else … … 623 619 uint32_t u32; 624 620 int rc = pHlp->pfnSSMGetU32(pSSM, &u32); 625 if (RT_FAILURE(rc)) 626 return rc; 621 AssertRCReturn(rc, rc); 627 622 AssertMsgReturn(u32 == UINT32_MAX, ("%#x\n", u32), VERR_SSM_DATA_UNIT_FORMAT_CHANGED); 628 623 … … 713 708 * Register the I/O ports and saved state. 714 709 */ 715 rc = PDMDevHlpIOPortRegister(pDevIns, pThis->IOBase, cPorts, 0, 716 parallelIOPortWrite, parallelIOPortRead, 717 NULL, NULL, "Parallel"); 710 rc = PDMDevHlpIoPortCreateAndMap(pDevIns, pThis->IOBase, cPorts, parallelIoPortWrite, parallelIoPortRead, 711 "Parallel", NULL /*paExtDesc*/, &pThis->hIoPorts); 718 712 AssertRCReturn(rc, rc); 719 713 720 714 #if 0 721 715 /* register ecp registers */ 722 rc = PDMDevHlpIOPortRegister(pDevIns, io_base+0x400, 8, 0, 723 parallelIOPortWriteECP, parallelIOPortReadECP, 724 NULL, NULL, "PARALLEL ECP"); 716 rc = PDMDevHlpIoPortCreateAndMap(pDevIns, pThis->IOBase + 0x400, 8, parallelIoPortWriteECP, parallelIoPortReadECP, 717 "Parallel ECP", NULL /*paExtDesc*/, &pThis->hIoPortsEcp); 725 718 AssertRCReturn(rc, rc); 726 719 #endif 727 720 728 if (pDevIns->fRCEnabled)729 {730 rc = PDMDevHlpIOPortRegisterRC(pDevIns, pThis->IOBase, cPorts, 0, "parallelIOPortWrite",731 "parallelIOPortRead", NULL, NULL, "Parallel");732 if (RT_FAILURE(rc))733 return rc;734 735 #if 0736 rc = PDMDevHlpIOPortRegisterGC(pDevIns, io_base+0x400, cPorts, 0, "parallelIOPortWriteECP",737 "parallelIOPortReadECP", NULL, NULL, "Parallel Ecp");738 if (RT_FAILURE(rc))739 return rc;740 #endif741 }742 743 if (pDevIns->fR0Enabled)744 {745 rc = PDMDevHlpIOPortRegisterR0(pDevIns, pThis->IOBase, cPorts, 0, "parallelIOPortWrite",746 "parallelIOPortRead", NULL, NULL, "Parallel");747 if (RT_FAILURE(rc))748 return rc;749 750 #if 0751 rc = PDMDevHlpIOPortRegisterR0(pDevIns, io_base+0x400, 8, 0, "parallelIOPortWriteECP",752 "parallelIOPortReadECP", NULL, NULL, "Parallel Ecp");753 if (RT_FAILURE(rc))754 return rc;755 #endif756 }757 721 758 722 rc = PDMDevHlpSSMRegister3(pDevIns, PARALLEL_SAVED_STATE_VERSION, sizeof(*pThis), … … 795 759 } 796 760 797 #endif /* IN_RING3 */ 761 #else /* !IN_RING3 */ 762 763 /** 764 * @callback_method_impl{PDMDEVREGR0,pfnConstruct} 765 */ 766 static DECLCALLBACK(int) parallelRZConstruct(PPDMDEVINS pDevIns) 767 { 768 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 769 PPARALLELPORT pThis = PDMDEVINS_2_DATA(pDevIns, PPARALLELPORT); 770 771 int rc = PDMDevHlpIoPortSetUpContext(pDevIns, pThis->hIoPorts, parallelIoPortWrite, parallelIoPortRead, NULL /*pvUser*/); 772 AssertRCReturn(rc, rc); 773 774 # if 0 775 rc = PDMDevHlpIoPortSetUpContext(pDevIns, pThis->hIoPortsEcp, parallelIoPortWriteECP, parallelIoPortReadECP, NULL /*pvUser*/); 776 AssertRCReturn(rc, rc); 777 # endif 778 779 return VINF_SUCCESS; 780 } 781 782 #endif /* !IN_RING3 */ 798 783 799 784 /** … … 842 827 #elif defined(IN_RING0) 843 828 /* .pfnEarlyConstruct = */ NULL, 844 /* .pfnConstruct = */ NULL,829 /* .pfnConstruct = */ parallelRZConstruct, 845 830 /* .pfnDestruct = */ NULL, 846 831 /* .pfnFinalDestruct = */ NULL, … … 855 840 /* .pfnReserved7 = */ NULL, 856 841 #elif defined(IN_RC) 857 /* .pfnConstruct = */ NULL,842 /* .pfnConstruct = */ parallelRZConstruct, 858 843 /* .pfnReserved0 = */ NULL, 859 844 /* .pfnReserved1 = */ NULL,
Note:
See TracChangeset
for help on using the changeset viewer.