ReactOS  0.4.15-dev-3175-g222acf5
apicp.h File Reference
#include <pshpack1.h>
#include <poppack.h>
Include dependency graph for apicp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

union  _APIC_BASE_ADRESS_REGISTER
 
union  _APIC_SPURIOUS_INERRUPT_REGISTER
 
union  _APIC_VERSION_REGISTER
 
union  _APIC_EXTENDED_CONTROL_REGISTER
 
union  _APIC_INTERRUPT_COMMAND_REGISTER
 
union  _LVT_REGISTER
 
union  _IOAPIC_REDIRECTION_REGISTER
 

Macros

#define LOCAL_APIC_BASE   0xFFFE0000
 
#define IOAPIC_BASE   0xFFFE1000
 
#define APIC_SPURIOUS_VECTOR   0x1f
 
#define APC_VECTOR   0x3D
 
#define DISPATCH_VECTOR   0x41
 
#define APIC_GENERIC_VECTOR   0xC1
 
#define APIC_CLOCK_VECTOR   0xD1
 
#define APIC_SYNCH_VECTOR   0xD1
 
#define APIC_IPI_VECTOR   0xE1
 
#define APIC_ERROR_VECTOR   0xE3
 
#define POWERFAIL_VECTOR   0xEF
 
#define APIC_PROFILE_VECTOR   0xFD
 
#define APIC_PERF_VECTOR   0xFE
 
#define APIC_NMI_VECTOR   0xFF
 
#define IrqlToTpr(Irql)   (HalpIRQLtoTPR[Irql])
 
#define IrqlToSoftVector(Irql)   IrqlToTpr(Irql)
 
#define TprToIrql(Tpr)   (HalVectorToIRQL[Tpr >> 4])
 
#define APIC_MAX_IRQ   24
 
#define APIC_FREE_VECTOR   0xFF
 
#define APIC_RESERVED_VECTOR   0xFE
 
#define IMCR_ADDRESS_PORT   (PUCHAR)0x0022
 
#define IMCR_DATA_PORT   (PUCHAR)0x0023
 
#define IMCR_SELECT   0x70
 
#define IMCR_PIC_DIRECT   0x00
 
#define IMCR_PIC_VIA_APIC   0x01
 
#define MSR_APIC_BASE   0x0000001B
 
#define IOAPIC_PHYS_BASE   0xFEC00000
 
#define APIC_CLOCK_INDEX   8
 
#define ApicLogicalId(Cpu)   ((UCHAR)(1<< Cpu))
 

Typedefs

typedef enum _APIC_REGISTER APIC_REGISTER
 
typedef enum _APIC_MT APIC_MT
 
typedef enum _APIC_TGM APIC_TGM
 
typedef enum _APIC_DM APIC_DM
 
typedef enum _APIC_DSH APIC_DSH
 
typedef enum _APIC_DF APIC_DF
 
typedef enum _APIC_RRS APIC_RRS
 
typedef union _APIC_BASE_ADRESS_REGISTER APIC_BASE_ADRESS_REGISTER
 
typedef union _APIC_SPURIOUS_INERRUPT_REGISTER APIC_SPURIOUS_INERRUPT_REGISTER
 
typedef union _APIC_VERSION_REGISTER APIC_VERSION_REGISTER
 
typedef union _APIC_EXTENDED_CONTROL_REGISTER APIC_EXTENDED_CONTROL_REGISTER
 
typedef union _APIC_INTERRUPT_COMMAND_REGISTER APIC_INTERRUPT_COMMAND_REGISTER
 
typedef union _LVT_REGISTER LVT_REGISTER
 
typedef union _IOAPIC_REDIRECTION_REGISTER IOAPIC_REDIRECTION_REGISTER
 

Enumerations

