From 68efcdd0ddeb43b471d05a2fcd4eb70b8ba85bdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 10 May 2024 23:47:15 +0800 Subject: [PATCH] PhysicalMemory: add new module --- CMakeLists.txt | 6 + src/common/modules.c | 1 + src/detection/physicalmemory/physicalmemory.h | 17 ++ .../physicalmemory/physicalmemory_nosupport.c | 6 + .../physicalmemory/physicalmemory_windows.c | 193 ++++++++++++++++++ src/modules/modules.h | 1 + src/modules/options.h | 1 + src/modules/physicalmemory/option.h | 12 ++ src/modules/physicalmemory/physicalmemory.c | 180 ++++++++++++++++ src/modules/physicalmemory/physicalmemory.h | 9 + src/options/modules.c | 2 + src/options/modules.h | 1 + 12 files changed, 429 insertions(+) create mode 100644 src/detection/physicalmemory/physicalmemory.h create mode 100644 src/detection/physicalmemory/physicalmemory_nosupport.c create mode 100644 src/detection/physicalmemory/physicalmemory_windows.c create mode 100644 src/modules/physicalmemory/option.h create mode 100644 src/modules/physicalmemory/physicalmemory.c create mode 100644 src/modules/physicalmemory/physicalmemory.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 8334482f6..3091d5bde 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -345,6 +345,7 @@ set(LIBFASTFETCH_SRC src/modules/os/os.c src/modules/packages/packages.c src/modules/physicaldisk/physicaldisk.c + src/modules/physicalmemory/physicalmemory.c src/modules/processes/processes.c src/modules/player/player.c src/modules/poweradapter/poweradapter.c @@ -400,6 +401,7 @@ if(LINUX) src/detection/bluetooth/bluetooth_linux.c src/detection/disk/disk_linux.c src/detection/physicaldisk/physicaldisk_linux.c + src/detection/physicalmemory/physicalmemory_nosupport.c src/detection/diskio/diskio_linux.c src/detection/displayserver/linux/displayserver_linux.c src/detection/displayserver/linux/drm.c @@ -466,6 +468,7 @@ elseif(ANDROID) src/detection/cpuusage/cpuusage_linux.c src/detection/disk/disk_linux.c src/detection/physicaldisk/physicaldisk_linux.c + src/detection/physicalmemory/physicalmemory_nosupport.c src/detection/diskio/diskio_linux.c src/detection/displayserver/displayserver_android.c src/detection/font/font_nosupport.c @@ -523,6 +526,7 @@ elseif(BSD) src/detection/cursor/cursor_linux.c src/detection/disk/disk_bsd.c src/detection/physicaldisk/physicaldisk_bsd.c + src/detection/physicalmemory/physicalmemory_nosupport.c src/detection/diskio/diskio_bsd.c src/detection/displayserver/linux/displayserver_linux.c src/detection/displayserver/linux/drm.c @@ -590,6 +594,7 @@ elseif(APPLE) src/detection/cursor/cursor_apple.m src/detection/disk/disk_bsd.c src/detection/physicaldisk/physicaldisk_apple.c + src/detection/physicalmemory/physicalmemory_nosupport.c src/detection/diskio/diskio_apple.c src/detection/displayserver/displayserver_apple.c src/detection/font/font_apple.m @@ -662,6 +667,7 @@ elseif(WIN32) src/detection/gamepad/gamepad_windows.c src/detection/media/media_nosupport.c src/detection/memory/memory_windows.c + src/detection/physicalmemory/physicalmemory_windows.c src/detection/monitor/monitor_windows.c src/detection/netio/netio_windows.c src/detection/opengl/opengl_windows.c diff --git a/src/common/modules.c b/src/common/modules.c index 1c4d43e4f..ea9958eb3 100644 --- a/src/common/modules.c +++ b/src/common/modules.c @@ -99,6 +99,7 @@ static FFModuleBaseInfo* O[] = { static FFModuleBaseInfo* P[] = { (void*) &instance.config.modules.packages, (void*) &instance.config.modules.physicalDisk, + (void*) &instance.config.modules.physicalMemory, (void*) &instance.config.modules.player, (void*) &instance.config.modules.powerAdapter, (void*) &instance.config.modules.processes, diff --git a/src/detection/physicalmemory/physicalmemory.h b/src/detection/physicalmemory/physicalmemory.h new file mode 100644 index 000000000..08e783a22 --- /dev/null +++ b/src/detection/physicalmemory/physicalmemory.h @@ -0,0 +1,17 @@ +#pragma once + +#include "fastfetch.h" + +typedef struct FFPhysicalMemoryResult +{ + uint64_t size; // B + uint32_t maxSpeed; // MT/s + uint32_t runningSpeed; // MT/s + FFstrbuf type; + FFstrbuf formFactor; + FFstrbuf deviceLocator; + FFstrbuf vendor; + FFstrbuf serial; +} FFPhysicalMemoryResult; + +const char* ffDetectPhysicalMemory(FFlist* result); // list of FFPhysicalMemoryResult diff --git a/src/detection/physicalmemory/physicalmemory_nosupport.c b/src/detection/physicalmemory/physicalmemory_nosupport.c new file mode 100644 index 000000000..a035753d7 --- /dev/null +++ b/src/detection/physicalmemory/physicalmemory_nosupport.c @@ -0,0 +1,6 @@ +#include "physicalmemory.h" + +const char* ffDetectPhysicalMemory(FF_MAYBE_UNUSED FFlist* result) +{ + return "Not supported on this platform"; +} diff --git a/src/detection/physicalmemory/physicalmemory_windows.c b/src/detection/physicalmemory/physicalmemory_windows.c new file mode 100644 index 000000000..0426d72c7 --- /dev/null +++ b/src/detection/physicalmemory/physicalmemory_windows.c @@ -0,0 +1,193 @@ +#include "physicalmemory.h" +#include "util/smbiosHelper.h" + +// 7.18 +typedef struct FFSmbiosMemoryDevice +{ + FFSmbiosHeader Header; + + // 2.1+ + uint16_t PhysicalMemoryArrayHandle; // varies + uint16_t MemoryErrorInformationHandle; //varies + uint16_t TotalWidth; // varies + uint16_t DataWidth; // varies + uint16_t Size; // varies + uint8_t FormFactor; // enum + uint8_t DeviceSet; // varies + uint8_t DeviceLocator; // string + uint8_t BankLocator; // string + uint8_t MemoryType; // enum + uint16_t TypeDetail; // bit field + + // 2.3+ + uint16_t Speed; // varies + uint8_t Manufacturer; // string + uint8_t SerialNumber; // string + uint8_t AssetTag; // string + uint8_t PartNumber; // string + + // 2.6+ + uint8_t Attributes; // varies + + // 2.7+ + uint32_t ExtendedSize; // varies + uint16_t ConfiguredMemorySpeed; // varies + + // 2.8+ + uint16_t MinimumVoltage; // varies + uint16_t MaximumVoltage; // varies + uint16_t ConfiguredVoltage; // varies + + // 3.2+ + uint8_t MemoryTechnology; // varies + uint16_t MemoryOperatingMode; // bit field + uint8_t FirmwareVersion; // string + uint16_t ModuleManufacturerID; // varies + uint16_t ModuleProductID; // varies + uint16_t MemorySubsystemControllerManufacturerID; // vaies + uint16_t MemorySubsystemControllerProductID; // varies + uint64_t NonVolatileSize; // varies + uint64_t VolatileSize; // varies + uint64_t CacheSize; // varies + uint64_t LogicalSize; // varies + + // 3.3+ + uint32_t ExtendedSpeed; // varies + uint32_t ExtendedConfiguredSpeed; // varies + + // 3.7+ + uint16_t Pmic0ManufacturerID; // varies + uint16_t Pmic0RevisionNumber; // varies + uint16_t RcdManufacturerID; // varies + uint16_t RcdRevisionNumber; // varies +} __attribute__((__packed__)) FFSmbiosMemoryDevice; + +static_assert(offsetof(FFSmbiosMemoryDevice, RcdRevisionNumber) == 0x62, + "FFSmbiosMemoryDevice: Wrong struct alignment"); + +const char* ffDetectPhysicalMemory(FFlist* result) +{ + const FFSmbiosMemoryDevice* data = (const FFSmbiosMemoryDevice*) (*ffGetSmbiosHeaderTable())[FF_SMBIOS_TYPE_MEMORY_DEVICE]; + if (!data) + return "System enclosure is not found in SMBIOS data"; + + for (; data->Header.Type == FF_SMBIOS_TYPE_MEMORY_DEVICE; + data = (const FFSmbiosMemoryDevice*) ffSmbiosNextEntry(&data->Header)) + { + if (data->Size == 0) continue; + + const char* strings = (const char*) data + data->Header.Length; + + FFPhysicalMemoryResult* device = ffListAdd(result); + ffStrbufInit(&device->type); + ffStrbufInit(&device->formFactor); + ffStrbufInit(&device->deviceLocator); + ffStrbufInit(&device->vendor); + ffStrbufInit(&device->serial); + device->size = 0; + device->maxSpeed = 0; + device->runningSpeed = 0; + + if (data->Size != 0xFFFF) + { + if (data->Size == 0x7FFF) + device->size = (data->ExtendedSize & ~(1 << 31)) * 1024 * 1024; + else if (data->Size & (1 << 15)) + { + // in kB + device->size = (data->Size & ~(1u << 15)) * 1024ULL; + } + else + { + // in MB + device->size = data->Size * 1024ULL * 1024ULL; + } + } + + ffStrbufSetStatic(&device->deviceLocator, ffSmbiosLocateString(strings, data->DeviceLocator)); + ffCleanUpSmbiosValue(&device->deviceLocator); + + switch (data->FormFactor) + { + case 0x01: ffStrbufSetStatic(&device->formFactor, "Other"); break; + case 0x02: ffStrbufSetStatic(&device->formFactor, "Unknown"); break; + case 0x03: ffStrbufSetStatic(&device->formFactor, "SIMM"); break; + case 0x04: ffStrbufSetStatic(&device->formFactor, "SIP"); break; + case 0x05: ffStrbufSetStatic(&device->formFactor, "Chip"); break; + case 0x06: ffStrbufSetStatic(&device->formFactor, "DIP"); break; + case 0x07: ffStrbufSetStatic(&device->formFactor, "ZIP"); break; + case 0x08: ffStrbufSetStatic(&device->formFactor, "Proprietary Card"); break; + case 0x09: ffStrbufSetStatic(&device->formFactor, "DIMM"); break; + case 0x0A: ffStrbufSetStatic(&device->formFactor, "TSOP"); break; + case 0x0B: ffStrbufSetStatic(&device->formFactor, "Row of chips"); break; + case 0x0C: ffStrbufSetStatic(&device->formFactor, "RIMM"); break; + case 0x0D: ffStrbufSetStatic(&device->formFactor, "SODIMM"); break; + case 0x0E: ffStrbufSetStatic(&device->formFactor, "SRIMM"); break; + case 0x0F: ffStrbufSetStatic(&device->formFactor, "FBDIMM"); break; + case 0x10: ffStrbufSetStatic(&device->formFactor, "Die"); break; + default: ffStrbufSetF(&device->formFactor, "Unknown (%d)", (int) data->FormFactor); break; + } + + switch (data->MemoryType) + { + case 0x01: ffStrbufSetStatic(&device->type, "Other"); break; + case 0x02: ffStrbufSetStatic(&device->type, "Unknown"); break; + case 0x03: ffStrbufSetStatic(&device->type, "DRAM"); break; + case 0x04: ffStrbufSetStatic(&device->type, "EDRAM"); break; + case 0x05: ffStrbufSetStatic(&device->type, "VRAM"); break; + case 0x06: ffStrbufSetStatic(&device->type, "SRAM"); break; + case 0x07: ffStrbufSetStatic(&device->type, "RAM"); break; + case 0x08: ffStrbufSetStatic(&device->type, "ROM"); break; + case 0x09: ffStrbufSetStatic(&device->type, "FLASH"); break; + case 0x0A: ffStrbufSetStatic(&device->type, "EEPROM"); break; + case 0x0B: ffStrbufSetStatic(&device->type, "FEPROM"); break; + case 0x0C: ffStrbufSetStatic(&device->type, "EPROM"); break; + case 0x0D: ffStrbufSetStatic(&device->type, "CDRAM"); break; + case 0x0E: ffStrbufSetStatic(&device->type, "3DRAM"); break; + case 0x0F: ffStrbufSetStatic(&device->type, "SDRAM"); break; + case 0x10: ffStrbufSetStatic(&device->type, "SGRAM"); break; + case 0x11: ffStrbufSetStatic(&device->type, "RDRAM"); break; + case 0x12: ffStrbufSetStatic(&device->type, "DDR"); break; + case 0x13: ffStrbufSetStatic(&device->type, "DDR2"); break; + case 0x14: ffStrbufSetStatic(&device->type, "DDR2 FB-DIMM"); break; + case 0x15: + case 0x16: + case 0x17: ffStrbufSetStatic(&device->type, "Reserved"); break; + case 0x18: ffStrbufSetStatic(&device->type, "DDR3"); break; + case 0x19: ffStrbufSetStatic(&device->type, "FBD2"); break; + case 0x1A: ffStrbufSetStatic(&device->type, "DDR4"); break; + case 0x1B: ffStrbufSetStatic(&device->type, "LPDDR"); break; + case 0x1C: ffStrbufSetStatic(&device->type, "LPDDR2"); break; + case 0x1D: ffStrbufSetStatic(&device->type, "LPDDR3"); break; + case 0x1E: ffStrbufSetStatic(&device->type, "LPDDR4"); break; + case 0x1F: ffStrbufSetStatic(&device->type, "Logical non-volatile device"); break; + case 0x20: ffStrbufSetStatic(&device->type, "HBM"); break; + case 0x21: ffStrbufSetStatic(&device->type, "HBM2"); break; + case 0x22: ffStrbufSetStatic(&device->type, "DDR5"); break; + case 0x23: ffStrbufSetStatic(&device->type, "LPDDR5"); break; + case 0x24: ffStrbufSetStatic(&device->type, "HBM3"); break; + default: ffStrbufSetF(&device->type, "Unknown (%d)", (int) data->MemoryType); break; + } + + if (data->Header.Length > offsetof(FFSmbiosMemoryDevice, Speed)) // 2.3+ + { + if (data->Speed) + device->maxSpeed = data->Speed == 0xFFFF ? data->ExtendedSpeed : data->Speed; + + ffStrbufSetStatic(&device->vendor, ffSmbiosLocateString(strings, data->Manufacturer)); + ffCleanUpSmbiosValue(&device->vendor); + + ffStrbufSetStatic(&device->serial, ffSmbiosLocateString(strings, data->SerialNumber)); + ffCleanUpSmbiosValue(&device->serial); + } + + if (data->Header.Length > offsetof(FFSmbiosMemoryDevice, ConfiguredMemorySpeed)) // 2.7+ + { + if (data->ConfiguredMemorySpeed) + device->runningSpeed = data->ConfiguredMemorySpeed == 0xFFFF + ? data->ExtendedConfiguredSpeed : data->ConfiguredMemorySpeed; + } + } + + return NULL; +} diff --git a/src/modules/modules.h b/src/modules/modules.h index cfff529c9..7bb11f8b2 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -40,6 +40,7 @@ #include "modules/os/os.h" #include "modules/packages/packages.h" #include "modules/physicaldisk/physicaldisk.h" +#include "modules/physicalmemory/physicalmemory.h" #include "modules/player/player.h" #include "modules/poweradapter/poweradapter.h" #include "modules/processes/processes.h" diff --git a/src/modules/options.h b/src/modules/options.h index af4ec7e99..cfcf931d0 100644 --- a/src/modules/options.h +++ b/src/modules/options.h @@ -40,6 +40,7 @@ #include "modules/os/option.h" #include "modules/packages/option.h" #include "modules/physicaldisk/option.h" +#include "modules/physicalmemory/option.h" #include "modules/player/option.h" #include "modules/poweradapter/option.h" #include "modules/processes/option.h" diff --git a/src/modules/physicalmemory/option.h b/src/modules/physicalmemory/option.h new file mode 100644 index 000000000..96ebccc57 --- /dev/null +++ b/src/modules/physicalmemory/option.h @@ -0,0 +1,12 @@ +#pragma once + +// This file will be included in "fastfetch.h", do NOT put unnecessary things here + +#include "common/option.h" +#include "common/percent.h" + +typedef struct FFPhysicalMemoryOptions +{ + FFModuleBaseInfo moduleInfo; + FFModuleArgs moduleArgs; +} FFPhysicalMemoryOptions; diff --git a/src/modules/physicalmemory/physicalmemory.c b/src/modules/physicalmemory/physicalmemory.c new file mode 100644 index 000000000..faabab6ff --- /dev/null +++ b/src/modules/physicalmemory/physicalmemory.c @@ -0,0 +1,180 @@ +#include "common/printing.h" +#include "common/jsonconfig.h" +#include "common/parsing.h" +#include "common/percent.h" +#include "detection/physicalmemory/physicalmemory.h" +#include "modules/physicalmemory/physicalmemory.h" +#include "util/stringUtils.h" + +#define FF_PHYSICALMEMORY_NUM_FORMAT_ARGS 9 +#define FF_PHYSICALMEMORY_DISPLAY_NAME "Physical Memory" + +void ffPrintPhysicalMemory(FFPhysicalMemoryOptions* options) +{ + FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFPhysicalMemoryResult)); + const char* error = ffDetectPhysicalMemory(&result); + + if(error) + { + ffPrintError(FF_PHYSICALMEMORY_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error); + return; + } + + FF_STRBUF_AUTO_DESTROY prettySize = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY key = ffStrbufCreate(); + + uint32_t i = 0; + FF_LIST_FOR_EACH(FFPhysicalMemoryResult, device, result) + { + ++i; + ffStrbufClear(&prettySize); + ffParseSize(device->size, &prettySize); + + if(options->moduleArgs.key.length == 0) + { + ffStrbufSetF(&key, "%s (%s %s-%u)", FF_PHYSICALMEMORY_DISPLAY_NAME, device->vendor.chars, device->type.chars, device->maxSpeed); + } + else + { + FF_PARSE_FORMAT_STRING_CHECKED(&key, &options->moduleArgs.key, 5, ((FFformatarg[]){ + {FF_FORMAT_ARG_TYPE_UINT, &i}, + {FF_FORMAT_ARG_TYPE_STRBUF, &device->vendor}, + {FF_FORMAT_ARG_TYPE_STRBUF, &device->type}, + {FF_FORMAT_ARG_TYPE_UINT, &device->maxSpeed}, + {FF_FORMAT_ARG_TYPE_STRBUF, &device->deviceLocator}, + })); + } + + if (options->moduleArgs.outputFormat.length == 0) + { + ffPrintLogoAndKey(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); + printf("%s, running at %u MT/s\n", prettySize.chars, device->runningSpeed); + } + else + { + FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_PHYSICALMEMORY_NUM_FORMAT_ARGS, ((FFformatarg[]) { + {FF_FORMAT_ARG_TYPE_UINT64, &device->size}, + {FF_FORMAT_ARG_TYPE_STRBUF, &prettySize}, + {FF_FORMAT_ARG_TYPE_UINT, &device->maxSpeed}, + {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_STRBUF, &device->vendor}, + {FF_FORMAT_ARG_TYPE_STRBUF, &device->serial}, + })); + } + } + + FF_LIST_FOR_EACH(FFPhysicalMemoryResult, device, result) + { + ffStrbufDestroy(&device->type); + ffStrbufDestroy(&device->formFactor); + ffStrbufDestroy(&device->vendor); + ffStrbufDestroy(&device->serial); + } +} + +bool ffParsePhysicalMemoryCommandOptions(FFPhysicalMemoryOptions* options, const char* key, const char* value) +{ + const char* subKey = ffOptionTestPrefix(key, FF_PHYSICALMEMORY_MODULE_NAME); + if (!subKey) return false; + if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) + return true; + + return false; +} + +void ffParsePhysicalMemoryJsonObject(FFPhysicalMemoryOptions* options, yyjson_val* module) +{ + yyjson_val *key_, *val; + size_t idx, max; + yyjson_obj_foreach(module, idx, max, key_, val) + { + const char* key = yyjson_get_str(key_); + if(ffStrEqualsIgnCase(key, "type")) + continue; + + if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) + continue; + + ffPrintError(FF_PHYSICALMEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key); + } +} + +void ffGeneratePhysicalMemoryJsonConfig(FFPhysicalMemoryOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) +{ + __attribute__((__cleanup__(ffDestroyPhysicalMemoryOptions))) FFPhysicalMemoryOptions defaultOptions; + ffInitPhysicalMemoryOptions(&defaultOptions); + + ffJsonConfigGenerateModuleArgsConfig(doc, module, &defaultOptions.moduleArgs, &options->moduleArgs); +} + +void ffGeneratePhysicalMemoryJsonResult(FF_MAYBE_UNUSED FFPhysicalMemoryOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) +{ + FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFPhysicalMemoryResult)); + const char* error = ffDetectPhysicalMemory(&result); + + if(error) + { + yyjson_mut_obj_add_str(doc, module, "error", error); + return; + } + + yyjson_mut_val* arr = yyjson_mut_obj_add_arr(doc, module, "result"); + FF_LIST_FOR_EACH(FFPhysicalMemoryResult, device, result) + { + yyjson_mut_val* obj = yyjson_mut_arr_add_obj(doc, arr); + yyjson_mut_obj_add_uint(doc, obj, "size", device->size); + 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, "formFactor", &device->formFactor); + yyjson_mut_obj_add_strbuf(doc, obj, "vendor", &device->vendor); + yyjson_mut_obj_add_strbuf(doc, obj, "serial", &device->serial); + } + + FF_LIST_FOR_EACH(FFPhysicalMemoryResult, device, result) + { + ffStrbufDestroy(&device->type); + ffStrbufDestroy(&device->formFactor); + ffStrbufDestroy(&device->vendor); + ffStrbufDestroy(&device->serial); + } +} + +void ffPrintPhysicalMemoryHelpFormat(void) +{ + FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_PHYSICALMEMORY_MODULE_NAME, "{7} {5}-{3}: {2}, running at {4} MT/s", FF_PHYSICALMEMORY_NUM_FORMAT_ARGS, ((const char* []) { + "Size (in bytes)", + "Size formatted", + "Max speed (in MT/s)", + "Running speed (in MT/s)", + "Type (DDR4, DDR5, etc.)", + "Form factor (SODIMM, DIMM, etc.)", + "Device locator (SIMM1, SIMM2, etc.)", + "Vendor", + "Serial number", + })); +} + +void ffInitPhysicalMemoryOptions(FFPhysicalMemoryOptions* options) +{ + ffOptionInitModuleBaseInfo( + &options->moduleInfo, + FF_PHYSICALMEMORY_MODULE_NAME, + "Print system physical memory devices", + ffParsePhysicalMemoryCommandOptions, + ffParsePhysicalMemoryJsonObject, + ffPrintPhysicalMemory, + ffGeneratePhysicalMemoryJsonResult, + ffPrintPhysicalMemoryHelpFormat, + ffGeneratePhysicalMemoryJsonConfig + ); + ffOptionInitModuleArg(&options->moduleArgs); +} + +void ffDestroyPhysicalMemoryOptions(FFPhysicalMemoryOptions* options) +{ + ffOptionDestroyModuleArg(&options->moduleArgs); +} diff --git a/src/modules/physicalmemory/physicalmemory.h b/src/modules/physicalmemory/physicalmemory.h new file mode 100644 index 000000000..c9e0048d1 --- /dev/null +++ b/src/modules/physicalmemory/physicalmemory.h @@ -0,0 +1,9 @@ +#pragma once + +#include "fastfetch.h" + +#define FF_PHYSICALMEMORY_MODULE_NAME "PhysicalMemory" + +void ffPrintPhysicalMemory(FFPhysicalMemoryOptions* options); +void ffInitPhysicalMemoryOptions(FFPhysicalMemoryOptions* options); +void ffDestroyPhysicalMemoryOptions(FFPhysicalMemoryOptions* options); diff --git a/src/options/modules.c b/src/options/modules.c index a64ca5ef9..d3a501c32 100644 --- a/src/options/modules.c +++ b/src/options/modules.c @@ -41,6 +41,7 @@ void ffOptionsInitModules(FFOptionsModules* options) ffInitOpenGLOptions(&options->openGL); ffInitPackagesOptions(&options->packages); ffInitPhysicalDiskOptions(&options->physicalDisk); + ffInitPhysicalMemoryOptions(&options->physicalMemory); ffInitPlayerOptions(&options->player); ffInitPowerAdapterOptions(&options->powerAdapter); ffInitProcessesOptions(&options->processes); @@ -105,6 +106,7 @@ void ffOptionsDestroyModules(FFOptionsModules* options) ffDestroyOpenCLOptions(&options->openCL); ffDestroyOpenGLOptions(&options->openGL); ffDestroyPhysicalDiskOptions(&options->physicalDisk); + ffDestroyPhysicalMemoryOptions(&options->physicalMemory); ffDestroyPackagesOptions(&options->packages); ffDestroyPlayerOptions(&options->player); ffDestroyPowerAdapterOptions(&options->powerAdapter); diff --git a/src/options/modules.h b/src/options/modules.h index d04f65071..dcd6e5bdc 100644 --- a/src/options/modules.h +++ b/src/options/modules.h @@ -42,6 +42,7 @@ typedef struct FFOptionsModules FFOpenGLOptions openGL; FFPackagesOptions packages; FFPhysicalDiskOptions physicalDisk; + FFPhysicalMemoryOptions physicalMemory; FFPlayerOptions player; FFPowerAdapterOptions powerAdapter; FFProcessesOptions processes;