ReactOS  0.4.15-dev-2534-geba00d1
apic.h File Reference
#include <pshpack1.h>
#include <poppack.h>
Include dependency graph for apic.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_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 IrqlToTpr(Irql)   (HalpIRQLtoTPR[Irql])
 
#define IrqlToSoftVector(Irql)   IrqlToTpr(Irql)
 
#define TprToIrql(Tpr)   (HalVectorToIRQL[Tpr >> 4])
 
#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 ZERO_VECTOR   0x00
 
#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 APIC_ID   0x0020 /* Local APIC ID Register (R/W) */
 
#define APIC_VER   0x0030 /* Local APIC Version Register (R) */
 
#define APIC_TPR   0x0080 /* Task Priority Register (R/W) */
 
#define APIC_APR   0x0090 /* Arbitration Priority Register (R) */
 
#define APIC_PPR   0x00A0 /* Processor Priority Register (R) */
 
#define APIC_EOI   0x00B0 /* EOI Register (W) */
 
#define APIC_RRR   0x00C0 /* Remote Read Register () */
 
#define APIC_LDR   0x00D0 /* Logical Destination Register (R/W) */
 
#define APIC_DFR   0x00E0 /* Destination Format Register (0-27 R, 28-31 R/W) */
 
#define APIC_SIVR   0x00F0 /* Spurious Interrupt Vector Register (0-3 R, 4-9 R/W) */
 
#define APIC_ISR   0x0100 /* Interrupt Service Register 0-255 (R) */
 
#define APIC_TMR   0x0180 /* Trigger Mode Register 0-255 (R) */
 
#define APIC_IRR   0x0200 /* Interrupt Request Register 0-255 (r) */
 
#define APIC_ESR   0x0280 /* Error Status Register (R) */
 
#define APIC_ICR0   0x0300 /* Interrupt Command Register 0-31 (R/W) */
 
#define APIC_ICR1   0x0310 /* Interrupt Command Register 32-63 (R/W) */
 
#define APIC_TMRLVTR   0x0320 /* Timer Local Vector Table (R/W) */
 
#define APIC_THRMLVTR   0x0330 /* Thermal Local Vector Table */
 
#define APIC_PCLVTR   0x0340 /* Performance Counter Local Vector Table (R/W) */
 
#define APIC_LINT0   0x0350 /* LINT0 Local Vector Table (R/W) */
 
#define APIC_LINT1   0x0360 /* LINT1 Local Vector Table (R/W) */
 
#define APIC_ERRLVTR   0x0370 /* Error Local Vector Table (R/W) */
 
#define APIC_TICR   0x0380 /* Initial Count Register for Timer (R/W) */
 
#define APIC_TCCR   0x0390 /* Current Count Register for Timer (R) */
 
#define APIC_TDCR   0x03E0 /* Timer Divide Configuration Register (R/W) */
 
#define APIC_EAFR   0x0400 /* extended APIC Feature register (R/W) */
 
#define APIC_EACR   0x0410 /* Extended APIC Control Register (R/W) */
 
#define APIC_SEOI   0x0420 /* Specific End Of Interrupt Register (W) */
 
#define APIC_EXT0LVTR   0x0500 /* Extended Interrupt 0 Local Vector Table */
 
#define APIC_EXT1LVTR   0x0510 /* Extended Interrupt 1 Local Vector Table */
 
#define APIC_EXT2LVTR   0x0520 /* Extended Interrupt 2 Local Vector Table */
 
#define APIC_EXT3LVTR   0x0530 /* Extended Interrupt 3 Local Vector Table */
 
#define MSR_APIC_BASE   0x0000001B
 
#define IOAPIC_PHYS_BASE   0xFEC00000
 
#define APIC_CLOCK_INDEX   8
 
#define ApicLogicalId(Cpu)   ((UCHAR)(1<< Cpu))
 

Typedefs

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_COMMAND_REGISTER APIC_COMMAND_REGISTER
 
typedef union _LVT_REGISTER LVT_REGISTER
 
typedef union _IOAPIC_REDIRECTION_REGISTER IOAPIC_REDIRECTION_REGISTER
 

Enumerations

enum  {
  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_Edge, APIC_TGM_Level }
 
enum  { APIC_DM_Physical, APIC_DM_Logical }
 
enum  { APIC_DSH_Destination, APIC_DSH_Self, APIC_DSH_AllIncludingSelf, APIC_DSH_AllExclusingSelf }
 