enum  _APIC_REGISTER {
  APIC_ID = 0x0020, APIC_VER = 0x0030, APIC_TPR = 0x0080, APIC_APR = 0x0090,
  APIC_PPR = 0x00A0, APIC_EOI = 0x00B0, APIC_RRR = 0x00C0, APIC_LDR = 0x00D0,
  APIC_DFR = 0x00E0, APIC_SIVR = 0x00F0, APIC_ISR = 0x0100, APIC_TMR = 0x0180,
  APIC_IRR = 0x0200, APIC_ESR = 0x0280, APIC_ICR0 = 0x0300, APIC_ICR1 = 0x0310,
  APIC_TMRLVTR = 0x0320, APIC_THRMLVTR = 0x0330, APIC_PCLVTR = 0x0340, APIC_LINT0 = 0x0350,
  APIC_LINT1 = 0x0360, APIC_ERRLVTR = 0x0370, APIC_TICR = 0x0380, APIC_TCCR = 0x0390,
  APIC_TDCR = 0x03E0, APIC_EAFR = 0x0400, APIC_EACR = 0x0410, APIC_SEOI = 0x0420,
  APIC_EXT0LVTR = 0x0500, APIC_EXT1LVTR = 0x0510, APIC_EXT2LVTR = 0x0520, APIC_EXT3LVTR = 0x0530
}
 
enum  _APIC_MT {
  APIC_MT_Fixed = 0, APIC_MT_LowestPriority = 1, APIC_MT_SMI = 2, APIC_MT_RemoteRead = 3,
  APIC_MT_NMI = 4, APIC_MT_INIT = 5, APIC_MT_Startup = 6, APIC_MT_ExtInt = 7
}
 
enum  _APIC_TGM { APIC_TGM_Edge, APIC_TGM_Level }
 
enum  _APIC_DM { APIC_DM_Physical, APIC_DM_Logical }
 
enum  _APIC_DSH { APIC_DSH_Destination, APIC_DSH_Self, APIC_DSH_AllIncludingSelf, APIC_DSH_AllExclusingSelf }
 
enum  _APIC_DF { APIC_DF_Flat = 0xFFFFFFFF, APIC_DF_Cluster = 0x0FFFFFFF }
 
enum  _APIC_RRS { APIC_RRS_Invalid = 0, APIC_RRS_Pending = 1, APIC_RRS_Done = 2 }
 
enum  _TIMER_DV {
  TIMER_DV_DivideBy2 = 0, TIMER_DV_DivideBy4 = 1, TIMER_DV_DivideBy8 = 2, TIMER_DV_DivideBy16 = 3,
  TIMER_DV_DivideBy32 = 8, TIMER_DV_DivideBy64 = 9, TIMER_DV_DivideBy128 = 10, TIMER_DV_DivideBy1 = 11
}
 
enum  { IOAPIC_IOREGSEL = 0x00, IOAPIC_IOWIN = 0x10 }
 
enum  { IOAPIC_ID = 0x00, IOAPIC_VER = 0x01, IOAPIC_ARB = 0x02, IOAPIC_REDTBL = 0x10 }
 

Functions

FORCEINLINE ULONG ApicRead (APIC_REGISTER Register)
 
FORCEINLINE VOID ApicWrite (APIC_REGISTER Register, ULONG Value)
 
VOID NTAPI ApicInitializeTimer (ULONG Cpu)
 
VOID NTAPI HalInitializeProfiling (VOID)
 
VOID NTAPI HalpInitApicInfo (IN PLOADER_PARAMETER_BLOCK KeLoaderBlock)
 
VOID __cdecl ApicSpuriousService (VOID)
 

Variables

enum _TIMER_DV TIMER_DV
 

Macro Definition Documentation

◆ APC_VECTOR

#define APC_VECTOR   0x3D

Definition at line 41 of file apicp.h.

◆ APIC_CLOCK_INDEX

#define APIC_CLOCK_INDEX   8

Definition at line 115 of file apicp.h.

◆ APIC_CLOCK_VECTOR

