xref: /reactos/hal/halx86/include/smp.h (revision 2c8d083f)
1 /*
2  * PROJECT:     ReactOS Kernel
3  * LICENSE:     GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE:     Header File for SMP support
5  * COPYRIGHT:   Copyright 2021 Justin Miller <justinmiller100@gmail.com>
6  */
7 
8 #pragma once
9 
10 /* This table is filled for each physical processor on system */
11 typedef struct _PROCESSOR_IDENTITY
12 {
13     UCHAR ProcessorId;
14     UCHAR LapicId;
15     BOOLEAN ProcessorStarted;
16     BOOLEAN BSPCheck;
17     PKPRCB ProcessorPrcb;
18 } PROCESSOR_IDENTITY, *PPROCESSOR_IDENTITY;
19 
20 /* This table is counter of the overall APIC constants acquired from madt */
21 #define HALP_APIC_INFO_TABLE_IOAPIC_NUMBER 256 // ACPI_MADT_IO_APIC.Id is a UINT8.
22 typedef struct _HALP_APIC_INFO_TABLE
23 {
24     ULONG ApicMode;
25     ULONG ProcessorCount; /* Count of all physical cores, This includes BSP */
26     ULONG IOAPICCount;
27     ULONG LocalApicPA;                // The 32-bit physical address at which each processor can access its local interrupt controller
28     ULONG IoApicVA[HALP_APIC_INFO_TABLE_IOAPIC_NUMBER];
29     ULONG IoApicPA[HALP_APIC_INFO_TABLE_IOAPIC_NUMBER];
30     ULONG IoApicIrqBase[HALP_APIC_INFO_TABLE_IOAPIC_NUMBER]; // Global system interrupt base
31 } HALP_APIC_INFO_TABLE, *PHALP_APIC_INFO_TABLE;
32 
33 /* HALP_APIC_INFO_TABLE.ApicMode values */
34 // TODO: What are the other modes/values?
35 #define HALP_APIC_MODE_LEGACY 0x00000010
36 
37 VOID
38 HalpParseApicTables(
39     _In_ PLOADER_PARAMETER_BLOCK LoaderBlock);
40 
41 VOID
42 HalpSetupProcessorsTable(
43     _In_ UINT32 NTProcessorNumber);
44 
45 VOID
46 HalpPrintApicTables(VOID);
47 
48 VOID
49 FASTCALL
50 HalpBroadcastClockIpi(
51     _In_ UCHAR Vector);
52 
53 /* APIC specific functions inside apic/apicsmp.c */
54 
55 VOID
56 ApicStartApplicationProcessor(
57     _In_ ULONG NTProcessorNumber,
58     _In_ PHYSICAL_ADDRESS StartupLoc);
59 
60 VOID
61 NTAPI
62 HalpRequestIpi(
63     _In_ KAFFINITY TargetProcessors);
64 
65 VOID
66 NTAPI
67 HalpBroadcastIpiSpecifyVector(
68     _In_ UCHAR Vector,
69     _In_ BOOLEAN IncludeSelf);
70 
71 VOID
72 NTAPI
73 HalRequestIpiSpecifyVector(
74     _In_ KAFFINITY TargetSet,
75     _In_ UCHAR Vector);
76 
77 #ifdef _M_AMD64
78 
79 NTHALAPI
80 VOID
81 NTAPI
82 HalpSendNMI(
83     _In_ KAFFINITY TargetSet);
84 
85 NTHALAPI
86 VOID
87 NTAPI
88 HalpSendSoftwareInterrupt(
89     _In_ KAFFINITY TargetSet,
90     _In_ KIRQL Irql);
91 
92 #endif // _M_AMD64
93