xen-stub.c 2.8 KB

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