#define APIC_CLOCK_VECTOR   0xD1

Definition at line 44 of file apicp.h.

◆ APIC_ERROR_VECTOR

#define APIC_ERROR_VECTOR   0xE3

Definition at line 47 of file apicp.h.

◆ APIC_FREE_VECTOR

#define APIC_FREE_VECTOR   0xFF

Definition at line 59 of file apicp.h.

◆ APIC_GENERIC_VECTOR

#define APIC_GENERIC_VECTOR   0xC1

Definition at line 43 of file apicp.h.

◆ APIC_IPI_VECTOR

#define APIC_IPI_VECTOR   0xE1

Definition at line 46 of file apicp.h.

◆ APIC_MAX_IRQ

#define APIC_MAX_IRQ   24

Definition at line 58 of file apicp.h.

◆ APIC_NMI_VECTOR

#define APIC_NMI_VECTOR   0xFF

Definition at line 51 of file apicp.h.

◆ APIC_PERF_VECTOR

#define APIC_PERF_VECTOR   0xFE

Definition at line 50 of file apicp.h.

◆ APIC_PROFILE_VECTOR

#define APIC_PROFILE_VECTOR   0xFD

Definition at line 49 of file apicp.h.

◆ APIC_RESERVED_VECTOR

#define APIC_RESERVED_VECTOR   0xFE

Definition at line 60 of file apicp.h.

◆ APIC_SPURIOUS_VECTOR

#define APIC_SPURIOUS_VECTOR   0x1f

Definition at line 40 of file apicp.h.

◆ APIC_SYNCH_VECTOR

#define APIC_SYNCH_VECTOR   0xD1

Definition at line 45 of file apicp.h.

◆ ApicLogicalId

#define ApicLogicalId (   Cpu)    ((UCHAR)(1<< Cpu))

Definition at line 116 of file apicp.h.

◆ DISPATCH_VECTOR

#define DISPATCH_VECTOR   0x41

Definition at line 42 of file apicp.h.

◆ IMCR_ADDRESS_PORT

#define IMCR_ADDRESS_PORT   (PUCHAR)0x0022

Definition at line 69 of file apicp.h.

◆ IMCR_DATA_PORT

#define IMCR_DATA_PORT   (PUCHAR)0x0023

Definition at line 70 of file apicp.h.

◆ IMCR_PIC_DIRECT

#define IMCR_PIC_DIRECT   0x00

Definition at line 72 of file apicp.h.

◆ IMCR_PIC_VIA_APIC

#define IMCR_PIC_VIA_APIC   0x01

Definition at line 73 of file apicp.h.

◆ IMCR_SELECT

#define IMCR_SELECT   0x70

Definition at line 71 of file apicp.h.

◆ IOAPIC_BASE

#define IOAPIC_BASE   0xFFFE1000

Definition at line 37 of file apicp.h.

◆ IOAPIC_PHYS_BASE

#define IOAPIC_PHYS_BASE   0xFEC00000

Definition at line 114 of file apicp.h.

◆ IrqlToSoftVector

#define IrqlToSoftVector (   Irql)    IrqlToTpr(Irql)

Definition at line 54 of file apicp.h.

◆ IrqlToTpr

#define IrqlToTpr (   Irql)    (HalpIRQLtoTPR[Irql])

Definition at line 53 of file apicp.h.

◆ LOCAL_APIC_BASE

#define LOCAL_APIC_BASE   0xFFFE0000

Definition at line 36 of file apicp.h.

◆ MSR_APIC_BASE

#define MSR_APIC_BASE   0x0000001B

Definition at line 113 of file apicp.h.

◆ POWERFAIL_VECTOR

#define POWERFAIL_VECTOR   0xEF

Definition at line 48 of file apicp.h.

◆ TprToIrql

#define TprToIrql (   Tpr)    (HalVectorToIRQL[Tpr >> 4])

Definition at line 55 of file apicp.h.

