diff options
author | Aaron Durbin <adurbin@chromium.org> | 2015-05-20 12:08:55 -0500 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2015-06-02 14:10:08 +0200 |
commit | ac12c66cf91343153ea90a6f33977a13e10b21d0 (patch) | |
tree | 2864de25bb12ed2d5c7ec8d691ec753f146c5e57 | |
parent | 6a452eff90411176f9f2cad0ca0c665a31c032ee (diff) |
assets: abstract away the firmware assets used for booting
As there can be more than one source of firmware assets this
patch generalizes the notion of locating a particular asset.
struct asset is added along with some helper functions for
working on assets as a first class citizen.
Change-Id: I2ce575d1e5259aed4c34c3dcfd438abe9db1d7b9
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/10264
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Tested-by: build bot (Jenkins)
-rw-r--r-- | src/arch/arm64/arm_tf.c | 5 | ||||
-rw-r--r-- | src/arch/arm64/boot.c | 2 | ||||
-rw-r--r-- | src/arch/x86/boot/boot.c | 2 | ||||
-rw-r--r-- | src/include/assets.h | 91 | ||||
-rw-r--r-- | src/include/program_loading.h | 55 | ||||
-rw-r--r-- | src/lib/Makefile.inc | 4 | ||||
-rw-r--r-- | src/lib/assets.c | 93 | ||||
-rw-r--r-- | src/lib/cbfs.c | 8 | ||||
-rw-r--r-- | src/lib/prog_loaders.c | 90 | ||||
-rw-r--r-- | src/lib/rmodule.c | 6 | ||||
-rw-r--r-- | src/lib/selfboot.c | 9 | ||||
-rw-r--r-- | src/soc/intel/baytrail/refcode.c | 6 | ||||
-rw-r--r-- | src/soc/intel/broadwell/refcode.c | 6 | ||||
-rw-r--r-- | src/vendorcode/google/chromeos/vboot2/vboot_loader.c | 50 |
14 files changed, 272 insertions, 155 deletions
diff --git a/src/arch/arm64/arm_tf.c b/src/arch/arm64/arm_tf.c index 3e0892ec34..29dc7c344f 100644 --- a/src/arch/arm64/arm_tf.c +++ b/src/arch/arm64/arm_tf.c @@ -45,10 +45,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 = { - .type = PROG_BL31, - .name = CONFIG_CBFS_PREFIX"/bl31", - }; + struct prog bl31 = PROG_INIT(ASSET_BL31, CONFIG_CBFS_PREFIX"/bl31"); void (*bl31_entry)(bl31_params_t *params, void *plat_params) = NULL; if (prog_locate(&bl31)) diff --git a/src/arch/arm64/boot.c b/src/arch/arm64/boot.c index 88d477c71f..b22f029e58 100644 --- a/src/arch/arm64/boot.c +++ b/src/arch/arm64/boot.c @@ -73,7 +73,7 @@ void arch_prog_run(struct prog *prog) void (*doit)(void *); void *arg; - if (ENV_RAMSTAGE && prog->type == PROG_PAYLOAD) { + if (ENV_RAMSTAGE && prog_type(prog) == ASSET_PAYLOAD) { run_payload(prog); return; } diff --git a/src/arch/x86/boot/boot.c b/src/arch/x86/boot/boot.c index 0ff8a6c37f..d86a6c35b8 100644 --- a/src/arch/x86/boot/boot.c +++ b/src/arch/x86/boot/boot.c @@ -125,7 +125,7 @@ static void jmp_payload(void *entry, unsigned long buffer, unsigned long size) static void try_payload(struct prog *prog) { - if (prog->type == PROG_PAYLOAD) { + if (prog_type(prog) == ASSET_PAYLOAD) { if (IS_ENABLED(CONFIG_RELOCATABLE_RAMSTAGE)) jmp_payload_no_bounce_buffer(prog_entry(prog)); else diff --git a/src/include/assets.h b/src/include/assets.h new file mode 100644 index 0000000000..9c757edc5e --- /dev/null +++ b/src/include/assets.h @@ -0,0 +1,91 @@ +/* + * 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. + * + * 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. + */ +#ifndef ASSETS_H +#define ASSETS_H + +#include <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, +}; + +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 7506c50f0f..d6da688831 100644 --- a/src/include/program_loading.h +++ b/src/include/program_loading.h @@ -22,7 +22,7 @@ #include <stdint.h> #include <stddef.h> -#include <region.h> +#include <assets.h> enum { /* Last segment of program. Can be used to take different actions for @@ -34,40 +34,49 @@ enum { * set on the last segment loaded. */ void arch_segment_loaded(uintptr_t start, size_t size, int flags); -enum prog_type { - PROG_VERSTAGE, - PROG_ROMSTAGE, - PROG_RAMSTAGE, - PROG_REFCODE, - PROG_PAYLOAD, - PROG_BL31, -}; - /* Representation of a program. */ struct prog { - enum prog_type type; - const char *name; - /* 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 region_device rdev; + /* 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 + * then it would represent the bounce buffer. */ + struct asset asset; /* Entry to program with optional argument. It's up to the architecture * to decide if argument is passed. */ void (*entry)(void *); void *arg; }; +#define PROG_INIT(type_, name_) \ + { \ + .asset = ASSET_INIT(type_, name_), \ + } + +static inline const char *prog_name(const struct prog *prog) +{ + return asset_name(&prog->asset); +} + +static inline enum asset_type prog_type(const struct prog *prog) +{ + return asset_type(&prog->asset); +} + +static inline struct region_device *prog_rdev(struct prog *prog) +{ + return asset_rdev(&prog->asset); +} + /* Only valid for loaded programs. */ static inline size_t prog_size(const struct prog *prog) { - return region_device_sz(&prog->rdev); + return asset_size(&prog->asset); } /* Only valid for loaded programs. */ static inline void *prog_start(const struct prog *prog) { - return rdev_mmap_full(&prog->rdev); + return asset_mmap(&prog->asset); } static inline void *prog_entry(const struct prog *prog) @@ -86,7 +95,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->rdev, &addrspace_32bit.rdev, ptr, size); + rdev_chain(&prog->asset.rdev, &addrspace_32bit.rdev, ptr, size); } static inline void prog_set_area(struct prog *prog, void *start, size_t size) @@ -101,7 +110,11 @@ static inline void prog_set_entry(struct prog *prog, void *e, void *arg) } /* Locate the identified program to run. Return 0 on success. < 0 on error. */ -int prog_locate(struct prog *prog); +static inline int prog_locate(struct prog *prog) +{ + return asset_locate(&prog->asset); +} + /* Run the program described by prog. */ void prog_run(struct prog *prog); /* Per architecture implementation running a program. */ diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc index ebb3076e63..557cd66846 100644 --- a/src/lib/Makefile.inc +++ b/src/lib/Makefile.inc @@ -18,6 +18,7 @@ # subdirs-y += loaders +bootblock-y += assets.c bootblock-y += prog_loaders.c bootblock-y += prog_ops.c bootblock-y += cbfs.c @@ -36,6 +37,7 @@ bootblock-y += region.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 @@ -60,6 +62,7 @@ verstage-$(CONFIG_GENERIC_UDELAY) += timer.c verstage-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c verstage-y += mem_pool.c +romstage-y += assets.c romstage-y += prog_loaders.c romstage-y += prog_ops.c romstage-y += memchr.c @@ -92,6 +95,7 @@ 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 new file mode 100644 index 0000000000..656f0b1e2b --- /dev/null +++ b/src/lib/assets.c @@ -0,0 +1,93 @@ +/* + * 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. + * + * 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 <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) +{ + return cbfs_boot_locate(&asset->rdev, asset->name, NULL); +} + +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 23dfee70c9..3e83765bf3 100644 --- a/src/lib/cbfs.c +++ b/src/lib/cbfs.c @@ -188,12 +188,10 @@ void *cbfs_boot_map_optionrom(uint16_t vendor, uint16_t device) void *cbfs_boot_load_stage_by_name(const char *name) { - struct prog stage = { - .name = name, - }; + struct prog stage = PROG_INIT(ASSET_UNKNOWN, name); uint32_t type = CBFS_TYPE_STAGE; - if (cbfs_boot_locate(&stage.rdev, name, &type)) + if (cbfs_boot_locate(&stage.asset.rdev, name, &type)) return NULL; if (cbfs_prog_stage_load(&stage)) @@ -209,7 +207,7 @@ int cbfs_prog_stage_load(struct prog *pstage) void *entry; size_t fsize; size_t foffset; - const struct region_device *fh = &pstage->rdev; + const struct region_device *fh = &pstage->asset.rdev; if (rdev_readat(fh, &stage, 0, sizeof(stage)) != sizeof(stage)) return 0; diff --git a/src/lib/prog_loaders.c b/src/lib/prog_loaders.c index 77999945d1..ec5eeb8693 100644 --- a/src/lib/prog_loaders.c +++ b/src/lib/prog_loaders.c @@ -20,7 +20,6 @@ #include <stdlib.h> #include <arch/stages.h> -#include <boot_device.h> #include <cbfs.h> #include <cbmem.h> #include <console/console.h> @@ -38,83 +37,10 @@ /* Only can represent up to 1 byte less than size_t. */ const struct mem_region_device addrspace_32bit = MEM_REGION_DEV_INIT(0, ~0UL); -#define DEFAULT_CBFS_LOADER_PRESENT \ - (!ENV_VERSTAGE || (ENV_VERSTAGE && !CONFIG_RETURN_FROM_VERSTAGE)) - -#if DEFAULT_CBFS_LOADER_PRESENT -static int cbfs_boot_prog_locate(struct prog *prog) -{ - return cbfs_boot_locate(&prog->rdev, prog->name, NULL); -} - -static const struct prog_loader_ops cbfs_default_loader = { - .locate = cbfs_boot_prog_locate, -}; -#endif - -extern const struct prog_loader_ops vboot_loader; - -static const struct prog_loader_ops *loaders[] = { -#if CONFIG_VBOOT_VERIFY_FIRMWARE - &vboot_loader, -#endif -#if DEFAULT_CBFS_LOADER_PRESENT - &cbfs_default_loader, -#endif -}; - -int prog_locate(struct prog *prog) -{ - int i; - - boot_device_init(); - - for (i = 0; i < ARRAY_SIZE(loaders); i++) { - /* Default loader state is active. */ - int ret = 1; - const struct prog_loader_ops *ops; - - ops = loaders[i]; - - if (ops->is_loader_active != NULL) - ret = ops->is_loader_active(prog); - - if (ret == 0) { - printk(BIOS_DEBUG, "%s loader inactive.\n", - ops->name); - continue; - } else if (ret < 0) { - printk(BIOS_DEBUG, "%s loader failure.\n", - ops->name); - continue; - } - - printk(BIOS_DEBUG, "%s loader active.\n", ops->name); - - if (ops->locate(prog)) - continue; - - printk(BIOS_DEBUG, "'%s' located at offset: %zx size: %zx\n", - prog->name, region_device_offset(&prog->rdev), - region_device_sz(&prog->rdev)); - - return 0; - } - - return -1; -} - void run_romstage(void) { - struct prog romstage = { - .name = CONFIG_CBFS_PREFIX "/romstage", - .type = PROG_ROMSTAGE, - }; - - /* The only time the default CBFS loader isn't present is during - * VERSTAGE in which it returns back to the calling stage. */ - if (!DEFAULT_CBFS_LOADER_PRESENT) - return; + struct prog romstage = + PROG_INIT(ASSET_ROMSTAGE, CONFIG_CBFS_PREFIX "/romstage"); if (prog_locate(&romstage)) goto fail; @@ -166,10 +92,8 @@ static int load_relocatable_ramstage(struct prog *ramstage) void run_ramstage(void) { - struct prog ramstage = { - .name = CONFIG_CBFS_PREFIX "/ramstage", - .type = PROG_RAMSTAGE, - }; + struct prog ramstage = + PROG_INIT(ASSET_RAMSTAGE, CONFIG_CBFS_PREFIX "/ramstage"); /* Only x86 systems currently take the same firmware path on resume. */ if (IS_ENABLED(CONFIG_ARCH_X86) && IS_ENABLED(CONFIG_EARLY_CBMEM_INIT)) @@ -197,10 +121,8 @@ fail: die("Ramstage was not loaded!\n"); } -static struct prog global_payload = { - .name = CONFIG_CBFS_PREFIX "/payload", - .type = PROG_PAYLOAD, -}; +static struct prog global_payload = + PROG_INIT(ASSET_PAYLOAD, CONFIG_CBFS_PREFIX "/payload"); void __attribute__((weak)) mirror_payload(struct prog *payload) { diff --git a/src/lib/rmodule.c b/src/lib/rmodule.c index 35893d9d96..c17c7a5a2c 100644 --- a/src/lib/rmodule.c +++ b/src/lib/rmodule.c @@ -264,10 +264,10 @@ int rmodule_stage_load(struct rmod_stage_load *rsl) void *rmod_loc; struct region_device *fh; - if (rsl->prog == NULL || rsl->prog->name == NULL) + if (rsl->prog == NULL || prog_name(rsl->prog) == NULL) return -1; - fh = &rsl->prog->rdev; + fh = prog_rdev(rsl->prog); if (rdev_readat(fh, &stage, 0, sizeof(stage)) != sizeof(stage)) return -1; @@ -284,7 +284,7 @@ int rmodule_stage_load(struct rmod_stage_load *rsl) rmod_loc = &stage_region[rmodule_offset]; printk(BIOS_INFO, "Decompressing stage %s @ 0x%p (%d bytes)\n", - rsl->prog->name, rmod_loc, stage.memlen); + prog_name(rsl->prog), rmod_loc, stage.memlen); if (stage.compression == CBFS_COMPRESS_NONE) { if (rdev_readat(fh, rmod_loc, sizeof(stage), stage.len) != diff --git a/src/lib/selfboot.c b/src/lib/selfboot.c index 3f8cc6fb18..94a75bef2e 100644 --- a/src/lib/selfboot.c +++ b/src/lib/selfboot.c @@ -454,7 +454,7 @@ void *selfload(struct prog *payload) struct segment head; void *data; - data = rdev_mmap_full(&payload->rdev); + data = rdev_mmap_full(prog_rdev(payload)); if (data == NULL) return NULL; @@ -469,7 +469,10 @@ void *selfload(struct prog *payload) printk(BIOS_SPEW, "Loaded segments\n"); - rdev_munmap(&payload->rdev, data); + rdev_munmap(prog_rdev(payload), data); + + /* Update the payload's area with the bounce buffer information. */ + prog_set_area(payload, (void *)(uintptr_t)bounce_buffer, bounce_size); /* Update the payload's area with the bounce buffer information. */ prog_set_area(payload, (void *)(uintptr_t)bounce_buffer, bounce_size); @@ -477,6 +480,6 @@ void *selfload(struct prog *payload) return (void *)entry; out: - rdev_munmap(&payload->rdev, data); + rdev_munmap(prog_rdev(payload), data); return NULL; } diff --git a/src/soc/intel/baytrail/refcode.c b/src/soc/intel/baytrail/refcode.c index 0c49a800a6..971ce60f9d 100644 --- a/src/soc/intel/baytrail/refcode.c +++ b/src/soc/intel/baytrail/refcode.c @@ -48,10 +48,8 @@ static efi_wrapper_entry_t load_refcode_from_cache(void) static efi_wrapper_entry_t load_reference_code(void) { - struct prog prog = { - .type = PROG_REFCODE, - .name = CONFIG_CBFS_PREFIX "/refcode", - }; + struct prog prog = + PROG_INIT(ASSET_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 f1bc4cbb8d..a890e82952 100644 --- a/src/soc/intel/broadwell/refcode.c +++ b/src/soc/intel/broadwell/refcode.c @@ -45,10 +45,8 @@ static pei_wrapper_entry_t load_refcode_from_cache(void) static efi_wrapper_entry_t load_reference_code(void) { - struct prog prog = { - .type = PROG_REFCODE, - .name = CONFIG_CBFS_PREFIX "/refcode", - }; + struct prog prog = + PROG_INIT(ASSET_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 5248305a04..cbb5f89bc0 100644 --- a/src/vendorcode/google/chromeos/vboot2/vboot_loader.c +++ b/src/vendorcode/google/chromeos/vboot2/vboot_loader.c @@ -17,10 +17,10 @@ * Foundation, Inc. */ +#include <assets.h> #include <cbfs.h> #include <cbmem.h> #include <console/console.h> -#include <program_loading.h> #include <rmodule.h> #include <rules.h> #include <string.h> @@ -79,7 +79,7 @@ static void init_vb2_working_data(void) wd->buffer_size = work_size - wd->buffer_offset; } -static int vboot_loader_active(struct prog *prog) +static int vboot_active(struct asset *asset) { struct vb2_working_data *wd; int run_verification; @@ -90,15 +90,15 @@ static int vboot_loader_active(struct prog *prog) init_vb2_working_data(); verstage_main(); } else if (verstage_should_load()) { - struct prog verstage = { - .type = PROG_VERSTAGE, - .name = CONFIG_CBFS_PREFIX "/verstage", - }; + struct prog verstage = + PROG_INIT(ASSET_VERSTAGE, + CONFIG_CBFS_PREFIX "/verstage"); printk(BIOS_DEBUG, "VBOOT: Loading verstage.\n"); /* load verstage from RO */ - if (cbfs_boot_locate(&verstage.rdev, verstage.name, NULL) || + if (cbfs_boot_locate(prog_rdev(&verstage), + prog_name(&verstage), NULL) || cbfs_prog_stage_load(&verstage)) die("failed to load verstage"); @@ -126,24 +126,24 @@ static int vboot_loader_active(struct prog *prog) } static int vboot_locate_by_components(const struct region_device *fw_main, - struct prog *prog) + struct asset *asset) { struct vboot_components *fw_info; size_t metadata_sz; size_t offset; size_t size; - struct region_device *fw = &prog->rdev; + struct region_device *fw = asset_rdev(asset); int fw_index = 0; - if (prog->type == PROG_ROMSTAGE) + if (asset_type(asset) == ASSET_ROMSTAGE) fw_index = CONFIG_VBOOT_ROMSTAGE_INDEX; - else if (prog->type == PROG_RAMSTAGE) + else if (asset_type(asset) == ASSET_RAMSTAGE) fw_index = CONFIG_VBOOT_RAMSTAGE_INDEX; - else if (prog->type == PROG_PAYLOAD) + else if (asset_type(asset) == ASSET_PAYLOAD) fw_index = CONFIG_VBOOT_BOOT_LOADER_INDEX; - else if (prog->type == PROG_REFCODE) + else if (asset_type(asset) == ASSET_REFCODE) fw_index = CONFIG_VBOOT_REFCODE_INDEX; - else if (prog->type == PROG_BL31) + else if (asset_type(asset) == ASSET_BL31) fw_index = CONFIG_VBOOT_BL31_INDEX; else die("Invalid program type for vboot."); @@ -177,7 +177,7 @@ static int vboot_locate_by_components(const struct region_device *fw_main, } static int vboot_locate_by_multi_cbfs(const struct region_device *fw_main, - struct prog *prog) + struct asset *asset) { struct cbfsd cbfs; struct region_device rdev; @@ -192,21 +192,21 @@ static int vboot_locate_by_multi_cbfs(const struct region_device *fw_main, cbfs.rdev = &rdev; cbfs.align = props.align; - return cbfs_locate(&prog->rdev, &cbfs, prog->name, NULL); + return cbfs_locate(asset_rdev(asset), &cbfs, asset_name(asset), NULL); } -static int vboot_prog_locate(const struct region_device *fw_main, - struct prog *prog) +static int vboot_asset_locate(const struct region_device *fw_main, + struct asset *asset) { if (IS_ENABLED(CONFIG_MULTIPLE_CBFS_INSTANCES)) - return vboot_locate_by_multi_cbfs(fw_main, prog); + return vboot_locate_by_multi_cbfs(fw_main, asset); else - return vboot_locate_by_components(fw_main, prog); + return vboot_locate_by_components(fw_main, asset); } -/* This function is only called when vboot_loader_active() returns 1. That +/* This function is only called when vboot_active() returns 1. That * means we are taking vboot paths. */ -static int vboot_locate(struct prog *prog) +static int vboot_locate(struct asset *asset) { struct vb2_working_data *wd; struct region_device fw_main; @@ -221,11 +221,11 @@ static int vboot_locate(struct prog *prog) if (vb2_get_selected_region(wd, &fw_main)) die("failed to reference selected region\n"); - return vboot_prog_locate(&fw_main, prog); + return vboot_asset_locate(&fw_main, asset); } -const struct prog_loader_ops vboot_loader = { +const struct asset_provider vboot_provider = { .name = "VBOOT", - .is_loader_active = vboot_loader_active, + .is_active = vboot_active, .locate = vboot_locate, }; |