VirtualBox

Changeset 21874 in vbox


Ignore:
Timestamp:
Jul 30, 2009 12:12:23 PM (15 years ago)
Author:
vboxsync
Message:

Dev/PcBios: added chassis information; don't change the number of DMI structures but use the inactive type to disable dedicated structures

Location:
trunk/src/VBox/Devices/PC
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/DevPcBios.cpp

    r21869 r21874  
    2929
    3030#include <VBox/log.h>
    31 #ifdef VBOX_WITH_DMI_OEMSTRINGS
    32  #include <VBox/version.h>
    33 #endif
     31#include <VBox/version.h>
    3432#include <iprt/assert.h>
    3533#include <iprt/alloc.h>
     
    194192AssertCompileSize(DMIHDR, 4);
    195193
    196 /** DMI BIOS information */
     194/** DMI BIOS information (Type 0) */
    197195typedef struct DMIBIOSINF
    198196{
     
    213211AssertCompileSize(DMIBIOSINF, 0x18);
    214212
    215 /** DMI system information */
     213/** DMI system information (Type 1) */
    216214typedef struct DMISYSTEMINF
    217215{
     
    228226AssertCompileSize(DMISYSTEMINF, 0x1b);
    229227
    230 /** DMI processor information */
     228/** DMI system enclosure or chassis type (Type 3) */
     229typedef 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;
     248AssertCompileSize(DMICHASSIS, 0x15);
     249
     250/** DMI processor information (Type 4) */
    231251typedef struct DMIPROCESSORINF
    232252{
     
    258278AssertCompileSize(DMIPROCESSORINF, 0x2a);
    259279
    260 #ifdef VBOX_WITH_DMI_OEMSTRINGS
    261 /** DMI OEM strings */
     280/** DMI OEM strings (Type 11) */
    262281typedef struct DMIOEMSTRINGS
    263282{
     
    268287} *PDMIOEMSTRINGS;
    269288AssertCompileSize(DMIOEMSTRINGS, 0x7);
    270 #endif
    271289
    272290/** MPS floating pointer structure */
     
    348366
    349367#pragma pack()
     368
    350369
    351370/* Attempt to guess the LCHS disk geometry from the MS-DOS master boot
     
    933952    int  iDmiBIOSReleaseMajor, iDmiBIOSReleaseMinor, iDmiBIOSFirmwareMajor, iDmiBIOSFirmwareMinor;
    934953    char *pszDmiSystemVendor, *pszDmiSystemProduct, *pszDmiSystemVersion, *pszDmiSystemSerial, *pszDmiSystemUuid, *pszDmiSystemFamily;
    935 #ifdef VBOX_WITH_DMI_OEMSTRINGS
     954    char *pszDmiChassisVendor, *pszDmiChassisVersion, *pszDmiChassisSerial, *pszDmiChassisAssetTag;
    936955    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)
    939966#define SETSTRING(memb, str) \
    940967    do { \
    941968        if (!str[0]) \
    942           memb = 0; /* empty string */ \
     969            memb = 0; /* empty string */ \
    943970        else \
    944971        { \
    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; \
    953977        } \
    954978    } while (0)
     
    9951019        return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
    9961020                                   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) */
    10001028    PDMIBIOSINF pBIOSInf         = (PDMIBIOSINF)pszStr;
    1001 
    1002     pszStr = (char *)&pBIOSInf->u8ReleaseMajor;
     1029    CHECKSIZE(sizeof(*pBIOSInf));
     1030
     1031    pszStr                       = (char *)&pBIOSInf->u8ReleaseMajor;
    10031032    pBIOSInf->header.u8Length    = RT_OFFSETOF(DMIBIOSINF, u8ReleaseMajor);
    10041033
     
    10431072    *pszStr++                    = '\0';
    10441073
    1045     /* DMI system information */
     1074    /* DMI system information (Type 1) */
    10461075    PDMISYSTEMINF pSystemInf     = (PDMISYSTEMINF)pszStr;
     1076    CHECKSIZE(sizeof(*pSystemInf));
    10471077    pszStr                       = (char *)(pSystemInf + 1);
    10481078    iStrNr                       = 1;
     
    10741104    *pszStr++                    = '\0';
    10751105
    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
    10771137    /* DMI OEM strings */
    10781138    PDMIOEMSTRINGS pOEMStrings    = (PDMIOEMSTRINGS)pszStr;
     1139    CHECKSIZE(sizeof(*pOEMStrings));
    10791140    pszStr                        = (char *)(pOEMStrings + 1);
    10801141    iStrNr                        = 1;
     1142#ifdef VBOX_WITH_DMI_OEMSTRINGS
    10811143    pOEMStrings->header.u8Type    = 0xb; /* OEM Strings */
     1144#else
     1145    pOEMStrings->header.u8Type    = 0x7e; /* inactive */
     1146#endif
    10821147    pOEMStrings->header.u8Length  = sizeof(*pOEMStrings);
    1083     pOEMStrings->header.u16Handle = 0x0002;   
     1148    pOEMStrings->header.u16Handle = 0x0002;
    10841149    pOEMStrings->u8Count          = 2;
    10851150
     
    10941159    RTStrFree(pszVBoxVer);
    10951160    RTStrFree(pszVBoxRev);
    1096 
    10971161    *pszStr++                    = '\0';
    1098 #endif
    10991162
    11001163    /* End-of-table marker - includes padding to account for fixed table size. */
     
    11021165    pEndOfTable->u8Type          = 0x7f;
    11031166    pEndOfTable->u8Length        = cbMax - ((char *)pszStr - (char *)pTable) - 2;
    1104     pEndOfTable->u16Handle       = 0xFFFF;
     1167    pEndOfTable->u16Handle       = 0xFEFF;
    11051168
    11061169    /* If more fields are added here, fix the size check in SETSTRING */
    11071170
    11081171#undef SETSTRING
    1109 #undef READCFG
     1172#undef READCFGSTR
     1173#undef READCFGINT
     1174#undef CHECKSIZE
    11101175
    11111176    MMR3HeapFree(pszDmiBIOSVendor);
     
    11181183    MMR3HeapFree(pszDmiSystemUuid);
    11191184    MMR3HeapFree(pszDmiSystemFamily);
    1120 #ifdef VBOX_WITH_DMI_OEMSTRINGS
     1185    MMR3HeapFree(pszDmiChassisVendor);
     1186    MMR3HeapFree(pszDmiChassisVersion);
     1187    MMR3HeapFree(pszDmiChassisSerial);
     1188    MMR3HeapFree(pszDmiChassisAssetTag);
    11211189    MMR3HeapFree(pszDmiOEMVBoxVer);
    11221190    MMR3HeapFree(pszDmiOEMVBoxRev);
    1123 #endif
    11241191
    11251192    return VINF_SUCCESS;
    11261193}
    1127 AssertCompile(VBOX_DMI_TABLE_ENTR == 4);
    1128 
     1194AssertCompile(VBOX_DMI_TABLE_ENTR == 5);
    11291195
    11301196/**
     
    14631529                              "DmiSystemUuid\0"
    14641530                              "DmiSystemVendor\0"
     1531                              "DmiSystemVersion\0"
     1532                              "DmiChassisVendor\0"
     1533                              "DmiChassisVersion\0"
     1534                              "DmiChassisSerial\0"
     1535                              "DmiChassisAssetTag\0"
    14651536                              "DmiSystemVersion\0"
    14661537                              "DmiOEMVBoxVer\0"
  • trunk/src/VBox/Devices/PC/DevPcBios.h

    r21869 r21874  
    2626#define VBOX_DMI_TABLE_BASE          0xe1000
    2727#define VBOX_DMI_TABLE_VER           0x25
    28 #define VBOX_DMI_TABLE_ENTR          4
     28#define VBOX_DMI_TABLE_ENTR          5
    2929#define VBOX_DMI_TABLE_SIZE          0x100
    3030
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette