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@chromium.org>
Reviewed-on: https://review.coreboot.org/12690
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
Aaron Durbin 2015-12-08 14:34:35 -06:00
parent 6d720f38e0
commit 7e7a4df580
15 changed files with 41 additions and 215 deletions

View File

@ -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) 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; void (*bl31_entry)(bl31_params_t *params, void *plat_params) = NULL;
if (prog_locate(&bl31)) 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); SET_PARAM_HEAD(&bl31_params, PARAM_BL31, VERSION_1, 0);
if (IS_ENABLED(CONFIG_ARM64_USE_SECURE_OS)) { 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)) if (prog_locate(&bl32))
die("BL31 not found"); die("BL31 not found");

View File

@ -61,7 +61,7 @@ void arch_prog_run(struct prog *prog)
void (*doit)(void *); void (*doit)(void *);
void *arg; void *arg;
if (ENV_RAMSTAGE && prog_type(prog) == ASSET_PAYLOAD) { if (ENV_RAMSTAGE && prog_type(prog) == PROG_PAYLOAD) {
run_payload(prog); run_payload(prog);
return; return;
} }

View File

@ -22,7 +22,7 @@ void arch_prog_run(struct prog *prog)
{ {
void (*doit)(void *) = prog_entry(prog); void (*doit)(void *) = prog_entry(prog);
if (ENV_RAMSTAGE && prog_type(prog) == ASSET_PAYLOAD) { if (ENV_RAMSTAGE && prog_type(prog) == PROG_PAYLOAD) {
initVirtualMemory(); initVirtualMemory();
write_csr(mepc, doit); write_csr(mepc, doit);
asm volatile("eret"); asm volatile("eret");

View File

@ -184,7 +184,7 @@ static void jmp_payload(void *entry, unsigned long buffer, unsigned long size)
static void try_payload(struct prog *prog) 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)) if (IS_ENABLED(CONFIG_RELOCATABLE_RAMSTAGE))
jmp_payload_no_bounce_buffer(prog_entry(prog)); jmp_payload_no_bounce_buffer(prog_entry(prog));
else else

View File

@ -79,7 +79,7 @@ asmlinkage void *romstage_after_verstage(void)
/* Need to locate the current FSP_INFO_HEADER. The cache-as-ram /* Need to locate the current FSP_INFO_HEADER. The cache-as-ram
* is still enabled. We can directly access work buffer here. */ * is still enabled. We can directly access work buffer here. */
FSP_INFO_HEADER *fih; FSP_INFO_HEADER *fih;
struct prog fsp = PROG_INIT(ASSET_REFCODE, "fsp.bin"); struct prog fsp = PROG_INIT(PROG_REFCODE, "fsp.bin");
console_init(); console_init();

View File

@ -176,7 +176,7 @@ static int fsp_find_and_relocate(struct prog *fsp)
void intel_silicon_init(void) 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(); int is_s3_wakeup = acpi_is_wakeup_s3();
if (is_s3_wakeup) { if (is_s3_wakeup) {

View File

@ -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 */

View File

@ -16,9 +16,9 @@
#ifndef PROGRAM_LOADING_H #ifndef PROGRAM_LOADING_H
#define PROGRAM_LOADING_H #define PROGRAM_LOADING_H
#include <commonlib/region.h>
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>
#include <assets.h>
enum { enum {
/* Last segment of program. Can be used to take different actions for /* Last segment of program. Can be used to take different actions for
@ -26,17 +26,30 @@ enum {
SEG_FINAL = 1 << 0, 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 /* Called for each segment of a program loaded. The SEG_FINAL flag will be
* set on the last segment loaded. */ * set on the last segment loaded. */
void arch_segment_loaded(uintptr_t start, size_t size, int flags); void arch_segment_loaded(uintptr_t start, size_t size, int flags);
/* Representation of a program. */ /* Representation of a program. */
struct prog { struct prog {
/* The region_device within the asset is the source of program content /* The region_device is the source of program content to load. After
* to load. After loading program it represents the memory region of * loading program it represents the memory region of the stages and
* the stages and payload. For architectures that use a bounce buffer * payload. For architectures that use a bounce buffer
* then it would represent the 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 /* Entry to program with optional argument. It's up to the architecture
* to decide if argument is passed. */ * to decide if argument is passed. */
void (*entry)(void *); void (*entry)(void *);
@ -45,34 +58,35 @@ struct prog {
#define PROG_INIT(type_, name_) \ #define PROG_INIT(type_, name_) \
{ \ { \
.asset = ASSET_INIT(type_, name_), \ .type = (type_), \
.name = (name_), \
} }
static inline const char *prog_name(const struct prog *prog) 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) static inline struct region_device *prog_rdev(struct prog *prog)
{ {
return asset_rdev(&prog->asset); return &prog->rdev;
} }
/* Only valid for loaded programs. */ /* Only valid for loaded programs. */
static inline size_t prog_size(const struct prog *prog) 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. */ /* Only valid for loaded programs. */
static inline void *prog_start(const struct prog *prog) 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) 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, static inline void prog_memory_init(struct prog *prog, uintptr_t ptr,
size_t size) 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) static inline void prog_set_area(struct prog *prog, void *start, size_t size)

View File

@ -19,7 +19,6 @@ ifneq ($(CONFIG_BOOTBLOCK_CUSTOM),y)
bootblock-y += bootblock.c bootblock-y += bootblock.c
endif endif
bootblock-y += assets.c
bootblock-y += prog_loaders.c bootblock-y += prog_loaders.c
bootblock-y += prog_ops.c bootblock-y += prog_ops.c
bootblock-y += cbfs.c bootblock-y += cbfs.c
@ -39,7 +38,6 @@ bootblock-y += memcmp.c
bootblock-y += boot_device.c bootblock-y += boot_device.c
bootblock-y += fmap.c bootblock-y += fmap.c
verstage-y += assets.c
verstage-y += prog_loaders.c verstage-y += prog_loaders.c
verstage-y += prog_ops.c verstage-y += prog_ops.c
verstage-y += delay.c verstage-y += delay.c
@ -62,7 +60,6 @@ endif
verstage-$(CONFIG_GENERIC_UDELAY) += timer.c verstage-$(CONFIG_GENERIC_UDELAY) += timer.c
verstage-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c verstage-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c
romstage-y += assets.c
romstage-y += prog_loaders.c romstage-y += prog_loaders.c
romstage-y += prog_ops.c romstage-y += prog_ops.c
romstage-y += memchr.c romstage-y += memchr.c
@ -98,7 +95,6 @@ endif
romstage-$(CONFIG_GENERIC_UDELAY) += timer.c romstage-$(CONFIG_GENERIC_UDELAY) += timer.c
ramstage-y += assets.c
ramstage-y += prog_loaders.c ramstage-y += prog_loaders.c
ramstage-y += prog_ops.c ramstage-y += prog_ops.c
ramstage-y += hardwaremain.c ramstage-y += hardwaremain.c

View File

@ -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;
}

View File

@ -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) void *cbfs_boot_load_stage_by_name(const char *name)
{ {
struct cbfsf fh; 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; uint32_t type = CBFS_TYPE_STAGE;
if (cbfs_boot_locate(&fh, name, &type)) if (cbfs_boot_locate(&fh, name, &type))

View File

@ -50,7 +50,7 @@ int prog_locate(struct prog *prog)
void run_romstage(void) void run_romstage(void)
{ {
struct prog romstage = struct prog romstage =
PROG_INIT(ASSET_ROMSTAGE, CONFIG_CBFS_PREFIX "/romstage"); PROG_INIT(PROG_ROMSTAGE, CONFIG_CBFS_PREFIX "/romstage");
if (prog_locate(&romstage)) if (prog_locate(&romstage))
goto fail; goto fail;
@ -104,7 +104,7 @@ static int load_relocatable_ramstage(struct prog *ramstage)
void run_ramstage(void) void run_ramstage(void)
{ {
struct prog ramstage = 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); timestamp_add_now(TS_END_ROMSTAGE);
@ -137,7 +137,7 @@ fail:
#ifdef __RAMSTAGE__ // gc-sections should take care of this #ifdef __RAMSTAGE__ // gc-sections should take care of this
static struct prog global_payload = 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) void __attribute__((weak)) mirror_payload(struct prog *payload)
{ {

View File

@ -45,7 +45,7 @@ static efi_wrapper_entry_t load_refcode_from_cache(void)
static efi_wrapper_entry_t load_reference_code(void) static efi_wrapper_entry_t load_reference_code(void)
{ {
struct prog prog = struct prog prog =
PROG_INIT(ASSET_REFCODE, CONFIG_CBFS_PREFIX "/refcode"); PROG_INIT(PROG_REFCODE, CONFIG_CBFS_PREFIX "/refcode");
struct rmod_stage_load refcode = { struct rmod_stage_load refcode = {
.cbmem_id = CBMEM_ID_REFCODE, .cbmem_id = CBMEM_ID_REFCODE,
.prog = &prog, .prog = &prog,

View File

@ -42,7 +42,7 @@ static pei_wrapper_entry_t load_refcode_from_cache(void)
static pei_wrapper_entry_t load_reference_code(void) static pei_wrapper_entry_t load_reference_code(void)
{ {
struct prog prog = struct prog prog =
PROG_INIT(ASSET_REFCODE, CONFIG_CBFS_PREFIX "/refcode"); PROG_INIT(PROG_REFCODE, CONFIG_CBFS_PREFIX "/refcode");
struct rmod_stage_load refcode = { struct rmod_stage_load refcode = {
.cbmem_id = CBMEM_ID_REFCODE, .cbmem_id = CBMEM_ID_REFCODE,
.prog = &prog, .prog = &prog,

View File

@ -98,7 +98,7 @@ static void vboot_prepare(void)
} else if (verstage_should_load()) { } else if (verstage_should_load()) {
struct cbfsf file; struct cbfsf file;
struct prog verstage = struct prog verstage =
PROG_INIT(ASSET_VERSTAGE, PROG_INIT(PROG_VERSTAGE,
CONFIG_CBFS_PREFIX "/verstage"); CONFIG_CBFS_PREFIX "/verstage");
printk(BIOS_DEBUG, "VBOOT: Loading verstage.\n"); printk(BIOS_DEBUG, "VBOOT: Loading verstage.\n");