https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0fc21e5a9b9ea59ef5a00bea042898bec6b05dd6

commit 0fc21e5a9b9ea59ef5a00bea042898bec6b05dd6
Author:     Justin Miller <[email protected]>
AuthorDate: Thu Jun 24 09:57:19 2021 -0700
Commit:     Stanislav Motylkov <[email protected]>
CommitDate: Thu Apr 7 22:54:13 2022 +0300

    [HALX86] Add function prototypes needed for parsing ACPI MADT table
    
    - Use ACPICA headers to gather the information.
    - Add PROCESSOR_IDENTITY structure that will be used by all APIC HALs.
---
 hal/halx86/CMakeLists.txt |  3 ++-
 hal/halx86/acpi.cmake     |  9 +++++++++
 hal/halx86/acpi/madt.c    | 30 ++++++++++++++++++++++++++++++
 hal/halx86/apic/halinit.c | 11 +++++++++++
 hal/halx86/include/smp.h  | 27 +++++++++++++++++++++++++++
 hal/halx86/legacy.cmake   |  3 ++-
 hal/halx86/smp.cmake      |  3 ++-
 hal/halx86/smp/mps/mps.c  | 22 ++++++++++++++++++++++
 hal/halx86/smp/smp.c      | 24 ++++++++++++++++++++++++
 9 files changed, 129 insertions(+), 3 deletions(-)

diff --git a/hal/halx86/CMakeLists.txt b/hal/halx86/CMakeLists.txt
index aaf526c11ea..50e1342f47f 100644
--- a/hal/halx86/CMakeLists.txt
+++ b/hal/halx86/CMakeLists.txt
@@ -66,7 +66,8 @@ if(ARCH STREQUAL "i386")
     add_hal(halxbox SOURCES xbox/halxbox.rc COMPONENTS xbox up)
     add_hal(halpc98 SOURCES pc98/halpc98.rc COMPONENTS pc98 up)
 
-    #add_hal(halmacpi SOURCES acpi/halacpi.rc COMPONENTS generic acpi smp pic)
+    #add_hal(halmacpi SOURCES smp/halmacpi.rc COMPONENTS generic acpi smp apic)
+    #add_hal(halmp SOURCES mp/halmp.rc COMPONENTS generic legacy smp apic)
 
 elseif(ARCH STREQUAL "amd64")
 
diff --git a/hal/halx86/acpi.cmake b/hal/halx86/acpi.cmake
index acc856a0b72..e35cab24e4a 100644
--- a/hal/halx86/acpi.cmake
+++ b/hal/halx86/acpi.cmake
@@ -1,11 +1,20 @@
 
+include_directories(include 
${REACTOS_SOURCE_DIR}/drivers/bus/acpi/acpica/include)
+
 list(APPEND HAL_ACPI_SOURCE
     acpi/halacpi.c
     acpi/halpnpdd.c
     acpi/busemul.c
+    acpi/madt.c
     legacy/bus/pcibus.c)
 
+# Needed to compile while using ACPICA
+if(ARCH STREQUAL "amd64")
+    add_definitions(-DWIN64)
+endif()
+
 add_library(lib_hal_acpi OBJECT ${HAL_ACPI_SOURCE})
+add_pch(lib_hal_acpi 
${REACTOS_SOURCE_DIR}/drivers/bus/acpi/acpica/include/acpi.h ${HAL_ACPI_SOURCE})
 add_dependencies(lib_hal_acpi bugcodes xdk)
 #add_pch(lib_hal_acpi include/hal.h)
 
diff --git a/hal/halx86/acpi/madt.c b/hal/halx86/acpi/madt.c
new file mode 100644
index 00000000000..9d4cdd070f8
--- /dev/null
+++ b/hal/halx86/acpi/madt.c
@@ -0,0 +1,30 @@
+/*
+ * PROJECT:     ReactOS Kernel
+ * LICENSE:     GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
+ * PURPOSE:     Source File for MADT Table parsing
+ * COPYRIGHT:   Copyright 2021 Justin Miller <[email protected]>
+ */
+
+/* INCLUDES 
*******************************************************************/
+
+#include <hal.h>
+#include <acpi.h>
+/* ACPI_BIOS_ERROR defined in acoutput.h and bugcodes.h */
+#undef ACPI_BIOS_ERROR
+#include <smp.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS 
********************************************************************/
+
+PROCESSOR_IDENTITY HalpStaticProcessorIdentity[MAXIMUM_PROCESSORS] = {{0}};
+PPROCESSOR_IDENTITY HalpProcessorIdentity = NULL;
+
+/* FUNCTIONS 
******************************************************************/
+
+VOID
+HalpParseApicTables(
+    _In_ PLOADER_PARAMETER_BLOCK LoaderBlock)
+{
+    UNIMPLEMENTED;
+}
diff --git a/hal/halx86/apic/halinit.c b/hal/halx86/apic/halinit.c
index 314317576b3..87c6a37854d 100644
--- a/hal/halx86/apic/halinit.c
+++ b/hal/halx86/apic/halinit.c
@@ -9,6 +9,7 @@
 
 #include <hal.h>
 #include "apicp.h"
