public inbox for linux-parisc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] parisc: Add qemu power-off handler
@ 2023-10-08 21:54 Helge Deller
  0 siblings, 0 replies; only message in thread
From: Helge Deller @ 2023-10-08 21:54 UTC (permalink / raw)
  To: linux-parisc

When running on qemu, use the artificial "system halt" instruction
to power the system off.

Signed-off-by: Helge Deller <deller@gmx.de>

diff --git a/arch/parisc/kernel/setup.c b/arch/parisc/kernel/setup.c
index 2f434f2da185..c934ec47d915 100644
--- a/arch/parisc/kernel/setup.c
+++ b/arch/parisc/kernel/setup.c
@@ -25,6 +25,7 @@
 #include <linux/sched.h>
 #include <linux/sched/clock.h>
 #include <linux/start_kernel.h>
+#include <linux/reboot.h>
 
 #include <asm/cacheflush.h>
 #include <asm/processor.h>
@@ -235,6 +236,13 @@ static int __init parisc_init_resources(void)
 	return 0;
 }
 
+static int qemu_power_off(struct sys_off_data *data)
+{
+	/* call qemu artificial "system halt" instruction */
+	asm volatile(".word 0xfffdead0": : :"memory");
+	return NOTIFY_DONE;
+}
+
 static int __init parisc_init(void)
 {
 	u32 osid = (OS_ID_LINUX << 16);
@@ -242,6 +250,11 @@ static int __init parisc_init(void)
 	parisc_init_resources();
 	do_device_inventory();                  /* probe for hardware */
 
+	/* register QEMU power off function */
+	if (running_on_qemu)
+		register_sys_off_handler(SYS_OFF_MODE_POWER_OFF,
+			SYS_OFF_PRIO_DEFAULT, qemu_power_off, NULL);
+
 	parisc_pdc_chassis_init();
 	
 	/* set up a new led state on systems shipped LED State panel */

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-10-08 21:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-08 21:54 [PATCH] parisc: Add qemu power-off handler Helge Deller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox