Changeset 64176 in vbox
- Timestamp:
- Oct 7, 2016 10:06:26 AM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 111159
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevAHCI.cpp
r64141 r64176 60 60 #include "PIIX3ATABmDma.h" 61 61 #include "ide.h" 62 #include "ATAPIPassthrough.h"63 62 #include "VBoxDD.h" 64 63 … … 80 79 #define AHCI_NR_COMMAND_SLOTS 32 81 80 82 #define AHCI_MAX_ALLOC_TOO_MUCH 2083 84 81 /** The current saved state version. */ 85 #define AHCI_SAVED_STATE_VERSION 8 82 #define AHCI_SAVED_STATE_VERSION 9 83 /** The saved state version before the ATAPI emulation was removed and the generic SCSI driver was used. */ 84 #define AHCI_SAVED_STATE_VERSION_PRE_ATAPI_REMOVE 8 86 85 /** The saved state version before changing the port reset logic in an incompatible way. */ 87 86 #define AHCI_SAVED_STATE_VERSION_PRE_PORT_RESET_CHANGES 7 … … 130 129 #define AHCI_FIRMWARE_REVISION_LENGTH 8 131 130 #define AHCI_MODEL_NUMBER_LENGTH 40 132 #define AHCI_ATAPI_INQUIRY_VENDOR_ID_LENGTH 8133 #define AHCI_ATAPI_INQUIRY_PRODUCT_ID_LENGTH 16134 #define AHCI_ATAPI_INQUIRY_REVISION_LENGTH 4135 136 /* MediaEventStatus */137 #define ATA_EVENT_STATUS_UNCHANGED 0 /**< medium event status not changed */138 #define ATA_EVENT_STATUS_MEDIA_NEW 1 /**< new medium inserted */139 #define ATA_EVENT_STATUS_MEDIA_REMOVED 2 /**< medium removed */140 #define ATA_EVENT_STATUS_MEDIA_CHANGED 3 /**< medium was removed + new medium was inserted */141 #define ATA_EVENT_STATUS_MEDIA_EJECT_REQUESTED 4 /**< medium eject requested (eject button pressed) */142 143 /* Media track type */144 #define ATA_MEDIA_TYPE_UNKNOWN 0 /**< unknown CD type */145 131 146 132 /** ATAPI sense info size. */ … … 314 300 * @implements PDMIMEDIAPORT 315 301 * @implements PDMIMEDIAEXPORT 316 * @implements PDMIMOUNTNOTIFY317 302 */ 318 303 typedef struct AHCIPort … … 380 365 /** Attached device is a CD/DVD drive. */ 381 366 bool fATAPI; 382 /** Passthrough SCSI commands. */383 bool fATAPIPassthrough;384 367 /** Flag whether this port is in a reset state. */ 385 368 volatile bool fPortReset; … … 407 390 /** ATAPI sense data. */ 408 391 uint8_t abATAPISense[ATAPI_SENSE_SIZE]; 409 /** HACK: Countdown till we report a newly unmounted drive as mounted. */410 uint8_t cNotifiedMediaChange;411 392 /** Exponent of logical sectors in a physical sector, number of logical sectors is 2^exp. */ 412 393 uint8_t cLogSectorsPerPhysicalExp; 413 /** The same for GET_EVENT_STATUS for mechanism */414 volatile uint32_t MediaEventStatus;415 /** Media type if known. */416 volatile uint32_t MediaTrackType;417 394 /** The LUN. */ 418 395 RTUINT iLUN; … … 443 420 /** Pointer to the attached driver's extended interface. */ 444 421 R3PTRTYPE(PPDMIMEDIAEX) pDrvMediaEx; 445 /** Pointer to the attached driver's mount interface. */446 R3PTRTYPE(PPDMIMOUNT) pDrvMount;447 422 /** The base interface. */ 448 423 PDMIBASE IBase; … … 451 426 /** The extended media port interface. */ 452 427 PDMIMEDIAEXPORT IMediaExPort; 453 /** The mount notify interface. */454 PDMIMOUNTNOTIFY IMountNotify;455 428 /** Physical geometry of this image. */ 456 429 PDMMEDIAGEOMETRY PCHSGeometry; … … 464 437 /** First task throwing an error. */ 465 438 R3PTRTYPE(volatile PAHCIREQ) pTaskErr; 466 /** The current tracklist of the loaded medium if passthrough is used. */467 R3PTRTYPE(PTRACKLIST) pTrackList;468 439 469 440 /** The event semaphore the processing thread waits on. */ … … 491 462 /** The model number to use for IDENTIFY DEVICE commands. */ 492 463 char szModelNumber[AHCI_MODEL_NUMBER_LENGTH+1]; /** < one extra byte for termination */ 493 /** The vendor identification string for SCSI INQUIRY commands. */494 char szInquiryVendorId[AHCI_ATAPI_INQUIRY_VENDOR_ID_LENGTH+1];495 /** The product identification string for SCSI INQUIRY commands. */496 char szInquiryProductId[AHCI_ATAPI_INQUIRY_PRODUCT_ID_LENGTH+1];497 /** The revision string for SCSI INQUIRY commands. */498 char szInquiryRevision[AHCI_ATAPI_INQUIRY_REVISION_LENGTH+1];499 464 /** Error counter */ 500 465 uint32_t cErrors; … … 904 869 905 870 #define PCIDEV_2_PAHCI(pPciDev) ( (PAHCI)(pPciDev) ) 906 #define PDMIMOUNT_2_PAHCIPORT(pInterface) ( (PAHCIPort)((uintptr_t)(pInterface) - RT_OFFSETOF(AHCIPort, IMount)) )907 #define PDMIMOUNTNOTIFY_2_PAHCIPORT(pInterface) ( (PAHCIPort)((uintptr_t)(pInterface) - RT_OFFSETOF(AHCIPort, IMountNotify)) )908 871 #define PDMIBASE_2_PAHCIPORT(pInterface) ( (PAHCIPort)((uintptr_t)(pInterface) - RT_OFFSETOF(AHCIPort, IBase)) ) 909 872 #define PDMIMEDIAPORT_2_PAHCIPORT(pInterface) ( (PAHCIPort)((uintptr_t)(pInterface) - RT_OFFSETOF(AHCIPort, IPort)) ) … … 2034 1997 pAhciPort->u32CurrentCommandSlot = 0; 2035 1998 2036 ASMAtomicWriteU32(&pAhciPort->MediaEventStatus, ATA_EVENT_STATUS_UNCHANGED);2037 ASMAtomicWriteU32(&pAhciPort->MediaTrackType, ATA_MEDIA_TYPE_UNKNOWN);2038 2039 1999 if (pAhciPort->pDrvBase) 2040 2000 { … … 2655 2615 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAPORT, &pAhciPort->IPort); 2656 2616 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAEXPORT, &pAhciPort->IMediaExPort); 2657 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUNTNOTIFY, &pAhciPort->IMountNotify);2658 2617 return NULL; 2659 2618 } … … 3093 3052 3094 3053 /* Send a status good D2H FIS. */ 3095 ASMAtomicWriteU32(&pAhciPort->MediaEventStatus, ATA_EVENT_STATUS_UNCHANGED);3096 3054 pAhciPort->fResetDevice = false; 3097 3055 if (pAhciPort->regCMD & AHCI_PORT_CMD_FRE) … … 3901 3859 ahciReqSetStatus(pAhciReq, 0, ATA_STAT_READY | ATA_STAT_SEEK); 3902 3860 pAhciReq->cmdFis[AHCI_CMDFIS_SECTN] = (pAhciReq->cmdFis[AHCI_CMDFIS_SECTN] & ~7) 3903 /*| ((pAhciReq->enmType != AHCITXDIR_WRITE) ? ATAPI_INT_REASON_IO : 0) @todo */3861 | ((pAhciReq->fFlags & AHCI_REQ_XFER_2_HOST) ? ATAPI_INT_REASON_IO : 0) 3904 3862 | (!pAhciReq->cbTransfer ? ATAPI_INT_REASON_CD : 0); 3905 3863 } … … 3910 3868 ATAPI_INT_REASON_IO | ATAPI_INT_REASON_CD; 3911 3869 pAhciReq->cbTransfer = 0; 3870 LogFlowFunc(("SCSI request completed with %u status\n", pAhciReq->u8ScsiSts)); 3912 3871 } 3913 3872 } … … 4242 4201 pAhciReq->cbTransfer = cbData; 4243 4202 pAhciReq->cmdFis[AHCI_CMDFIS_SECTN] = (pAhciReq->cmdFis[AHCI_CMDFIS_SECTN] & ~7) 4244 /*| ((pAhciReq->enmTxDir != AHCITXDIR_WRITE) ? ATAPI_INT_REASON_IO : 0) @todo */4203 | ((pAhciReq->fFlags & AHCI_REQ_XFER_2_HOST) ? ATAPI_INT_REASON_IO : 0) 4245 4204 | (!pAhciReq->cbTransfer ? ATAPI_INT_REASON_CD : 0); 4246 4205 … … 5042 5001 SSMR3PutBool(pSSM, pThis->ahciPort[i].fATAPI); 5043 5002 SSMR3PutMem(pSSM, &pThis->ahciPort[i].abATAPISense[0], sizeof(pThis->ahciPort[i].abATAPISense)); 5044 SSMR3PutU8(pSSM, pThis->ahciPort[i].cNotifiedMediaChange);5045 SSMR3PutU32(pSSM, pThis->ahciPort[i].MediaEventStatus);5046 5003 } 5047 5004 … … 5287 5244 SSMR3GetBool(pSSM, &pThis->ahciPort[i].fATAPI); 5288 5245 SSMR3GetMem(pSSM, pThis->ahciPort[i].abATAPISense, sizeof(pThis->ahciPort[i].abATAPISense)); 5289 SSMR3GetU8(pSSM, &pThis->ahciPort[i].cNotifiedMediaChange); 5290 SSMR3GetU32(pSSM, (uint32_t*)&pThis->ahciPort[i].MediaEventStatus); 5246 if (uVersion < AHCI_SAVED_STATE_VERSION_PRE_ATAPI_REMOVE) 5247 { 5248 SSMR3Skip(pSSM, 1); /* cNotifiedMediaChange. */ 5249 SSMR3Skip(pSSM, 4); /* MediaEventStatus */ 5250 } 5291 5251 } 5292 5252 else if (pThis->ahciPort[i].fATAPI) … … 5371 5331 VERR_PDM_MISSING_INTERFACE); 5372 5332 5373 pAhciPort->pDrvMount = PDMIBASE_QUERY_INTERFACE(pAhciPort->pDrvBase, PDMIMOUNT);5374 5375 5333 /* 5376 5334 * Validate type. … … 5380 5338 ("AHCI configuration error: LUN#%d isn't a disk or cd/dvd. enmType=%u\n", pAhciPort->iLUN, enmType), 5381 5339 VERR_PDM_UNSUPPORTED_BLOCK_TYPE); 5382 AssertMsgReturn(enmType == PDMMEDIATYPE_HARD_DISK || pAhciPort->pDrvMount,5383 ("AHCI configuration error: LUN#%d is CD/DVD-ROM without a mountable interface\n", pAhciPort->iLUN),5384 VERR_INTERNAL_ERROR);5385 5340 5386 5341 int rc = pAhciPort->pDrvMediaEx->pfnIoReqAllocSizeSet(pAhciPort->pDrvMediaEx, sizeof(AHCIREQ)); … … 5598 5553 return PDMDEV_SET_ERROR(pDevIns, rc, 5599 5554 N_("AHCI configuration error: \"LogicalSectorsPerPhysical\" must be between 0 and 15")); 5600 5601 /* There are three other identification strings for CD drives used for INQUIRY */5602 if (pAhciPort->fATAPI)5603 {5604 rc = CFGMR3QueryStringDef(pCfgNode, "ATAPIVendorId", pAhciPort->szInquiryVendorId, sizeof(pAhciPort->szInquiryVendorId),5605 "VBOX");5606 if (RT_FAILURE(rc))5607 {5608 if (rc == VERR_CFGM_NOT_ENOUGH_SPACE)5609 return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER,5610 N_("AHCI configuration error: \"ATAPIVendorId\" is longer than 16 bytes"));5611 return PDMDEV_SET_ERROR(pDevIns, rc,5612 N_("AHCI configuration error: failed to read \"ATAPIVendorId\" as string"));5613 }5614 5615 rc = CFGMR3QueryStringDef(pCfgNode, "ATAPIProductId", pAhciPort->szInquiryProductId, sizeof(pAhciPort->szInquiryProductId),5616 "CD-ROM");5617 if (RT_FAILURE(rc))5618 {5619 if (rc == VERR_CFGM_NOT_ENOUGH_SPACE)5620 return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER,5621 N_("AHCI configuration error: \"ATAPIProductId\" is longer than 16 bytes"));5622 return PDMDEV_SET_ERROR(pDevIns, rc,5623 N_("AHCI configuration error: failed to read \"ATAPIProductId\" as string"));5624 }5625 5626 rc = CFGMR3QueryStringDef(pCfgNode, "ATAPIRevision", pAhciPort->szInquiryRevision, sizeof(pAhciPort->szInquiryRevision),5627 "1.0");5628 if (RT_FAILURE(rc))5629 {5630 if (rc == VERR_CFGM_NOT_ENOUGH_SPACE)5631 return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER,5632 N_("AHCI configuration error: \"ATAPIRevision\" is longer than 4 bytes"));5633 return PDMDEV_SET_ERROR(pDevIns, rc,5634 N_("AHCI configuration error: failed to read \"ATAPIRevision\" as string"));5635 }5636 }5637 5555 5638 5556 return rc; -
trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp
r64094 r64176 1385 1385 GEN_CHECK_OFF(AHCIPort, fFirstD2HFisSend); 1386 1386 GEN_CHECK_OFF(AHCIPort, fATAPI); 1387 GEN_CHECK_OFF(AHCIPort, fATAPIPassthrough);1388 1387 GEN_CHECK_OFF(AHCIPort, fPortReset); 1389 1388 GEN_CHECK_OFF(AHCIPort, fTrimEnabled); … … 1397 1396 GEN_CHECK_OFF(AHCIPort, uATATransferMode); 1398 1397 GEN_CHECK_OFF(AHCIPort, abATAPISense); 1399 GEN_CHECK_OFF(AHCIPort, cNotifiedMediaChange);1400 1398 GEN_CHECK_OFF(AHCIPort, cLogSectorsPerPhysicalExp); 1401 GEN_CHECK_OFF(AHCIPort, MediaEventStatus);1402 GEN_CHECK_OFF(AHCIPort, MediaTrackType);1403 1399 GEN_CHECK_OFF(AHCIPort, iLUN); 1404 1400 GEN_CHECK_OFF(AHCIPort, u32TasksFinished); … … 1410 1406 GEN_CHECK_OFF(AHCIPort, pDrvMedia); 1411 1407 GEN_CHECK_OFF(AHCIPort, pDrvMediaEx); 1412 GEN_CHECK_OFF(AHCIPort, pDrvMount);1413 1408 GEN_CHECK_OFF(AHCIPort, IBase); 1414 1409 GEN_CHECK_OFF(AHCIPort, IPort); 1415 1410 GEN_CHECK_OFF(AHCIPort, IMediaExPort); 1416 GEN_CHECK_OFF(AHCIPort, IMountNotify);1417 1411 GEN_CHECK_OFF(AHCIPort, PCHSGeometry); 1418 1412 GEN_CHECK_OFF(AHCIPort, Led); … … 1420 1414 1421 1415 GEN_CHECK_OFF(AHCIPort, pTaskErr); 1422 GEN_CHECK_OFF(AHCIPort, pTrackList);1423 1416 GEN_CHECK_OFF(AHCIPort, hEvtProcess); 1424 1417 GEN_CHECK_OFF(AHCIPort, StatDMA); … … 1436 1429 GEN_CHECK_OFF(AHCIPort, szModelNumber); 1437 1430 GEN_CHECK_OFF(AHCIPort, szModelNumber[AHCI_MODEL_NUMBER_LENGTH]); /* One additional byte for the termination.*/ 1438 GEN_CHECK_OFF(AHCIPort, szInquiryVendorId[AHCI_ATAPI_INQUIRY_VENDOR_ID_LENGTH]);1439 GEN_CHECK_OFF(AHCIPort, szInquiryProductId);1440 GEN_CHECK_OFF(AHCIPort, szInquiryProductId[AHCI_ATAPI_INQUIRY_PRODUCT_ID_LENGTH]);1441 GEN_CHECK_OFF(AHCIPort, szInquiryRevision);1442 GEN_CHECK_OFF(AHCIPort, szInquiryRevision[AHCI_ATAPI_INQUIRY_REVISION_LENGTH]);1443 1431 GEN_CHECK_OFF(AHCIPort, cErrors); 1444 1432 GEN_CHECK_OFF(AHCIPort, fRedo);
Note:
See TracChangeset
for help on using the changeset viewer.