io_apic.h 3.6 KB

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