Changeset 81889 in vbox
- Timestamp:
- Nov 15, 2019 10:44:32 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Serial/DevSerial.cpp
r81888 r81889 50 50 /** Pointer to the device instance - RC Ptr. */ 51 51 PPDMDEVINSRC pDevInsRC; 52 /** Alignment. */53 RTRCPTR Alignment0;54 /** Flag whether the R0 portion of this device is enabled. */55 bool fR0Enabled;56 /** Flag whether the RC portion of this device is enabled. */57 bool fRCEnabled;58 /** Alignment. */59 bool afAlignment1[2];60 52 /** The IRQ value. */ 61 53 uint8_t uIrq; 54 uint8_t bAlignment; 62 55 /** The base I/O port the device is registered at. */ 63 56 RTIOPORT PortBase; 57 /** The I/O ports registration. */ 58 IOMIOPORTHANDLE hIoPorts; 64 59 65 60 /** The UART core. */ … … 84 79 85 80 /** 86 * @callback_method_impl{FNIOMIOPORTOUT} 87 */ 88 PDMBOTHCBDECL(int) serialIoPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t u32, unsigned cb) 81 * @callback_method_impl{FNIOMIOPORTNEWOUT} 82 */ 83 static DECLCALLBACK(VBOXSTRICTRC) 84 serialIoPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb) 89 85 { 90 86 PDEVSERIAL pThis = PDMDEVINS_2_DATA(pDevIns, PDEVSERIAL); 91 87 RT_NOREF_PV(pvUser); 92 88 93 return uartRegWrite(&pThis->UartCore, uPort - pThis->PortBase, u32, cb); 94 } 95 96 97 /** 98 * @callback_method_impl{FNIOMIOPORTIN} 99 */ 100 PDMBOTHCBDECL(int) serialIoPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t *pu32, unsigned cb) 89 return uartRegWrite(&pThis->UartCore, offPort, u32, cb); 90 } 91 92 93 /** 94 * @callback_method_impl{FNIOMIOPORTNEWIN} 95 */ 96 static DECLCALLBACK(VBOXSTRICTRC) 97 serialIoPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb) 101 98 { 102 99 PDEVSERIAL pThis = PDMDEVINS_2_DATA(pDevIns, PDEVSERIAL); 103 100 RT_NOREF_PV(pvUser); 104 101 105 return uartRegRead(&pThis->UartCore, uPort - pThis->PortBase, pu32, cb);102 return uartRegRead(&pThis->UartCore, offPort, pu32, cb); 106 103 } 107 104 … … 326 323 PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "IRQ|IOBase|YieldOnLSRRead|UartType", ""); 327 324 328 rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "GCEnabled", &pThis->fRCEnabled, true);329 if (RT_FAILURE(rc))330 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to get the \"GCEnabled\" value"));331 332 rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "R0Enabled", &pThis->fR0Enabled, true);333 if (RT_FAILURE(rc))334 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to get the \"R0Enabled\" value"));335 336 325 bool fYieldOnLSRRead = false; 337 326 rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "YieldOnLSRRead", &fYieldOnLSRRead, false); … … 393 382 * Register the I/O ports. 394 383 */ 395 rc = PDMDevHlpIOPortRegister(pDevIns, uIoBase, 8, 0, 396 serialIoPortWrite, serialIoPortRead, 397 NULL, NULL, "SERIAL"); 398 if (RT_FAILURE(rc)) 399 return rc; 384 rc = PDMDevHlpIoPortCreateAndMap(pDevIns, uIoBase, 8 /*cPorts*/, serialIoPortWrite, serialIoPortRead, 385 "SERIAL", NULL /*paExtDescs*/, &pThis->hIoPorts); 386 AssertRCReturn(rc, rc); 400 387 401 388 PVM pVM = PDMDevHlpGetVM(pDevIns); … … 406 393 if (pDevIns->fRCEnabled) 407 394 { 408 rc = PDMDevHlpIOPortRegisterRC(pDevIns, uIoBase, 8, 0, "serialIoPortWrite", "serialIoPortRead", NULL, NULL, "SERIAL"); 409 if ( RT_SUCCESS(rc) 410 && VM_IS_RAW_MODE_ENABLED(pVM)) /** @todo this dynamic symbol resolving will be reworked later! */ 395 if (VM_IS_RAW_MODE_ENABLED(pVM)) /** @todo this dynamic symbol resolving will be reworked later! */ 411 396 rc = PDMR3LdrGetSymbolRC(pVM, pDevIns->pReg->pszRCMod, "serialIrqReq", &pfnSerialIrqReqRC); 412 397 if (RT_FAILURE(rc)) … … 417 402 if (pDevIns->fR0Enabled) 418 403 { 419 rc = PDMDevHlpIOPortRegisterR0(pDevIns, uIoBase, 8, 0, "serialIoPortWrite", "serialIoPortRead", NULL, NULL, "SERIAL"); 420 if (RT_SUCCESS(rc)) /** @todo this dynamic symbol resolving will be reworked later! */ 421 rc = PDMR3LdrGetSymbolR0(pVM, pDevIns->pReg->pszR0Mod, "serialIrqReq", &pfnSerialIrqReqR0); 404 /** @todo this dynamic symbol resolving will be reworked later! */ 405 rc = PDMR3LdrGetSymbolR0(pVM, pDevIns->pReg->pszR0Mod, "serialIrqReq", &pfnSerialIrqReqR0); 422 406 if (RT_FAILURE(rc)) 423 407 return rc; … … 442 426 } 443 427 444 #endif /* IN_RING3 */ 428 #else /* !IN_RING3 */ 429 430 /** 431 * @callback_method_impl{PDMDEVREGR0,pfnConstruct} 432 */ 433 static DECLCALLBACK(int) serialRZConstruct(PPDMDEVINS pDevIns) 434 { 435 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 436 PDEVSERIAL pThis = PDMDEVINS_2_DATA(pDevIns, PDEVSERIAL); 437 438 int rc = PDMDevHlpSetDeviceCritSect(pDevIns, PDMDevHlpCritSectGetNop(pDevIns)); 439 AssertRCReturn(rc, rc); 440 441 rc = PDMDevHlpIoPortSetUpContext(pDevIns, pThis->hIoPorts, serialIoPortWrite, serialIoPortRead, NULL /*pvUser*/); 442 AssertRCReturn(rc, rc); 443 444 return VINF_SUCCESS; 445 } 446 447 #endif /* !IN_RING3 */ 445 448 446 449 /** … … 452 455 /* .uReserved0 = */ 0, 453 456 /* .szName = */ "serial", 454 /* .fFlags = */ PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RZ ,457 /* .fFlags = */ PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RZ | PDM_DEVREG_FLAGS_NEW_STYLE, 455 458 /* .fClass = */ PDM_DEVREG_CLASS_SERIAL, 456 459 /* .cMaxInstances = */ UINT32_MAX, … … 489 492 #elif defined(IN_RING0) 490 493 /* .pfnEarlyConstruct = */ NULL, 491 /* .pfnConstruct = */ NULL,494 /* .pfnConstruct = */ serialRZConstruct, 492 495 /* .pfnDestruct = */ NULL, 493 496 /* .pfnFinalDestruct = */ NULL, … … 502 505 /* .pfnReserved7 = */ NULL, 503 506 #elif defined(IN_RC) 504 /* .pfnConstruct = */ NULL,507 /* .pfnConstruct = */ serialRZConstruct, 505 508 /* .pfnReserved0 = */ NULL, 506 509 /* .pfnReserved1 = */ NULL,
Note:
See TracChangeset
for help on using the changeset viewer.