Changeset 11269 in vbox for trunk/src/VBox/Devices/Parallel
- Timestamp:
- Aug 8, 2008 4:24:48 PM (16 years ago)
- Location:
- trunk/src/VBox/Devices/Parallel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Parallel/DevParallel.cpp
r11267 r11269 402 402 static DECLCALLBACK(int) parallelNotifyInterrupt(PPDMIHOSTPARALLELPORT pInterface) 403 403 { 404 ParallelState *p Data= PDMIHOSTPARALLELPORT_2_PARALLELSTATE(pInterface);405 406 PDMCritSectEnter(&p Data->CritSect, VINF_SUCCESS);407 parallel_set_irq(p Data);408 PDMCritSectLeave(&p Data->CritSect);404 ParallelState *pThis = PDMIHOSTPARALLELPORT_2_PARALLELSTATE(pInterface); 405 406 PDMCritSectEnter(&pThis->CritSect, VINF_SUCCESS); 407 parallel_set_irq(pThis); 408 PDMCritSectLeave(&pThis->CritSect); 409 409 410 410 return VINF_SUCCESS; … … 426 426 RTIOPORT Port, uint32_t u32, unsigned cb) 427 427 { 428 ParallelState *p Data= PDMINS_2_DATA(pDevIns, ParallelState *);428 ParallelState *pThis = PDMINS_2_DATA(pDevIns, ParallelState *); 429 429 int rc = VINF_SUCCESS; 430 430 431 431 if (cb == 1) 432 432 { 433 rc = PDMCritSectEnter(&p Data->CritSect, VINF_IOM_HC_IOPORT_WRITE);433 rc = PDMCritSectEnter(&pThis->CritSect, VINF_IOM_HC_IOPORT_WRITE); 434 434 if (rc == VINF_SUCCESS) 435 435 { 436 436 Log2(("%s: port %#06x val %#04x\n", __FUNCTION__, Port, u32)); 437 rc = parallel_ioport_write (p Data, Port, u32);438 PDMCritSectLeave(&p Data->CritSect);437 rc = parallel_ioport_write (pThis, Port, u32); 438 PDMCritSectLeave(&pThis->CritSect); 439 439 } 440 440 } … … 459 459 RTIOPORT Port, uint32_t *pu32, unsigned cb) 460 460 { 461 ParallelState *p Data= PDMINS_2_DATA(pDevIns, ParallelState *);461 ParallelState *pThis = PDMINS_2_DATA(pDevIns, ParallelState *); 462 462 int rc = VINF_SUCCESS; 463 463 464 464 if (cb == 1) 465 465 { 466 rc = PDMCritSectEnter(&p Data->CritSect, VINF_IOM_HC_IOPORT_READ);466 rc = PDMCritSectEnter(&pThis->CritSect, VINF_IOM_HC_IOPORT_READ); 467 467 if (rc == VINF_SUCCESS) 468 468 { 469 *pu32 = parallel_ioport_read (p Data, Port, &rc);469 *pu32 = parallel_ioport_read (pThis, Port, &rc); 470 470 Log2(("%s: port %#06x val %#04x\n", __FUNCTION__, Port, *pu32)); 471 PDMCritSectLeave(&p Data->CritSect);471 PDMCritSectLeave(&pThis->CritSect); 472 472 } 473 473 } … … 493 493 RTIOPORT Port, uint32_t u32, unsigned cb) 494 494 { 495 ParallelState *p Data= PDMINS_2_DATA(pDevIns, ParallelState *);495 ParallelState *pThis = PDMINS_2_DATA(pDevIns, ParallelState *); 496 496 int rc = VINF_SUCCESS; 497 497 498 498 if (cb == 1) 499 499 { 500 rc = PDMCritSectEnter(&p Data->CritSect, VINF_IOM_HC_IOPORT_WRITE);500 rc = PDMCritSectEnter(&pThis->CritSect, VINF_IOM_HC_IOPORT_WRITE); 501 501 if (rc == VINF_SUCCESS) 502 502 { 503 503 Log2(("%s: ecp port %#06x val %#04x\n", __FUNCTION__, Port, u32)); 504 rc = parallel_ioport_write_ecp (p Data, Port, u32);505 PDMCritSectLeave(&p Data->CritSect);504 rc = parallel_ioport_write_ecp (pThis, Port, u32); 505 PDMCritSectLeave(&pThis->CritSect); 506 506 } 507 507 } … … 526 526 RTIOPORT Port, uint32_t *pu32, unsigned cb) 527 527 { 528 ParallelState *p Data= PDMINS_2_DATA(pDevIns, ParallelState *);528 ParallelState *pThis = PDMINS_2_DATA(pDevIns, ParallelState *); 529 529 int rc = VINF_SUCCESS; 530 530 531 531 if (cb == 1) 532 532 { 533 rc = PDMCritSectEnter(&p Data->CritSect, VINF_IOM_HC_IOPORT_READ);533 rc = PDMCritSectEnter(&pThis->CritSect, VINF_IOM_HC_IOPORT_READ); 534 534 if (rc == VINF_SUCCESS) 535 535 { 536 *pu32 = parallel_ioport_read_ecp (p Data, Port, &rc);536 *pu32 = parallel_ioport_read_ecp (pThis, Port, &rc); 537 537 Log2(("%s: ecp port %#06x val %#04x\n", __FUNCTION__, Port, *pu32)); 538 PDMCritSectLeave(&p Data->CritSect);538 PDMCritSectLeave(&pThis->CritSect); 539 539 } 540 540 } … … 557 557 PSSMHANDLE pSSMHandle) 558 558 { 559 ParallelState *p Data= PDMINS_2_DATA(pDevIns, ParallelState *);560 561 SSMR3PutU8(pSSMHandle, p Data->reg_data);562 SSMR3PutU8(pSSMHandle, p Data->reg_status);563 SSMR3PutU8(pSSMHandle, p Data->reg_control);564 SSMR3PutS32(pSSMHandle, p Data->irq);565 SSMR3PutU32(pSSMHandle, p Data->base);559 ParallelState *pThis = PDMINS_2_DATA(pDevIns, ParallelState *); 560 561 SSMR3PutU8(pSSMHandle, pThis->reg_data); 562 SSMR3PutU8(pSSMHandle, pThis->reg_status); 563 SSMR3PutU8(pSSMHandle, pThis->reg_control); 564 SSMR3PutS32(pSSMHandle, pThis->irq); 565 SSMR3PutU32(pSSMHandle, pThis->base); 566 566 567 567 return SSMR3PutU32(pSSMHandle, ~0); /* sanity/terminator */ … … 582 582 int rc; 583 583 uint32_t u32; 584 ParallelState *p Data= PDMINS_2_DATA(pDevIns, ParallelState *);584 ParallelState *pThis = PDMINS_2_DATA(pDevIns, ParallelState *); 585 585 586 586 if (u32Version != PARALLEL_SAVED_STATE_VERSION) … … 590 590 } 591 591 592 SSMR3GetU8(pSSMHandle, &p Data->reg_data);593 SSMR3GetU8(pSSMHandle, &p Data->reg_status);594 SSMR3GetU8(pSSMHandle, &p Data->reg_control);595 SSMR3GetS32(pSSMHandle, &p Data->irq);596 SSMR3GetU32(pSSMHandle, &p Data->base);592 SSMR3GetU8(pSSMHandle, &pThis->reg_data); 593 SSMR3GetU8(pSSMHandle, &pThis->reg_status); 594 SSMR3GetU8(pSSMHandle, &pThis->reg_control); 595 SSMR3GetS32(pSSMHandle, &pThis->irq); 596 SSMR3GetU32(pSSMHandle, &pThis->base); 597 597 598 598 rc = SSMR3GetU32(pSSMHandle, &u32); … … 606 606 } 607 607 608 p Data->pDevInsHC = pDevIns;609 p Data->pDevInsGC = PDMDEVINS_2_GCPTR(pDevIns);608 pThis->pDevInsHC = pDevIns; 609 pThis->pDevInsGC = PDMDEVINS_2_GCPTR(pDevIns); 610 610 return VINF_SUCCESS; 611 611 } … … 617 617 static DECLCALLBACK(void) parallelRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta) 618 618 { 619 ParallelState *p Data= PDMINS_2_DATA(pDevIns, ParallelState *);620 p Data->pDevInsGC += offDelta;619 ParallelState *pThis = PDMINS_2_DATA(pDevIns, ParallelState *); 620 pThis->pDevInsGC += offDelta; 621 621 } 622 622 … … 624 624 static DECLCALLBACK(void *) parallelQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface) 625 625 { 626 ParallelState *p Data= PDMIBASE_2_PARALLELSTATE(pInterface);626 ParallelState *pThis = PDMIBASE_2_PARALLELSTATE(pInterface); 627 627 switch (enmInterface) 628 628 { 629 629 case PDMINTERFACE_BASE: 630 return &p Data->IBase;630 return &pThis->IBase; 631 631 case PDMINTERFACE_HOST_PARALLEL_PORT: 632 return &p Data->IHostParallelPort;632 return &pThis->IHostParallelPort; 633 633 default: 634 634 return NULL; … … 647 647 static DECLCALLBACK(int) parallelDestruct(PPDMDEVINS pDevIns) 648 648 { 649 ParallelState *p Data= PDMINS_2_DATA(pDevIns, ParallelState *);650 651 PDMR3CritSectDelete(&p Data->CritSect);652 RTSemEventDestroy(p Data->ReceiveSem);649 ParallelState *pThis = PDMINS_2_DATA(pDevIns, ParallelState *); 650 651 PDMR3CritSectDelete(&pThis->CritSect); 652 RTSemEventDestroy(pThis->ReceiveSem); 653 653 654 654 return VINF_SUCCESS; … … 674 674 { 675 675 int rc; 676 ParallelState *p Data= PDMINS_2_DATA(pDevIns, ParallelState*);676 ParallelState *pThis = PDMINS_2_DATA(pDevIns, ParallelState*); 677 677 uint16_t io_base; 678 678 uint8_t irq_lvl; … … 680 680 Assert(iInstance < 4); 681 681 682 p Data->pDevInsHC = pDevIns;683 p Data->pDevInsGC = PDMDEVINS_2_GCPTR(pDevIns);682 pThis->pDevInsHC = pDevIns; 683 pThis->pDevInsGC = PDMDEVINS_2_GCPTR(pDevIns); 684 684 685 685 /* … … 690 690 N_("Configuration error: Unknown config key")); 691 691 692 rc = CFGMR3QueryBool(pCfgHandle, "GCEnabled", &p Data->fGCEnabled);692 rc = CFGMR3QueryBool(pCfgHandle, "GCEnabled", &pThis->fGCEnabled); 693 693 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 694 p Data->fGCEnabled = true;694 pThis->fGCEnabled = true; 695 695 else if (RT_FAILURE(rc)) 696 696 return PDMDEV_SET_ERROR(pDevIns, rc, 697 697 N_("Configuration error: Failed to get the \"GCEnabled\" value")); 698 698 699 rc = CFGMR3QueryBool(pCfgHandle, "R0Enabled", &p Data->fR0Enabled);699 rc = CFGMR3QueryBool(pCfgHandle, "R0Enabled", &pThis->fR0Enabled); 700 700 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 701 p Data->fR0Enabled = true;701 pThis->fR0Enabled = true; 702 702 else if (RT_FAILURE(rc)) 703 703 return PDMDEV_SET_ERROR(pDevIns, rc, … … 705 705 706 706 /* IBase */ 707 p Data->IBase.pfnQueryInterface = parallelQueryInterface;707 pThis->IBase.pfnQueryInterface = parallelQueryInterface; 708 708 709 709 /* IHostParallelPort */ 710 p Data->IHostParallelPort.pfnNotifyInterrupt = parallelNotifyInterrupt;711 712 rc = RTSemEventCreate(&p Data->ReceiveSem);710 pThis->IHostParallelPort.pfnNotifyInterrupt = parallelNotifyInterrupt; 711 712 rc = RTSemEventCreate(&pThis->ReceiveSem); 713 713 AssertRC(rc); 714 714 … … 719 719 char szName[24]; 720 720 RTStrPrintf(szName, sizeof(szName), "Parallel#%d", iInstance); 721 rc = PDMDevHlpCritSectInit(pDevIns, &p Data->CritSect, szName);721 rc = PDMDevHlpCritSectInit(pDevIns, &pThis->CritSect, szName); 722 722 if (RT_FAILURE(rc)) 723 723 return rc; … … 739 739 Log(("parallelConstruct instance %d iobase=%04x irq=%d\n", iInstance, io_base, irq_lvl)); 740 740 741 p Data->irq = irq_lvl;742 p Data->base = io_base;741 pThis->irq = irq_lvl; 742 pThis->base = io_base; 743 743 744 744 /* Init parallel state */ 745 p Data->reg_data = 0;746 p Data->reg_ecp_ecr = LPT_ECP_ECR_CHIPMODE_COMPAT | LPT_ECP_ECR_FIFO_EMPTY;747 p Data->act_fifo_pos_read = 0;748 p Data->act_fifo_pos_write = 0;745 pThis->reg_data = 0; 746 pThis->reg_ecp_ecr = LPT_ECP_ECR_CHIPMODE_COMPAT | LPT_ECP_ECR_FIFO_EMPTY; 747 pThis->act_fifo_pos_read = 0; 748 pThis->act_fifo_pos_write = 0; 749 749 750 750 rc = PDMDevHlpIOPortRegister(pDevIns, io_base, 8, 0, … … 763 763 #endif 764 764 765 if (p Data->fGCEnabled)765 if (pThis->fGCEnabled) 766 766 { 767 767 rc = PDMDevHlpIOPortRegisterGC(pDevIns, io_base, 8, 0, "parallelIOPortWrite", … … 778 778 } 779 779 780 if (p Data->fR0Enabled)780 if (pThis->fR0Enabled) 781 781 { 782 782 rc = PDMDevHlpIOPortRegisterR0(pDevIns, io_base, 8, 0, "parallelIOPortWrite", … … 795 795 /* Attach the parallel port driver and get the interfaces. For now no run-time 796 796 * changes are supported. */ 797 rc = PDMDevHlpDriverAttach(pDevIns, 0, &p Data->IBase, &pData->pDrvBase, "Parallel Host");797 rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis->IBase, &pThis->pDrvBase, "Parallel Host"); 798 798 if (RT_SUCCESS(rc)) 799 799 { 800 p Data->pDrvHostParallelConnector = (PDMIHOSTPARALLELCONNECTOR *)pData->pDrvBase->pfnQueryInterface(pData->pDrvBase,800 pThis->pDrvHostParallelConnector = (PDMIHOSTPARALLELCONNECTOR *)pThis->pDrvBase->pfnQueryInterface(pThis->pDrvBase, 801 801 PDMINTERFACE_HOST_PARALLEL_CONNECTOR); 802 if (!p Data->pDrvHostParallelConnector)802 if (!pThis->pDrvHostParallelConnector) 803 803 { 804 804 AssertMsgFailed(("Configuration error: instance %d has no host parallel interface!\n", iInstance)); … … 809 809 else if (rc == VERR_PDM_NO_ATTACHED_DRIVER) 810 810 { 811 p Data->pDrvBase = NULL;812 p Data->pDrvHostParallelConnector = NULL;811 pThis->pDrvBase = NULL; 812 pThis->pDrvHostParallelConnector = NULL; 813 813 LogRel(("Parallel%d: no unit\n", iInstance)); 814 814 } … … 821 821 822 822 /* Set compatibility mode */ 823 p Data->pDrvHostParallelConnector->pfnSetMode(pData->pDrvHostParallelConnector, PDM_PARALLEL_PORT_MODE_COMPAT);823 pThis->pDrvHostParallelConnector->pfnSetMode(pThis->pDrvHostParallelConnector, PDM_PARALLEL_PORT_MODE_COMPAT); 824 824 /* Get status of control register */ 825 p Data->pDrvHostParallelConnector->pfnReadControl(pData->pDrvHostParallelConnector, &pData->reg_control);825 pThis->pDrvHostParallelConnector->pfnReadControl(pThis->pDrvHostParallelConnector, &pThis->reg_control); 826 826 827 827 rc = PDMDevHlpSSMRegister( … … 830 830 iInstance, /* u32Instance */ 831 831 PARALLEL_SAVED_STATE_VERSION, /* u32Version */ 832 sizeof (*p Data), /* cbGuess */832 sizeof (*pThis), /* cbGuess */ 833 833 NULL, /* pfnSavePrep */ 834 834 parallelSaveExec, /* pfnSaveExec */ -
trunk/src/VBox/Devices/Parallel/DrvHostParallel.cpp
r11268 r11269 94 94 { 95 95 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface); 96 PDRVHOSTPARALLEL p Data= PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL);96 PDRVHOSTPARALLEL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL); 97 97 switch (enmInterface) 98 98 { … … 100 100 return &pDrvIns->IBase; 101 101 case PDMINTERFACE_HOST_PARALLEL_CONNECTOR: 102 return &p Data->IHostParallelConnector;102 return &pThis->IHostParallelConnector; 103 103 default: 104 104 return NULL; … … 111 111 static DECLCALLBACK(int) drvHostParallelWrite(PPDMIHOSTPARALLELCONNECTOR pInterface, const void *pvBuf, size_t *cbWrite) 112 112 { 113 PDRVHOSTPARALLEL p Data= PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface);113 PDRVHOSTPARALLEL pThis = PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface); 114 114 const unsigned char *pBuffer = (const unsigned char *)pvBuf; 115 115 116 116 LogFlow(("%s: pvBuf=%#p cbWrite=%d\n", __FUNCTION__, pvBuf, *cbWrite)); 117 117 118 ioctl(p Data->FileDevice, PPWDATA, pBuffer);118 ioctl(pThis->FileDevice, PPWDATA, pBuffer); 119 119 *cbWrite = 1; 120 120 … … 124 124 static DECLCALLBACK(int) drvHostParallelRead(PPDMIHOSTPARALLELCONNECTOR pInterface, void *pvBuf, size_t *cbRead) 125 125 { 126 PDRVHOSTPARALLEL p Data= PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface);126 PDRVHOSTPARALLEL pThis = PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface); 127 127 unsigned char *pBuffer = (unsigned char *)pvBuf; 128 128 129 129 LogFlow(("%s: pvBuf=%#p cbRead=%d\n", __FUNCTION__, pvBuf, cbRead)); 130 130 131 ioctl(p Data->FileDevice, PPRDATA, pBuffer);131 ioctl(pThis->FileDevice, PPRDATA, pBuffer); 132 132 *cbRead = 1; 133 133 … … 137 137 static DECLCALLBACK(int) drvHostParallelSetMode(PPDMIHOSTPARALLELCONNECTOR pInterface, PDMPARALLELPORTMODE enmMode) 138 138 { 139 PDRVHOSTPARALLEL p Data= PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface);139 PDRVHOSTPARALLEL pThis = PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface); 140 140 int ppdev_mode; 141 141 … … 154 154 } 155 155 156 ioctl(p Data->FileDevice, PPSETMODE, &ppdev_mode);156 ioctl(pThis->FileDevice, PPSETMODE, &ppdev_mode); 157 157 158 158 return VINF_SUCCESS; … … 161 161 static DECLCALLBACK(int) drvHostParallelWriteControl(PPDMIHOSTPARALLELCONNECTOR pInterface, uint8_t fReg) 162 162 { 163 PDRVHOSTPARALLEL p Data= PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface);163 PDRVHOSTPARALLEL pThis = PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface); 164 164 165 165 LogFlow(("%s: fReg=%d\n", __FUNCTION__, fReg)); 166 166 167 ioctl(p Data->FileDevice, PPWCONTROL, &fReg);167 ioctl(pThis->FileDevice, PPWCONTROL, &fReg); 168 168 169 169 return VINF_SUCCESS; … … 172 172 static DECLCALLBACK(int) drvHostParallelReadControl(PPDMIHOSTPARALLELCONNECTOR pInterface, uint8_t *pfReg) 173 173 { 174 PDRVHOSTPARALLEL p Data= PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface);174 PDRVHOSTPARALLEL pThis = PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface); 175 175 uint8_t fReg; 176 176 177 ioctl(p Data->FileDevice, PPRCONTROL, &fReg);177 ioctl(pThis->FileDevice, PPRCONTROL, &fReg); 178 178 179 179 LogFlow(("%s: fReg=%d\n", __FUNCTION__, fReg)); … … 186 186 static DECLCALLBACK(int) drvHostParallelReadStatus(PPDMIHOSTPARALLELCONNECTOR pInterface, uint8_t *pfReg) 187 187 { 188 PDRVHOSTPARALLEL p Data= PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface);188 PDRVHOSTPARALLEL pThis = PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface); 189 189 uint8_t fReg; 190 190 191 ioctl(p Data->FileDevice, PPRSTATUS, &fReg);191 ioctl(pThis->FileDevice, PPRSTATUS, &fReg); 192 192 193 193 LogFlow(("%s: fReg=%d\n", __FUNCTION__, fReg)); … … 200 200 static DECLCALLBACK(int) drvHostParallelMonitorThread(PPDMDRVINS pDrvIns, PPDMTHREAD pThread) 201 201 { 202 PDRVHOSTPARALLEL p Data= PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL);202 PDRVHOSTPARALLEL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL); 203 203 struct pollfd aFDs[2]; 204 204 … … 210 210 int rc; 211 211 212 aFDs[0].fd = p Data->FileDevice;212 aFDs[0].fd = pThis->FileDevice; 213 213 aFDs[0].events = POLLIN; 214 214 aFDs[0].revents = 0; 215 aFDs[1].fd = p Data->WakeupPipeR;215 aFDs[1].fd = pThis->WakeupPipeR; 216 216 aFDs[1].events = POLLIN | POLLERR | POLLHUP; 217 217 aFDs[1].revents = 0; … … 232 232 char ch; 233 233 size_t cbRead; 234 RTFileRead(p Data->WakeupPipeR, &ch, 1, &cbRead);234 RTFileRead(pThis->WakeupPipeR, &ch, 1, &cbRead); 235 235 continue; 236 236 } 237 237 238 238 /* Interrupt occured. */ 239 rc = p Data->pDrvHostParallelPort->pfnNotifyInterrupt(pData->pDrvHostParallelPort);239 rc = pThis->pDrvHostParallelPort->pfnNotifyInterrupt(pThis->pDrvHostParallelPort); 240 240 AssertRC(rc); 241 241 } … … 253 253 static DECLCALLBACK(int) drvHostParallelWakeupMonitorThread(PPDMDRVINS pDrvIns, PPDMTHREAD pThread) 254 254 { 255 PDRVHOSTPARALLEL p Data= PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL);256 257 return RTFileWrite(p Data->WakeupPipeW, "", 1, NULL);255 PDRVHOSTPARALLEL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL); 256 257 return RTFileWrite(pThis->WakeupPipeW, "", 1, NULL); 258 258 } 259 259 … … 272 272 static DECLCALLBACK(int) drvHostParallelConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle) 273 273 { 274 PDRVHOSTPARALLEL p Data= PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL);274 PDRVHOSTPARALLEL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL); 275 275 LogFlow(("%s: iInstance=%d\n", __FUNCTION__, pDrvIns->iInstance)); 276 276 … … 289 289 pDrvIns->IBase.pfnQueryInterface = drvHostParallelQueryInterface; 290 290 /* IHostParallelConnector. */ 291 p Data->IHostParallelConnector.pfnWrite = drvHostParallelWrite;292 p Data->IHostParallelConnector.pfnRead = drvHostParallelRead;293 p Data->IHostParallelConnector.pfnSetMode = drvHostParallelSetMode;294 p Data->IHostParallelConnector.pfnWriteControl = drvHostParallelWriteControl;295 p Data->IHostParallelConnector.pfnReadControl = drvHostParallelReadControl;296 p Data->IHostParallelConnector.pfnReadStatus = drvHostParallelReadStatus;291 pThis->IHostParallelConnector.pfnWrite = drvHostParallelWrite; 292 pThis->IHostParallelConnector.pfnRead = drvHostParallelRead; 293 pThis->IHostParallelConnector.pfnSetMode = drvHostParallelSetMode; 294 pThis->IHostParallelConnector.pfnWriteControl = drvHostParallelWriteControl; 295 pThis->IHostParallelConnector.pfnReadControl = drvHostParallelReadControl; 296 pThis->IHostParallelConnector.pfnReadStatus = drvHostParallelReadStatus; 297 297 298 298 /* … … 300 300 */ 301 301 /* Device */ 302 int rc = CFGMR3QueryStringAlloc(pCfgHandle, "DevicePath", &p Data->pszDevicePath);302 int rc = CFGMR3QueryStringAlloc(pCfgHandle, "DevicePath", &pThis->pszDevicePath); 303 303 if (RT_FAILURE(rc)) 304 304 { … … 310 310 * Open the device 311 311 */ 312 rc = RTFileOpen(&p Data->FileDevice, pData->pszDevicePath, RTFILE_O_OPEN | RTFILE_O_READWRITE);312 rc = RTFileOpen(&pThis->FileDevice, pThis->pszDevicePath, RTFILE_O_OPEN | RTFILE_O_READWRITE); 313 313 if (RT_FAILURE(rc)) 314 314 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("Parallel#%d could not open '%s'"), 315 pDrvIns->iInstance, p Data->pszDevicePath);315 pDrvIns->iInstance, pThis->pszDevicePath); 316 316 317 317 /* 318 318 * Try to get exclusive access to parallel port 319 319 */ 320 rc = ioctl(p Data->FileDevice, PPEXCL);320 rc = ioctl(pThis->FileDevice, PPEXCL); 321 321 if (rc < 0) 322 322 return PDMDrvHlpVMSetError(pDrvIns, RTErrConvertFromErrno(errno), RT_SRC_POS, 323 323 N_("Parallel#%d could not get exclusive access for parallel port '%s'" 324 324 "Be sure that no other process or driver accesses this port"), 325 pDrvIns->iInstance, p Data->pszDevicePath);325 pDrvIns->iInstance, pThis->pszDevicePath); 326 326 327 327 /* 328 328 * Claim the parallel port 329 329 */ 330 rc = ioctl(p Data->FileDevice, PPCLAIM);330 rc = ioctl(pThis->FileDevice, PPCLAIM); 331 331 if (rc < 0) 332 332 return PDMDrvHlpVMSetError(pDrvIns, RTErrConvertFromErrno(errno), RT_SRC_POS, 333 333 N_("Parallel#%d could not claim parallel port '%s'" 334 334 "Be sure that no other process or driver accesses this port"), 335 pDrvIns->iInstance, p Data->pszDevicePath);335 pDrvIns->iInstance, pThis->pszDevicePath); 336 336 337 337 /* 338 338 * Get the IHostParallelPort interface of the above driver/device. 339 339 */ 340 p Data->pDrvHostParallelPort = (PPDMIHOSTPARALLELPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_HOST_PARALLEL_PORT);341 if (!p Data->pDrvHostParallelPort)340 pThis->pDrvHostParallelPort = (PPDMIHOSTPARALLELPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_HOST_PARALLEL_PORT); 341 if (!pThis->pDrvHostParallelPort) 342 342 return PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_MISSING_INTERFACE_ABOVE, RT_SRC_POS, N_("Parallel#%d has no parallel port interface above"), 343 343 pDrvIns->iInstance); … … 353 353 return rc; 354 354 } 355 p Data->WakeupPipeR = aFDs[0];356 p Data->WakeupPipeW = aFDs[1];355 pThis->WakeupPipeR = aFDs[0]; 356 pThis->WakeupPipeW = aFDs[1]; 357 357 358 358 /* 359 359 * Start waiting for interrupts. 360 360 */ 361 rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &p Data->pMonitorThread, pData, drvHostParallelMonitorThread, drvHostParallelWakeupMonitorThread, 0,361 rc = PDMDrvHlpPDMThreadCreate(pDrvIns, &pThis->pMonitorThread, pThis, drvHostParallelMonitorThread, drvHostParallelWakeupMonitorThread, 0, 362 362 RTTHREADTYPE_IO, "ParMon"); 363 363 if (RT_FAILURE(rc)) … … 378 378 static DECLCALLBACK(void) drvHostParallelDestruct(PPDMDRVINS pDrvIns) 379 379 { 380 PDRVHOSTPARALLEL p Data= PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL);380 PDRVHOSTPARALLEL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL); 381 381 382 382 LogFlow(("%s: iInstance=%d\n", __FUNCTION__, pDrvIns->iInstance)); 383 383 384 ioctl(p Data->FileDevice, PPRELEASE);385 386 if (p Data->WakeupPipeW != NIL_RTFILE)387 { 388 int rc = RTFileClose(p Data->WakeupPipeW);384 ioctl(pThis->FileDevice, PPRELEASE); 385 386 if (pThis->WakeupPipeW != NIL_RTFILE) 387 { 388 int rc = RTFileClose(pThis->WakeupPipeW); 389 389 AssertRC(rc); 390 p Data->WakeupPipeW = NIL_RTFILE;391 } 392 if (p Data->WakeupPipeR != NIL_RTFILE)393 { 394 int rc = RTFileClose(p Data->WakeupPipeR);390 pThis->WakeupPipeW = NIL_RTFILE; 391 } 392 if (pThis->WakeupPipeR != NIL_RTFILE) 393 { 394 int rc = RTFileClose(pThis->WakeupPipeR); 395 395 AssertRC(rc); 396 p Data->WakeupPipeR = NIL_RTFILE;397 } 398 if (p Data->FileDevice != NIL_RTFILE)399 { 400 int rc = RTFileClose(p Data->FileDevice);396 pThis->WakeupPipeR = NIL_RTFILE; 397 } 398 if (pThis->FileDevice != NIL_RTFILE) 399 { 400 int rc = RTFileClose(pThis->FileDevice); 401 401 AssertRC(rc); 402 p Data->FileDevice = NIL_RTFILE;402 pThis->FileDevice = NIL_RTFILE; 403 403 } 404 404 }
Note:
See TracChangeset
for help on using the changeset viewer.