- Timestamp:
- Nov 22, 2019 11:42:56 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 134930
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Parallel/DevParallel.cpp
r81591 r82120 90 90 *********************************************************************************************************************************/ 91 91 /** 92 * Parallel device state.92 * The shared parallel device state. 93 93 * 94 94 * @implements PDMIBASE … … 98 98 { 99 99 /** Pointer to the device instance - R3 Ptr */ 100 PPDMDEVINSR3 pDevInsR3;100 PPDMDEVINSR3 pDevInsR3; 101 101 /** Pointer to the device instance - R0 Ptr */ 102 PPDMDEVINSR0 pDevInsR0;102 PPDMDEVINSR0 pDevInsR0; 103 103 /** Pointer to the device instance - RC Ptr */ 104 PPDMDEVINSRC pDevInsRC;104 PPDMDEVINSRC pDevInsRC; 105 105 /** Alignment. */ 106 RTRCPTR Alignment0;106 RTRCPTR RCPtrAlignment0; 107 107 /** LUN\#0: The base interface. */ 108 PDMIBASE IBase;108 PDMIBASE IBase; 109 109 /** LUN\#0: The host device port interface. */ 110 PDMIHOSTPARALLELPORT IHostParallelPort;110 PDMIHOSTPARALLELPORT IHostParallelPort; 111 111 /** Pointer to the attached base driver. */ 112 R3PTRTYPE(PPDMIBASE) pDrvBase;112 R3PTRTYPE(PPDMIBASE) pDrvBase; 113 113 /** Pointer to the attached host device. */ 114 R3PTRTYPE(PPDMIHOSTPARALLELCONNECTOR) pDrvHostParallelConnector; 115 /** Flag whether the device has its RC component enabled. */ 116 bool fGCEnabled; 117 /** Flag whether the device has its R0 component enabled. */ 118 bool fR0Enabled; 114 R3PTRTYPE(PPDMIHOSTPARALLELCONNECTOR) pDrvHostParallelConnector; 119 115 /** Flag whether an EPP timeout occurred (error handling). */ 120 bool fEppTimeout; 116 bool fEppTimeout; 117 bool fAlignment1; 121 118 /** Base I/O port of the parallel port. */ 122 RTIOPORT 119 RTIOPORT IOBase; 123 120 /** IRQ number assigned ot the parallel port. */ 124 int 121 int32_t iIrq; 125 122 /** Data register. */ 126 uint8_t 123 uint8_t regData; 127 124 /** Status register. */ 128 uint8_t 125 uint8_t regStatus; 129 126 /** Control register. */ 130 uint8_t 127 uint8_t regControl; 131 128 /** EPP address register. */ 132 uint8_t 129 uint8_t regEppAddr; 133 130 /** EPP data register. */ 134 uint8_t 131 uint8_t regEppData; 135 132 /** More alignment. */ 136 uint 32_t u32Alignment;133 uint8_t abAlignment2[3]; 137 134 138 135 #if 0 /* Data for ECP implementation, currently unused. */ 139 uint8_t 140 uint8_t 141 uint8_t 136 uint8_t reg_ecp_ecr; 137 uint8_t reg_ecp_base_plus_400h; /* has different meanings */ 138 uint8_t reg_ecp_config_b; 142 139 143 140 /** The ECP FIFO implementation*/ 144 uint8_t ecp_fifo[LPT_ECP_FIFO_DEPTH]; 145 uint8_t abAlignemnt[2]; 146 int act_fifo_pos_write; 147 int act_fifo_pos_read; 148 #endif 149 } PARALLELPORT, *PPARALLELPORT; 141 uint8_t ecp_fifo[LPT_ECP_FIFO_DEPTH]; 142 uint8_t abAlignemnt[3]; 143 int32_t act_fifo_pos_write; 144 int32_t act_fifo_pos_read; 145 #endif 146 } PARALLELPORT; 147 /** Pointer to the shared parallel device state. */ 148 typedef PARALLELPORT *PPARALLELPORT; 150 149 151 150 #ifndef VBOX_DEVICE_STRUCT_TESTCASE … … 428 427 PDMBOTHCBDECL(int) parallelIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t *pu32, unsigned cb) 429 428 { 430 P ARALLELPORT *pThis = PDMDEVINS_2_DATA(pDevIns, PARALLELPORT *);429 PPARALLELPORT pThis = PDMDEVINS_2_DATA(pDevIns, PPARALLELPORT); 431 430 int rc = VINF_SUCCESS; 432 431 RT_NOREF_PV(pvUser); … … 531 530 PDMBOTHCBDECL(int) parallelIOPortWriteECP(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb) 532 531 { 533 P ARALLELPORT *pThis = PDMDEVINS_2_DATA(pDevIns, PARALLELPORT *);532 PPARALLELPORT pThis = PDMDEVINS_2_DATA(pDevIns, PPARALLELPORT); 534 533 int rc = VINF_SUCCESS; 535 534 … … 550 549 PDMBOTHCBDECL(int) parallelIOPortReadECP(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb) 551 550 { 552 P ARALLELPORT *pThis = PDMDEVINS_2_DATA(pDevIns, PARALLELPORT *);551 PPARALLELPORT pThis = PDMDEVINS_2_DATA(pDevIns, PPARALLELPORT); 553 552 int rc = VINF_SUCCESS; 554 553 … … 572 571 static DECLCALLBACK(int) parallelR3LiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass) 573 572 { 573 PPARALLELPORT pThis = PDMDEVINS_2_DATA(pDevIns, PPARALLELPORT); 574 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 574 575 RT_NOREF(uPass); 575 PARALLELPORT *pThis = PDMDEVINS_2_DATA(pDevIns, PARALLELPORT *); 576 577 SSMR3PutS32(pSSM, pThis->iIrq); 578 SSMR3PutU32(pSSM, pThis->IOBase); 579 SSMR3PutU32(pSSM, UINT32_MAX); /* sanity/terminator */ 576 577 pHlp->pfnSSMPutS32(pSSM, pThis->iIrq); 578 pHlp->pfnSSMPutU32(pSSM, pThis->IOBase); 579 pHlp->pfnSSMPutU32(pSSM, UINT32_MAX); /* sanity/terminator */ 580 580 return VINF_SSM_DONT_CALL_AGAIN; 581 581 } … … 587 587 static DECLCALLBACK(int) parallelR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 588 588 { 589 PARALLELPORT *pThis = PDMDEVINS_2_DATA(pDevIns, PARALLELPORT *); 590 591 SSMR3PutU8(pSSM, pThis->regData); 592 SSMR3PutU8(pSSM, pThis->regStatus); 593 SSMR3PutU8(pSSM, pThis->regControl); 589 PPARALLELPORT pThis = PDMDEVINS_2_DATA(pDevIns, PPARALLELPORT); 590 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 591 592 pHlp->pfnSSMPutU8(pSSM, pThis->regData); 593 pHlp->pfnSSMPutU8(pSSM, pThis->regStatus); 594 pHlp->pfnSSMPutU8(pSSM, pThis->regControl); 594 595 595 596 parallelR3LiveExec(pDevIns, pSSM, 0); … … 603 604 static DECLCALLBACK(int) parallelR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 604 605 { 605 PARALLELPORT *pThis = PDMDEVINS_2_DATA(pDevIns, PARALLELPORT *); 606 PPARALLELPORT pThis = PDMDEVINS_2_DATA(pDevIns, PPARALLELPORT); 607 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 606 608 607 609 AssertMsgReturn(uVersion == PARALLEL_SAVED_STATE_VERSION, ("%d\n", uVersion), VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION); … … 609 611 if (uPass == SSM_PASS_FINAL) 610 612 { 611 SSMR3GetU8(pSSM, &pThis->regData);612 SSMR3GetU8(pSSM, &pThis->regStatus);613 SSMR3GetU8(pSSM, &pThis->regControl);613 pHlp->pfnSSMGetU8(pSSM, &pThis->regData); 614 pHlp->pfnSSMGetU8(pSSM, &pThis->regStatus); 615 pHlp->pfnSSMGetU8(pSSM, &pThis->regControl); 614 616 } 615 617 616 618 /* the config */ 617 619 int32_t iIrq; 618 SSMR3GetS32(pSSM, &iIrq);620 pHlp->pfnSSMGetS32(pSSM, &iIrq); 619 621 uint32_t uIoBase; 620 SSMR3GetU32(pSSM, &uIoBase);622 pHlp->pfnSSMGetU32(pSSM, &uIoBase); 621 623 uint32_t u32; 622 int rc = SSMR3GetU32(pSSM, &u32);624 int rc = pHlp->pfnSSMGetU32(pSSM, &u32); 623 625 if (RT_FAILURE(rc)) 624 626 return rc; … … 626 628 627 629 if (pThis->iIrq != iIrq) 628 return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("IRQ changed: config=%#x state=%#x"), pThis->iIrq, iIrq);630 return pHlp->pfnSSMSetCfgError(pSSM, RT_SRC_POS, N_("IRQ changed: config=%#x state=%#x"), pThis->iIrq, iIrq); 629 631 630 632 if (pThis->IOBase != uIoBase) 631 return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("IOBase changed: config=%#x state=%#x"), pThis->IOBase, uIoBase);633 return pHlp->pfnSSMSetCfgError(pSSM, RT_SRC_POS, N_("IOBase changed: config=%#x state=%#x"), pThis->IOBase, uIoBase); 632 634 633 635 /* not necessary... but it doesn't harm. */ … … 656 658 static DECLCALLBACK(void) parallelR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta) 657 659 { 658 P ARALLELPORT *pThis = PDMDEVINS_2_DATA(pDevIns, PARALLELPORT *);660 PPARALLELPORT pThis = PDMDEVINS_2_DATA(pDevIns, PPARALLELPORT); 659 661 pThis->pDevInsRC += offDelta; 660 662 } … … 667 669 { 668 670 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 669 int rc; 670 PARALLELPORT *pThis = PDMDEVINS_2_DATA(pDevIns, PARALLELPORT*); 671 PPARALLELPORT pThis = PDMDEVINS_2_DATA(pDevIns, PPARALLELPORT); 672 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 673 int rc; 671 674 672 675 Assert(iInstance < 4); … … 696 699 * Validate and read the configuration. 697 700 */ 698 if (!CFGMR3AreValuesValid(pCfg, "IRQ\0" "IOBase\0" "GCEnabled\0" "R0Enabled\0")) 699 return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES, 700 N_("Configuration error: Unknown config key")); 701 702 rc = CFGMR3QueryBoolDef(pCfg, "GCEnabled", &pThis->fGCEnabled, false); 701 PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "IRQ|IOBase", ""); 702 703 rc = pHlp->pfnCFGMQueryS32Def(pCfg, "IRQ", &pThis->iIrq, 7); 703 704 if (RT_FAILURE(rc)) 704 return PDMDEV_SET_ERROR(pDevIns, rc, 705 N_("Configuration error: Failed to get the \"GCEnabled\" value")); 706 707 rc = CFGMR3QueryBoolDef(pCfg, "R0Enabled", &pThis->fR0Enabled, false); 705 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to get the \"IRQ\" value")); 706 707 rc = pHlp->pfnCFGMQueryU16Def(pCfg, "IOBase", &pThis->IOBase, 0x378); 708 708 if (RT_FAILURE(rc)) 709 return PDMDEV_SET_ERROR(pDevIns, rc, 710 N_("Configuration error: Failed to get the \"R0Enabled\" value")); 711 rc = CFGMR3QueryS32Def(pCfg, "IRQ", &pThis->iIrq, 7); 712 if (RT_FAILURE(rc)) 713 return PDMDEV_SET_ERROR(pDevIns, rc, 714 N_("Configuration error: Failed to get the \"IRQ\" value")); 715 rc = CFGMR3QueryU16Def(pCfg, "IOBase", &pThis->IOBase, 0x378); 716 if (RT_FAILURE(rc)) 717 return PDMDEV_SET_ERROR(pDevIns, rc, 718 N_("Configuration error: Failed to get the \"IOBase\" value")); 719 720 int port_count = (pThis->IOBase == 0x3BC) ? 4 : 8; 709 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to get the \"IOBase\" value")); 710 711 int cPorts = (pThis->IOBase == 0x3BC) ? 4 : 8; 721 712 /* 722 713 * Register the I/O ports and saved state. 723 714 */ 724 rc = PDMDevHlpIOPortRegister(pDevIns, pThis->IOBase, port_count, 0,715 rc = PDMDevHlpIOPortRegister(pDevIns, pThis->IOBase, cPorts, 0, 725 716 parallelIOPortWrite, parallelIOPortRead, 726 717 NULL, NULL, "Parallel"); 727 if (RT_FAILURE(rc)) 728 return rc; 718 AssertRCReturn(rc, rc); 729 719 730 720 #if 0 … … 733 723 parallelIOPortWriteECP, parallelIOPortReadECP, 734 724 NULL, NULL, "PARALLEL ECP"); 735 if (RT_FAILURE(rc)) 736 return rc; 737 #endif 738 739 if (pThis->fGCEnabled) 740 { 741 rc = PDMDevHlpIOPortRegisterRC(pDevIns, pThis->IOBase, port_count, 0, "parallelIOPortWrite", 725 AssertRCReturn(rc, rc); 726 #endif 727 728 if (pDevIns->fRCEnabled) 729 { 730 rc = PDMDevHlpIOPortRegisterRC(pDevIns, pThis->IOBase, cPorts, 0, "parallelIOPortWrite", 742 731 "parallelIOPortRead", NULL, NULL, "Parallel"); 743 732 if (RT_FAILURE(rc)) … … 745 734 746 735 #if 0 747 rc = PDMDevHlpIOPortRegisterGC(pDevIns, io_base+0x400, port_count, 0, "parallelIOPortWriteECP",736 rc = PDMDevHlpIOPortRegisterGC(pDevIns, io_base+0x400, cPorts, 0, "parallelIOPortWriteECP", 748 737 "parallelIOPortReadECP", NULL, NULL, "Parallel Ecp"); 749 738 if (RT_FAILURE(rc)) … … 752 741 } 753 742 754 if (p This->fR0Enabled)755 { 756 rc = PDMDevHlpIOPortRegisterR0(pDevIns, pThis->IOBase, port_count, 0, "parallelIOPortWrite",743 if (pDevIns->fR0Enabled) 744 { 745 rc = PDMDevHlpIOPortRegisterR0(pDevIns, pThis->IOBase, cPorts, 0, "parallelIOPortWrite", 757 746 "parallelIOPortRead", NULL, NULL, "Parallel"); 758 747 if (RT_FAILURE(rc)) … … 769 758 rc = PDMDevHlpSSMRegister3(pDevIns, PARALLEL_SAVED_STATE_VERSION, sizeof(*pThis), 770 759 parallelR3LiveExec, parallelR3SaveExec, parallelR3LoadExec); 771 if (RT_FAILURE(rc)) 772 return rc; 760 AssertRCReturn(rc, rc); 773 761 774 762
Note:
See TracChangeset
for help on using the changeset viewer.