lib/smbios: Improve Type9
[coreboot2.git] / src / drivers / generic / cbfs-uuid / cbfs-uuid.c
blobe657bdd922b3dbc6a91d826e073760f6f4f9ca2c
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <cbfs.h>
4 #include <device/device.h>
5 #include <smbios.h>
6 #include <string.h>
7 #include <uuid.h>
9 void smbios_system_set_uuid(u8 *uuid)
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];
15 size_t uuid_len = cbfs_load("system_uuid", uuid_str, UUID_STRLEN);
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);