[ros-diffs] [reactos] 01/01: [SHELL32] Remove horizontal scrollbar in File Types property page (#4412)

2022-04-07 Thread Jose Carlos Jesus
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7a83e0a145a0ef3edf635414fb916bfbc74afe1b

commit 7a83e0a145a0ef3edf635414fb916bfbc74afe1b
Author: Jose Carlos Jesus 
AuthorDate: Thu Apr 7 14:10:50 2022 +0100
Commit: GitHub 
CommitDate: Thu Apr 7 16:10:50 2022 +0300

[SHELL32] Remove horizontal scrollbar in File Types property page (#4412)

Reviewed-by: Hermès Bélusca-Maïto 
---
 dll/win32/shell32/dialogs/filetypes.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/dll/win32/shell32/dialogs/filetypes.cpp 
b/dll/win32/shell32/dialogs/filetypes.cpp
index c1e08e02198..ba2a5c10a42 100644
--- a/dll/win32/shell32/dialogs/filetypes.cpp
+++ b/dll/win32/shell32/dialogs/filetypes.cpp
@@ -1482,7 +1482,7 @@ FileTypesDlg_InitListView(HWND hwndDlg, HWND hListView)
 LVCOLUMNW col;
 WCHAR szName[50];
 DWORD dwStyle;
-INT columnSize = 140;
+INT columnSize;
 
 if (!LoadStringW(shell32_hInstance, IDS_COLUMN_EXTENSION, szName, 
_countof(szName)))
 {
@@ -1495,7 +1495,7 @@ FileTypesDlg_InitListView(HWND hwndDlg, HWND hListView)
 
 GetClientRect(hListView, &clientRect);
 ZeroMemory(&col, sizeof(LV_COLUMN));
-columnSize  = 120;
+columnSize  = (clientRect.right - clientRect.left) / 4;
 col.iSubItem= 0;
 col.mask= LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_FMT;
 col.fmt = LVCFMT_FIXED_WIDTH;
@@ -1512,7 +1512,7 @@ FileTypesDlg_InitListView(HWND hwndDlg, HWND hListView)
 }
 
 col.iSubItem= 1;
-col.cx  = clientRect.right - clientRect.left - columnSize;
+col.cx  = clientRect.right - clientRect.left - columnSize - 
GetSystemMetrics(SM_CYVSCROLL);
 col.cchTextMax  = wcslen(szName);
 col.pszText = szName;
 SendMessageW(hListView, LVM_INSERTCOLUMNW, 1, (LPARAM)&col);



[ros-diffs] [reactos] 01/01: [IMM32] Add ctf.c for Cicero (#4430)

2022-04-07 Thread Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4342b84c9a310006bf521c74a4e65f6020083cbd

commit 4342b84c9a310006bf521c74a4e65f6020083cbd
Author: Katayama Hirofumi MZ 
AuthorDate: Thu Apr 7 22:55:33 2022 +0900
Commit: GitHub 
CommitDate: Thu Apr 7 22:55:33 2022 +0900

[IMM32] Add ctf.c for Cicero (#4430)

Preparing of Cicero (modern input method) support.

- Add ctf.c and add some CTF functions.
- Modify the IMM table.
- Modify imm32.spec.
- Rename: s/Imm32FreeImeStates/Imm32DestroyImeModeSaver/.
- Improve Imm32DestroyInputContext.

CORE-11700
---
 dll/win32/imm32/CMakeLists.txt |  1 +
 dll/win32/imm32/ctf.c  | 90 ++
 dll/win32/imm32/imm.c  | 62 ---
 dll/win32/imm32/imm32.spec |  8 +--
 dll/win32/imm32/utils.c|  8 ---
 sdk/include/reactos/imm32_undoc.h  |  1 +
 win32ss/user/user32/include/immtable.h |  2 +-
 7 files changed, 131 insertions(+), 41 deletions(-)

diff --git a/dll/win32/imm32/CMakeLists.txt b/dll/win32/imm32/CMakeLists.txt
index 5e67f36f4f5..a0c518040aa 100644
--- a/dll/win32/imm32/CMakeLists.txt
+++ b/dll/win32/imm32/CMakeLists.txt
@@ -10,6 +10,7 @@ spec2def(imm32.dll imm32.spec ADD_IMPORTLIB)
 list(APPEND SOURCE
 candidate.c
 compstr.c
+ctf.c
 guideline.c
 ime.c
 imm.c
diff --git a/dll/win32/imm32/ctf.c b/dll/win32/imm32/ctf.c
new file mode 100644
index 000..e7f9cc77cad
--- /dev/null
+++ b/dll/win32/imm32/ctf.c
@@ -0,0 +1,90 @@
+/*
+ * PROJECT: ReactOS IMM32
+ * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
+ * PURPOSE: Implementing IMM32 Cicero (modern input method)
+ * COPYRIGHT:   Copyright 2022 Katayama Hirofumi MZ 

+ */
+
+#include "precomp.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(imm);
+
+// Win: LoadCtfIme
+HMODULE APIENTRY Imm32LoadCtfIme(VOID)
+{
+FIXME("()\n");
+return NULL;
+}
+
+// Win: Internal_CtfImeDestroyInputContext
+HRESULT APIENTRY Imm32CtfImeDestroyInputContext(HIMC hIMC)
+{
+if (!Imm32LoadCtfIme())
+return E_FAIL;
+#if 1
+FIXME("(%p)\n", hIMC);
+return E_NOTIMPL;
+#else
+return g_pfnCtfImeDestroyInputContext(hIMC);
+#endif
+}
+
+// Win: CtfImmTIMDestroyInputContext
+HRESULT APIENTRY CtfImmTIMDestroyInputContext(HIMC hIMC)
+{
+if (!Imm32IsCiceroMode() || (GetWin32ClientInfo()->dwCompatFlags2 & 2))
+return E_NOINTERFACE;
+
+return Imm32CtfImeDestroyInputContext(hIMC);
+}
+
+/***
+ * CtfImmIsCiceroEnabled (IMM32.@)
+ */
+BOOL WINAPI CtfImmIsCiceroEnabled(VOID)
+{
+return Imm32IsCiceroMode();
+}
+
+/***
+ * CtfImmIsTextFrameServiceDisabled(IMM32.@)
+ */
+BOOL WINAPI CtfImmIsTextFrameServiceDisabled(VOID)
+{
+return !!(GetWin32ClientInfo()->CI_flags & CI_TFSDISABLED);
+}
+
+/***
+ * CtfImmTIMActivate(IMM32.@)
+ */
+HRESULT WINAPI CtfImmTIMActivate(HKL hKL)
+{
+FIXME("(%p)\n", hKL);
+return E_NOTIMPL;
+}
+
+/***
+ * CtfImmRestoreToolbarWnd(IMM32.@)
+ */
+VOID WINAPI CtfImmRestoreToolbarWnd(DWORD dwStatus)
+{
+FIXME("(0x%lx)\n", dwStatus);
+}
+
+/***
+ * CtfImmHideToolbarWnd(IMM32.@)
+ */
+DWORD WINAPI CtfImmHideToolbarWnd(VOID)
+{
+FIXME("()\n");
+return 0;
+}
+
+/***
+ * CtfImmDispatchDefImeMessage(IMM32.@)
+ */
+LRESULT WINAPI CtfImmDispatchDefImeMessage(HWND hWnd, UINT uMsg, WPARAM 
wParam, LPARAM lParam)
+{
+FIXME("(%p, %u, %p, %p)\n", hWnd, uMsg, wParam, lParam);
+return 0;
+}
diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c
index e3a71f8ba8d..4b6b72433f3 100644
--- a/dll/win32/imm32/imm.c
+++ b/dll/win32/imm32/imm.c
@@ -611,23 +611,26 @@ HIMC WINAPI ImmCreateContext(void)
 return hIMC;
 }
 
-static VOID APIENTRY Imm32FreeImeStates(LPINPUTCONTEXTDX pIC)
+// Win: DestroyImeModeSaver
+static VOID APIENTRY Imm32DestroyImeModeSaver(LPINPUTCONTEXTDX pIC)
 {
-PIME_STATE pState, pStateNext;
-PIME_SUBSTATE pSubState, pSubStateNext;
+PIME_STATE pState, pNext;
+PIME_SUBSTATE pSubState, pSubNext;
 
-pState = pIC->pState;
-pIC->pState = NULL;
-for (; pState; pState = pStateNext)
+for (pState = pIC->pState; pState; pState = pNext)
 {
-pStateNext = pState->pNext;
-for (pSubState = pState->pSubState; pSubState; pSubState = 
pSubStateNext)
+pNext = pState->pNext;
+
+for (pSubState = pState->pSubState; pSubState; pSubState = pSubNext)
 {
-pSubStateNext = pSubState->pNext;
+pSubNext 

[ros-diffs] [reactos] 01/02: [XDK] Start define of xdk ke.h for arm64

2022-04-07 Thread Justin Miller
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3cee1f718b05b8e5a95728ed4336fe851ab62dc2

commit 3cee1f718b05b8e5a95728ed4336fe851ab62dc2
Author: Justin Miller 
AuthorDate: Mon Dec 13 05:43:56 2021 -0800
Commit: Stanislav Motylkov 
CommitDate: Thu Apr 7 19:50:42 2022 +0300

[XDK] Start define of xdk ke.h for arm64

CORE-17518
---
 sdk/include/xdk/arm64/ke.h   | 112 +++
 sdk/include/xdk/kefuncs.h|   2 +
 sdk/include/xdk/ntddk.template.h |   2 +
 3 files changed, 116 insertions(+)

diff --git a/sdk/include/xdk/arm64/ke.h b/sdk/include/xdk/arm64/ke.h
new file mode 100644
index 000..6fca07e5e56
--- /dev/null
+++ b/sdk/include/xdk/arm64/ke.h
@@ -0,0 +1,112 @@
+$if (_WDMDDK_)
+/** Kernel definitions for ARM64 **/
+
+/* Interrupt request 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 DRS_LEVEL   14
+#define POWER_LEVEL 14
+#define PROFILE_LEVEL   15
+#define HIGH_LEVEL  15
+
+NTSYSAPI
+PKTHREAD
+NTAPI
+KeGetCurrentThread(VOID);
+
+#define DbgRaiseAssertionFailure() __break(0xf001)
+
+$endif (_WDMDDK_)
+$if (_NTDDK_)
+
+#define ARM64_MAX_BREAKPOINTS 8
+#define ARM64_MAX_WATCHPOINTS 2
+
+typedef union NEON128 {
+struct {
+ULONGLONG Low;
+LONGLONG High;
+} DUMMYSTRUCTNAME;
+double D[2];
+float  S[4];
+USHORT H[8];
+UCHAR  B[16];
+} NEON128, *PNEON128;
+typedef NEON128 NEON128, *PNEON128;
+
+typedef struct _CONTEXT {
+
+//
+// Control flags.
+//
+
+ULONG ContextFlags;
+
+//
+// Integer registers
+//
+
+ULONG Cpsr;
+union {
+struct {
+ULONG64 X0;
+ULONG64 X1;
+ULONG64 X2;
+ULONG64 X3;
+ULONG64 X4;
+ULONG64 X5;
+ULONG64 X6;
+ULONG64 X7;
+ULONG64 X8;
+ULONG64 X9;
+ULONG64 X10;
+ULONG64 X11;
+ULONG64 X12;
+ULONG64 X13;
+ULONG64 X14;
+ULONG64 X15;
+ULONG64 X16;
+ULONG64 X17;
+ULONG64 X18;
+ULONG64 X19;
+ULONG64 X20;
+ULONG64 X21;
+ULONG64 X22;
+ULONG64 X23;
+ULONG64 X24;
+ULONG64 X25;
+ULONG64 X26;
+ULONG64 X27;
+ULONG64 X28;
+   ULONG64 Fp;
+ULONG64 Lr;
+} DUMMYSTRUCTNAME;
+ULONG64 X[31];
+} DUMMYUNIONNAME;
+
+ULONG64 Sp;
+ULONG64 Pc;
+
+//
+// Floating Point/NEON Registers
+//
+
+NEON128 V[32];
+ULONG Fpcr;
+ULONG Fpsr;
+
+//
+// Debug registers
+//
+
+ULONG Bcr[ARM64_MAX_BREAKPOINTS];
+ULONG64 Bvr[ARM64_MAX_BREAKPOINTS];
+ULONG Wcr[ARM64_MAX_WATCHPOINTS];
+ULONG64 Wvr[ARM64_MAX_WATCHPOINTS];
+
+} CONTEXT, *PCONTEXT;
+$endif
diff --git a/sdk/include/xdk/kefuncs.h b/sdk/include/xdk/kefuncs.h
index bb8c662b73a..b1f02f5a9a1 100644
--- a/sdk/include/xdk/kefuncs.h
+++ b/sdk/include/xdk/kefuncs.h
@@ -14,6 +14,8 @@ $include(ppc/ke.h)
 $include(mips/ke.h)
 #elif defined(_M_ARM)
 $include(arm/ke.h)
+#elif defined(_M_ARM64)
+$include(arm64/ke.h)
 #else
 #error Unknown Architecture
 #endif
diff --git a/sdk/include/xdk/ntddk.template.h b/sdk/include/xdk/ntddk.template.h
index b942818ed81..35eb73c4aaf 100644
--- a/sdk/include/xdk/ntddk.template.h
+++ b/sdk/include/xdk/ntddk.template.h
@@ -118,6 +118,8 @@ $include(mips/ke.h)
 #elif defined(_M_ARM)
 $include(arm/ke.h)
 $include(arm/mm.h)
+#elif defined(_M_ARM64)
+$include(arm64/ke.h)
 #else
 #error Unknown Architecture
 #endif



[ros-diffs] [reactos] 02/02: [SDK] Fix some arm64 stuff that was discovered during testing

2022-04-07 Thread Justin Miller
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2204695f0a87741b9b6224625a4707e59b9c9995

commit 2204695f0a87741b9b6224625a4707e59b9c9995
Author: Justin Miller 
AuthorDate: Mon Dec 13 05:16:45 2021 -0800
Commit: Stanislav Motylkov 
CommitDate: Thu Apr 7 19:50:43 2022 +0300

[SDK] Fix some arm64 stuff that was discovered during testing

Addendum to 6dfc13e4. CORE-17518
---
 CMakeLists.txt|  2 ++
 sdk/include/crt/crtdefs.h |  2 +-
 sdk/include/crt/vadefs.h  |  6 ++--
 sdk/include/ndk/asm.h |  2 +-
 sdk/include/ndk/rtltypes.h|  2 ++
 sdk/include/xdk/ketypes.h |  2 +-
 sdk/include/xdk/ntbasedef.h   |  2 +-
 sdk/include/xdk/winnt_old.h   | 70 +++
 sdk/lib/runtmchk/rtcapi.c |  3 +-
 sdk/tools/rsym/CMakeLists.txt |  2 ++
 sdk/tools/rsym/rsym64.h   |  1 +
 11 files changed, 53 insertions(+), 41 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7dfcb64a841..2168dcb2422 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -280,6 +280,8 @@ Enable this if the module uses typeid or dynamic_cast. You 
will probably need to
 add_compile_definitions(USE_COMPILER_EXCEPTIONS)
 elseif(ARCH STREQUAL "arm")
 add_compile_definitions(USE_COMPILER_EXCEPTIONS)
+elseif(ARCH STREQUAL "arm64")
+add_compile_definitions(USE_COMPILER_EXCEPTIONS)
 endif()
 
 # Activate support for assembly source files
diff --git a/sdk/include/crt/crtdefs.h b/sdk/include/crt/crtdefs.h
index 582ae24edb2..bf01188fe9f 100644
--- a/sdk/include/crt/crtdefs.h
+++ b/sdk/include/crt/crtdefs.h
@@ -138,7 +138,7 @@
 #endif
 
 #ifndef UNALIGNED
-#if defined(__ia64__) || defined(__x86_64) || defined(__arm__)
+#if defined(__ia64__) || defined(__x86_64) || defined(__arm__) || 
defined(__arm64__)
 #define UNALIGNED __unaligned
 #else
 #define UNALIGNED
diff --git a/sdk/include/crt/vadefs.h b/sdk/include/crt/vadefs.h
index 17ab6f61b59..bee42c465c0 100644
--- a/sdk/include/crt/vadefs.h
+++ b/sdk/include/crt/vadefs.h
@@ -72,12 +72,12 @@ extern "C" {
 #define __va_copy(d,s) ((void)((d) = (s)))
 #elif defined(_M_ARM64)
 extern void __cdecl __va_start(va_list*, ...);
-#define __crt_va_start(ap,v) ((void)(__va_start(&ap, _ADDRESSOF(v), 
_SLOTSIZEOF(v), __alignof(v), _ADDRESSOF(v
-#define __crt_va_arg(ap, t)\
+#define _crt_va_start(ap,v) ((void)(__va_start(&ap, _ADDRESSOF(v), 
_SLOTSIZEOF(v), __alignof(v), _ADDRESSOF(v
+#define _crt_va_arg(ap, t)\
 ((sizeof(t) > (2 * sizeof(__int64)))   \
 ? **(t**)((ap += sizeof(__int64)) - sizeof(__int64))   \
 : *(t*)((ap += _SLOTSIZEOF(t) + _APALIGN(t,ap)) - _SLOTSIZEOF(t)))
-#define __crt_va_end(ap)   ((void)(ap = (va_list)0))
+#define _crt_va_end(ap)   ((void)(ap = (va_list)0))
 #define __va_copy(d,s) ((void)((d) = (s)))
 #else //if defined(_M_IA64) || defined(_M_CEE)
 #error Please implement me
diff --git a/sdk/include/ndk/asm.h b/sdk/include/ndk/asm.h
index feb0ea4441d..ce2ada8cd1f 100644
--- a/sdk/include/ndk/asm.h
+++ b/sdk/include/ndk/asm.h
@@ -20,7 +20,7 @@ Author:
 #include 
 #elif defined(_M_AMD64)
 #include 
-#elif defined(_M_ARM) || defined(_M_PPC)
+#elif defined(_M_ARM) || defined(_M_PPC) || defined(_M_ARM64)
 //
 // ARM and PPC ports don't use asm.h
 //
diff --git a/sdk/include/ndk/rtltypes.h b/sdk/include/ndk/rtltypes.h
index 0799bcce4cb..62bca65bee1 100644
--- a/sdk/include/ndk/rtltypes.h
+++ b/sdk/include/ndk/rtltypes.h
@@ -196,6 +196,8 @@ C_ASSERT(HEAP_CREATE_VALID_MASK == 0x0007F0FF);
 #define IMAGE_FILE_MACHINE_NATIVE IMAGE_FILE_MACHINE_ARM
 #elif defined(_M_AMD64)
 #define IMAGE_FILE_MACHINE_NATIVE IMAGE_FILE_MACHINE_AMD64
+#elif defined(_M_ARM64)
+#define IMAGE_FILE_MACHINE_NATIVE IMAGE_FILE_MACHINE_ARM64
 #else
 #error Define these please!
 #endif
diff --git a/sdk/include/xdk/ketypes.h b/sdk/include/xdk/ketypes.h
index 2b0c99a867f..fdeee0904a3 100644
--- a/sdk/include/xdk/ketypes.h
+++ b/sdk/include/xdk/ketypes.h
@@ -980,7 +980,7 @@ typedef struct _XSTATE_SAVE {
   struct _KTHREAD* Thread;
   UCHAR Level;
   XSTATE_CONTEXT XStateContext;
-#elif defined(_IA64_) || defined(_ARM_)
+#elif defined(_IA64_) || defined(_ARM_) || defined(_ARM64_)
   ULONG Dummy;
 #elif defined(_X86_)
   _ANONYMOUS_UNION union {
diff --git a/sdk/include/xdk/ntbasedef.h b/sdk/include/xdk/ntbasedef.h
index 753bfd0f1b5..2cb40d0ee17 100644
--- a/sdk/include/xdk/ntbasedef.h
+++ b/sdk/include/xdk/ntbasedef.h
@@ -68,7 +68,7 @@
  #pragma strict_gs_check(push, on)
 #endif
 
-#if defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || 
defined(_M_IA64) || defined(_M_AMD64) || defined(_M_ARM)
+#if defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || 
defined(_M_IA64) || defined(_M_AMD64) || defined(_M_ARM) || defined(_M_ARM64)
  #define ALIGNMENT_MACHINE
  #define UNALIGNED __unaligned
  #if defined(_WI

[ros-diffs] [reactos] 01/04: [HALX86] Add function prototypes needed for parsing ACPI MADT table

2022-04-07 Thread Justin Miller
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0fc21e5a9b9ea59ef5a00bea042898bec6b05dd6

commit 0fc21e5a9b9ea59ef5a00bea042898bec6b05dd6
Author: Justin Miller 
AuthorDate: Thu Jun 24 09:57:19 2021 -0700
Commit: Stanislav Motylkov 
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 000..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 
+ */
+
+/* INCLUDES 
***/
+
+#include 
+#include 
+/* ACPI_BIOS_ERROR defined in acoutput.h and bugcodes.h */
+#undef ACPI_BIOS_ERROR
+#include 
+#define NDEBUG
+#include 
+
+/* 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 
 #include "apicp.h"
+#include 
 #define NDEBUG
 #include 
 
@@ -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 000..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 
+ */
+
+#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 2f48774852

[ros-diffs] [reactos] 02/04: [HALX86] Implement HalpSetupProcessorsTable

2022-04-07 Thread Justin Miller
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a09f925c1cd3254a530841ba80c893ed5c0c282b

commit a09f925c1cd3254a530841ba80c893ed5c0c282b
Author: Justin Miller 
AuthorDate: Sat Mar 26 10:01:21 2022 -0700
Commit: Stanislav Motylkov 
CommitDate: Thu Apr 7 22:54:31 2022 +0300

[HALX86] Implement HalpSetupProcessorsTable

Add a helper function for getting a pointer to the PRCB of every processor
in the system and assign it to the PROCESSOR_IDENTITY struct.
---
 hal/halx86/smp/smp.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/hal/halx86/smp/smp.c b/hal/halx86/smp/smp.c
index 8950aa83cfe..f8e2f9e4cdf 100644
--- a/hal/halx86/smp/smp.c
+++ b/hal/halx86/smp/smp.c
@@ -14,11 +14,20 @@
 
 /* GLOBALS ***/
 
+extern PPROCESSOR_IDENTITY HalpProcessorIdentity;
+
 /* FUNCTIONS */
 
 VOID
 HalpSetupProcessorsTable(
 _In_ UINT32 NTProcessorNumber)
 {
-UNIMPLEMENTED;
+PKPRCB CurrentPrcb;
+
+/*
+ * Link the Prcb of the current CPU to
+ * the current CPUs entry in the global ProcessorIdentity
+ */
+CurrentPrcb = KeGetCurrentPrcb();
+HalpProcessorIdentity[NTProcessorNumber].ProcessorPrcb = CurrentPrcb;
 }



[ros-diffs] [reactos] 03/04: [HALX86] Add a way to print the ProcessorTable data on bootup

2022-04-07 Thread Justin Miller
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5c7990051923441a35304c75a3ef964dc5c61052

commit 5c7990051923441a35304c75a3ef964dc5c61052
Author: Justin Miller 
AuthorDate: Sat Mar 26 10:22:12 2022 -0700
Commit: Stanislav Motylkov 
CommitDate: Thu Apr 7 22:54:32 2022 +0300

[HALX86] Add a way to print the ProcessorTable data on bootup
---
 hal/halx86/acpi/madt.c| 15 +++
 hal/halx86/apic/halinit.c |  3 +++
 hal/halx86/include/smp.h  |  3 +++
 hal/halx86/smp/mps/mps.c  | 21 +
 4 files changed, 42 insertions(+)

diff --git a/hal/halx86/acpi/madt.c b/hal/halx86/acpi/madt.c
index 9d4cdd070f8..183eaefcb04 100644
--- a/hal/halx86/acpi/madt.c
+++ b/hal/halx86/acpi/madt.c
@@ -28,3 +28,18 @@ HalpParseApicTables(
 {
 UNIMPLEMENTED;
 }
+
+VOID
+HalpPrintApicTables(VOID)
+{ 
+UINT32 i;
+
+DPRINT1("HAL has detected a physical processor count of: %d\n", 
HalpApicInfoTable.ProcessorCount);
+for (i = 0; i < HalpApicInfoTable.ProcessorCount; i++)
+{
+DPRINT1("Information about the following processor is for processors 
number: %d\n"
+"   The BSPCheck is set to: %X\n"
+"   The LapicID is set to: %X\n",
+i, HalpProcessorIdentity[i].BSPCheck, 
HalpProcessorIdentity[i].LapicId);
+}
+}
diff --git a/hal/halx86/apic/halinit.c b/hal/halx86/apic/halinit.c
index 87c6a37854d..cb0c5af7b77 100644
--- a/hal/halx86/apic/halinit.c
+++ b/hal/halx86/apic/halinit.c
@@ -59,6 +59,9 @@ HalpInitPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
CLOCK2_LEVEL,
HalpClockInterrupt,
Latched);
+#if DBG
+HalpPrintApicTables();
+#endif
 }
 
 VOID
diff --git a/hal/halx86/include/smp.h b/hal/halx86/include/smp.h
index 5eaccdbc285..cac946310f2 100644
--- a/hal/halx86/include/smp.h
+++ b/hal/halx86/include/smp.h
@@ -25,3 +25,6 @@ HalpParseApicTables(
 VOID
 HalpSetupProcessorsTable(
 _In_ UINT32 NTProcessorNumber);
+
+VOID
+HalpPrintApicTables(VOID);
diff --git a/hal/halx86/smp/mps/mps.c b/hal/halx86/smp/mps/mps.c
index a03c80c4db8..a55a962f02d 100644
--- a/hal/halx86/smp/mps/mps.c
+++ b/hal/halx86/smp/mps/mps.c
@@ -12,6 +12,12 @@
 #define NDEBUG
 #include 
 
+/* GLOBALS 
/
+
+PROCESSOR_IDENTITY HalpStaticProcessorIdentity[MAXIMUM_PROCESSORS] = {{0}};
+PPROCESSOR_IDENTITY HalpProcessorIdentity = NULL;
+UINT32 PhysicalProcessorCount = 0;
+
 /* FUNCTIONS 
**/
 
 VOID
@@ -20,3 +26,18 @@ HalpParseApicTables(
 {
 UNIMPLEMENTED;
 }
+
+VOID
+HalpPrintApicTables(VOID)
+{
+UINT32 i;
+
+DPRINT1("HAL has detected a physical processor count of: %d\n", 
PhysicalProcessorCount);
+for (i = 0; i < PhysicalProcessorCount; i++)
+{
+DPRINT1("Information about the following processor is for processors 
number: %d\n"
+"   The BSPCheck is set to: %X\n"
+"   The LapicID is set to: %X\n",
+i, HalpProcessorIdentity[i].BSPCheck, 
HalpProcessorIdentity[i].LapicId);
+}
+}



[ros-diffs] [reactos] 04/04: [HALX86] Add support for parsing ACPI MADT tables

2022-04-07 Thread Justin Miller
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=eebe11ae0cc923d9cd9047b3394ea5c3e9d37c60

commit eebe11ae0cc923d9cd9047b3394ea5c3e9d37c60
Author: Justin Miller 
AuthorDate: Sat Mar 26 12:39:28 2022 -0700
Commit: Stanislav Motylkov 
CommitDate: Thu Apr 7 22:54:32 2022 +0300

[HALX86] Add support for parsing ACPI MADT tables
---
 hal/halx86/acpi/madt.c| 45 -
 hal/halx86/apic/halinit.c | 10 +-
 hal/halx86/include/smp.h  | 13 +
 3 files changed, 62 insertions(+), 6 deletions(-)

diff --git a/hal/halx86/acpi/madt.c b/hal/halx86/acpi/madt.c
index 183eaefcb04..cd26be67b21 100644
--- a/hal/halx86/acpi/madt.c
+++ b/hal/halx86/acpi/madt.c
@@ -19,6 +19,10 @@
 
 PROCESSOR_IDENTITY HalpStaticProcessorIdentity[MAXIMUM_PROCESSORS] = {{0}};
 PPROCESSOR_IDENTITY HalpProcessorIdentity = NULL;
+HALP_APIC_INFO_TABLE HalpApicInfoTable;
+ACPI_TABLE_MADT *MadtTable;
+ACPI_SUBTABLE_HEADER *AcpiHeader;
+ACPI_MADT_LOCAL_APIC *LocalApic;
 
 /* FUNCTIONS 
**/
 
@@ -26,7 +30,46 @@ VOID
 HalpParseApicTables(
 _In_ PLOADER_PARAMETER_BLOCK LoaderBlock)
 {
-UNIMPLEMENTED;
+ULONG_PTR TableEnd;
+ULONG ValidProcessorCount;
+
+/* We only support legacy APIC for now, this will be updated in the future 
*/
+HalpApicInfoTable.ApicMode = 0x10;
+MadtTable = HalAcpiGetTable(LoaderBlock, 'CIPA');
+
+AcpiHeader = (ACPI_SUBTABLE_HEADER*)MadtTable;
+AcpiHeader->Length = sizeof(ACPI_TABLE_MADT);
+TableEnd = (ULONG_PTR)MadtTable + MadtTable->Header.Length;
+
+HalpApicInfoTable.ProcessorCount = 0;
+HalpProcessorIdentity = HalpStaticProcessorIdentity;
+
+AcpiHeader = (ACPI_SUBTABLE_HEADER*)MadtTable;
+AcpiHeader->Length = sizeof(ACPI_TABLE_MADT);
+TableEnd = (ULONG_PTR)MadtTable + MadtTable->Header.Length;
+
+while ((ULONG_PTR)AcpiHeader <= TableEnd)
+{
+LocalApic = (ACPI_MADT_LOCAL_APIC*)AcpiHeader;
+
+if (LocalApic->Header.Type == ACPI_MADT_TYPE_LOCAL_APIC &&
+LocalApic->Header.Length == sizeof(ACPI_MADT_LOCAL_APIC))
+{
+ValidProcessorCount = HalpApicInfoTable.ProcessorCount;
+
+HalpProcessorIdentity[ValidProcessorCount].LapicId = LocalApic->Id;
+HalpProcessorIdentity[ValidProcessorCount].ProcessorId = 
LocalApic->ProcessorId;
+
+HalpApicInfoTable.ProcessorCount++;
+
+AcpiHeader = (ACPI_SUBTABLE_HEADER*)((ULONG_PTR)AcpiHeader + 
AcpiHeader->Length);
+}
+else
+{
+/* End the parsing early if we don't use the currently selected 
table */
+AcpiHeader = (ACPI_SUBTABLE_HEADER*)((ULONG_PTR)AcpiHeader + 1);
+}
+}
 }
 
 VOID
diff --git a/hal/halx86/apic/halinit.c b/hal/halx86/apic/halinit.c
index cb0c5af7b77..907f0cfd28f 100644
--- a/hal/halx86/apic/halinit.c
+++ b/hal/halx86/apic/halinit.c
@@ -25,13 +25,14 @@ HalpInitProcessor(
 IN ULONG ProcessorNumber,
 IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 {
+#ifdef CONFIG_SMP
 if (ProcessorNumber == 0)
 {
-/* APIC tables should always be parsed once before touching APIC */
+#endif
 HalpParseApicTables(LoaderBlock);
+#ifdef CONFIG_SMP
 }
 
-#ifdef CONFIG_SMP
 HalpSetupProcessorsTable(ProcessorNumber);
 #endif
 
@@ -52,6 +53,8 @@ HalpInitPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 (HalpBuildType & PRCB_BUILD_UNIPROCESSOR) ? "UP" : "SMP",
 (HalpBuildType & PRCB_BUILD_DEBUG) ? "DBG" : "REL");
 
+HalpPrintApicTables();
+
 /* Enable clock interrupt handler */
 HalpEnableInterruptHandler(IDT_INTERNAL,
0,
@@ -59,9 +62,6 @@ HalpInitPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
CLOCK2_LEVEL,
HalpClockInterrupt,
Latched);
-#if DBG
-HalpPrintApicTables();
-#endif
 }
 
 VOID
diff --git a/hal/halx86/include/smp.h b/hal/halx86/include/smp.h
index cac946310f2..06ec42ec6db 100644
--- a/hal/halx86/include/smp.h
+++ b/hal/halx86/include/smp.h
@@ -18,6 +18,19 @@ typedef struct _PROCESSOR_IDENTITY
 
 } PROCESSOR_IDENTITY, *PPROCESSOR_IDENTITY;
 
+/* This table is counter of the overall APIC constants acquired from madt */
+typedef struct _HALP_APIC_INFO_TABLE
+{
+ULONG ApicMode;
+ULONG ProcessorCount; /* Count of all physical cores, This includes BSP */
+ULONG IOAPICCount;
+ULONG LocalApicPA;// The 32-bit physical address at which 
each processor can access its local interrupt controller
+ULONG IoApicVA[256];
+ULONG IoApicPA[256];
+ULONG IoApicIrqBase[256]; // Global system interrupt base
+
+} HALP_APIC_INFO_TABLE, *PHALP_APIC_INFO_TABLE;
+
 VOID
 HalpParseApicTables(
 _In_ PLOADER_PARAMETER_BLOCK LoaderBlock);