ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

apic.h
Go to the documentation of this file.
00001 /*
00002  *
00003  */
00004 
00005 #pragma once
00006 
00007 #define APIC_DEFAULT_BASE     0xFEE00000    /* Default Local APIC Base Register Address */
00008 
00009 /* APIC Register Address Map */
00010 #define APIC_ID      0x0020 /* Local APIC ID Register (R/W) */
00011 #define APIC_VER     0x0030 /* Local APIC Version Register (R) */
00012 #define APIC_TPR     0x0080 /* Task Priority Register (R/W) */
00013 #define APIC_APR     0x0090 /* Arbitration Priority Register (R) */
00014 #define APIC_PPR     0x00A0 /* Processor Priority Register (R) */
00015 #define APIC_EOI     0x00B0 /* EOI Register (W) */
00016 #define APIC_LDR     0x00D0 /* Logical Destination Register (R/W) */
00017 #define APIC_DFR     0x00E0 /* Destination Format Register (0-27 R, 28-31 R/W) */
00018 #define APIC_SIVR    0x00F0 /* Spurious Interrupt Vector Register (0-3 R, 4-9 R/W) */
00019 #define APIC_ISR     0x0100 /* Interrupt Service Register 0-255 (R) */
00020 #define APIC_TMR     0x0180 /* Trigger Mode Register 0-255 (R) */
00021 #define APIC_IRR     0x0200 /* Interrupt Request Register 0-255 (r) */
00022 #define APIC_ESR     0x0280 /* Error Status Register (R) */
00023 #define APIC_ICR0    0x0300 /* Interrupt Command Register 0-31 (R/W) */
00024 #define APIC_ICR1    0x0310 /* Interrupt Command Register 32-63 (R/W) */
00025 #define APIC_LVTT    0x0320 /* Local Vector Table (Timer) (R/W) */
00026 #define APIC_LVTTHMR 0x0330
00027 #define APIC_LVTPC   0x0340 /* Performance Counter LVT (R/W) */
00028 #define APIC_LINT0   0x0350 /* Local Vector Table (LINT0) (R/W) */
00029 #define APIC_LINT1   0x0360 /* Local Vector Table (LINT1) (R/W) */
00030 #define APIC_LVT3    0x0370 /* Local Vector Table (Error) (R/W) */
00031 #define APIC_ICRT    0x0380 /* Initial Count Register for Timer (R/W) */
00032 #define APIC_CCRT    0x0390 /* Current Count Register for Timer (R) */
00033 #define APIC_TDCR    0x03E0 /* Timer Divide Configuration Register (R/W) */
00034 
00035 #define APIC_ID_MASK        (0xF << 24)
00036 #define GET_APIC_ID(x)      (((x) & APIC_ID_MASK) >> 24)
00037 #define GET_APIC_LOGICAL_ID(x)  (((x)>>24)&0xFF)
00038 #define APIC_VER_MASK       0xFF00FF
00039 #define GET_APIC_VERSION(x) ((x) & 0xFF)
00040 #define GET_APIC_MAXLVT(x)  (((x) >> 16) & 0xFF)
00041 
00042 #define APIC_TPR_PRI       0xFF
00043 #define APIC_TPR_INT       0xF0
00044 #define APIC_TPR_SUB       0xF
00045 #define APIC_TPR_MAX       0xFF           /* Maximum priority */
00046 #define APIC_TPR_MIN       0x20           /* Minimum priority */
00047 
00048 #define APIC_LDR_MASK      (0xFF << 24)
00049 
00050 #define APIC_SIVR_ENABLE   (0x1 << 8)
00051 #define APIC_SIVR_FOCUS    (0x1 << 9)
00052 
00053 #define APIC_ESR_MASK      (0xFE << 0)    /* Error Mask */
00054 
00055 #define APIC_ICR0_VECTOR   (0xFF << 0)    /* Vector */
00056 #define APIC_ICR0_DM       (0x7 << 8)     /* Delivery Mode */
00057 #define APIC_ICR0_DESTM    (0x1 << 11)    /* Destination Mode */
00058 #define APIC_ICR0_DS       (0x1 << 12)    /* Delivery Status */
00059 #define APIC_ICR0_LEVEL    (0x1 << 14)    /* Level */
00060 #define APIC_ICR0_TM       (0x1 << 15)    /* Trigger Mode */
00061 #define APIC_ICR0_DESTS    (0x3 << 18)    /* Destination Shorthand */
00062 
00063 /* Delivery Modes */
00064 #define APIC_DM_FIXED     (0x0 << 8)
00065 #define APIC_DM_LOWEST    (0x1 << 8)
00066 #define APIC_DM_SMI       (0x2 << 8)
00067 #define APIC_DM_REMRD     (0x3 << 8)
00068 #define APIC_DM_NMI       (0x4 << 8)
00069 #define APIC_DM_INIT      (0x5 << 8)
00070 #define APIC_DM_STARTUP   (0x6 << 8)
00071 #define APIC_DM_EXTINT    (0x7 << 8)
00072 #define GET_APIC_DELIVERY_MODE(x)   (((x) >> 8) & 0x7)
00073 #define SET_APIC_DELIVERY_MODE(x,y) (((x) & ~0x700) | ((y) << 8))
00074 
00075 /* Destination Shorthand values */
00076 #define APIC_ICR0_DESTS_FIELD          (0x0 << 0)
00077 #define APIC_ICR0_DESTS_SELF           (0x1 << 18)
00078 #define APIC_ICR0_DESTS_ALL            (0x2 << 18)
00079 #define APIC_ICR0_DESTS_ALL_BUT_SELF   (0x3 << 18)
00080 
00081 #define APIC_ICR0_LEVEL_DEASSERT (0x0 << 14) /* Deassert level */
00082 #define APIC_ICR0_LEVEL_ASSERT   (0x1 << 14) /* Assert level */
00083 
00084 #define GET_APIC_DEST_FIELD(x)   (((x) >> 24) & 0xFF)
00085 #define SET_APIC_DEST_FIELD(x)   (((x) & 0xFF) << 24)
00086 
00087 #define GET_APIC_TIMER_BASE(x)   (((x) >> 18) & 0x3)
00088 #define SET_APIC_TIMER_BASE(x)   ((x) << 18)
00089 #define APIC_TIMER_BASE_CLKIN    0x0
00090 #define APIC_TIMER_BASE_TMBASE   0x1
00091 #define APIC_TIMER_BASE_DIV      0x2
00092 
00093 #define APIC_LVT_VECTOR           (0xFF << 0)   /* Vector */
00094 #define APIC_LVT_DS               (0x1 << 12)   /* Delivery Status */
00095 #define APIC_LVT_REMOTE_IRR       (0x1 << 14)       /* Remote IRR */
00096 #define APIC_LVT_LEVEL_TRIGGER  (0x1 << 15)     /* Lvel Triggered */
00097 #define APIC_LVT_MASKED         (0x1 << 16)   /* Mask */
00098 #define APIC_LVT_PERIODIC       (0x1 << 17)   /* Timer Mode */
00099 
00100 #define APIC_LVT3_DM        (0x7 << 8)
00101 #define APIC_LVT3_IIPP      (0x1 << 13)
00102 #define APIC_LVT3_TM        (0x1 << 15)
00103 #define APIC_LVT3_MASKED    (0x1 << 16)
00104 #define APIC_LVT3_OS        (0x1 << 17)
00105 
00106 #define APIC_TDCR_TMBASE   (0x1 << 2)
00107 #define APIC_TDCR_MASK     0x0F
00108 #define APIC_TDCR_2        0x00
00109 #define APIC_TDCR_4        0x01
00110 #define APIC_TDCR_8        0x02
00111 #define APIC_TDCR_16       0x03
00112 #define APIC_TDCR_32       0x08
00113 #define APIC_TDCR_64       0x09
00114 #define APIC_TDCR_128      0x0A
00115 #define APIC_TDCR_1        0x0B
00116 
00117 #define APIC_LVT_VECTOR           (0xFF << 0)   /* Vector */
00118 #define APIC_LVT_DS               (0x1 << 12)   /* Delivery Status */
00119 #define APIC_LVT_REMOTE_IRR       (0x1 << 14)       /* Remote IRR */
00120 #define APIC_LVT_LEVEL_TRIGGER  (0x1 << 15)     /* Lvel Triggered */
00121 #define APIC_LVT_MASKED         (0x1 << 16)   /* Mask */
00122 #define APIC_LVT_PERIODIC       (0x1 << 17)   /* Timer Mode */
00123 
00124 #define APIC_LVT3_DM        (0x7 << 8)
00125 #define APIC_LVT3_IIPP      (0x1 << 13)
00126 #define APIC_LVT3_TM        (0x1 << 15)
00127 #define APIC_LVT3_MASKED    (0x1 << 16)
00128 #define APIC_LVT3_OS        (0x1 << 17)
00129 
00130 #define APIC_TDCR_TMBASE   (0x1 << 2)
00131 #define APIC_TDCR_MASK     0x0F
00132 #define APIC_TDCR_2        0x00
00133 #define APIC_TDCR_4        0x01
00134 #define APIC_TDCR_8        0x02
00135 #define APIC_TDCR_16       0x03
00136 #define APIC_TDCR_32       0x08
00137 #define APIC_TDCR_64       0x09
00138 #define APIC_TDCR_128      0x0A
00139 #define APIC_TDCR_1        0x0B
00140 
00141 #define APIC_TARGET_SELF         0x100
00142 #define APIC_TARGET_ALL          0x200
00143 #define APIC_TARGET_ALL_BUT_SELF 0x300
00144 
00145 #define APIC_INTEGRATED(version) (version & 0xF0)
00146 
00147 typedef enum {
00148   amPIC = 0,    /* IMCR and PIC compatibility mode */
00149   amVWIRE       /* Virtual Wire compatibility mode */
00150 } APIC_MODE;
00151 
00152 #ifdef CONFIG_SMP
00153 #define MAX_CPU   32
00154 #else
00155 #define MAX_CPU   1
00156 #endif
00157 
00158 /*
00159  * Local APIC timer IRQ vector is on a different priority level,
00160  * to work around the 'lost local interrupt if more than 2 IRQ
00161  * sources per level' errata.
00162  */
00163 #define LOCAL_TIMER_VECTOR      0xEF
00164 
00165 #define IPI_VECTOR          0xFB
00166 #define ERROR_VECTOR            0xFE
00167 #define SPURIOUS_VECTOR         0xFF  /* Must be 0xXF */
00168 
00169 /* CPU flags */
00170 #define CPU_USABLE   0x01  /* 1 if the CPU is usable (ie. can be used) */
00171 #define CPU_ENABLED  0x02  /* 1 if the CPU is enabled */
00172 #define CPU_BSP      0x04  /* 1 if the CPU is the bootstrap processor */
00173 #define CPU_TSC      0x08  /* 1 if the CPU has a time stamp counter */
00174 
00175 typedef struct _CPU_INFO
00176 {
00177    UCHAR    Flags;            /* CPU flags */
00178    UCHAR    APICId;           /* Local APIC ID */
00179    UCHAR    APICVersion;      /* Local APIC version */
00180 //   UCHAR    MaxLVT;           /* Number of LVT registers */
00181    ULONG    BusSpeed;         /* BUS speed */
00182    ULONG    CoreSpeed;        /* Core speed */
00183    UCHAR    Padding[16-12];   /* Padding to 16-byte */
00184 } CPU_INFO, *PCPU_INFO;
00185 
00186 extern ULONG CPUCount;          /* Total number of CPUs */
00187 extern ULONG BootCPU;                   /* Bootstrap processor */
00188 extern ULONG OnlineCPUs;        /* Bitmask of online CPUs */
00189 extern CPU_INFO CPUMap[MAX_CPU];    /* Map of all CPUs in the system */
00190 
00191 /* Prototypes */
00192 
00193 __inline VOID APICWrite(ULONG Offset, ULONG Value);
00194 __inline ULONG APICRead(ULONG Offset);
00195 VOID APICSendIPI(ULONG Target, ULONG Mode);
00196 VOID APICSetup(VOID);
00197 VOID HaliInitBSP(VOID);
00198 VOID APICSyncArbIDs(VOID);
00199 __inline VOID APICSendEOI(VOID);
00200 VOID APICCalibrateTimer(ULONG CPU);
00201 VOID HaliStartApplicationProcessor(ULONG Cpu, ULONG Stack);
00202 
00203 static __inline ULONG ThisCPU(VOID)
00204 {
00205     return (APICRead(APIC_ID) & APIC_ID_MASK) >> 24;
00206 }
00207 
00208 /* EOF */

Generated on Sun May 27 2012 04:28:41 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.