io_apic.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. #ifndef __ASM_IO_APIC_H
  2. #define __ASM_IO_APIC_H
  3. #include <asm/types.h>
  4. #include <asm/mpspec.h>
  5. /*
  6. * Intel IO-APIC support for SMP and UP systems.
  7. *
  8. * Copyright (C) 1997, 1998, 1999, 2000 Ingo Molnar
  9. */
  10. #define APIC_MISMATCH_DEBUG
  11. #define IO_APIC_BASE(idx) \
  12. ((volatile int *)(__fix_to_virt(FIX_IO_APIC_BASE_0 + idx) \
  13. + (mp_ioapics[idx].mpc_apicaddr & ~PAGE_MASK)))
  14. /*
  15. * The structure of the IO-APIC:
  16. */
  17. union IO_APIC_reg_00 {
  18. u32 raw;
  19. struct {
  20. u32 __reserved_2 : 14,
  21. LTS : 1,
  22. delivery_type : 1,
  23. __reserved_1 : 8,
  24. ID : 8;
  25. } __attribute__ ((packed)) bits;
  26. };
  27. union IO_APIC_reg_01 {
  28. u32 raw;
  29. struct {
  30. u32 version : 8,
  31. __reserved_2 : 7,
  32. PRQ : 1,
  33. entries : 8,
  34. __reserved_1 : 8;
  35. } __attribute__ ((packed)) bits;
  36. };
  37. union IO_APIC_reg_02 {
  38. u32 raw;
  39. struct {
  40. u32 __reserved_2 : 24,
  41. arbitration : 4,
  42. __reserved_1 : 4;
  43. } __attribute__ ((packed)) bits;
  44. };
  45. union IO_APIC_reg_03 {
  46. u32 raw;
  47. struct {
  48. u32 boot_DT : 1,
  49. __reserved_1 : 31;
  50. } __attribute__ ((packed)) bits;
  51. };
  52. /*
  53. * # of IO-APICs and # of IRQ routing registers
  54. */
  55. extern int nr_ioapics;
  56. extern int nr_ioapic_registers[MAX_IO_APICS];
  57. enum ioapic_irq_destination_types {
  58. dest_Fixed = 0,
  59. dest_LowestPrio = 1,
  60. dest_SMI = 2,
  61. dest__reserved_1 = 3,
  62. dest_NMI = 4,
  63. dest_INIT = 5,
  64. dest__reserved_2 = 6,
  65. dest_ExtINT = 7
  66. };
  67. struct IO_APIC_route_entry {
  68. __u32 vector : 8,
  69. delivery_mode : 3, /* 000: FIXED
  70. * 001: lowest prio
  71. * 111: ExtINT
  72. */
  73. dest_mode : 1, /* 0: physical, 1: logical */
  74. delivery_status : 1,
  75. polarity : 1,
  76. irr : 1,
  77. trigger : 1, /* 0: edge, 1: level */
  78. mask : 1, /* 0: enabled, 1: disabled */
  79. __reserved_2 : 15;
  80. union { struct { __u32
  81. __reserved_1 : 24,
  82. physical_dest : 4,
  83. __reserved_2 : 4;
  84. } physical;
  85. struct { __u32
  86. __reserved_1 : 24,
  87. logical_dest : 8;
  88. } logical;
  89. } dest;
  90. } __attribute__ ((packed));
  91. /*
  92. * MP-BIOS irq configuration table structures:
  93. */
  94. /* I/O APIC entries */
  95. extern struct mpc_config_ioapic mp_ioapics[MAX_IO_APICS];
  96. /* # of MP IRQ source entries */
  97. extern int mp_irq_entries;
  98. /* MP IRQ source entries */
  99. extern struct mpc_config_intsrc mp_irqs[MAX_IRQ_SOURCES];
  100. /* non-0 if default (table-less) MP configuration */
  101. extern int mpc_default_type;
  102. static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)
  103. {
  104. *IO_APIC_BASE(apic) = reg;
  105. return *(IO_APIC_BASE(apic)+4);
  106. }
  107. static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned int value)
  108. {
  109. *IO_APIC_BASE(apic) = reg;
  110. *(IO_APIC_BASE(apic)+4) = value;
  111. }
  112. /*
  113. * Re-write a value: to be used for read-modify-write
  114. * cycles where the read already set up the index register.
  115. */
  116. static inline void io_apic_modify(unsigned int apic, unsigned int value)
  117. {
  118. *(IO_APIC_BASE(apic)+4) = value;
  119. }
  120. /*
  121. * Synchronize the IO-APIC and the CPU by doing
  122. * a dummy read from the IO-APIC
  123. */
  124. static inline void io_apic_sync(unsigned int apic)
  125. {
  126. (void) *(IO_APIC_BASE(apic)+4);
  127. }
  128. /* 1 if "noapic" boot option passed */
  129. extern int skip_ioapic_setup;
  130. /*
  131. * If we use the IO-APIC for IRQ routing, disable automatic
  132. * assignment of PCI IRQ's.
  133. */
  134. #define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs)
  135. #ifdef CONFIG_ACPI
  136. extern int io_apic_get_version (int ioapic);
  137. extern int io_apic_get_redir_entries (int ioapic);
  138. extern int io_apic_set_pci_routing (int ioapic, int pin, int irq, int, int);
  139. #endif
  140. extern int sis_apic_bug; /* dummy */
  141. void enable_NMI_through_LVT0 (void * dummy);
  142. extern spinlock_t i8259A_lock;
  143. #endif