Changeset 81886 in vbox for trunk/src/VBox/Devices/Storage
- Timestamp:
- Nov 15, 2019 10:27:05 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 134681
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevAHCI.cpp
r81885 r81886 281 281 282 282 /** 283 * @implements PDMIBASE 284 * @implements PDMIMEDIAPORT 285 * @implements PDMIMEDIAEXPORT 286 */ 287 typedef struct AHCIPort 288 { 289 /** Pointer to the device instance - HC ptr */ 290 PPDMDEVINSR3 pDevInsR3; 291 /** Pointer to the device instance - R0 ptr */ 292 PPDMDEVINSR0 pDevInsR0; 293 /** Pointer to the device instance - RC ptr. */ 294 PPDMDEVINSRC pDevInsRC; 295 296 #if HC_ARCH_BITS == 64 297 uint32_t Alignment0; 298 #endif 299 300 /** Pointer to the parent AHCI structure - R3 ptr. */ 301 R3PTRTYPE(struct AHCI *) pAhciR3; 302 /** Pointer to the parent AHCI structure - R0 ptr. */ 303 R0PTRTYPE(struct AHCI *) pAhciR0; 304 /** Pointer to the parent AHCI structure - RC ptr. */ 305 RCPTRTYPE(struct AHCI *) pAhciRC; 306 283 * The shared state of an AHCI port. 284 */ 285 typedef struct AHCIPORT 286 { 307 287 /** Command List Base Address. */ 308 288 uint32_t regCLB; … … 336 316 /** Current number of active tasks. */ 337 317 volatile uint32_t cTasksActive; 318 uint32_t u32Alignment1; 338 319 /** Command List Base Address */ 339 320 volatile RTGCPHYS GCPhysAddrClb; … … 362 343 volatile bool fWrkThreadSleeping; 363 344 364 bool afAlignment [4];345 bool afAlignment1[2]; 365 346 366 347 /** Number of total sectors. */ … … 370 351 /** Currently configured number of sectors in a multi-sector transfer. */ 371 352 uint32_t cMultSectors; 353 /** The LUN (same as port number). */ 354 uint32_t iLUN; 355 /** Set if there is a device present at the port. */ 356 bool fPresent; 372 357 /** Currently active transfer mode (MDMA/UDMA) and speed. */ 373 358 uint8_t uATATransferMode; 359 /** Exponent of logical sectors in a physical sector, number of logical sectors is 2^exp. */ 360 uint8_t cLogSectorsPerPhysicalExp; 361 uint8_t bAlignment2; 374 362 /** ATAPI sense data. */ 375 363 uint8_t abATAPISense[ATAPI_SENSE_SIZE]; 376 /** Exponent of logical sectors in a physical sector, number of logical sectors is 2^exp. */377 uint8_t cLogSectorsPerPhysicalExp;378 /** The LUN. */379 RTUINT iLUN;380 364 381 365 /** Bitmap for finished tasks (R3 -> Guest). */ … … 393 377 volatile uint32_t u32CurrentCommandSlot; 394 378 395 #if HC_ARCH_BITS == 64396 uint32_t u32Alignment2;397 #endif398 399 /** Device specific settings (R3 only stuff). */400 /** Pointer to the attached driver's base interface. */401 R3PTRTYPE(PPDMIBASE) pDrvBase;402 /** Pointer to the attached driver's block interface. */403 R3PTRTYPE(PPDMIMEDIA) pDrvMedia;404 /** Pointer to the attached driver's extended interface. */405 R3PTRTYPE(PPDMIMEDIAEX) pDrvMediaEx;406 /** Port description. */407 R3PTRTYPE(char *) pszDesc;408 /** The base interface. */409 PDMIBASE IBase;410 /** The block port interface. */411 PDMIMEDIAPORT IPort;412 /** The extended media port interface. */413 PDMIMEDIAEXPORT IMediaExPort;414 379 /** Physical geometry of this image. */ 415 380 PDMMEDIAGEOMETRY PCHSGeometry; 381 416 382 /** The status LED state for this drive. */ 417 383 PDMLED Led; 418 419 #if HC_ARCH_BITS == 64420 uint32_t u32Alignment3;421 #endif422 423 /** Async IO Thread. */424 R3PTRTYPE(PPDMTHREAD) pAsyncIOThread;425 /** First task throwing an error. */426 R3PTRTYPE(volatile PAHCIREQ) pTaskErr;427 384 428 385 /** The event semaphore the processing thread waits on. */ … … 445 402 446 403 uint32_t u32Alignment5; 447 448 } AHCIPort; 449 AssertCompileSizeAlignment(AHCIPort, 8); 450 /** Pointer to the state of an AHCI port. */ 451 typedef AHCIPort *PAHCIPort; 404 } AHCIPORT; 405 AssertCompileSizeAlignment(AHCIPORT, 8); 406 /** Pointer to the shared state of an AHCI port. */ 407 typedef AHCIPORT *PAHCIPORT; 408 409 410 /** 411 * The ring-3 state of an AHCI port. 412 * 413 * @implements PDMIBASE 414 * @implements PDMIMEDIAPORT 415 * @implements PDMIMEDIAEXPORT 416 */ 417 typedef struct AHCIPORTR3 418 { 419 /** Pointer to the device instance - only to get our bearings in an interface 420 * method, nothing else. */ 421 PPDMDEVINSR3 pDevIns; 422 423 /** The LUN (same as port number). */ 424 uint32_t iLUN; 425 426 /** Device specific settings (R3 only stuff). */ 427 /** Pointer to the attached driver's base interface. */ 428 R3PTRTYPE(PPDMIBASE) pDrvBase; 429 /** Pointer to the attached driver's block interface. */ 430 R3PTRTYPE(PPDMIMEDIA) pDrvMedia; 431 /** Pointer to the attached driver's extended interface. */ 432 R3PTRTYPE(PPDMIMEDIAEX) pDrvMediaEx; 433 /** Port description. */ 434 char szDesc[8]; 435 /** The base interface. */ 436 PDMIBASE IBase; 437 /** The block port interface. */ 438 PDMIMEDIAPORT IPort; 439 /** The extended media port interface. */ 440 PDMIMEDIAEXPORT IMediaExPort; 441 442 /** Async IO Thread. */ 443 R3PTRTYPE(PPDMTHREAD) pAsyncIOThread; 444 /** First task throwing an error. */ 445 R3PTRTYPE(volatile PAHCIREQ) pTaskErr; 446 447 } AHCIPORTR3; 448 AssertCompileSizeAlignment(AHCIPORTR3, 8); 449 /** Pointer to the ring-3 state of an AHCI port. */ 450 typedef AHCIPORTR3 *PAHCIPORTR3; 452 451 453 452 … … 459 458 typedef struct AHCI 460 459 { 461 /** Pointer to the device instance - R3 ptr */462 PPDMDEVINSR3 pDevInsR3;463 /** Pointer to the device instance - R0 ptr */464 PPDMDEVINSR0 pDevInsR0;465 /** Pointer to the device instance - RC ptr. */466 PPDMDEVINSRC pDevInsRC;467 468 #if HC_ARCH_BITS == 64469 uint32_t Alignment0;470 #endif471 472 /** Status LUN: The base interface. */473 PDMIBASE IBase;474 /** Status LUN: Leds interface. */475 PDMILEDPORTS ILeds;476 /** Status LUN: Partner of ILeds. */477 R3PTRTYPE(PPDMILEDCONNECTORS) pLedsConnector;478 /** Status LUN: Media Notifys. */479 R3PTRTYPE(PPDMIMEDIANOTIFY) pMediaNotify;480 481 #if HC_ARCH_BITS == 32482 uint32_t Alignment1;483 #endif484 485 460 /** Global Host Control register of the HBA 486 461 * @todo r=bird: Make this a 'name' doxygen comment with { and add a … … 506 481 uint32_t regIdx; 507 482 508 #if HC_ARCH_BITS == 64509 uint32_t Alignment3;510 #endif511 512 483 /** Countdown timer for command completion coalescing. */ 513 484 TMTIMERHANDLE hHbaCccTimer; … … 515 486 /** Which port number is used to mark an CCC interrupt */ 516 487 uint8_t uCccPortNr; 517 518 #if HC_ARCH_BITS == 64 519 uint32_t Alignment6; 520 #endif 488 uint8_t abAlignment1[7]; 521 489 522 490 /** Timeout value */ … … 528 496 529 497 /** Register structure per port */ 530 AHCIP ortahciPort[AHCI_MAX_NR_PORTS_IMPL];498 AHCIPORT ahciPort[AHCI_MAX_NR_PORTS_IMPL]; 531 499 532 500 /** The critical section. */ … … 537 505 /** Number of I/O threads currently active - used for async controller reset handling. */ 538 506 volatile uint32_t cThreadsActive; 539 /** Device is in a reset state. */ 540 bool fReset; 541 /** Supports 64bit addressing */ 542 bool f64BitAddr; 543 /** Indicates that PDMDevHlpAsyncNotificationCompleted should be called when 544 * a port is entering the idle state. */ 545 bool volatile fSignalIdle; 546 /** Flag whether the controller has BIOS access enabled. */ 547 bool fBootable; 507 548 508 /** Flag whether the legacy port reset method should be used to make it work with saved states. */ 549 509 bool fLegacyPortResetMethod; 550 510 /** Enable tiger (10.4.x) SSTS hack or not. */ 551 511 bool fTigerHack; 552 bool afAlignment7[2]; 512 /** Flag whether we have written the first 4bytes in an 8byte MMIO write successfully. */ 513 volatile bool f8ByteMMIO4BytesWrittenSuccessfully; 514 515 /** Device is in a reset state. 516 * @todo r=bird: This isn't actually being modified by anyone... */ 517 bool fReset; 518 /** Supports 64bit addressing 519 * @todo r=bird: This isn't really being modified by anyone (always false). */ 520 bool f64BitAddr; 521 /** Flag whether the controller has BIOS access enabled. 522 * @todo r=bird: Not used, just queried from CFGM. */ 523 bool fBootable; 524 525 bool afAlignment2[2]; 553 526 554 527 /** Number of usable ports on this controller. */ … … 556 529 /** Number of usable command slots for each port. */ 557 530 uint32_t cCmdSlotsAvail; 558 559 /** Flag whether we have written the first 4bytes in an 8byte MMIO write successfully. */560 volatile bool f8ByteMMIO4BytesWrittenSuccessfully;561 562 #if HC_ARCH_BITS == 64563 uint32_t Alignment8;564 #endif565 531 566 532 /** PCI region \#0: Legacy IDE fake, 8 ports. */ … … 584 550 585 551 /** 552 * Main AHCI device ring-3 state. 553 * 554 * @implements PDMILEDPORTS 555 */ 556 typedef struct AHCIR3 557 { 558 /** Pointer to the device instance - only for getting our bearings in 559 * interface methods. */ 560 PPDMDEVINSR3 pDevIns; 561 562 /** Status LUN: The base interface. */ 563 PDMIBASE IBase; 564 /** Status LUN: Leds interface. */ 565 PDMILEDPORTS ILeds; 566 /** Status LUN: Partner of ILeds. */ 567 R3PTRTYPE(PPDMILEDCONNECTORS) pLedsConnector; 568 /** Status LUN: Media Notifys. */ 569 R3PTRTYPE(PPDMIMEDIANOTIFY) pMediaNotify; 570 571 /** Register structure per port */ 572 AHCIPORTR3 aPorts[AHCI_MAX_NR_PORTS_IMPL]; 573 574 /** Indicates that PDMDevHlpAsyncNotificationCompleted should be called when 575 * a port is entering the idle state. */ 576 bool volatile fSignalIdle; 577 bool afAlignment7[2+4]; 578 } AHCIR3; 579 /** Pointer to the ring-3 state of an AHCI device. */ 580 typedef AHCIR3 *PAHCIR3; 581 582 583 /** 584 * Main AHCI device ring-0 state. 585 */ 586 typedef struct AHCIR0 587 { 588 uint64_t uUnused; 589 } AHCIR0; 590 /** Pointer to the ring-0 state of an AHCI device. */ 591 typedef AHCIR0 *PAHCIR0; 592 593 594 /** 595 * Main AHCI device raw-mode state. 596 */ 597 typedef struct AHCIRC 598 { 599 uint64_t uUnused; 600 } AHCIRC; 601 /** Pointer to the raw-mode state of an AHCI device. */ 602 typedef AHCIRC *PAHCIRC; 603 604 605 /** Main AHCI device current context state. */ 606 typedef CTX_SUFF(AHCI) AHCICC; 607 /** Pointer to the current context state of an AHCI device. */ 608 typedef CTX_SUFF(PAHCI) PAHCICC; 609 610 611 /** 586 612 * Scatter gather list entry. 587 613 */ … … 604 630 * 605 631 * @returns nothing. 606 * @param p This The NVME controllerinstance.632 * @param pDevIns The device instance. 607 633 * @param GCPhys The guest physical address of the memory buffer. 608 634 * @param pSgBuf The pointer to the host R3 S/G buffer. … … 614 640 * cbCopy < *pcbSkip or 0 otherwise. 615 641 */ 616 typedef DECLCALLBACK(void) AHCIR3MEMCOPYCALLBACK(PAHCI pThis, RTGCPHYS GCPhys, PRTSGBUF pSgBuf, size_t cbCopy, size_t *pcbSkip); 642 typedef DECLCALLBACK(void) AHCIR3MEMCOPYCALLBACK(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, 643 PRTSGBUF pSgBuf, size_t cbCopy, size_t *pcbSkip); 617 644 /** Pointer to a memory copy buffer callback. */ 618 645 typedef AHCIR3MEMCOPYCALLBACK *PAHCIR3MEMCOPYCALLBACK; … … 805 832 { 806 833 const char *pszName; 807 int (*pfnRead )(PAHCI pThis, uint32_t iReg, uint32_t *pu32Value);808 int (*pfnWrite)(PAHCI pThis, uint32_t iReg, uint32_t u32Value);834 VBOXSTRICTRC (*pfnRead )(PPDMDEVINS pDevIns, PAHCI pThis, uint32_t iReg, uint32_t *pu32Value); 835 VBOXSTRICTRC (*pfnWrite)(PPDMDEVINS pDevIns, PAHCI pThis, uint32_t iReg, uint32_t u32Value); 809 836 } AHCIOPREG; 810 837 … … 815 842 { 816 843 const char *pszName; 817 int (*pfnRead )(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t *pu32Value);818 int (*pfnWrite)(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t u32Value);844 VBOXSTRICTRC (*pfnRead )(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t *pu32Value); 845 VBOXSTRICTRC (*pfnWrite)(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t u32Value); 819 846 } AHCIPORTOPREG; 820 847 … … 826 853 RT_C_DECLS_BEGIN 827 854 #ifdef IN_RING3 828 static void ahciHBAReset(PAHCI pThis); 829 static int ahciPostFisIntoMemory(PAHCIPort pAhciPort, unsigned uFisType, uint8_t *cmdFis); 830 static void ahciPostFirstD2HFisIntoMemory(PAHCIPort pAhciPort); 831 static size_t ahciR3CopyBufferToPrdtl(PAHCI pThis, PAHCIREQ pAhciReq, const void *pvSrc, 832 size_t cbSrc, size_t cbSkip); 833 static bool ahciCancelActiveTasks(PAHCIPort pAhciPort); 855 static void ahciR3HBAReset(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIR3 pThisCC); 856 static int ahciPostFisIntoMemory(PPDMDEVINS pDevIns, PAHCIPORT pAhciPort, unsigned uFisType, uint8_t *pCmdFis); 857 static void ahciPostFirstD2HFisIntoMemory(PPDMDEVINS pDevIns, PAHCIPORT pAhciPort); 858 static size_t ahciR3CopyBufferToPrdtl(PPDMDEVINS pDevIns, PAHCIREQ pAhciReq, const void *pvSrc, size_t cbSrc, size_t cbSkip); 859 static bool ahciR3CancelActiveTasks(PAHCIPORTR3 pAhciPortR3); 834 860 #endif 835 861 RT_C_DECLS_END … … 839 865 * Defined Constants And Macros * 840 866 *********************************************************************************************************************************/ 841 #define PDMIBASE_2_PAHCIPORT(pInterface) ( (PAHCIPort)((uintptr_t)(pInterface) - RT_UOFFSETOF(AHCIPort, IBase)) )842 #define PDMIMEDIAPORT_2_PAHCIPORT(pInterface) ( (PAHCIPort)((uintptr_t)(pInterface) - RT_UOFFSETOF(AHCIPort, IPort)) )843 #define PDMIBASE_2_PAHCI(pInterface) ( (PAHCI)((uintptr_t)(pInterface) - RT_UOFFSETOF(AHCI, IBase)) )844 #define PDMILEDPORTS_2_PAHCI(pInterface) ( (PAHCI)((uintptr_t)(pInterface) - RT_UOFFSETOF(AHCI, ILeds)) )845 846 867 #define AHCI_RTGCPHYS_FROM_U32(Hi, Lo) ( (RTGCPHYS)RT_MAKE_U64(Lo, Hi) ) 847 868 … … 883 904 * Update PCI IRQ levels 884 905 */ 885 static void ahciHbaClearInterrupt(P AHCI pThis)906 static void ahciHbaClearInterrupt(PPDMDEVINS pDevIns) 886 907 { 887 908 Log(("%s: Clearing interrupt\n", __FUNCTION__)); 888 PDMDevHlpPCISetIrq(p This->CTX_SUFF(pDevIns), 0, 0);909 PDMDevHlpPCISetIrq(pDevIns, 0, 0); 889 910 } 890 911 … … 892 913 * Updates the IRQ level and sets port bit in the global interrupt status register of the HBA. 893 914 */ 894 static int ahciHbaSetInterrupt(P AHCI pThis, uint8_t iPort, int rcBusy)915 static int ahciHbaSetInterrupt(PPDMDEVINS pDevIns, PAHCI pThis, uint8_t iPort, int rcBusy) 895 916 { 896 917 Log(("P%u: %s: Setting interrupt\n", iPort, __FUNCTION__)); 897 918 898 int rc = PDMDevHlpCritSectEnter(p This->CTX_SUFF(pDevIns), &pThis->lock, rcBusy);919 int rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->lock, rcBusy); 899 920 if (rc != VINF_SUCCESS) 900 921 return rc; … … 908 929 { 909 930 /* Reset command completion coalescing state. */ 910 PDMDevHlpTimerSetMillies(p This->CTX_SUFF(pDevIns), pThis->hHbaCccTimer, pThis->uCccTimeout);931 PDMDevHlpTimerSetMillies(pDevIns, pThis->hHbaCccTimer, pThis->uCccTimeout); 911 932 pThis->uCccCurrentNr = 0; 912 933 … … 915 936 { 916 937 Log(("P%u: %s: Fire interrupt\n", iPort, __FUNCTION__)); 917 PDMDevHlpPCISetIrq(p This->CTX_SUFF(pDevIns), 0, 1);938 PDMDevHlpPCISetIrq(pDevIns, 0, 1); 918 939 } 919 940 } … … 930 951 { 931 952 Log(("P%u: %s: Fire interrupt\n", iPort, __FUNCTION__)); 932 PDMDevHlpPCISetIrq(p This->CTX_SUFF(pDevIns), 0, 1);953 PDMDevHlpPCISetIrq(pDevIns, 0, 1); 933 954 } 934 955 } 935 956 } 936 957 937 PDMDevHlpCritSectLeave(p This->CTX_SUFF(pDevIns), &pThis->lock);958 PDMDevHlpCritSectLeave(pDevIns, &pThis->lock); 938 959 return VINF_SUCCESS; 939 960 } … … 949 970 PAHCI pThis = (PAHCI)pvUser; 950 971 951 int rc = ahciHbaSetInterrupt(p This, pThis->uCccPortNr, VERR_IGNORED);972 int rc = ahciHbaSetInterrupt(pDevIns, pThis, pThis->uCccPortNr, VERR_IGNORED); 952 973 AssertRC(rc); 953 974 } … … 957 978 * 958 979 * @returns nothing. 959 * @param pAhciPort The port to finish the reset on. 960 */ 961 static void ahciPortResetFinish(PAHCIPort pAhciPort) 980 * @param pDevIns The device instance. 981 * @param pThis The shared AHCI state. 982 * @param pAhciPort The port to finish the reset on, shared bits. 983 * @param pAhciPortR3 The port to finish the reset on, ring-3 bits. 984 */ 985 static void ahciPortResetFinish(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, PAHCIPORTR3 pAhciPortR3) 962 986 { 963 987 ahciLog(("%s: Initiated.\n", __FUNCTION__)); 964 988 965 989 /* Cancel all tasks first. */ 966 bool fAllTasksCanceled = ahci CancelActiveTasks(pAhciPort);990 bool fAllTasksCanceled = ahciR3CancelActiveTasks(pAhciPortR3); 967 991 Assert(fAllTasksCanceled); NOREF(fAllTasksCanceled); 968 992 … … 980 1004 if ((pAhciPort->regCMD & AHCI_PORT_CMD_FRE) && (!pAhciPort->fFirstD2HFisSent)) 981 1005 { 982 ahciPostFirstD2HFisIntoMemory(p AhciPort);1006 ahciPostFirstD2HFisIntoMemory(pDevIns, pAhciPort); 983 1007 ASMAtomicOrU32(&pAhciPort->regIS, AHCI_PORT_IS_DHRS); 984 1008 985 1009 if (pAhciPort->regIE & AHCI_PORT_IE_DHRE) 986 1010 { 987 int rc = ahciHbaSetInterrupt(p AhciPort->CTX_SUFF(pAhci), pAhciPort->iLUN, VERR_IGNORED);1011 int rc = ahciHbaSetInterrupt(pDevIns, pThis, pAhciPort->iLUN, VERR_IGNORED); 988 1012 AssertRC(rc); 989 1013 } … … 1018 1042 * 1019 1043 * @returns nothing. 1020 * @param p This The AHCI controllerinstance.1021 * @param pAhciPort The port to kick.1022 */ 1023 static void ahciIoThreadKick(P AHCI pThis, PAHCIPortpAhciPort)1044 * @param pDevIns The device instance. 1045 * @param pAhciPort The port to kick. 1046 */ 1047 static void ahciIoThreadKick(PPDMDEVINS pDevIns, PAHCIPORT pAhciPort) 1024 1048 { 1025 1049 LogFlowFunc(("Signal event semaphore\n")); 1026 int rc = PDMDevHlpSUPSemEventSignal(p This->CTX_SUFF(pDevIns), pAhciPort->hEvtProcess);1050 int rc = PDMDevHlpSUPSemEventSignal(pDevIns, pAhciPort->hEvtProcess); 1027 1051 AssertRC(rc); 1028 1052 } 1029 1053 1030 static int PortCmdIssue_w(PAHCI pThis, PAHCIPort pAhciPort, uint32_t iReg, uint32_t u32Value) 1031 { 1032 RT_NOREF(iReg); 1054 static VBOXSTRICTRC PortCmdIssue_w(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t u32Value) 1055 { 1033 1056 ahciLog(("%s: write u32Value=%#010x\n", __FUNCTION__, u32Value)); 1057 RT_NOREF(pThis, iReg); 1034 1058 1035 1059 /* Update the CI register first. */ … … 1050 1074 /* Send a notification to R3 if u32TasksNew was 0 before our write. */ 1051 1075 if (ASMAtomicReadBool(&pAhciPort->fWrkThreadSleeping)) 1052 ahciIoThreadKick(p This, pAhciPort);1076 ahciIoThreadKick(pDevIns, pAhciPort); 1053 1077 else 1054 1078 ahciLog(("%s: Worker thread busy, no need to kick.\n", __FUNCTION__)); … … 1062 1086 } 1063 1087 1064 static int PortCmdIssue_r(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t *pu32Value)1065 { 1066 RT_NOREF(p This, iReg);1088 static VBOXSTRICTRC PortCmdIssue_r(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t *pu32Value) 1089 { 1090 RT_NOREF(pDevIns, pThis, iReg); 1067 1091 1068 1092 uint32_t uCIValue = ASMAtomicXchgU32(&pAhciPort->u32TasksFinished, 0); … … 1075 1099 } 1076 1100 1077 static int PortSActive_w(PAHCI pThis, PAHCIPort pAhciPort, uint32_t iReg, uint32_t u32Value) 1078 { 1079 RT_NOREF(pThis, iReg); 1101 static VBOXSTRICTRC PortSActive_w(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t u32Value) 1102 { 1080 1103 ahciLog(("%s: write u32Value=%#010x\n", __FUNCTION__, u32Value)); 1104 RT_NOREF(pDevIns, pThis, iReg); 1081 1105 1082 1106 pAhciPort->regSACT |= u32Value; … … 1085 1109 } 1086 1110 1087 static int PortSActive_r(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t *pu32Value)1088 { 1089 RT_NOREF(p This, iReg);1111 static VBOXSTRICTRC PortSActive_r(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t *pu32Value) 1112 { 1113 RT_NOREF(pDevIns, pThis, iReg); 1090 1114 1091 1115 uint32_t u32TasksFinished = ASMAtomicXchgU32(&pAhciPort->u32QueuedTasksFinished, 0); … … 1100 1124 } 1101 1125 1102 static int PortSError_w(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t u32Value)1103 { 1104 RT_NOREF(p This, iReg);1126 static VBOXSTRICTRC PortSError_w(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t u32Value) 1127 { 1128 RT_NOREF(pDevIns, pThis, iReg); 1105 1129 ahciLog(("%s: write u32Value=%#010x\n", __FUNCTION__, u32Value)); 1106 1130 … … 1122 1146 } 1123 1147 1124 static int PortSError_r(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t *pu32Value)1125 { 1126 RT_NOREF(p This, iReg);1148 static VBOXSTRICTRC PortSError_r(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t *pu32Value) 1149 { 1150 RT_NOREF(pDevIns, pThis, iReg); 1127 1151 ahciLog(("%s: read regSERR=%#010x\n", __FUNCTION__, pAhciPort->regSERR)); 1128 1152 *pu32Value = pAhciPort->regSERR; … … 1130 1154 } 1131 1155 1132 static int PortSControl_w(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t u32Value)1156 static VBOXSTRICTRC PortSControl_w(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t u32Value) 1133 1157 { 1134 1158 RT_NOREF(pThis, iReg); … … 1138 1162 1139 1163 #ifndef IN_RING3 1140 RT_NOREF(p AhciPort, u32Value);1164 RT_NOREF(pDevIns, pAhciPort, u32Value); 1141 1165 return VINF_IOM_R3_MMIO_WRITE; 1142 1166 #else … … 1144 1168 { 1145 1169 if (!ASMAtomicXchgBool(&pAhciPort->fPortReset, true)) 1146 LogRel(("AHCI#%u: Port %d reset\n", p This->CTX_SUFF(pDevIns)->iInstance,1170 LogRel(("AHCI#%u: Port %d reset\n", pDevIns->iInstance, 1147 1171 pAhciPort->iLUN)); 1148 1172 … … 1155 1179 else if ( (u32Value & AHCI_PORT_SCTL_DET) == AHCI_PORT_SCTL_DET_NINIT 1156 1180 && (pAhciPort->regSCTL & AHCI_PORT_SCTL_DET) == AHCI_PORT_SCTL_DET_INIT 1157 && pAhciPort-> pDrvBase)1181 && pAhciPort->fPresent) 1158 1182 { 1159 1183 /* Do the port reset here, so the guest sees the new status immediately. */ 1160 1184 if (pThis->fLegacyPortResetMethod) 1161 1185 { 1162 ahciPortResetFinish(pAhciPort); 1186 PAHCIR3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAHCICC); 1187 PAHCIPORTR3 pAhciPortR3 = &RT_SAFE_SUBSCRIPT(pThisCC->aPorts, pAhciPort->iLUN); 1188 ahciPortResetFinish(pDevIns, pThis, pAhciPort, pAhciPortR3); 1163 1189 pAhciPort->regSCTL = u32Value; /* Update after finishing the reset, so the I/O thread doesn't get a chance to do the reset. */ 1164 1190 } … … 1172 1198 1173 1199 /* Kick the thread to finish the reset. */ 1174 ahciIoThreadKick(p This, pAhciPort);1200 ahciIoThreadKick(pDevIns, pAhciPort); 1175 1201 } 1176 1202 } … … 1182 1208 } 1183 1209 1184 static int PortSControl_r(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t *pu32Value)1185 { 1186 RT_NOREF(p This, iReg);1210 static VBOXSTRICTRC PortSControl_r(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t *pu32Value) 1211 { 1212 RT_NOREF(pDevIns, pThis, iReg); 1187 1213 ahciLog(("%s: read regSCTL=%#010x\n", __FUNCTION__, pAhciPort->regSCTL)); 1188 1214 ahciLog(("%s: IPM=%d SPD=%d DET=%d\n", __FUNCTION__, … … 1194 1220 } 1195 1221 1196 static int PortSStatus_r(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t *pu32Value)1197 { 1198 RT_NOREF(p This, iReg);1222 static VBOXSTRICTRC PortSStatus_r(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t *pu32Value) 1223 { 1224 RT_NOREF(pDevIns, pThis, iReg); 1199 1225 ahciLog(("%s: read regSSTS=%#010x\n", __FUNCTION__, pAhciPort->regSSTS)); 1200 1226 ahciLog(("%s: IPM=%d SPD=%d DET=%d\n", __FUNCTION__, … … 1206 1232 } 1207 1233 1208 static int PortSignature_r(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t *pu32Value)1209 { 1210 RT_NOREF(p This, iReg);1234 static VBOXSTRICTRC PortSignature_r(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t *pu32Value) 1235 { 1236 RT_NOREF(pDevIns, pThis, iReg); 1211 1237 ahciLog(("%s: read regSIG=%#010x\n", __FUNCTION__, pAhciPort->regSIG)); 1212 1238 *pu32Value = pAhciPort->regSIG; … … 1214 1240 } 1215 1241 1216 static int PortTaskFileData_r(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t *pu32Value)1217 { 1218 RT_NOREF(p This, iReg);1242 static VBOXSTRICTRC PortTaskFileData_r(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t *pu32Value) 1243 { 1244 RT_NOREF(pDevIns, pThis, iReg); 1219 1245 ahciLog(("%s: read regTFD=%#010x\n", __FUNCTION__, pAhciPort->regTFD)); 1220 1246 ahciLog(("%s: ERR=%x BSY=%d DRQ=%d ERR=%d\n", __FUNCTION__, … … 1228 1254 * Read from the port command register. 1229 1255 */ 1230 static int PortCmd_r(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t *pu32Value)1231 { 1232 RT_NOREF(p This, iReg);1256 static VBOXSTRICTRC PortCmd_r(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t *pu32Value) 1257 { 1258 RT_NOREF(pDevIns, pThis, iReg); 1233 1259 ahciLog(("%s: read regCMD=%#010x\n", __FUNCTION__, pAhciPort->regCMD | AHCI_PORT_CMD_CCS_SHIFT(pAhciPort->u32CurrentCommandSlot))); 1234 1260 ahciLog(("%s: ICC=%d ASP=%d ALPE=%d DLAE=%d ATAPI=%d CPD=%d ISP=%d HPCP=%d PMA=%d CPS=%d CR=%d FR=%d ISS=%d CCS=%d FRE=%d CLO=%d POD=%d SUD=%d ST=%d\n", … … 1251 1277 * This is the register where all the data transfer is started 1252 1278 */ 1253 static int PortCmd_w(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t u32Value)1254 { 1255 RT_NOREF( iReg);1279 static VBOXSTRICTRC PortCmd_w(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t u32Value) 1280 { 1281 RT_NOREF(pDevIns, pThis, iReg); 1256 1282 ahciLog(("%s: write u32Value=%#010x\n", __FUNCTION__, u32Value)); 1257 1283 ahciLog(("%s: ICC=%d ASP=%d ALPE=%d DLAE=%d ATAPI=%d CPD=%d ISP=%d HPCP=%d PMA=%d CPS=%d CR=%d FR=%d ISS=%d CCS=%d FRE=%d CLO=%d POD=%d SUD=%d ST=%d\n", … … 1286 1312 * IS.PCS is clear. 1287 1313 */ 1288 if ( pAhciPort-> pDrvBase1314 if ( pAhciPort->fPresent 1289 1315 && !(pAhciPort->regIS & AHCI_PORT_IS_PCS)) 1290 1316 { … … 1298 1324 ASMAtomicOrU32(&pAhciPort->u32TasksNew, pAhciPort->regCI); 1299 1325 LogFlowFunc(("Signal event semaphore\n")); 1300 int rc = PDMDevHlpSUPSemEventSignal(p This->CTX_SUFF(pDevIns), pAhciPort->hEvtProcess);1326 int rc = PDMDevHlpSUPSemEventSignal(pDevIns, pAhciPort->hEvtProcess); 1301 1327 AssertRC(rc); 1302 1328 } … … 1304 1330 else 1305 1331 { 1306 if (!pAhciPort-> pDrvBase)1332 if (!pAhciPort->fPresent) 1307 1333 ahciLog(("%s: No pDrvBase, clearing PxCMD.CR!\n", __FUNCTION__)); 1308 1334 else … … 1323 1349 } 1324 1350 } 1325 else if (pAhciPort-> pDrvBase)1351 else if (pAhciPort->fPresent) 1326 1352 { 1327 1353 if ((u32Value & AHCI_PORT_CMD_POD) && (pAhciPort->regCMD & AHCI_PORT_CMD_CPS) && !pAhciPort->fPoweredOn) … … 1346 1372 return VINF_IOM_R3_MMIO_WRITE; 1347 1373 #else 1348 ahciPostFirstD2HFisIntoMemory(p AhciPort);1374 ahciPostFirstD2HFisIntoMemory(pDevIns, pAhciPort); 1349 1375 ASMAtomicOrU32(&pAhciPort->regIS, AHCI_PORT_IS_DHRS); 1350 1376 1351 1377 if (pAhciPort->regIE & AHCI_PORT_IE_DHRE) 1352 1378 { 1353 int rc = ahciHbaSetInterrupt(p AhciPort->CTX_SUFF(pAhci), pAhciPort->iLUN, VERR_IGNORED);1379 int rc = ahciHbaSetInterrupt(pDevIns, pThis, pAhciPort->iLUN, VERR_IGNORED); 1354 1380 AssertRC(rc); 1355 1381 } … … 1375 1401 /* Send the first D2H FIS only if it wasn't already sent. */ 1376 1402 if ( !pAhciPort->fFirstD2HFisSent 1377 && pAhciPort-> pDrvBase)1403 && pAhciPort->fPresent) 1378 1404 { 1379 1405 #ifndef IN_RING3 1380 1406 return VINF_IOM_R3_MMIO_WRITE; 1381 1407 #else 1382 ahciPostFirstD2HFisIntoMemory(p AhciPort);1408 ahciPostFirstD2HFisIntoMemory(pDevIns, pAhciPort); 1383 1409 pAhciPort->fFirstD2HFisSent = true; 1384 1410 #endif … … 1399 1425 * Read from the port interrupt enable register. 1400 1426 */ 1401 static int PortIntrEnable_r(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t *pu32Value)1402 { 1403 RT_NOREF(p This, iReg);1427 static VBOXSTRICTRC PortIntrEnable_r(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t *pu32Value) 1428 { 1429 RT_NOREF(pDevIns, pThis, iReg); 1404 1430 ahciLog(("%s: read regIE=%#010x\n", __FUNCTION__, pAhciPort->regIE)); 1405 1431 ahciLog(("%s: CPDE=%d TFEE=%d HBFE=%d HBDE=%d IFE=%d INFE=%d OFE=%d IPME=%d PRCE=%d DIE=%d PCE=%d DPE=%d UFE=%d SDBE=%d DSE=%d PSE=%d DHRE=%d\n", … … 1420 1446 * Write to the port interrupt enable register. 1421 1447 */ 1422 static int PortIntrEnable_w(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t u32Value)1448 static VBOXSTRICTRC PortIntrEnable_w(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t u32Value) 1423 1449 { 1424 1450 RT_NOREF(iReg); … … 1442 1468 int rc = VINF_SUCCESS; 1443 1469 if (u32Value & u32IntrStatus) 1444 rc = ahciHbaSetInterrupt(p This, pAhciPort->iLUN, VINF_IOM_R3_MMIO_WRITE);1470 rc = ahciHbaSetInterrupt(pDevIns, pThis, pAhciPort->iLUN, VINF_IOM_R3_MMIO_WRITE); 1445 1471 1446 1472 if (rc == VINF_SUCCESS) … … 1453 1479 * Read from the port interrupt status register. 1454 1480 */ 1455 static int PortIntrSts_r(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t *pu32Value)1456 { 1457 RT_NOREF(p This, iReg);1481 static VBOXSTRICTRC PortIntrSts_r(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t *pu32Value) 1482 { 1483 RT_NOREF(pDevIns, pThis, iReg); 1458 1484 ahciLog(("%s: read regIS=%#010x\n", __FUNCTION__, pAhciPort->regIS)); 1459 1485 ahciLog(("%s: CPDS=%d TFES=%d HBFS=%d HBDS=%d IFS=%d INFS=%d OFS=%d IPMS=%d PRCS=%d DIS=%d PCS=%d DPS=%d UFS=%d SDBS=%d DSS=%d PSS=%d DHRS=%d\n", … … 1474 1500 * Write to the port interrupt status register. 1475 1501 */ 1476 static int PortIntrSts_w(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t u32Value)1477 { 1478 RT_NOREF(p This, iReg);1502 static VBOXSTRICTRC PortIntrSts_w(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t u32Value) 1503 { 1504 RT_NOREF(pDevIns, pThis, iReg); 1479 1505 ahciLog(("%s: write u32Value=%#010x\n", __FUNCTION__, u32Value)); 1480 1506 ASMAtomicAndU32(&pAhciPort->regIS, ~(u32Value & AHCI_PORT_IS_READONLY)); … … 1486 1512 * Read from the port FIS base address upper 32bit register. 1487 1513 */ 1488 static int PortFisAddrUp_r(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t *pu32Value)1489 { 1490 RT_NOREF(p This, iReg);1514 static VBOXSTRICTRC PortFisAddrUp_r(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t *pu32Value) 1515 { 1516 RT_NOREF(pDevIns, pThis, iReg); 1491 1517 ahciLog(("%s: read regFBU=%#010x\n", __FUNCTION__, pAhciPort->regFBU)); 1492 1518 *pu32Value = pAhciPort->regFBU; … … 1497 1523 * Write to the port FIS base address upper 32bit register. 1498 1524 */ 1499 static int PortFisAddrUp_w(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t u32Value)1500 { 1501 RT_NOREF(p This, iReg);1525 static VBOXSTRICTRC PortFisAddrUp_w(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t u32Value) 1526 { 1527 RT_NOREF(pDevIns, pThis, iReg); 1502 1528 ahciLog(("%s: write u32Value=%#010x\n", __FUNCTION__, u32Value)); 1503 1529 … … 1511 1537 * Read from the port FIS base address register. 1512 1538 */ 1513 static int PortFisAddr_r(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t *pu32Value)1514 { 1515 RT_NOREF(p This, iReg);1539 static VBOXSTRICTRC PortFisAddr_r(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t *pu32Value) 1540 { 1541 RT_NOREF(pDevIns, pThis, iReg); 1516 1542 ahciLog(("%s: read regFB=%#010x\n", __FUNCTION__, pAhciPort->regFB)); 1517 1543 *pu32Value = pAhciPort->regFB; … … 1522 1548 * Write to the port FIS base address register. 1523 1549 */ 1524 static int PortFisAddr_w(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t u32Value)1525 { 1526 RT_NOREF(p This, iReg);1550 static VBOXSTRICTRC PortFisAddr_w(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t u32Value) 1551 { 1552 RT_NOREF(pDevIns, pThis, iReg); 1527 1553 ahciLog(("%s: write u32Value=%#010x\n", __FUNCTION__, u32Value)); 1528 1554 … … 1538 1564 * Write to the port command list base address upper 32bit register. 1539 1565 */ 1540 static int PortCmdLstAddrUp_w(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t u32Value)1541 { 1542 RT_NOREF(p This, iReg);1566 static VBOXSTRICTRC PortCmdLstAddrUp_w(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t u32Value) 1567 { 1568 RT_NOREF(pDevIns, pThis, iReg); 1543 1569 ahciLog(("%s: write u32Value=%#010x\n", __FUNCTION__, u32Value)); 1544 1570 … … 1552 1578 * Read from the port command list base address upper 32bit register. 1553 1579 */ 1554 static int PortCmdLstAddrUp_r(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t *pu32Value)1555 { 1556 RT_NOREF(p This, iReg);1580 static VBOXSTRICTRC PortCmdLstAddrUp_r(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t *pu32Value) 1581 { 1582 RT_NOREF(pDevIns, pThis, iReg); 1557 1583 ahciLog(("%s: read regCLBU=%#010x\n", __FUNCTION__, pAhciPort->regCLBU)); 1558 1584 *pu32Value = pAhciPort->regCLBU; … … 1563 1589 * Read from the port command list base address register. 1564 1590 */ 1565 static int PortCmdLstAddr_r(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t *pu32Value)1566 { 1567 RT_NOREF(p This, iReg);1591 static VBOXSTRICTRC PortCmdLstAddr_r(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t *pu32Value) 1592 { 1593 RT_NOREF(pDevIns, pThis, iReg); 1568 1594 ahciLog(("%s: read regCLB=%#010x\n", __FUNCTION__, pAhciPort->regCLB)); 1569 1595 *pu32Value = pAhciPort->regCLB; … … 1574 1600 * Write to the port command list base address register. 1575 1601 */ 1576 static int PortCmdLstAddr_w(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t u32Value)1577 { 1578 RT_NOREF(p This, iReg);1602 static VBOXSTRICTRC PortCmdLstAddr_w(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t u32Value) 1603 { 1604 RT_NOREF(pDevIns, pThis, iReg); 1579 1605 ahciLog(("%s: write u32Value=%#010x\n", __FUNCTION__, u32Value)); 1580 1606 … … 1590 1616 * Read from the global Version register. 1591 1617 */ 1592 static int HbaVersion_r(PAHCI pThis, uint32_t iReg, uint32_t *pu32Value)1593 { 1594 RT_NOREF( iReg);1618 static VBOXSTRICTRC HbaVersion_r(PPDMDEVINS pDevIns, PAHCI pThis, uint32_t iReg, uint32_t *pu32Value) 1619 { 1620 RT_NOREF(pDevIns, iReg); 1595 1621 Log(("%s: read regHbaVs=%#010x\n", __FUNCTION__, pThis->regHbaVs)); 1596 1622 *pu32Value = pThis->regHbaVs; … … 1601 1627 * Read from the global Ports implemented register. 1602 1628 */ 1603 static int HbaPortsImplemented_r(PAHCI pThis, uint32_t iReg, uint32_t *pu32Value)1604 { 1605 RT_NOREF( iReg);1629 static VBOXSTRICTRC HbaPortsImplemented_r(PPDMDEVINS pDevIns, PAHCI pThis, uint32_t iReg, uint32_t *pu32Value) 1630 { 1631 RT_NOREF(pDevIns, iReg); 1606 1632 Log(("%s: read regHbaPi=%#010x\n", __FUNCTION__, pThis->regHbaPi)); 1607 1633 *pu32Value = pThis->regHbaPi; … … 1612 1638 * Write to the global interrupt status register. 1613 1639 */ 1614 static int HbaInterruptStatus_w(PAHCI pThis, uint32_t iReg, uint32_t u32Value)1640 static VBOXSTRICTRC HbaInterruptStatus_w(PPDMDEVINS pDevIns, PAHCI pThis, uint32_t iReg, uint32_t u32Value) 1615 1641 { 1616 1642 RT_NOREF(iReg); 1617 1643 Log(("%s: write u32Value=%#010x\n", __FUNCTION__, u32Value)); 1618 1644 1619 int rc = PDMDevHlpCritSectEnter(p This->CTX_SUFF(pDevIns), &pThis->lock, VINF_IOM_R3_MMIO_WRITE);1645 int rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->lock, VINF_IOM_R3_MMIO_WRITE); 1620 1646 if (rc != VINF_SUCCESS) 1621 1647 return rc; … … 1638 1664 if (u32Value & 0x01) 1639 1665 { 1640 PAHCIP ortpAhciPort = &pThis->ahciPort[i];1666 PAHCIPORT pAhciPort = &pThis->ahciPort[i]; 1641 1667 1642 1668 if (pAhciPort->regIE & pAhciPort->regIS) … … 1656 1682 1657 1683 if (fClear) 1658 ahciHbaClearInterrupt(p This);1684 ahciHbaClearInterrupt(pDevIns); 1659 1685 else 1660 1686 { … … 1665 1691 * We need to clear it first because the PCI bus only calls the interrupt controller if the state changes. 1666 1692 */ 1667 PDMDevHlpPCISetIrq(p This->CTX_SUFF(pDevIns), 0, 0);1668 PDMDevHlpPCISetIrq(p This->CTX_SUFF(pDevIns), 0, 1);1669 } 1670 1671 PDMDevHlpCritSectLeave(p This->CTX_SUFF(pDevIns), &pThis->lock);1693 PDMDevHlpPCISetIrq(pDevIns, 0, 0); 1694 PDMDevHlpPCISetIrq(pDevIns, 0, 1); 1695 } 1696 1697 PDMDevHlpCritSectLeave(pDevIns, &pThis->lock); 1672 1698 return VINF_SUCCESS; 1673 1699 } … … 1676 1702 * Read from the global interrupt status register. 1677 1703 */ 1678 static int HbaInterruptStatus_r(PAHCI pThis, uint32_t iReg, uint32_t *pu32Value)1704 static VBOXSTRICTRC HbaInterruptStatus_r(PPDMDEVINS pDevIns, PAHCI pThis, uint32_t iReg, uint32_t *pu32Value) 1679 1705 { 1680 1706 RT_NOREF(iReg); 1681 1707 1682 int rc = PDMDevHlpCritSectEnter(p This->CTX_SUFF(pDevIns), &pThis->lock, VINF_IOM_R3_MMIO_READ);1708 int rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->lock, VINF_IOM_R3_MMIO_READ); 1683 1709 if (rc != VINF_SUCCESS) 1684 1710 return rc; … … 1686 1712 uint32_t u32PortsInterrupted = ASMAtomicXchgU32(&pThis->u32PortsInterrupted, 0); 1687 1713 1688 PDMDevHlpCritSectLeave(p This->CTX_SUFF(pDevIns), &pThis->lock);1714 PDMDevHlpCritSectLeave(pDevIns, &pThis->lock); 1689 1715 Log(("%s: read regHbaIs=%#010x u32PortsInterrupted=%#010x\n", __FUNCTION__, pThis->regHbaIs, u32PortsInterrupted)); 1690 1716 … … 1693 1719 #ifdef LOG_ENABLED 1694 1720 Log(("%s:", __FUNCTION__)); 1695 u nsigned i;1696 for ( i = 0; i < pThis->cPortsImpl; i++)1721 uint32_t const cPortsImpl = RT_MIN(pThis->cPortsImpl, RT_ELEMENTS(pThis->ahciPort)); 1722 for (unsigned i = 0; i < cPortsImpl; i++) 1697 1723 { 1698 1724 if ((pThis->regHbaIs >> i) & 0x01) … … 1710 1736 * Write to the global control register. 1711 1737 */ 1712 static int HbaControl_w(PAHCI pThis, uint32_t iReg, uint32_t u32Value) 1713 { 1714 RT_NOREF(iReg); 1738 static VBOXSTRICTRC HbaControl_w(PPDMDEVINS pDevIns, PAHCI pThis, uint32_t iReg, uint32_t u32Value) 1739 { 1715 1740 Log(("%s: write u32Value=%#010x\n" 1716 1741 "%s: AE=%d IE=%d HR=%d\n", … … 1718 1743 __FUNCTION__, (u32Value & AHCI_HBA_CTRL_AE) >> 31, (u32Value & AHCI_HBA_CTRL_IE) >> 1, 1719 1744 (u32Value & AHCI_HBA_CTRL_HR))); 1745 RT_NOREF(iReg); 1720 1746 1721 1747 #ifndef IN_RING3 1722 RT_NOREF(p This, u32Value);1748 RT_NOREF(pDevIns, pThis, u32Value); 1723 1749 return VINF_IOM_R3_MMIO_WRITE; 1724 1750 #else … … 1737 1763 if ( (u32Value & AHCI_HBA_CTRL_HR) 1738 1764 && !cThreadsActive) 1739 ahci HBAReset(pThis);1765 ahciR3HBAReset(pDevIns, pThis, PDMDEVINS_2_DATA_CC(pDevIns, PAHCICC)); 1740 1766 1741 1767 return VINF_SUCCESS; … … 1746 1772 * Read the global control register. 1747 1773 */ 1748 static int HbaControl_r(PAHCI pThis, uint32_t iReg, uint32_t *pu32Value)1749 { 1750 RT_NOREF( iReg);1774 static VBOXSTRICTRC HbaControl_r(PPDMDEVINS pDevIns, PAHCI pThis, uint32_t iReg, uint32_t *pu32Value) 1775 { 1776 RT_NOREF(pDevIns, iReg); 1751 1777 Log(("%s: read regHbaCtrl=%#010x\n" 1752 1778 "%s: AE=%d IE=%d HR=%d\n", … … 1761 1787 * Read the global capabilities register. 1762 1788 */ 1763 static int HbaCapabilities_r(PAHCI pThis, uint32_t iReg, uint32_t *pu32Value)1764 { 1765 RT_NOREF( iReg);1789 static VBOXSTRICTRC HbaCapabilities_r(PPDMDEVINS pDevIns, PAHCI pThis, uint32_t iReg, uint32_t *pu32Value) 1790 { 1791 RT_NOREF(pDevIns, iReg); 1766 1792 Log(("%s: read regHbaCap=%#010x\n" 1767 1793 "%s: S64A=%d SNCQ=%d SIS=%d SSS=%d SALP=%d SAL=%d SCLO=%d ISS=%d SNZO=%d SAM=%d SPM=%d PMD=%d SSC=%d PSC=%d NCS=%d NP=%d\n", … … 1782 1808 * Write to the global command completion coalescing control register. 1783 1809 */ 1784 static int HbaCccCtl_w(PAHCI pThis, uint32_t iReg, uint32_t u32Value)1810 static VBOXSTRICTRC HbaCccCtl_w(PPDMDEVINS pDevIns, PAHCI pThis, uint32_t iReg, uint32_t u32Value) 1785 1811 { 1786 1812 RT_NOREF(iReg); … … 1797 1823 1798 1824 if (u32Value & AHCI_HBA_CCC_CTL_EN) 1799 PDMDevHlpTimerSetMillies(p This->CTX_SUFF(pDevIns), pThis->hHbaCccTimer, pThis->uCccTimeout); /* Arm the timer */1825 PDMDevHlpTimerSetMillies(pDevIns, pThis->hHbaCccTimer, pThis->uCccTimeout); /* Arm the timer */ 1800 1826 else 1801 PDMDevHlpTimerStop(p This->CTX_SUFF(pDevIns), pThis->hHbaCccTimer);1827 PDMDevHlpTimerStop(pDevIns, pThis->hHbaCccTimer); 1802 1828 1803 1829 return VINF_SUCCESS; … … 1807 1833 * Read the global command completion coalescing control register. 1808 1834 */ 1809 static int HbaCccCtl_r(PAHCI pThis, uint32_t iReg, uint32_t *pu32Value)1810 { 1811 RT_NOREF( iReg);1835 static VBOXSTRICTRC HbaCccCtl_r(PPDMDEVINS pDevIns, PAHCI pThis, uint32_t iReg, uint32_t *pu32Value) 1836 { 1837 RT_NOREF(pDevIns, iReg); 1812 1838 Log(("%s: read regHbaCccCtl=%#010x\n" 1813 1839 "%s: TV=%d CC=%d INT=%d EN=%d\n", … … 1822 1848 * Write to the global command completion coalescing ports register. 1823 1849 */ 1824 static int HbaCccPorts_w(PAHCI pThis, uint32_t iReg, uint32_t u32Value)1825 { 1826 RT_NOREF( iReg);1850 static VBOXSTRICTRC HbaCccPorts_w(PPDMDEVINS pDevIns, PAHCI pThis, uint32_t iReg, uint32_t u32Value) 1851 { 1852 RT_NOREF(pDevIns, iReg); 1827 1853 Log(("%s: write u32Value=%#010x\n", __FUNCTION__, u32Value)); 1828 1854 … … 1835 1861 * Read the global command completion coalescing ports register. 1836 1862 */ 1837 static int HbaCccPorts_r(PAHCI pThis, uint32_t iReg, uint32_t *pu32Value)1838 { 1839 RT_NOREF( iReg);1863 static VBOXSTRICTRC HbaCccPorts_r(PPDMDEVINS pDevIns, PAHCI pThis, uint32_t iReg, uint32_t *pu32Value) 1864 { 1865 RT_NOREF(pDevIns, iReg); 1840 1866 Log(("%s: read regHbaCccPorts=%#010x\n", __FUNCTION__, pThis->regHbaCccPorts)); 1841 1867 1842 1868 #ifdef LOG_ENABLED 1843 1869 Log(("%s:", __FUNCTION__)); 1844 u nsigned i;1845 for ( i = 0; i < pThis->cPortsImpl; i++)1870 uint32_t const cPortsImpl = RT_MIN(pThis->cPortsImpl, RT_ELEMENTS(pThis->ahciPort)); 1871 for (unsigned i = 0; i < cPortsImpl; i++) 1846 1872 { 1847 1873 if ((pThis->regHbaCccPorts >> i) & 0x01) … … 1858 1884 * Invalid write to global register 1859 1885 */ 1860 static int HbaInvalid_w(PAHCI pThis, uint32_t iReg, uint32_t u32Value)1861 { 1862 RT_NOREF(p This, iReg, u32Value);1886 static VBOXSTRICTRC HbaInvalid_w(PPDMDEVINS pDevIns, PAHCI pThis, uint32_t iReg, uint32_t u32Value) 1887 { 1888 RT_NOREF(pDevIns, pThis, iReg, u32Value); 1863 1889 Log(("%s: Write denied!!! iReg=%u u32Value=%#010x\n", __FUNCTION__, iReg, u32Value)); 1864 1890 return VINF_SUCCESS; … … 1868 1894 * Invalid Port write. 1869 1895 */ 1870 static int PortInvalid_w(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t u32Value)1871 { 1872 RT_NOREF(p This, pAhciPort, iReg, u32Value);1896 static VBOXSTRICTRC PortInvalid_w(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t u32Value) 1897 { 1898 RT_NOREF(pDevIns, pThis, pAhciPort, iReg, u32Value); 1873 1899 ahciLog(("%s: Write denied!!! iReg=%u u32Value=%#010x\n", __FUNCTION__, iReg, u32Value)); 1874 1900 return VINF_SUCCESS; … … 1878 1904 * Invalid Port read. 1879 1905 */ 1880 static int PortInvalid_r(PAHCI pThis, PAHCIPortpAhciPort, uint32_t iReg, uint32_t *pu32Value)1881 { 1882 RT_NOREF(p This, pAhciPort, iReg, pu32Value);1906 static VBOXSTRICTRC PortInvalid_r(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t *pu32Value) 1907 { 1908 RT_NOREF(pDevIns, pThis, pAhciPort, iReg, pu32Value); 1883 1909 ahciLog(("%s: Read denied!!! iReg=%u\n", __FUNCTION__, iReg)); 1884 1910 return VINF_SUCCESS; … … 1923 1949 1924 1950 #ifdef IN_RING3 1951 1925 1952 /** 1926 1953 * Reset initiated by system software for one port. 1927 1954 * 1928 * @param pAhciPort The port to reset. 1929 */ 1930 static void ahciPortSwReset(PAHCIPort pAhciPort) 1955 * @param pAhciPort The port to reset, shared bits. 1956 * @param pAhciPortR3 The port to reset, ring-3 bits. 1957 */ 1958 static void ahciR3PortSwReset(PAHCIPORT pAhciPort, PAHCIPORTR3 pAhciPortR3) 1931 1959 { 1932 1960 bool fAllTasksCanceled; 1933 1961 1934 1962 /* Cancel all tasks first. */ 1935 fAllTasksCanceled = ahci CancelActiveTasks(pAhciPort);1963 fAllTasksCanceled = ahciR3CancelActiveTasks(pAhciPortR3); 1936 1964 Assert(fAllTasksCanceled); 1937 1965 … … 1968 1996 pAhciPort->u32CurrentCommandSlot = 0; 1969 1997 1970 if (pAhciPort-> pDrvBase)1998 if (pAhciPort->fPresent) 1971 1999 { 1972 2000 pAhciPort->regCMD |= AHCI_PORT_CMD_CPS; /* Indicate that there is a device on that port */ … … 1993 2021 * @param pAhciPort The port to reset. 1994 2022 */ 1995 static void ahciPortHwReset(PAHCIP ortpAhciPort)2023 static void ahciPortHwReset(PAHCIPORT pAhciPort) 1996 2024 { 1997 2025 /* Reset the address registers. */ … … 2025 2053 * Reset the entire HBA. 2026 2054 * 2027 * @param pThis The HBA state. 2028 */ 2029 static void ahciHBAReset(PAHCI pThis) 2055 * @param pDevIns The device instance. 2056 * @param pThis The shared AHCI state. 2057 * @param pThisCC The ring-3 AHCI state. 2058 */ 2059 static void ahciR3HBAReset(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIR3 pThisCC) 2030 2060 { 2031 2061 unsigned i; 2032 2062 int rc = VINF_SUCCESS; 2033 2063 2034 LogRel(("AHCI#%u: Reset the HBA\n", p This->CTX_SUFF(pDevIns)->iInstance));2064 LogRel(("AHCI#%u: Reset the HBA\n", pDevIns->iInstance)); 2035 2065 2036 2066 /* Stop the CCC timer. */ 2037 2067 if (pThis->regHbaCccCtl & AHCI_HBA_CCC_CTL_EN) 2038 2068 { 2039 rc = PDMDevHlpTimerStop(p This->CTX_SUFF(pDevIns), pThis->hHbaCccTimer);2069 rc = PDMDevHlpTimerStop(pDevIns, pThis->hHbaCccTimer); 2040 2070 if (RT_FAILURE(rc)) 2041 2071 AssertMsgFailed(("%s: Failed to stop timer!\n", __FUNCTION__)); … … 2043 2073 2044 2074 /* Reset every port */ 2045 for (i = 0; i < pThis->cPortsImpl; i++) 2046 { 2047 PAHCIPort pAhciPort = &pThis->ahciPort[i]; 2048 2049 pAhciPort->iLUN = i; 2050 ahciPortSwReset(pAhciPort); 2075 uint32_t const cPortsImpl = RT_MIN(pThis->cPortsImpl, RT_ELEMENTS(pThisCC->aPorts)); 2076 for (i = 0; i < cPortsImpl; i++) 2077 { 2078 PAHCIPORT pAhciPort = &pThis->ahciPort[i]; 2079 PAHCIPORTR3 pAhciPortR3 = &pThisCC->aPorts[i]; 2080 2081 pAhciPort->iLUN = i; 2082 pAhciPortR3->iLUN = i; 2083 ahciR3PortSwReset(pAhciPort, pAhciPortR3); 2051 2084 } 2052 2085 2053 2086 /* Init Global registers */ 2054 pThis->regHbaCap = AHCI_HBA_CAP_ISS_SHIFT(AHCI_HBA_CAP_ISS_GEN2) |2055 AHCI_HBA_CAP_S64A |/* 64bit addressing supported */2056 AHCI_HBA_CAP_SAM |/* AHCI mode only */2057 AHCI_HBA_CAP_SNCQ |/* Support native command queuing */2058 AHCI_HBA_CAP_SSS |/* Staggered spin up */2059 AHCI_HBA_CAP_CCCS |/* Support command completion coalescing */2060 AHCI_HBA_CAP_NCS_SET(pThis->cCmdSlotsAvail) |/* Number of command slots we support */2061 2087 pThis->regHbaCap = AHCI_HBA_CAP_ISS_SHIFT(AHCI_HBA_CAP_ISS_GEN2) 2088 | AHCI_HBA_CAP_S64A /* 64bit addressing supported */ 2089 | AHCI_HBA_CAP_SAM /* AHCI mode only */ 2090 | AHCI_HBA_CAP_SNCQ /* Support native command queuing */ 2091 | AHCI_HBA_CAP_SSS /* Staggered spin up */ 2092 | AHCI_HBA_CAP_CCCS /* Support command completion coalescing */ 2093 | AHCI_HBA_CAP_NCS_SET(pThis->cCmdSlotsAvail) /* Number of command slots we support */ 2094 | AHCI_HBA_CAP_NP_SET(pThis->cPortsImpl); /* Number of supported ports */ 2062 2095 pThis->regHbaCtrl = AHCI_HBA_CTRL_AE; 2063 2096 pThis->regHbaPi = ahciGetPortsImplemented(pThis->cPortsImpl); … … 2072 2105 pThis->regHbaIs = 0; 2073 2106 pThis->u32PortsInterrupted = 0; 2074 ahciHbaClearInterrupt(p This);2107 ahciHbaClearInterrupt(pDevIns); 2075 2108 2076 2109 pThis->f64BitAddr = false; … … 2080 2113 pThis->regHbaCtrl &= ~AHCI_HBA_CTRL_HR; 2081 2114 } 2082 #endif 2115 2116 #endif /* IN_RING3 */ 2083 2117 2084 2118 /** 2085 2119 * Reads from a AHCI controller register. 2086 2120 * 2087 * @returns VBox status code. 2088 * 2089 * @param pThis The AHCI instance. 2121 * @returns Strict VBox status code. 2122 * 2123 * @param pDevIns The device instance. 2124 * @param pThis The shared AHCI state. 2090 2125 * @param uReg The register to write. 2091 2126 * @param pv Where to store the result. 2092 2127 * @param cb Number of bytes read. 2093 2128 */ 2094 static int ahciRegisterRead(PAHCI pThis, uint32_t uReg, void *pv, unsigned cb)2095 { 2096 int rc = VINF_SUCCESS;2129 static VBOXSTRICTRC ahciRegisterRead(PPDMDEVINS pDevIns, PAHCI pThis, uint32_t uReg, void *pv, unsigned cb) 2130 { 2131 VBOXSTRICTRC rc; 2097 2132 uint32_t iReg; 2098 2133 … … 2108 2143 { 2109 2144 const AHCIOPREG *pReg = &g_aOpRegs[iReg]; 2110 rc = pReg->pfnRead(p This, iReg, (uint32_t *)pv);2145 rc = pReg->pfnRead(pDevIns, pThis, iReg, (uint32_t *)pv); 2111 2146 } 2112 2147 else … … 2114 2149 Log3(("%s: Trying to read global register %u/%u!!!\n", __FUNCTION__, iReg, RT_ELEMENTS(g_aOpRegs))); 2115 2150 *(uint32_t *)pv = 0; 2151 rc = VINF_SUCCESS; 2116 2152 } 2117 2153 } … … 2129 2165 Log3(("%s: Trying to read from port %u and register %u\n", __FUNCTION__, iPort, iReg)); 2130 2166 2131 if (RT_LIKELY( iPort < pThis->cPortsImpl2167 if (RT_LIKELY( iPort < RT_MIN(pThis->cPortsImpl, RT_ELEMENTS(pThis->ahciPort)) 2132 2168 && iReg < RT_ELEMENTS(g_aPortOpRegs))) 2133 2169 { 2134 2170 const AHCIPORTOPREG *pPortReg = &g_aPortOpRegs[iReg]; 2135 rc = pPortReg->pfnRead(p This, &pThis->ahciPort[iPort], iReg, (uint32_t *)pv);2171 rc = pPortReg->pfnRead(pDevIns, pThis, &pThis->ahciPort[iPort], iReg, (uint32_t *)pv); 2136 2172 } 2137 2173 else … … 2163 2199 } 2164 2200 default: 2165 A ssertMsgFailed(("%s: unsupported access width cb=%d iPort=%x iRegOffset=%x iReg=%x!!!\n",2166 __FUNCTION__, cb, iPort, iRegOffset, iReg));2201 ASSERT_GUEST_MSG_FAILED(("%s: unsupported access width cb=%d iPort=%x iRegOffset=%x iReg=%x!!!\n", 2202 __FUNCTION__, cb, iPort, iRegOffset, iReg)); 2167 2203 } 2168 2204 } … … 2175 2211 * Writes a value to one of the AHCI controller registers. 2176 2212 * 2177 * @returns VBox status code. 2178 * 2179 * @param pThis The AHCI instance. 2213 * @returns Strict VBox status code. 2214 * 2215 * @param pDevIns The device instance. 2216 * @param pThis The shared AHCI state. 2180 2217 * @param offReg The offset of the register to write to. 2181 2218 * @param u32Value The value to write. 2182 2219 */ 2183 static int ahciRegisterWrite(PAHCI pThis, uint32_t offReg, uint32_t u32Value)2184 { 2185 intrc;2220 static VBOXSTRICTRC ahciRegisterWrite(PPDMDEVINS pDevIns, PAHCI pThis, uint32_t offReg, uint32_t u32Value) 2221 { 2222 VBOXSTRICTRC rc; 2186 2223 uint32_t iReg; 2187 2224 … … 2197 2234 { 2198 2235 const AHCIOPREG *pReg = &g_aOpRegs[iReg]; 2199 rc = pReg->pfnWrite(p This, iReg, u32Value);2236 rc = pReg->pfnWrite(pDevIns, pThis, iReg, u32Value); 2200 2237 } 2201 2238 else … … 2214 2251 iReg = (offReg % AHCI_PORT_REGISTER_SIZE) >> 2; 2215 2252 Log3(("%s: Trying to write to port %u and register %u\n", __FUNCTION__, iPort, iReg)); 2216 if (RT_LIKELY( iPort < pThis->cPortsImpl2253 if (RT_LIKELY( iPort < RT_MIN(pThis->cPortsImpl, RT_ELEMENTS(pThis->ahciPort)) 2217 2254 && iReg < RT_ELEMENTS(g_aPortOpRegs))) 2218 2255 { 2219 2256 const AHCIPORTOPREG *pPortReg = &g_aPortOpRegs[iReg]; 2220 rc = pPortReg->pfnWrite(p This, &pThis->ahciPort[iPort], iReg, u32Value);2257 rc = pPortReg->pfnWrite(pDevIns, pThis, &pThis->ahciPort[iPort], iReg, u32Value); 2221 2258 } 2222 2259 else … … 2240 2277 RT_NOREF(pvUser); 2241 2278 2242 VBOXSTRICTRC rc = ahciRegisterRead(p This, off, pv, cb);2279 VBOXSTRICTRC rc = ahciRegisterRead(pDevIns, pThis, off, pv, cb); 2243 2280 2244 2281 Log2(("#%d ahciMMIORead: return pvUser=%p:{%.*Rhxs} cb=%d off=%RGp rc=%Rrc\n", … … 2292 2329 /* Do the access. */ 2293 2330 Log2(("#%d ahciMMIOWrite: pvUser=%p:{%.*Rhxs} cb=%d GCPhysAddr=%RGp\n", pDevIns->iInstance, pv, cb, pv, cb, off)); 2294 return ahciRegisterWrite(p This, off, *(uint32_t const *)pv);2331 return ahciRegisterWrite(pDevIns, pThis, off, *(uint32_t const *)pv); 2295 2332 } 2296 2333 … … 2346 2383 /** @todo range check? */ 2347 2384 ASSERT_GUEST(iReg == 1); 2348 rc = ahciRegisterWrite(p This, pThis->regIdx, u32);2385 rc = ahciRegisterWrite(pDevIns, pThis, pThis->regIdx, u32); 2349 2386 if (rc == VINF_IOM_R3_MMIO_WRITE) 2350 2387 rc = VINF_IOM_R3_IOPORT_WRITE; … … 2382 2419 /** @todo range check? */ 2383 2420 ASSERT_GUEST(iReg == 1); 2384 rc = ahciRegisterRead(p This, pThis->regIdx, pu32, cb);2421 rc = ahciRegisterRead(pDevIns, pThis, pThis->regIdx, pu32, cb); 2385 2422 if (rc == VINF_IOM_R3_MMIO_READ) 2386 2423 rc = VINF_IOM_R3_IOPORT_READ; … … 2411 2448 static DECLCALLBACK(int) ahciR3Status_QueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed) 2412 2449 { 2413 PAHCI pThis = PDMILEDPORTS_2_PAHCI(pInterface);2450 PAHCICC pThisCC = RT_FROM_MEMBER(pInterface, AHCICC, ILeds); 2414 2451 if (iLUN < AHCI_MAX_NR_PORTS_IMPL) 2415 2452 { 2453 PAHCI pThis = PDMDEVINS_2_DATA(pThisCC->pDevIns, PAHCI); 2416 2454 *ppLed = &pThis->ahciPort[iLUN].Led; 2417 2455 Assert((*ppLed)->u32Magic == PDMLED_MAGIC); … … 2426 2464 static DECLCALLBACK(void *) ahciR3Status_QueryInterface(PPDMIBASE pInterface, const char *pszIID) 2427 2465 { 2428 PAHCI pThis = PDMIBASE_2_PAHCI(pInterface);2429 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis ->IBase);2430 PDMIBASE_RETURN_INTERFACE(pszIID, PDMILEDPORTS, &pThis ->ILeds);2466 PAHCICC pThisCC = RT_FROM_MEMBER(pInterface, AHCICC, IBase); 2467 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThisCC->IBase); 2468 PDMIBASE_RETURN_INTERFACE(pszIID, PDMILEDPORTS, &pThisCC->ILeds); 2431 2469 return NULL; 2432 2470 } … … 2437 2475 static DECLCALLBACK(void *) ahciR3PortQueryInterface(PPDMIBASE pInterface, const char *pszIID) 2438 2476 { 2439 PAHCIP ort pAhciPort = PDMIBASE_2_PAHCIPORT(pInterface);2440 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pAhciPort ->IBase);2441 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAPORT, &pAhciPort ->IPort);2442 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAEXPORT, &pAhciPort ->IMediaExPort);2477 PAHCIPORTR3 pAhciPortR3 = RT_FROM_MEMBER(pInterface, AHCIPORTR3, IBase); 2478 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pAhciPortR3->IBase); 2479 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAPORT, &pAhciPortR3->IPort); 2480 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAEXPORT, &pAhciPortR3->IMediaExPort); 2443 2481 return NULL; 2444 2482 } … … 2450 2488 uint32_t *piInstance, uint32_t *piLUN) 2451 2489 { 2452 PAHCIP ort pAhciPort = PDMIMEDIAPORT_2_PAHCIPORT(pInterface);2453 PPDMDEVINS pDevIns = pAhciPort->CTX_SUFF(pDevIns);2490 PAHCIPORTR3 pAhciPortR3 = RT_FROM_MEMBER(pInterface, AHCIPORTR3, IPort); 2491 PPDMDEVINS pDevIns = pAhciPortR3->pDevIns; 2454 2492 2455 2493 AssertPtrReturn(ppcszController, VERR_INVALID_POINTER); … … 2459 2497 *ppcszController = pDevIns->pReg->szName; 2460 2498 *piInstance = pDevIns->iInstance; 2461 *piLUN = pAhciPort ->iLUN;2499 *piLUN = pAhciPortR3->iLUN; 2462 2500 2463 2501 return VINF_SUCCESS; … … 2470 2508 const char **ppszProductId, const char **ppszRevision) 2471 2509 { 2472 PAHCIPort pAhciPort = PDMIMEDIAPORT_2_PAHCIPORT(pInterface); 2510 PAHCIPORTR3 pAhciPortR3 = RT_FROM_MEMBER(pInterface, AHCIPORTR3, IPort); 2511 PAHCI pThis = PDMDEVINS_2_DATA(pAhciPortR3->pDevIns, PAHCI); 2512 PAHCIPORT pAhciPort = &RT_SAFE_SUBSCRIPT(pThis->ahciPort, pAhciPortR3->iLUN); 2473 2513 2474 2514 if (ppszVendorId) … … 2490 2530 * @param cmdFis The FIS to print info from. 2491 2531 */ 2492 static void ahciDumpFisInfo(PAHCIP ortpAhciPort, uint8_t *cmdFis)2532 static void ahciDumpFisInfo(PAHCIPORT pAhciPort, uint8_t *cmdFis) 2493 2533 { 2494 2534 ahciLog(("%s: *** Begin FIS info dump. ***\n", __FUNCTION__)); … … 2572 2612 * @param pCmdHdr The command header to print info from. 2573 2613 */ 2574 static void ahciDumpCmdHdrInfo(PAHCIP ortpAhciPort, CmdHdr *pCmdHdr)2614 static void ahciDumpCmdHdrInfo(PAHCIPORT pAhciPort, CmdHdr *pCmdHdr) 2575 2615 { 2576 2616 ahciLog(("%s: *** Begin command header info dump. ***\n", __FUNCTION__)); … … 2603 2643 * 2604 2644 * @returns nothing 2605 * @param pAhciPort Pointer to the port which "receives" the FIS. 2606 */ 2607 static void ahciPostFirstD2HFisIntoMemory(PAHCIPort pAhciPort) 2645 * @param pDevIns The device instance. 2646 * @param pAhciPort Pointer to the port which "receives" the FIS. 2647 */ 2648 static void ahciPostFirstD2HFisIntoMemory(PPDMDEVINS pDevIns, PAHCIPORT pAhciPort) 2608 2649 { 2609 2650 uint8_t d2hFis[AHCI_CMDFIS_TYPE_D2H_SIZE]; … … 2638 2679 pAhciPort->regTFD |= ATA_STAT_READY; 2639 2680 2640 ahciPostFisIntoMemory(p AhciPort, AHCI_CMDFIS_TYPE_D2H, d2hFis);2681 ahciPostFisIntoMemory(pDevIns, pAhciPort, AHCI_CMDFIS_TYPE_D2H, d2hFis); 2641 2682 } 2642 2683 … … 2645 2686 * 2646 2687 * @returns VBox status code 2688 * @param pDevIns The device instance. 2647 2689 * @param pAhciPort The port which "receives" the FIS. 2648 2690 * @param uFisType The type of the FIS. 2649 2691 * @param pCmdFis Pointer to the FIS which is to be posted into memory. 2650 2692 */ 2651 static int ahciPostFisIntoMemory(P AHCIPortpAhciPort, unsigned uFisType, uint8_t *pCmdFis)2693 static int ahciPostFisIntoMemory(PPDMDEVINS pDevIns, PAHCIPORT pAhciPort, unsigned uFisType, uint8_t *pCmdFis) 2652 2694 { 2653 2695 int rc = VINF_SUCCESS; … … 2698 2740 /* Post the FIS into memory. */ 2699 2741 ahciLog(("%s: PDMDevHlpPCIPhysWrite GCPhysAddrRecFis=%RGp cbFis=%u\n", __FUNCTION__, GCPhysAddrRecFis, cbFis)); 2700 PDMDevHlpPCIPhysWrite(p AhciPort->CTX_SUFF(pDevIns), GCPhysAddrRecFis, pCmdFis, cbFis);2742 PDMDevHlpPCIPhysWrite(pDevIns, GCPhysAddrRecFis, pCmdFis, cbFis); 2701 2743 } 2702 2744 … … 2734 2776 } 2735 2777 2736 static int ahciIdentifySS(PAHCI Port pAhciPort, void *pvBuf)2778 static int ahciIdentifySS(PAHCI pThis, PAHCIPORT pAhciPort, PAHCIPORTR3 pAhciPortR3, void *pvBuf) 2737 2779 { 2738 2780 uint16_t *p = (uint16_t *)pvBuf; … … 2785 2827 if ( pAhciPort->fTrimEnabled 2786 2828 || pAhciPort->cbSector != 512 2787 || pAhciPort ->pDrvMedia->pfnIsNonRotational(pAhciPort->pDrvMedia))2829 || pAhciPortR3->pDrvMedia->pfnIsNonRotational(pAhciPortR3->pDrvMedia)) 2788 2830 { 2789 2831 p[80] = RT_H2LE_U16(0x1f0); /* support everything up to ATA/ATAPI-8 ACS */ … … 2821 2863 } 2822 2864 2823 if (pAhciPort ->pDrvMedia->pfnIsNonRotational(pAhciPort->pDrvMedia))2865 if (pAhciPortR3->pDrvMedia->pfnIsNonRotational(pAhciPortR3->pDrvMedia)) 2824 2866 p[217] = RT_H2LE_U16(1); /* Non-rotational medium */ 2825 2867 … … 2828 2870 2829 2871 /* The following are SATA specific */ 2830 p[75] = RT_H2LE_U16(p AhciPort->CTX_SUFF(pAhci)->cCmdSlotsAvail-1); /* Number of commands we support, 0's based */2872 p[75] = RT_H2LE_U16(pThis->cCmdSlotsAvail - 1); /* Number of commands we support, 0's based */ 2831 2873 p[76] = RT_H2LE_U16((1 << 8) | (1 << 2)); /* Native command queuing and Serial ATA Gen2 (3.0 Gbps) speed supported */ 2832 2874 … … 2837 2879 } 2838 2880 2839 static int ahciR3AtapiIdentify(P AHCIREQ pAhciReq, PAHCIPortpAhciPort, size_t cbData, size_t *pcbData)2881 static int ahciR3AtapiIdentify(PPDMDEVINS pDevIns, PAHCIREQ pAhciReq, PAHCIPORT pAhciPort, size_t cbData, size_t *pcbData) 2840 2882 { 2841 2883 uint16_t p[256]; … … 2878 2920 2879 2921 /* Copy the buffer in to the scatter gather list. */ 2880 *pcbData = ahciR3CopyBufferToPrdtl(pAhciPort->CTX_SUFF(pAhci), pAhciReq, (void *)&p[0], 2881 RT_MIN(cbData, sizeof(p)), 0 /* cbSkip */); 2922 *pcbData = ahciR3CopyBufferToPrdtl(pDevIns, pAhciReq, (void *)&p[0], RT_MIN(cbData, sizeof(p)), 0 /* cbSkip */); 2882 2923 return VINF_SUCCESS; 2883 2924 } … … 2887 2928 * 2888 2929 * @returns nothing 2889 * @param pAhciPort The port the device is attached to. 2890 * @param pAhciReq The state to get the tag number from. 2891 */ 2892 static void ahciFinishStorageDeviceReset(PAHCIPort pAhciPort, PAHCIREQ pAhciReq) 2930 * @param pDevIns The device instance. 2931 * @param pThis The shared AHCI state. 2932 * @param pAhciPort The port the device is attached to, shared bits. 2933 * @param pAhciReq The state to get the tag number from. 2934 */ 2935 static void ahciFinishStorageDeviceReset(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, PAHCIREQ pAhciReq) 2893 2936 { 2894 2937 int rc; … … 2897 2940 pAhciPort->fResetDevice = false; 2898 2941 if (pAhciPort->regCMD & AHCI_PORT_CMD_FRE) 2899 ahciPostFirstD2HFisIntoMemory(p AhciPort);2942 ahciPostFirstD2HFisIntoMemory(pDevIns, pAhciPort); 2900 2943 2901 2944 /* As this is the first D2H FIS after the reset update the signature in the SIG register of the port. */ … … 2906 2949 ASMAtomicOrU32(&pAhciPort->u32TasksFinished, (1 << pAhciReq->uTag)); 2907 2950 2908 rc = ahciHbaSetInterrupt(p AhciPort->CTX_SUFF(pAhci), pAhciPort->iLUN, VERR_IGNORED);2951 rc = ahciHbaSetInterrupt(pDevIns, pThis, pAhciPort->iLUN, VERR_IGNORED); 2909 2952 AssertRC(rc); 2910 2953 } … … 2914 2957 * 2915 2958 * @returns nothing. 2916 * @param pAhciPort The device to reset. 2917 * @param pAhciReq The task state. 2918 */ 2919 static void ahciDeviceReset(PAHCIPort pAhciPort, PAHCIREQ pAhciReq) 2959 * @param pDevIns The device instance. 2960 * @param pThis The shared AHCI state. 2961 * @param pAhciPort The device to reset. 2962 * @param pAhciReq The task state. 2963 */ 2964 static void ahciDeviceReset(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, PAHCIREQ pAhciReq) 2920 2965 { 2921 2966 ASMAtomicWriteBool(&pAhciPort->fResetDevice, true); … … 2927 2972 */ 2928 2973 Assert(ASMAtomicReadU32(&pAhciPort->cTasksActive) == 0); 2929 ahciFinishStorageDeviceReset(p AhciPort, pAhciReq);2974 ahciFinishStorageDeviceReset(pDevIns, pThis, pAhciPort, pAhciReq); 2930 2975 } 2931 2976 … … 2934 2979 * 2935 2980 * @returns nothing. 2936 * @param pAhciPort The port of the SATA controller. 2937 * @param cbTransfer Transfer size of the request. 2938 * @param pCmdFis Pointer to the command FIS from the guest. 2939 * @param fRead Flag whether this is a read request. 2940 * @param fInterrupt If an interrupt should be send to the guest. 2941 */ 2942 static void ahciSendPioSetupFis(PAHCIPort pAhciPort, size_t cbTransfer, uint8_t *pCmdFis, 2943 bool fRead, bool fInterrupt) 2981 * @param pDevIns The device instance. 2982 * @param pThis The shared AHCI state. 2983 * @param pAhciPort The port of the SATA controller. 2984 * @param cbTransfer Transfer size of the request. 2985 * @param pCmdFis Pointer to the command FIS from the guest. 2986 * @param fRead Flag whether this is a read request. 2987 * @param fInterrupt If an interrupt should be send to the guest. 2988 */ 2989 static void ahciSendPioSetupFis(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, 2990 size_t cbTransfer, uint8_t *pCmdFis, bool fRead, bool fInterrupt) 2944 2991 { 2945 2992 uint8_t abPioSetupFis[20]; 2946 2993 bool fAssertIntr = false; 2947 PAHCI pThis = pAhciPort->CTX_SUFF(pAhci);2948 2994 2949 2995 ahciLog(("%s: building PIO setup Fis\n", __FUNCTION__)); … … 2979 3025 pAhciPort->regTFD = (pCmdFis[AHCI_CMDFIS_ERR] << 8) | pCmdFis[AHCI_CMDFIS_STS]; 2980 3026 2981 ahciPostFisIntoMemory(p AhciPort, AHCI_CMDFIS_TYPE_PIOSETUP, abPioSetupFis);3027 ahciPostFisIntoMemory(pDevIns, pAhciPort, AHCI_CMDFIS_TYPE_PIOSETUP, abPioSetupFis); 2982 3028 2983 3029 if (fInterrupt) … … 2991 3037 if (fAssertIntr) 2992 3038 { 2993 int rc = ahciHbaSetInterrupt(p This, pAhciPort->iLUN, VERR_IGNORED);3039 int rc = ahciHbaSetInterrupt(pDevIns, pThis, pAhciPort->iLUN, VERR_IGNORED); 2994 3040 AssertRC(rc); 2995 3041 } … … 3001 3047 * 3002 3048 * @returns Nothing 3003 * @param pAhciPort The port of the SATA controller. 3004 * @param uTag The tag of the request. 3005 * @param pCmdFis Pointer to the command FIS from the guest. 3006 * @param fInterrupt If an interrupt should be send to the guest. 3007 */ 3008 static void ahciSendD2HFis(PAHCIPort pAhciPort, uint32_t uTag, uint8_t *pCmdFis, bool fInterrupt) 3049 * @param pDevIns The device instance. 3050 * @param pThis The shared AHCI state. 3051 * @param pAhciPort The port of the SATA controller. 3052 * @param uTag The tag of the request. 3053 * @param pCmdFis Pointer to the command FIS from the guest. 3054 * @param fInterrupt If an interrupt should be send to the guest. 3055 */ 3056 static void ahciSendD2HFis(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t uTag, uint8_t *pCmdFis, bool fInterrupt) 3009 3057 { 3010 3058 uint8_t d2hFis[20]; 3011 3059 bool fAssertIntr = false; 3012 PAHCI pThis = pAhciPort->CTX_SUFF(pAhci);3013 3060 3014 3061 ahciLog(("%s: building D2H Fis\n", __FUNCTION__)); … … 3034 3081 pAhciPort->regTFD = (pCmdFis[AHCI_CMDFIS_ERR] << 8) | pCmdFis[AHCI_CMDFIS_STS]; 3035 3082 3036 ahciPostFisIntoMemory(p AhciPort, AHCI_CMDFIS_TYPE_D2H, d2hFis);3083 ahciPostFisIntoMemory(pDevIns, pAhciPort, AHCI_CMDFIS_TYPE_D2H, d2hFis); 3037 3084 3038 3085 if (pCmdFis[AHCI_CMDFIS_STS] & ATA_STAT_ERR) … … 3060 3107 if (fAssertIntr) 3061 3108 { 3062 int rc = ahciHbaSetInterrupt(p This, pAhciPort->iLUN, VERR_IGNORED);3109 int rc = ahciHbaSetInterrupt(pDevIns, pThis, pAhciPort->iLUN, VERR_IGNORED); 3063 3110 AssertRC(rc); 3064 3111 } … … 3070 3117 * 3071 3118 * @returns Nothing 3072 * @param pAhciPort The port for which the SDB Fis is send. 3073 * @param uFinishedTasks Bitmask of finished tasks. 3074 * @param fInterrupt If an interrupt should be asserted. 3075 */ 3076 static void ahciSendSDBFis(PAHCIPort pAhciPort, uint32_t uFinishedTasks, bool fInterrupt) 3119 * @param pDevIns The device instance. 3120 * @param pThis The shared AHCI state. 3121 * @param pAhciPort The port for which the SDB Fis is send, shared bits. 3122 * @param pAhciPortR3 The port for which the SDB Fis is send, ring-3 bits. 3123 * @param uFinishedTasks Bitmask of finished tasks. 3124 * @param fInterrupt If an interrupt should be asserted. 3125 */ 3126 static void ahciSendSDBFis(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, PAHCIPORTR3 pAhciPortR3, 3127 uint32_t uFinishedTasks, bool fInterrupt) 3077 3128 { 3078 3129 uint32_t sdbFis[2]; 3079 3130 bool fAssertIntr = false; 3080 PAHCI pThis = pAhciPort->CTX_SUFF(pAhci); 3081 PAHCIREQ pTaskErr = ASMAtomicReadPtrT(&pAhciPort->pTaskErr, PAHCIREQ); 3131 PAHCIREQ pTaskErr = ASMAtomicReadPtrT(&pAhciPortR3->pTaskErr, PAHCIREQ); 3082 3132 3083 3133 ahciLog(("%s: Building SDB FIS\n", __FUNCTION__)); … … 3105 3155 sdbFis[1] = pAhciPort->u32QueuedTasksFinished | uFinishedTasks; 3106 3156 3107 ahciPostFisIntoMemory(p AhciPort, AHCI_CMDFIS_TYPE_SETDEVBITS, (uint8_t *)sdbFis);3157 ahciPostFisIntoMemory(pDevIns, pAhciPort, AHCI_CMDFIS_TYPE_SETDEVBITS, (uint8_t *)sdbFis); 3108 3158 3109 3159 if (RT_UNLIKELY(pTaskErr)) … … 3127 3177 if (fAssertIntr) 3128 3178 { 3129 int rc = ahciHbaSetInterrupt(p This, pAhciPort->iLUN, VERR_IGNORED);3179 int rc = ahciHbaSetInterrupt(pDevIns, pThis, pAhciPort->iLUN, VERR_IGNORED); 3130 3180 AssertRC(rc); 3131 3181 } … … 3152 3202 } 3153 3203 3154 static uint64_t ahciGetSector(PAHCIP ortpAhciPort, uint8_t *pCmdFis, bool fLBA48)3204 static uint64_t ahciGetSector(PAHCIPORT pAhciPort, uint8_t *pCmdFis, bool fLBA48) 3155 3205 { 3156 3206 uint64_t iLBA; … … 3212 3262 * @copydoc AHCIR3MEMCOPYCALLBACK 3213 3263 */ 3214 static DECLCALLBACK(void) ahciR3CopyBufferFromGuestWorker(P AHCI pThis, RTGCPHYS GCPhys, PRTSGBUF pSgBuf,3264 static DECLCALLBACK(void) ahciR3CopyBufferFromGuestWorker(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, PRTSGBUF pSgBuf, 3215 3265 size_t cbCopy, size_t *pcbSkip) 3216 3266 { … … 3226 3276 3227 3277 AssertPtr(pvSeg); 3228 PDMDevHlpPhysRead(p This->CTX_SUFF(pDevIns), GCPhys, pvSeg, cbSeg);3278 PDMDevHlpPhysRead(pDevIns, GCPhys, pvSeg, cbSeg); 3229 3279 GCPhys += cbSeg; 3230 3280 cbCopy -= cbSeg; … … 3237 3287 * @copydoc AHCIR3MEMCOPYCALLBACK 3238 3288 */ 3239 static DECLCALLBACK(void) ahciR3CopyBufferToGuestWorker(P AHCI pThis, RTGCPHYS GCPhys, PRTSGBUF pSgBuf,3289 static DECLCALLBACK(void) ahciR3CopyBufferToGuestWorker(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, PRTSGBUF pSgBuf, 3240 3290 size_t cbCopy, size_t *pcbSkip) 3241 3291 { … … 3251 3301 3252 3302 AssertPtr(pvSeg); 3253 PDMDevHlpPCIPhysWrite(p This->CTX_SUFF(pDevIns), GCPhys, pvSeg, cbSeg);3303 PDMDevHlpPCIPhysWrite(pDevIns, GCPhys, pvSeg, cbSeg); 3254 3304 GCPhys += cbSeg; 3255 3305 cbCopy -= cbSeg; … … 3261 3311 * 3262 3312 * @returns Amount of bytes copied. 3263 * @param p This The AHCI controllerdevice instance.3264 * @param pAhciReq AHCI request structure.3265 * @param pfnCopyWorker The copy method to apply for each guest buffer.3266 * @param pSgBuf The host S/G buffer.3267 * @param cbSkip How many bytes to skip in advance before starting to copy.3268 * @param cbCopy How many bytes to copy.3269 */ 3270 static size_t ahciR3PrdtlWalk(P AHCI pThis, PAHCIREQ pAhciReq,3313 * @param pDevIns The device instance. 3314 * @param pAhciReq AHCI request structure. 3315 * @param pfnCopyWorker The copy method to apply for each guest buffer. 3316 * @param pSgBuf The host S/G buffer. 3317 * @param cbSkip How many bytes to skip in advance before starting to copy. 3318 * @param cbCopy How many bytes to copy. 3319 */ 3320 static size_t ahciR3PrdtlWalk(PPDMDEVINS pDevIns, PAHCIREQ pAhciReq, 3271 3321 PAHCIR3MEMCOPYCALLBACK pfnCopyWorker, 3272 3322 PRTSGBUF pSgBuf, size_t cbSkip, size_t cbCopy) … … 3291 3341 : RT_ELEMENTS(aPrdtlEntries); 3292 3342 3293 PDMDevHlpPhysRead(p This->CTX_SUFF(pDevIns), GCPhysPrdtl, &aPrdtlEntries[0],3343 PDMDevHlpPhysRead(pDevIns, GCPhysPrdtl, &aPrdtlEntries[0], 3294 3344 cPrdtlEntriesRead * sizeof(SGLEntry)); 3295 3345 … … 3302 3352 3303 3353 /* Copy into SG entry. */ 3304 pfnCopyWorker(p This, GCPhysAddrDataBase, pSgBuf, cbThisCopy, &cbSkip);3354 pfnCopyWorker(pDevIns, GCPhysAddrDataBase, pSgBuf, cbThisCopy, &cbSkip); 3305 3355 3306 3356 cbCopy -= cbThisCopy; … … 3322 3372 * 3323 3373 * @returns Amount of bytes copied to the PRDTL. 3324 * @param pThis The AHCI controller device instance. 3325 * @param pAhciReq AHCI request structure. 3326 * @param pSgBuf The S/G buffer to copy from. 3327 * @param cbSkip How many bytes to skip in advance before starting to copy. 3328 * @param cbCopy How many bytes to copy. 3329 */ 3330 static size_t ahciR3CopySgBufToPrdtl(PAHCI pThis, PAHCIREQ pAhciReq, PRTSGBUF pSgBuf, 3331 size_t cbSkip, size_t cbCopy) 3332 { 3333 return ahciR3PrdtlWalk(pThis, pAhciReq, ahciR3CopyBufferToGuestWorker, 3334 pSgBuf, cbSkip, cbCopy); 3374 * @param pDevIns The device instance. 3375 * @param pAhciReq AHCI request structure. 3376 * @param pSgBuf The S/G buffer to copy from. 3377 * @param cbSkip How many bytes to skip in advance before starting to copy. 3378 * @param cbCopy How many bytes to copy. 3379 */ 3380 static size_t ahciR3CopySgBufToPrdtl(PPDMDEVINS pDevIns, PAHCIREQ pAhciReq, PRTSGBUF pSgBuf, size_t cbSkip, size_t cbCopy) 3381 { 3382 return ahciR3PrdtlWalk(pDevIns, pAhciReq, ahciR3CopyBufferToGuestWorker, pSgBuf, cbSkip, cbCopy); 3335 3383 } 3336 3384 … … 3339 3387 * 3340 3388 * @returns Amount of bytes copied from the PRDTL. 3341 * @param pThis The AHCI controller device instance. 3342 * @param pAhciReq AHCI request structure. 3343 * @param pSgBuf The S/G buffer to copy into. 3344 * @param cbSkip How many bytes to skip in advance before starting to copy. 3345 * @param cbCopy How many bytes to copy. 3346 */ 3347 static size_t ahciR3CopySgBufFromPrdtl(PAHCI pThis, PAHCIREQ pAhciReq, PRTSGBUF pSgBuf, 3348 size_t cbSkip, size_t cbCopy) 3349 { 3350 return ahciR3PrdtlWalk(pThis, pAhciReq, ahciR3CopyBufferFromGuestWorker, 3351 pSgBuf, cbSkip, cbCopy); 3389 * @param pDevIns The device instance. 3390 * @param pAhciReq AHCI request structure. 3391 * @param pSgBuf The S/G buffer to copy into. 3392 * @param cbSkip How many bytes to skip in advance before starting to copy. 3393 * @param cbCopy How many bytes to copy. 3394 */ 3395 static size_t ahciR3CopySgBufFromPrdtl(PPDMDEVINS pDevIns, PAHCIREQ pAhciReq, PRTSGBUF pSgBuf, size_t cbSkip, size_t cbCopy) 3396 { 3397 return ahciR3PrdtlWalk(pDevIns, pAhciReq, ahciR3CopyBufferFromGuestWorker, pSgBuf, cbSkip, cbCopy); 3352 3398 } 3353 3399 … … 3356 3402 * 3357 3403 * @returns Amount of bytes copied from the PRDTL. 3358 * @param pThis The AHCI controller device instance. 3359 * @param pAhciReq AHCI request structure. 3360 * @param pvSrc The buffer to copy from. 3361 * @param cbSrc How many bytes to copy. 3362 * @param cbSkip How many bytes to skip initially. 3363 */ 3364 static size_t ahciR3CopyBufferToPrdtl(PAHCI pThis, PAHCIREQ pAhciReq, const void *pvSrc, 3365 size_t cbSrc, size_t cbSkip) 3404 * @param pDevIns The device instance. 3405 * @param pAhciReq AHCI request structure. 3406 * @param pvSrc The buffer to copy from. 3407 * @param cbSrc How many bytes to copy. 3408 * @param cbSkip How many bytes to skip initially. 3409 */ 3410 static size_t ahciR3CopyBufferToPrdtl(PPDMDEVINS pDevIns, PAHCIREQ pAhciReq, const void *pvSrc, size_t cbSrc, size_t cbSkip) 3366 3411 { 3367 3412 RTSGSEG Seg; … … 3370 3415 Seg.cbSeg = cbSrc; 3371 3416 RTSgBufInit(&SgBuf, &Seg, 1); 3372 return ahciR3CopySgBufToPrdtl(p This, pAhciReq, &SgBuf, cbSkip, cbSrc);3417 return ahciR3CopySgBufToPrdtl(pDevIns, pAhciReq, &SgBuf, cbSkip, cbSrc); 3373 3418 } 3374 3419 … … 3377 3422 * 3378 3423 * @returns VBox status code. 3379 * @param pThis The AHCI controller device instance. 3380 * @param pAhciReq AHCI request structure. 3381 * @param pcbPrdt Where to store the size of the guest buffer. 3382 */ 3383 static int ahciR3PrdtQuerySize(PAHCI pThis, PAHCIREQ pAhciReq, size_t *pcbPrdt) 3424 * @param pDevIns The device instance. 3425 * @param pThis The AHCI controller device instance. 3426 * @param pAhciReq AHCI request structure. 3427 * @param pcbPrdt Where to store the size of the guest buffer. 3428 */ 3429 static int ahciR3PrdtQuerySize(PPDMDEVINS pDevIns, PAHCIREQ pAhciReq, size_t *pcbPrdt) 3384 3430 { 3385 3431 RTGCPHYS GCPhysPrdtl = pAhciReq->GCPhysPrdtl; … … 3390 3436 { 3391 3437 SGLEntry aPrdtlEntries[32]; 3392 uint32_t cPrdtlEntriesRead = cPrdtlEntries < RT_ELEMENTS(aPrdtlEntries) 3393 ? cPrdtlEntries 3394 : RT_ELEMENTS(aPrdtlEntries); 3395 3396 PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), GCPhysPrdtl, &aPrdtlEntries[0], 3397 cPrdtlEntriesRead * sizeof(SGLEntry)); 3438 uint32_t const cPrdtlEntriesRead = RT_MIN(cPrdtlEntries, RT_ELEMENTS(aPrdtlEntries)); 3439 3440 PDMDevHlpPhysRead(pDevIns, GCPhysPrdtl, &aPrdtlEntries[0], cPrdtlEntriesRead * sizeof(SGLEntry)); 3398 3441 3399 3442 for (uint32_t i = 0; i < cPrdtlEntriesRead; i++) … … 3412 3455 * 3413 3456 * @returns Whether all active tasks were canceled. 3414 * @param pAhciPort The AHCI port.3415 */ 3416 static bool ahci CancelActiveTasks(PAHCIPort pAhciPort)3417 { 3418 if (pAhciPort ->pDrvMediaEx)3419 { 3420 int rc = pAhciPort ->pDrvMediaEx->pfnIoReqCancelAll(pAhciPort->pDrvMediaEx);3457 * @param pAhciPortR3 The AHCI port, ring-3 bits. 3458 */ 3459 static bool ahciR3CancelActiveTasks(PAHCIPORTR3 pAhciPortR3) 3460 { 3461 if (pAhciPortR3->pDrvMediaEx) 3462 { 3463 int rc = pAhciPortR3->pDrvMediaEx->pfnIoReqCancelAll(pAhciPortR3->pDrvMediaEx); 3421 3464 AssertRC(rc); 3422 3465 } … … 3428 3471 * 3429 3472 * @returns VBox status code. 3430 * @param pAhciPort AHCI port state. 3431 * @param pAhciReq The request handling the TRIM request. 3432 * @param idxRangeStart Index of the first range to start copying. 3433 * @param paRanges Where to store the ranges. 3434 * @param cRanges Number of ranges fitting into the array. 3435 * @param pcRanges Where to store the amount of ranges actually copied on success. 3436 */ 3437 static int ahciTrimRangesCreate(PAHCIPort pAhciPort, PAHCIREQ pAhciReq, uint32_t idxRangeStart, 3473 * @param pDevIns The device instance. 3474 * @param pAhciPort AHCI port state. 3475 * @param pAhciReq The request handling the TRIM request. 3476 * @param idxRangeStart Index of the first range to start copying. 3477 * @param paRanges Where to store the ranges. 3478 * @param cRanges Number of ranges fitting into the array. 3479 * @param pcRanges Where to store the amount of ranges actually copied on success. 3480 */ 3481 static int ahciTrimRangesCreate(PPDMDEVINS pDevIns, PAHCIPORT pAhciPort, PAHCIREQ pAhciReq, uint32_t idxRangeStart, 3438 3482 PRTRANGE paRanges, uint32_t cRanges, uint32_t *pcRanges) 3439 3483 { … … 3442 3486 uint32_t cPrdtlEntries = pAhciReq->cPrdtlEntries; 3443 3487 RTGCPHYS GCPhysPrdtl = pAhciReq->GCPhysPrdtl; 3444 PPDMDEVINS pDevIns = pAhciPort->CTX_SUFF(pDevIns);3445 3488 int rc = VERR_PDM_MEDIAEX_IOBUF_OVERFLOW; 3446 3489 uint32_t idxRange = 0; … … 3506 3549 * 3507 3550 * @returns A new AHCI request structure or NULL if out of memory. 3508 * @param pAhciPort The AHCI port.3509 * @param uTag 3510 */ 3511 static PAHCIREQ ahciR3ReqAlloc(PAHCIP ort pAhciPort, uint32_t uTag)3551 * @param pAhciPortR3 The AHCI port, ring-3 bits. 3552 * @param uTag The tag to assign. 3553 */ 3554 static PAHCIREQ ahciR3ReqAlloc(PAHCIPORTR3 pAhciPortR3, uint32_t uTag) 3512 3555 { 3513 3556 PAHCIREQ pAhciReq = NULL; 3514 3557 PDMMEDIAEXIOREQ hIoReq = NULL; 3515 3558 3516 int rc = pAhciPort ->pDrvMediaEx->pfnIoReqAlloc(pAhciPort->pDrvMediaEx, &hIoReq, (void **)&pAhciReq,3517 uTag, PDMIMEDIAEX_F_SUSPEND_ON_RECOVERABLE_ERR);3559 int rc = pAhciPortR3->pDrvMediaEx->pfnIoReqAlloc(pAhciPortR3->pDrvMediaEx, &hIoReq, (void **)&pAhciReq, 3560 uTag, PDMIMEDIAEX_F_SUSPEND_ON_RECOVERABLE_ERR); 3518 3561 if (RT_SUCCESS(rc)) 3519 3562 { … … 3530 3573 * 3531 3574 * @returns nothing. 3532 * @param pAhciPort The AHCI port. 3533 * @param pAhciReq The request to free. 3534 */ 3535 static void ahciR3ReqFree(PAHCIPort pAhciPort, PAHCIREQ pAhciReq) 3575 * @param pAhciPort The AHCI port, shared bits. 3576 * @param pAhciPortR3 The AHCI port, ring-3 bits. 3577 * @param pAhciReq The request to free. 3578 */ 3579 static void ahciR3ReqFree(PAHCIPORTR3 pAhciPortR3, PAHCIREQ pAhciReq) 3536 3580 { 3537 3581 if ( pAhciReq 3538 3582 && !(pAhciReq->fFlags & AHCI_REQ_IS_ON_STACK)) 3539 3583 { 3540 int rc = pAhciPort ->pDrvMediaEx->pfnIoReqFree(pAhciPort->pDrvMediaEx, pAhciReq->hIoReq);3584 int rc = pAhciPortR3->pDrvMediaEx->pfnIoReqFree(pAhciPortR3->pDrvMediaEx, pAhciReq->hIoReq); 3541 3585 AssertRC(rc); 3542 3586 } … … 3549 3593 * @returns Flag whether the given request was canceled inbetween; 3550 3594 * 3551 * @param pAhciPort Pointer to the port where to request completed. 3552 * @param pAhciReq Pointer to the task which finished. 3553 * @param rcReq IPRT status code of the completed request. 3554 */ 3555 static bool ahciTransferComplete(PAHCIPort pAhciPort, PAHCIREQ pAhciReq, int rcReq) 3595 * @param pDevIns The device instance. 3596 * @param pThis The shared AHCI state. 3597 * @param pThisCC The ring-3 AHCI state. 3598 * @param pAhciPort Pointer to the port where to request completed, shared bits. 3599 * @param pAhciPortR3 Pointer to the port where to request completed, ring-3 bits. 3600 * @param pAhciReq Pointer to the task which finished. 3601 * @param rcReq IPRT status code of the completed request. 3602 */ 3603 static bool ahciR3TransferComplete(PPDMDEVINS pDevIns, PAHCI pThis, PAHCICC pThisCC, 3604 PAHCIPORT pAhciPort, PAHCIPORTR3 pAhciPortR3, PAHCIREQ pAhciReq, int rcReq) 3556 3605 { 3557 3606 bool fCanceled = false; … … 3563 3612 3564 3613 if (pAhciReq->fMapped) 3565 PDMDevHlpPhysReleasePageMappingLock(pAhciPort->CTX_SUFF(pAhci)->CTX_SUFF(pDevIns), 3566 &pAhciReq->PgLck); 3614 PDMDevHlpPhysReleasePageMappingLock(pDevIns, &pAhciReq->PgLck); 3567 3615 3568 3616 if (rcReq != VERR_PDM_MEDIAEX_IOREQ_CANCELED) … … 3587 3635 if (pAhciReq->enmType == PDMMEDIAEXIOREQTYPE_FLUSH) 3588 3636 LogRel(("AHCI#%uP%u: Flush returned rc=%Rrc\n", 3589 p AhciPort->CTX_SUFF(pDevIns)->iInstance, pAhciPort->iLUN, rcReq));3637 pDevIns->iInstance, pAhciPort->iLUN, rcReq)); 3590 3638 else if (pAhciReq->enmType == PDMMEDIAEXIOREQTYPE_DISCARD) 3591 3639 LogRel(("AHCI#%uP%u: Trim returned rc=%Rrc\n", 3592 p AhciPort->CTX_SUFF(pDevIns)->iInstance, pAhciPort->iLUN, rcReq));3640 pDevIns->iInstance, pAhciPort->iLUN, rcReq)); 3593 3641 else 3594 3642 LogRel(("AHCI#%uP%u: %s at offset %llu (%zu bytes left) returned rc=%Rrc\n", 3595 p AhciPort->CTX_SUFF(pDevIns)->iInstance, pAhciPort->iLUN,3643 pDevIns->iInstance, pAhciPort->iLUN, 3596 3644 pAhciReq->enmType == PDMMEDIAEXIOREQTYPE_READ 3597 3645 ? "Read" … … 3608 3656 PAHCIREQ pReqDup = (PAHCIREQ)RTMemDup(pAhciReq, sizeof(AHCIREQ)); 3609 3657 if ( pReqDup 3610 && !ASMAtomicCmpXchgPtr(&pAhciPort ->pTaskErr, pReqDup, NULL))3658 && !ASMAtomicCmpXchgPtr(&pAhciPortR3->pTaskErr, pReqDup, NULL)) 3611 3659 RTMemFree(pReqDup); 3612 3660 } … … 3640 3688 { 3641 3689 size_t cbXfer = 0; 3642 int rc = pAhciPort ->pDrvMediaEx->pfnIoReqQueryXferSize(pAhciPort->pDrvMediaEx, pAhciReq->hIoReq, &cbXfer);3690 int rc = pAhciPortR3->pDrvMediaEx->pfnIoReqQueryXferSize(pAhciPortR3->pDrvMediaEx, pAhciReq->hIoReq, &cbXfer); 3643 3691 AssertRC(rc); 3644 3692 u32PRDBC = (uint32_t)RT_MIN(cbXfer, pAhciReq->cbTransfer); … … 3647 3695 u32PRDBC = (uint32_t)pAhciReq->cbTransfer; 3648 3696 3649 PDMDevHlpPCIPhysWrite(p AhciPort->CTX_SUFF(pDevIns), pAhciReq->GCPhysCmdHdrAddr + RT_UOFFSETOF(CmdHdr, u32PRDBC),3697 PDMDevHlpPCIPhysWrite(pDevIns, pAhciReq->GCPhysCmdHdrAddr + RT_UOFFSETOF(CmdHdr, u32PRDBC), 3650 3698 &u32PRDBC, sizeof(u32PRDBC)); 3651 3699 … … 3659 3707 ASMAtomicOrU32(&pAhciPort->regIS, AHCI_PORT_IS_OFS); 3660 3708 if (pAhciPort->regIE & AHCI_PORT_IE_OFE) 3661 ahciHbaSetInterrupt(p AhciPort->CTX_SUFF(pAhci), pAhciPort->iLUN, VERR_IGNORED);3709 ahciHbaSetInterrupt(pDevIns, pThis, pAhciPort->iLUN, VERR_IGNORED); 3662 3710 } 3663 3711 } … … 3675 3723 memcpy(&cmdFis[0], &pAhciReq->cmdFis[0], sizeof(cmdFis)); 3676 3724 3677 ahciR3ReqFree(pAhciPort , pAhciReq);3725 ahciR3ReqFree(pAhciPortR3, pAhciReq); 3678 3726 3679 3727 /* Post a PIO setup FIS first if this is a PIO command which transfers data. */ 3680 3728 if (fFlags & AHCI_REQ_PIO_DATA) 3681 ahciSendPioSetupFis(p AhciPort, cbTransfer, &cmdFis[0], fRead, false /* fInterrupt */);3729 ahciSendPioSetupFis(pDevIns, pThis, pAhciPort, cbTransfer, &cmdFis[0], fRead, false /* fInterrupt */); 3682 3730 3683 3731 if (fFlags & AHCI_REQ_CLEAR_SACT) 3684 3732 { 3685 if (RT_SUCCESS(rcReq) && !ASMAtomicReadPtrT(&pAhciPort ->pTaskErr, PAHCIREQ))3733 if (RT_SUCCESS(rcReq) && !ASMAtomicReadPtrT(&pAhciPortR3->pTaskErr, PAHCIREQ)) 3686 3734 ASMAtomicOrU32(&pAhciPort->u32QueuedTasksFinished, RT_BIT_32(uTag)); 3687 3735 } … … 3694 3742 * impact on performance (see @bugref{5071}) 3695 3743 */ 3696 ahciSendSDBFis(p AhciPort, 0, true);3744 ahciSendSDBFis(pDevIns, pThis, pAhciPort, pAhciPortR3, 0, true); 3697 3745 } 3698 3746 else 3699 ahciSendD2HFis(p AhciPort, uTag, &cmdFis[0], true);3747 ahciSendD2HFis(pDevIns, pThis, pAhciPort, uTag, &cmdFis[0], true); 3700 3748 } 3701 3749 else … … 3712 3760 if (pAhciReq->enmType == PDMMEDIAEXIOREQTYPE_FLUSH) 3713 3761 LogRel(("AHCI#%uP%u: Canceled flush returned rc=%Rrc\n", 3714 p AhciPort->CTX_SUFF(pDevIns)->iInstance, pAhciPort->iLUN, rcReq));3762 pDevIns->iInstance, pAhciPort->iLUN, rcReq)); 3715 3763 else if (pAhciReq->enmType == PDMMEDIAEXIOREQTYPE_DISCARD) 3716 3764 LogRel(("AHCI#%uP%u: Canceled trim returned rc=%Rrc\n", 3717 p AhciPort->CTX_SUFF(pDevIns)->iInstance,pAhciPort->iLUN, rcReq));3765 pDevIns->iInstance,pAhciPort->iLUN, rcReq)); 3718 3766 else 3719 3767 LogRel(("AHCI#%uP%u: Canceled %s at offset %llu (%zu bytes left) returned rc=%Rrc\n", 3720 p AhciPort->CTX_SUFF(pDevIns)->iInstance, pAhciPort->iLUN,3768 pDevIns->iInstance, pAhciPort->iLUN, 3721 3769 pAhciReq->enmType == PDMMEDIAEXIOREQTYPE_READ 3722 3770 ? "read" … … 3726 3774 } 3727 3775 3728 ahciR3ReqFree(pAhciPort , pAhciReq);3776 ahciR3ReqFree(pAhciPortR3, pAhciReq); 3729 3777 } 3730 3778 … … 3739 3787 ASMAtomicDecU32(&pAhciPort->cTasksActive); 3740 3788 3741 if (pAhciPort->cTasksActive == 0 && p AhciPort->pAhciR3->fSignalIdle)3742 PDMDevHlpAsyncNotificationCompleted(p AhciPort->pDevInsR3);3789 if (pAhciPort->cTasksActive == 0 && pThisCC->fSignalIdle) 3790 PDMDevHlpAsyncNotificationCompleted(pDevIns); 3743 3791 3744 3792 return fCanceled; … … 3752 3800 size_t cbCopy) 3753 3801 { 3754 RT_NOREF(hIoReq); 3755 PAHCIPort pAhciPort = RT_FROM_MEMBER(pInterface, AHCIPort, IMediaExPort); 3802 PAHCIPORTR3 pAhciPortR3 = RT_FROM_MEMBER(pInterface, AHCIPORTR3, IMediaExPort); 3756 3803 int rc = VINF_SUCCESS; 3757 3804 PAHCIREQ pIoReq = (PAHCIREQ)pvIoReqAlloc; 3758 3759 ahciR3CopySgBufToPrdtl(pAhciPort->CTX_SUFF(pAhci), pIoReq, pSgBuf, offDst, cbCopy); 3805 RT_NOREF(hIoReq); 3806 3807 ahciR3CopySgBufToPrdtl(pAhciPortR3->pDevIns, pIoReq, pSgBuf, offDst, cbCopy); 3760 3808 3761 3809 if (pIoReq->fFlags & AHCI_REQ_OVERFLOW) … … 3772 3820 size_t cbCopy) 3773 3821 { 3774 RT_NOREF(hIoReq); 3775 PAHCIPort pAhciPort = RT_FROM_MEMBER(pInterface, AHCIPort, IMediaExPort); 3822 PAHCIPORTR3 pAhciPortR3 = RT_FROM_MEMBER(pInterface, AHCIPORTR3, IMediaExPort); 3776 3823 int rc = VINF_SUCCESS; 3777 3824 PAHCIREQ pIoReq = (PAHCIREQ)pvIoReqAlloc; 3778 3779 ahciR3CopySgBufFromPrdtl(pAhciPort->CTX_SUFF(pAhci), pIoReq, pSgBuf, offSrc, cbCopy); 3825 RT_NOREF(hIoReq); 3826 3827 ahciR3CopySgBufFromPrdtl(pAhciPortR3->pDevIns, pIoReq, pSgBuf, offSrc, cbCopy); 3780 3828 if (pIoReq->fFlags & AHCI_REQ_OVERFLOW) 3781 3829 rc = VERR_PDM_MEDIAEX_IOBUF_UNDERRUN; … … 3790 3838 void *pvIoReqAlloc, void **ppvBuf, size_t *pcbBuf) 3791 3839 { 3840 PAHCIPORTR3 pAhciPortR3 = RT_FROM_MEMBER(pInterface, AHCIPORTR3, IMediaExPort); 3841 PPDMDEVINS pDevIns = pAhciPortR3->pDevIns; 3842 PAHCIREQ pIoReq = (PAHCIREQ)pvIoReqAlloc; 3843 int rc = VERR_NOT_SUPPORTED; 3792 3844 RT_NOREF(hIoReq); 3793 int rc = VERR_NOT_SUPPORTED;3794 PAHCIPort pAhciPort = RT_FROM_MEMBER(pInterface, AHCIPort, IMediaExPort);3795 PAHCIREQ pIoReq = (PAHCIREQ)pvIoReqAlloc;3796 PAHCI pThis = pAhciPort->CTX_SUFF(pAhci);3797 3845 3798 3846 /* Only allow single 4KB page aligned buffers at the moment. */ … … 3803 3851 SGLEntry PrdtEntry; 3804 3852 3805 PDMDevHlpPhysRead(p This->pDevInsR3, GCPhysPrdt, &PrdtEntry, sizeof(SGLEntry));3853 PDMDevHlpPhysRead(pDevIns, GCPhysPrdt, &PrdtEntry, sizeof(SGLEntry)); 3806 3854 3807 3855 RTGCPHYS GCPhysAddrDataBase = AHCI_RTGCPHYS_FROM_U32(PrdtEntry.u32DBAUp, PrdtEntry.u32DBA); … … 3811 3859 && !(GCPhysAddrDataBase & (_4K - 1))) 3812 3860 { 3813 rc = PDMDevHlpPhysGCPhys2CCPtr(pThis->pDevInsR3, GCPhysAddrDataBase, 3814 0, ppvBuf, &pIoReq->PgLck); 3861 rc = PDMDevHlpPhysGCPhys2CCPtr(pDevIns, GCPhysAddrDataBase, 0, ppvBuf, &pIoReq->PgLck); 3815 3862 if (RT_SUCCESS(rc)) 3816 3863 { … … 3834 3881 uint32_t *pcRanges) 3835 3882 { 3883 PAHCIPORTR3 pAhciPortR3 = RT_FROM_MEMBER(pInterface, AHCIPORTR3, IMediaExPort); 3884 PPDMDEVINS pDevIns = pAhciPortR3->pDevIns; 3885 PAHCI pThis = PDMDEVINS_2_DATA(pDevIns, PAHCI); 3886 PAHCIPORT pAhciPort = &RT_SAFE_SUBSCRIPT(pThis->ahciPort, pAhciPortR3->iLUN); 3887 PAHCIREQ pIoReq = (PAHCIREQ)pvIoReqAlloc; 3836 3888 RT_NOREF(hIoReq); 3837 PAHCIPort pAhciPort = RT_FROM_MEMBER(pInterface, AHCIPort, IMediaExPort); 3838 PAHCIREQ pIoReq = (PAHCIREQ)pvIoReqAlloc; 3839 3840 return ahciTrimRangesCreate(pAhciPort, pIoReq, idxRangeStart, paRanges, cRanges, pcRanges); 3889 3890 return ahciTrimRangesCreate(pDevIns, pAhciPort, pIoReq, idxRangeStart, paRanges, cRanges, pcRanges); 3841 3891 } 3842 3892 … … 3847 3897 void *pvIoReqAlloc, int rcReq) 3848 3898 { 3899 PAHCIPORTR3 pAhciPortR3 = RT_FROM_MEMBER(pInterface, AHCIPORTR3, IMediaExPort); 3900 PPDMDEVINS pDevIns = pAhciPortR3->pDevIns; 3901 PAHCIR3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAHCICC); 3902 PAHCI pThis = PDMDEVINS_2_DATA(pDevIns, PAHCI); 3903 PAHCIPORT pAhciPort = &RT_SAFE_SUBSCRIPT(pThis->ahciPort, pAhciPortR3->iLUN); 3904 PAHCIREQ pIoReq = (PAHCIREQ)pvIoReqAlloc; 3849 3905 RT_NOREF(hIoReq); 3850 PAHCIPort pAhciPort = RT_FROM_MEMBER(pInterface, AHCIPort, IMediaExPort); 3851 ahci TransferComplete(pAhciPort, (PAHCIREQ)pvIoReqAlloc, rcReq);3906 3907 ahciR3TransferComplete(pDevIns, pThis, pThisCC, pAhciPort, pAhciPortR3, pIoReq, rcReq); 3852 3908 return VINF_SUCCESS; 3853 3909 } … … 3859 3915 void *pvIoReqAlloc, PDMMEDIAEXIOREQSTATE enmState) 3860 3916 { 3917 PAHCIPORTR3 pAhciPortR3 = RT_FROM_MEMBER(pInterface, AHCIPORTR3, IMediaExPort); 3918 PPDMDEVINS pDevIns = pAhciPortR3->pDevIns; 3919 PAHCIR3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAHCICC); 3920 PAHCI pThis = PDMDEVINS_2_DATA(pDevIns, PAHCI); 3921 PAHCIPORT pAhciPort = &RT_SAFE_SUBSCRIPT(pThis->ahciPort, pAhciPortR3->iLUN); 3861 3922 RT_NOREF(hIoReq, pvIoReqAlloc); 3862 PAHCIPort pAhciPort = RT_FROM_MEMBER(pInterface, AHCIPort, IMediaExPort);3863 3923 3864 3924 switch (enmState) … … 3868 3928 /* Make sure the request is not accounted for so the VM can suspend successfully. */ 3869 3929 uint32_t cTasksActive = ASMAtomicDecU32(&pAhciPort->cTasksActive); 3870 if (!cTasksActive && p AhciPort->pAhciR3->fSignalIdle)3871 PDMDevHlpAsyncNotificationCompleted(p AhciPort->pDevInsR3);3930 if (!cTasksActive && pThisCC->fSignalIdle) 3931 PDMDevHlpAsyncNotificationCompleted(pDevIns); 3872 3932 break; 3873 3933 } … … 3886 3946 static DECLCALLBACK(void) ahciR3MediumEjected(PPDMIMEDIAEXPORT pInterface) 3887 3947 { 3888 PAHCIPort pAhciPort = RT_FROM_MEMBER(pInterface, AHCIPort, IMediaExPort); 3889 PAHCI pThis = pAhciPort->CTX_SUFF(pAhci); 3890 3891 if (pThis->pMediaNotify) 3892 { 3893 int rc = VMR3ReqCallNoWait(PDMDevHlpGetVM(pThis->CTX_SUFF(pDevIns)), VMCPUID_ANY, 3894 (PFNRT)pThis->pMediaNotify->pfnEjected, 2, 3895 pThis->pMediaNotify, pAhciPort->iLUN); 3948 PAHCIPORTR3 pAhciPortR3 = RT_FROM_MEMBER(pInterface, AHCIPORTR3, IMediaExPort); 3949 PPDMDEVINS pDevIns = pAhciPortR3->pDevIns; 3950 PAHCIR3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAHCICC); 3951 PAHCI pThis = PDMDEVINS_2_DATA(pDevIns, PAHCI); 3952 PAHCIPORT pAhciPort = &RT_SAFE_SUBSCRIPT(pThis->ahciPort, pAhciPortR3->iLUN); 3953 3954 if (pThisCC->pMediaNotify) 3955 { 3956 int rc = VMR3ReqCallNoWait(PDMDevHlpGetVM(pDevIns), VMCPUID_ANY, 3957 (PFNRT)pThisCC->pMediaNotify->pfnEjected, 2, 3958 pThisCC->pMediaNotify, pAhciPort->iLUN); 3896 3959 AssertRC(rc); 3897 3960 } … … 3902 3965 * 3903 3966 * @returns The direction of the data transfer 3904 * @param pAhciPort The AHCI port of the request. 3905 * @param pAhciReq The AHCI request state. 3906 * @param pCmdFis Pointer to the command FIS. 3907 */ 3908 static PDMMEDIAEXIOREQTYPE ahciProcessCmd(PAHCIPort pAhciPort, PAHCIREQ pAhciReq, uint8_t *pCmdFis) 3967 * @param pDevIns The device instance. 3968 * @param pThis The shared AHCI state. 3969 * @param pAhciPort The AHCI port of the request, shared bits. 3970 * @param pAhciPortR3 The AHCI port of the request, ring-3 bits. 3971 * @param pAhciReq The AHCI request state. 3972 * @param pCmdFis Pointer to the command FIS. 3973 */ 3974 static PDMMEDIAEXIOREQTYPE ahciProcessCmd(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, PAHCIPORTR3 pAhciPortR3, 3975 PAHCIREQ pAhciReq, uint8_t *pCmdFis) 3909 3976 { 3910 3977 PDMMEDIAEXIOREQTYPE enmType = PDMMEDIAEXIOREQTYPE_INVALID; … … 3919 3986 case ATA_IDENTIFY_DEVICE: 3920 3987 { 3921 if (pAhciPort ->pDrvMedia && !pAhciPort->fATAPI)3988 if (pAhciPortR3->pDrvMedia && !pAhciPort->fATAPI) 3922 3989 { 3923 3990 uint16_t u16Temp[256]; 3924 3991 3925 3992 /* Fill the buffer. */ 3926 ahciIdentifySS(p AhciPort, u16Temp);3993 ahciIdentifySS(pThis, pAhciPort, pAhciPortR3, u16Temp); 3927 3994 3928 3995 /* Copy the buffer. */ 3929 size_t cbCopied = ahciR3CopyBufferToPrdtl(pAhciPort->CTX_SUFF(pAhci), pAhciReq, 3930 &u16Temp[0], sizeof(u16Temp), 0 /* cbSkip */); 3996 size_t cbCopied = ahciR3CopyBufferToPrdtl(pDevIns, pAhciReq, &u16Temp[0], sizeof(u16Temp), 0 /* cbSkip */); 3931 3997 3932 3998 pAhciReq->fFlags |= AHCI_REQ_PIO_DATA; … … 3986 4052 { 3987 4053 /* Reset the device. */ 3988 ahciDeviceReset(p AhciPort, pAhciReq);4054 ahciDeviceReset(pDevIns, pThis, pAhciPort, pAhciReq); 3989 4055 } 3990 4056 break; … … 4006 4072 { 4007 4073 size_t cbData; 4008 ahciR3AtapiIdentify(p AhciReq, pAhciPort, 512, &cbData);4074 ahciR3AtapiIdentify(pDevIns, pAhciReq, pAhciPort, 512, &cbData); 4009 4075 4010 4076 pAhciReq->fFlags |= AHCI_REQ_PIO_DATA; … … 4099 4165 { 4100 4166 LogFlow(("Reading error page\n")); 4101 PAHCIREQ pTaskErr = ASMAtomicXchgPtrT(&pAhciPort ->pTaskErr, NULL, PAHCIREQ);4167 PAHCIREQ pTaskErr = ASMAtomicXchgPtrT(&pAhciPortR3->pTaskErr, NULL, PAHCIREQ); 4102 4168 if (pTaskErr) 4103 4169 { … … 4132 4198 * See SATA2 1.2 spec chapter 4.2.3.4 4133 4199 */ 4134 bool fAbortedAll = ahci CancelActiveTasks(pAhciPort);4200 bool fAbortedAll = ahciR3CancelActiveTasks(pAhciPortR3); 4135 4201 Assert(fAbortedAll); NOREF(fAbortedAll); 4136 ahciSendSDBFis(p AhciPort, 0xffffffff, true);4202 ahciSendSDBFis(pDevIns, pThis, pAhciPort, pAhciPortR3, UINT32_C(0xffffffff), true); 4137 4203 4138 4204 break; … … 4141 4207 4142 4208 /* Copy the buffer. */ 4143 size_t cbCopied = ahciR3CopyBufferToPrdtl(pAhciPort->CTX_SUFF(pAhci), pAhciReq, 4144 &aBuf[offLogRead], cbLogRead, 0 /* cbSkip */); 4209 size_t cbCopied = ahciR3CopyBufferToPrdtl(pDevIns, pAhciReq, &aBuf[offLogRead], cbLogRead, 0 /* cbSkip */); 4145 4210 4146 4211 pAhciReq->fFlags |= AHCI_REQ_PIO_DATA; … … 4185 4250 * 4186 4251 * @returns whether the H2D FIS was successfully read from the guest memory. 4187 * @param pAhciPort The AHCI port of the request. 4188 * @param pAhciReq The state of the actual task. 4189 */ 4190 static bool ahciPortTaskGetCommandFis(PAHCIPort pAhciPort, PAHCIREQ pAhciReq) 4252 * @param pDevIns The device instance. 4253 * @param pThis The shared AHCI state. 4254 * @param pAhciPort The AHCI port of the request. 4255 * @param pAhciReq The state of the actual task. 4256 */ 4257 static bool ahciPortTaskGetCommandFis(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, PAHCIREQ pAhciReq) 4191 4258 { 4192 4259 AssertMsgReturn(pAhciPort->GCPhysAddrClb && pAhciPort->GCPhysAddrFb, … … 4203 4270 LogFlow(("%s: PDMDevHlpPhysRead GCPhysAddrCmdLst=%RGp cbCmdHdr=%u\n", __FUNCTION__, 4204 4271 pAhciReq->GCPhysCmdHdrAddr, sizeof(CmdHdr))); 4205 PDMDevHlpPhysRead(p AhciPort->CTX_SUFF(pDevIns), pAhciReq->GCPhysCmdHdrAddr, &cmdHdr, sizeof(CmdHdr));4272 PDMDevHlpPhysRead(pDevIns, pAhciReq->GCPhysCmdHdrAddr, &cmdHdr, sizeof(CmdHdr)); 4206 4273 4207 4274 #ifdef LOG_ENABLED … … 4218 4285 /* Read the command Fis. */ 4219 4286 LogFlow(("%s: PDMDevHlpPhysRead GCPhysAddrCmdTbl=%RGp cbCmdFis=%u\n", __FUNCTION__, GCPhysAddrCmdTbl, AHCI_CMDFIS_TYPE_H2D_SIZE)); 4220 PDMDevHlpPhysRead(p AhciPort->CTX_SUFF(pDevIns), GCPhysAddrCmdTbl, &pAhciReq->cmdFis[0], AHCI_CMDFIS_TYPE_H2D_SIZE);4287 PDMDevHlpPhysRead(pDevIns, GCPhysAddrCmdTbl, &pAhciReq->cmdFis[0], AHCI_CMDFIS_TYPE_H2D_SIZE); 4221 4288 4222 4289 AssertMsgReturn(pAhciReq->cmdFis[AHCI_CMDFIS_TYPE] == AHCI_CMDFIS_TYPE_H2D, … … 4231 4298 { 4232 4299 GCPhysAddrCmdTbl += AHCI_CMDHDR_ACMD_OFFSET; 4233 PDMDevHlpPhysRead(p AhciPort->CTX_SUFF(pDevIns), GCPhysAddrCmdTbl, &pAhciReq->aATAPICmd[0], ATAPI_PACKET_SIZE);4300 PDMDevHlpPhysRead(pDevIns, GCPhysAddrCmdTbl, &pAhciReq->aATAPICmd[0], ATAPI_PACKET_SIZE); 4234 4301 } 4235 4302 … … 4241 4308 * but this FIS does not assert an interrupt 4242 4309 */ 4243 ahciSendD2HFis(p AhciPort, pAhciReq->uTag, pAhciReq->cmdFis, false);4310 ahciSendD2HFis(pDevIns, pThis, pAhciPort, pAhciReq->uTag, pAhciReq->cmdFis, false); 4244 4311 pAhciPort->regTFD &= ~AHCI_PORT_TFD_BSY; 4245 4312 } … … 4261 4328 4262 4329 ahciLog(("Entry %u at address %RGp\n", i, GCPhysPrdtl)); 4263 PDMDevHlpPhysRead(p AhciPort->CTX_SUFF(pDevIns), GCPhysPrdtl, &SGEntry, sizeof(SGLEntry));4330 PDMDevHlpPhysRead(pDevIns, GCPhysPrdtl, &SGEntry, sizeof(SGLEntry)); 4264 4331 4265 4332 RTGCPHYS GCPhysDataAddr = AHCI_RTGCPHYS_FROM_U32(SGEntry.u32DBAUp, SGEntry.u32DBA); … … 4277 4344 * 4278 4345 * @returns Flag whether the request was canceled inbetween. 4279 * @param pAhciPort The port the request is for. 4280 * @param pAhciReq The request to submit. 4346 * @param pDevIns The device instance. 4347 * @param pThis The shared AHCI state. 4348 * @param pThisCC The ring-3 AHCI state. 4349 * @param pAhciPort The port the request is for. 4350 * @param pAhciReq The request to submit. 4281 4351 * @param enmType The request type. 4282 4352 */ 4283 static bool ahciR3ReqSubmit(PAHCIPort pAhciPort, PAHCIREQ pAhciReq, PDMMEDIAEXIOREQTYPE enmType) 4353 static bool ahciR3ReqSubmit(PPDMDEVINS pDevIns, PAHCI pThis, PAHCICC pThisCC, PAHCIPORT pAhciPort, PAHCIPORTR3 pAhciPortR3, 4354 PAHCIREQ pAhciReq, PDMMEDIAEXIOREQTYPE enmType) 4284 4355 { 4285 4356 int rc = VINF_SUCCESS; … … 4289 4360 4290 4361 if (enmType == PDMMEDIAEXIOREQTYPE_FLUSH) 4291 rc = pAhciPort ->pDrvMediaEx->pfnIoReqFlush(pAhciPort->pDrvMediaEx, pAhciReq->hIoReq);4362 rc = pAhciPortR3->pDrvMediaEx->pfnIoReqFlush(pAhciPortR3->pDrvMediaEx, pAhciReq->hIoReq); 4292 4363 else if (enmType == PDMMEDIAEXIOREQTYPE_DISCARD) 4293 4364 { … … 4301 4372 4302 4373 pAhciPort->Led.Asserted.s.fWriting = pAhciPort->Led.Actual.s.fWriting = 1; 4303 rc = pAhciPort ->pDrvMediaEx->pfnIoReqDiscard(pAhciPort->pDrvMediaEx, pAhciReq->hIoReq,4374 rc = pAhciPortR3->pDrvMediaEx->pfnIoReqDiscard(pAhciPortR3->pDrvMediaEx, pAhciReq->hIoReq, 4304 4375 cRangesMax); 4305 4376 } … … 4307 4378 { 4308 4379 pAhciPort->Led.Asserted.s.fReading = pAhciPort->Led.Actual.s.fReading = 1; 4309 rc = pAhciPort ->pDrvMediaEx->pfnIoReqRead(pAhciPort->pDrvMediaEx, pAhciReq->hIoReq,4380 rc = pAhciPortR3->pDrvMediaEx->pfnIoReqRead(pAhciPortR3->pDrvMediaEx, pAhciReq->hIoReq, 4310 4381 pAhciReq->uOffset, pAhciReq->cbTransfer); 4311 4382 } … … 4313 4384 { 4314 4385 pAhciPort->Led.Asserted.s.fWriting = pAhciPort->Led.Actual.s.fWriting = 1; 4315 rc = pAhciPort ->pDrvMediaEx->pfnIoReqWrite(pAhciPort->pDrvMediaEx, pAhciReq->hIoReq,4386 rc = pAhciPortR3->pDrvMediaEx->pfnIoReqWrite(pAhciPortR3->pDrvMediaEx, pAhciReq->hIoReq, 4316 4387 pAhciReq->uOffset, pAhciReq->cbTransfer); 4317 4388 } … … 4321 4392 4322 4393 if (pAhciReq->cPrdtlEntries) 4323 rc = ahciR3PrdtQuerySize(p AhciPort->CTX_SUFF(pAhci), pAhciReq, &cbBuf);4394 rc = ahciR3PrdtQuerySize(pDevIns, pAhciReq, &cbBuf); 4324 4395 pAhciReq->cbTransfer = cbBuf; 4325 4396 if (RT_SUCCESS(rc)) … … 4329 4400 else if (cbBuf) 4330 4401 pAhciPort->Led.Asserted.s.fWriting = pAhciPort->Led.Actual.s.fWriting = 1; 4331 rc = pAhciPort ->pDrvMediaEx->pfnIoReqSendScsiCmd(pAhciPort->pDrvMediaEx, pAhciReq->hIoReq,4402 rc = pAhciPortR3->pDrvMediaEx->pfnIoReqSendScsiCmd(pAhciPortR3->pDrvMediaEx, pAhciReq->hIoReq, 4332 4403 0, &pAhciReq->aATAPICmd[0], ATAPI_PACKET_SIZE, 4333 4404 PDMMEDIAEXIOREQSCSITXDIR_UNKNOWN, NULL, cbBuf, … … 4338 4409 4339 4410 if (rc == VINF_SUCCESS) 4340 fReqCanceled = ahci TransferComplete(pAhciPort, pAhciReq, VINF_SUCCESS);4411 fReqCanceled = ahciR3TransferComplete(pDevIns, pThis, pThisCC, pAhciPort, pAhciPortR3, pAhciReq, VINF_SUCCESS); 4341 4412 else if (rc != VINF_PDM_MEDIAEX_IOREQ_IN_PROGRESS) 4342 fReqCanceled = ahci TransferComplete(pAhciPort, pAhciReq, rc);4413 fReqCanceled = ahciR3TransferComplete(pDevIns, pThis, pThisCC, pAhciPort, pAhciPortR3, pAhciReq, rc); 4343 4414 4344 4415 return fReqCanceled; … … 4351 4422 * @returns Whether the command was successfully fetched from guest memory and 4352 4423 * can be continued. 4353 * @param pAhciPort The AHCI port the request is for. 4354 * @param pAhciReq Request structure to copy the command to. 4355 */ 4356 static bool ahciR3CmdPrepare(PAHCIPort pAhciPort, PAHCIREQ pAhciReq) 4424 * @param pDevIns The device instance. 4425 * @param pThis The shared AHCI state. 4426 * @param pAhciPort The AHCI port the request is for. 4427 * @param pAhciReq Request structure to copy the command to. 4428 */ 4429 static bool ahciR3CmdPrepare(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, PAHCIREQ pAhciReq) 4357 4430 { 4358 4431 /* Set current command slot */ 4359 4432 ASMAtomicWriteU32(&pAhciPort->u32CurrentCommandSlot, pAhciReq->uTag); 4360 4433 4361 bool fContinue = ahciPortTaskGetCommandFis(p AhciPort, pAhciReq);4434 bool fContinue = ahciPortTaskGetCommandFis(pDevIns, pThis, pAhciPort, pAhciReq); 4362 4435 if (fContinue) 4363 4436 { … … 4380 4453 AssertLogRelMsg(ASMAtomicReadU32(&pAhciPort->cTasksActive) <= AHCI_NR_COMMAND_SLOTS, 4381 4454 ("AHCI#%uP%u: There are more than %u (+1) requests active", 4382 p AhciPort->CTX_SUFF(pDevIns)->iInstance, pAhciPort->iLUN,4455 pDevIns->iInstance, pAhciPort->iLUN, 4383 4456 AHCI_NR_COMMAND_SLOTS)); 4384 4457 ASMAtomicIncU32(&pAhciPort->cTasksActive); … … 4391 4464 ahciLog(("%s: Setting device into reset state\n", __FUNCTION__)); 4392 4465 pAhciPort->fResetDevice = true; 4393 ahciSendD2HFis(p AhciPort, pAhciReq->uTag, pAhciReq->cmdFis, true);4466 ahciSendD2HFis(pDevIns, pThis, pAhciPort, pAhciReq->uTag, pAhciReq->cmdFis, true); 4394 4467 } 4395 4468 else if (pAhciPort->fResetDevice) /* The bit is not set and we are in a reset state. */ 4396 ahciFinishStorageDeviceReset(p AhciPort, pAhciReq);4469 ahciFinishStorageDeviceReset(pDevIns, pThis, pAhciPort, pAhciReq); 4397 4470 else /* We are not in a reset state update the control registers. */ 4398 4471 AssertMsgFailed(("%s: Update the control register\n", __FUNCTION__)); … … 4422 4495 static DECLCALLBACK(int) ahciAsyncIOLoop(PPDMDEVINS pDevIns, PPDMTHREAD pThread) 4423 4496 { 4424 RT_NOREF(pDevIns); 4425 PAHCIPort pAhciPort = (PAHCIPort)pThread->pvUser; 4426 PAHCI pThis = pAhciPort->CTX_SUFF(pAhci); 4427 int rc = VINF_SUCCESS; 4497 PAHCIPORTR3 pAhciPortR3 = (PAHCIPORTR3)pThread->pvUser; 4498 PAHCI pThis = PDMDEVINS_2_DATA(pDevIns, PAHCI); 4499 PAHCIR3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAHCICC); 4500 PAHCIPORT pAhciPort = &RT_SAFE_SUBSCRIPT(pThis->ahciPort, pAhciPortR3->iLUN); 4501 int rc = VINF_SUCCESS; 4428 4502 4429 4503 ahciLog(("%s: Port %d entering async IO loop.\n", __FUNCTION__, pAhciPort->iLUN)); … … 4455 4529 4456 4530 /* Check whether the thread should be suspended. */ 4457 if (pThis ->fSignalIdle)4531 if (pThisCC->fSignalIdle) 4458 4532 { 4459 4533 if (!ASMAtomicDecU32(&pThis->cThreadsActive)) 4460 PDMDevHlpAsyncNotificationCompleted(p AhciPort->pDevInsR3);4534 PDMDevHlpAsyncNotificationCompleted(pDevIns); 4461 4535 continue; 4462 4536 } … … 4470 4544 && !ASMAtomicDecU32(&pThis->cThreadsActive)) 4471 4545 { 4472 ahci HBAReset(pThis);4473 if (pThis ->fSignalIdle)4474 PDMDevHlpAsyncNotificationCompleted(p AhciPort->pDevInsR3);4546 ahciR3HBAReset(pDevIns, pThis, pThisCC); 4547 if (pThisCC->fSignalIdle) 4548 PDMDevHlpAsyncNotificationCompleted(pDevIns); 4475 4549 continue; 4476 4550 } … … 4486 4560 ahciLog(("%s: Processing command at slot %d\n", __FUNCTION__, idx)); 4487 4561 4488 PAHCIREQ pAhciReq = ahciR3ReqAlloc(pAhciPort , idx);4562 PAHCIREQ pAhciReq = ahciR3ReqAlloc(pAhciPortR3, idx); 4489 4563 if (RT_LIKELY(pAhciReq)) 4490 4564 { … … 4492 4566 pAhciReq->fFlags = 0; 4493 4567 4494 bool fContinue = ahciR3CmdPrepare(p AhciPort, pAhciReq);4568 bool fContinue = ahciR3CmdPrepare(pDevIns, pThis, pAhciPort, pAhciReq); 4495 4569 if (fContinue) 4496 4570 { 4497 PDMMEDIAEXIOREQTYPE enmType = ahciProcessCmd(pAhciPort, pAhciReq, pAhciReq->cmdFis); 4571 PDMMEDIAEXIOREQTYPE enmType = ahciProcessCmd(pDevIns, pThis, pAhciPort, pAhciPortR3, 4572 pAhciReq, pAhciReq->cmdFis); 4498 4573 pAhciReq->enmType = enmType; 4499 4574 4500 4575 if (enmType != PDMMEDIAEXIOREQTYPE_INVALID) 4501 fReqCanceled = ahciR3ReqSubmit(p AhciPort, pAhciReq, enmType);4576 fReqCanceled = ahciR3ReqSubmit(pDevIns, pThis, pThisCC, pAhciPort, pAhciPortR3, pAhciReq, enmType); 4502 4577 else 4503 fReqCanceled = ahciTransferComplete(pAhciPort, pAhciReq, VINF_SUCCESS); 4578 fReqCanceled = ahciR3TransferComplete(pDevIns, pThis, pThisCC, pAhciPort, pAhciPortR3, 4579 pAhciReq, VINF_SUCCESS); 4504 4580 } /* Command */ 4505 4581 else 4506 ahciR3ReqFree(pAhciPort , pAhciReq);4582 ahciR3ReqFree(pAhciPortR3, pAhciReq); 4507 4583 } 4508 4584 else /* !Request allocated, use on stack variant to signal the error. */ … … 4516 4592 Req.enmType = PDMMEDIAEXIOREQTYPE_INVALID; 4517 4593 4518 bool fContinue = ahciR3CmdPrepare(p AhciPort, &Req);4594 bool fContinue = ahciR3CmdPrepare(pDevIns, pThis, pAhciPort, &Req); 4519 4595 if (fContinue) 4520 fReqCanceled = ahci TransferComplete(pAhciPort, &Req, VERR_NO_MEMORY);4596 fReqCanceled = ahciR3TransferComplete(pDevIns, pThis, pThisCC, pAhciPort, pAhciPortR3, &Req, VERR_NO_MEMORY); 4521 4597 } 4522 4598 … … 4535 4611 if ( ASMAtomicReadBool(&pAhciPort->fPortReset) 4536 4612 && (pAhciPort->regSCTL & AHCI_PORT_SCTL_DET) == AHCI_PORT_SCTL_DET_NINIT) 4537 ahciPortResetFinish(p AhciPort);4613 ahciPortResetFinish(pDevIns, pThis, pAhciPort, pAhciPortR3); 4538 4614 4539 4615 /* … … 4545 4621 if ( (u32RegHbaCtrl & AHCI_HBA_CTRL_HR) 4546 4622 && !cThreadsActive) 4547 ahci HBAReset(pThis);4548 4549 if (!cThreadsActive && pThis ->fSignalIdle)4550 PDMDevHlpAsyncNotificationCompleted(p AhciPort->pDevInsR3);4623 ahciR3HBAReset(pDevIns, pThis, pThisCC); 4624 4625 if (!cThreadsActive && pThisCC->fSignalIdle) 4626 PDMDevHlpAsyncNotificationCompleted(pDevIns); 4551 4627 } /* While running */ 4552 4628 … … 4560 4636 static DECLCALLBACK(int) ahciAsyncIOLoopWakeUp(PPDMDEVINS pDevIns, PPDMTHREAD pThread) 4561 4637 { 4562 PAHCIPort pAhciPort = (PAHCIPort)pThread->pvUser; 4638 PAHCIPORTR3 pAhciPortR3 = (PAHCIPORTR3)pThread->pvUser; 4639 PAHCI pThis = PDMDEVINS_2_DATA(pDevIns, PAHCI); 4640 PAHCIPORT pAhciPort = &RT_SAFE_SUBSCRIPT(pThis->ahciPort, pAhciPortR3->iLUN); 4563 4641 return PDMDevHlpSUPSemEventSignal(pDevIns, pAhciPort->hEvtProcess); 4564 4642 } … … 4605 4683 * Per port data. 4606 4684 */ 4607 for (unsigned i = 0; i < pThis->cPortsImpl; i++)4608 {4609 PAHCIPort pThisPort = &pThis->ahciPort[i];4610 4611 pHlp->pfnPrintf(pHlp, "Port %d: device-attached=%RTbool\n", 4612 pThisPort->iLUN, pThisPort->pDrvBase != NULL);4685 uint32_t const cPortsImpl = RT_MIN(pThis->cPortsImpl, RT_ELEMENTS(pThis->ahciPort)); 4686 for (unsigned i = 0; i < cPortsImpl; i++) 4687 { 4688 PAHCIPORT pThisPort = &pThis->ahciPort[i]; 4689 4690 pHlp->pfnPrintf(pHlp, "Port %d: device-attached=%RTbool\n", pThisPort->iLUN, pThisPort->fPresent); 4613 4691 pHlp->pfnPrintf(pHlp, "PortClb=%#x\n", pThisPort->regCLB); 4614 4692 pHlp->pfnPrintf(pHlp, "PortClbU=%#x\n", pThisPort->regCLBU); … … 4659 4737 for (uint32_t i = 0; i < RT_ELEMENTS(pThis->ahciPort); i++) 4660 4738 { 4661 PAHCIP ortpThisPort = &pThis->ahciPort[i];4662 if (pThisPort-> pDrvBase)4739 PAHCIPORT pThisPort = &pThis->ahciPort[i]; 4740 if (pThisPort->fPresent) 4663 4741 { 4664 4742 if ( (pThisPort->cTasksActive != 0) … … 4705 4783 for (uint32_t i = 0; i < AHCI_MAX_NR_PORTS_IMPL; i++) 4706 4784 { 4707 pHlp->pfnSSMPutBool(pSSM, pThis->ahciPort[i]. pDrvBase != NULL);4785 pHlp->pfnSSMPutBool(pSSM, pThis->ahciPort[i].fPresent); 4708 4786 pHlp->pfnSSMPutBool(pSSM, pThis->ahciPort[i].fHotpluggable); 4709 4787 pHlp->pfnSSMPutStrZ(pSSM, pThis->ahciPort[i].szSerialNumber); … … 4909 4987 rc = pHlp->pfnSSMGetBool(pSSM, &fInUse); 4910 4988 AssertRCReturn(rc, rc); 4911 if (fInUse != (pThis->ahciPort[i].pDrvBase != NULL))4989 if (fInUse != pThis->ahciPort[i].fPresent) 4912 4990 return pHlp->pfnSSMSetCfgError(pSSM, RT_SRC_POS, 4913 4991 N_("The %s VM is missing a device on port %u. Please make sure the source and target VMs have compatible storage configurations"), … … 4995 5073 for (uint32_t i = 0; i < AHCI_MAX_NR_PORTS_IMPL; i++) 4996 5074 { 4997 PAHCIP ortpAhciPort = &pThis->ahciPort[i];5075 PAHCIPORT pAhciPort = &pThis->ahciPort[i]; 4998 5076 4999 5077 pHlp->pfnSSMGetU32(pSSM, &pThis->ahciPort[i].regCLB); … … 5087 5165 /* -=-=-=-=- device PDM interface -=-=-=-=- */ 5088 5166 5089 static DECLCALLBACK(void) ahciR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)5090 {5091 uint32_t i;5092 PAHCI pThis = PDMDEVINS_2_DATA(pDevIns, PAHCI);5093 5094 pThis->pDevInsRC += offDelta;5095 5096 /* Relocate every port. */5097 for (i = 0; i < RT_ELEMENTS(pThis->ahciPort); i++)5098 {5099 PAHCIPort pAhciPort = &pThis->ahciPort[i];5100 pAhciPort->pAhciRC += offDelta;5101 pAhciPort->pDevInsRC += offDelta;5102 }5103 }5104 5105 5167 /** 5106 5168 * Configure the attached device for a port. … … 5110 5172 * @returns VBox status code 5111 5173 * @param pDevIns The device instance data. 5112 * @param pAhciPort The port for which the device is to be configured. 5113 */ 5114 static int ahciR3ConfigureLUN(PPDMDEVINS pDevIns, PAHCIPort pAhciPort) 5174 * @param pAhciPort The port for which the device is to be configured, shared bits. 5175 * @param pAhciPortR3 The port for which the device is to be configured, ring-3 bits. 5176 */ 5177 static int ahciR3ConfigureLUN(PPDMDEVINS pDevIns, PAHCIPORT pAhciPort, PAHCIPORTR3 pAhciPortR3) 5115 5178 { 5116 5179 /* Query the media interface. */ 5117 pAhciPort ->pDrvMedia = PDMIBASE_QUERY_INTERFACE(pAhciPort->pDrvBase, PDMIMEDIA);5118 AssertMsgReturn(VALID_PTR(pAhciPort ->pDrvMedia),5180 pAhciPortR3->pDrvMedia = PDMIBASE_QUERY_INTERFACE(pAhciPortR3->pDrvBase, PDMIMEDIA); 5181 AssertMsgReturn(VALID_PTR(pAhciPortR3->pDrvMedia), 5119 5182 ("AHCI configuration error: LUN#%d misses the basic media interface!\n", pAhciPort->iLUN), 5120 5183 VERR_PDM_MISSING_INTERFACE); 5121 5184 5122 5185 /* Get the extended media interface. */ 5123 pAhciPort ->pDrvMediaEx = PDMIBASE_QUERY_INTERFACE(pAhciPort->pDrvBase, PDMIMEDIAEX);5124 AssertMsgReturn(VALID_PTR(pAhciPort ->pDrvMediaEx),5186 pAhciPortR3->pDrvMediaEx = PDMIBASE_QUERY_INTERFACE(pAhciPortR3->pDrvBase, PDMIMEDIAEX); 5187 AssertMsgReturn(VALID_PTR(pAhciPortR3->pDrvMediaEx), 5125 5188 ("AHCI configuration error: LUN#%d misses the extended media interface!\n", pAhciPort->iLUN), 5126 5189 VERR_PDM_MISSING_INTERFACE); … … 5129 5192 * Validate type. 5130 5193 */ 5131 PDMMEDIATYPE enmType = pAhciPort ->pDrvMedia->pfnGetType(pAhciPort->pDrvMedia);5194 PDMMEDIATYPE enmType = pAhciPortR3->pDrvMedia->pfnGetType(pAhciPortR3->pDrvMedia); 5132 5195 AssertMsgReturn(enmType == PDMMEDIATYPE_HARD_DISK || enmType == PDMMEDIATYPE_CDROM || enmType == PDMMEDIATYPE_DVD, 5133 5196 ("AHCI configuration error: LUN#%d isn't a disk or cd/dvd. enmType=%u\n", pAhciPort->iLUN, enmType), 5134 5197 VERR_PDM_UNSUPPORTED_BLOCK_TYPE); 5135 5198 5136 int rc = pAhciPort ->pDrvMediaEx->pfnIoReqAllocSizeSet(pAhciPort->pDrvMediaEx, sizeof(AHCIREQ));5199 int rc = pAhciPortR3->pDrvMediaEx->pfnIoReqAllocSizeSet(pAhciPortR3->pDrvMediaEx, sizeof(AHCIREQ)); 5137 5200 if (RT_FAILURE(rc)) 5138 5201 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, … … 5141 5204 5142 5205 uint32_t fFeatures = 0; 5143 rc = pAhciPort ->pDrvMediaEx->pfnQueryFeatures(pAhciPort->pDrvMediaEx, &fFeatures);5206 rc = pAhciPortR3->pDrvMediaEx->pfnQueryFeatures(pAhciPortR3->pDrvMediaEx, &fFeatures); 5144 5207 if (RT_FAILURE(rc)) 5145 5208 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, … … 5150 5213 pAhciPort->fTrimEnabled = true; 5151 5214 5215 pAhciPort->fPresent = true; 5216 5152 5217 pAhciPort->fATAPI = (enmType == PDMMEDIATYPE_CDROM || enmType == PDMMEDIATYPE_DVD) 5153 5218 && RT_BOOL(fFeatures & PDMIMEDIAEX_FEATURE_F_RAWSCSICMD); … … 5161 5226 else 5162 5227 { 5163 pAhciPort->cbSector = pAhciPort ->pDrvMedia->pfnGetSectorSize(pAhciPort->pDrvMedia);5164 pAhciPort->cTotalSectors = pAhciPort ->pDrvMedia->pfnGetSize(pAhciPort->pDrvMedia) / pAhciPort->cbSector;5165 rc = pAhciPort ->pDrvMedia->pfnBiosGetPCHSGeometry(pAhciPort->pDrvMedia, &pAhciPort->PCHSGeometry);5228 pAhciPort->cbSector = pAhciPortR3->pDrvMedia->pfnGetSectorSize(pAhciPortR3->pDrvMedia); 5229 pAhciPort->cTotalSectors = pAhciPortR3->pDrvMedia->pfnGetSize(pAhciPortR3->pDrvMedia) / pAhciPort->cbSector; 5230 rc = pAhciPortR3->pDrvMedia->pfnBiosGetPCHSGeometry(pAhciPortR3->pDrvMedia, &pAhciPort->PCHSGeometry); 5166 5231 if (rc == VERR_PDM_MEDIA_NOT_MOUNTED) 5167 5232 { … … 5186 5251 pAhciPort->PCHSGeometry.cSectors = 63; 5187 5252 /* Set the disk geometry information. Ignore errors. */ 5188 pAhciPort ->pDrvMedia->pfnBiosSetPCHSGeometry(pAhciPort->pDrvMedia, &pAhciPort->PCHSGeometry);5253 pAhciPortR3->pDrvMedia->pfnBiosSetPCHSGeometry(pAhciPortR3->pDrvMedia, &pAhciPort->PCHSGeometry); 5189 5254 rc = VINF_SUCCESS; 5190 5255 } … … 5210 5275 return false; 5211 5276 5212 PAHCI pThis = PDMDEVINS_2_DATA(pDevIns, PAHCI);5213 ASMAtomicWriteBool(&pThis ->fSignalIdle, false);5277 PAHCIR3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAHCICC); 5278 ASMAtomicWriteBool(&pThisCC->fSignalIdle, false); 5214 5279 return true; 5215 5280 } … … 5220 5285 static void ahciR3SuspendOrPowerOff(PPDMDEVINS pDevIns) 5221 5286 { 5222 PAHCI pThis = PDMDEVINS_2_DATA(pDevIns, PAHCI);5223 5224 ASMAtomicWriteBool(&pThis ->fSignalIdle, true);5287 PAHCIR3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAHCICC); 5288 5289 ASMAtomicWriteBool(&pThisCC->fSignalIdle, true); 5225 5290 if (!ahciR3AllAsyncIOIsFinished(pDevIns)) 5226 5291 PDMDevHlpSetAsyncNotification(pDevIns, ahciR3IsAsyncSuspendOrPowerOffDone); 5227 5292 else 5228 ASMAtomicWriteBool(&pThis ->fSignalIdle, false);5229 5230 for (uint32_t i = 0; i < RT_ELEMENTS(pThis ->ahciPort); i++)5231 { 5232 PAHCIP ort pThisPort = &pThis->ahciPort[i];5293 ASMAtomicWriteBool(&pThisCC->fSignalIdle, false); 5294 5295 for (uint32_t i = 0; i < RT_ELEMENTS(pThisCC->aPorts); i++) 5296 { 5297 PAHCIPORTR3 pThisPort = &pThisCC->aPorts[i]; 5233 5298 if (pThisPort->pDrvMediaEx) 5234 5299 pThisPort->pDrvMediaEx->pfnNotifySuspend(pThisPort->pDrvMediaEx); … … 5262 5327 for (unsigned i = 0; i < RT_ELEMENTS(pThis->ahciPort); i++) 5263 5328 { 5264 PAHCIP ortpAhciPort = &pThis->ahciPort[i];5329 PAHCIPORT pAhciPort = &pThis->ahciPort[i]; 5265 5330 5266 5331 if (pAhciPort->u32TasksRedo) … … 5285 5350 * 5286 5351 * @returns VBox status code. 5287 * @param pDevIns The device instance. 5288 * @param pAhciPort The attached device. 5289 * @param pszName Name of the port to get the CFGM node. 5290 */ 5291 static int ahciR3VpdInit(PPDMDEVINS pDevIns, PAHCIPort pAhciPort, const char *pszName) 5352 * @param pDevIns The device instance. 5353 * @param pAhciPort The attached device, shared bits. 5354 * @param pAhciPortR3 The attached device, ring-3 bits. 5355 * @param pszName Name of the port to get the CFGM node. 5356 */ 5357 static int ahciR3VpdInit(PPDMDEVINS pDevIns, PAHCIPORT pAhciPort, PAHCIPORTR3 pAhciPortR3, const char *pszName) 5292 5358 { 5293 5359 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; … … 5298 5364 5299 5365 int rc = VINF_SUCCESS; 5300 if (pAhciPort ->pDrvMedia)5301 rc = pAhciPort ->pDrvMedia->pfnGetUuid(pAhciPort->pDrvMedia, &Uuid);5366 if (pAhciPortR3->pDrvMedia) 5367 rc = pAhciPortR3->pDrvMedia->pfnGetUuid(pAhciPortR3->pDrvMedia, &Uuid); 5302 5368 else 5303 5369 RTUuidClear(&Uuid); … … 5401 5467 static DECLCALLBACK(void) ahciR3Detach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags) 5402 5468 { 5403 PAHCI pThis= PDMDEVINS_2_DATA(pDevIns, PAHCI);5404 PAHCI Port pAhciPort = &pThis->ahciPort[iLUN];5405 int 5469 PAHCI pThis = PDMDEVINS_2_DATA(pDevIns, PAHCI); 5470 PAHCIR3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAHCICC); 5471 int rc = VINF_SUCCESS; 5406 5472 5407 5473 Log(("%s:\n", __FUNCTION__)); 5408 5474 5409 AssertMsg(iLUN < pThis->cPortsImpl, ("iLUN=%u", iLUN)); 5475 AssertMsgReturnVoid(iLUN < RT_MIN(pThis->cPortsImpl, RT_ELEMENTS(pThisCC->aPorts)), ("iLUN=%u", iLUN)); 5476 PAHCIPORT pAhciPort = &pThis->ahciPort[iLUN]; 5477 PAHCIPORTR3 pAhciPortR3 = &pThisCC->aPorts[iLUN]; 5410 5478 AssertMsgReturnVoid( pAhciPort->fHotpluggable 5411 5479 || (fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG), … … 5413 5481 5414 5482 5415 if (pAhciPort ->pAsyncIOThread)5483 if (pAhciPortR3->pAsyncIOThread) 5416 5484 { 5417 5485 int rcThread; 5418 5486 /* Destroy the thread. */ 5419 rc = PDMDevHlpThreadDestroy(pDevIns, pAhciPort ->pAsyncIOThread, &rcThread);5487 rc = PDMDevHlpThreadDestroy(pDevIns, pAhciPortR3->pAsyncIOThread, &rcThread); 5420 5488 if (RT_FAILURE(rc) || RT_FAILURE(rcThread)) 5421 5489 AssertMsgFailed(("%s Failed to destroy async IO thread rc=%Rrc rcThread=%Rrc\n", __FUNCTION__, rc, rcThread)); 5422 5490 5423 pAhciPort ->pAsyncIOThread = NULL;5491 pAhciPortR3->pAsyncIOThread = NULL; 5424 5492 pAhciPort->fWrkThreadSleeping = true; 5425 5493 } … … 5440 5508 ASMAtomicOrU32(&pAhciPort->regSERR, AHCI_PORT_SERR_X | AHCI_PORT_SERR_N); 5441 5509 if (pAhciPort->regIE & (AHCI_PORT_IE_CPDE | AHCI_PORT_IE_PCE | AHCI_PORT_IE_PRCE)) 5442 ahciHbaSetInterrupt(p AhciPort->CTX_SUFF(pAhci), pAhciPort->iLUN, VERR_IGNORED);5510 ahciHbaSetInterrupt(pDevIns, pThis, pAhciPort->iLUN, VERR_IGNORED); 5443 5511 } 5444 5512 … … 5446 5514 * Zero some important members. 5447 5515 */ 5448 pAhciPort->pDrvBase = NULL; 5449 pAhciPort->pDrvMedia = NULL; 5450 pAhciPort->pDrvMediaEx = NULL; 5516 pAhciPortR3->pDrvBase = NULL; 5517 pAhciPortR3->pDrvMedia = NULL; 5518 pAhciPortR3->pDrvMediaEx = NULL; 5519 pAhciPort->fPresent = false; 5451 5520 } 5452 5521 … … 5464 5533 static DECLCALLBACK(int) ahciR3Attach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags) 5465 5534 { 5466 PAHCI pThis = PDMDEVINS_2_DATA(pDevIns, PAHCI);5467 PAHCI Port pAhciPort = &pThis->ahciPort[iLUN];5535 PAHCI pThis = PDMDEVINS_2_DATA(pDevIns, PAHCI); 5536 PAHCIR3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAHCICC); 5468 5537 int rc; 5469 5538 … … 5471 5540 5472 5541 /* the usual paranoia */ 5473 AssertMsg(iLUN < pThis->cPortsImpl, ("iLUN=%u", iLUN)); 5474 AssertRelease(!pAhciPort->pDrvBase); 5475 AssertRelease(!pAhciPort->pDrvMedia); 5476 AssertRelease(!pAhciPort->pDrvMediaEx); 5542 AssertMsgReturn(iLUN < RT_MIN(pThis->cPortsImpl, RT_ELEMENTS(pThisCC->aPorts)), ("iLUN=%u", iLUN), VERR_PDM_LUN_NOT_FOUND); 5543 PAHCIPORT pAhciPort = &pThis->ahciPort[iLUN]; 5544 PAHCIPORTR3 pAhciPortR3 = &pThisCC->aPorts[iLUN]; 5545 AssertRelease(!pAhciPortR3->pDrvBase); 5546 AssertRelease(!pAhciPortR3->pDrvMedia); 5547 AssertRelease(!pAhciPortR3->pDrvMediaEx); 5477 5548 Assert(pAhciPort->iLUN == iLUN); 5549 Assert(pAhciPortR3->iLUN == iLUN); 5478 5550 5479 5551 AssertMsgReturn( pAhciPort->fHotpluggable … … 5486 5558 * required as well as optional. 5487 5559 */ 5488 rc = PDMDevHlpDriverAttach(pDevIns, pAhciPort->iLUN, &pAhciPort ->IBase, &pAhciPort->pDrvBase, pAhciPort->pszDesc);5560 rc = PDMDevHlpDriverAttach(pDevIns, pAhciPort->iLUN, &pAhciPortR3->IBase, &pAhciPortR3->pDrvBase, pAhciPortR3->szDesc); 5489 5561 if (RT_SUCCESS(rc)) 5490 rc = ahciR3ConfigureLUN(pDevIns, pAhciPort );5562 rc = ahciR3ConfigureLUN(pDevIns, pAhciPort, pAhciPortR3); 5491 5563 else 5492 5564 AssertMsgFailed(("Failed to attach LUN#%d. rc=%Rrc\n", pAhciPort->iLUN, rc)); … … 5494 5566 if (RT_FAILURE(rc)) 5495 5567 { 5496 pAhciPort->pDrvBase = NULL; 5497 pAhciPort->pDrvMedia = NULL; 5568 pAhciPortR3->pDrvBase = NULL; 5569 pAhciPortR3->pDrvMedia = NULL; 5570 pAhciPortR3->pDrvMediaEx = NULL; 5571 pAhciPort->fPresent = false; 5498 5572 } 5499 5573 else … … 5505 5579 5506 5580 /* Create the async IO thread. */ 5507 rc = PDMDevHlpThreadCreate(pDevIns, &pAhciPort ->pAsyncIOThread, pAhciPort, ahciAsyncIOLoop, ahciAsyncIOLoopWakeUp, 0,5508 RTTHREADTYPE_IO, pAhciPort->pszDesc);5581 rc = PDMDevHlpThreadCreate(pDevIns, &pAhciPortR3->pAsyncIOThread, pAhciPortR3, ahciAsyncIOLoop, 5582 ahciAsyncIOLoopWakeUp, 0, RTTHREADTYPE_IO, pAhciPortR3->szDesc); 5509 5583 if (RT_FAILURE(rc)) 5510 5584 return rc; … … 5514 5588 */ 5515 5589 if (RT_SUCCESS(rc)) 5516 rc = ahciR3VpdInit(pDevIns, pAhciPort, pAhciPort ->pszDesc);5590 rc = ahciR3VpdInit(pDevIns, pAhciPort, pAhciPortR3, pAhciPortR3->szDesc); 5517 5591 5518 5592 /* Inform the guest about the added device in case of hotplugging. */ … … 5542 5616 || (pAhciPort->regIE & AHCI_PORT_IE_PCE) 5543 5617 || (pAhciPort->regIE & AHCI_PORT_IE_PRCE)) 5544 ahciHbaSetInterrupt(p AhciPort->CTX_SUFF(pAhci), pAhciPort->iLUN, VERR_IGNORED);5618 ahciHbaSetInterrupt(pDevIns, pThis, pAhciPort->iLUN, VERR_IGNORED); 5545 5619 } 5546 5620 … … 5557 5631 static int ahciR3ResetCommon(PPDMDEVINS pDevIns) 5558 5632 { 5559 PAHCI pThis= PDMDEVINS_2_DATA(pDevIns, PAHCI);5560 5561 ahci HBAReset(pThis);5633 PAHCI pThis = PDMDEVINS_2_DATA(pDevIns, PAHCI); 5634 PAHCIR3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAHCICC); 5635 ahciR3HBAReset(pDevIns, pThis, pThisCC); 5562 5636 5563 5637 /* Hardware reset for the ports. */ … … 5575 5649 static DECLCALLBACK(bool) ahciR3IsAsyncResetDone(PPDMDEVINS pDevIns) 5576 5650 { 5577 PAHCI pThis = PDMDEVINS_2_DATA(pDevIns, PAHCI);5651 PAHCIR3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAHCICC); 5578 5652 5579 5653 if (!ahciR3AllAsyncIOIsFinished(pDevIns)) 5580 5654 return false; 5581 ASMAtomicWriteBool(&pThis ->fSignalIdle, false);5655 ASMAtomicWriteBool(&pThisCC->fSignalIdle, false); 5582 5656 5583 5657 ahciR3ResetCommon(pDevIns); … … 5592 5666 static DECLCALLBACK(void) ahciR3Reset(PPDMDEVINS pDevIns) 5593 5667 { 5594 PAHCI pThis = PDMDEVINS_2_DATA(pDevIns, PAHCI);5595 5596 ASMAtomicWriteBool(&pThis ->fSignalIdle, true);5668 PAHCIR3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAHCICC); 5669 5670 ASMAtomicWriteBool(&pThisCC->fSignalIdle, true); 5597 5671 if (!ahciR3AllAsyncIOIsFinished(pDevIns)) 5598 5672 PDMDevHlpSetAsyncNotification(pDevIns, ahciR3IsAsyncResetDone); 5599 5673 else 5600 5674 { 5601 ASMAtomicWriteBool(&pThis ->fSignalIdle, false);5675 ASMAtomicWriteBool(&pThisCC->fSignalIdle, false); 5602 5676 ahciR3ResetCommon(pDevIns); 5603 5677 } … … 5626 5700 { 5627 5701 PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns); 5628 PAHCI pThis= PDMDEVINS_2_DATA(pDevIns, PAHCI);5629 int rc= VINF_SUCCESS;5702 PAHCI pThis = PDMDEVINS_2_DATA(pDevIns, PAHCI); 5703 int rc = VINF_SUCCESS; 5630 5704 5631 5705 /* … … 5640 5714 5641 5715 Log(("%s: Destruct every port\n", __FUNCTION__)); 5642 for (unsigned iActPort = 0; iActPort < pThis->cPortsImpl; iActPort++) 5643 { 5644 PAHCIPort pAhciPort = &pThis->ahciPort[iActPort]; 5716 uint32_t const cPortsImpl = RT_MIN(pThis->cPortsImpl, RT_ELEMENTS(pThis->ahciPort)); 5717 for (unsigned iActPort = 0; iActPort < cPortsImpl; iActPort++) 5718 { 5719 PAHCIPORT pAhciPort = &pThis->ahciPort[iActPort]; 5645 5720 5646 5721 if (pAhciPort->hEvtProcess != NIL_SUPSEMEVENT) … … 5649 5724 pAhciPort->hEvtProcess = NIL_SUPSEMEVENT; 5650 5725 } 5651 5652 if (pAhciPort->pszDesc)5653 RTStrFree(pAhciPort->pszDesc);5654 5726 } 5655 5727 … … 5666 5738 { 5667 5739 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 5668 PAHCI pThis = PDMDEVINS_2_DATA(pDevIns, PAHCI); 5669 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 5740 PAHCI pThis = PDMDEVINS_2_DATA(pDevIns, PAHCI); 5741 PAHCIR3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PAHCICC); 5742 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 5670 5743 PPDMIBASE pBase; 5671 int rc = VINF_SUCCESS;5672 unsigned i = 0;5673 uint32_t cbTotalBufferSize = 0; 5744 int rc; 5745 unsigned i; 5746 uint32_t cbTotalBufferSize = 0; /** @todo r=bird: cbTotalBufferSize isn't ever set. */ 5674 5747 5675 5748 LogFlowFunc(("pThis=%#p\n", pThis)); 5749 /* 5750 * Initialize the instance data (everything touched by the destructor need 5751 * to be initialized here!). 5752 */ 5753 PPDMPCIDEV pPciDev = pDevIns->apPciDevs[0]; 5754 PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev); 5755 5756 PDMPciDevSetVendorId(pPciDev, 0x8086); /* Intel */ 5757 PDMPciDevSetDeviceId(pPciDev, 0x2829); /* ICH-8M */ 5758 PDMPciDevSetCommand(pPciDev, 0x0000); 5759 #ifdef VBOX_WITH_MSI_DEVICES 5760 PDMPciDevSetStatus(pPciDev, VBOX_PCI_STATUS_CAP_LIST); 5761 PDMPciDevSetCapabilityList(pPciDev, 0x80); 5762 #else 5763 PDMPciDevSetCapabilityList(pPciDev, 0x70); 5764 #endif 5765 PDMPciDevSetRevisionId(pPciDev, 0x02); 5766 PDMPciDevSetClassProg(pPciDev, 0x01); 5767 PDMPciDevSetClassSub(pPciDev, 0x06); 5768 PDMPciDevSetClassBase(pPciDev, 0x01); 5769 PDMPciDevSetBaseAddress(pPciDev, 5, false, false, false, 0x00000000); 5770 5771 PDMPciDevSetInterruptLine(pPciDev, 0x00); 5772 PDMPciDevSetInterruptPin(pPciDev, 0x01); 5773 5774 PDMPciDevSetByte(pPciDev, 0x70, VBOX_PCI_CAP_ID_PM); /* Capability ID: PCI Power Management Interface */ 5775 PDMPciDevSetByte(pPciDev, 0x71, 0xa8); /* next */ 5776 PDMPciDevSetByte(pPciDev, 0x72, 0x03); /* version ? */ 5777 5778 PDMPciDevSetByte(pPciDev, 0x90, 0x40); /* AHCI mode. */ 5779 PDMPciDevSetByte(pPciDev, 0x92, 0x3f); 5780 PDMPciDevSetByte(pPciDev, 0x94, 0x80); 5781 PDMPciDevSetByte(pPciDev, 0x95, 0x01); 5782 PDMPciDevSetByte(pPciDev, 0x97, 0x78); 5783 5784 PDMPciDevSetByte(pPciDev, 0xa8, 0x12); /* SATACR capability */ 5785 PDMPciDevSetByte(pPciDev, 0xa9, 0x00); /* next */ 5786 PDMPciDevSetWord(pPciDev, 0xaa, 0x0010); /* Revision */ 5787 PDMPciDevSetDWord(pPciDev, 0xac, 0x00000028); /* SATA Capability Register 1 */ 5788 5789 pThis->cThreadsActive = 0; 5790 5791 pThisCC->pDevIns = pDevIns; 5792 pThisCC->IBase.pfnQueryInterface = ahciR3Status_QueryInterface; 5793 pThisCC->ILeds.pfnQueryStatusLed = ahciR3Status_QueryStatusLed; 5794 5795 /* Initialize port members. */ 5796 for (i = 0; i < AHCI_MAX_NR_PORTS_IMPL; i++) 5797 { 5798 PAHCIPORT pAhciPort = &pThis->ahciPort[i]; 5799 PAHCIPORTR3 pAhciPortR3 = &pThisCC->aPorts[i]; 5800 pAhciPortR3->pDevIns = pDevIns; 5801 pAhciPort->iLUN = i; 5802 pAhciPortR3->iLUN = i; 5803 pAhciPort->Led.u32Magic = PDMLED_MAGIC; 5804 pAhciPortR3->pDrvBase = NULL; 5805 pAhciPortR3->pAsyncIOThread = NULL; 5806 pAhciPort->hEvtProcess = NIL_SUPSEMEVENT; 5807 pAhciPort->fHotpluggable = true; 5808 } 5809 5810 /* 5811 * Init locks, using explicit locking where necessary. 5812 */ 5813 rc = PDMDevHlpSetDeviceCritSect(pDevIns, PDMDevHlpCritSectGetNop(pDevIns)); 5814 AssertRCReturn(rc, rc); 5815 5816 rc = PDMDevHlpCritSectInit(pDevIns, &pThis->lock, RT_SRC_POS, "AHCI#%u", iInstance); 5817 if (RT_FAILURE(rc)) 5818 { 5819 Log(("%s: Failed to create critical section.\n", __FUNCTION__)); 5820 return rc; 5821 } 5676 5822 5677 5823 /* … … 5718 5864 return PDMDEV_SET_ERROR(pDevIns, rc, N_("AHCI configuration error: failed to read TigerHack as boolean")); 5719 5865 5720 /*5721 * Initialize the instance data (everything touched by the destructor need5722 * to be initialized here!).5723 */5724 pThis->pDevInsR3 = pDevIns;5725 pThis->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);5726 pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);5727 5728 PPDMPCIDEV pPciDev = pDevIns->apPciDevs[0];5729 PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev);5730 5731 PDMPciDevSetVendorId(pPciDev, 0x8086); /* Intel */5732 PDMPciDevSetDeviceId(pPciDev, 0x2829); /* ICH-8M */5733 PDMPciDevSetCommand(pPciDev, 0x0000);5734 #ifdef VBOX_WITH_MSI_DEVICES5735 PDMPciDevSetStatus(pPciDev, VBOX_PCI_STATUS_CAP_LIST);5736 PDMPciDevSetCapabilityList(pPciDev, 0x80);5737 #else5738 PDMPciDevSetCapabilityList(pPciDev, 0x70);5739 #endif5740 PDMPciDevSetRevisionId(pPciDev, 0x02);5741 PDMPciDevSetClassProg(pPciDev, 0x01);5742 PDMPciDevSetClassSub(pPciDev, 0x06);5743 PDMPciDevSetClassBase(pPciDev, 0x01);5744 PDMPciDevSetBaseAddress(pPciDev, 5, false, false, false, 0x00000000);5745 5746 PDMPciDevSetInterruptLine(pPciDev, 0x00);5747 PDMPciDevSetInterruptPin(pPciDev, 0x01);5748 5749 PDMPciDevSetByte(pPciDev, 0x70, VBOX_PCI_CAP_ID_PM); /* Capability ID: PCI Power Management Interface */5750 PDMPciDevSetByte(pPciDev, 0x71, 0xa8); /* next */5751 PDMPciDevSetByte(pPciDev, 0x72, 0x03); /* version ? */5752 5753 PDMPciDevSetByte(pPciDev, 0x90, 0x40); /* AHCI mode. */5754 PDMPciDevSetByte(pPciDev, 0x92, 0x3f);5755 PDMPciDevSetByte(pPciDev, 0x94, 0x80);5756 PDMPciDevSetByte(pPciDev, 0x95, 0x01);5757 PDMPciDevSetByte(pPciDev, 0x97, 0x78);5758 5759 PDMPciDevSetByte(pPciDev, 0xa8, 0x12); /* SATACR capability */5760 PDMPciDevSetByte(pPciDev, 0xa9, 0x00); /* next */5761 PDMPciDevSetWord(pPciDev, 0xaa, 0x0010); /* Revision */5762 PDMPciDevSetDWord(pPciDev, 0xac, 0x00000028); /* SATA Capability Register 1 */5763 5764 pThis->cThreadsActive = 0;5765 5766 pThis->IBase.pfnQueryInterface = ahciR3Status_QueryInterface;5767 pThis->ILeds.pfnQueryStatusLed = ahciR3Status_QueryStatusLed;5768 5769 /* Initialize port members. */5770 for (i = 0; i < AHCI_MAX_NR_PORTS_IMPL; i++)5771 {5772 PAHCIPort pAhciPort = &pThis->ahciPort[i];5773 pAhciPort->pDevInsR3 = pDevIns;5774 pAhciPort->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);5775 pAhciPort->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);5776 pAhciPort->iLUN = i;5777 pAhciPort->pAhciR3 = pThis;5778 pAhciPort->pAhciR0 = PDMINS_2_DATA_R0PTR(pDevIns);5779 pAhciPort->pAhciRC = PDMINS_2_DATA_RCPTR(pDevIns);5780 pAhciPort->Led.u32Magic = PDMLED_MAGIC;5781 pAhciPort->pDrvBase = NULL;5782 pAhciPort->pAsyncIOThread = NULL;5783 pAhciPort->hEvtProcess = NIL_SUPSEMEVENT;5784 pAhciPort->fHotpluggable = true;5785 }5786 5787 /*5788 * Init locks, using explicit locking where necessary.5789 */5790 rc = PDMDevHlpSetDeviceCritSect(pDevIns, PDMDevHlpCritSectGetNop(pDevIns));5791 AssertRCReturn(rc, rc);5792 5793 rc = PDMDevHlpCritSectInit(pDevIns, &pThis->lock, RT_SRC_POS, "AHCI#%u", iInstance);5794 if (RT_FAILURE(rc))5795 {5796 Log(("%s: Failed to create critical section.\n", __FUNCTION__));5797 return rc;5798 }5799 5866 5800 5867 /* … … 5885 5952 for (i = 0; i < pThis->cPortsImpl; i++) 5886 5953 { 5887 PAHCIP ort pAhciPort= &pThis->ahciPort[i];5888 5889 if (RTStrAPrintf(&pAhciPort->pszDesc, "Port%u", i) <= 0) 5890 AssertLogRelFailedReturn(VERR_NO_MEMORY);5954 PAHCIPORT pAhciPort = &pThis->ahciPort[i]; 5955 PAHCIPORTR3 pAhciPortR3 = &pThisCC->aPorts[i]; 5956 5957 RTStrPrintf(pAhciPortR3->szDesc, sizeof(pAhciPortR3->szDesc), "Port%u", i); 5891 5958 5892 5959 /* 5893 5960 * Init interfaces. 5894 5961 */ 5895 pAhciPort ->IBase.pfnQueryInterface = ahciR3PortQueryInterface;5896 pAhciPort ->IMediaExPort.pfnIoReqCompleteNotify = ahciR3IoReqCompleteNotify;5897 pAhciPort ->IMediaExPort.pfnIoReqCopyFromBuf = ahciR3IoReqCopyFromBuf;5898 pAhciPort ->IMediaExPort.pfnIoReqCopyToBuf = ahciR3IoReqCopyToBuf;5899 pAhciPort ->IMediaExPort.pfnIoReqQueryBuf = ahciR3IoReqQueryBuf;5900 pAhciPort ->IMediaExPort.pfnIoReqQueryDiscardRanges = ahciR3IoReqQueryDiscardRanges;5901 pAhciPort ->IMediaExPort.pfnIoReqStateChanged = ahciR3IoReqStateChanged;5902 pAhciPort ->IMediaExPort.pfnMediumEjected = ahciR3MediumEjected;5903 pAhciPort ->IPort.pfnQueryDeviceLocation = ahciR3PortQueryDeviceLocation;5904 pAhciPort ->IPort.pfnQueryScsiInqStrings = ahciR3PortQueryScsiInqStrings;5905 pAhciPort->fWrkThreadSleeping = true;5962 pAhciPortR3->IBase.pfnQueryInterface = ahciR3PortQueryInterface; 5963 pAhciPortR3->IMediaExPort.pfnIoReqCompleteNotify = ahciR3IoReqCompleteNotify; 5964 pAhciPortR3->IMediaExPort.pfnIoReqCopyFromBuf = ahciR3IoReqCopyFromBuf; 5965 pAhciPortR3->IMediaExPort.pfnIoReqCopyToBuf = ahciR3IoReqCopyToBuf; 5966 pAhciPortR3->IMediaExPort.pfnIoReqQueryBuf = ahciR3IoReqQueryBuf; 5967 pAhciPortR3->IMediaExPort.pfnIoReqQueryDiscardRanges = ahciR3IoReqQueryDiscardRanges; 5968 pAhciPortR3->IMediaExPort.pfnIoReqStateChanged = ahciR3IoReqStateChanged; 5969 pAhciPortR3->IMediaExPort.pfnMediumEjected = ahciR3MediumEjected; 5970 pAhciPortR3->IPort.pfnQueryDeviceLocation = ahciR3PortQueryDeviceLocation; 5971 pAhciPortR3->IPort.pfnQueryScsiInqStrings = ahciR3PortQueryScsiInqStrings; 5972 pAhciPort->fWrkThreadSleeping = true; 5906 5973 5907 5974 /* Query per port configuration options if available. */ 5908 PCFGMNODE pCfgPort = pHlp->pfnCFGMGetChild(pDevIns->pCfg, pAhciPort ->pszDesc);5975 PCFGMNODE pCfgPort = pHlp->pfnCFGMGetChild(pDevIns->pCfg, pAhciPortR3->szDesc); 5909 5976 if (pCfgPort) 5910 5977 { … … 5917 5984 * Attach the block driver 5918 5985 */ 5919 rc = PDMDevHlpDriverAttach(pDevIns, pAhciPort->iLUN, &pAhciPort ->IBase, &pAhciPort->pDrvBase, pAhciPort->pszDesc);5986 rc = PDMDevHlpDriverAttach(pDevIns, pAhciPort->iLUN, &pAhciPortR3->IBase, &pAhciPortR3->pDrvBase, pAhciPortR3->szDesc); 5920 5987 if (RT_SUCCESS(rc)) 5921 5988 { 5922 rc = ahciR3ConfigureLUN(pDevIns, pAhciPort );5989 rc = ahciR3ConfigureLUN(pDevIns, pAhciPort, pAhciPortR3); 5923 5990 if (RT_FAILURE(rc)) 5924 5991 { 5925 Log(("%s: Failed to configure the %s.\n", __FUNCTION__, pAhciPort ->pszDesc));5992 Log(("%s: Failed to configure the %s.\n", __FUNCTION__, pAhciPortR3->szDesc)); 5926 5993 return rc; 5927 5994 } … … 5934 6001 * Init vendor product data. 5935 6002 */ 5936 rc = ahciR3VpdInit(pDevIns, pAhciPort, pAhciPort ->pszDesc);6003 rc = ahciR3VpdInit(pDevIns, pAhciPort, pAhciPortR3, pAhciPortR3->szDesc); 5937 6004 if (RT_FAILURE(rc)) 5938 6005 return rc; … … 5943 6010 N_("AHCI: Failed to create SUP event semaphore")); 5944 6011 5945 rc = PDMDevHlpThreadCreate(pDevIns, &pAhciPort ->pAsyncIOThread, pAhciPort, ahciAsyncIOLoop,5946 ahciAsyncIOLoopWakeUp, 0, RTTHREADTYPE_IO, pAhciPort ->pszDesc);6012 rc = PDMDevHlpThreadCreate(pDevIns, &pAhciPortR3->pAsyncIOThread, pAhciPortR3, ahciAsyncIOLoop, 6013 ahciAsyncIOLoopWakeUp, 0, RTTHREADTYPE_IO, pAhciPortR3->szDesc); 5947 6014 if (RT_FAILURE(rc)) 5948 6015 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, 5949 N_("AHCI: Failed to create worker thread %s"), pAhciPort ->pszDesc);6016 N_("AHCI: Failed to create worker thread %s"), pAhciPortR3->szDesc); 5950 6017 } 5951 6018 else if (rc == VERR_PDM_NO_ATTACHED_DRIVER) 5952 6019 { 5953 pAhciPort->pDrvBase = NULL; 6020 pAhciPortR3->pDrvBase = NULL; 6021 pAhciPort->fPresent = false; 5954 6022 rc = VINF_SUCCESS; 5955 LogRel(("AHCI: %s: No driver attached\n", pAhciPort ->pszDesc));6023 LogRel(("AHCI: %s: No driver attached\n", pAhciPortR3->szDesc)); 5956 6024 } 5957 6025 else 5958 6026 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, 5959 N_("AHCI: Failed to attach drive to %s"), pAhciPort ->pszDesc);6027 N_("AHCI: Failed to attach drive to %s"), pAhciPortR3->szDesc); 5960 6028 } 5961 6029 … … 5963 6031 * Attach status driver (optional). 5964 6032 */ 5965 rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pThis ->IBase, &pBase, "Status Port");6033 rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pThisCC->IBase, &pBase, "Status Port"); 5966 6034 if (RT_SUCCESS(rc)) 5967 6035 { 5968 pThis ->pLedsConnector = PDMIBASE_QUERY_INTERFACE(pBase, PDMILEDCONNECTORS);5969 pThis ->pMediaNotify= PDMIBASE_QUERY_INTERFACE(pBase, PDMIMEDIANOTIFY);6036 pThisCC->pLedsConnector = PDMIBASE_QUERY_INTERFACE(pBase, PDMILEDCONNECTORS); 6037 pThisCC->pMediaNotify = PDMIBASE_QUERY_INTERFACE(pBase, PDMIMEDIANOTIFY); 5970 6038 } 5971 6039 else … … 6034 6102 /* .uReserved0 = */ 0, 6035 6103 /* .szName = */ "ahci", 6036 /* .fFlags = */ PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RZ | 6037 PDM_DEVREG_FLAGS_FIRST_SUSPEND_NOTIFICATION | PDM_DEVREG_FLAGS_FIRST_POWEROFF_NOTIFICATION |6038 PDM_DEVREG_FLAGS_FIRST_RESET_NOTIFICATION,6104 /* .fFlags = */ PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RZ | PDM_DEVREG_FLAGS_NEW_STYLE 6105 | PDM_DEVREG_FLAGS_FIRST_SUSPEND_NOTIFICATION | PDM_DEVREG_FLAGS_FIRST_POWEROFF_NOTIFICATION 6106 | PDM_DEVREG_FLAGS_FIRST_RESET_NOTIFICATION, 6039 6107 /* .fClass = */ PDM_DEVREG_CLASS_STORAGE, 6040 6108 /* .cMaxInstances = */ ~0U, 6041 6109 /* .uSharedVersion = */ 42, 6042 6110 /* .cbInstanceShared = */ sizeof(AHCI), 6043 /* .cbInstanceCC = */ 0,6044 /* .cbInstanceRC = */ 0,6111 /* .cbInstanceCC = */ sizeof(AHCICC), 6112 /* .cbInstanceRC = */ sizeof(AHCIRC), 6045 6113 /* .cMaxPciDevices = */ 1, 6046 6114 /* .cMaxMsixVectors = */ 0, … … 6051 6119 /* .pfnConstruct = */ ahciR3Construct, 6052 6120 /* .pfnDestruct = */ ahciR3Destruct, 6053 /* .pfnRelocate = */ ahciR3Relocate,6121 /* .pfnRelocate = */ NULL, 6054 6122 /* .pfnMemSetup = */ NULL, 6055 6123 /* .pfnPowerOn = */ NULL,
Note:
See TracChangeset
for help on using the changeset viewer.