2
0

ioapic_internal.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * IOAPIC emulation logic - internal interfaces
  3. *
  4. * Copyright (c) 2004-2005 Fabrice Bellard
  5. * Copyright (c) 2009 Xiantao Zhang, Intel
  6. * Copyright (c) 2011 Jan Kiszka, Siemens AG
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef HW_INTC_IOAPIC_INTERNAL_H
  22. #define HW_INTC_IOAPIC_INTERNAL_H
  23. #include "exec/memory.h"
  24. #include "hw/intc/ioapic.h"
  25. #include "hw/sysbus.h"
  26. #include "qemu/notify.h"
  27. #include "qom/object.h"
  28. #define MAX_IOAPICS 2
  29. #define IOAPIC_LVT_DEST_SHIFT 56
  30. #define IOAPIC_LVT_DEST_IDX_SHIFT 48
  31. #define IOAPIC_LVT_MASKED_SHIFT 16
  32. #define IOAPIC_LVT_TRIGGER_MODE_SHIFT 15
  33. #define IOAPIC_LVT_REMOTE_IRR_SHIFT 14
  34. #define IOAPIC_LVT_POLARITY_SHIFT 13
  35. #define IOAPIC_LVT_DELIV_STATUS_SHIFT 12
  36. #define IOAPIC_LVT_DEST_MODE_SHIFT 11
  37. #define IOAPIC_LVT_DELIV_MODE_SHIFT 8
  38. #define IOAPIC_LVT_MASKED (1 << IOAPIC_LVT_MASKED_SHIFT)
  39. #define IOAPIC_LVT_TRIGGER_MODE (1 << IOAPIC_LVT_TRIGGER_MODE_SHIFT)
  40. #define IOAPIC_LVT_REMOTE_IRR (1 << IOAPIC_LVT_REMOTE_IRR_SHIFT)
  41. #define IOAPIC_LVT_POLARITY (1 << IOAPIC_LVT_POLARITY_SHIFT)
  42. #define IOAPIC_LVT_DELIV_STATUS (1 << IOAPIC_LVT_DELIV_STATUS_SHIFT)
  43. #define IOAPIC_LVT_DEST_MODE (1 << IOAPIC_LVT_DEST_MODE_SHIFT)
  44. #define IOAPIC_LVT_DELIV_MODE (7 << IOAPIC_LVT_DELIV_MODE_SHIFT)
  45. /* Bits that are read-only for IOAPIC entry */
  46. #define IOAPIC_RO_BITS (IOAPIC_LVT_REMOTE_IRR | \
  47. IOAPIC_LVT_DELIV_STATUS)
  48. #define IOAPIC_RW_BITS (~(uint64_t)IOAPIC_RO_BITS)
  49. #define IOAPIC_TRIGGER_EDGE 0
  50. #define IOAPIC_TRIGGER_LEVEL 1
  51. /*io{apic,sapic} delivery mode*/
  52. #define IOAPIC_DM_FIXED 0x0
  53. #define IOAPIC_DM_LOWEST_PRIORITY 0x1
  54. #define IOAPIC_DM_PMI 0x2
  55. #define IOAPIC_DM_NMI 0x4
  56. #define IOAPIC_DM_INIT 0x5
  57. #define IOAPIC_DM_SIPI 0x6
  58. #define IOAPIC_DM_EXTINT 0x7
  59. #define IOAPIC_DM_MASK 0x7
  60. #define IOAPIC_VECTOR_MASK 0xff
  61. #define IOAPIC_IOREGSEL 0x00
  62. #define IOAPIC_IOWIN 0x10
  63. #define IOAPIC_EOI 0x40
  64. #define IOAPIC_REG_ID 0x00
  65. #define IOAPIC_REG_VER 0x01
  66. #define IOAPIC_REG_ARB 0x02
  67. #define IOAPIC_REG_REDTBL_BASE 0x10
  68. #define IOAPIC_ID 0x00
  69. #define IOAPIC_ID_SHIFT 24
  70. #define IOAPIC_ID_MASK 0xf
  71. #define IOAPIC_VER_ENTRIES_SHIFT 16
  72. #define TYPE_IOAPIC_COMMON "ioapic-common"
  73. OBJECT_DECLARE_TYPE(IOAPICCommonState, IOAPICCommonClass, IOAPIC_COMMON)
  74. struct IOAPICCommonClass {
  75. SysBusDeviceClass parent_class;
  76. DeviceRealize realize;
  77. DeviceUnrealize unrealize;
  78. void (*pre_save)(IOAPICCommonState *s);
  79. void (*post_load)(IOAPICCommonState *s);
  80. };
  81. struct IOAPICCommonState {
  82. SysBusDevice busdev;
  83. MemoryRegion io_memory;
  84. uint8_t id;
  85. uint8_t ioregsel;
  86. uint32_t irr;
  87. uint64_t ioredtbl[IOAPIC_NUM_PINS];
  88. Notifier machine_done;
  89. uint8_t version;
  90. uint64_t irq_count[IOAPIC_NUM_PINS];
  91. int irq_level[IOAPIC_NUM_PINS];
  92. int irq_eoi[IOAPIC_NUM_PINS];
  93. QEMUTimer *delayed_ioapic_service_timer;
  94. };
  95. void ioapic_reset_common(DeviceState *dev);
  96. void ioapic_stat_update_irq(IOAPICCommonState *s, int irq, int level);
  97. #endif /* HW_INTC_IOAPIC_INTERNAL_H */