blob: 84c191c1cd620fa1e5a723dcb060f9a8d4ae9175 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * drivers/s390/char/sclp_quiesce.c
3 * signal quiesce handler
4 *
5 * (C) Copyright IBM Corp. 1999,2004
6 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
7 * Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
8 */
9
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include <linux/module.h>
11#include <linux/types.h>
12#include <linux/cpumask.h>
13#include <linux/smp.h>
14#include <linux/init.h>
Adrian Bunk83cc5ed2006-06-25 05:47:41 -070015#include <linux/reboot.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <asm/atomic.h>
17#include <asm/ptrace.h>
18#include <asm/sigp.h>
Jan Glauber188596f2007-02-21 10:55:03 +010019#include <asm/smp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
21#include "sclp.h"
22
Linus Torvalds1da177e2005-04-16 15:20:36 -070023/* Shutdown handler. Signal completion of shutdown by loading special PSW. */
24static void
25do_machine_quiesce(void)
26{
27 psw_t quiesce_psw;
28
Heiko Carstensc6b5b842006-12-04 15:40:33 +010029 smp_send_stop();
Linus Torvalds1da177e2005-04-16 15:20:36 -070030 quiesce_psw.mask = PSW_BASE_BITS | PSW_MASK_WAIT;
31 quiesce_psw.addr = 0xfff;
32 __load_psw(quiesce_psw);
33}
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Linus Torvalds1da177e2005-04-16 15:20:36 -070035/* Handler for quiesce event. Start shutdown procedure. */
36static void
37sclp_quiesce_handler(struct evbuf_header *evbuf)
38{
39 _machine_restart = (void *) do_machine_quiesce;
40 _machine_halt = do_machine_quiesce;
41 _machine_power_off = do_machine_quiesce;
42 ctrl_alt_del();
43}
44
45static struct sclp_register sclp_quiesce_event = {
Stefan Haberland6d4740c2007-04-27 16:01:53 +020046 .receive_mask = EVTYP_SIGQUIESCE_MASK,
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 .receiver_fn = sclp_quiesce_handler
48};
49
50/* Initialize quiesce driver. */
51static int __init
52sclp_quiesce_init(void)
53{
Martin Schwidefskya12c53f2008-07-14 09:59:28 +020054 return sclp_register(&sclp_quiesce_event);
Linus Torvalds1da177e2005-04-16 15:20:36 -070055}
56
57module_init(sclp_quiesce_init);