diff options
author | Maxim Uvarov <maxim.uvarov@linaro.org> | 2020-10-23 11:53:13 +0100 |
---|---|---|
committer | jmarinho <jose.marinho@arm.com> | 2021-01-29 10:48:28 +0000 |
commit | f924cf73b1c35ad79a78f3c08fd3d7c123d4f077 (patch) | |
tree | bbbad9bed490fca54ba6e5db185162c003d4bae9 | |
parent | 9da29c5bda4badb607ea23a4836ce3ac54fc2a0b (diff) | |
download | arm-trusted-firmware-f924cf73b1c35ad79a78f3c08fd3d7c123d4f077.tar.gz |
qemu: use sbsa-ec for reboot/poweroff secure machine
qemu just merdge sbsa-ec driver which is simple memory
mapped power controler for emulated device. Adopting
this driver to machine virt,secure=on makes it possible
to follow common firmware way for reboot and poweroff.
I.e. in secure boot PSCI control moves to firmware and
after that we need some way say qemu that we are ready
for reboot.
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
-rw-r--r-- | plat/qemu/common/qemu_common.c | 8 | ||||
-rw-r--r-- | plat/qemu/common/qemu_pm.c | 12 | ||||
-rw-r--r-- | plat/qemu/qemu/include/platform_def.h | 3 |
3 files changed, 21 insertions, 2 deletions
diff --git a/plat/qemu/common/qemu_common.c b/plat/qemu/common/qemu_common.c index 365cfb7f0..b26e19403 100644 --- a/plat/qemu/common/qemu_common.c +++ b/plat/qemu/common/qemu_common.c @@ -28,6 +28,10 @@ MT_DEVICE | MT_RO | MT_SECURE) #endif +#define MAP_PSCI MAP_REGION_FLAT(PSCI_BASE, \ + PSCI_SIZE, \ + MT_DEVICE | MT_RW | MT_SECURE) + #define MAP_SHARED_RAM MAP_REGION_FLAT(SHARED_RAM_BASE, \ SHARED_RAM_SIZE, \ MT_DEVICE | MT_RW | MT_SECURE) @@ -61,6 +65,7 @@ static const mmap_region_t plat_qemu_mmap[] = { #ifdef MAP_DEVICE2 MAP_DEVICE2, #endif + MAP_PSCI, {0} }; #endif @@ -76,6 +81,7 @@ static const mmap_region_t plat_qemu_mmap[] = { #ifdef MAP_DEVICE2 MAP_DEVICE2, #endif + MAP_PSCI, MAP_NS_DRAM0, MAP_BL32_MEM, {0} @@ -88,6 +94,7 @@ static const mmap_region_t plat_qemu_mmap[] = { #ifdef MAP_DEVICE1 MAP_DEVICE1, #endif + MAP_PSCI, MAP_BL32_MEM, {0} }; @@ -99,6 +106,7 @@ static const mmap_region_t plat_qemu_mmap[] = { #ifdef MAP_DEVICE1 MAP_DEVICE1, #endif + MAP_PSCI, {0} }; #endif diff --git a/plat/qemu/common/qemu_pm.c b/plat/qemu/common/qemu_pm.c index cf800096f..c4aa6ef51 100644 --- a/plat/qemu/common/qemu_pm.c +++ b/plat/qemu/common/qemu_pm.c @@ -11,12 +11,18 @@ #include <common/debug.h> #include <lib/psci/psci.h> #include <lib/semihosting.h> +#include <lib/mmio.h> #include <plat/common/platform.h> #include "qemu_private.h" #define ADP_STOPPED_APPLICATION_EXIT 0x20026 +enum psci_powerstates { + EC_CMD_POWEROFF = 0x01, + EC_CMD_REBOOT = 0x02, +}; + /* * The secure entry point to be used on warm reset. */ @@ -203,14 +209,16 @@ void qemu_pwr_domain_suspend_finish(const psci_power_state_t *target_state) ******************************************************************************/ static void __dead2 qemu_system_off(void) { - semihosting_exit(ADP_STOPPED_APPLICATION_EXIT, 0); +// semihosting_exit(ADP_STOPPED_APPLICATION_EXIT, 0); ERROR("QEMU System Off: semihosting call unexpectedly returned.\n"); + mmio_write_32(PSCI_BASE, EC_CMD_REBOOT); panic(); } static void __dead2 qemu_system_reset(void) { - ERROR("QEMU System Reset: operation not handled.\n"); + ERROR("QEMU System Reset: operation handled.\n"); + mmio_write_32(PSCI_BASE, EC_CMD_REBOOT); panic(); } diff --git a/plat/qemu/qemu/include/platform_def.h b/plat/qemu/qemu/include/platform_def.h index 7dfae458f..9bf016a5e 100644 --- a/plat/qemu/qemu/include/platform_def.h +++ b/plat/qemu/qemu/include/platform_def.h @@ -207,6 +207,9 @@ #define DEVICE1_BASE 0x09000000 #define DEVICE1_SIZE 0x00041000 +#define PSCI_BASE 0x090c0000 +#define PSCI_SIZE 0x1000 + /* * GIC related constants */ |