dmi_platform_create
Description
The dmi_platform_create function creates a platform descriptor, which
tells the vendor, the product, the family and the generation of the platform
the SMBIOS data comes from:
struct dmi_platform
{
dmi_context_t *context;
dmi_vendor_t firmware_vendor;
dmi_vendor_t system_vendor;
dmi_vendor_t baseboard_vendor;
dmi_vendor_t processor_vendor;
char *product;
char *family;
unsigned generation;
};
The new platform has the vendors DMI_VENDOR_OTHER, no product name, no
family and an unknown generation, which is zero. The vendors and the
generation are plain values, which the caller sets directly, see
dmi_get_platform for their meaning. The product
name and the family code are owned by the platform, and are set with
dmi_platform_set_product and dmi_platform_set_family, which copy
them.
A context tells the platform of its data itself as it is opened, see
dmi_get_platform. A platform created by the caller is given to a
context with dmi_set_platform, which keeps a copy of it, so the caller
destroys the platform with dmi_platform_destroy whenever it is done
with it.
Examples
dmi_platform_t *platform = dmi_platform_create(context);
if (platform == nullptr)
return false;
platform->firmware_vendor = DMI_VENDOR_HPE;
platform->generation = DMI_HPE_GEN10;
bool success = dmi_platform_set_family(platform, DMI_HPE_FAMILY_SERVER) &&
dmi_set_platform(context, platform);
dmi_platform_destroy(platform);