2 * drivers/s390/char/sclp_quiesce.c
3 * signal quiesce handler
5 * (C) Copyright IBM Corp. 1999,2004
6 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
7 * Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
10 #include <linux/config.h>
11 #include <linux/module.h>
12 #include <linux/types.h>
13 #include <linux/cpumask.h>
14 #include <linux/smp.h>
15 #include <linux/init.h>
16 #include <asm/atomic.h>
17 #include <asm/ptrace.h>
24 /* Signal completion of shutdown process. All CPUs except the first to enter
25 * this function: go to stopped state. First CPU: wait until all other
26 * CPUs are in stopped or check stop state. Afterwards, load special PSW
27 * to indicate completion. */
29 do_load_quiesce_psw(void * __unused)
31 static atomic_t cpuid = ATOMIC_INIT(-1);
36 if (atomic_compare_and_swap(-1, smp_processor_id(), &cpuid))
37 signal_processor(smp_processor_id(), sigp_stop);
38 /* Wait for all other cpus to enter stopped state */
45 switch (signal_processor_ps(&status, 0, i, sigp_sense)) {
46 case sigp_order_code_accepted:
47 case sigp_status_stored:
48 /* Check for stopped and check stop state */
54 case sigp_not_operational:
59 /* Quiesce the last cpu with the special psw */
60 quiesce_psw.mask = PSW_BASE_BITS | PSW_MASK_WAIT;
61 quiesce_psw.addr = 0xfff;
62 __load_psw(quiesce_psw);
65 /* Shutdown handler. Perform shutdown function on all CPUs. */
67 do_machine_quiesce(void)
69 on_each_cpu(do_load_quiesce_psw, NULL, 0, 0);
72 /* Shutdown handler. Signal completion of shutdown by loading special PSW. */
74 do_machine_quiesce(void)
78 quiesce_psw.mask = PSW_BASE_BITS | PSW_MASK_WAIT;
79 quiesce_psw.addr = 0xfff;
80 __load_psw(quiesce_psw);
84 extern void ctrl_alt_del(void);
86 /* Handler for quiesce event. Start shutdown procedure. */
88 sclp_quiesce_handler(struct evbuf_header *evbuf)
90 _machine_restart = (void *) do_machine_quiesce;
91 _machine_halt = do_machine_quiesce;
92 _machine_power_off = do_machine_quiesce;
96 static struct sclp_register sclp_quiesce_event = {
97 .receive_mask = EvTyp_SigQuiesce_Mask,
98 .receiver_fn = sclp_quiesce_handler
101 /* Initialize quiesce driver. */
103 sclp_quiesce_init(void)
107 rc = sclp_register(&sclp_quiesce_event);
109 printk(KERN_WARNING "sclp: could not register quiesce handler "
114 module_init(sclp_quiesce_init);