VirtualBox

Changeset 39707 in vbox for trunk/src/VBox/Devices/PC


Ignore:
Timestamp:
Jan 6, 2012 12:16:54 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
75563
Message:

BIOS: allow to expose the processor informtion

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

Legend:

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

    r39274 r39707  
    6565static const char   *s_szDefDmiChassisSerial    = "";
    6666static const char   *s_szDefDmiChassisAssetTag  = "";
     67static const char   *s_szDefDmiProcManufacturer = "GenuineIntel";
     68static const char   *s_szDefDmiProcVersion      = "Pentium(R) III";
    6769
    6870static       char    g_szHostDmiSystemProduct[64];
     
    189191    uint8_t         u8ProcessorFamily;
    190192    uint8_t         u8ProcessorManufacturer;
    191     uint64_t        u64ProcessorIdentification;
     193    uint64_t        u64ProcessorID;
    192194    uint8_t         u8ProcessorVersion;
    193195    uint8_t         u8Voltage;
     
    197199    uint8_t         u8Status;
    198200    uint8_t         u8ProcessorUpgrade;
     201    /* v2.1+ */
    199202    uint16_t        u16L1CacheHandle;
    200203    uint16_t        u16L2CacheHandle;
    201204    uint16_t        u16L3CacheHandle;
     205    /* v2.3+ */
    202206    uint8_t         u8SerialNumber;
    203207    uint8_t         u8AssetTag;
    204208    uint8_t         u8PartNumber;
     209    /* v2.5+ */
    205210    uint8_t         u8CoreCount;
    206211    uint8_t         u8CoreEnabled;
    207212    uint8_t         u8ThreadCount;
    208213    uint16_t        u16ProcessorCharacteristics;
     214    /* v2.6+ */
    209215    uint16_t        u16ProcessorFamily2;
    210216} *PDMIPROCESSORINF;
     
    398404 * @param   pCfg                The handle to our config node.
    399405 */
    400 int FwCommonPlantDMITable(PPDMDEVINS pDevIns, uint8_t *pTable, unsigned cbMax, PCRTUUID pUuid, PCFGMNODE pCfg)
     406int FwCommonPlantDMITable(PPDMDEVINS pDevIns, uint8_t *pTable, unsigned cbMax, PCRTUUID pUuid, PCFGMNODE pCfg, uint16_t cCpus)
    401407{
    402408#define CHECKSIZE(cbWant) \
     
    514520        return PDMDEV_SET_ERROR(pDevIns, rc,
    515521                                N_("Configuration error: Failed to read \"DmiExposeMemoryTable\""));
     522    uint8_t fDmiExposeProcessorInf;
     523    rc = CFGMR3QueryU8Def(pCfg, "DmiExposeProcInf", &fDmiExposeProcessorInf, 0);
     524    if (RT_FAILURE (rc))
     525        return PDMDEV_SET_ERROR(pDevIns, rc,
     526                                N_("Configuration error: Failed to read \"DmiExposeProcInf\""));
    516527
    517528    for  (;; fForceDefault = true, fHideErrors = false)
     
    606617        PDMISYSTEMINF pSystemInf     = (PDMISYSTEMINF)pszStr;
    607618        CHECKSIZE(sizeof(*pSystemInf));
    608         pszStr                       = (char *)(pSystemInf + 1);
     619        START_STRUCT(pSystemInf);
    609620        iStrNr                       = 1;
    610621        pSystemInf->header.u8Type    = 1; /* System Information */
     
    675686        TERM_STRUCT;
    676687
     688        /**************************************
     689         * DMI Processor Information (Type 4) *
     690         **************************************/
     691
     692        /*
     693         * This is just a dummy processor. Should we expose the real guest CPU features
     694         * here? Accessing this information at this point is difficult.
     695         */
     696        char szSocket[32];
     697        PDMIPROCESSORINF pProcessorInf = (PDMIPROCESSORINF)pszStr;
     698        CHECKSIZE(sizeof(*pProcessorInf));
     699        START_STRUCT(pProcessorInf);
     700        iStrNr                             = 1;
     701        if (fDmiExposeProcessorInf)
     702            pProcessorInf->header.u8Type   = 4; /* Processor Information */
     703        else
     704            pProcessorInf->header.u8Type   = 126; /* inactive structure */
     705        pProcessorInf->header.u8Length     = sizeof(*pProcessorInf);
     706        pProcessorInf->header.u16Handle    = 0x0007;
     707        RTStrPrintf(szSocket, sizeof(szSocket), "Socket #%u", 0);
     708        pProcessorInf->u8SocketDesignation = iStrNr++;
     709        {
     710            size_t cStr = strlen(szSocket) + 1;
     711            CHECKSIZE(cStr);
     712            memcpy(pszStr, szSocket, cStr);
     713            pszStr += cStr;
     714        }
     715        pProcessorInf->u8ProcessorType     = 0x03; /* Central Processor */
     716        pProcessorInf->u8ProcessorFamily   = 0xB1; /* Pentium III with Intel SpeedStep(TM) */
     717        READCFGSTR(pProcessorInf->u8ProcessorManufacturer, DmiProcManufacturer);
     718
     719        pProcessorInf->u64ProcessorID      = UINT64_C(0x0FEBFBFF00010676);
     720                                             /* Ext Family ID  = 0
     721                                              * Ext Model ID   = 2
     722                                              * Processor Type = 0
     723                                              * Family ID      = 6
     724                                              * Model          = 7
     725                                              * Stepping       = 6
     726                                              * Features: FPU, VME, DE, PSE, TSC, MSR, PAE, MCE, CX8,
     727                                              *           APIC, SEP, MTRR, PGE, MCA, CMOV, PAT, PSE-36,
     728                                              *           CFLSH, DS, ACPI, MMX, FXSR, SSE, SSE2, SS */
     729        READCFGSTR(pProcessorInf->u8ProcessorVersion, DmiProcVersion);
     730        pProcessorInf->u8Voltage           = 0x02;   /* 3.3V */
     731        pProcessorInf->u16ExternalClock    = 0x00;   /* unknown */
     732        pProcessorInf->u16MaxSpeed         = 3000;   /* 3GHz */
     733        pProcessorInf->u16CurrentSpeed     = 3000;   /* 3GHz */
     734        pProcessorInf->u8Status            = RT_BIT(6)  /* CPU socket populated */
     735                                           | RT_BIT(0)  /* CPU enabled */
     736                                           ;
     737        pProcessorInf->u8ProcessorUpgrade  = 0x04;   /* ZIF Socket */
     738        pProcessorInf->u16L1CacheHandle    = 0x001C;
     739        pProcessorInf->u16L2CacheHandle    = 0x001D;
     740        pProcessorInf->u16L3CacheHandle    = 0xFFFF; /* unknown */
     741        pProcessorInf->u8SerialNumber      = 0;      /* not specified */
     742        pProcessorInf->u8AssetTag          = 0;      /* not specified */
     743        pProcessorInf->u8PartNumber        = 0;      /* not specified */
     744        pProcessorInf->u8CoreCount         = cCpus;  /*  */
     745        pProcessorInf->u8CoreEnabled       = cCpus;
     746        pProcessorInf->u8ThreadCount       = 1;
     747        pProcessorInf->u16ProcessorCharacteristics
     748                                           = RT_BIT(2); /* 64-bit capable */
     749        pProcessorInf->u16ProcessorFamily2 = 0;
     750        TERM_STRUCT;
     751
     752        /***************************************
     753         * DMI Physical Memory Array (Type 16) *
     754         ***************************************/
     755        uint64_t u64RamSize;
     756        rc = CFGMR3QueryU64(pCfg, "RamSize", &u64RamSize);
     757        if (RT_FAILURE (rc))
     758            return PDMDEV_SET_ERROR(pDevIns, rc,
     759                                    N_("Configuration error: Failed to read \"RamSize\""));
     760
     761        PDMIRAMARRAY pMemArray = (PDMIRAMARRAY)pszStr;
     762        CHECKSIZE(sizeof(*pMemArray));
     763        START_STRUCT(pMemArray);
    677764        if (fDmiExposeMemoryTable)
    678         {
    679             /***************************************
    680              * DMI Physical Memory Array (Type 16) *
    681              ***************************************/
    682             uint64_t u64RamSize;
    683             rc = CFGMR3QueryU64(pCfg, "RamSize", &u64RamSize);
    684             if (RT_FAILURE (rc))
    685                 return PDMDEV_SET_ERROR(pDevIns, rc,
    686                                         N_("Configuration error: Failed to read \"RamSize\""));
    687 
    688             PDMIRAMARRAY pMemArray = (PDMIRAMARRAY)pszStr;
    689             CHECKSIZE(sizeof(*pMemArray));
    690 
    691             START_STRUCT(pMemArray);
    692             pMemArray->header.u8Type    = 16; /* Physical Memory Array */
    693             pMemArray->header.u8Length  = sizeof(*pMemArray);
    694             pMemArray->header.u16Handle = 0x0005;
    695             pMemArray->u8Location = 0x03; /* Motherboard */
    696             pMemArray->u8Use = 0x03; /* System memory */
    697             pMemArray->u8MemErrorCorrection = 0x01; /* Other */
    698             uint32_t u32RamSizeK = (uint32_t)(u64RamSize / _1K);
    699             pMemArray->u32MaxCapacity = u32RamSizeK; /* RAM size in K */
    700             pMemArray->u16MemErrorHandle = 0xfffe; /* No error info structure */
    701             pMemArray->u16NumberOfMemDevices = 1;
    702             TERM_STRUCT;
    703 
    704             /***************************************
    705              * DMI Memory Device (Type 17)         *
    706              ***************************************/
    707             PDMIMEMORYDEV pMemDev = (PDMIMEMORYDEV)pszStr;
    708             CHECKSIZE(sizeof(*pMemDev));
    709 
    710             START_STRUCT(pMemDev);
    711             pMemDev->header.u8Type    = 17; /* Memory Device */
    712             pMemDev->header.u8Length  = sizeof(*pMemDev);
    713             pMemDev->header.u16Handle = 0x0006;
    714             pMemDev->u16PhysMemArrayHandle = 0x0005; /* handle of array we belong to */
    715             pMemDev->u16MemErrHandle = 0xfffe; /* system doesn't provide this information */
    716             pMemDev->u16TotalWidth = 0xffff; /* Unknown */
    717             pMemDev->u16DataWidth = 0xffff;  /* Unknown */
    718             int16_t u16RamSizeM = (uint16_t)(u64RamSize / _1M);
    719             if (u16RamSizeM == 0)
    720                 u16RamSizeM = 0x400; /* 1G */
    721             pMemDev->u16Size = u16RamSizeM; /* RAM size */
    722             pMemDev->u8FormFactor = 0x09; /* DIMM */
    723             pMemDev->u8DeviceSet = 0x00; /* Not part of a device set */
    724             READCFGSTRDEF(pMemDev->u8DeviceLocator, " ", "DIMM 0");
    725             READCFGSTRDEF(pMemDev->u8BankLocator, " ", "Bank 0");
    726             pMemDev->u8MemoryType = 0x03; /* DRAM */
    727             pMemDev->u16TypeDetail = 0; /* Nothing special */
    728             pMemDev->u16Speed = 1600; /* Unknown, shall be speed in MHz */
    729             READCFGSTR(pMemDev->u8Manufacturer, DmiSystemVendor);
    730             READCFGSTRDEF(pMemDev->u8SerialNumber, " ", "00000000");
    731             READCFGSTRDEF(pMemDev->u8AssetTag, " ", "00000000");
    732             READCFGSTRDEF(pMemDev->u8PartNumber, " ", "00000000");
    733             pMemDev->u8Attributes = 0; /* Unknown */
    734             TERM_STRUCT;
    735         }
     765            pMemArray->header.u8Type     = 16;     /* Physical Memory Array */
     766        else
     767            pMemArray->header.u8Type     = 126;    /* inactive structure */
     768        pMemArray->header.u8Length       = sizeof(*pMemArray);
     769        pMemArray->header.u16Handle      = 0x0005;
     770        pMemArray->u8Location            = 0x03;   /* Motherboard */
     771        pMemArray->u8Use                 = 0x03;   /* System memory */
     772        pMemArray->u8MemErrorCorrection  = 0x01;   /* Other */
     773        pMemArray->u32MaxCapacity        = (uint32_t)(u64RamSize / _1K); /* RAM size in K */
     774        pMemArray->u16MemErrorHandle     = 0xfffe; /* No error info structure */
     775        pMemArray->u16NumberOfMemDevices = 1;
     776        TERM_STRUCT;
     777
     778        /***************************************
     779         * DMI Memory Device (Type 17)         *
     780         ***************************************/
     781        PDMIMEMORYDEV pMemDev = (PDMIMEMORYDEV)pszStr;
     782        CHECKSIZE(sizeof(*pMemDev));
     783        START_STRUCT(pMemDev);
     784        if (fDmiExposeMemoryTable)
     785            pMemDev->header.u8Type       = 17;     /* Memory Device */
     786        else
     787            pMemDev->header.u8Type       = 126;    /* inactive structure */
     788        pMemDev->header.u8Length         = sizeof(*pMemDev);
     789        pMemDev->header.u16Handle        = 0x0006;
     790        pMemDev->u16PhysMemArrayHandle   = 0x0005; /* handle of array we belong to */
     791        pMemDev->u16MemErrHandle         = 0xfffe; /* system doesn't provide this information */
     792        pMemDev->u16TotalWidth           = 0xffff; /* Unknown */
     793        pMemDev->u16DataWidth            = 0xffff; /* Unknown */
     794        int16_t u16RamSizeM = (uint16_t)(u64RamSize / _1M);
     795        if (u16RamSizeM == 0)
     796            u16RamSizeM = 0x400; /* 1G */
     797        pMemDev->u16Size                 = u16RamSizeM; /* RAM size */
     798        pMemDev->u8FormFactor            = 0x09; /* DIMM */
     799        pMemDev->u8DeviceSet             = 0x00; /* Not part of a device set */
     800        READCFGSTRDEF(pMemDev->u8DeviceLocator, " ", "DIMM 0");
     801        READCFGSTRDEF(pMemDev->u8BankLocator, " ", "Bank 0");
     802        pMemDev->u8MemoryType            = 0x03; /* DRAM */
     803        pMemDev->u16TypeDetail           = 0;    /* Nothing special */
     804        pMemDev->u16Speed                = 1600; /* Unknown, shall be speed in MHz */
     805        READCFGSTR(pMemDev->u8Manufacturer, DmiSystemVendor);
     806        READCFGSTRDEF(pMemDev->u8SerialNumber, " ", "00000000");
     807        READCFGSTRDEF(pMemDev->u8AssetTag, " ", "00000000");
     808        READCFGSTRDEF(pMemDev->u8PartNumber, " ", "00000000");
     809        pMemDev->u8Attributes            = 0; /* Unknown */
     810        TERM_STRUCT;
    736811
    737812        /*****************************
     
    740815        PDMIOEMSTRINGS pOEMStrings    = (PDMIOEMSTRINGS)pszStr;
    741816        CHECKSIZE(sizeof(*pOEMStrings));
    742         pszStr                        = (char *)(pOEMStrings + 1);
     817        START_STRUCT(pOEMStrings);
    743818        iStrNr                        = 1;
    744819#ifdef VBOX_WITH_DMI_OEMSTRINGS
    745820        pOEMStrings->header.u8Type    = 0xb; /* OEM Strings */
    746821#else
    747         pOEMStrings->header.u8Type    = 0x7e; /* inactive */
     822        pOEMStrings->header.u8Type    = 126; /* inactive structure */
    748823#endif
    749824        pOEMStrings->header.u8Length  = sizeof(*pOEMStrings);
     
    762837        PDMIHDR pEndOfTable          = (PDMIHDR)pszStr;
    763838        pEndOfTable->u8Type          = 0x7f;
    764         pEndOfTable->u8Length        = cbMax - ((char *)pszStr - (char *)pTable) - 2;
     839        uint32_t cbEof = cbMax - ((uintptr_t)pszStr - (uintptr_t)pTable) - 2;
     840        if (cbEof > 255)
     841            return PDMDevHlpVMSetError(pDevIns, VERR_TOO_MUCH_DATA, RT_SRC_POS, \
     842                                       N_("DMI table has the wrong length (%u bytes left for the EOF marker). One of the DMI strings is too long. Check all bios/Dmi* configuration entries"), cbEof); \
     843        pEndOfTable->u8Length        = cbEof;
    765844        pEndOfTable->u16Handle       = 0xFEFF;
    766845
     
    818897    PDMDevHlpPhysWrite(pDevIns, 0xfe300, &aBiosHeaders, sizeof(aBiosHeaders));
    819898}
    820 AssertCompile(VBOX_DMI_TABLE_ENTR == 5);
     899AssertCompile(VBOX_DMI_TABLE_ENTR == 8);
    821900
    822901/**
  • trunk/src/VBox/Devices/PC/DevFwCommon.h

    r28800 r39707  
    2828
    2929/* Plant DMI table */
    30 int FwCommonPlantDMITable(PPDMDEVINS pDevIns, uint8_t *pTable, unsigned cbMax, PCRTUUID pUuid, PCFGMNODE pCfg);
     30int FwCommonPlantDMITable(PPDMDEVINS pDevIns, uint8_t *pTable, unsigned cbMax, PCRTUUID pUuid, PCFGMNODE pCfg, uint16_t cCpus);
    3131void FwCommonPlantSmbiosAndDmiHdrs(PPDMDEVINS pDevIns);
    3232
  • trunk/src/VBox/Devices/PC/DevPcBios.cpp

    r38698 r39707  
    982982                              "DmiUseHostInfo\0"
    983983                              "DmiExposeMemoryTable\0"
     984                              "DmiExposeProcInf\0"
    984985                              ))
    985986        return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,
     
    10891090    uuid.Gen.u16TimeHiAndVersion = RT_H2BE_U16(uuid.Gen.u16TimeHiAndVersion);
    10901091    rc = FwCommonPlantDMITable(pDevIns, pThis->au8DMIPage,
    1091                                VBOX_DMI_TABLE_SIZE, &uuid, pCfg);
     1092                               VBOX_DMI_TABLE_SIZE, &uuid, pCfg, pThis->cCpus);
    10921093    if (RT_FAILURE(rc))
    10931094        return rc;
  • trunk/src/VBox/Devices/PC/DevPcBios.h

    r34081 r39707  
    2222#define VBOX_DMI_TABLE_BASE         0xe1000
    2323#define VBOX_DMI_TABLE_VER          0x25
    24 #define VBOX_DMI_TABLE_ENTR         5
     24#define VBOX_DMI_TABLE_ENTR         8
    2525
    2626/** def VBOX_DMI_TABLE_SIZE
     
    3131 * the MPS table.
    3232 */
    33 #define VBOX_DMI_TABLE_SIZE         352
     33#define VBOX_DMI_TABLE_SIZE         496
    3434
    3535
Note: See TracChangeset for help on using the changeset viewer.

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