rmodule: use struct prog while loading rmodules

The rmod_stage_load structure contained the same fields
as struct prog. In order to more closely integrate with the
rest of program loading use struct prog.

Change-Id: Ib7f45d0b3573e6d518864deacc4002802b11aa9c
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/9143
Tested-by: build bot (Jenkins)
Reviewed-by: Marc Jones <marc.jones@se-eng.com>
This commit is contained in:
Aaron Durbin 2015-03-27 21:17:22 -05:00 committed by Aaron Durbin
parent ce9efe061a
commit 460703bbb4
5 changed files with 32 additions and 32 deletions

View File

@ -55,15 +55,11 @@ int rmodule_calc_region(unsigned int region_alignment, size_t rmodule_size,
* using dynamic cbmem because it uses the dynamic cbmem API to obtain * using dynamic cbmem because it uses the dynamic cbmem API to obtain
* the backing store region for the stage. */ * the backing store region for the stage. */
struct cbfs_stage; struct cbfs_stage;
struct cbmem_entry; struct prog;
struct rmod_stage_load { struct rmod_stage_load {
/* Inputs */
uint32_t cbmem_id; uint32_t cbmem_id;
const char *name; struct prog *prog;
/* Outputs */
const struct cbmem_entry *cbmem_entry;
void *entry;
}; };
/* Both of the following functions return 0 on success, -1 on error. */ /* Both of the following functions return 0 on success, -1 on error. */

View File

@ -29,7 +29,7 @@ static int cbfs_load_ramstage(struct prog *ramstage)
{ {
struct rmod_stage_load rmod_ram = { struct rmod_stage_load rmod_ram = {
.cbmem_id = CBMEM_ID_RAMSTAGE, .cbmem_id = CBMEM_ID_RAMSTAGE,
.name = ramstage->name, .prog = ramstage,
}; };
if (rmodule_stage_load_from_cbfs(&rmod_ram)) { if (rmodule_stage_load_from_cbfs(&rmod_ram)) {
@ -37,10 +37,6 @@ static int cbfs_load_ramstage(struct prog *ramstage)
return -1; return -1;
} }
prog_set_area(ramstage, cbmem_entry_start(rmod_ram.cbmem_entry),
cbmem_entry_size(rmod_ram.cbmem_entry));
prog_set_entry(ramstage, rmod_ram.entry, NULL);
return 0; return 0;
} }

View File

@ -261,7 +261,7 @@ int rmodule_stage_load(struct rmod_stage_load *rsl, struct cbfs_stage *stage)
int load_offset; int load_offset;
const struct cbmem_entry *cbmem_entry; const struct cbmem_entry *cbmem_entry;
if (stage == NULL || rsl->name == NULL) if (stage == NULL || rsl->prog == NULL || rsl->prog->name == NULL)
return -1; return -1;
rmodule_offset = rmodule_offset =
@ -276,7 +276,7 @@ int rmodule_stage_load(struct rmod_stage_load *rsl, struct cbfs_stage *stage)
stage_region = cbmem_entry_start(cbmem_entry); stage_region = cbmem_entry_start(cbmem_entry);
printk(BIOS_INFO, "Decompressing stage %s @ 0x%p (%d bytes)\n", printk(BIOS_INFO, "Decompressing stage %s @ 0x%p (%d bytes)\n",
rsl->name, &stage_region[rmodule_offset], stage->memlen); rsl->prog->name, &stage_region[rmodule_offset], stage->memlen);
if (!cbfs_decompress(stage->compression, &stage[1], if (!cbfs_decompress(stage->compression, &stage[1],
&stage_region[rmodule_offset], stage->len)) &stage_region[rmodule_offset], stage->len))
@ -288,8 +288,8 @@ int rmodule_stage_load(struct rmod_stage_load *rsl, struct cbfs_stage *stage)
if (rmodule_load(&stage_region[load_offset], &rmod_stage)) if (rmodule_load(&stage_region[load_offset], &rmod_stage))
return -1; return -1;
rsl->cbmem_entry = cbmem_entry; prog_set_area(rsl->prog, stage_region, cbmem_entry_size(cbmem_entry));
rsl->entry = rmodule_entry(&rmod_stage); prog_set_entry(rsl->prog, rmodule_entry(&rmod_stage), NULL);
return 0; return 0;
} }
@ -299,7 +299,7 @@ int rmodule_stage_load_from_cbfs(struct rmod_stage_load *rsl)
struct cbfs_stage *stage; struct cbfs_stage *stage;
stage = cbfs_get_file_content(CBFS_DEFAULT_MEDIA, stage = cbfs_get_file_content(CBFS_DEFAULT_MEDIA,
rsl->name, CBFS_TYPE_STAGE, NULL); rsl->prog->name, CBFS_TYPE_STAGE, NULL);
if (stage == NULL) if (stage == NULL)
return -1; return -1;

