[coreboot-gerrit] Patch set updated for coreboot: cbtable: describe boot media
Patrick Georgi (pgeorgi@google.com)
gerrit at coreboot.org
Tue Jul 14 18:52:03 CEST 2015
Patrick Georgi (pgeorgi at google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10867
-gerrit
commit 400b1517f55b34ab5afd753fb2ba526f266e7fcf
Author: Patrick Georgi <pgeorgi at chromium.org>
Date: Tue Jul 14 17:15:51 2015 +0100
cbtable: describe boot media
This allows finding the currently used CBFS (in case there are several), and
avoids the need to define flash size when building the payload.
Change-Id: I4b00159610077761c501507e136407e9ae08c73e
Signed-off-by: Aaron Durbin <adurbin at chromium.org>
Signed-off-by: Patrick Georgi <pgeorgi at chromium.org>
---
src/include/boot/coreboot_tables.h | 14 ++++++
src/lib/coreboot_table.c | 27 +++++++++++
src/vendorcode/google/chromeos/vboot2/Makefile.inc | 1 +
src/vendorcode/google/chromeos/vboot2/cbtable.c | 55 ++++++++++++++++++++++
4 files changed, 97 insertions(+)
diff --git a/src/include/boot/coreboot_tables.h b/src/include/boot/coreboot_tables.h
index c8d5251..d1a63a8 100644
--- a/src/include/boot/coreboot_tables.h
+++ b/src/include/boot/coreboot_tables.h
@@ -297,6 +297,17 @@ struct lb_spi_flash {
uint32_t erase_cmd;
};
+#define LB_TAG_BOOT_MEDIA_PARAMS 0x0030
+struct lb_boot_media_params {
+ uint32_t tag;
+ uint32_t size;
+ /* offsets are relative to start of boot media */
+ uint32_t fmap_offset;
+ uint32_t cbfs_offset;
+ uint32_t cbfs_size;
+ uint32_t boot_media_size;
+};
+
#define LB_TAG_SERIALNO 0x002a
#define MAX_SERIALNO_LENGTH 32
@@ -390,6 +401,9 @@ void lb_add_console(uint16_t consoletype, void *data);
/* Define this in mainboard.c to add board-specific table entries. */
void lb_board(struct lb_header *header);
+/* Define this to add information which sub-CBFS to use. */
+void lb_boot_media_params(struct lb_header *header);
+
/*
* Function to retrieve MAC address(es) from the VPD and store them in the
* coreboot table.
diff --git a/src/lib/coreboot_table.c b/src/lib/coreboot_table.c
index f7fb2bb..b03d748 100644
--- a/src/lib/coreboot_table.c
+++ b/src/lib/coreboot_table.c
@@ -27,6 +27,7 @@
#include <version.h>
#include <boardid.h>
#include <device/device.h>
+#include <fmap.h>
#include <stdlib.h>
#include <cbfs.h>
#include <cbmem.h>
@@ -228,6 +229,30 @@ static void lb_board_id(struct lb_header *header)
#endif
}
+
+void __attribute__((weak)) lb_boot_media_params(struct lb_header *header)
+{
+ struct lb_boot_media_params *bmp;
+ struct region_device fmrd;
+
+ bmp = (struct lb_boot_media_params *)lb_new_record(header);
+
+ bmp->tag = LB_TAG_BOOT_MEDIA_PARAMS;
+ bmp->size = sizeof(*bmp);
+ bmp->fmap_offset = ~0;
+ if (IS_ENABLED(CONFIG_ARCH_X86)) {
+ bmp->cbfs_offset = CONFIG_ROM_SIZE - CONFIG_CBFS_SIZE;
+ } else {
+ bmp->cbfs_offset = 0;
+ }
+ bmp->cbfs_size = CONFIG_CBFS_SIZE;
+ bmp->boot_media_size = CONFIG_ROM_SIZE;
+
+ if (find_fmap_directory(&fmrd) == 0) {
+ bmp->fmap_offset = region_device_offset(&fmrd);
+ }
+}
+
static void lb_ram_code(struct lb_header *header)
{
#if IS_ENABLED(CONFIG_RAM_CODE_SUPPORT)
@@ -483,6 +508,8 @@ unsigned long write_coreboot_table(
lb_ramoops(head);
#endif
+ lb_boot_media_params(head);
+
/* Remember where my valid memory ranges are */
return lb_table_fini(head);
}
diff --git a/src/vendorcode/google/chromeos/vboot2/Makefile.inc b/src/vendorcode/google/chromeos/vboot2/Makefile.inc
index 9026df6..08993cb 100644
--- a/src/vendorcode/google/chromeos/vboot2/Makefile.inc
+++ b/src/vendorcode/google/chromeos/vboot2/Makefile.inc
@@ -41,6 +41,7 @@ endif
romstage-y += vboot_handoff.c common.c
ramstage-y += common.c
+ramstage-y += cbtable.c
verstage-y += verstage.ld
diff --git a/src/vendorcode/google/chromeos/vboot2/cbtable.c b/src/vendorcode/google/chromeos/vboot2/cbtable.c
new file mode 100644
index 0000000..7c95395
--- /dev/null
+++ b/src/vendorcode/google/chromeos/vboot2/cbtable.c
@@ -0,0 +1,55 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; version 2 of
+ * the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc.
+ */
+
+#include <boot/coreboot_tables.h>
+#include <fmap.h>
+#include <fmap_serialized.h>
+#include <region.h>
+#include <string.h>
+
+#include "misc.h"
+
+/* Don't create an entry in case of any error. After all, what would be a
+ correct response? */
+void lb_boot_media_params(struct lb_header *header)
+{
+ struct lb_boot_media_params *bmp;
+ struct vb2_working_data *wd = vboot_get_working_data();
+ struct region_device boot_media, fmrd;
+
+ if (!wd)
+ return; /* no vboot2 data to work with */
+
+ if (find_fmap_directory(&fmrd))
+ return; /* couldn't find fmap */
+
+ if (vb2_get_selected_region(wd, &boot_media))
+ return; /* no boot media defined */
+
+ bmp = (struct lb_boot_media_params *)lb_new_record(header);
+
+ bmp->tag = LB_TAG_BOOT_MEDIA_PARAMS;
+ bmp->size = sizeof(*bmp);
+ bmp->fmap_offset = region_device_offset(&fmrd);
+ bmp->cbfs_offset = region_device_offset(&boot_media);
+ bmp->cbfs_size = region_device_size(&boot_media);
+ bmp->boot_media_size = CONFIG_ROM_SIZE;
+}
+
More information about the coreboot-gerrit
mailing list