1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 3 #include <cbfs.h> 4 #include <device/device.h> 5 #include <smbios.h> 6 #include <string.h> 7 #include <uuid.h> 8 smbios_system_set_uuid(u8 * uuid)9void smbios_system_set_uuid(u8 *uuid) 10 { 11 /* Add 3 more bytes: 2 for possible CRLF and third for NULL char */ 12 char uuid_str[UUID_STRLEN + 3] = {0}; 13 uint8_t system_uuid[UUID_LEN]; 14 15 size_t uuid_len = cbfs_load("system_uuid", uuid_str, UUID_STRLEN); 16 17 if (uuid_len >= UUID_STRLEN && uuid_len <= UUID_STRLEN + 3) { 18 /* Cut off any trailing whitespace like CR or LF */ 19 uuid_str[UUID_STRLEN] = '\0'; 20 if (!parse_uuid(system_uuid, uuid_str)) 21 memcpy(uuid, system_uuid, UUID_LEN); 22 } 23 } 24