From 65200f0746d09ea3e53da248c7dabc4f19c80715 Mon Sep 17 00:00:00 2001 From: Arthur Heymans Date: Thu, 20 Dec 2018 11:23:56 +0100 Subject: mb/qemu-{i440fx,q35}: Use POSTCAR stage to load the ramstage Qemu does not have a real CAR but postcar stage is still useful for testing the stage. The postcar stage is also mandatory for x86_64 to setup pagetables for x86_64 ramstage. Do not set up MTRRs, as qemu ignores them anyways. Tested on qemu-i440fx and qemu-q35. Change-Id: I6638534d99fde312e55b6a6be8c95e4cb25cca80 Signed-off-by: Arthur Heymans Signed-off-by: Patrick Rudolph Reviewed-on: https://review.coreboot.org/c/coreboot/+/30499 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi --- src/lib/Makefile.inc | 1 + src/mainboard/emulation/qemu-i440fx/Kconfig | 3 ++- src/mainboard/emulation/qemu-i440fx/Makefile.inc | 3 +++ src/mainboard/emulation/qemu-i440fx/exit_car.S | 18 ++++++++++++++++++ src/mainboard/emulation/qemu-i440fx/romstage.c | 16 +++++++++++++++- src/mainboard/emulation/qemu-q35/Kconfig | 3 ++- src/mainboard/emulation/qemu-q35/Makefile.inc | 5 +++++ src/mainboard/emulation/qemu-q35/romstage.c | 16 +++++++++++++++- 8 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 src/mainboard/emulation/qemu-i440fx/exit_car.S (limited to 'src') diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc index fa1ff8bccd..70bbece49d 100644 --- a/src/lib/Makefile.inc +++ b/src/lib/Makefile.inc @@ -133,6 +133,7 @@ ramstage-y += wrdd.c ramstage-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c ramstage-$(CONFIG_BOOTSPLASH) += jpeg.c ramstage-$(CONFIG_TRACE) += trace.c +postcar-$(CONFIG_TRACE) += trace.c ramstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c ramstage-$(CONFIG_COVERAGE) += libgcov.c ramstage-y += edid.c diff --git a/src/mainboard/emulation/qemu-i440fx/Kconfig b/src/mainboard/emulation/qemu-i440fx/Kconfig index 78ca2d9d64..23526f96d9 100644 --- a/src/mainboard/emulation/qemu-i440fx/Kconfig +++ b/src/mainboard/emulation/qemu-i440fx/Kconfig @@ -12,7 +12,8 @@ config BOARD_SPECIFIC_OPTIONS select BOARD_ROMSIZE_KB_256 select MAINBOARD_HAS_NATIVE_VGA_INIT select MAINBOARD_FORCE_NATIVE_VGA_INIT - select NO_CAR_GLOBAL_MIGRATION + select POSTCAR_STAGE + select POSTCAR_CONSOLE config MAINBOARD_DIR string diff --git a/src/mainboard/emulation/qemu-i440fx/Makefile.inc b/src/mainboard/emulation/qemu-i440fx/Makefile.inc index 8c19afc128..e3ca3002ff 100644 --- a/src/mainboard/emulation/qemu-i440fx/Makefile.inc +++ b/src/mainboard/emulation/qemu-i440fx/Makefile.inc @@ -3,3 +3,6 @@ ramstage-y += fw_cfg.c romstage-y += fw_cfg.c romstage-y += memory.c ramstage-y += memory.c +postcar-y += memory.c +postcar-y += fw_cfg.c +postcar-y += exit_car.S diff --git a/src/mainboard/emulation/qemu-i440fx/exit_car.S b/src/mainboard/emulation/qemu-i440fx/exit_car.S new file mode 100644 index 0000000000..06f1256768 --- /dev/null +++ b/src/mainboard/emulation/qemu-i440fx/exit_car.S @@ -0,0 +1,18 @@ +/* + * This file is part of the coreboot project. + * + * 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. + */ +.text +.global chipset_teardown_car +chipset_teardown_car: + /* There's no CAR to tear down */ + ret diff --git a/src/mainboard/emulation/qemu-i440fx/romstage.c b/src/mainboard/emulation/qemu-i440fx/romstage.c index e31394c282..e1d4f62708 100644 --- a/src/mainboard/emulation/qemu-i440fx/romstage.c +++ b/src/mainboard/emulation/qemu-i440fx/romstage.c @@ -23,11 +23,25 @@ asmlinkage void car_stage_entry(void) { + struct postcar_frame pcf; + console_init(); cbmem_recovery(0); timestamp_add_now(TS_START_ROMSTAGE); - run_ramstage(); + /** + * The LZMA decoder needs about 4 KiB stack. + * Leave 1 KiB stack for general postcar code. + */ + if (postcar_frame_init(&pcf, 5 * KiB)) + die("Unable to initialize postcar frame.\n"); + + /** + * Run postcar to tear down CAR and load relocatable ramstage. + * There's no CAR on qemu, but for educational purposes and + * testing the postcar stage is used on qemu, too. + */ + run_postcar_phase(&pcf); } diff --git a/src/mainboard/emulation/qemu-q35/Kconfig b/src/mainboard/emulation/qemu-q35/Kconfig index 1ceb62c968..815b93b012 100644 --- a/src/mainboard/emulation/qemu-q35/Kconfig +++ b/src/mainboard/emulation/qemu-q35/Kconfig @@ -11,7 +11,8 @@ config BOARD_SPECIFIC_OPTIONS select BOARD_ROMSIZE_KB_2048 select MAINBOARD_HAS_NATIVE_VGA_INIT select MAINBOARD_FORCE_NATIVE_VGA_INIT - select NO_CAR_GLOBAL_MIGRATION + select POSTCAR_STAGE + select POSTCAR_CONSOLE config MAINBOARD_DIR string diff --git a/src/mainboard/emulation/qemu-q35/Makefile.inc b/src/mainboard/emulation/qemu-q35/Makefile.inc index a52aad42fc..b18d2e4f97 100644 --- a/src/mainboard/emulation/qemu-q35/Makefile.inc +++ b/src/mainboard/emulation/qemu-q35/Makefile.inc @@ -3,4 +3,9 @@ ramstage-y += ../qemu-i440fx/memory.c ramstage-y += ../qemu-i440fx/fw_cfg.c romstage-y += ../qemu-i440fx/memory.c romstage-y += ../qemu-i440fx/fw_cfg.c + +postcar-y += ../qemu-i440fx/memory.c +postcar-y += ../qemu-i440fx/exit_car.S +postcar-y += ../qemu-i440fx/fw_cfg.c + bootblock-y += bootblock.c diff --git a/src/mainboard/emulation/qemu-q35/romstage.c b/src/mainboard/emulation/qemu-q35/romstage.c index 2b8d9351c0..3e0870ffec 100644 --- a/src/mainboard/emulation/qemu-q35/romstage.c +++ b/src/mainboard/emulation/qemu-q35/romstage.c @@ -24,6 +24,7 @@ asmlinkage void car_stage_entry(void) { + struct postcar_frame pcf; i82801ix_early_init(); console_init(); @@ -31,5 +32,18 @@ asmlinkage void car_stage_entry(void) timestamp_add_now(TS_START_ROMSTAGE); - run_ramstage(); + /** + * The LZMA decoder needs about 4 KiB stack. + * Leave 1 KiB stack for general postcar code. + */ + if (postcar_frame_init(&pcf, 5 * KiB)) + die("Unable to initialize postcar frame.\n"); + + /** + * Run postcar to tear down CAR and load relocatable ramstage. + * There's no CAR on qemu, but for educational purposes and + * testing the postcar stage is used on qemu, too. + */ + + run_postcar_phase(&pcf); } -- cgit v1.2.3