- Timestamp:
- Jun 28, 2011 11:18:27 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevAHCI.cpp
r37636 r37660 7876 7876 for (uint32_t i = 0; i < RT_ELEMENTS(pAhci->aCts); i++) 7877 7877 ataControllerResume(&pAhci->aCts[i]); 7878 return; 7879 } 7878 } 7879 7880 /** 7881 * Initializes the VPD data of a attached device. 7882 * 7883 * @returns VBox status code. 7884 * @param pDevIns The device instance. 7885 * @param pAhciPort The attached device. 7886 * @param szName Name of the port to get the CFGM node. 7887 */ 7888 static int ahciR3VpdInit(PPDMDEVINS pDevIns, PAHCIPort pAhciPort, const char *pszName) 7889 { 7890 int rc = VINF_SUCCESS; 7891 PAHCI pAhci = PDMINS_2_DATA(pDevIns, PAHCI); 7892 7893 /* Generate a default serial number. */ 7894 char szSerial[AHCI_SERIAL_NUMBER_LENGTH+1]; 7895 RTUUID Uuid; 7896 7897 if (pAhciPort->pDrvBlock) 7898 rc = pAhciPort->pDrvBlock->pfnGetUuid(pAhciPort->pDrvBlock, &Uuid); 7899 else 7900 RTUuidClear(&Uuid); 7901 7902 if (RT_FAILURE(rc) || RTUuidIsNull(&Uuid)) 7903 { 7904 /* Generate a predictable serial for drives which don't have a UUID. */ 7905 RTStrPrintf(szSerial, sizeof(szSerial), "VB%x-1a2b3c4d", 7906 pAhciPort->iLUN); 7907 } 7908 else 7909 RTStrPrintf(szSerial, sizeof(szSerial), "VB%08x-%08x", Uuid.au32[0], Uuid.au32[3]); 7910 7911 /* Get user config if present using defaults otherwise. */ 7912 PCFGMNODE pCfgNode = CFGMR3GetChild(pDevIns->pCfg, pszName); 7913 rc = CFGMR3QueryStringDef(pCfgNode, "SerialNumber", pAhciPort->szSerialNumber, sizeof(pAhciPort->szSerialNumber), 7914 szSerial); 7915 if (RT_FAILURE(rc)) 7916 { 7917 if (rc == VERR_CFGM_NOT_ENOUGH_SPACE) 7918 return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER, 7919 N_("AHCI configuration error: \"SerialNumber\" is longer than 20 bytes")); 7920 return PDMDEV_SET_ERROR(pDevIns, rc, 7921 N_("AHCI configuration error: failed to read \"SerialNumber\" as string")); 7922 } 7923 7924 rc = CFGMR3QueryStringDef(pCfgNode, "FirmwareRevision", pAhciPort->szFirmwareRevision, sizeof(pAhciPort->szFirmwareRevision), 7925 "1.0"); 7926 if (RT_FAILURE(rc)) 7927 { 7928 if (rc == VERR_CFGM_NOT_ENOUGH_SPACE) 7929 return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER, 7930 N_("AHCI configuration error: \"FirmwareRevision\" is longer than 8 bytes")); 7931 return PDMDEV_SET_ERROR(pDevIns, rc, 7932 N_("AHCI configuration error: failed to read \"FirmwareRevision\" as string")); 7933 } 7934 7935 rc = CFGMR3QueryStringDef(pCfgNode, "ModelNumber", pAhciPort->szModelNumber, sizeof(pAhciPort->szModelNumber), 7936 pAhciPort->fATAPI ? "VBOX CD-ROM" : "VBOX HARDDISK"); 7937 if (RT_FAILURE(rc)) 7938 { 7939 if (rc == VERR_CFGM_NOT_ENOUGH_SPACE) 7940 return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER, 7941 N_("AHCI configuration error: \"ModelNumber\" is longer than 40 bytes")); 7942 return PDMDEV_SET_ERROR(pDevIns, rc, 7943 N_("AHCI configuration error: failed to read \"ModelNumber\" as string")); 7944 } 7945 7946 rc = CFGMR3QueryBoolDef(pCfgNode, "NonRotationalMedium", &pAhciPort->fNonRotational, false); 7947 if (RT_FAILURE(rc)) 7948 return PDMDEV_SET_ERROR(pDevIns, rc, 7949 N_("AHCI configuration error: failed to read \"NonRotationalMedium\" as boolean")); 7950 7951 /* There are three other identification strings for CD drives used for INQUIRY */ 7952 if (pAhciPort->fATAPI) 7953 { 7954 rc = CFGMR3QueryStringDef(pCfgNode, "ATAPIVendorId", pAhciPort->szInquiryVendorId, sizeof(pAhciPort->szInquiryVendorId), 7955 "VBOX"); 7956 if (RT_FAILURE(rc)) 7957 { 7958 if (rc == VERR_CFGM_NOT_ENOUGH_SPACE) 7959 return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER, 7960 N_("AHCI configuration error: \"ATAPIVendorId\" is longer than 16 bytes")); 7961 return PDMDEV_SET_ERROR(pDevIns, rc, 7962 N_("AHCI configuration error: failed to read \"ATAPIVendorId\" as string")); 7963 } 7964 7965 rc = CFGMR3QueryStringDef(pCfgNode, "ATAPIProductId", pAhciPort->szInquiryProductId, sizeof(pAhciPort->szInquiryProductId), 7966 "CD-ROM"); 7967 if (RT_FAILURE(rc)) 7968 { 7969 if (rc == VERR_CFGM_NOT_ENOUGH_SPACE) 7970 return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER, 7971 N_("AHCI configuration error: \"ATAPIProductId\" is longer than 16 bytes")); 7972 return PDMDEV_SET_ERROR(pDevIns, rc, 7973 N_("AHCI configuration error: failed to read \"ATAPIProductId\" as string")); 7974 } 7975 7976 rc = CFGMR3QueryStringDef(pCfgNode, "ATAPIRevision", pAhciPort->szInquiryRevision, sizeof(pAhciPort->szInquiryRevision), 7977 "1.0"); 7978 if (RT_FAILURE(rc)) 7979 { 7980 if (rc == VERR_CFGM_NOT_ENOUGH_SPACE) 7981 return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER, 7982 N_("AHCI configuration error: \"ATAPIRevision\" is longer than 4 bytes")); 7983 return PDMDEV_SET_ERROR(pDevIns, rc, 7984 N_("AHCI configuration error: failed to read \"ATAPIRevision\" as string")); 7985 } 7986 } 7987 7988 return rc; 7989 } 7990 7880 7991 7881 7992 /** … … 8023 8134 if (RT_SUCCESS(rc)) 8024 8135 { 8136 char szName[24]; 8137 RTStrPrintf(szName, sizeof(szName), "Port%d", iLUN); 8138 8025 8139 if ( pAhciPort->pDrvBlockAsync 8026 8140 && !pAhciPort->fATAPI) … … 8030 8144 else 8031 8145 { 8032 char szName[24];8033 RTStrPrintf(szName, sizeof(szName), "Port%d", iLUN);8034 8035 8146 pAhciPort->fAsyncInterface = false; 8036 8147 … … 8055 8166 if (RT_SUCCESS(rc) && pAhciPort->fATAPI) 8056 8167 ahciMediumInserted(pAhciPort); 8168 8169 /* 8170 * Init vendor product data. 8171 */ 8172 if (RT_SUCCESS(rc)) 8173 rc = ahciR3VpdInit(pDevIns, pAhciPort, szName); 8057 8174 8058 8175 /* Inform the guest about the added device in case of hotplugging. */ … … 8440 8557 * Init vendor product data. 8441 8558 */ 8442 /* Generate a default serial number. */ 8443 char szSerial[AHCI_SERIAL_NUMBER_LENGTH+1]; 8444 RTUUID Uuid; 8445 if (pAhciPort->pDrvBlock) 8446 rc = pAhciPort->pDrvBlock->pfnGetUuid(pAhciPort->pDrvBlock, &Uuid); 8447 else 8448 RTUuidClear(&Uuid); 8449 8450 if (RT_FAILURE(rc) || RTUuidIsNull(&Uuid)) 8451 { 8452 /* Generate a predictable serial for drives which don't have a UUID. */ 8453 RTStrPrintf(szSerial, sizeof(szSerial), "VB%x-1a2b3c4d", 8454 pAhciPort->iLUN); 8455 } 8456 else 8457 RTStrPrintf(szSerial, sizeof(szSerial), "VB%08x-%08x", Uuid.au32[0], Uuid.au32[3]); 8458 8459 /* Get user config if present using defaults otherwise. */ 8460 PCFGMNODE pCfgNode = CFGMR3GetChild(pCfg, szName); 8461 rc = CFGMR3QueryStringDef(pCfgNode, "SerialNumber", pAhciPort->szSerialNumber, sizeof(pAhciPort->szSerialNumber), 8462 szSerial); 8559 rc = ahciR3VpdInit(pDevIns, pAhciPort, szName); 8463 8560 if (RT_FAILURE(rc)) 8464 { 8465 if (rc == VERR_CFGM_NOT_ENOUGH_SPACE) 8466 return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER, 8467 N_("AHCI configuration error: \"SerialNumber\" is longer than 20 bytes")); 8468 return PDMDEV_SET_ERROR(pDevIns, rc, 8469 N_("AHCI configuration error: failed to read \"SerialNumber\" as string")); 8470 } 8471 8472 rc = CFGMR3QueryStringDef(pCfgNode, "FirmwareRevision", pAhciPort->szFirmwareRevision, sizeof(pAhciPort->szFirmwareRevision), 8473 "1.0"); 8474 if (RT_FAILURE(rc)) 8475 { 8476 if (rc == VERR_CFGM_NOT_ENOUGH_SPACE) 8477 return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER, 8478 N_("AHCI configuration error: \"FirmwareRevision\" is longer than 8 bytes")); 8479 return PDMDEV_SET_ERROR(pDevIns, rc, 8480 N_("AHCI configuration error: failed to read \"FirmwareRevision\" as string")); 8481 } 8482 8483 rc = CFGMR3QueryStringDef(pCfgNode, "ModelNumber", pAhciPort->szModelNumber, sizeof(pAhciPort->szModelNumber), 8484 pAhciPort->fATAPI ? "VBOX CD-ROM" : "VBOX HARDDISK"); 8485 if (RT_FAILURE(rc)) 8486 { 8487 if (rc == VERR_CFGM_NOT_ENOUGH_SPACE) 8488 return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER, 8489 N_("AHCI configuration error: \"ModelNumber\" is longer than 40 bytes")); 8490 return PDMDEV_SET_ERROR(pDevIns, rc, 8491 N_("AHCI configuration error: failed to read \"ModelNumber\" as string")); 8492 } 8493 8494 rc = CFGMR3QueryBoolDef(pCfgNode, "NonRotationalMedium", &pAhciPort->fNonRotational, false); 8495 if (RT_FAILURE(rc)) 8496 return PDMDEV_SET_ERROR(pDevIns, rc, 8497 N_("PIIX3 configuration error: failed to read \"NonRotationalMedium\" as boolean")); 8498 8499 /* There are three other identification strings for CD drives used for INQUIRY */ 8500 if (pAhciPort->fATAPI) 8501 { 8502 rc = CFGMR3QueryStringDef(pCfgNode, "ATAPIVendorId", pAhciPort->szInquiryVendorId, sizeof(pAhciPort->szInquiryVendorId), 8503 "VBOX"); 8504 if (RT_FAILURE(rc)) 8505 { 8506 if (rc == VERR_CFGM_NOT_ENOUGH_SPACE) 8507 return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER, 8508 N_("PIIX3 configuration error: \"ATAPIVendorId\" is longer than 16 bytes")); 8509 return PDMDEV_SET_ERROR(pDevIns, rc, 8510 N_("PIIX3 configuration error: failed to read \"ATAPIVendorId\" as string")); 8511 } 8512 8513 rc = CFGMR3QueryStringDef(pCfgNode, "ATAPIProductId", pAhciPort->szInquiryProductId, sizeof(pAhciPort->szInquiryProductId), 8514 "CD-ROM"); 8515 if (RT_FAILURE(rc)) 8516 { 8517 if (rc == VERR_CFGM_NOT_ENOUGH_SPACE) 8518 return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER, 8519 N_("PIIX3 configuration error: \"ATAPIProductId\" is longer than 16 bytes")); 8520 return PDMDEV_SET_ERROR(pDevIns, rc, 8521 N_("PIIX3 configuration error: failed to read \"ATAPIProductId\" as string")); 8522 } 8523 8524 rc = CFGMR3QueryStringDef(pCfgNode, "ATAPIRevision", pAhciPort->szInquiryRevision, sizeof(pAhciPort->szInquiryRevision), 8525 "1.0"); 8526 if (RT_FAILURE(rc)) 8527 { 8528 if (rc == VERR_CFGM_NOT_ENOUGH_SPACE) 8529 return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER, 8530 N_("PIIX3 configuration error: \"ATAPIRevision\" is longer than 4 bytes")); 8531 return PDMDEV_SET_ERROR(pDevIns, rc, 8532 N_("PIIX3 configuration error: failed to read \"ATAPIRevision\" as string")); 8533 } 8534 } 8561 return rc; 8535 8562 8536 8563 /*
Note:
See TracChangeset
for help on using the changeset viewer.