2 * signal quiesce handler
4 * Copyright IBM Corp. 1999, 2004
5 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
6 * Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
9 #include <linux/types.h>
10 #include <linux/cpumask.h>
11 #include <linux/smp.h>
12 #include <linux/init.h>
13 #include <linux/reboot.h>
14 #include <linux/atomic.h>
15 #include <asm/ptrace.h>
20 static void (*old_machine_restart
)(char *);
21 static void (*old_machine_halt
)(void);
22 static void (*old_machine_power_off
)(void);
24 /* Shutdown handler. Signal completion of shutdown by loading special PSW. */
25 static void do_machine_quiesce(void)
31 PSW_MASK_BASE
| PSW_MASK_EA
| PSW_MASK_BA
| PSW_MASK_WAIT
;
32 quiesce_psw
.addr
= 0xfff;
33 __load_psw(quiesce_psw
);
36 /* Handler for quiesce event. Start shutdown procedure. */
37 static void sclp_quiesce_handler(struct evbuf_header
*evbuf
)
39 if (_machine_restart
!= (void *) do_machine_quiesce
) {
40 old_machine_restart
= _machine_restart
;
41 old_machine_halt
= _machine_halt
;
42 old_machine_power_off
= _machine_power_off
;
43 _machine_restart
= (void *) do_machine_quiesce
;
44 _machine_halt
= do_machine_quiesce
;
45 _machine_power_off
= do_machine_quiesce
;
50 /* Undo machine restart/halt/power_off modification on resume */
51 static void sclp_quiesce_pm_event(struct sclp_register
*reg
,
52 enum sclp_pm_event sclp_pm_event
)
54 switch (sclp_pm_event
) {
55 case SCLP_PM_EVENT_RESTORE
:
56 if (old_machine_restart
) {
57 _machine_restart
= old_machine_restart
;
58 _machine_halt
= old_machine_halt
;
59 _machine_power_off
= old_machine_power_off
;
60 old_machine_restart
= NULL
;
61 old_machine_halt
= NULL
;
62 old_machine_power_off
= NULL
;
65 case SCLP_PM_EVENT_FREEZE
:
66 case SCLP_PM_EVENT_THAW
:
71 static struct sclp_register sclp_quiesce_event
= {
72 .receive_mask
= EVTYP_SIGQUIESCE_MASK
,
73 .receiver_fn
= sclp_quiesce_handler
,
74 .pm_event_fn
= sclp_quiesce_pm_event
77 /* Initialize quiesce driver. */
78 static int __init
sclp_quiesce_init(void)
80 return sclp_register(&sclp_quiesce_event
);
82 device_initcall(sclp_quiesce_init
);