I want to write a Linux kernel module that do stuff depending on the board vendor and product version.
In userspace, I could just read files under /sys/class/dmi/id/*
, but they are not available in kernel space.
I think I should collect data from UEFI SMBIOS table. Can I do it without hardcoding the exact memory address where each vendor uses to save the SMBIOS table?
I figured out by myself.
There's a library to access DMI and obtain these information:
#include <linux/dmi.h>
const char *board_vendor, *product_version;
board_vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
product_version = dmi_get_system_info(DMI_PRODUCT_VERSION);