Typedef Documentation

◆ APIC_BASE_ADRESS_REGISTER

◆ APIC_DF

◆ APIC_DM

◆ APIC_DSH

◆ APIC_EXTENDED_CONTROL_REGISTER

◆ APIC_INTERRUPT_COMMAND_REGISTER

◆ APIC_MT

◆ APIC_REGISTER

◆ APIC_RRS

◆ APIC_SPURIOUS_INERRUPT_REGISTER

◆ APIC_TGM

◆ APIC_VERSION_REGISTER

◆ IOAPIC_REDIRECTION_REGISTER

◆ LVT_REGISTER

typedef union _LVT_REGISTER LVT_REGISTER

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
IOAPIC_IOREGSEL 
IOAPIC_IOWIN 

Definition at line 280 of file apicp.h.

281 {
282  IOAPIC_IOREGSEL = 0x00,
283  IOAPIC_IOWIN = 0x10
284 };

◆ anonymous enum

anonymous enum
Enumerator
IOAPIC_ID 
IOAPIC_VER 
IOAPIC_ARB 
IOAPIC_REDTBL 

Definition at line 287 of file apicp.h.

288 {
289  IOAPIC_ID = 0x00,
290  IOAPIC_VER = 0x01,
291  IOAPIC_ARB = 0x02,
292  IOAPIC_REDTBL = 0x10
293 };

◆ _APIC_DF

Enumerator
APIC_DF_Flat 
APIC_DF_Cluster 

Definition at line 158 of file apicp.h.

159 {
160  APIC_DF_Flat = 0xFFFFFFFF,
161  APIC_DF_Cluster = 0x0FFFFFFF
162 } APIC_DF;
enum _APIC_DF APIC_DF

◆ _APIC_DM

Enumerator
APIC_DM_Physical 
APIC_DM_Logical 

Definition at line 142 of file apicp.h.

143 {
146 } APIC_DM;
enum _APIC_DM APIC_DM

◆ _APIC_DSH

Enumerator
APIC_DSH_Destination 
APIC_DSH_Self 
APIC_DSH_AllIncludingSelf 
APIC_DSH_AllExclusingSelf 

Definition at line 149 of file apicp.h.

◆ _APIC_MT

Enumerator
APIC_MT_Fixed 
APIC_MT_LowestPriority 
APIC_MT_SMI 
APIC_MT_RemoteRead 
APIC_MT_NMI 
APIC_MT_INIT 
APIC_MT_Startup 
APIC_MT_ExtInt 

Definition at line 122 of file apicp.h.

123 {
124  APIC_MT_Fixed = 0,
126  APIC_MT_SMI = 2,
127  APIC_MT_RemoteRead = 3,
128  APIC_MT_NMI = 4,
129  APIC_MT_INIT = 5,
130  APIC_MT_Startup = 6,
131  APIC_MT_ExtInt = 7,
132 } APIC_MT;
enum _APIC_MT APIC_MT

◆ _APIC_REGISTER

Enumerator
APIC_ID 
APIC_VER 
APIC_TPR 
APIC_APR 
APIC_PPR 
APIC_EOI 
APIC_RRR 
APIC_LDR 
APIC_DFR 
APIC_SIVR 
APIC_ISR 
APIC_TMR 
APIC_IRR 
APIC_ESR 
APIC_ICR0 
APIC_ICR1 
APIC_TMRLVTR 
APIC_THRMLVTR 
APIC_PCLVTR 
APIC_LINT0 
APIC_LINT1 
APIC_ERRLVTR 
APIC_TICR 
APIC_TCCR 
APIC_TDCR 
APIC_EAFR 
APIC_EACR 
APIC_SEOI 
APIC_EXT0LVTR 
APIC_EXT1LVTR 
APIC_EXT2LVTR 
APIC_EXT3LVTR 

Definition at line 77 of file apicp.h.

