Changeset 21874 in vbox
- Timestamp:
- Jul 30, 2009 12:12:23 PM (15 years ago)
- Location:
- trunk/src/VBox/Devices/PC
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/DevPcBios.cpp
r21869 r21874 29 29 30 30 #include <VBox/log.h> 31 #ifdef VBOX_WITH_DMI_OEMSTRINGS 32 #include <VBox/version.h> 33 #endif 31 #include <VBox/version.h> 34 32 #include <iprt/assert.h> 35 33 #include <iprt/alloc.h> … … 194 192 AssertCompileSize(DMIHDR, 4); 195 193 196 /** DMI BIOS information */194 /** DMI BIOS information (Type 0) */ 197 195 typedef struct DMIBIOSINF 198 196 { … … 213 211 AssertCompileSize(DMIBIOSINF, 0x18); 214 212 215 /** DMI system information */213 /** DMI system information (Type 1) */ 216 214 typedef struct DMISYSTEMINF 217 215 { … … 228 226 AssertCompileSize(DMISYSTEMINF, 0x1b); 229 227 230 /** DMI processor information */ 228 /** DMI system enclosure or chassis type (Type 3) */ 229 typedef struct DMICHASSIS 230 { 231 DMIHDR header; 232 uint8_t u8Manufacturer; 233 uint8_t u8Type; 234 uint8_t u8Version; 235 uint8_t u8SerialNumber; 236 uint8_t u8AssetTag; 237 uint8_t u8BootupState; 238 uint8_t u8PowerSupplyState; 239 uint8_t u8ThermalState; 240 uint8_t u8SecurityStatus; 241 /* v2.3+, currently not supported */ 242 uint32_t u32OEMdefined; 243 uint8_t u8Height; 244 uint8_t u8NumPowerChords; 245 uint8_t u8ContElems; 246 uint8_t u8ContElemRecLen; 247 } *PDMICHASSIS; 248 AssertCompileSize(DMICHASSIS, 0x15); 249 250 /** DMI processor information (Type 4) */ 231 251 typedef struct DMIPROCESSORINF 232 252 { … … 258 278 AssertCompileSize(DMIPROCESSORINF, 0x2a); 259 279 260 #ifdef VBOX_WITH_DMI_OEMSTRINGS 261 /** DMI OEM strings */ 280 /** DMI OEM strings (Type 11) */ 262 281 typedef struct DMIOEMSTRINGS 263 282 { … … 268 287 } *PDMIOEMSTRINGS; 269 288 AssertCompileSize(DMIOEMSTRINGS, 0x7); 270 #endif271 289 272 290 /** MPS floating pointer structure */ … … 348 366 349 367 #pragma pack() 368 350 369 351 370 /* Attempt to guess the LCHS disk geometry from the MS-DOS master boot … … 933 952 int iDmiBIOSReleaseMajor, iDmiBIOSReleaseMinor, iDmiBIOSFirmwareMajor, iDmiBIOSFirmwareMinor; 934 953 char *pszDmiSystemVendor, *pszDmiSystemProduct, *pszDmiSystemVersion, *pszDmiSystemSerial, *pszDmiSystemUuid, *pszDmiSystemFamily; 935 #ifdef VBOX_WITH_DMI_OEMSTRINGS 954 char *pszDmiChassisVendor, *pszDmiChassisVersion, *pszDmiChassisSerial, *pszDmiChassisAssetTag; 936 955 char *pszDmiOEMVBoxVer, *pszDmiOEMVBoxRev; 937 #endif 938 956 957 #define CHECKSIZE(want) \ 958 do { \ 959 size_t _max = (size_t)(pszStr + want - (char *)pTable) + 5; /* +1 for strtab terminator +4 for end-of-table entry */ \ 960 if (_max > cbMax) \ 961 { \ 962 return PDMDevHlpVMSetError(pDevIns, VERR_TOO_MUCH_DATA, RT_SRC_POS, \ 963 N_("One of the DMI strings is too long. Check all bios/Dmi* configuration entries. At least %zu bytes are needed but there is no space for more than %d bytes"), _max, cbMax); \ 964 } \ 965 } while (0) 939 966 #define SETSTRING(memb, str) \ 940 967 do { \ 941 968 if (!str[0]) \ 942 memb = 0; /* empty string */ \969 memb = 0; /* empty string */ \ 943 970 else \ 944 971 { \ 945 memb = iStrNr++; \ 946 size_t _len = strlen(str) + 1; \ 947 size_t _max = (size_t)(pszStr + _len - (char *)pTable) + 5; /* +1 for strtab terminator +4 for end-of-table entry */ \ 948 if (_max > cbMax) \ 949 return PDMDevHlpVMSetError(pDevIns, VERR_TOO_MUCH_DATA, RT_SRC_POS, \ 950 N_("One of the DMI strings is too long. Check all bios/Dmi* configuration entries. At least %zu bytes are needed but there is no space for more than %d bytes"), _max, cbMax); \ 951 memcpy(pszStr, str, _len); \ 952 pszStr += _len; \ 972 memb = iStrNr++; \ 973 size_t _len = strlen(str) + 1; \ 974 CHECKSIZE(_len); \ 975 memcpy(pszStr, str, _len); \ 976 pszStr += _len; \ 953 977 } \ 954 978 } while (0) … … 995 1019 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, 996 1020 N_("Configuration error: Querying \"DmiUuid\" as a string failed")); 997 READCFGSTR("DmiSystemFamily", pszDmiSystemFamily, "Virtual Machine"); 998 999 /* DMI BIOS information */ 1021 READCFGSTR("DmiSystemFamily", pszDmiSystemFamily, "Virtual Machine"); 1022 READCFGSTR("DmiChassisVendor", pszDmiChassisVendor, "Sun Microsystems, Inc."); 1023 READCFGSTR("DmiChassisVersion", pszDmiChassisVersion, ""); /* default not specified */ 1024 READCFGSTR("DmiChassisSerial", pszDmiChassisSerial, ""); /* default not specified */ 1025 READCFGSTR("DmiChassisAssetTag", pszDmiChassisAssetTag, ""); /* default not specified */ 1026 1027 /* DMI BIOS information (Type 0) */ 1000 1028 PDMIBIOSINF pBIOSInf = (PDMIBIOSINF)pszStr; 1001 1002 pszStr = (char *)&pBIOSInf->u8ReleaseMajor; 1029 CHECKSIZE(sizeof(*pBIOSInf)); 1030 1031 pszStr = (char *)&pBIOSInf->u8ReleaseMajor; 1003 1032 pBIOSInf->header.u8Length = RT_OFFSETOF(DMIBIOSINF, u8ReleaseMajor); 1004 1033 … … 1043 1072 *pszStr++ = '\0'; 1044 1073 1045 /* DMI system information */1074 /* DMI system information (Type 1) */ 1046 1075 PDMISYSTEMINF pSystemInf = (PDMISYSTEMINF)pszStr; 1076 CHECKSIZE(sizeof(*pSystemInf)); 1047 1077 pszStr = (char *)(pSystemInf + 1); 1048 1078 iStrNr = 1; … … 1074 1104 *pszStr++ = '\0'; 1075 1105 1076 #ifdef VBOX_WITH_DMI_OEMSTRINGS 1106 /* DMI System Enclosure or Chassis (Type 3) */ 1107 PDMICHASSIS pChassis = (PDMICHASSIS)pszStr; 1108 CHECKSIZE(sizeof(*pChassis)); 1109 pszStr = (char*)&pChassis->u32OEMdefined; 1110 iStrNr = 1; 1111 #ifdef VBOX_WITH_DMI_CHASSIS 1112 pChassis->header.u8Type = 3; /* System Enclosure or Chassis */ 1113 #else 1114 pChassis->header.u8Type = 0x7e; /* inactive */ 1115 #endif 1116 pChassis->header.u8Length = RT_OFFSETOF(DMICHASSIS, u32OEMdefined); 1117 pChassis->header.u16Handle = 0x0003; 1118 SETSTRING(pChassis->u8Manufacturer, pszDmiChassisVendor); 1119 pChassis->u8Type = 0x01; /* ''other'', no chassis lock present */ 1120 SETSTRING(pChassis->u8Version, pszDmiChassisVersion); 1121 SETSTRING(pChassis->u8SerialNumber, pszDmiChassisSerial); 1122 SETSTRING(pChassis->u8AssetTag, pszDmiChassisAssetTag); 1123 pChassis->u8BootupState = 0x03; /* safe */ 1124 pChassis->u8PowerSupplyState = 0x03; /* safe */ 1125 pChassis->u8ThermalState = 0x03; /* safe */ 1126 pChassis->u8SecurityStatus = 0x03; /* none XXX */ 1127 # if 0 1128 /* v2.3+, currently not supported */ 1129 pChassis->u32OEMdefined = 0; 1130 pChassis->u8Height = 0; /* unspecified */ 1131 pChassis->u8NumPowerChords = 0; /* unspecified */ 1132 pChassis->u8ContElems = 0; /* no contained elements */ 1133 pChassis->u8ContElemRecLen = 0; /* no contained elements */ 1134 # endif 1135 *pszStr++ = '\0'; 1136 1077 1137 /* DMI OEM strings */ 1078 1138 PDMIOEMSTRINGS pOEMStrings = (PDMIOEMSTRINGS)pszStr; 1139 CHECKSIZE(sizeof(*pOEMStrings)); 1079 1140 pszStr = (char *)(pOEMStrings + 1); 1080 1141 iStrNr = 1; 1142 #ifdef VBOX_WITH_DMI_OEMSTRINGS 1081 1143 pOEMStrings->header.u8Type = 0xb; /* OEM Strings */ 1144 #else 1145 pOEMStrings->header.u8Type = 0x7e; /* inactive */ 1146 #endif 1082 1147 pOEMStrings->header.u8Length = sizeof(*pOEMStrings); 1083 pOEMStrings->header.u16Handle = 0x0002; 1148 pOEMStrings->header.u16Handle = 0x0002; 1084 1149 pOEMStrings->u8Count = 2; 1085 1150 … … 1094 1159 RTStrFree(pszVBoxVer); 1095 1160 RTStrFree(pszVBoxRev); 1096 1097 1161 *pszStr++ = '\0'; 1098 #endif1099 1162 1100 1163 /* End-of-table marker - includes padding to account for fixed table size. */ … … 1102 1165 pEndOfTable->u8Type = 0x7f; 1103 1166 pEndOfTable->u8Length = cbMax - ((char *)pszStr - (char *)pTable) - 2; 1104 pEndOfTable->u16Handle = 0xF FFF;1167 pEndOfTable->u16Handle = 0xFEFF; 1105 1168 1106 1169 /* If more fields are added here, fix the size check in SETSTRING */ 1107 1170 1108 1171 #undef SETSTRING 1109 #undef READCFG 1172 #undef READCFGSTR 1173 #undef READCFGINT 1174 #undef CHECKSIZE 1110 1175 1111 1176 MMR3HeapFree(pszDmiBIOSVendor); … … 1118 1183 MMR3HeapFree(pszDmiSystemUuid); 1119 1184 MMR3HeapFree(pszDmiSystemFamily); 1120 #ifdef VBOX_WITH_DMI_OEMSTRINGS 1185 MMR3HeapFree(pszDmiChassisVendor); 1186 MMR3HeapFree(pszDmiChassisVersion); 1187 MMR3HeapFree(pszDmiChassisSerial); 1188 MMR3HeapFree(pszDmiChassisAssetTag); 1121 1189 MMR3HeapFree(pszDmiOEMVBoxVer); 1122 1190 MMR3HeapFree(pszDmiOEMVBoxRev); 1123 #endif1124 1191 1125 1192 return VINF_SUCCESS; 1126 1193 } 1127 AssertCompile(VBOX_DMI_TABLE_ENTR == 4); 1128 1194 AssertCompile(VBOX_DMI_TABLE_ENTR == 5); 1129 1195 1130 1196 /** … … 1463 1529 "DmiSystemUuid\0" 1464 1530 "DmiSystemVendor\0" 1531 "DmiSystemVersion\0" 1532 "DmiChassisVendor\0" 1533 "DmiChassisVersion\0" 1534 "DmiChassisSerial\0" 1535 "DmiChassisAssetTag\0" 1465 1536 "DmiSystemVersion\0" 1466 1537 "DmiOEMVBoxVer\0" -
trunk/src/VBox/Devices/PC/DevPcBios.h
r21869 r21874 26 26 #define VBOX_DMI_TABLE_BASE 0xe1000 27 27 #define VBOX_DMI_TABLE_VER 0x25 28 #define VBOX_DMI_TABLE_ENTR 428 #define VBOX_DMI_TABLE_ENTR 5 29 29 #define VBOX_DMI_TABLE_SIZE 0x100 30 30
Note:
See TracChangeset
for help on using the changeset viewer.