sched: cleanup, make struct rq comments more consistent
[linux-2.6/mini2440.git] / arch / sparc64 / kernel / sstate.c
blob5b6e75b7f0526dadf4935ace3ed23d0f2353a834
1 /* sstate.c: System soft state support.
3 * Copyright (C) 2007 David S. Miller <davem@davemloft.net>
4 */
6 #include <linux/kernel.h>
7 #include <linux/notifier.h>
8 #include <linux/init.h>
10 #include <asm/hypervisor.h>
11 #include <asm/sstate.h>
12 #include <asm/oplib.h>
13 #include <asm/head.h>
14 #include <asm/io.h>
16 static int hv_supports_soft_state;
18 static unsigned long kimage_addr_to_ra(const char *p)
20 unsigned long val = (unsigned long) p;
22 return kern_base + (val - KERNBASE);
25 static void do_set_sstate(unsigned long state, const char *msg)
27 unsigned long err;
29 if (!hv_supports_soft_state)
30 return;
32 err = sun4v_mach_set_soft_state(state, kimage_addr_to_ra(msg));
33 if (err) {
34 printk(KERN_WARNING "SSTATE: Failed to set soft-state to "
35 "state[%lx] msg[%s], err=%lu\n",
36 state, msg, err);
40 static const char booting_msg[32] __attribute__((aligned(32))) =
41 "Linux booting";
42 static const char running_msg[32] __attribute__((aligned(32))) =
43 "Linux running";
44 static const char halting_msg[32] __attribute__((aligned(32))) =
45 "Linux halting";
46 static const char poweroff_msg[32] __attribute__((aligned(32))) =
47 "Linux powering off";
48 static const char rebooting_msg[32] __attribute__((aligned(32))) =
49 "Linux rebooting";
50 static const char panicing_msg[32] __attribute__((aligned(32))) =
51 "Linux panicing";
53 void sstate_booting(void)
55 do_set_sstate(HV_SOFT_STATE_TRANSITION, booting_msg);
58 void sstate_running(void)
60 do_set_sstate(HV_SOFT_STATE_NORMAL, running_msg);
63 void sstate_halt(void)
65 do_set_sstate(HV_SOFT_STATE_TRANSITION, halting_msg);
68 void sstate_poweroff(void)
70 do_set_sstate(HV_SOFT_STATE_TRANSITION, poweroff_msg);
73 void sstate_reboot(void)
75 do_set_sstate(HV_SOFT_STATE_TRANSITION, rebooting_msg);
78 static int sstate_panic_event(struct notifier_block *n, unsigned long event, void *ptr)
80 do_set_sstate(HV_SOFT_STATE_TRANSITION, panicing_msg);
82 return NOTIFY_DONE;
85 static struct notifier_block sstate_panic_block = {
86 .notifier_call = sstate_panic_event,
87 .priority = INT_MAX,
90 void __init sun4v_sstate_init(void)
92 unsigned long major, minor;
94 major = 1;
95 minor = 0;
96 if (sun4v_hvapi_register(HV_GRP_SOFT_STATE, major, &minor))
97 return;
99 hv_supports_soft_state = 1;
101 prom_sun4v_guest_soft_state();
102 atomic_notifier_chain_register(&panic_notifier_list,
103 &sstate_panic_block);