78 {
79  APIC_ID = 0x0020, /* Local APIC ID Register (R/W) */
80  APIC_VER = 0x0030, /* Local APIC Version Register (R) */
81  APIC_TPR = 0x0080, /* Task Priority Register (R/W) */
82  APIC_APR = 0x0090, /* Arbitration Priority Register (R) */
83  APIC_PPR = 0x00A0, /* Processor Priority Register (R) */
84  APIC_EOI = 0x00B0, /* EOI Register (W) */
85  APIC_RRR = 0x00C0, /* Remote Read Register () */
86  APIC_LDR = 0x00D0, /* Logical Destination Register (R/W) */
87  APIC_DFR = 0x00E0, /* Destination Format Register (0-27 R, 28-31 R/W) */
88  APIC_SIVR = 0x00F0, /* Spurious Interrupt Vector Register (0-3 R, 4-9 R/W) */
89  APIC_ISR = 0x0100, /* Interrupt Service Register 0-255 (R) */
90  APIC_TMR = 0x0180, /* Trigger Mode Register 0-255 (R) */
91  APIC_IRR = 0x0200, /* Interrupt Request Register 0-255 (r) */
92  APIC_ESR = 0x0280, /* Error Status Register (R) */
93  APIC_ICR0 = 0x0300, /* Interrupt Command Register 0-31 (R/W) */
94  APIC_ICR1 = 0x0310, /* Interrupt Command Register 32-63 (R/W) */
95  APIC_TMRLVTR = 0x0320, /* Timer Local Vector Table (R/W) */
96  APIC_THRMLVTR = 0x0330, /* Thermal Local Vector Table */
97  APIC_PCLVTR = 0x0340, /* Performance Counter Local Vector Table (R/W) */
98  APIC_LINT0 = 0x0350, /* LINT0 Local Vector Table (R/W) */
99  APIC_LINT1 = 0x0360, /* LINT1 Local Vector Table (R/W) */
100  APIC_ERRLVTR = 0x0370, /* Error Local Vector Table (R/W) */
101  APIC_TICR = 0x0380, /* Initial Count Register for Timer (R/W) */
102  APIC_TCCR = 0x0390, /* Current Count Register for Timer (R) */
103  APIC_TDCR = 0x03E0, /* Timer Divide Configuration Register (R/W) */
104  APIC_EAFR = 0x0400, /* extended APIC Feature register (R/W) */
105  APIC_EACR = 0x0410, /* Extended APIC Control Register (R/W) */
106  APIC_SEOI = 0x0420, /* Specific End Of Interrupt Register (W) */
107  APIC_EXT0LVTR = 0x0500, /* Extended Interrupt 0 Local Vector Table */
108  APIC_EXT1LVTR = 0x0510, /* Extended Interrupt 1 Local Vector Table */
109  APIC_EXT2LVTR = 0x0520, /* Extended Interrupt 2 Local Vector Table */
110  APIC_EXT3LVTR = 0x0530 /* Extended Interrupt 3 Local Vector Table */
111 } APIC_REGISTER;
Definition: apicp.h:80
Definition: apicp.h:87
Definition: apicp.h:82
Definition: apicp.h:85
Definition: apicp.h:90
Definition: apicp.h:83
Definition: apicp.h:92
Definition: apicp.h:79
Definition: apicp.h:89
Definition: apicp.h:86
enum _APIC_REGISTER APIC_REGISTER
Definition: apicp.h:91
Definition: apicp.h:84
Definition: apicp.h:81

◆ _APIC_RRS

Enumerator
APIC_RRS_Invalid 
APIC_RRS_Pending 
APIC_RRS_Done 

Definition at line 165 of file apicp.h.

166 {
167  APIC_RRS_Invalid = 0,
168  APIC_RRS_Pending = 1,
169  APIC_RRS_Done = 2
170 } APIC_RRS;
enum _APIC_RRS APIC_RRS

◆ _APIC_TGM