View File

@ -23,6 +23,7 @@
#include <console/console.h> #include <console/console.h>
#include <console/streams.h> #include <console/streams.h>
#include <cpu/x86/tsc.h> #include <cpu/x86/tsc.h>
#include <program_loading.h>
#include <rmodule.h> #include <rmodule.h>
#include <ramstage_cache.h> #include <ramstage_cache.h>
#if IS_ENABLED(CONFIG_CHROMEOS) #if IS_ENABLED(CONFIG_CHROMEOS)
@ -84,16 +85,16 @@ static void cache_refcode(const struct rmod_stage_load *rsl)
/* Determine how much remaining cache available. */ /* Determine how much remaining cache available. */
cache_size -= c->size + sizeof(*c); cache_size -= c->size + sizeof(*c);
if (cache_size < (sizeof(*c) + cbmem_entry_size(rsl->cbmem_entry))) { if (cache_size < (sizeof(*c) + prog_size(rsl->prog))) {
printk(BIOS_DEBUG, "Not enough cache space for ref code.\n"); printk(BIOS_DEBUG, "Not enough cache space for ref code.\n");
return; return;
} }
c = next_cache(c); c = next_cache(c);
c->magic = RAMSTAGE_CACHE_MAGIC; c->magic = RAMSTAGE_CACHE_MAGIC;
c->entry_point = (uint32_t)rsl->entry; c->entry_point = (uint32_t)(uintptr_t)prog_entry(rsl->prog);
c->load_address = (uint32_t)cbmem_entry_start(rsl->cbmem_entry); c->load_address = (uint32_t)(uintptr_t)prog_start(rsl->prog);
c->size = cbmem_entry_size(rsl->cbmem_entry); c->size = prog_size(rsl->prog);
printk(BIOS_DEBUG, "Caching refcode at 0x%p(%x)\n", printk(BIOS_DEBUG, "Caching refcode at 0x%p(%x)\n",
&c->program[0], c->size); &c->program[0], c->size);
@ -119,7 +120,7 @@ static int load_refcode_from_vboot(struct rmod_stage_load *refcode)
printk(BIOS_DEBUG, "refcode loading from vboot rw area.\n"); printk(BIOS_DEBUG, "refcode loading from vboot rw area.\n");
stage = (void *)(uintptr_t)fwc->address; stage = (void *)(uintptr_t)fwc->address;
if (rmodule_stage_load(refcode, stage) || refcode->entry == NULL) { if (rmodule_stage_load(refcode, stage)) {
printk(BIOS_DEBUG, "Error loading reference code.\n"); printk(BIOS_DEBUG, "Error loading reference code.\n");
return -1; return -1;
} }
@ -136,7 +137,7 @@ static int load_refcode_from_cbfs(struct rmod_stage_load *refcode)
{ {
printk(BIOS_DEBUG, "refcode loading from cbfs.\n"); printk(BIOS_DEBUG, "refcode loading from cbfs.\n");
if (rmodule_stage_load_from_cbfs(refcode) || refcode->entry == NULL) { if (rmodule_stage_load_from_cbfs(refcode)) {
printk(BIOS_DEBUG, "Error loading reference code.\n"); printk(BIOS_DEBUG, "Error loading reference code.\n");
return -1; return -1;
} }
@ -146,9 +147,12 @@ static int load_refcode_from_cbfs(struct rmod_stage_load *refcode)
static efi_wrapper_entry_t load_reference_code(void) static efi_wrapper_entry_t load_reference_code(void)
{ {
struct prog prog = {
.name = CONFIG_CBFS_PREFIX "/refcode",
};
struct rmod_stage_load refcode = { struct rmod_stage_load refcode = {
.cbmem_id = CBMEM_ID_REFCODE, .cbmem_id = CBMEM_ID_REFCODE,
.name = CONFIG_CBFS_PREFIX "/refcode", .prog = &prog,
}; };
if (acpi_is_wakeup_s3()) { if (acpi_is_wakeup_s3()) {
@ -162,7 +166,7 @@ static efi_wrapper_entry_t load_reference_code(void)
/* Cache loaded reference code. */ /* Cache loaded reference code. */
cache_refcode(&refcode); cache_refcode(&refcode);
return refcode.entry; return prog_entry(&prog);
} }
void baytrail_run_reference_code(void) void baytrail_run_reference_code(void)

View File

@ -23,6 +23,7 @@
#include <console/console.h> #include <console/console.h>
#include <console/streams.h> #include <console/streams.h>
#include <cpu/x86/tsc.h> #include <cpu/x86/tsc.h>
#include <program_loading.h>
#include <rmodule.h> #include <rmodule.h>
#include <ramstage_cache.h> #include <ramstage_cache.h>
#include <string.h> #include <string.h>
@ -80,16 +81,16 @@ static void cache_refcode(const struct rmod_stage_load *rsl)
/* Determine how much remaining cache available. */ /* Determine how much remaining cache available. */
cache_size -= c->size + sizeof(*c); cache_size -= c->size + sizeof(*c);
if (cache_size < (sizeof(*c) + cbmem_entry_size(rsl->cbmem_entry))) { if (cache_size < (sizeof(*c) + prog_size(rsl->prog))) {
printk(BIOS_DEBUG, "Not enough cache space for ref code.\n"); printk(BIOS_DEBUG, "Not enough cache space for ref code.\n");
return; return;
} }
c = next_cache(c); c = next_cache(c);
c->magic = RAMSTAGE_CACHE_MAGIC; c->magic = RAMSTAGE_CACHE_MAGIC;
c->entry_point = (uint32_t)rsl->entry; c->entry_point = (uint32_t)(uintptr_t)prog_entry(rsl->prog);
c->load_address = (uint32_t)cbmem_entry_start(rsl->cbmem_entry); c->load_address = (uint32_t)(uintptr_t)prog_start(rsl->prog);
c->size = cbmem_entry_size(rsl->cbmem_entry); c->size = prog_size(rsl->prog);
printk(BIOS_DEBUG, "Caching refcode at 0x%p(%x)\n", printk(BIOS_DEBUG, "Caching refcode at 0x%p(%x)\n",
&c->program[0], c->size); &c->program[0], c->size);
@ -115,7 +116,7 @@ static int load_refcode_from_vboot(struct rmod_stage_load *refcode)
printk(BIOS_DEBUG, "refcode loading from vboot rw area.\n"); printk(BIOS_DEBUG, "refcode loading from vboot rw area.\n");
stage = (void *)(uintptr_t)fwc->address; stage = (void *)(uintptr_t)fwc->address;
if (rmodule_stage_load(refcode, stage) || refcode->entry == NULL) { if (rmodule_stage_load(refcode, stage)) {
printk(BIOS_DEBUG, "Error loading reference code.\n"); printk(BIOS_DEBUG, "Error loading reference code.\n");
return -1; return -1;
} }
@ -132,7 +133,7 @@ static int load_refcode_from_cbfs(struct rmod_stage_load *refcode)
{ {
printk(BIOS_DEBUG, "refcode loading from cbfs.\n"); printk(BIOS_DEBUG, "refcode loading from cbfs.\n");
if (rmodule_stage_load_from_cbfs(refcode) || refcode->entry == NULL) { if (rmodule_stage_load_from_cbfs(refcode)) {
printk(BIOS_DEBUG, "Error loading reference code.\n"); printk(BIOS_DEBUG, "Error loading reference code.\n");
return -1; return -1;
} }
@ -142,9 +143,12 @@ static int load_refcode_from_cbfs(struct rmod_stage_load *refcode)
static pei_wrapper_entry_t load_reference_code(void) static pei_wrapper_entry_t load_reference_code(void)
{ {
struct prog prog = {
.name = CONFIG_CBFS_PREFIX "/refcode",
};
struct rmod_stage_load refcode = { struct rmod_stage_load refcode = {
.cbmem_id = CBMEM_ID_REFCODE, .cbmem_id = CBMEM_ID_REFCODE,
.name = CONFIG_CBFS_PREFIX "/refcode", .prog = &prog,
}; };
if (acpi_is_wakeup_s3()) { if (acpi_is_wakeup_s3()) {
@ -158,7 +162,7 @@ static pei_wrapper_entry_t load_reference_code(void)
/* Cache loaded reference code. */ /* Cache loaded reference code. */
cache_refcode(&refcode); cache_refcode(&refcode);
return refcode.entry; return prog_entry(&prog);
} }
void broadwell_run_reference_code(void) void broadwell_run_reference_code(void)