https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5f477e0e3b1ad8e00cda3…
commit 5f477e0e3b1ad8e00cda3e3a97ce0d112a1bab01
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Sep 5 03:58:26 2021 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Aug 6 17:28:51 2023 +0200
[SDK:ASM][NDK] Improve and synchronize the definition of the SYNCH_LEVEL symbol
(#3943)
In particular, for a given platform (x86, AMD64...) its definition
depends for uniprocessor vs. multiprocessor NT kernel/HAL (controlled
by the CONFIG_SMP define).
Regarding the ASM-generated headers (from asm/ksx.template.h), since
they are generated once for a given platform, and since UP/MP NT builds
are generated at the same time, these headers need to contain both
SYNCH_LEVEL definitions controlled by CONFIG_SMP, instead of a fixed
value. Therefore we need to employ the geninc RAW(...) construct.
[NDK:X86] Add missing x86 CLOCK1_LEVEL and POWER_LEVEL definitions.
---
sdk/include/asm/ksx.template.h | 11 ++++++++---
sdk/include/ndk/amd64/asm.h | 27 ++++++++++++++++++---------
sdk/include/ndk/amd64/ketypes.h | 12 ++++++++----
sdk/include/ndk/arm/ketypes.h | 8 +++++---
sdk/include/ndk/i386/asm.h | 6 ++++--
5 files changed, 43 insertions(+), 21 deletions(-)
diff --git a/sdk/include/asm/ksx.template.h b/sdk/include/asm/ksx.template.h
index 35f9837242f..019232bb439 100644
--- a/sdk/include/asm/ksx.template.h
+++ b/sdk/include/asm/ksx.template.h
@@ -126,10 +126,15 @@ CONSTANT(IPI_LEVEL),
CONSTANT(POWER_LEVEL),
CONSTANT(PROFILE_LEVEL),
CONSTANT(HIGH_LEVEL),
-RAW("#ifdef NT_UP"),
-{TYPE_CONSTANT, "SYNCH_LEVEL", DISPATCH_LEVEL},
+
+RAW("#ifndef CONFIG_SMP"),
+CONSTANTX(SYNCH_LEVEL, DISPATCH_LEVEL),
RAW("#else"),
-{TYPE_CONSTANT, "SYNCH_LEVEL", (IPI_LEVEL - 2)},
+#if defined(_M_IX86) && (NTDDI_VERSION < NTDDI_WS03)
+CONSTANTX(SYNCH_LEVEL, (IPI_LEVEL - 1)),
+#else
+CONSTANTX(SYNCH_LEVEL, (IPI_LEVEL - 2)),
+#endif
RAW("#endif"),
#if (NTDDI_VERSION >= NTDDI_WIN8)
diff --git a/sdk/include/ndk/amd64/asm.h b/sdk/include/ndk/amd64/asm.h
index 69f3ad2fb17..9adcc3842d1 100644
--- a/sdk/include/ndk/amd64/asm.h
+++ b/sdk/include/ndk/amd64/asm.h
@@ -380,15 +380,24 @@ Author:
//
// IRQL Levels
//
-#define PASSIVE_LEVEL 0
-#define LOW_LEVEL 0
-#define APC_LEVEL 1
-#define DISPATCH_LEVEL 2
-#define CLOCK_LEVEL 13
-#define IPI_LEVEL 14
-#define POWER_LEVEL 14
-#define PROFILE_LEVEL 15
-#define HIGH_LEVEL 15
+#define PASSIVE_LEVEL 0
+#define LOW_LEVEL 0
+#define APC_LEVEL 1
+#define DISPATCH_LEVEL 2
+#define CLOCK_LEVEL 13
+#define IPI_LEVEL 14
+#define POWER_LEVEL 14
+#define PROFILE_LEVEL 15
+#define HIGH_LEVEL 15
+
+//
+// Synchronization-level IRQL
+//
+#ifndef CONFIG_SMP
+#define SYNCH_LEVEL DISPATCH_LEVEL
+#else
+#define SYNCH_LEVEL (IPI_LEVEL - 2)
+#endif
//
// Quantum Decrements
diff --git a/sdk/include/ndk/amd64/ketypes.h b/sdk/include/ndk/amd64/ketypes.h
index 9bdb9e43bc2..e09c0a884ce 100644
--- a/sdk/include/ndk/amd64/ketypes.h
+++ b/sdk/include/ndk/amd64/ketypes.h
@@ -277,13 +277,17 @@ typedef enum
//
#define KSEG0_BASE 0xfffff80000000000ULL
+#define NMI_STACK_SIZE 0x2000
+#define ISR_STACK_SIZE 0x6000
+
//
// Synchronization-level IRQL
//
-#define SYNCH_LEVEL 12
-
-#define NMI_STACK_SIZE 0x2000
-#define ISR_STACK_SIZE 0x6000
+#ifndef CONFIG_SMP
+#define SYNCH_LEVEL DISPATCH_LEVEL
+#else
+#define SYNCH_LEVEL (IPI_LEVEL - 2)
+#endif
//
// Number of pool lookaside lists per pool in the PRCB
diff --git a/sdk/include/ndk/arm/ketypes.h b/sdk/include/ndk/arm/ketypes.h
index c047436d769..5bcac60f7d7 100644
--- a/sdk/include/ndk/arm/ketypes.h
+++ b/sdk/include/ndk/arm/ketypes.h
@@ -29,9 +29,6 @@ extern "C" {
//
-#define SYNCH_LEVEL DISPATCH_LEVEL
-
-
//
// CPU Vendors
//
@@ -303,6 +300,11 @@ typedef enum
//
#define KSEG0_BASE 0x80000000
+//
+// Synchronization-level IRQL
+//
+#define SYNCH_LEVEL DISPATCH_LEVEL
+
//
// Number of pool lookaside lists per pool in the PRCB
//
diff --git a/sdk/include/ndk/i386/asm.h b/sdk/include/ndk/i386/asm.h
index 428c39734a4..57fad2bdcb3 100644
--- a/sdk/include/ndk/i386/asm.h
+++ b/sdk/include/ndk/i386/asm.h
@@ -577,8 +577,10 @@ Author:
#define APC_LEVEL 0x1
#define DISPATCH_LEVEL 0x2
#define PROFILE_LEVEL 0x1B
+#define CLOCK1_LEVEL 0x1C
#define CLOCK2_LEVEL 0x1C
#define IPI_LEVEL 0x1D
+#define POWER_LEVEL 0x1E
#define HIGH_LEVEL 0x1F
//
@@ -588,9 +590,9 @@ Author:
#define SYNCH_LEVEL DISPATCH_LEVEL
#else
#if (NTDDI_VERSION < NTDDI_WS03)
-#define SYNCH_LEVEL (IPI_LEVEL - 0x1)
+#define SYNCH_LEVEL (IPI_LEVEL - 1)
#else
-#define SYNCH_LEVEL (IPI_LEVEL - 0x2)
+#define SYNCH_LEVEL (IPI_LEVEL - 2)
#endif
#endif