xen-stub.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  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. #include <linux/kernel.h>
  23. #include <linux/init.h>
  24. #include <linux/export.h>
  25. #include <linux/types.h>
  26. #include <linux/acpi.h>
  27. #include <acpi/acpi_drivers.h>
  28. #include <xen/acpi.h>
  29. #ifdef CONFIG_ACPI
  30. /*--------------------------------------------
  31. stub driver for Xen memory hotplug
  32. --------------------------------------------*/
  33. static const struct acpi_device_id memory_device_ids[] = {
  34. {ACPI_MEMORY_DEVICE_HID, 0},
  35. {"", 0},
  36. };
  37. static struct acpi_driver xen_stub_memory_device_driver = {
  38. /* same name as native memory driver to block native loaded */
  39. .name = "acpi_memhotplug",
  40. .class = ACPI_MEMORY_DEVICE_CLASS,
  41. .ids = memory_device_ids,
  42. };
  43. int xen_stub_memory_device_init(void)
  44. {
  45. if (!xen_initial_domain())
  46. return -ENODEV;
  47. /* just reserve space for Xen, block native driver loaded */
  48. return acpi_bus_register_driver(&xen_stub_memory_device_driver);
  49. }
  50. EXPORT_SYMBOL_GPL(xen_stub_memory_device_init);
  51. subsys_initcall(xen_stub_memory_device_init);
  52. void xen_stub_memory_device_exit(void)
  53. {
  54. acpi_bus_unregister_driver(&xen_stub_memory_device_driver);
  55. }
  56. EXPORT_SYMBOL_GPL(xen_stub_memory_device_exit);
  57. /*--------------------------------------------
  58. stub driver for Xen cpu hotplug
  59. --------------------------------------------*/
  60. static const struct acpi_device_id processor_device_ids[] = {
  61. {ACPI_PROCESSOR_OBJECT_HID, 0},
  62. {ACPI_PROCESSOR_DEVICE_HID, 0},
  63. {"", 0},
  64. };
  65. static struct acpi_driver xen_stub_processor_driver = {
  66. /* same name as native processor driver to block native loaded */
  67. .name = "processor",
  68. .class = ACPI_PROCESSOR_CLASS,
  69. .ids = processor_device_ids,
  70. };
  71. int xen_stub_processor_init(void)
  72. {
  73. if (!xen_initial_domain())
  74. return -ENODEV;
  75. /* just reserve space for Xen, block native driver loaded */
  76. return acpi_bus_register_driver(&xen_stub_processor_driver);
  77. }
  78. EXPORT_SYMBOL_GPL(xen_stub_processor_init);
  79. subsys_initcall(xen_stub_processor_init);
  80. void xen_stub_processor_exit(void)
  81. {
  82. acpi_bus_unregister_driver(&xen_stub_processor_driver);
  83. }
  84. EXPORT_SYMBOL_GPL(xen_stub_processor_exit);
  85. #endif