Changeset 15846 in vbox for trunk/src/VBox
- Timestamp:
- Jan 7, 2009 10:00:53 PM (16 years ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevATA.cpp
r15845 r15846 97 97 #define ATA_EVENT_STATUS_MEDIA_CHANGED 3 /**< medium was removed + new medium was inserted */ 98 98 99 /** 100 * Length of the configurable VPD data (without termination) 101 */ 102 #define ATA_SERIAL_NUMBER_LENGTH 20 103 #define ATA_FIRMWARE_REVISION_LENGTH 8 104 #define ATA_MODEL_NUMBER_LENGTH 40 99 105 100 106 /******************************************************************************* … … 276 282 277 283 /** The serial numnber to use for IDENTIFY DEVICE commands. */ 278 int8_t abSerialNumber[20];284 char achSerialNumber[ATA_SERIAL_NUMBER_LENGTH+1]; 279 285 /** The firmware revision to use for IDENTIFY DEVICE commands. */ 280 int8_t abFirmwareRevision[8];286 char achFirmwareRevision[ATA_FIRMWARE_REVISION_LENGTH+1]; 281 287 /** The model number to use for IDENTIFY DEVICE commands. */ 282 int8_t abModelNumber[40];288 char achModelNumber[ATA_MODEL_NUMBER_LENGTH+1]; 283 289 284 290 #if HC_ARCH_BITS == 64 285 uint32_t Alignment1;291 uint32_t Alignment3[2]; 286 292 #endif 287 293 } ATADevState; … … 1107 1113 p[5] = RT_H2LE_U16(512); 1108 1114 p[6] = RT_H2LE_U16(s->PCHSGeometry.cSectors); 1109 ataPadString((uint8_t *)(p + 10), (const char *)s->abSerialNumber, 20); /* serial number */1115 ataPadString((uint8_t *)(p + 10), s->achSerialNumber, ATA_SERIAL_NUMBER_LENGTH); /* serial number */ 1110 1116 p[20] = RT_H2LE_U16(3); /* XXX: retired, cache type */ 1111 1117 p[21] = RT_H2LE_U16(512); /* XXX: retired, cache size in sectors */ 1112 1118 p[22] = RT_H2LE_U16(0); /* ECC bytes per sector */ 1113 ataPadString((uint8_t *)(p + 23), (const char *)s->abFirmwareRevision, 8); /* firmware version */1114 ataPadString((uint8_t *)(p + 27), (const char *)s->abModelNumber, 40); /* model */1119 ataPadString((uint8_t *)(p + 23), s->achFirmwareRevision, ATA_FIRMWARE_REVISION_LENGTH); /* firmware version */ 1120 ataPadString((uint8_t *)(p + 27), s->achModelNumber, ATA_MODEL_NUMBER_LENGTH); /* model */ 1115 1121 #if ATA_MAX_MULT_SECTORS > 1 1116 1122 p[47] = RT_H2LE_U16(0x8000 | ATA_MAX_MULT_SECTORS); … … 1213 1219 /* Removable CDROM, 50us response, 12 byte packets */ 1214 1220 p[0] = RT_H2LE_U16(2 << 14 | 5 << 8 | 1 << 7 | 2 << 5 | 0 << 0); 1215 ataPadString((uint8_t *)(p + 10), (const char *)s->abSerialNumber, 20); /* serial number */1221 ataPadString((uint8_t *)(p + 10), s->achSerialNumber, ATA_SERIAL_NUMBER_LENGTH); /* serial number */ 1216 1222 p[20] = RT_H2LE_U16(3); /* XXX: retired, cache type */ 1217 1223 p[21] = RT_H2LE_U16(512); /* XXX: retired, cache size in sectors */ 1218 ataPadString((uint8_t *)(p + 23), (const char *)s->abFirmwareRevision, 8); /* firmware version */1219 ataPadString((uint8_t *)(p + 27), (const char *)s->abModelNumber, 40); /* model */1224 ataPadString((uint8_t *)(p + 23), s->achFirmwareRevision, ATA_FIRMWARE_REVISION_LENGTH); /* firmware version */ 1225 ataPadString((uint8_t *)(p + 27), s->achModelNumber, ATA_MODEL_NUMBER_LENGTH); /* model */ 1220 1226 p[49] = RT_H2LE_U16(1 << 11 | 1 << 9 | 1 << 8); /* DMA and LBA supported */ 1221 1227 p[50] = RT_H2LE_U16(1 << 14); /* No drive specific standby timer minimum */ … … 6298 6304 { "SecondaryMaster", "SecondarySlave" } 6299 6305 }; 6300 char aSerial[ 20];6306 char aSerial[ATA_SERIAL_NUMBER_LENGTH+1]; 6301 6307 RTUUID Uuid; 6302 6308 if (pIf->pDrvBlock) … … 6314 6320 else 6315 6321 RTStrPrintf(aSerial, sizeof(aSerial), "VB%08x-%08x", Uuid.au32[0], Uuid.au32[3]); 6316 strncpy( (char *)pIf->abSerialNumber, aSerial, 20);6317 strncpy( (char *)pIf->abFirmwareRevision, "1.0", 8);6322 strncpy(pIf->achSerialNumber, aSerial, sizeof(pIf->achSerialNumber)); 6323 strncpy(pIf->achFirmwareRevision, "1.0", sizeof(pIf->achSerialNumber)); 6318 6324 if (pIf->fATAPI) 6319 strncpy( (char *)pIf->abModelNumber, "VBOX CD-ROM", 40);6325 strncpy(pIf->achModelNumber, "VBOX CD-ROM", sizeof(pIf->achModelNumber)); 6320 6326 else 6321 strncpy( (char *)pIf->abModelNumber, "VBOX HARDDISK", 40);6327 strncpy(pIf->achModelNumber, "VBOX HARDDISK", sizeof(pIf->achModelNumber)); 6322 6328 6323 6329 /* Check if the user provided some values to overwrite. */ … … 6325 6331 if (pCfgNode) 6326 6332 { 6327 char *pszCFGMValue; 6328 6329 rc = CFGMR3QueryStringAlloc(pCfgNode, "SerialNumber", &pszCFGMValue); 6330 if (RT_SUCCESS(rc)) 6333 rc = CFGMR3QueryString(pCfgNode, "SerialNumber", pIf->achSerialNumber, sizeof(pIf->achSerialNumber)); 6334 if (rc == VERR_CFGM_NOT_ENOUGH_SPACE) 6331 6335 { 6332 /* Check length of the serial number. It shouldn't be longer than 20 bytes. */ 6333 if (strlen(pszCFGMValue) > 20) 6334 return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER, 6335 N_("PIIX3 configuration error: \"SerialNumber\" is longer than 20 bytes")); 6336 /* Copy the data over. */ 6337 strncpy((char *)pIf->abSerialNumber, pszCFGMValue, 20); 6338 MMR3HeapFree(pszCFGMValue); 6336 return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER, 6337 N_("PIIX3 configuration error: \"SerialNumber\" is longer than 20 bytes")); 6339 6338 } 6340 else if ( rc != VERR_CFGM_VALUE_NOT_FOUND)6339 else if (RT_FAILURE(rc) && (rc != VERR_CFGM_VALUE_NOT_FOUND)) 6341 6340 return PDMDEV_SET_ERROR(pDevIns, rc, 6342 6341 N_("PIIX3 configuration error: failed to read \"SerialNumber\" as string")); 6343 6342 6344 rc = CFGMR3QueryString Alloc(pCfgNode, "FirmwareRevision", &pszCFGMValue);6345 if ( RT_SUCCESS(rc))6343 rc = CFGMR3QueryString(pCfgNode, "FirmwareRevision", pIf->achFirmwareRevision, sizeof(pIf->achFirmwareRevision)); 6344 if (rc == VERR_CFGM_NOT_ENOUGH_SPACE) 6346 6345 { 6347 /* Check length of the firmware revision. It shouldn't be longer than 8 bytes. */ 6348 if (strlen(pszCFGMValue) > 8) 6349 return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER, 6350 N_("PIIX3 configuration error: \"FirmwareRevision\" is longer than 8 bytes")); 6351 /* Copy the data over. */ 6352 strncpy((char *)pIf->abFirmwareRevision, pszCFGMValue, 8); 6353 MMR3HeapFree(pszCFGMValue); 6346 return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER, 6347 N_("PIIX3 configuration error: \"FirmwareRevision\" is longer than 8 bytes")); 6354 6348 } 6355 else if ( rc != VERR_CFGM_VALUE_NOT_FOUND)6349 else if (RT_FAILURE(rc) && (rc != VERR_CFGM_VALUE_NOT_FOUND)) 6356 6350 return PDMDEV_SET_ERROR(pDevIns, rc, 6357 6351 N_("PIIX3 configuration error: failed to read \"FirmwareRevision\" as string")); 6358 6352 6359 rc = CFGMR3QueryString Alloc(pCfgNode, "ModelNumber", &pszCFGMValue);6360 if ( RT_SUCCESS(rc))6353 rc = CFGMR3QueryString(pCfgNode, "ModelNumber", pIf->achModelNumber, sizeof(pIf->achModelNumber)); 6354 if (rc == VERR_CFGM_NOT_ENOUGH_SPACE) 6361 6355 { 6362 /* Check length of the model number. It shouldn't be longer than 40 bytes. */ 6363 if (strlen(pszCFGMValue) > 40) 6364 return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER, 6365 N_("PIIX3 configuration error: \"ModelNumber\" is longer than 40 bytes")); 6366 /* Copy the data over. */ 6367 strncpy((char *)pIf->abModelNumber, pszCFGMValue, 40); 6368 MMR3HeapFree(pszCFGMValue); 6356 return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER, 6357 N_("PIIX3 configuration error: \"ModelNumber\" is longer than 40 bytes")); 6369 6358 } 6370 else if ( rc != VERR_CFGM_VALUE_NOT_FOUND)6359 else if (RT_FAILURE(rc) && (rc != VERR_CFGM_VALUE_NOT_FOUND)) 6371 6360 return PDMDEV_SET_ERROR(pDevIns, rc, 6372 6361 N_("PIIX3 configuration error: failed to read \"ModelNumber\" as string")); -
trunk/src/VBox/Devices/testcase/tstDeviceStructSizeGC.cpp
r15710 r15846 698 698 GEN_CHECK_OFF(ATADevState, pControllerR0); 699 699 GEN_CHECK_OFF(ATADevState, pControllerRC); 700 GEN_CHECK_OFF(ATADevState, a bSerialNumber);701 GEN_CHECK_OFF(ATADevState, a bSerialNumber[19]);702 GEN_CHECK_OFF(ATADevState, a bFirmwareRevision);703 GEN_CHECK_OFF(ATADevState, a bFirmwareRevision[7]);704 GEN_CHECK_OFF(ATADevState, a bModelNumber);705 GEN_CHECK_OFF(ATADevState, a bModelNumber[39]);700 GEN_CHECK_OFF(ATADevState, achSerialNumber); 701 GEN_CHECK_OFF(ATADevState, achSerialNumber[ATA_SERIAL_NUMBER_LENGTH]); 702 GEN_CHECK_OFF(ATADevState, achFirmwareRevision); 703 GEN_CHECK_OFF(ATADevState, achFirmwareRevision[ATA_FIRMWARE_REVISION_LENGTH]); 704 GEN_CHECK_OFF(ATADevState, achModelNumber); 705 GEN_CHECK_OFF(ATADevState, achModelNumber[ATA_MODEL_NUMBER_LENGTH]); 706 706 GEN_CHECK_SIZE(ATATransferRequest); 707 707 GEN_CHECK_OFF(ATATransferRequest, iIf); … … 1143 1143 GEN_CHECK_OFF(AHCIPort, fNotificationSend); 1144 1144 GEN_CHECK_OFF(AHCIPort, fPortReset); 1145 GEN_CHECK_OFF(AHCIPort, a bSerialNumber);1146 GEN_CHECK_OFF(AHCIPort, a bSerialNumber[19]);1147 GEN_CHECK_OFF(AHCIPort, a bFirmwareRevision);1148 GEN_CHECK_OFF(AHCIPort, a bFirmwareRevision[7]);1149 GEN_CHECK_OFF(AHCIPort, a bModelNumber);1150 GEN_CHECK_OFF(AHCIPort, a bModelNumber[39]);1145 GEN_CHECK_OFF(AHCIPort, achSerialNumber); 1146 GEN_CHECK_OFF(AHCIPort, achSerialNumber[AHCI_SERIAL_NUMBER_LENGTH]); /* One additional byte for the termination.*/ 1147 GEN_CHECK_OFF(AHCIPort, achFirmwareRevision); 1148 GEN_CHECK_OFF(AHCIPort, achFirmwareRevision[AHCI_FIRMWARE_REVISION_LENGTH]); /* One additional byte for the termination.*/ 1149 GEN_CHECK_OFF(AHCIPort, achModelNumber); 1150 GEN_CHECK_OFF(AHCIPort, achModelNumber[AHCI_MODEL_NUMBER_LENGTH]); /* One additional byte for the termination.*/ 1151 1151 1152 1152 GEN_CHECK_SIZE(AHCI);
Note:
See TracChangeset
for help on using the changeset viewer.