ReactOS 0.4.15-dev-7089-gea8a49d
apicsmp.c File Reference
#include <hal.h>
#include "apicp.h"
#include <smp.h>
#include <debug.h>
Include dependency graph for apicsmp.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

FORCEINLINE VOID ApicRequestGlobalInterrupt (_In_ UCHAR DestinationProcessor, _In_ UCHAR Vector, _In_ APIC_MT MessageType, _In_ APIC_TGM TriggerMode, _In_ APIC_DSH DestinationShortHand)
 
VOID NTAPI HalpRequestIpi (_In_ KAFFINITY TargetProcessors)
 
VOID ApicStartApplicationProcessor (_In_ ULONG NTProcessorNumber, _In_ PHYSICAL_ADDRESS StartupLoc)
 

Variables

PPROCESSOR_IDENTITY HalpProcessorIdentity
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file apicsmp.c.

Function Documentation

◆ ApicRequestGlobalInterrupt()

FORCEINLINE VOID ApicRequestGlobalInterrupt ( _In_ UCHAR  DestinationProcessor,
_In_ UCHAR  Vector,
_In_ APIC_MT  MessageType,
_In_ APIC_TGM  TriggerMode,
_In_ APIC_DSH  DestinationShortHand 
)
Parameters
Vector- Specifies the interrupt vector to be delivered.
MessageType- Specifies the message type sent to the CPU core interrupt handler. This can be one of the following values: APIC_MT_Fixed - Delivers an interrupt to the target local APIC specified in Destination field. APIC_MT_LowestPriority - Delivers an interrupt to the local APIC executing at the lowest priority of all local APICs. APIC_MT_SMI - Delivers an SMI interrupt to target local APIC(s). APIC_MT_RemoteRead - Delivers a read request to read an APIC register in the target local APIC specified in Destination field. APIC_MT_NMI - Delivers a non-maskable interrupt to the target local APIC specified in the Destination field. Vector is ignored. APIC_MT_INIT - Delivers an INIT request to the target local APIC(s) specified in the Destination field. TriggerMode must be APIC_TGM_Edge, Vector must be 0. APIC_MT_Startup - Delivers a start-up request (SIPI) to the target local APIC(s) specified in Destination field. Vector specifies the startup address. APIC_MT_ExtInt - Delivers an external interrupt to the target local APIC specified in Destination field.
TriggerMode- The trigger mode of the interrupt. Can be: APIC_TGM_Edge - The interrupt is edge triggered. APIC_TGM_Level - The interrupt is level triggered.
DestinationShortHand- Specifies where to send the interrupt. APIC_DSH_Destination APIC_DSH_Self APIC_DSH_AllIncludingSelf APIC_DSH_AllExclusingSelf
See also
"AMD64 Architecture Programmer's Manual Volume 2 System Programming" Chapter 16 "Advanced Programmable Interrupt Controller (APIC)" 16.5 "Interprocessor Interrupts (IPI)"

Definition at line 63 of file apicsmp.c.

69{
72
73 /* Disable interrupts so that we can change IRR without being interrupted */
75 _disable();
76
77 /* Wait for the APIC to be idle */
78 do
79 {
81 } while (Icr.DeliveryStatus);
82
83 /* Setup the command register */
84 Icr.LongLong = 0;
85 Icr.Vector = Vector;
86 Icr.MessageType = MessageType;
88 Icr.DeliveryStatus = 0;
89 Icr.Level = 0;
90 Icr.TriggerMode = TriggerMode;
91 Icr.RemoteReadStatus = 0;
92 Icr.DestinationShortHand = DestinationShortHand;
93 Icr.Destination = DestinationProcessor;
94
95 /* Write the low dword last to send the interrupt */
98
99 /* Finally, restore the original interrupt state */
101 {
102 _enable();
103 }
104}
@ APIC_DM_Physical
Definition: apicp.h:144
FORCEINLINE ULONG ApicRead(APIC_REGISTER Register)
Definition: apicp.h:315
FORCEINLINE VOID ApicWrite(APIC_REGISTER Register, ULONG Value)
Definition: apicp.h:322
@ APIC_ICR0
Definition: apicp.h:93
@ APIC_ICR1
Definition: apicp.h:94
void __cdecl _disable(void)
Definition: intrin_arm.h:365
void __cdecl _enable(void)
Definition: intrin_arm.h:373
__INTRIN_INLINE uintptr_t __readeflags(void)
Definition: intrin_x86.h:1674
#define EFLAGS_INTERRUPT_MASK
Definition: ketypes.h:187
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by ApicStartApplicationProcessor().

◆ ApicStartApplicationProcessor()

VOID ApicStartApplicationProcessor ( _In_ ULONG  NTProcessorNumber,
_In_ PHYSICAL_ADDRESS  StartupLoc 
)

Definition at line 118 of file apicsmp.c.

121{
122 ASSERT(StartupLoc.HighPart == 0);
123 ASSERT((StartupLoc.QuadPart & 0xFFF) == 0);
124 ASSERT((StartupLoc.QuadPart & 0xFFF00FFF) == 0);
125
126 /* Init IPI */
127 ApicRequestGlobalInterrupt(HalpProcessorIdentity[NTProcessorNumber].LapicId, 0,
129
130 /* De-Assert Init IPI */
131 ApicRequestGlobalInterrupt(HalpProcessorIdentity[NTProcessorNumber].LapicId, 0,
133
134 /* Stall execution for a bit to give APIC time: MPS Spec - B.4 */
136
137 /* Startup IPI */
138 ApicRequestGlobalInterrupt(HalpProcessorIdentity[NTProcessorNumber].LapicId, (StartupLoc.LowPart) >> 12,
140}
@ APIC_DSH_Destination
Definition: apicp.h:151
@ APIC_MT_INIT
Definition: apicp.h:129
@ APIC_MT_Startup
Definition: apicp.h:130
@ APIC_TGM_Level
Definition: apicp.h:138
@ APIC_TGM_Edge
Definition: apicp.h:137
FORCEINLINE VOID ApicRequestGlobalInterrupt(_In_ UCHAR DestinationProcessor, _In_ UCHAR Vector, _In_ APIC_MT MessageType, _In_ APIC_TGM TriggerMode, _In_ APIC_DSH DestinationShortHand)
Definition: apicsmp.c:63
PPROCESSOR_IDENTITY HalpProcessorIdentity
Definition: madt.c:21
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:81
#define ASSERT(a)
Definition: mode.c:44

Referenced by HalStartNextProcessor().

◆ HalpRequestIpi()

VOID NTAPI HalpRequestIpi ( _In_ KAFFINITY  TargetProcessors)

Definition at line 111 of file apicsmp.c.

112{
114 __debugbreak();
115}
#define UNIMPLEMENTED
Definition: debug.h:115
void __cdecl __debugbreak(void)
Definition: intrin_ppc.h:698

Referenced by HalRequestIpi().

Variable Documentation

◆ HalpProcessorIdentity

PPROCESSOR_IDENTITY HalpProcessorIdentity
extern

Definition at line 21 of file madt.c.

Referenced by ApicStartApplicationProcessor().