VirtualBox

Changeset 28568 in vbox


Ignore:
Timestamp:
Apr 21, 2010 4:30:36 PM (15 years ago)
Author:
vboxsync
Message:

DMI: provide memory info structures

File:
1 edited

Legend:

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

    r28424 r28568  
    222222} *PDMIOEMSTRINGS;
    223223AssertCompileSize(DMIOEMSTRINGS, 0x7);
     224
     225/** Physical memory array (Type 16) */
     226typedef struct DMIRAMARRAY
     227{
     228    DMIHDR          header;
     229    uint8_t         u8Location;
     230    uint8_t         u8Use;
     231    uint8_t         u8MemErrorCorrection;
     232    uint32_t        u32MaxCapacity;
     233    uint16_t        u16MemErrorHandle;
     234    uint16_t        u16NumberOfMemDevices;
     235} *PDMIRAMARRAY;
     236AssertCompileSize(DMIRAMARRAY, 15);
     237
     238/** DMI Memory Device (Type 17) */
     239typedef struct DMIMEMORYDEV
     240{
     241    DMIHDR          header;
     242    uint16_t        u16PhysMemArrayHandle;
     243    uint16_t        u16MemErrHandle;
     244    uint16_t        u16TotalWidth;
     245    uint16_t        u16DataWidth;
     246    uint16_t        u16Size;
     247    uint8_t         u8FormFactor;
     248    uint8_t         u8DeviceSet;
     249    uint8_t         u8DeviceLocator;
     250    uint8_t         u8BankLocator;
     251    uint8_t         u8MemoryType;
     252    uint16_t        u16TypeDetail;
     253    uint16_t        u16Speed;
     254    uint8_t         u8Manufacturer;
     255    uint8_t         u8SerialNumber;
     256    uint8_t         u8AssetTag;
     257    uint8_t         u8PartNumber;
     258    /* v2.6+ */
     259    uint8_t         u8Attributes;
     260} *PDMIMEMORYDEV;
     261AssertCompileSize(DMIMEMORYDEV, 28);
    224262
    225263/** MPS floating pointer structure */
     
    436474    }
    437475
     476#define START_STRUCT(tbl)                                       \
     477        pszStr                       = (char *)(tbl + 1);       \
     478        iStrNr                       = 1;   
     479
    438480#define TERM_STRUCT \
    439481    { \
     
    629671        TERM_STRUCT;
    630672
     673
     674        /***************************************
     675         * DMI Physical Memory Array (Type 16) *
     676         ***************************************/
     677        uint64_t u64RamSize;
     678        rc = CFGMR3QueryU64(pCfg, "RamSize", &u64RamSize);
     679        if (RT_FAILURE (rc))
     680            return PDMDEV_SET_ERROR(pDevIns, rc,
     681                                N_("Configuration error: Failed to read \"RamSize\""));
     682
     683        PDMIRAMARRAY pMemArray = (PDMIRAMARRAY)pszStr;
     684        CHECKSIZE(sizeof(*pMemArray));
     685
     686        START_STRUCT(pMemArray);
     687        pMemArray->header.u8Type    = 16; /* Physical Memory Array */
     688        pMemArray->header.u8Length  = sizeof(*pMemArray);
     689        pMemArray->header.u16Handle = 0x0005;
     690        pMemArray->u8Location = 0x03; /* Motherboard */
     691        pMemArray->u8Use = 0x03; /* System memory */
     692        pMemArray->u8MemErrorCorrection = 0x01; /* Other */       
     693        uint32_t u32RamSizeK = (uint32_t)(u64RamSize / _1K);
     694        pMemArray->u32MaxCapacity = u32RamSizeK; /* RAM size in K */
     695        pMemArray->u16MemErrorHandle = 0xfffe; /* No error info structure */
     696        pMemArray->u16NumberOfMemDevices = 1;
     697        TERM_STRUCT;
     698
     699        /***************************************
     700         * DMI Memory Device (Type 17)         *
     701         ***************************************/
     702        PDMIMEMORYDEV pMemDev = (PDMIMEMORYDEV)pszStr;
     703        CHECKSIZE(sizeof(*pMemDev));
     704
     705        START_STRUCT(pMemDev);
     706        pMemDev->header.u8Type    = 17; /* Memory Device */
     707        pMemDev->header.u8Length  = sizeof(*pMemDev);
     708        pMemDev->header.u16Handle = 0x0006;
     709        pMemDev->u16PhysMemArrayHandle = 0x0005; /* handle of array we belong to */
     710        pMemDev->u16MemErrHandle = 0xfffe; /* system doesn't provide this information */
     711        pMemDev->u16TotalWidth = 0xffff; /* Unknown */
     712        pMemDev->u16DataWidth = 0xffff;  /* Unknown */
     713        int16_t u16RamSizeM = (uint16_t)(u64RamSize / _1M);
     714        if (u16RamSizeM == 0)
     715            u16RamSizeM = 0x400; /* 1G */
     716        pMemDev->u16Size = u16RamSizeM; /* RAM size */
     717        pMemDev->u8FormFactor = 0x09; /* DIMM */
     718        pMemDev->u8DeviceSet = 0x00; /* Not part of a device set */
     719        READCFGSTRDEF(pMemDev->u8DeviceLocator, " ", "DIMM 0");
     720        READCFGSTRDEF(pMemDev->u8BankLocator, " ", "Bank 0");
     721        pMemDev->u8MemoryType = 0x03; /* DRAM */
     722        pMemDev->u16TypeDetail = 0; /* Nothing special */
     723        pMemDev->u16Speed = 1600; /* Unknown, shall be speed in MHz */
     724        READCFGSTR(pMemDev->u8Manufacturer, DmiSystemVendor);
     725        READCFGSTRDEF(pMemDev->u8SerialNumber, " ", "00000000");
     726        READCFGSTRDEF(pMemDev->u8AssetTag, " ", "00000000");
     727        READCFGSTRDEF(pMemDev->u8PartNumber, " ", "00000000");
     728        pMemDev->u8Attributes = 0; /* Unknown */
     729        TERM_STRUCT;
     730
    631731        /*****************************
    632732         * DMI OEM strings (Type 11) *
     
    885985    PDMDevHlpPhysWrite(pDevIns, 0x9fff0, &floatPtr, 16);
    886986}
    887 
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