enum  { APIC_DF_Flat = 0xFFFFFFFF, APIC_DF_Cluster = 0x0FFFFFFF }
 
enum  {
  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 (ULONG Offset)
 
FORCEINLINE VOID ApicWrite (ULONG Offset, ULONG Value)
 
VOID NTAPI ApicInitializeTimer (ULONG Cpu)
 
VOID NTAPI HalInitializeProfiling (VOID)
 
VOID NTAPI HalpInitApicInfo (IN PLOADER_PARAMETER_BLOCK KeLoaderBlock)
 
VOID __cdecl ApicSpuriousService (VOID)
 

Macro Definition Documentation

◆ APC_VECTOR

#define APC_VECTOR   0x3D

Definition at line 42 of file apic.h.

◆ APIC_APR

#define APIC_APR   0x0090 /* Arbitration Priority Register (R) */

Definition at line 58 of file apic.h.

◆ APIC_CLOCK_INDEX

#define APIC_CLOCK_INDEX   8

Definition at line 90 of file apic.h.

◆ APIC_CLOCK_VECTOR

#define APIC_CLOCK_VECTOR   0xD1

Definition at line 45 of file apic.h.

◆ APIC_DFR

#define APIC_DFR   0x00E0 /* Destination Format Register (0-27 R, 28-31 R/W) */

Definition at line 63 of file apic.h.

◆ APIC_EACR

#define APIC_EACR   0x0410 /* Extended APIC Control Register (R/W) */

Definition at line 81 of file apic.h.

◆ APIC_EAFR

#define APIC_EAFR   0x0400 /* extended APIC Feature register (R/W) */

Definition at line 80 of file apic.h.

◆ APIC_EOI

#define APIC_EOI   0x00B0 /* EOI Register (W) */

Definition at line 60 of file apic.h.

◆ APIC_ERRLVTR

#define APIC_ERRLVTR   0x0370 /* Error Local Vector Table (R/W) */

Definition at line 76 of file apic.h.

◆ APIC_ERROR_VECTOR

#define APIC_ERROR_VECTOR   0xE3

Definition at line 48 of file apic.h.

◆ APIC_ESR

#define APIC_ESR   0x0280 /* Error Status Register (R) */

Definition at line 68 of file apic.h.

◆ APIC_EXT0LVTR

#define APIC_EXT0LVTR   0x0500 /* Extended Interrupt 0 Local Vector Table */

Definition at line 83 of file apic.h.

◆ APIC_EXT1LVTR

#define APIC_EXT1LVTR   0x0510 /* Extended Interrupt 1 Local Vector Table */

Definition at line 84 of file apic.h.

◆ APIC_EXT2LVTR

#define APIC_EXT2LVTR   0x0520 /* Extended Interrupt 2 Local Vector Table */

Definition at line 85 of file apic.h.

◆ APIC_EXT3LVTR

#define APIC_EXT3LVTR   0x0530 /* Extended Interrupt 3 Local Vector Table */

Definition at line 86 of file apic.h.

◆ APIC_GENERIC_VECTOR

#define APIC_GENERIC_VECTOR   0xC1

Definition at line 44 of file apic.h.

◆ APIC_ICR0

#define APIC_ICR0   0x0300 /* Interrupt Command Register 0-31 (R/W) */

Definition at line 69 of file apic.h.

◆ APIC_ICR1

#define APIC_ICR1   0x0310 /* Interrupt Command Register 32-63 (R/W) */

Definition at line 70 of file apic.h.

◆ APIC_ID

#define APIC_ID   0x0020 /* Local APIC ID Register (R/W) */

Definition at line 55 of file apic.h.

◆ APIC_IPI_VECTOR

#define APIC_IPI_VECTOR   0xE1

Definition at line 47 of file apic.h.

◆ APIC_IRR

#define APIC_IRR   0x0200 /* Interrupt Request Register 0-255 (r) */

Definition at line 67 of file apic.h.

◆ APIC_ISR

#define APIC_ISR   0x0100 /* Interrupt Service Register 0-255 (R) */

Definition at line 65 of file apic.h.

◆ APIC_LDR

#define APIC_LDR   0x00D0 /* Logical Destination Register (R/W) */

Definition at line 62 of file apic.h.

◆ APIC_LINT0

#define APIC_LINT0   0x0350 /* LINT0 Local Vector Table (R/W) */

Definition at line 74 of file apic.h.

◆ APIC_LINT1

#define APIC_LINT1   0x0360 /* LINT1 Local Vector Table (R/W) */

Definition at line 75 of file apic.h.

◆ APIC_NMI_VECTOR

#define APIC_NMI_VECTOR   0xFF

Definition at line 52 of file apic.h.

◆ APIC_PCLVTR

#define APIC_PCLVTR   0x0340 /* Performance Counter Local Vector Table (R/W) */

Definition at line 73 of file apic.h.

◆ APIC_PERF_VECTOR

#define APIC_PERF_VECTOR   0xFE

Definition at line 51 of file apic.h.

◆ APIC_PPR

#define APIC_PPR   0x00A0 /* Processor Priority Register (R) */

Definition at line 59 of file apic.h.

◆ APIC_PROFILE_VECTOR

#define APIC_PROFILE_VECTOR   0xFD

Definition at line 50 of file apic.h.

◆ APIC_RRR

#define APIC_RRR   0x00C0 /* Remote Read Register () */

Definition at line 61 of file apic.h.

◆ APIC_SEOI

#define APIC_SEOI   0x0420 /* Specific End Of Interrupt Register (W) */

Definition at line 82 of file apic.h.

◆ APIC_SIVR

#define APIC_SIVR   0x00F0 /* Spurious Interrupt Vector Register (0-3 R, 4-9 R/W) */

Definition at line 64 of file apic.h.

◆ APIC_SPURIOUS_VECTOR

#define APIC_SPURIOUS_VECTOR   0x1f

Definition at line 22 of file apic.h.

◆ APIC_SYNCH_VECTOR

#define APIC_SYNCH_VECTOR   0xD1

Definition at line 46 of file apic.h.

◆ APIC_TCCR

#define APIC_TCCR   0x0390 /* Current Count Register for Timer (R) */

Definition at line 78 of file apic.h.

◆ APIC_TDCR

#define APIC_TDCR   0x03E0 /* Timer Divide Configuration Register (R/W) */

Definition at line 79 of file apic.h.

◆ APIC_THRMLVTR

#define APIC_THRMLVTR   0x0330 /* Thermal Local Vector Table */

Definition at line 72 of file apic.h.

◆ APIC_TICR

#define APIC_TICR   0x0380 /* Initial Count Register for Timer (R/W) */

Definition at line 77 of file apic.h.

◆ APIC_TMR

#define APIC_TMR   0x0180 /* Trigger Mode Register 0-255 (R) */

Definition at line 66 of file apic.h.

◆ APIC_TMRLVTR

#define APIC_TMRLVTR   0x0320 /* Timer Local Vector Table (R/W) */

Definition at line 71 of file apic.h.

◆ APIC_TPR

#define APIC_TPR   0x0080 /* Task Priority Register (R/W) */

Definition at line 57 of file apic.h.

◆ APIC_VER

#define APIC_VER   0x0030 /* Local APIC Version Register (R) */

Definition at line 56 of file apic.h.

◆ ApicLogicalId

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

Definition at line 91 of file apic.h.

◆ DISPATCH_VECTOR

#define DISPATCH_VECTOR   0x41

Definition at line 43 of file apic.h.

◆ IMCR_ADDRESS_PORT

#define IMCR_ADDRESS_PORT   (PUCHAR)0x0022

Definition at line 35 of file apic.h.

◆ IMCR_DATA_PORT

#define IMCR_DATA_PORT   (PUCHAR)0x0023

Definition at line 36 of file apic.h.

◆ IMCR_PIC_DIRECT

#define IMCR_PIC_DIRECT   0x00

Definition at line 38 of file apic.h.

◆ IMCR_PIC_VIA_APIC

#define IMCR_PIC_VIA_APIC   0x01

Definition at line 39 of file apic.h.

◆ IMCR_SELECT

#define IMCR_SELECT   0x70

Definition at line 37 of file apic.h.

◆ IOAPIC_BASE

#define IOAPIC_BASE   0xFFFE1000

Definition at line 21 of file apic.h.

◆ IOAPIC_PHYS_BASE

#define IOAPIC_PHYS_BASE   0xFEC00000

Definition at line 89 of file apic.h.

◆ IrqlToSoftVector

#define IrqlToSoftVector (   Irql)    IrqlToTpr(Irql)

Definition at line 24 of file apic.h.

◆ IrqlToTpr

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

Definition at line 23 of file apic.h.

◆ LOCAL_APIC_BASE

#define LOCAL_APIC_BASE   0xFFFE0000

Definition at line 20 of file apic.h.

◆ MSR_APIC_BASE

#define MSR_APIC_BASE   0x0000001B

Definition at line 88 of file apic.h.

◆ POWERFAIL_VECTOR

#define POWERFAIL_VECTOR   0xEF

Definition at line 49 of file apic.h.

◆ TprToIrql

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

Definition at line 25 of file apic.h.

◆ ZERO_VECTOR

#define ZERO_VECTOR   0x00

Definition at line 41 of file apic.h.

Typedef Documentation

◆ APIC_BASE_ADRESS_REGISTER

◆ APIC_COMMAND_REGISTER

◆ APIC_EXTENDED_CONTROL_REGISTER

◆ APIC_SPURIOUS_INERRUPT_REGISTER

◆ APIC_VERSION_REGISTER

◆ IOAPIC_REDIRECTION_REGISTER

◆ LVT_REGISTER

typedef union _LVT_REGISTER LVT_REGISTER

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
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 94 of file apic.h.

95 {
96  APIC_MT_Fixed = 0,
98  APIC_MT_SMI = 2,
100  APIC_MT_NMI = 4,
101  APIC_MT_INIT = 5,
102  APIC_MT_Startup = 6,
103  APIC_MT_ExtInt = 7,
104 };

◆ anonymous enum

anonymous enum
Enumerator
APIC_TGM_Edge 
APIC_TGM_Level 

Definition at line 107 of file apic.h.

108 {
111 };

◆ anonymous enum

anonymous enum
Enumerator
APIC_DM_Physical 
APIC_DM_Logical 

Definition at line 114 of file apic.h.

115 {
118 };

◆ anonymous enum

anonymous enum
Enumerator
APIC_DSH_Destination 
APIC_DSH_Self 
APIC_DSH_AllIncludingSelf 
APIC_DSH_AllExclusingSelf 

Definition at line 121 of file apic.h.

◆ anonymous enum

anonymous enum
Enumerator
APIC_DF_Flat 
APIC_DF_Cluster 

Definition at line 130 of file apic.h.

131 {
132  APIC_DF_Flat = 0xFFFFFFFF,
133  APIC_DF_Cluster = 0x0FFFFFFF
134 };

◆ anonymous enum

anonymous enum
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 137 of file apic.h.

◆ anonymous enum

anonymous enum
Enumerator
IOAPIC_IOREGSEL 
IOAPIC_IOWIN 

Definition at line 244 of file apic.h.

245 {
246  IOAPIC_IOREGSEL = 0x00,
247  IOAPIC_IOWIN = 0x10
248 };

◆ anonymous enum

anonymous enum
Enumerator
IOAPIC_ID 
IOAPIC_VER 
IOAPIC_ARB 
IOAPIC_REDTBL 

Definition at line 251 of file apic.h.

252 {
253  IOAPIC_ID = 0x00,
254  IOAPIC_VER = 0x01,
255  IOAPIC_ARB = 0x02,
256  IOAPIC_REDTBL = 0x10
257 };

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
#define APIC_TDCR
Definition: apic.h:33
FORCEINLINE VOID ApicWrite(ULONG Offset, ULONG Value)
Definition: apic.h:292

◆ ApicRead()

FORCEINLINE ULONG ApicRead ( ULONG  Offset)

Definition at line 285 of file apic.h.

286 {
287  return *(volatile ULONG *)(APIC_BASE + Offset);
288 }
#define APIC_BASE
Definition: mboot.c:45
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
unsigned int ULONG
Definition: retypes.h:1

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

◆ ApicSpuriousService()

VOID __cdecl ApicSpuriousService ( VOID  )

Referenced by ApicInitializeLocalApic().

◆ ApicWrite()

FORCEINLINE VOID ApicWrite ( ULONG  Offset,
ULONG  Value 
)

Definition at line 292 of file apic.h.

293 {
294  *(volatile ULONG *)(APIC_BASE + Offset) = Value;
295 }
#define APIC_BASE
Definition: mboot.c:45
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
unsigned int ULONG
Definition: retypes.h:1

Referenced by ApicInitializeLocalApic(), ApicInitializeTimer(), ApicRequestInterrupt(), ApicSetIrql(), ApicSetTimerInterval(), HalBeginSystemInterrupt(), HalSetProfileInterval(), HalStartProfileInterrupt(), and HalStopProfileInterrupt().

◆ HalInitializeProfiling()

VOID NTAPI HalInitializeProfiling ( VOID  )

Definition at line 69 of file apictimer.c.

70 {
72  KeGetPcr()->HalReserved[HAL_PROFILING_MULTIPLIER] = 1; /* TODO: HACK */
73 }
#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)