Hello Arthur Heymans,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/30499
to review the following change.
Change subject: mb/qemu-{i440fx,q35}: Use POSTCAR stage to load the ramstage ......................................................................
mb/qemu-{i440fx,q35}: Use POSTCAR stage to load the ramstage
Qemu does not have a real CAR but postcar stage is still useful to setup pagetables for x86_64 ramstage.
Change-Id: I6638534d99fde312e55b6a6be8c95e4cb25cca80 Signed-off-by: Arthur Heymans arthur@aheymans.xyz Signed-off-by: Patrick Rudolph siro@das-labor.org --- M src/lib/Makefile.inc M src/mainboard/emulation/qemu-i440fx/Kconfig M src/mainboard/emulation/qemu-i440fx/Makefile.inc A src/mainboard/emulation/qemu-i440fx/exit_car.S M src/mainboard/emulation/qemu-i440fx/romstage.c M src/mainboard/emulation/qemu-q35/Kconfig M src/mainboard/emulation/qemu-q35/Makefile.inc M src/mainboard/emulation/qemu-q35/romstage.c 8 files changed, 75 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/99/30499/1
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc index 2fd4e4c..48dc664 100644 --- a/src/lib/Makefile.inc +++ b/src/lib/Makefile.inc @@ -132,6 +132,7 @@ 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 eb9f011..3a507d3 100644 --- a/src/mainboard/emulation/qemu-i440fx/Kconfig +++ b/src/mainboard/emulation/qemu-i440fx/Kconfig @@ -14,6 +14,8 @@ select MAINBOARD_FORCE_NATIVE_VGA_INIT select BOOTBLOCK_CONSOLE 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 9e2880a..de790e6 100644 --- a/src/mainboard/emulation/qemu-i440fx/Makefile.inc +++ b/src/mainboard/emulation/qemu-i440fx/Makefile.inc @@ -2,3 +2,5 @@ ramstage-y += fw_cfg.c romstage-y += memory.c ramstage-y += memory.c +postcar-y += memory.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 0000000..74f6ed2 --- /dev/null +++ b/src/mainboard/emulation/qemu-i440fx/exit_car.S @@ -0,0 +1,23 @@ +/* + * 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. + */ +#include <cpu/x86/mtrr.h> +#include <cpu/x86/cr.h> +/* jump directly to the main function, as there is no real CAR to tear down. */ +.text +.global chipset_teardown_car +chipset_teardown_car: + /* Set up new stack. */ + mov post_car_stack_top, %esp + /* Call C code */ + call main diff --git a/src/mainboard/emulation/qemu-i440fx/romstage.c b/src/mainboard/emulation/qemu-i440fx/romstage.c index e31394c..137dfbf 100644 --- a/src/mainboard/emulation/qemu-i440fx/romstage.c +++ b/src/mainboard/emulation/qemu-i440fx/romstage.c @@ -20,14 +20,35 @@ #include <cpu/intel/romstage.h> #include <timestamp.h> #include <program_loading.h> +#include <cpu/x86/mtrr.h> + +#include "memory.h"
asmlinkage void car_stage_entry(void) { + struct postcar_frame pcf; + console_init();
cbmem_recovery(0);
timestamp_add_now(TS_START_ROMSTAGE);
- run_ramstage(); + if (postcar_frame_init(&pcf, 5 * KiB)) + die("Unable to initialize postcar frame.\n"); + + /* Cache the ROM as WP just below 4GiB. */ + postcar_frame_add_romcache(&pcf, MTRR_TYPE_WRPROT); + + /* Cache memory below 4 GiB */ + postcar_frame_add_mtrr(&pcf, 0, qemu_get_memory_size() * KiB, + MTRR_TYPE_WRBACK); + + /* Cache memory beyond 4 GiB */ + if (qemu_get_high_memory_size() > 0) + postcar_frame_add_mtrr(&pcf, (4ULL * GiB), + qemu_get_high_memory_size() * KiB, + MTRR_TYPE_WRBACK); + + run_postcar_phase(&pcf); } diff --git a/src/mainboard/emulation/qemu-q35/Kconfig b/src/mainboard/emulation/qemu-q35/Kconfig index 1cc7148..07c15f3 100644 --- a/src/mainboard/emulation/qemu-q35/Kconfig +++ b/src/mainboard/emulation/qemu-q35/Kconfig @@ -13,6 +13,8 @@ select MAINBOARD_FORCE_NATIVE_VGA_INIT select BOOTBLOCK_CONSOLE 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 1c06d77..a0ac5dd 100644 --- a/src/mainboard/emulation/qemu-q35/Makefile.inc +++ b/src/mainboard/emulation/qemu-q35/Makefile.inc @@ -3,4 +3,6 @@ ramstage-y += ../qemu-i440fx/fw_cfg.c romstage-y += ../qemu-i440fx/memory.c
+postcar-y += ../qemu-i440fx/memory.c +postcar-y += ../qemu-i440fx/exit_car.S bootblock-y += bootblock.c diff --git a/src/mainboard/emulation/qemu-q35/romstage.c b/src/mainboard/emulation/qemu-q35/romstage.c index 2b8d935..badafdd 100644 --- a/src/mainboard/emulation/qemu-q35/romstage.c +++ b/src/mainboard/emulation/qemu-q35/romstage.c @@ -21,9 +21,13 @@ #include <timestamp.h> #include <southbridge/intel/i82801ix/i82801ix.h> #include <program_loading.h> +#include <cpu/x86/mtrr.h> + +#include "../qemu-i440fx/memory.h"
asmlinkage void car_stage_entry(void) { + struct postcar_frame pcf; i82801ix_early_init(); console_init();
@@ -31,5 +35,21 @@
timestamp_add_now(TS_START_ROMSTAGE);
- run_ramstage(); + if (postcar_frame_init(&pcf, 5 * KiB)) + die("Unable to initialize postcar frame.\n"); + + /* Cache the ROM as WP just below 4GiB. */ + postcar_frame_add_romcache(&pcf, MTRR_TYPE_WRPROT); + + /* Cache memory below 4 GiB */ + postcar_frame_add_mtrr(&pcf, 0, qemu_get_memory_size() * KiB, + MTRR_TYPE_WRBACK); + + /* Cache memory beyond 4 GiB */ + if (qemu_get_high_memory_size() > 0) + postcar_frame_add_mtrr(&pcf, (4ULL * GiB), + qemu_get_high_memory_size() * KiB, + MTRR_TYPE_WRBACK); + + run_postcar_phase(&pcf); }
Hello Arthur Heymans, build bot (Jenkins), Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/30499
to look at the new patch set (#2).
Change subject: mb/qemu-{i440fx,q35}: Use POSTCAR stage to load the ramstage ......................................................................
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.
Tested on qemu-i440fx and qemu-q35.
Change-Id: I6638534d99fde312e55b6a6be8c95e4cb25cca80 Signed-off-by: Arthur Heymans arthur@aheymans.xyz Signed-off-by: Patrick Rudolph siro@das-labor.org --- M src/lib/Makefile.inc M src/mainboard/emulation/qemu-i440fx/Kconfig M src/mainboard/emulation/qemu-i440fx/Makefile.inc A src/mainboard/emulation/qemu-i440fx/exit_car.S M src/mainboard/emulation/qemu-i440fx/romstage.c M src/mainboard/emulation/qemu-q35/Kconfig M src/mainboard/emulation/qemu-q35/Makefile.inc M src/mainboard/emulation/qemu-q35/romstage.c 8 files changed, 59 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/99/30499/2
Arthur Heymans has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/30499 )
Change subject: mb/qemu-{i440fx,q35}: Use POSTCAR stage to load the ramstage ......................................................................
Patch Set 2: Code-Review+2
Arthur Heymans has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/30499 )
Change subject: mb/qemu-{i440fx,q35}: Use POSTCAR stage to load the ramstage ......................................................................
Patch Set 2: Code-Review+1
(1 comment)
https://review.coreboot.org/#/c/30499/2/src/mainboard/emulation/qemu-i440fx/... File src/mainboard/emulation/qemu-i440fx/Kconfig:
https://review.coreboot.org/#/c/30499/2/src/mainboard/emulation/qemu-i440fx/... PS2, Line 16: select NO_CAR_GLOBAL_MIGRATION also selected by POSTCAR_STAGE
Hello Arthur Heymans, build bot (Jenkins), Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/30499
to look at the new patch set (#3).
Change subject: mb/qemu-{i440fx,q35}: Use POSTCAR stage to load the ramstage ......................................................................
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.
Tested on qemu-i440fx and qemu-q35.
Change-Id: I6638534d99fde312e55b6a6be8c95e4cb25cca80 Signed-off-by: Arthur Heymans arthur@aheymans.xyz Signed-off-by: Patrick Rudolph siro@das-labor.org --- M src/lib/Makefile.inc M src/mainboard/emulation/qemu-i440fx/Kconfig M src/mainboard/emulation/qemu-i440fx/Makefile.inc A src/mainboard/emulation/qemu-i440fx/exit_car.S M src/mainboard/emulation/qemu-i440fx/romstage.c M src/mainboard/emulation/qemu-q35/Kconfig M src/mainboard/emulation/qemu-q35/Makefile.inc M src/mainboard/emulation/qemu-q35/romstage.c 8 files changed, 59 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/99/30499/3
Patrick Rudolph has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/30499 )
Change subject: mb/qemu-{i440fx,q35}: Use POSTCAR stage to load the ramstage ......................................................................
Patch Set 3:
(1 comment)
https://review.coreboot.org/#/c/30499/2/src/mainboard/emulation/qemu-i440fx/... File src/mainboard/emulation/qemu-i440fx/Kconfig:
https://review.coreboot.org/#/c/30499/2/src/mainboard/emulation/qemu-i440fx/... PS2, Line 16: select NO_CAR_GLOBAL_MIGRATION
also selected by POSTCAR_STAGE
Done
Kyösti Mälkki has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/30499 )
Change subject: mb/qemu-{i440fx,q35}: Use POSTCAR stage to load the ramstage ......................................................................
Patch Set 3:
(2 comments)
https://review.coreboot.org/#/c/30499/3/src/mainboard/emulation/qemu-i440fx/... File src/mainboard/emulation/qemu-i440fx/romstage.c:
https://review.coreboot.org/#/c/30499/3/src/mainboard/emulation/qemu-i440fx/... PS3, Line 44: postcar_frame_add_mtrr(&pcf, 0, qemu_get_memory_size() * KiB, You need to honour MTRR alignment requirements here. Sort of.
From what I remember MTRRs are just dummy backup stores on QEMU, i.e. you can read back what you write there, so I think these poscar_frame_add_xx() calls don't make any sense.
https://review.coreboot.org/#/c/30499/3/src/mainboard/emulation/qemu-q35/rom... File src/mainboard/emulation/qemu-q35/romstage.c:
https://review.coreboot.org/#/c/30499/3/src/mainboard/emulation/qemu-q35/rom... PS3, Line 42: postcar_frame_add_romcache(&pcf, MTRR_TYPE_WRPROT); As before, MTRRs are dummies on QEMU, AFAIR.
Patrick Rudolph has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/30499 )
Change subject: mb/qemu-{i440fx,q35}: Use POSTCAR stage to load the ramstage ......................................................................
Patch Set 3:
(1 comment)
https://review.coreboot.org/#/c/30499/3/src/mainboard/emulation/qemu-i440fx/... File src/mainboard/emulation/qemu-i440fx/romstage.c:
https://review.coreboot.org/#/c/30499/3/src/mainboard/emulation/qemu-i440fx/... PS3, Line 44: postcar_frame_add_mtrr(&pcf, 0, qemu_get_memory_size() * KiB,
You need to honour MTRR alignment requirements here. Sort of. […]
Agree. They are used in the following patches to setup correct page tables for x86_64. I'll add a comment and explain why they are added and move them to the follow on patches.
Hello Kyösti Mälkki, Stefan T, Arthur Heymans, Gerd Hoffmann, Stefan Reinauer, build bot (Jenkins), Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/30499
to look at the new patch set (#4).
Change subject: mb/qemu-{i440fx,q35}: Use POSTCAR stage to load the ramstage ......................................................................
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 arthur@aheymans.xyz Signed-off-by: Patrick Rudolph siro@das-labor.org --- M src/lib/Makefile.inc M src/mainboard/emulation/qemu-i440fx/Kconfig M src/mainboard/emulation/qemu-i440fx/Makefile.inc A src/mainboard/emulation/qemu-i440fx/exit_car.S M src/mainboard/emulation/qemu-i440fx/romstage.c M src/mainboard/emulation/qemu-q35/Kconfig M src/mainboard/emulation/qemu-q35/Makefile.inc M src/mainboard/emulation/qemu-q35/romstage.c 8 files changed, 69 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/99/30499/4
Patrick Rudolph has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/30499 )
Change subject: mb/qemu-{i440fx,q35}: Use POSTCAR stage to load the ramstage ......................................................................
Patch Set 4:
(2 comments)
https://review.coreboot.org/#/c/30499/3/src/mainboard/emulation/qemu-i440fx/... File src/mainboard/emulation/qemu-i440fx/romstage.c:
https://review.coreboot.org/#/c/30499/3/src/mainboard/emulation/qemu-i440fx/... PS3, Line 44: postcar_frame_add_mtrr(&pcf, 0, qemu_get_memory_size() * KiB,
Agree. They are used in the following patches to setup correct page tables for x86_64. […]
Done
https://review.coreboot.org/#/c/30499/3/src/mainboard/emulation/qemu-q35/rom... File src/mainboard/emulation/qemu-q35/romstage.c:
https://review.coreboot.org/#/c/30499/3/src/mainboard/emulation/qemu-q35/rom... PS3, Line 42: postcar_frame_add_romcache(&pcf, MTRR_TYPE_WRPROT);
As before, MTRRs are dummies on QEMU, AFAIR.
Done
Kyösti Mälkki has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/30499 )
Change subject: mb/qemu-{i440fx,q35}: Use POSTCAR stage to load the ramstage ......................................................................
Patch Set 4:
(4 comments)
https://review.coreboot.org/#/c/30499/4/src/mainboard/emulation/qemu-i440fx/... File src/mainboard/emulation/qemu-i440fx/Kconfig:
https://review.coreboot.org/#/c/30499/4/src/mainboard/emulation/qemu-i440fx/... PS4, Line 15: select BOOTBLOCK_CONSOLE This needs C_ENV_BOOTBLOCK to have any effect?
https://review.coreboot.org/#/c/30499/4/src/mainboard/emulation/qemu-i440fx/... File src/mainboard/emulation/qemu-i440fx/romstage.c:
https://review.coreboot.org/#/c/30499/4/src/mainboard/emulation/qemu-i440fx/... PS4, Line 23: #include <cpu/x86/mtrr.h> I don't see why.
https://review.coreboot.org/#/c/30499/4/src/mainboard/emulation/qemu-q35/Kco... File src/mainboard/emulation/qemu-q35/Kconfig:
https://review.coreboot.org/#/c/30499/4/src/mainboard/emulation/qemu-q35/Kco... PS4, Line 14: select BOOTBLOCK_CONSOLE As before.
https://review.coreboot.org/#/c/30499/4/src/mainboard/emulation/qemu-q35/rom... File src/mainboard/emulation/qemu-q35/romstage.c:
https://review.coreboot.org/#/c/30499/4/src/mainboard/emulation/qemu-q35/rom... PS4, Line 24: #include <cpu/x86/mtrr.h> As before.
Hello Kyösti Mälkki, Stefan T, Arthur Heymans, Gerd Hoffmann, Stefan Reinauer, build bot (Jenkins), Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/30499
to look at the new patch set (#5).
Change subject: mb/qemu-{i440fx,q35}: Use POSTCAR stage to load the ramstage ......................................................................
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 arthur@aheymans.xyz Signed-off-by: Patrick Rudolph siro@das-labor.org --- M src/lib/Makefile.inc M src/mainboard/emulation/qemu-i440fx/Kconfig M src/mainboard/emulation/qemu-i440fx/Makefile.inc A src/mainboard/emulation/qemu-i440fx/exit_car.S M src/mainboard/emulation/qemu-i440fx/romstage.c M src/mainboard/emulation/qemu-q35/Kconfig M src/mainboard/emulation/qemu-q35/Makefile.inc M src/mainboard/emulation/qemu-q35/romstage.c 8 files changed, 65 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/99/30499/5
Patrick Rudolph has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/30499 )
Change subject: mb/qemu-{i440fx,q35}: Use POSTCAR stage to load the ramstage ......................................................................
Patch Set 5:
(4 comments)
https://review.coreboot.org/#/c/30499/4/src/mainboard/emulation/qemu-i440fx/... File src/mainboard/emulation/qemu-i440fx/Kconfig:
https://review.coreboot.org/#/c/30499/4/src/mainboard/emulation/qemu-i440fx/... PS4, Line 15: select BOOTBLOCK_CONSOLE
This needs C_ENV_BOOTBLOCK to have any effect?
Removed. It has nothing to do with postcar stage.
https://review.coreboot.org/#/c/30499/4/src/mainboard/emulation/qemu-i440fx/... File src/mainboard/emulation/qemu-i440fx/romstage.c:
https://review.coreboot.org/#/c/30499/4/src/mainboard/emulation/qemu-i440fx/... PS4, Line 23: #include <cpu/x86/mtrr.h>
I don't see why.
Done
https://review.coreboot.org/#/c/30499/4/src/mainboard/emulation/qemu-q35/Kco... File src/mainboard/emulation/qemu-q35/Kconfig:
https://review.coreboot.org/#/c/30499/4/src/mainboard/emulation/qemu-q35/Kco... PS4, Line 14: select BOOTBLOCK_CONSOLE
As before.
Done
https://review.coreboot.org/#/c/30499/4/src/mainboard/emulation/qemu-q35/rom... File src/mainboard/emulation/qemu-q35/romstage.c:
https://review.coreboot.org/#/c/30499/4/src/mainboard/emulation/qemu-q35/rom... PS4, Line 24: #include <cpu/x86/mtrr.h>
As before.
Done
Kyösti Mälkki has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/30499 )
Change subject: mb/qemu-{i440fx,q35}: Use POSTCAR stage to load the ramstage ......................................................................
Patch Set 5:
(2 comments)
https://review.coreboot.org/#/c/30499/5/src/mainboard/emulation/qemu-i440fx/... File src/mainboard/emulation/qemu-i440fx/romstage.c:
https://review.coreboot.org/#/c/30499/5/src/mainboard/emulation/qemu-i440fx/... PS5, Line 24: #include "memory.h" Not required here, yet.
https://review.coreboot.org/#/c/30499/5/src/mainboard/emulation/qemu-q35/rom... File src/mainboard/emulation/qemu-q35/romstage.c:
https://review.coreboot.org/#/c/30499/5/src/mainboard/emulation/qemu-q35/rom... PS5, Line 25: #include "../qemu-i440fx/memory.h" As before, not yet?
Hello Kyösti Mälkki, Stefan T, Arthur Heymans, Gerd Hoffmann, Stefan Reinauer, build bot (Jenkins), Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/30499
to look at the new patch set (#6).
Change subject: mb/qemu-{i440fx,q35}: Use POSTCAR stage to load the ramstage ......................................................................
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 arthur@aheymans.xyz Signed-off-by: Patrick Rudolph siro@das-labor.org --- M src/lib/Makefile.inc M src/mainboard/emulation/qemu-i440fx/Kconfig M src/mainboard/emulation/qemu-i440fx/Makefile.inc A src/mainboard/emulation/qemu-i440fx/exit_car.S M src/mainboard/emulation/qemu-i440fx/romstage.c M src/mainboard/emulation/qemu-q35/Kconfig M src/mainboard/emulation/qemu-q35/Makefile.inc M src/mainboard/emulation/qemu-q35/romstage.c 8 files changed, 61 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/99/30499/6
Patrick Georgi has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/30499 )
Change subject: mb/qemu-{i440fx,q35}: Use POSTCAR stage to load the ramstage ......................................................................
Patch Set 6: Code-Review+2
entirely unrelated, but just to get the idea out there: does it make sense to make QEMU i440fx and q35 board variants?
Patrick Georgi has submitted this change and it was merged. ( https://review.coreboot.org/c/coreboot/+/30499 )
Change subject: mb/qemu-{i440fx,q35}: Use POSTCAR stage to load the ramstage ......................................................................
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 arthur@aheymans.xyz Signed-off-by: Patrick Rudolph siro@das-labor.org Reviewed-on: https://review.coreboot.org/c/coreboot/+/30499 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Patrick Georgi pgeorgi@google.com --- M src/lib/Makefile.inc M src/mainboard/emulation/qemu-i440fx/Kconfig M src/mainboard/emulation/qemu-i440fx/Makefile.inc A src/mainboard/emulation/qemu-i440fx/exit_car.S M src/mainboard/emulation/qemu-i440fx/romstage.c M src/mainboard/emulation/qemu-q35/Kconfig M src/mainboard/emulation/qemu-q35/Makefile.inc M src/mainboard/emulation/qemu-q35/romstage.c 8 files changed, 61 insertions(+), 4 deletions(-)
Approvals: build bot (Jenkins): Verified Patrick Georgi: Looks good to me, approved
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc index fa1ff8b..70bbece 100644 --- a/src/lib/Makefile.inc +++ b/src/lib/Makefile.inc @@ -133,6 +133,7 @@ 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 78ca2d9..23526f9 100644 --- a/src/mainboard/emulation/qemu-i440fx/Kconfig +++ b/src/mainboard/emulation/qemu-i440fx/Kconfig @@ -12,7 +12,8 @@ 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 8c19afc..e3ca300 100644 --- a/src/mainboard/emulation/qemu-i440fx/Makefile.inc +++ b/src/mainboard/emulation/qemu-i440fx/Makefile.inc @@ -3,3 +3,6 @@ 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 0000000..06f1256 --- /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 e31394c..e1d4f62 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 1ceb62c..815b93b 100644 --- a/src/mainboard/emulation/qemu-q35/Kconfig +++ b/src/mainboard/emulation/qemu-q35/Kconfig @@ -11,7 +11,8 @@ 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 a52aad4..b18d2e4 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/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 2b8d935..3e0870f 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 @@
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); }