From b3847e64242228166976f425cd42331db7857551 Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Fri, 20 Mar 2015 15:55:08 -0500 Subject: 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 Reviewed-on: http://review.coreboot.org/8846 Tested-by: build bot (Jenkins) Tested-by: Raptor Engineering Automated Test Stand Reviewed-by: Marc Jones --- src/lib/Makefile.inc | 8 +++---- src/lib/arch_ops.c | 28 ----------------------- src/lib/loaders/load_and_run_payload.c | 2 +- src/lib/loaders/load_and_run_ramstage.c | 4 ++-- src/lib/loaders/load_and_run_romstage.c | 2 +- src/lib/prog_ops.c | 39 +++++++++++++++++++++++++++++++++ 6 files changed, 47 insertions(+), 36 deletions(-) delete mode 100644 src/lib/arch_ops.c create mode 100644 src/lib/prog_ops.c (limited to 'src/lib') diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc index 67cf577a52..5f149c9cfa 100644 --- a/src/lib/Makefile.inc +++ b/src/lib/Makefile.inc @@ -18,7 +18,7 @@ # subdirs-y += loaders -bootblock-y += arch_ops.c +bootblock-y += prog_ops.c bootblock-y += cbfs.c cbfs_core.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 += memcmp.c -verstage-y += arch_ops.c +verstage-y += prog_ops.c verstage-y += delay.c verstage-y += cbfs.c verstage-y += memcmp.c @@ -35,7 +35,7 @@ verstage-$(CONFIG_COMMON_CBFS_SPI_WRAPPER) += cbfs_spi.c verstage-y += tlcl.c verstage-$(CONFIG_GENERIC_UDELAY) += timer.c -romstage-y += arch_ops.c +romstage-y += prog_ops.c romstage-y += memchr.c romstage-y += memcmp.c $(foreach arch,$(ARCH_SUPPORTED),\ @@ -60,7 +60,7 @@ romstage-$(CONFIG_ARCH_ROMSTAGE_X86_32) += gcc.c ramstage-$(CONFIG_ARCH_RAMSTAGE_X86_32) += gcc.c endif -ramstage-y += arch_ops.c +ramstage-y += prog_ops.c ramstage-y += hardwaremain.c ramstage-y += selfboot.c ramstage-y += coreboot_table.c diff --git a/src/lib/arch_ops.c b/src/lib/arch_ops.c deleted file mode 100644 index ac1be77c9e..0000000000 --- a/src/lib/arch_ops.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file is part of the coreboot project. - * - * Copyright (C) 2014 Imagination Technologies - * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -/* For each segment of a program loaded this function is called*/ -void __attribute__ ((weak)) arch_segment_loaded(uintptr_t start, size_t size, - int flags) -{ - /* do nothing */ -} diff --git a/src/lib/loaders/load_and_run_payload.c b/src/lib/loaders/load_and_run_payload.c index 8e745c9b3b..e3208a9feb 100644 --- a/src/lib/loaders/load_and_run_payload.c +++ b/src/lib/loaders/load_and_run_payload.c @@ -83,7 +83,7 @@ out: 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 */ boot_successful(); diff --git a/src/lib/loaders/load_and_run_ramstage.c b/src/lib/loaders/load_and_run_ramstage.c index 82bc1e08fd..9067a28dc6 100644 --- a/src/lib/loaders/load_and_run_ramstage.c +++ b/src/lib/loaders/load_and_run_ramstage.c @@ -48,7 +48,7 @@ load_ramstage(const struct ramstage_loader_ops *ops, timestamp_add_now(TS_END_COPYRAM); - stage_exit(prog_entry(ramstage)); + prog_run(ramstage); } 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) { printk(BIOS_DEBUG, "Jumping to image.\n"); - stage_exit(prog_entry(ramstage)); + prog_run(ramstage); } } } diff --git a/src/lib/loaders/load_and_run_romstage.c b/src/lib/loaders/load_and_run_romstage.c index 3ad9176877..8467e90129 100644 --- a/src/lib/loaders/load_and_run_romstage.c +++ b/src/lib/loaders/load_and_run_romstage.c @@ -38,5 +38,5 @@ void run_romstage(void) halt(); } - stage_exit(prog_entry(&romstage)); + prog_run(&romstage); } diff --git a/src/lib/prog_ops.c b/src/lib/prog_ops.c new file mode 100644 index 0000000000..755b135615 --- /dev/null +++ b/src/lib/prog_ops.c @@ -0,0 +1,39 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2014 Imagination Technologies + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +/* For each segment of a program loaded this function is called*/ +void __attribute__ ((weak)) arch_segment_loaded(uintptr_t start, size_t size, + int flags) +{ + /* 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 */ +} -- cgit v1.2.3