staging: vt6655: MACvSaveContext use memcpy_fromio to read context.
[linux/fpc-iii.git] / drivers / s390 / char / sclp_quiesce.c
blob475e470d9768ea729adc9ba95feee801f942dda1
1 /*
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>
7 */
9 #include <linux/module.h>
10 #include <linux/types.h>
11 #include <linux/cpumask.h>
12 #include <linux/smp.h>
13 #include <linux/init.h>
14 #include <linux/reboot.h>
15 #include <linux/atomic.h>
16 #include <asm/ptrace.h>
17 #include <asm/smp.h>
19 #include "sclp.h"
21 static void (*old_machine_restart)(char *);
22 static void (*old_machine_halt)(void);
23 static void (*old_machine_power_off)(void);
25 /* Shutdown handler. Signal completion of shutdown by loading special PSW. */
26 static void do_machine_quiesce(void)
28 psw_t quiesce_psw;
30 smp_send_stop();
31 quiesce_psw.mask =
32 PSW_MASK_BASE | PSW_MASK_EA | PSW_MASK_BA | PSW_MASK_WAIT;
33 quiesce_psw.addr = 0xfff;
34 __load_psw(quiesce_psw);
37 /* Handler for quiesce event. Start shutdown procedure. */
38 static void sclp_quiesce_handler(struct evbuf_header *evbuf)
40 if (_machine_restart != (void *) do_machine_quiesce) {
41 old_machine_restart = _machine_restart;
42 old_machine_halt = _machine_halt;
43 old_machine_power_off = _machine_power_off;
44 _machine_restart = (void *) do_machine_quiesce;
45 _machine_halt = do_machine_quiesce;
46 _machine_power_off = do_machine_quiesce;
48 ctrl_alt_del();
51 /* Undo machine restart/halt/power_off modification on resume */
52 static void sclp_quiesce_pm_event(struct sclp_register *reg,
53 enum sclp_pm_event sclp_pm_event)
55 switch (sclp_pm_event) {
56 case SCLP_PM_EVENT_RESTORE:
57 if (old_machine_restart) {
58 _machine_restart = old_machine_restart;
59 _machine_halt = old_machine_halt;
60 _machine_power_off = old_machine_power_off;
61 old_machine_restart = NULL;
62 old_machine_halt = NULL;
63 old_machine_power_off = NULL;
65 break;
66 case SCLP_PM_EVENT_FREEZE:
67 case SCLP_PM_EVENT_THAW:
68 break;
72 static struct sclp_register sclp_quiesce_event = {
73 .receive_mask = EVTYP_SIGQUIESCE_MASK,
74 .receiver_fn = sclp_quiesce_handler,
75 .pm_event_fn = sclp_quiesce_pm_event
78 /* Initialize quiesce driver. */
79 static int __init sclp_quiesce_init(void)
81 return sclp_register(&sclp_quiesce_event);
84 module_init(sclp_quiesce_init);