+#include <smp.h>
 #define NDEBUG
 #include <debug.h>
 
@@ -24,6 +25,16 @@ HalpInitProcessor(
     IN ULONG ProcessorNumber,
     IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 {
+    if (ProcessorNumber == 0)
+    {
+        /* APIC tables should always be parsed once before touching APIC */
+        HalpParseApicTables(LoaderBlock);
+    }
+
+#ifdef CONFIG_SMP
+    HalpSetupProcessorsTable(ProcessorNumber);
+#endif
+
     /* Initialize the local APIC for this cpu */
     ApicInitializeLocalApic(ProcessorNumber);
 
diff --git a/hal/halx86/include/smp.h b/hal/halx86/include/smp.h
new file mode 100644
index 00000000000..5eaccdbc285
--- /dev/null
+++ b/hal/halx86/include/smp.h
@@ -0,0 +1,27 @@
+/*
+ * PROJECT:     ReactOS Kernel
+ * LICENSE:     GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
+ * PURPOSE:     Header File for SMP support
+ * COPYRIGHT:   Copyright 2021 Justin Miller <[email protected]>
+ */
+
+#pragma once
+
+/* This table is filled for each physical processor on system */
+typedef struct _PROCESSOR_IDENTITY
+{
+    UCHAR ProcessorId;
+    UCHAR LapicId;
+    BOOLEAN ProcessorStarted;
+    BOOLEAN BSPCheck;
+    PKPRCB ProcessorPrcb;
+
+} PROCESSOR_IDENTITY, *PPROCESSOR_IDENTITY;
+
+VOID
+HalpParseApicTables(
+    _In_ PLOADER_PARAMETER_BLOCK LoaderBlock);
+
+VOID
+HalpSetupProcessorsTable(
+    _In_ UINT32 NTProcessorNumber);
diff --git a/hal/halx86/legacy.cmake b/hal/halx86/legacy.cmake
index 2f487748524..a289e56d459 100644
--- a/hal/halx86/legacy.cmake
+++ b/hal/halx86/legacy.cmake
@@ -9,7 +9,8 @@ list(APPEND HAL_LEGACY_SOURCE
     legacy/bus/sysbus.c
     legacy/bussupp.c
     legacy/halpnpdd.c
-    legacy/halpcat.c)
+    legacy/halpcat.c
+    smp/mps/mps.c)
 
 add_library(lib_hal_legacy OBJECT ${HAL_LEGACY_SOURCE})
 add_dependencies(lib_hal_legacy bugcodes xdk)
diff --git a/hal/halx86/smp.cmake b/hal/halx86/smp.cmake
index f05db28f3de..0f302133835 100644
--- a/hal/halx86/smp.cmake
+++ b/hal/halx86/smp.cmake
@@ -1,7 +1,8 @@
 
 list(APPEND HAL_SMP_SOURCE
     generic/buildtype.c
-    generic/spinlock.c)
+    generic/spinlock.c
+    smp/smp.c)
 
 add_library(lib_hal_smp OBJECT ${HAL_SMP_SOURCE})
 add_dependencies(lib_hal_smp bugcodes xdk)
diff --git a/hal/halx86/smp/mps/mps.c b/hal/halx86/smp/mps/mps.c
new file mode 100644
index 00000000000..a03c80c4db8
--- /dev/null
+++ b/hal/halx86/smp/mps/mps.c
@@ -0,0 +1,22 @@
+/*
+ * PROJECT:     ReactOS Kernel
+ * LICENSE:     GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
+ * PURPOSE:     Source File for MPS specific functions
+ * COPYRIGHT:   Copyright 2021 Justin Miller <[email protected]>
+ */
+
+/* INCLUDES 
*******************************************************************/
+
+#include <hal.h>
+#include <smp.h>
+#define NDEBUG
+#include <debug.h>
+
+/* FUNCTIONS 
******************************************************************/
+
+VOID
+HalpParseApicTables(
+    _In_ PLOADER_PARAMETER_BLOCK LoaderBlock)
+{
+    UNIMPLEMENTED;
+}
diff --git a/hal/halx86/smp/smp.c b/hal/halx86/smp/smp.c
new file mode 100644
index 00000000000..8950aa83cfe
--- /dev/null
+++ b/hal/halx86/smp/smp.c
@@ -0,0 +1,24 @@
+/*
+ * PROJECT:     ReactOS Kernel
+ * LICENSE:     GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
+ * PURPOSE:     Core source file for SMP management
+ * COPYRIGHT:   Copyright 2021 Justin Miller <[email protected]>
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <hal.h>
+#include <smp.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS *******************************************************************/
+
+/* FUNCTIONS *****************************************************************/
+
+VOID
+HalpSetupProcessorsTable(
+    _In_ UINT32 NTProcessorNumber)
+{
+    UNIMPLEMENTED;
+}

Reply via email to