loApic.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:8k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* loApic.h - Intel Pentium[234] Local APIC/xAPIC (Advanced PIC) */
  2. /* Copyright 1984-2002 Wind River Systems, Inc. */ 
  3. /*
  4. modification history
  5. --------------------
  6. 01d,08mar02,hdn  added prototypes for HTT (spr 73738)
  7. 01c,21jun01,hdn  added support for Pentium4 Local xAPIC
  8. 01b,25may98,hdn  re-written
  9. 01a,26jun97,sub  written
  10. */
  11. #ifndef __INCloApich
  12. #define __INCloApich
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. /* Local APIC Register Offset */
  17. #define LOAPIC_ID 0x020 /* Local APIC ID Reg */
  18. #define LOAPIC_VER 0x030 /* Local APIC Version Reg */
  19. #define LOAPIC_TPR 0x080 /* Task Priority Reg */
  20. #define LOAPIC_APR 0x090 /* Arbitration Priority Reg */
  21. #define LOAPIC_PPR 0x0a0 /* Processor Priority Reg */
  22. #define LOAPIC_EOI 0x0b0 /* EOI Reg */
  23. #define LOAPIC_LDR 0x0d0 /* Logical Destination Reg */
  24. #define LOAPIC_DFR 0x0e0 /* Destination Format Reg */
  25. #define LOAPIC_SVR 0x0f0 /* Spurious Interrupt Reg */
  26. #define LOAPIC_ISR 0x100 /* In-service Reg */
  27. #define LOAPIC_TMR 0x180 /* Trigger Mode Reg */
  28. #define LOAPIC_IRR 0x200 /* Interrupt Request Reg */
  29. #define LOAPIC_ESR 0x280 /* Error Status Reg */
  30. #define LOAPIC_ICRLO 0x300 /* Interrupt Command Reg */
  31. #define LOAPIC_ICRHI 0x310 /* Interrupt Command Reg */
  32. #define LOAPIC_TIMER 0x320 /* LVT (Timer) */
  33. #define LOAPIC_THERMAL 0x330 /* LVT (Thermal) */
  34. #define LOAPIC_PMC 0x340 /* LVT (PMC) */
  35. #define LOAPIC_LINT0 0x350 /* LVT (LINT0) */
  36. #define LOAPIC_LINT1 0x360 /* LVT (LINT1) */
  37. #define LOAPIC_ERROR 0x370 /* LVT (ERROR) */
  38. #define LOAPIC_TIMER_ICR 0x380 /* Timer Initial Count Reg */
  39. #define LOAPIC_TIMER_CCR 0x390 /* Timer Current Count Reg */
  40. #define LOAPIC_TIMER_CONFIG 0x3e0 /* Timer Divide Config Reg */
  41. /* IA32_APIC_BASE MSR Bits */
  42. #define LOAPIC_BASE_MASK 0xfffff000 /* LO APIC Base Addr mask */
  43. #define LOAPIC_GLOBAL_ENABLE 0x00000800 /* LO APIC Global Enable */
  44. #define LOAPIC_BSP 0x00000100 /* LO APIC BSP */
  45. /* Local APIC ID Register Bits */
  46. #define LOAPIC_ID_MASK 0x0f000000 /* LO APIC ID mask */
  47. /* Local APIC Version Register Bits */
  48. #define LOAPIC_VERSION_MASK 0x000000ff /* LO APIC Version mask */
  49. #define LOAPIC_MAXLVT_MASK 0x00ff0000 /* LO APIC Max LVT mask */
  50. #define LOAPIC_PENTIUM4 0x00000014 /* LO APIC in Pentium4 */
  51. #define LOAPIC_LVT_PENTIUM4 5     /* LO APIC LVT - Pentium4 */
  52. #define LOAPIC_LVT_P6 4     /* LO APIC LVT - P6 */
  53. #define LOAPIC_LVT_P5 3     /* LO APIC LVT - P5 */
  54. /* Local APIC Vector Table Bits */
  55. #define LOAPIC_VECTOR 0x000000ff /* vectorNo */
  56. #define LOAPIC_MODE 0x00000700 /* delivery mode */
  57. #define LOAPIC_FIXED 0x00000000 /* delivery mode: FIXED */
  58. #define LOAPIC_SMI 0x00000200 /* delivery mode: SMI */
  59. #define LOAPIC_NMI 0x00000400 /* delivery mode: NMI */
  60. #define LOAPIC_EXT 0x00000700 /* delivery mode: ExtINT */
  61. #define LOAPIC_IDLE 0x00000000 /* delivery status: Idle */
  62. #define LOAPIC_PEND 0x00001000 /* delivery status: Pend */
  63. #define LOAPIC_HIGH 0x00000000 /* polarity: High */
  64. #define LOAPIC_LOW 0x00002000 /* polarity: Low */
  65. #define LOAPIC_REMOTE 0x00004000 /* remote IRR */
  66. #define LOAPIC_EDGE 0x00000000 /* trigger mode: Edge */
  67. #define LOAPIC_LEVEL 0x00008000 /* trigger mode: Level */
  68. #define LOAPIC_MASK 0x00010000 /* mask */
  69. /* Local APIC Spurious-Interrupt Register Bits */
  70. #define LOAPIC_ENABLE 0x100 /* APIC Enabled */
  71. #define LOAPIC_FOCUS_DISABLE 0x200 /* Focus Processor Checking */
  72. /* Local APIC Timer Bits */
  73. #define LOAPIC_TIMER_DIVBY_2 0x0 /* Divide by 2 */
  74. #define LOAPIC_TIMER_DIVBY_4 0x1 /* Divide by 4 */
  75. #define LOAPIC_TIMER_DIVBY_8 0x2 /* Divide by 8 */
  76. #define LOAPIC_TIMER_DIVBY_16 0x3 /* Divide by 16 */
  77. #define LOAPIC_TIMER_DIVBY_32 0x8 /* Divide by 32 */
  78. #define LOAPIC_TIMER_DIVBY_64 0x9 /* Divide by 64 */
  79. #define LOAPIC_TIMER_DIVBY_128 0xa /* Divide by 128 */
  80. #define LOAPIC_TIMER_DIVBY_1 0xb /* Divide by 1 */
  81. #define LOAPIC_TIMER_DIVBY_MASK 0xf /* mask bits */
  82. #define LOAPIC_TIMER_PERIODIC 0x00020000 /* Timer Mode: Periodic */
  83. /* Local Vector's lock-unlock macro used in loApicIntLock/Unlock */
  84. #define LOCKED_TIMER 0x01
  85. #define LOCKED_PMC 0x02
  86. #define LOCKED_LINT0 0x04
  87. #define LOCKED_LINT1 0x08
  88. #define LOCKED_ERROR 0x10
  89. #define LOCKED_THERMAL 0x20
  90. /* Interrupt Command Register: delivery mode and status */
  91. #define MODE_FIXED 0x0 /* delivery mode: Fixed */
  92. #define MODE_LOWEST 0x1 /* delivery mode: Lowest */
  93. #define MODE_SMI 0x2 /* delivery mode: SMI */
  94. #define MODE_NMI 0x4 /* delivery mode: NMI */
  95. #define MODE_INIT 0x5 /* delivery mode: INIT */
  96. #define MODE_STARTUP 0x6 /* delivery mode: StartUp */
  97. #define STATUS_PEND 0x1000 /* delivery status: Pend */
  98. /* MP Configuration Table Entries */
  99. #define MP_ENTRY_CPU 0 /* Entry Type: CPU */
  100. #define MP_ENTRY_BUS 1 /* Entry Type: BUS */
  101. #define MP_ENTRY_IOAPIC 2 /* Entry Type: IO APIC */
  102. #define MP_ENTRY_IOINTERRUPT 3 /* Entry Type: IO INT */
  103. #define MP_ENTRY_LOINTERRUPT 4 /* Entry Type: LO INT */
  104. /* MP Configuration Table CPU Flags */
  105. #define MP_CPU_FLAGS_BP 0x02
  106. /* IMCR related bits */
  107. #define IMCR_ADRS 0x22 /* IMCR addr reg */
  108. #define IMCR_DATA 0x23 /* IMCR data reg */
  109. #define IMCR_REG_SEL 0x70 /* IMCR reg select */
  110. #define IMCR_IOAPIC_ON 0x01 /* IMCR IOAPIC route enable */
  111. #define IMCR_IOAPIC_OFF 0x00 /* IMCR IOAPIC route disable */
  112. #ifndef _ASMLANGUAGE
  113. /* MultiProcessor Specification version 1.4 */
  114. typedef struct /* MP Floating Pointer Structure */
  115.     {
  116.     char    signature [4]; /* "_MP_" */
  117.     UINT32  configTableAddr; /* address of the MP configuration table */
  118.     UINT8   length; /* length of the floating pointer structure */
  119.     UINT8   specRev; /* version number of the MP specification */
  120.     UINT8   cksum; /* checksum of the pointer structure */
  121.     UINT8   featureByte[5]; /* MP feature bytes 1 - 5 */
  122.     } MP_FPS;
  123. typedef struct /* MP Configuration Table Header */
  124.     {
  125.     char    mpSignature[4]; /* "PCMP" */
  126.     UINT16  tableLength; /* length of the base configuration table */
  127.     UINT8   specRevision; /* version number of the MP specification */
  128.     UINT8   cksum; /* checksum of the base configuration table */
  129.     char    oemId[8]; /* string that identifies the manufacturer */
  130.     char    prodId[12]; /* string that identifies the product */
  131.     UINT32  oemTablePtr; /* address to an OEM configuration table */
  132.     UINT16  oemTableSize; /* size of the OEM configuration table */
  133.     UINT16  entryCount; /* number of entries in the variable table */
  134.     UINT32  localApicBaseAddr; /* address of the Local APIC */
  135.     UINT16  extendedTableLength; /* length of the extended entries */
  136.     UINT8   extendedTableCksum; /* checksum of the extended table entries */
  137.     UINT8   reserved;            
  138.     } MP_HEADER; 
  139. typedef struct /* MP Config Table Entry for CPU's */
  140.     {
  141.     UINT8   entryType; /* 0 identifies a processor entry */
  142.     UINT8   localApicId; /* Local APIC ID number */
  143.     UINT8   localApicVersion; /* Local APIC's version number */
  144.     UINT8   cpuFlags; /* EN: usable, BP: boot-processor */
  145.     UINT32  cpuSig; /* stepping, model, family of the CPU */
  146.     UINT32  featureFlags; /* feature definition flag */
  147.     UINT32  reserved[2];
  148.     } MP_CPU;
  149. typedef struct /* MP Config Table Entry for IO APIC's */
  150.     {
  151.     UINT8  entryType; /* 2 identifies an IO APIC entry */
  152.     UINT8  ioApicId; /* ID of this IO APIC */
  153.     UINT8  ioApicVersion; /* version of this IO APIC */
  154.     UINT8  ioApicFlags; /* usable or not */
  155.     UINT32 ioApicBaseAddress; /* address of this IO APIC */
  156.     } MP_IOAPIC;
  157. /* variable declarations */
  158. IMPORT UINT32 loApicBase; /* default Local APIC addr */
  159. IMPORT UINT32 ioApicBase; /* default IO APIC index addr */
  160. IMPORT UINT32 ioApicData; /* default IO APIC data addr */
  161. IMPORT UINT32 loApicId; /* local APIC Id */
  162. IMPORT UINT32 loApicVersion; /* local APIC Version */
  163. IMPORT UINT32 loApicMaxLvt; /* local APIC Max LVT */
  164. #if defined(__STDC__) || defined(__cplusplus)
  165. IMPORT void loApicInit (void);
  166. IMPORT void loApicEnable (BOOL enable);
  167. IMPORT STATUS loApicIpi (INT32 apicId, INT32 shortHand, INT32 trigger, 
  168.  INT32 level, INT32 destMode, INT32 deliMode, 
  169.  INT32 vectorNo);
  170. #else
  171. IMPORT void loApicInit ();
  172. IMPORT void loApicEnable ();
  173. IMPORT STATUS loApicIpi ();
  174. #endif  /* __STDC__ */
  175. #endif  /* _ASMLANGUAGE */
  176. #ifdef __cplusplus
  177. }
  178. #endif
  179. #endif /* __INCloApich */