Allow for the sysinfo drivers to provide a system UUID to SMBIOS. Will
be first used by the IOT2050 boards.

Signed-off-by: Li Hua Qian <huaqian...@siemens.com>
Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>
Signed-off-by: Baocheng Su <baocheng...@siemens.com>

---

Changes in v3:
- use sysinfo_get_data to get the SMBios UUID bin
- s/strncpy/memcpy/ for the UUID bin

 include/sysinfo.h | 1 +
 lib/smbios.c      | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/include/sysinfo.h b/include/sysinfo.h
index ba2ac273e8e2..14e923c6589f 100644
--- a/include/sysinfo.h
+++ b/include/sysinfo.h
@@ -57,6 +57,7 @@ enum sysinfo_id {
        SYSID_SM_SYSTEM_WAKEUP,
        SYSID_SM_SYSTEM_SKU,
        SYSID_SM_SYSTEM_FAMILY,
+       SYSID_SM_SYSTEM_UUID,
 
        /* Baseboard (or Module) Information (Type 2) */
        SYSID_SM_BASEBOARD_MANUFACTURER,
diff --git a/lib/smbios.c b/lib/smbios.c
index 78cee8c0c264..7c9701a57f9d 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -429,6 +429,8 @@ static int smbios_write_type1(ulong *current, int handle,
        struct smbios_type1 *t;
        int len = sizeof(*t);
        char *serial_str = env_get("serial#");
+       size_t uuid_len;
+       void *uuid;
 
        t = map_sysmem(*current, len);
        memset(t, 0, len);
@@ -450,6 +452,10 @@ static int smbios_write_type1(ulong *current, int handle,
                                                      SYSID_SM_SYSTEM_SERIAL,
                                                      NULL);
        }
+       if (!sysinfo_get_data(ctx->dev, SYSID_SM_SYSTEM_UUID, &uuid,
+                             &uuid_len) &&
+           uuid_len == sizeof(t->uuid))
+               memcpy(t->uuid, uuid, sizeof(t->uuid));
        t->wakeup_type = smbios_get_val_si(ctx, "wakeup-type",
                                           SYSID_SM_SYSTEM_WAKEUP,
                                           SMBIOS_WAKEUP_TYPE_UNKNOWN);
-- 
2.39.5

Reply via email to