[coreboot-gerrit] Patch set updated for coreboot: lib: remove assets infrastructure

Aaron Durbin (adurbin@chromium.org) gerrit at coreboot.org
Wed Dec 9 01:04:09 CET 2015


Aaron Durbin (adurbin at chromium.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12690

-gerrit

commit d375fcbaec2e096ebe4516092387983d0f9ae482
Author: Aaron Durbin <adurbin at chromium.org>
Date:   Tue Dec 8 14:34:35 2015 -0600

    lib: remove assets infrastructure
    
    Now that only CBFS access is supported for finding resources
    within the boot media the assets infrastructure can be removed.
    Remove it.
    
    BUG=chromium:445938
    BRANCH=None
    TEST=Built and ran on glados.
    
    Change-Id: I383fd6579280cf9cfe5a18c2851baf74cad004e9
    Signed-off-by: Aaron Durbin <adurbin at chromium.org>
---
 src/arch/arm64/arm_tf.c                            |  4 +-
 src/arch/arm64/boot.c                              |  2 +-
 src/arch/riscv/boot.c                              |  2 +-
 src/arch/x86/boot.c                                |  2 +-
 src/drivers/intel/fsp1_1/car.c                     |  2 +-
 src/drivers/intel/fsp1_1/ramstage.c                |  2 +-
 src/include/assets.h                               | 88 --------------------
 src/include/program_loading.h                      | 40 ++++++---
 src/lib/Makefile.inc                               |  4 -
 src/lib/assets.c                                   | 96 ----------------------
 src/lib/cbfs.c                                     |  2 +-
 src/lib/prog_loaders.c                             |  6 +-
 src/soc/intel/baytrail/refcode.c                   |  2 +-
 src/soc/intel/broadwell/refcode.c                  |  2 +-
 .../google/chromeos/vboot2/vboot_loader.c          |  2 +-
 15 files changed, 41 insertions(+), 215 deletions(-)

diff --git a/src/arch/arm64/arm_tf.c b/src/arch/arm64/arm_tf.c
index 6435fc7..1cb35ba 100644
--- a/src/arch/arm64/arm_tf.c
+++ b/src/arch/arm64/arm_tf.c
@@ -44,7 +44,7 @@ void __attribute__((weak)) *soc_get_bl31_plat_params(bl31_params_t *params)
 
 void arm_tf_run_bl31(u64 payload_entry, u64 payload_arg0, u64 payload_spsr)
 {
-	struct prog bl31 = PROG_INIT(ASSET_BL31, CONFIG_CBFS_PREFIX"/bl31");
+	struct prog bl31 = PROG_INIT(PROG_BL31, CONFIG_CBFS_PREFIX"/bl31");
 	void (*bl31_entry)(bl31_params_t *params, void *plat_params) = NULL;
 
 	if (prog_locate(&bl31))
@@ -58,7 +58,7 @@ void arm_tf_run_bl31(u64 payload_entry, u64 payload_arg0, u64 payload_spsr)
 	SET_PARAM_HEAD(&bl31_params, PARAM_BL31, VERSION_1, 0);
 
 	if (IS_ENABLED(CONFIG_ARM64_USE_SECURE_OS)) {
-		struct prog bl32 = PROG_INIT(ASSET_BL32, CONFIG_CBFS_PREFIX"/secure_os");
+		struct prog bl32 = PROG_INIT(PROG_BL32, CONFIG_CBFS_PREFIX"/secure_os");
 
 		if (prog_locate(&bl32))
 			die("BL31 not found");
diff --git a/src/arch/arm64/boot.c b/src/arch/arm64/boot.c
index c996d50..eea758c 100644
--- a/src/arch/arm64/boot.c
+++ b/src/arch/arm64/boot.c
@@ -61,7 +61,7 @@ void arch_prog_run(struct prog *prog)
 	void (*doit)(void *);
 	void *arg;
 
-	if (ENV_RAMSTAGE && prog_type(prog) == ASSET_PAYLOAD) {
+	if (ENV_RAMSTAGE && prog_type(prog) == PROG_PAYLOAD) {
 		run_payload(prog);
 		return;
 	}
diff --git a/src/arch/riscv/boot.c b/src/arch/riscv/boot.c
index 39008e7..552b3f4 100644
--- a/src/arch/riscv/boot.c
+++ b/src/arch/riscv/boot.c
@@ -22,7 +22,7 @@ void arch_prog_run(struct prog *prog)
 {
 	void (*doit)(void *) = prog_entry(prog);
 
-	if (ENV_RAMSTAGE && prog_type(prog) == ASSET_PAYLOAD) {
+	if (ENV_RAMSTAGE && prog_type(prog) == PROG_PAYLOAD) {
 		initVirtualMemory();
 		write_csr(mepc, doit);
 		asm volatile("eret");
diff --git a/src/arch/x86/boot.c b/src/arch/x86/boot.c
index 7eb87fb..bf9a02b 100644
--- a/src/arch/x86/boot.c
+++ b/src/arch/x86/boot.c
@@ -184,7 +184,7 @@ static void jmp_payload(void *entry, unsigned long buffer, unsigned long size)
 
 static void try_payload(struct prog *prog)
 {
-	if (prog_type(prog) == ASSET_PAYLOAD) {
+	if (prog_type(prog) == PROG_PAYLOAD) {
 		if (IS_ENABLED(CONFIG_RELOCATABLE_RAMSTAGE))
 			jmp_payload_no_bounce_buffer(prog_entry(prog));
 		else
diff --git a/src/drivers/intel/fsp1_1/car.c b/src/drivers/intel/fsp1_1/car.c
index 23312e1..b525a62 100644
--- a/src/drivers/intel/fsp1_1/car.c
+++ b/src/drivers/intel/fsp1_1/car.c
@@ -79,7 +79,7 @@ asmlinkage void *romstage_after_verstage(void)
 	/* Need to locate the current FSP_INFO_HEADER. The cache-as-ram
 	 * is still enabled. We can directly access work buffer here. */
 	FSP_INFO_HEADER *fih;
-	struct prog fsp = PROG_INIT(ASSET_REFCODE, "fsp.bin");
+	struct prog fsp = PROG_INIT(PROG_REFCODE, "fsp.bin");
 
 	console_init();
 
diff --git a/src/drivers/intel/fsp1_1/ramstage.c b/src/drivers/intel/fsp1_1/ramstage.c
index aa1b658..20ec323 100644
--- a/src/drivers/intel/fsp1_1/ramstage.c
+++ b/src/drivers/intel/fsp1_1/ramstage.c
@@ -176,7 +176,7 @@ static int fsp_find_and_relocate(struct prog *fsp)
 
 void intel_silicon_init(void)
 {
-	struct prog fsp = PROG_INIT(ASSET_REFCODE, "fsp.bin");
+	struct prog fsp = PROG_INIT(PROG_REFCODE, "fsp.bin");
 	int is_s3_wakeup = acpi_is_wakeup_s3();
 
 	if (is_s3_wakeup) {
diff --git a/src/include/assets.h b/src/include/assets.h
deleted file mode 100644
index ac168a9..0000000
--- a/src/include/assets.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright 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.
- */
-#ifndef ASSETS_H
-#define ASSETS_H
-
-#include <commonlib/region.h>
-
-/* An asset represents data used to boot the system. It can be found within
- * CBFS or some other mechanism. While CBFS can be a source of an asset, note
- * that using the asset API implies querying of other sources. */
-
-enum asset_type {
-	ASSET_UNKNOWN,
-	ASSET_VERSTAGE,
-	ASSET_ROMSTAGE,
-	ASSET_RAMSTAGE,
-	ASSET_REFCODE,
-	ASSET_PAYLOAD,
-	ASSET_BL31,
-	ASSET_BL32,
-};
-
-struct asset {
-	enum asset_type type;
-	const char *name;
-	struct region_device rdev;
-};
-
-static inline const char *asset_name(const struct asset *asset)
-{
-	return asset->name;
-}
-
-static inline enum asset_type asset_type(const struct asset *asset)
-{
-	return asset->type;
-}
-
-static struct region_device *asset_rdev(struct asset *asset)
-{
-	return &asset->rdev;
-}
-
-static inline size_t asset_size(const struct asset *asset)
-{
-	return region_device_sz(&asset->rdev);
-}
-
-/* Returns NULL on error. */
-static inline void *asset_mmap(const struct asset *asset)
-{
-	return rdev_mmap_full(&asset->rdev);
-}
-
-#define ASSET_INIT(type_, name_)	\
-	{				\
-		.type = (type_),	\
-		.name = (name_),	\
-	}
-
-/* Locate the asset as described by the parameter. It will query all known
- * asset providers. Returns 0 on success. < 0 on error. */
-int asset_locate(struct asset *asset);
-
-struct asset_provider {
-	const char *name;
-	/* Determines if the provider is the active one. If so returns 1 else 0
-	 * or < 0 on error. */
-	int (*is_active)(struct asset *asset);
-	/* Returns < 0 on error or 0 on success. This function locates
-	 * the rdev representing the file data associated with the passed in
-	 * prog. */
-	int (*locate)(struct asset *asset);
-};
-
-#endif /* ASSETS_H */
diff --git a/src/include/program_loading.h b/src/include/program_loading.h
index 4385e36..f71dcb7 100644
--- a/src/include/program_loading.h
+++ b/src/include/program_loading.h
@@ -16,9 +16,9 @@
 #ifndef PROGRAM_LOADING_H
 #define PROGRAM_LOADING_H
 
+#include <commonlib/region.h>
 #include <stdint.h>
 #include <stddef.h>
-#include <assets.h>
 
 enum {
 	/* Last segment of program. Can be used to take different actions for
@@ -26,17 +26,30 @@ enum {
 	SEG_FINAL = 1 << 0,
 };
 
+enum prog_type {
+	PROG_UNKNOWN,
+	PROG_VERSTAGE,
+	PROG_ROMSTAGE,
+	PROG_RAMSTAGE,
+	PROG_REFCODE,
+	PROG_PAYLOAD,
+	PROG_BL31,
+	PROG_BL32,
+};
+
 /* Called for each segment of a program loaded. The SEG_FINAL flag will be
  * set on the last segment loaded. */
 void arch_segment_loaded(uintptr_t start, size_t size, int flags);
 
 /* Representation of a program. */
 struct prog {
-	/* The region_device within the asset is the source of program content
-	 * to load. After loading program it represents the memory region of
-	 * the stages and payload. For architectures that use a bounce buffer
+	/* The region_device is the source of program content to load. After
+	 * loading program it represents the memory region of the stages and
+	 * payload. For architectures that use a bounce buffer
 	 * then it would represent the bounce buffer. */
-	struct asset asset;
+	enum prog_type type;
+	const char *name;
+	struct region_device rdev;
 	/* Entry to program with optional argument. It's up to the architecture
 	 * to decide if argument is passed. */
 	void (*entry)(void *);
@@ -45,34 +58,35 @@ struct prog {
 
 #define PROG_INIT(type_, name_)				\
 	{						\
-		.asset = ASSET_INIT(type_, name_),	\
+		.type = (type_),			\
+		.name = (name_),			\
 	}
 
 static inline const char *prog_name(const struct prog *prog)
 {
-	return asset_name(&prog->asset);
+	return prog->name;
 }
 
-static inline enum asset_type prog_type(const struct prog *prog)
+static inline enum prog_type prog_type(const struct prog *prog)
 {
-	return asset_type(&prog->asset);
+	return prog->type;
 }
 
 static inline struct region_device *prog_rdev(struct prog *prog)
 {
-	return asset_rdev(&prog->asset);
+	return &prog->rdev;
 }
 
 /* Only valid for loaded programs. */
 static inline size_t prog_size(const struct prog *prog)
 {
-	return asset_size(&prog->asset);
+	return region_device_sz(&prog->rdev);
 }
 
 /* Only valid for loaded programs. */
 static inline void *prog_start(const struct prog *prog)
 {
-	return asset_mmap(&prog->asset);
+	return rdev_mmap_full(&prog->rdev);
 }
 
 static inline void *prog_entry(const struct prog *prog)
@@ -91,7 +105,7 @@ extern const struct mem_region_device addrspace_32bit;
 static inline void prog_memory_init(struct prog *prog, uintptr_t ptr,
 					size_t size)
 {
-	rdev_chain(&prog->asset.rdev, &addrspace_32bit.rdev, ptr, size);
+	rdev_chain(&prog->rdev, &addrspace_32bit.rdev, ptr, size);
 }
 
 static inline void prog_set_area(struct prog *prog, void *start, size_t size)
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index 0aada53..724391f 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -19,7 +19,6 @@ ifneq ($(CONFIG_BOOTBLOCK_CUSTOM),y)
 bootblock-y += bootblock.c
 endif
 
-bootblock-y += assets.c
 bootblock-y += prog_loaders.c
 bootblock-y += prog_ops.c
 bootblock-y += cbfs.c
@@ -39,7 +38,6 @@ bootblock-y += memcmp.c
 bootblock-y += boot_device.c
 bootblock-y += fmap.c
 
-verstage-y += assets.c
 verstage-y += prog_loaders.c
 verstage-y += prog_ops.c
 verstage-y += delay.c
@@ -62,7 +60,6 @@ endif
 verstage-$(CONFIG_GENERIC_UDELAY) += timer.c
 verstage-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c
 
-romstage-y += assets.c
 romstage-y += prog_loaders.c
 romstage-y += prog_ops.c
 romstage-y += memchr.c
@@ -98,7 +95,6 @@ endif
 
 romstage-$(CONFIG_GENERIC_UDELAY) += timer.c
 
-ramstage-y += assets.c
 ramstage-y += prog_loaders.c
 ramstage-y += prog_ops.c
 ramstage-y += hardwaremain.c
diff --git a/src/lib/assets.c b/src/lib/assets.c
deleted file mode 100644
index e9f3afb..0000000
--- a/src/lib/assets.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright 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.
- */
-
-
-#include <assets.h>
-#include <boot_device.h>
-#include <cbfs.h>
-#include <console/console.h>
-#include <rules.h>
-#include <stdlib.h>
-
-#define DEFAULT_CBFS_PROVIDER_PRESENT \
-	(!ENV_VERSTAGE || (ENV_VERSTAGE && !CONFIG_RETURN_FROM_VERSTAGE))
-
-#if DEFAULT_CBFS_PROVIDER_PRESENT
-static int cbfs_boot_asset_locate(struct asset *asset)
-{
-	struct cbfsf file;
-
-	if (cbfs_boot_locate(&file, asset_name(asset), NULL))
-		return -1;
-
-	cbfs_file_data(asset_rdev(asset), &file);
-
-	return 0;
-}
-
-static const struct asset_provider cbfs_default_provider = {
-	.name = "CBFS",
-	.locate = cbfs_boot_asset_locate,
-};
-#endif
-
-extern const struct asset_provider vboot_provider;
-
-static const struct asset_provider *providers[] = {
-#if CONFIG_VBOOT_VERIFY_FIRMWARE
-	&vboot_provider,
-#endif
-#if DEFAULT_CBFS_PROVIDER_PRESENT
-	&cbfs_default_provider,
-#endif
-};
-
-int asset_locate(struct asset *asset)
-{
-	int i;
-
-	boot_device_init();
-
-	for (i = 0; i < ARRAY_SIZE(providers); i++) {
-		/* Default provider state is active. */
-		int ret = 1;
-		const struct asset_provider *ops;
-
-		ops = providers[i];
-
-		if (ops->is_active != NULL)
-			ret = ops->is_active(asset);
-
-		if (ret == 0) {
-			printk(BIOS_DEBUG, "%s provider inactive.\n",
-				ops->name);
-			continue;
-		} else if (ret < 0) {
-			printk(BIOS_DEBUG, "%s provider failure.\n",
-				ops->name);
-			continue;
-		}
-
-		printk(BIOS_DEBUG, "%s provider active.\n", ops->name);
-
-		if (ops->locate(asset))
-			continue;
-
-		printk(BIOS_DEBUG, "'%s' located at offset: %zx size: %zx\n",
-			asset->name, region_device_offset(&asset->rdev),
-			region_device_sz(&asset->rdev));
-
-		return 0;
-	}
-
-	return -1;
-}
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c
index 1d0869c..d68aa39 100644
--- a/src/lib/cbfs.c
+++ b/src/lib/cbfs.c
@@ -175,7 +175,7 @@ void *cbfs_boot_map_optionrom(uint16_t vendor, uint16_t device)
 void *cbfs_boot_load_stage_by_name(const char *name)
 {
 	struct cbfsf fh;
-	struct prog stage = PROG_INIT(ASSET_UNKNOWN, name);
+	struct prog stage = PROG_INIT(PROG_UNKNOWN, name);
 	uint32_t type = CBFS_TYPE_STAGE;
 
 	if (cbfs_boot_locate(&fh, name, &type))
diff --git a/src/lib/prog_loaders.c b/src/lib/prog_loaders.c
index e27eca1..3f5d95c 100644
--- a/src/lib/prog_loaders.c
+++ b/src/lib/prog_loaders.c
@@ -50,7 +50,7 @@ int prog_locate(struct prog *prog)
 void run_romstage(void)
 {
 	struct prog romstage =
-		PROG_INIT(ASSET_ROMSTAGE, CONFIG_CBFS_PREFIX "/romstage");
+		PROG_INIT(PROG_ROMSTAGE, CONFIG_CBFS_PREFIX "/romstage");
 
 	if (prog_locate(&romstage))
 		goto fail;
@@ -104,7 +104,7 @@ static int load_relocatable_ramstage(struct prog *ramstage)
 void run_ramstage(void)
 {
 	struct prog ramstage =
-		PROG_INIT(ASSET_RAMSTAGE, CONFIG_CBFS_PREFIX "/ramstage");
+		PROG_INIT(PROG_RAMSTAGE, CONFIG_CBFS_PREFIX "/ramstage");
 
 	timestamp_add_now(TS_END_ROMSTAGE);
 
@@ -137,7 +137,7 @@ fail:
 #ifdef __RAMSTAGE__ // gc-sections should take care of this
 
 static struct prog global_payload =
-	PROG_INIT(ASSET_PAYLOAD, CONFIG_CBFS_PREFIX "/payload");
+	PROG_INIT(PROG_PAYLOAD, CONFIG_CBFS_PREFIX "/payload");
 
 void __attribute__((weak)) mirror_payload(struct prog *payload)
 {
diff --git a/src/soc/intel/baytrail/refcode.c b/src/soc/intel/baytrail/refcode.c
index 3a72a8f..a5946bc 100644
--- a/src/soc/intel/baytrail/refcode.c
+++ b/src/soc/intel/baytrail/refcode.c
@@ -45,7 +45,7 @@ static efi_wrapper_entry_t load_refcode_from_cache(void)
 static efi_wrapper_entry_t load_reference_code(void)
 {
 	struct prog prog =
-		PROG_INIT(ASSET_REFCODE, CONFIG_CBFS_PREFIX "/refcode");
+		PROG_INIT(PROG_REFCODE, CONFIG_CBFS_PREFIX "/refcode");
 	struct rmod_stage_load refcode = {
 		.cbmem_id = CBMEM_ID_REFCODE,
 		.prog = &prog,
diff --git a/src/soc/intel/broadwell/refcode.c b/src/soc/intel/broadwell/refcode.c
index a51031b..c818752 100644
--- a/src/soc/intel/broadwell/refcode.c
+++ b/src/soc/intel/broadwell/refcode.c
@@ -42,7 +42,7 @@ static pei_wrapper_entry_t load_refcode_from_cache(void)
 static pei_wrapper_entry_t load_reference_code(void)
 {
 	struct prog prog =
-		PROG_INIT(ASSET_REFCODE, CONFIG_CBFS_PREFIX "/refcode");
+		PROG_INIT(PROG_REFCODE, CONFIG_CBFS_PREFIX "/refcode");
 	struct rmod_stage_load refcode = {
 		.cbmem_id = CBMEM_ID_REFCODE,
 		.prog = &prog,
diff --git a/src/vendorcode/google/chromeos/vboot2/vboot_loader.c b/src/vendorcode/google/chromeos/vboot2/vboot_loader.c
index 5fdd026..5900613 100644
--- a/src/vendorcode/google/chromeos/vboot2/vboot_loader.c
+++ b/src/vendorcode/google/chromeos/vboot2/vboot_loader.c
@@ -98,7 +98,7 @@ static void vboot_prepare(void)
 	} else if (verstage_should_load()) {
 		struct cbfsf file;
 		struct prog verstage =
-			PROG_INIT(ASSET_VERSTAGE,
+			PROG_INIT(PROG_VERSTAGE,
 				CONFIG_CBFS_PREFIX "/verstage");
 
 		printk(BIOS_DEBUG, "VBOOT: Loading verstage.\n");



More information about the coreboot-gerrit mailing list