xen_apic.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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/apic_internal.h"
  13. #include "hw/pci/msi.h"
  14. #include "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_init(APICCommonState *s)
  35. {
  36. memory_region_init_io(&s->io_memory, &xen_apic_io_ops, s, "xen-apic-msi",
  37. MSI_SPACE_SIZE);
  38. #if defined(CONFIG_XEN_CTRL_INTERFACE_VERSION) \
  39. && CONFIG_XEN_CTRL_INTERFACE_VERSION >= 420
  40. msi_supported = true;
  41. #endif
  42. }
  43. static void xen_apic_set_base(APICCommonState *s, uint64_t val)
  44. {
  45. }
  46. static void xen_apic_set_tpr(APICCommonState *s, uint8_t val)
  47. {
  48. }
  49. static uint8_t xen_apic_get_tpr(APICCommonState *s)
  50. {
  51. return 0;
  52. }
  53. static void xen_apic_vapic_base_update(APICCommonState *s)
  54. {
  55. }
  56. static void xen_apic_external_nmi(APICCommonState *s)
  57. {
  58. }
  59. static void xen_apic_class_init(ObjectClass *klass, void *data)
  60. {
  61. APICCommonClass *k = APIC_COMMON_CLASS(klass);
  62. k->init = xen_apic_init;
  63. k->set_base = xen_apic_set_base;
  64. k->set_tpr = xen_apic_set_tpr;
  65. k->get_tpr = xen_apic_get_tpr;
  66. k->vapic_base_update = xen_apic_vapic_base_update;
  67. k->external_nmi = xen_apic_external_nmi;
  68. }
  69. static const TypeInfo xen_apic_info = {
  70. .name = "xen-apic",
  71. .parent = TYPE_APIC_COMMON,
  72. .instance_size = sizeof(APICCommonState),
  73. .class_init = xen_apic_class_init,
  74. };
  75. static void xen_apic_register_types(void)
  76. {
  77. type_register_static(&xen_apic_info);
  78. }
  79. type_init(xen_apic_register_types)