program loading: add prog_run() function
The prog_run() function abstracts away what is required for running a given program. Within it, there are 2 calls: 1. platform_prog_run() and 2. arch_prog_run(). The platform_prog_run() allows for a chipset to intercept a program that will be run. This allows for CPU switching as currently needed in t124 and t132. Change-Id: I22a5dd5bfb1018e7e46475e47ac993a0941e2a8c Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/8846 Tested-by: build bot (Jenkins) Tested-by: Raptor Engineering Automated Test Stand <noreply@raptorengineeringinc.com> Reviewed-by: Marc Jones <marc.jones@se-eng.com>
This commit is contained in:
parent
3948e5392b
commit
b3847e6424
|
@ -54,6 +54,7 @@ ifeq ($(CONFIG_ARCH_BOOTBLOCK_ARM),y)
|
||||||
bootblock-y += id.S
|
bootblock-y += id.S
|
||||||
$(obj)/arch/arm/id.bootblock.o: $(obj)/build.h
|
$(obj)/arch/arm/id.bootblock.o: $(obj)/build.h
|
||||||
|
|
||||||
|
bootblock-y += boot.c
|
||||||
bootblock-y += stages.c
|
bootblock-y += stages.c
|
||||||
bootblock-y += eabi_compat.c
|
bootblock-y += eabi_compat.c
|
||||||
bootblock-y += memset.S
|
bootblock-y += memset.S
|
||||||
|
@ -89,6 +90,7 @@ verstage-y += stages.c
|
||||||
|
|
||||||
ifeq ($(CONFIG_ARCH_ROMSTAGE_ARM),y)
|
ifeq ($(CONFIG_ARCH_ROMSTAGE_ARM),y)
|
||||||
|
|
||||||
|
romstage-y += boot.c
|
||||||
romstage-y += stages.c
|
romstage-y += stages.c
|
||||||
romstage-y += div0.c
|
romstage-y += div0.c
|
||||||
romstage-y += eabi_compat.c
|
romstage-y += eabi_compat.c
|
||||||
|
|
|
@ -20,12 +20,17 @@
|
||||||
#include <arch/cache.h>
|
#include <arch/cache.h>
|
||||||
#include <program_loading.h>
|
#include <program_loading.h>
|
||||||
|
|
||||||
void arch_payload_run(const struct payload *payload)
|
void arch_prog_run(struct prog *prog)
|
||||||
{
|
{
|
||||||
void (*doit)(void *);
|
void (*doit)(void *);
|
||||||
|
|
||||||
cache_sync_instructions();
|
cache_sync_instructions();
|
||||||
|
|
||||||
doit = prog_entry(&payload->prog);
|
doit = prog_entry(prog);
|
||||||
doit(prog_entry_arg(&payload->prog));
|
doit(prog_entry_arg(prog));
|
||||||
|
}
|
||||||
|
|
||||||
|
void arch_payload_run(struct payload *payload)
|
||||||
|
{
|
||||||
|
arch_prog_run(&payload->prog);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ bootblock-y += div0.c
|
||||||
bootblock-y += id.S
|
bootblock-y += id.S
|
||||||
$(obj)/arch/arm64/id.bootblock.o: $(obj)/build.h
|
$(obj)/arch/arm64/id.bootblock.o: $(obj)/build.h
|
||||||
|
|
||||||
|
bootblock-y += boot.c
|
||||||
bootblock-y += c_entry.c
|
bootblock-y += c_entry.c
|
||||||
bootblock-y += stage_entry.S
|
bootblock-y += stage_entry.S
|
||||||
bootblock-y += stages.c
|
bootblock-y += stages.c
|
||||||
|
@ -81,6 +82,7 @@ endif # CONFIG_ARCH_BOOTBLOCK_ARM64
|
||||||
|
|
||||||
ifeq ($(CONFIG_ARCH_ROMSTAGE_ARM64),y)
|
ifeq ($(CONFIG_ARCH_ROMSTAGE_ARM64),y)
|
||||||
|
|
||||||
|
romstage-y += boot.c
|
||||||
romstage-y += c_entry.c
|
romstage-y += c_entry.c
|
||||||
romstage-y += stage_entry.S
|
romstage-y += stage_entry.S
|
||||||
romstage-y += stages.c
|
romstage-y += stages.c
|
||||||
|
|
|
@ -25,15 +25,16 @@
|
||||||
#include <arch/transition.h>
|
#include <arch/transition.h>
|
||||||
#include <console/console.h>
|
#include <console/console.h>
|
||||||
#include <program_loading.h>
|
#include <program_loading.h>
|
||||||
|
#include <rules.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
void arch_payload_run(const struct payload *payload)
|
static void run_payload(struct prog *prog)
|
||||||
{
|
{
|
||||||
void (*doit)(void *);
|
void (*doit)(void *);
|
||||||
void *arg;
|
void *arg;
|
||||||
|
|
||||||
doit = prog_entry(&payload->prog);
|
doit = prog_entry(prog);
|
||||||
arg = prog_entry_arg(&payload->prog);
|
arg = prog_entry_arg(prog);
|
||||||
|
|
||||||
uint8_t current_el = get_current_el();
|
uint8_t current_el = get_current_el();
|
||||||
|
|
||||||
|
@ -61,3 +62,23 @@ void arch_payload_run(const struct payload *payload)
|
||||||
cache_sync_instructions();
|
cache_sync_instructions();
|
||||||
transition_with_entry(doit, arg, &exc_state);
|
transition_with_entry(doit, arg, &exc_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void arch_prog_run(struct prog *prog)
|
||||||
|
{
|
||||||
|
void (*doit)(void *);
|
||||||
|
void *arg;
|
||||||
|
|
||||||
|
if (ENV_RAMSTAGE && prog->type == PROG_PAYLOAD)
|
||||||
|
run_payload(prog);
|
||||||
|
return;
|
||||||
|
|
||||||
|
doit = prog_entry(prog);
|
||||||
|
arg = prog_entry_arg(prog);
|
||||||
|
|
||||||
|
doit(prog_entry_arg(prog));
|
||||||
|
}
|
||||||
|
|
||||||
|
void arch_payload_run(struct payload *payload)
|
||||||
|
{
|
||||||
|
arch_prog_run(&payload->prog);
|
||||||
|
}
|
||||||
|
|
|
@ -20,7 +20,12 @@
|
||||||
#include <arch/stages.h>
|
#include <arch/stages.h>
|
||||||
#include <program_loading.h>
|
#include <program_loading.h>
|
||||||
|
|
||||||
void arch_payload_run(const struct payload *payload)
|
void arch_prog_run(struct prog *prog)
|
||||||
{
|
{
|
||||||
stage_exit(prog_entry(&payload->prog));
|
stage_exit(prog_entry(prog));
|
||||||
|
}
|
||||||
|
|
||||||
|
void arch_payload_run(struct payload *payload)
|
||||||
|
{
|
||||||
|
arch_prog_run(&payload->prog);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ ifeq ($(CONFIG_ARCH_BOOTBLOCK_RISCV),y)
|
||||||
bootblock_lds = $(src)/arch/riscv/bootblock.ld
|
bootblock_lds = $(src)/arch/riscv/bootblock.ld
|
||||||
|
|
||||||
bootblock-y = bootblock.S stages.c
|
bootblock-y = bootblock.S stages.c
|
||||||
|
bootblock-y += boot.c
|
||||||
bootblock-y += rom_media.c
|
bootblock-y += rom_media.c
|
||||||
bootblock-y += \
|
bootblock-y += \
|
||||||
$(top)/src/lib/memchr.c \
|
$(top)/src/lib/memchr.c \
|
||||||
|
@ -52,6 +53,7 @@ endif
|
||||||
################################################################################
|
################################################################################
|
||||||
ifeq ($(CONFIG_ARCH_ROMSTAGE_RISCV),y)
|
ifeq ($(CONFIG_ARCH_ROMSTAGE_RISCV),y)
|
||||||
|
|
||||||
|
romstage-y += boot.c
|
||||||
romstage-y += stages.c
|
romstage-y += stages.c
|
||||||
romstage-y += rom_media.c
|
romstage-y += rom_media.c
|
||||||
romstage-y += \
|
romstage-y += \
|
||||||
|
|
|
@ -17,11 +17,17 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <arch/stages.h>
|
|
||||||
#include <program_loading.h>
|
#include <program_loading.h>
|
||||||
|
|
||||||
void arch_payload_run(const struct payload *payload)
|
void arch_prog_run(struct prog *prog)
|
||||||
{
|
{
|
||||||
// uart_rx_byte(0);
|
void (*doit)(void *);
|
||||||
stage_exit(prog_entry(&payload->prog));
|
|
||||||
|
doit = prog_entry(prog);
|
||||||
|
doit(prog_entry_arg(prog));
|
||||||
|
}
|
||||||
|
|
||||||
|
void arch_payload_run(struct payload *payload)
|
||||||
|
{
|
||||||
|
arch_prog_run(&payload->prog);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y)
|
ifeq ($(CONFIG_ARCH_ROMSTAGE_X86_32),y)
|
||||||
|
|
||||||
romstage-y += cbmem.c
|
romstage-y += cbmem.c
|
||||||
|
romstage-y += boot.c
|
||||||
|
|
||||||
endif # CONFIG_ARCH_ROMSTAGE_X86_32
|
endif # CONFIG_ARCH_ROMSTAGE_X86_32
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ static void jmp_payload(void *entry, unsigned long buffer, unsigned long size)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void arch_payload_run(const struct payload *payload)
|
void arch_payload_run(struct payload *payload)
|
||||||
{
|
{
|
||||||
if (IS_ENABLED(CONFIG_RELOCATABLE_RAMSTAGE))
|
if (IS_ENABLED(CONFIG_RELOCATABLE_RAMSTAGE))
|
||||||
jmp_payload_no_bounce_buffer(prog_entry(&payload->prog));
|
jmp_payload_no_bounce_buffer(prog_entry(&payload->prog));
|
||||||
|
@ -132,3 +132,11 @@ void arch_payload_run(const struct payload *payload)
|
||||||
(uintptr_t)payload->bounce.data,
|
(uintptr_t)payload->bounce.data,
|
||||||
payload->bounce.size);
|
payload->bounce.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void arch_prog_run(struct prog *prog)
|
||||||
|
{
|
||||||
|
__asm__ volatile (
|
||||||
|
"jmp *%%edi\n"
|
||||||
|
:: "D"(prog_entry(prog))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -90,6 +90,16 @@ static inline void prog_set_entry(struct prog *prog, void *e, void *arg)
|
||||||
prog->arg = arg;
|
prog->arg = arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Run the program described by prog. */
|
||||||
|
void prog_run(struct prog *prog);
|
||||||
|
/* Per architecture implementation running a program. */
|
||||||
|
void arch_prog_run(struct prog *prog);
|
||||||
|
/* Platform (SoC/chipset) specific overrides for running a program. This is
|
||||||
|
* called prior to calling the arch_prog_run. Thus, if there is anything
|
||||||
|
* special that needs to be done by the platform similar to the architecture
|
||||||
|
* code it needs to that as well. */
|
||||||
|
void platform_prog_run(struct prog *prog);
|
||||||
|
|
||||||
/************************
|
/************************
|
||||||
* ROMSTAGE LOADING *
|
* ROMSTAGE LOADING *
|
||||||
************************/
|
************************/
|
||||||
|
@ -143,7 +153,7 @@ void payload_run(void);
|
||||||
void mirror_payload(struct payload *payload);
|
void mirror_payload(struct payload *payload);
|
||||||
|
|
||||||
/* architecture specific function to run payload. */
|
/* architecture specific function to run payload. */
|
||||||
void arch_payload_run(const struct payload *payload);
|
void arch_payload_run(struct payload *payload);
|
||||||
|
|
||||||
/* Payload loading operations. */
|
/* Payload loading operations. */
|
||||||
struct payload_loader_ops {
|
struct payload_loader_ops {
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#
|
#
|
||||||
subdirs-y += loaders
|
subdirs-y += loaders
|
||||||
|
|
||||||
bootblock-y += arch_ops.c
|
bootblock-y += prog_ops.c
|
||||||
bootblock-y += cbfs.c cbfs_core.c
|
bootblock-y += cbfs.c cbfs_core.c
|
||||||
bootblock-$(CONFIG_COMMON_CBFS_SPI_WRAPPER) += cbfs_spi.c
|
bootblock-$(CONFIG_COMMON_CBFS_SPI_WRAPPER) += cbfs_spi.c
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ bootblock-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
|
||||||
bootblock-y += memchr.c
|
bootblock-y += memchr.c
|
||||||
bootblock-y += memcmp.c
|
bootblock-y += memcmp.c
|
||||||
|
|
||||||
verstage-y += arch_ops.c
|
verstage-y += prog_ops.c
|
||||||
verstage-y += delay.c
|
verstage-y += delay.c
|
||||||
verstage-y += cbfs.c
|
verstage-y += cbfs.c
|
||||||
verstage-y += memcmp.c
|
verstage-y += memcmp.c
|
||||||
|
@ -35,7 +35,7 @@ verstage-$(CONFIG_COMMON_CBFS_SPI_WRAPPER) += cbfs_spi.c
|
||||||
verstage-y += tlcl.c
|
verstage-y += tlcl.c
|
||||||
verstage-$(CONFIG_GENERIC_UDELAY) += timer.c
|
verstage-$(CONFIG_GENERIC_UDELAY) += timer.c
|
||||||
|
|
||||||
romstage-y += arch_ops.c
|
romstage-y += prog_ops.c
|
||||||
romstage-y += memchr.c
|
romstage-y += memchr.c
|
||||||
romstage-y += memcmp.c
|
romstage-y += memcmp.c
|
||||||
$(foreach arch,$(ARCH_SUPPORTED),\
|
$(foreach arch,$(ARCH_SUPPORTED),\
|
||||||
|
@ -60,7 +60,7 @@ romstage-$(CONFIG_ARCH_ROMSTAGE_X86_32) += gcc.c
|
||||||
ramstage-$(CONFIG_ARCH_RAMSTAGE_X86_32) += gcc.c
|
ramstage-$(CONFIG_ARCH_RAMSTAGE_X86_32) += gcc.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ramstage-y += arch_ops.c
|
ramstage-y += prog_ops.c
|
||||||
ramstage-y += hardwaremain.c
|
ramstage-y += hardwaremain.c
|
||||||
ramstage-y += selfboot.c
|
ramstage-y += selfboot.c
|
||||||
ramstage-y += coreboot_table.c
|
ramstage-y += coreboot_table.c
|
||||||
|
|
|
@ -83,7 +83,7 @@ out:
|
||||||
|
|
||||||
void payload_run(void)
|
void payload_run(void)
|
||||||
{
|
{
|
||||||
const struct payload *payload = &global_payload;
|
struct payload *payload = &global_payload;
|
||||||
|
|
||||||
/* Reset to booting from this image as late as possible */
|
/* Reset to booting from this image as late as possible */
|
||||||
boot_successful();
|
boot_successful();
|
||||||
|
|
|
@ -48,7 +48,7 @@ load_ramstage(const struct ramstage_loader_ops *ops,
|
||||||
|
|
||||||
timestamp_add_now(TS_END_COPYRAM);
|
timestamp_add_now(TS_END_COPYRAM);
|
||||||
|
|
||||||
stage_exit(prog_entry(ramstage));
|
prog_run(ramstage);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void run_ramstage_from_resume(struct romstage_handoff *handoff,
|
static void run_ramstage_from_resume(struct romstage_handoff *handoff,
|
||||||
|
@ -60,7 +60,7 @@ static void run_ramstage_from_resume(struct romstage_handoff *handoff,
|
||||||
|
|
||||||
if (prog_entry(ramstage) != NULL) {
|
if (prog_entry(ramstage) != NULL) {
|
||||||
printk(BIOS_DEBUG, "Jumping to image.\n");
|
printk(BIOS_DEBUG, "Jumping to image.\n");
|
||||||
stage_exit(prog_entry(ramstage));
|
prog_run(ramstage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,5 +38,5 @@ void run_romstage(void)
|
||||||
halt();
|
halt();
|
||||||
}
|
}
|
||||||
|
|
||||||
stage_exit(prog_entry(&romstage));
|
prog_run(&romstage);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,3 +26,14 @@ void __attribute__ ((weak)) arch_segment_loaded(uintptr_t start, size_t size,
|
||||||
{
|
{
|
||||||
/* do nothing */
|
/* do nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void prog_run(struct prog *prog)
|
||||||
|
{
|
||||||
|
platform_prog_run(prog);
|
||||||
|
arch_prog_run(prog);
|
||||||
|
}
|
||||||
|
|
||||||
|
void __attribute__ ((weak)) platform_prog_run(struct prog *prog)
|
||||||
|
{
|
||||||
|
/* do nothing */
|
||||||
|
}
|
Loading…
Reference in New Issue