xen_apic.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Xen basic APIC support
  3. *
  4. * Copyright (c) 2012 Citrix
  5. *
  6. * Authors:
  7. * Wei Liu <wei.liu2@citrix.com>
  8. *
  9. * This work is licensed under the terms of the GNU GPL version 2 or
  10. * later. See the COPYING file in the top-level directory.
  11. */
  12. #include "hw/i386/apic_internal.h"
  13. #include "hw/pci/msi.h"
  14. #include "hw/xen/xen.h"
  15. static uint64_t xen_apic_mem_read(void *opaque, hwaddr addr,
  16. unsigned size)
  17. {
  18. return ~(uint64_t)0;
  19. }
  20. static void xen_apic_mem_write(void *opaque, hwaddr addr,
  21. uint64_t data, unsigned size)
  22. {
  23. if (size != sizeof(uint32_t)) {
  24. fprintf(stderr, "Xen: APIC write data size = %d, invalid\n", size);
  25. return;
  26. }
  27. xen_hvm_inject_msi(addr, data);
  28. }
  29. static const MemoryRegionOps xen_apic_io_ops = {
  30. .read = xen_apic_mem_read,
  31. .write = xen_apic_mem_write,
  32. .endianness = DEVICE_NATIVE_ENDIAN,
  33. };
  34. static void xen_apic_realize(DeviceState *dev, Error **errp)
  35. {
  36. APICCommonState *s = APIC_COMMON(dev);
  37. memory_region_init_io(&s->io_memory, OBJECT(s), &xen_apic_io_ops, s,
  38. "xen-apic-msi", APIC_SPACE_SIZE);
  39. #if defined(CONFIG_XEN_CTRL_INTERFACE_VERSION) \
  40. && CONFIG_XEN_CTRL_INTERFACE_VERSION >= 420
  41. msi_supported = true;
  42. #endif
  43. }
  44. static void xen_apic_set_base(APICCommonState *s, uint64_t val)
  45. {
  46. }
  47. static void xen_apic_set_tpr(APICCommonState *s, uint8_t val)
  48. {
  49. }
  50. static uint8_t xen_apic_get_tpr(APICCommonState *s)
  51. {
  52. return 0;
  53. }
  54. static void xen_apic_vapic_base_update(APICCommonState *s)
  55. {
  56. }
  57. static void xen_apic_external_nmi(APICCommonState *s)
  58. {
  59. }
  60. static void xen_apic_class_init(ObjectClass *klass, void *data)
  61. {
  62. APICCommonClass *k = APIC_COMMON_CLASS(klass);
  63. k->realize = xen_apic_realize;
  64. k->set_base = xen_apic_set_base;
  65. k->set_tpr = xen_apic_set_tpr;
  66. k->get_tpr = xen_apic_get_tpr;
  67. k->vapic_base_update = xen_apic_vapic_base_update;
  68. k->external_nmi = xen_apic_external_nmi;
  69. }
  70. static const TypeInfo xen_apic_info = {
  71. .name = "xen-apic",
  72. .parent = TYPE_APIC_COMMON,
  73. .instance_size = sizeof(APICCommonState),
  74. .class_init = xen_apic_class_init,
  75. };
  76. static void xen_apic_register_types(void)
  77. {
  78. type_register_static(&xen_apic_info);
  79. }
  80. type_init(xen_apic_register_types)