Enumerator
APIC_TGM_Edge 
APIC_TGM_Level 

Definition at line 135 of file apicp.h.

136 {
139 } APIC_TGM;
enum _APIC_TGM APIC_TGM

◆ _TIMER_DV

Enumerator
TIMER_DV_DivideBy2 
TIMER_DV_DivideBy4 
TIMER_DV_DivideBy8 
TIMER_DV_DivideBy16 
TIMER_DV_DivideBy32 
TIMER_DV_DivideBy64 
TIMER_DV_DivideBy128 
TIMER_DV_DivideBy1 

Definition at line 173 of file apicp.h.

Function Documentation

◆ ApicInitializeTimer()

VOID NTAPI ApicInitializeTimer ( ULONG  Cpu)

Definition at line 50 of file apictimer.c.

51 {
52 
53  /* Initialize the TSC */
54  //HalpInitializeTsc();
55 
56  /* Set clock multiplier to 1 */
58 
60 
61 // KeSetTimeIncrement
62 }
VOID NTAPI ApicSetTimerInterval(ULONG MicroSeconds)
Definition: apictimer.c:28
FORCEINLINE VOID ApicWrite(APIC_REGISTER Register, ULONG Value)
Definition: apicp.h:328

◆ ApicRead()

FORCEINLINE ULONG ApicRead ( APIC_REGISTER  Register)

Definition at line 321 of file apicp.h.

322 {
323  return READ_REGISTER_ULONG((PULONG)(APIC_BASE + Register));
324 }
NTKERNELAPI ULONG NTAPI READ_REGISTER_ULONG(IN PULONG Register)
unsigned int * PULONG
Definition: retypes.h:1
#define APIC_BASE
Definition: ketypes.h:262

Referenced by ApicGetCurrentIrql(), ApicGetProcessorIrql(), ApicInitializeIOApic(), and ApicInitializeLocalApic().

◆ ApicSpuriousService()

VOID __cdecl ApicSpuriousService ( VOID  )

Referenced by ApicInitializeLocalApic().

◆ ApicWrite()

FORCEINLINE VOID ApicWrite ( APIC_REGISTER  Register,
ULONG  Value 
)

Definition at line 328 of file apicp.h.

329 {
330  WRITE_REGISTER_ULONG((PULONG)(APIC_BASE + Register), Value);
331 }
NTKERNELAPI VOID NTAPI WRITE_REGISTER_ULONG(IN PULONG Register, IN ULONG Value)
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
unsigned int * PULONG
Definition: retypes.h:1
#define APIC_BASE
Definition: ketypes.h:262

Referenced by ApicInitializeLocalApic(), ApicInitializeTimer(), ApicLowerIrql(), ApicRequestGlobalInterrupt(), ApicRequestSelfInterrupt(), ApicSendEOI(), ApicSetIrql(), ApicSetTimerInterval(), HalBeginSystemInterrupt(), HalSetProfileInterval(), HalStartProfileInterrupt(), and HalStopProfileInterrupt().

◆ HalInitializeProfiling()

VOID NTAPI HalInitializeProfiling ( VOID  )

Definition at line 76 of file apictimer.c.

77 {
79  KeGetPcr()->HalReserved[HAL_PROFILING_MULTIPLIER] = 1; /* TODO: HACK */
80 }
#define KeGetPcr()
Definition: ke.h:26
ULONGLONG HalCurProfileInterval
Definition: apictimer.c:20
#define HAL_PROFILING_MULTIPLIER
Definition: halp.h:47
#define HAL_PROFILING_INTERVAL
Definition: halp.h:46

Referenced by HalpInitProcessor().

◆ HalpInitApicInfo()

VOID NTAPI HalpInitApicInfo ( IN PLOADER_PARAMETER_BLOCK  KeLoaderBlock)

Variable Documentation

◆ TIMER_DV

enum _TIMER_DV TIMER_DV