Patrick Georgi (pgeorgi@google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10867
-gerrit
commit e6b2ffdacd9f1b6e1932dba63952980acdd7ce27 Author: Daisuke Nojiri dnojiri@chromium.org Date: Wed Jul 1 11:08:22 2015 -0700
fmap: store boot params to coreboot table
This allows payloads on ARM platforms to use cbfs on spi flash by passing along information to look it up from fmap.
[pg: adapted to use fmap instead of CBFS_HEADER_OFFSET]
Change-Id: I4b00159610077761c501507e136407e9ae08c73e Signed-off-by: Daisuke Nojiri dnojiri@chromium.org Signed-off-by: Patrick Georgi pgeorgi@chromium.org --- src/include/boot/coreboot_tables.h | 12 +++++ src/lib/coreboot_table.c | 6 +++ src/vendorcode/google/chromeos/vboot2/Makefile.inc | 1 + src/vendorcode/google/chromeos/vboot2/cbtable.c | 55 ++++++++++++++++++++++ 4 files changed, 74 insertions(+)
diff --git a/src/include/boot/coreboot_tables.h b/src/include/boot/coreboot_tables.h index c8d5251..99eb3c6 100644 --- a/src/include/boot/coreboot_tables.h +++ b/src/include/boot/coreboot_tables.h @@ -297,6 +297,15 @@ 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; + /* offset from the start of the media */ + uint32_t fmap_offset; + char fmap_name[32]; +}; + #define LB_TAG_SERIALNO 0x002a #define MAX_SERIALNO_LENGTH 32
@@ -390,6 +399,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..9fa5da6 100644 --- a/src/lib/coreboot_table.c +++ b/src/lib/coreboot_table.c @@ -228,6 +228,10 @@ static void lb_board_id(struct lb_header *header) #endif }
+ +void __attribute__((weak)) lb_boot_media_params(struct lb_header *header) +{ /* NOOP */ } + static void lb_ram_code(struct lb_header *header) { #if IS_ENABLED(CONFIG_RAM_CODE_SUPPORT) @@ -483,6 +487,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..988cb13 --- /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" + +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; + char name[FMAP_STRLEN]; + + 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 */ + + if (fmap_find_region_name(&boot_media.region, name)) + return; /* couldn't find region */ + + 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); + memcpy(bmp->fmap_name, name, FMAP_STRLEN); +} +