blob: d85e411cbf8924ceaf8e3947ab961e1c5ea68744 [file] [log] [blame]
Liu Jinsongdcb93b92013-01-24 20:16:59 +08001/*
2 * xen-stub.c - stub drivers to reserve space for Xen
3 *
4 * Copyright (C) 2012 Intel Corporation
5 * Author: Liu Jinsong <jinsong.liu@intel.com>
6 * Author: Jiang Yunhong <yunhong.jiang@intel.com>
7 *
8 * Copyright (C) 2012 Oracle Inc
9 * Author: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or (at
14 * your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
19 * NON INFRINGEMENT. See the GNU General Public License for more
20 * details.
21 */
22
23#include <linux/kernel.h>
24#include <linux/init.h>
25#include <linux/export.h>
26#include <linux/types.h>
27#include <linux/acpi.h>
28#include <acpi/acpi_drivers.h>
29#include <xen/acpi.h>
30
Liu Jinsongb22ff772013-01-24 22:12:30 +080031#ifdef CONFIG_ACPI
32
Liu Jinsongdcb93b92013-01-24 20:16:59 +080033/*--------------------------------------------
34 stub driver for Xen memory hotplug
35--------------------------------------------*/
36
Liu Jinsongdcb93b92013-01-24 20:16:59 +080037static const struct acpi_device_id memory_device_ids[] = {
38 {ACPI_MEMORY_DEVICE_HID, 0},
39 {"", 0},
40};
41
42static struct acpi_driver xen_stub_memory_device_driver = {
43 /* same name as native memory driver to block native loaded */
44 .name = "acpi_memhotplug",
45 .class = ACPI_MEMORY_DEVICE_CLASS,
46 .ids = memory_device_ids,
47};
48
49int xen_stub_memory_device_init(void)
50{
51 if (!xen_initial_domain())
52 return -ENODEV;
53
54 /* just reserve space for Xen, block native driver loaded */
55 return acpi_bus_register_driver(&xen_stub_memory_device_driver);
56}
57EXPORT_SYMBOL_GPL(xen_stub_memory_device_init);
58subsys_initcall(xen_stub_memory_device_init);
59
60void xen_stub_memory_device_exit(void)
61{
62 acpi_bus_unregister_driver(&xen_stub_memory_device_driver);
63}
64EXPORT_SYMBOL_GPL(xen_stub_memory_device_exit);
65
Liu Jinsongb22ff772013-01-24 22:12:30 +080066
67/*--------------------------------------------
68 stub driver for Xen cpu hotplug
69--------------------------------------------*/
70
71static const struct acpi_device_id processor_device_ids[] = {
72 {ACPI_PROCESSOR_OBJECT_HID, 0},
73 {ACPI_PROCESSOR_DEVICE_HID, 0},
74 {"", 0},
75};
76
77static struct acpi_driver xen_stub_processor_driver = {
78 /* same name as native processor driver to block native loaded */
79 .name = "processor",
80 .class = ACPI_PROCESSOR_CLASS,
81 .ids = processor_device_ids,
82};
83
84int xen_stub_processor_init(void)
85{
86 if (!xen_initial_domain())
87 return -ENODEV;
88
89 /* just reserve space for Xen, block native driver loaded */
90 return acpi_bus_register_driver(&xen_stub_processor_driver);
91}
92EXPORT_SYMBOL_GPL(xen_stub_processor_init);
93subsys_initcall(xen_stub_processor_init);
94
95void xen_stub_processor_exit(void)
96{
97 acpi_bus_unregister_driver(&xen_stub_processor_driver);
98}
99EXPORT_SYMBOL_GPL(xen_stub_processor_exit);
100
Liu Jinsongdcb93b92013-01-24 20:16:59 +0800101#endif