Debian Codegraph @

src/vendorcode/google/chromeos/vpd_serialno.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <boot/coreboot_tables.h>
4 #include <console/console.h>
5 #include <assert.h>
6 #include <string.h>
7
8 #include <drivers/vpd/vpd.h>
9
10 void lb_table_add_serialno_from_vpd(struct lb_header *header)
11 {
12 struct lb_string *serialno_rec = NULL;
13 const char serialno_key[] = "serial_number";
14 char serialno[32];
15 size_t len;
16
17 if (!vpd_gets(serialno_key, serialno,
18 sizeof(serialno), VPD_RO_THEN_RW)) {
19 printk(BIOS_ERR, "no serial number in vpd\n");
20 return;
21 }
22 printk(BIOS_DEBUG, "serial number is %s\n", serialno);
23 len = strlen(serialno) + 1;
24 ASSERT(len <= 32);
25
26 serialno_rec = (struct lb_string *)lb_new_record(header);
27 serialno_rec->tag = LB_TAG_SERIALNO;
28
29 serialno_rec->size = ALIGN_UP(sizeof(*serialno_rec) + len, 8);
30 memcpy(&serialno_rec->string, serialno, len);
31 }