1*4882a593Smuzhiyun /******************************************************************************
2*4882a593Smuzhiyun * acpi.c
3*4882a593Smuzhiyun * acpi file for domain 0 kernel
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * Copyright (c) 2011 Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
6*4882a593Smuzhiyun * Copyright (c) 2011 Yu Ke ke.yu@intel.com
7*4882a593Smuzhiyun *
8*4882a593Smuzhiyun * This program is free software; you can redistribute it and/or
9*4882a593Smuzhiyun * modify it under the terms of the GNU General Public License version 2
10*4882a593Smuzhiyun * as published by the Free Software Foundation; or, when distributed
11*4882a593Smuzhiyun * separately from the Linux kernel or incorporated into other
12*4882a593Smuzhiyun * software packages, subject to the following license:
13*4882a593Smuzhiyun *
14*4882a593Smuzhiyun * Permission is hereby granted, free of charge, to any person obtaining a copy
15*4882a593Smuzhiyun * of this source file (the "Software"), to deal in the Software without
16*4882a593Smuzhiyun * restriction, including without limitation the rights to use, copy, modify,
17*4882a593Smuzhiyun * merge, publish, distribute, sublicense, and/or sell copies of the Software,
18*4882a593Smuzhiyun * and to permit persons to whom the Software is furnished to do so, subject to
19*4882a593Smuzhiyun * the following conditions:
20*4882a593Smuzhiyun *
21*4882a593Smuzhiyun * The above copyright notice and this permission notice shall be included in
22*4882a593Smuzhiyun * all copies or substantial portions of the Software.
23*4882a593Smuzhiyun *
24*4882a593Smuzhiyun * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25*4882a593Smuzhiyun * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26*4882a593Smuzhiyun * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27*4882a593Smuzhiyun * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28*4882a593Smuzhiyun * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29*4882a593Smuzhiyun * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30*4882a593Smuzhiyun * IN THE SOFTWARE.
31*4882a593Smuzhiyun */
32*4882a593Smuzhiyun
33*4882a593Smuzhiyun #include <xen/acpi.h>
34*4882a593Smuzhiyun #include <xen/interface/platform.h>
35*4882a593Smuzhiyun #include <asm/xen/hypercall.h>
36*4882a593Smuzhiyun #include <asm/xen/hypervisor.h>
37*4882a593Smuzhiyun
xen_acpi_notify_hypervisor_state(u8 sleep_state,u32 val_a,u32 val_b,bool extended)38*4882a593Smuzhiyun static int xen_acpi_notify_hypervisor_state(u8 sleep_state,
39*4882a593Smuzhiyun u32 val_a, u32 val_b,
40*4882a593Smuzhiyun bool extended)
41*4882a593Smuzhiyun {
42*4882a593Smuzhiyun unsigned int bits = extended ? 8 : 16;
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun struct xen_platform_op op = {
45*4882a593Smuzhiyun .cmd = XENPF_enter_acpi_sleep,
46*4882a593Smuzhiyun .interface_version = XENPF_INTERFACE_VERSION,
47*4882a593Smuzhiyun .u.enter_acpi_sleep = {
48*4882a593Smuzhiyun .val_a = (u16)val_a,
49*4882a593Smuzhiyun .val_b = (u16)val_b,
50*4882a593Smuzhiyun .sleep_state = sleep_state,
51*4882a593Smuzhiyun .flags = extended ? XENPF_ACPI_SLEEP_EXTENDED : 0,
52*4882a593Smuzhiyun },
53*4882a593Smuzhiyun };
54*4882a593Smuzhiyun
55*4882a593Smuzhiyun if (WARN((val_a & (~0 << bits)) || (val_b & (~0 << bits)),
56*4882a593Smuzhiyun "Using more than %u bits of sleep control values %#x/%#x!"
57*4882a593Smuzhiyun "Email xen-devel@lists.xen.org - Thank you.\n", \
58*4882a593Smuzhiyun bits, val_a, val_b))
59*4882a593Smuzhiyun return -1;
60*4882a593Smuzhiyun
61*4882a593Smuzhiyun HYPERVISOR_platform_op(&op);
62*4882a593Smuzhiyun return 1;
63*4882a593Smuzhiyun }
64*4882a593Smuzhiyun
xen_acpi_notify_hypervisor_sleep(u8 sleep_state,u32 pm1a_cnt,u32 pm1b_cnt)65*4882a593Smuzhiyun int xen_acpi_notify_hypervisor_sleep(u8 sleep_state,
66*4882a593Smuzhiyun u32 pm1a_cnt, u32 pm1b_cnt)
67*4882a593Smuzhiyun {
68*4882a593Smuzhiyun return xen_acpi_notify_hypervisor_state(sleep_state, pm1a_cnt,
69*4882a593Smuzhiyun pm1b_cnt, false);
70*4882a593Smuzhiyun }
71*4882a593Smuzhiyun
xen_acpi_notify_hypervisor_extended_sleep(u8 sleep_state,u32 val_a,u32 val_b)72*4882a593Smuzhiyun int xen_acpi_notify_hypervisor_extended_sleep(u8 sleep_state,
73*4882a593Smuzhiyun u32 val_a, u32 val_b)
74*4882a593Smuzhiyun {
75*4882a593Smuzhiyun return xen_acpi_notify_hypervisor_state(sleep_state, val_a,
76*4882a593Smuzhiyun val_b, true);
77*4882a593Smuzhiyun }
78