PhysicalMemory: detect ecc & bank locator

This commit is contained in:
李通洲
2024-05-12 19:55:04 +08:00
parent df6ab6427e
commit df2862996b
4 changed files with 28 additions and 13 deletions
@@ -9,10 +9,11 @@ typedef struct FFPhysicalMemoryResult
uint32_t runningSpeed; // MT/s
FFstrbuf type;
FFstrbuf formFactor;
FFstrbuf deviceLocator;
FFstrbuf locator;
FFstrbuf partNumber;
FFstrbuf vendor;
FFstrbuf serial;
bool ecc;
} FFPhysicalMemoryResult;
const char* ffDetectPhysicalMemory(FFlist* result); // list of FFPhysicalMemoryResult
@@ -12,15 +12,16 @@ static void appendDevice(
NSString* size,
// Intel only
NSString* deviceLocator,
NSString* locator,
NSString* serial,
NSString* partNumber,
NSString* speed)
NSString* speed,
bool ecc)
{
FFPhysicalMemoryResult* device = ffListAdd(result);
ffStrbufInitS(&device->type, type.UTF8String);
ffStrbufInit(&device->formFactor);
ffStrbufInitS(&device->deviceLocator, deviceLocator.UTF8String);
ffStrbufInitS(&device->locator, locator.UTF8String);
ffStrbufInitS(&device->vendor, vendor.UTF8String);
ffCleanUpSmbiosValue(&device->vendor);
ffStrbufInitS(&device->serial, serial.UTF8String);
@@ -30,6 +31,7 @@ static void appendDevice(
device->size = 0;
device->maxSpeed = 0;
device->runningSpeed = 0;
device->ecc = ecc;
if (size)
{
@@ -96,7 +98,8 @@ const char* ffDetectPhysicalMemory(FFlist* result)
item[@"_name"],
item[@"dimm_serial_number"],
item[@"dimm_part_number"],
item[@"dimm_speed"]);
item[@"dimm_speed"],
!![data[@"global_ecc_state"] isEqualToString:@"ecc_enabled"]);
}
}
else
@@ -109,7 +112,8 @@ const char* ffDetectPhysicalMemory(FFlist* result)
nil,
nil,
nil,
nil);
nil,
false);
}
}
@@ -85,13 +85,17 @@ const char* ffDetectPhysicalMemory(FFlist* result)
FFPhysicalMemoryResult* device = ffListAdd(result);
ffStrbufInit(&device->type);
ffStrbufInit(&device->formFactor);
ffStrbufInit(&device->deviceLocator);
ffStrbufInit(&device->locator);
ffStrbufInit(&device->vendor);
ffStrbufInit(&device->serial);
ffStrbufInit(&device->partNumber);
device->size = 0;
device->maxSpeed = 0;
device->runningSpeed = 0;
device->ecc = false;
if (data->TotalWidth != 0xFFFF && data->DataWidth != 0xFFFF)
device->ecc = data->TotalWidth > data->DataWidth;
if (data->Size != 0xFFFF)
{
@@ -109,8 +113,7 @@ const char* ffDetectPhysicalMemory(FFlist* result)
}
}
ffStrbufSetStatic(&device->deviceLocator, ffSmbiosLocateString(strings, data->DeviceLocator));
ffCleanUpSmbiosValue(&device->deviceLocator);
ffStrbufSetF(&device->locator, "%s/%s", ffSmbiosLocateString(strings, data->BankLocator), ffSmbiosLocateString(strings, data->DeviceLocator));
switch (data->FormFactor)
{
+11 -4
View File
@@ -6,7 +6,7 @@
#include "modules/physicalmemory/physicalmemory.h"
#include "util/stringUtils.h"
#define FF_PHYSICALMEMORY_NUM_FORMAT_ARGS 10
#define FF_PHYSICALMEMORY_NUM_FORMAT_ARGS 11
#define FF_PHYSICALMEMORY_DISPLAY_NAME "Physical Memory"
void ffPrintPhysicalMemory(FFPhysicalMemoryOptions* options)
@@ -40,7 +40,6 @@ void ffPrintPhysicalMemory(FFPhysicalMemoryOptions* options)
fputs(prettySize.chars, stdout);
fputs(" - ", stdout);
ffStrbufWriteTo(&device->type, stdout);
if (device->maxSpeed > 0)
printf("-%u", device->maxSpeed);
@@ -48,6 +47,8 @@ void ffPrintPhysicalMemory(FFPhysicalMemoryOptions* options)
printf(" at %u MT/s\n", device->runningSpeed);
if (device->vendor.length > 0)
printf(" (%s)", device->vendor.chars);
if (device->ecc)
fputs(" - ECC", stdout);
putchar('\n');
}
else
@@ -59,10 +60,11 @@ void ffPrintPhysicalMemory(FFPhysicalMemoryOptions* options)
{FF_FORMAT_ARG_TYPE_UINT, &device->runningSpeed},
{FF_FORMAT_ARG_TYPE_STRBUF, &device->type},
{FF_FORMAT_ARG_TYPE_STRBUF, &device->formFactor},
{FF_FORMAT_ARG_TYPE_DOUBLE, &device->deviceLocator},
{FF_FORMAT_ARG_TYPE_DOUBLE, &device->locator},
{FF_FORMAT_ARG_TYPE_STRBUF, &device->vendor},
{FF_FORMAT_ARG_TYPE_STRBUF, &device->serial},
{FF_FORMAT_ARG_TYPE_STRBUF, &device->partNumber},
{FF_FORMAT_ARG_TYPE_BOOL, &device->ecc},
}));
}
}
@@ -70,6 +72,7 @@ void ffPrintPhysicalMemory(FFPhysicalMemoryOptions* options)
FF_LIST_FOR_EACH(FFPhysicalMemoryResult, device, result)
{
ffStrbufDestroy(&device->type);
ffStrbufDestroy(&device->locator);
ffStrbufDestroy(&device->formFactor);
ffStrbufDestroy(&device->vendor);
ffStrbufDestroy(&device->serial);
@@ -131,15 +134,18 @@ void ffGeneratePhysicalMemoryJsonResult(FF_MAYBE_UNUSED FFPhysicalMemoryOptions*
yyjson_mut_obj_add_uint(doc, obj, "maxSpeed", device->maxSpeed);
yyjson_mut_obj_add_uint(doc, obj, "runningSpeed", device->runningSpeed);
yyjson_mut_obj_add_strbuf(doc, obj, "type", &device->type);
yyjson_mut_obj_add_strbuf(doc, obj, "locator", &device->locator);
yyjson_mut_obj_add_strbuf(doc, obj, "formFactor", &device->formFactor);
yyjson_mut_obj_add_strbuf(doc, obj, "vendor", &device->vendor);
yyjson_mut_obj_add_strbuf(doc, obj, "serial", &device->serial);
yyjson_mut_obj_add_strbuf(doc, obj, "partNumber", &device->partNumber);
yyjson_mut_obj_add_bool(doc, obj, "ecc", device->ecc);
}
FF_LIST_FOR_EACH(FFPhysicalMemoryResult, device, result)
{
ffStrbufDestroy(&device->type);
ffStrbufDestroy(&device->locator);
ffStrbufDestroy(&device->formFactor);
ffStrbufDestroy(&device->vendor);
ffStrbufDestroy(&device->serial);
@@ -156,10 +162,11 @@ void ffPrintPhysicalMemoryHelpFormat(void)
"Running speed (in MT/s)",
"Type (DDR4, DDR5, etc.)",
"Form factor (SODIMM, DIMM, etc.)",
"Device locator (SIMM1, SIMM2, etc.)",
"Bank/Device Locator (BANK0/SIMM0, BANK0/SIMM1, etc.)",
"Vendor",
"Serial number",
"Part number",
"ECC enabled",
}));
}