Tim Wawrzynczak has uploaded this change for review.

View Change

[RFC] Add new board configuration entry to coreboot tables

The new entry is intended to be the configuration entry to rule them
all, possibly deprecating the three separate "strapping ID" tables with
which it is slightly redundant with. In one entry, it should provide
enough information to give firmware the information it needs at runtime
to make decisions based on what kind of board it is or what is attached
to it, all in one place.

The new entry contains:
- Board ID
- DRAM ID (RAM code)
- SKU ID
- FW Config

Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Change-Id: I1ecec847ee77b72233587c1ad7f124e2027470bf
---
M payloads/libpayload/include/coreboot_tables.h
M src/commonlib/include/commonlib/coreboot_tables.h
M src/include/fw_config.h
M src/lib/coreboot_table.c
4 files changed, 59 insertions(+), 11 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/05/46605/1
diff --git a/payloads/libpayload/include/coreboot_tables.h b/payloads/libpayload/include/coreboot_tables.h
index bf8c0d9..fc10031 100644
--- a/payloads/libpayload/include/coreboot_tables.h
+++ b/payloads/libpayload/include/coreboot_tables.h
@@ -79,6 +79,7 @@
CB_TAG_MMC_INFO = 0x0035,
CB_TAG_TCPA_LOG = 0x0036,
CB_TAG_FMAP = 0x0037,
+ CB_TAG_BOARD_CONFIG = 0x0039,
CB_TAG_CMOS_OPTION_TABLE = 0x00c8,
CB_TAG_OPTION = 0x00c9,
CB_TAG_OPTION_ENUM = 0x00ca,
@@ -316,6 +317,16 @@
int32_t early_cmd1_status;
};

+struct cb_board_config {
+ uint32_t tag;
+ uint32_t size;
+
+ struct cbuint64 fw_config;
+ uint32_t board_id;
+ uint32_t dram_id;
+ uint32_t sku_id;
+};
+
#define CB_MAX_SERIALNO_LENGTH 32

struct cb_cmos_option_table {
diff --git a/src/commonlib/include/commonlib/coreboot_tables.h b/src/commonlib/include/commonlib/coreboot_tables.h
index 6393c01..4fb7318 100644
--- a/src/commonlib/include/commonlib/coreboot_tables.h
+++ b/src/commonlib/include/commonlib/coreboot_tables.h
@@ -80,6 +80,8 @@
LB_TAG_TCPA_LOG = 0x0036,
LB_TAG_FMAP = 0x0037,
LB_TAG_PLATFORM_BLOB_VERSION = 0x0038,
+ LB_TAG_BOARD_CONFIG = 0x0039,
+ /* The following options are CMOS-related */
LB_TAG_CMOS_OPTION_TABLE = 0x00c8,
LB_TAG_OPTION = 0x00c9,
LB_TAG_OPTION_ENUM = 0x00ca,
@@ -415,6 +417,16 @@
struct mac_address mac_addrs[0];
};

+struct lb_board_config {
+ uint32_t tag;
+ uint32_t size;
+
+ struct lb_uint64 fw_config;
+ uint32_t board_id;
+ uint32_t dram_id;
+ uint32_t sku_id;
+};
+
#define MAX_SERIALNO_LENGTH 32

/* The following structures are for the CMOS definitions table */
diff --git a/src/include/fw_config.h b/src/include/fw_config.h
index c9ef75f..7eaad7d 100644
--- a/src/include/fw_config.h
+++ b/src/include/fw_config.h
@@ -8,6 +8,8 @@
#include <stdbool.h>
#include <stdint.h>

+#define DEFAULT_FW_CONFIG (uint64_t)0
+
/**
* struct fw_config - Firmware configuration field and option.
* @field_name: Name of the field that this option belongs to.
diff --git a/src/lib/coreboot_table.c b/src/lib/coreboot_table.c
index 9148405..82b718a 100644
--- a/src/lib/coreboot_table.c
+++ b/src/lib/coreboot_table.c
@@ -1,22 +1,23 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#include <arch/cbconfig.h>
-#include <console/console.h>
-#include <console/uart.h>
-#include <ip_checksum.h>
+#include <boardid.h>
#include <boot/coreboot_tables.h>
#include <boot/tables.h>
#include <boot_device.h>
-#include <string.h>
-#include <version.h>
-#include <boardid.h>
-#include <device/device.h>
-#include <fmap.h>
-#include <stdlib.h>
-#include <cbfs.h>
-#include <cbmem.h>
#include <bootmem.h>
#include <bootsplash.h>
+#include <cbfs.h>
+#include <cbmem.h>
+#include <console/console.h>
+#include <console/uart.h>
+#include <device/device.h>
+#include <fmap.h>
+#include <fw_config.h>
+#include <ip_checksum.h>
+#include <stdlib.h>
+#include <string.h>
+#include <version.h>
#include <spi_flash.h>
#include <security/vboot/misc.h>
#include <security/vboot/vbnv_layout.h>
@@ -211,6 +212,7 @@
__weak uint32_t board_id(void) { return UNDEFINED_STRAPPING_ID; }
__weak uint32_t ram_code(void) { return UNDEFINED_STRAPPING_ID; }
__weak uint32_t sku_id(void) { return UNDEFINED_STRAPPING_ID; }
+__weak uint64_t fw_config_get(void) { return DEFAULT_FW_CONFIG; }

static void lb_board_id(struct lb_header *header)
{
@@ -368,6 +370,24 @@
return mainboard;
}

+static struct lb_board_config *lb_board_config(struct lb_header *header)
+{
+ struct lb_record *rec;
+ struct lb_board_config *config;
+ rec = lb_new_record(header);
+ config = (struct lb_board_config *)rec;
+
+ config->tag = LB_TAG_BOARD_CONFIG;
+ config->size = sizeof(*config);
+
+ config->board_id = board_id();
+ config->dram_id = ram_code();
+ config->sku_id = sku_id();
+ config->fw_config = pack_lb64(fw_config_get());
+
+ return config;
+}
+
#if CONFIG(USE_OPTION_TABLE)
static struct cmos_checksum *lb_cmos_checksum(struct lb_header *header)
{
@@ -557,6 +577,9 @@

lb_boot_media_params(head);

+ /* Board configuration information */
+ lb_board_config(head);
+
/* Add architecture records. */
lb_arch_add_records(head);


To view, visit change 46605. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I1ecec847ee77b72233587c1ad7f124e2027470bf
Gerrit-Change-Number: 46605
Gerrit-PatchSet: 1
Gerrit-Owner: Tim Wawrzynczak <twawrzynczak@chromium.org>
Gerrit-MessageType: newchange