https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5e705d06834c947514e18…
commit 5e705d06834c947514e18ec64ef0338b60a35113
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Fri Jun 2 00:52:36 2017 +0000
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Thu Oct 25 00:40:04 2018 +0200
[FREELDR] Small code re-organization for the "ntldr" sub-module.
Split the "main" winldr.h header into the one containing global code
that actually doesn't really depend on the "windows" NT loader part,
and one that actually concerns code just for the NT Loader.
The latter goes into "ntldr".
svn path=/branches/setup_improvements/; revision=74743
---
boot/freeldr/freeldr/include/winldr.h | 98 ++++--------------------
boot/freeldr/freeldr/ntldr/setupldr.c | 7 +-
boot/freeldr/freeldr/ntldr/winldr.c | 1 +
boot/freeldr/freeldr/{include => ntldr}/winldr.h | 75 +++++-------------
boot/freeldr/freeldr/ntldr/wlmemory.c | 1 +
boot/freeldr/freeldr/ntldr/wlregistry.c | 1 +
6 files changed, 36 insertions(+), 147 deletions(-)
diff --git a/boot/freeldr/freeldr/include/winldr.h
b/boot/freeldr/freeldr/include/winldr.h
index f5b3a8821c..56af2eda3f 100644
--- a/boot/freeldr/freeldr/include/winldr.h
+++ b/boot/freeldr/freeldr/include/winldr.h
@@ -22,20 +22,20 @@
#include <arc/setupblk.h>
+// See freeldr/ntldr/winldr.h
#define TAG_WLDR_DTE 'eDlW'
#define TAG_WLDR_BDE 'dBlW'
#define TAG_WLDR_NAME 'mNlW'
-/* Entry-point to kernel */
-typedef VOID (NTAPI *KERNEL_ENTRY_POINT) (PLOADER_PARAMETER_BLOCK LoaderBlock);
-
// Some definitions
+
+// FIXME: This one has nothing to do here!!
#define SECTOR_SIZE 512
// Descriptors
-#define NUM_GDT 128 // Must be 128
-#define NUM_IDT 0x100 // only 16 are used though. Must be 0x100
+#define NUM_GDT 128 // Must be 128
+#define NUM_IDT 0x100 // Only 16 are used though. Must be 0x100
#include <pshpack1.h>
typedef struct /* Root System Descriptor Pointer */
@@ -58,27 +58,6 @@ typedef struct _ARC_DISK_SIGNATURE_EX
CHAR ArcName[MAX_PATH];
} ARC_DISK_SIGNATURE_EX, *PARC_DISK_SIGNATURE_EX;
-#define MAX_OPTIONS_LENGTH 255
-
-typedef struct _LOADER_SYSTEM_BLOCK
-{
- LOADER_PARAMETER_BLOCK LoaderBlock;
- LOADER_PARAMETER_EXTENSION Extension;
- SETUP_LOADER_BLOCK SetupBlock;
-#ifdef _M_IX86
- HEADLESS_LOADER_BLOCK HeadlessLoaderBlock;
-#endif
- NLS_DATA_BLOCK NlsDataBlock;
- CHAR LoadOptions[MAX_OPTIONS_LENGTH+1];
- CHAR ArcBootDeviceName[MAX_PATH+1];
- // CHAR ArcHalDeviceName[MAX_PATH];
- CHAR NtBootPathName[MAX_PATH+1];
- CHAR NtHalPathName[MAX_PATH+1];
- ARC_DISK_INFORMATION ArcDiskInformation;
-} LOADER_SYSTEM_BLOCK, *PLOADER_SYSTEM_BLOCK;
-
-extern PLOADER_SYSTEM_BLOCK WinLdrSystemBlock;
-
///////////////////////////////////////////////////////////////////////////////////////
//
// ReactOS Loading Functions
@@ -87,11 +66,16 @@ extern PLOADER_SYSTEM_BLOCK WinLdrSystemBlock;
VOID LoadAndBootWindows(IN OperatingSystemItem* OperatingSystem,
IN USHORT OperatingSystemVersion);
-// conversion.c
+VOID
+LoadReactOSSetup(IN OperatingSystemItem* OperatingSystem,
+ IN USHORT OperatingSystemVersion);
+
+
+// conversion.c and conversion.h
PVOID VaToPa(PVOID Va);
PVOID PaToVa(PVOID Pa);
VOID List_PaToVa(_In_ LIST_ENTRY *ListEntry);
-VOID ConvertConfigToVA(PCONFIGURATION_COMPONENT_DATA Start);
+
// peloader.c
BOOLEAN
@@ -99,7 +83,6 @@ WinLdrLoadImage(IN PCHAR FileName,
TYPE_OF_MEMORY MemoryType,
OUT PVOID *ImageBasePA);
-
BOOLEAN
WinLdrAllocateDataTableEntry(IN OUT PLIST_ENTRY ModuleListHead,
IN PCCH BaseDllName,
@@ -112,54 +95,13 @@ WinLdrScanImportDescriptorTable(IN OUT PLIST_ENTRY ModuleListHead,
IN PCCH DirectoryPath,
IN PLDR_DATA_TABLE_ENTRY ScanDTE);
-// winldr.c
-PVOID WinLdrLoadModule(PCSTR ModuleName, ULONG *Size,
- TYPE_OF_MEMORY MemoryType);
-
-// wlmemory.c
-BOOLEAN
-WinLdrSetupMemoryLayout(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock);
-
-// wlregistry.c
-BOOLEAN WinLdrInitSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
- IN LPCSTR DirectoryPath);
-
-BOOLEAN WinLdrScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
- IN LPCSTR DirectoryPath);
-
-
BOOLEAN
WinLdrCheckForLoadedDll(IN OUT PLIST_ENTRY ModuleListHead,
IN PCH DllName,
OUT PLDR_DATA_TABLE_ENTRY *LoadedEntry);
-VOID
-WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock,
- LPCSTR Options,
- LPCSTR SystemPath,
- LPCSTR BootPath,
- USHORT VersionToBoot);
-BOOLEAN
-WinLdrLoadNLSData(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
- IN LPCSTR DirectoryPath,
- IN LPCSTR AnsiFileName,
- IN LPCSTR OemFileName,
- IN LPCSTR LanguageFileName);
-BOOLEAN
-WinLdrAddDriverToList(LIST_ENTRY *BootDriverListHead,
- LPWSTR RegistryPath,
- LPWSTR ImagePath,
- LPWSTR ServiceName);
-
-VOID
-WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock);
-
-VOID
-WinLdrpDumpBootDriver(PLOADER_PARAMETER_BLOCK LoaderBlock);
-
-VOID
-WinLdrpDumpArcDisks(PLOADER_PARAMETER_BLOCK LoaderBlock);
+// arch/xxx/winldr.c
BOOLEAN
MempSetupPaging(IN PFN_NUMBER StartPage,
IN PFN_NUMBER NumberOfPages,
@@ -169,19 +111,7 @@ VOID
MempUnmapPage(PFN_NUMBER Page);
VOID
-MempDump();
-
-VOID
-LoadAndBootWindowsCommon(
- USHORT OperatingSystemVersion,
- PLOADER_PARAMETER_BLOCK LoaderBlock,
- LPCSTR BootOptions,
- LPCSTR BootPath,
- BOOLEAN Setup);
-
-VOID
-LoadReactOSSetup(IN OperatingSystemItem* OperatingSystem,
- IN USHORT OperatingSystemVersion);
+MempDump(VOID);
VOID
WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock);
diff --git a/boot/freeldr/freeldr/ntldr/setupldr.c
b/boot/freeldr/freeldr/ntldr/setupldr.c
index 20fc1b63a3..72e69f889c 100644
--- a/boot/freeldr/freeldr/ntldr/setupldr.c
+++ b/boot/freeldr/freeldr/ntldr/setupldr.c
@@ -19,6 +19,7 @@
*/
#include <freeldr.h>
+#include "winldr.h"
#include <ndk/ldrtypes.h>
#include <arc/setupblk.h>
@@ -28,12 +29,6 @@
DBG_DEFAULT_CHANNEL(WINDOWS);
#define TAG_BOOT_OPTIONS 'pOtB'
-void
-WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock);
-
-VOID
-WinLdrSetProcessorContext(void);
-
// TODO: Move to .h
VOID AllocateAndInitLPB(PLOADER_PARAMETER_BLOCK *OutLoaderBlock);
diff --git a/boot/freeldr/freeldr/ntldr/winldr.c b/boot/freeldr/freeldr/ntldr/winldr.c
index b11015600a..6c8da87683 100644
--- a/boot/freeldr/freeldr/ntldr/winldr.c
+++ b/boot/freeldr/freeldr/ntldr/winldr.c
@@ -20,6 +20,7 @@
*/
#include <freeldr.h>
+#include "winldr.h"
#include "registry.h"
#include <ndk/ldrtypes.h>
diff --git a/boot/freeldr/freeldr/include/winldr.h b/boot/freeldr/freeldr/ntldr/winldr.h
similarity index 70%
copy from boot/freeldr/freeldr/include/winldr.h
copy to boot/freeldr/freeldr/ntldr/winldr.h
index f5b3a8821c..31ca33dd44 100644
--- a/boot/freeldr/freeldr/include/winldr.h
+++ b/boot/freeldr/freeldr/ntldr/winldr.h
@@ -22,20 +22,25 @@
#include <arc/setupblk.h>
+#if 0
+// See freeldr/include/winldr.h
#define TAG_WLDR_DTE 'eDlW'
#define TAG_WLDR_BDE 'dBlW'
#define TAG_WLDR_NAME 'mNlW'
+#endif
+
/* Entry-point to kernel */
typedef VOID (NTAPI *KERNEL_ENTRY_POINT) (PLOADER_PARAMETER_BLOCK LoaderBlock);
// Some definitions
-#define SECTOR_SIZE 512
+
+#if 0
// Descriptors
-#define NUM_GDT 128 // Must be 128
-#define NUM_IDT 0x100 // only 16 are used though. Must be 0x100
+#define NUM_GDT 128 // Must be 128
+#define NUM_IDT 0x100 // Only 16 are used though. Must be 0x100
#include <pshpack1.h>
typedef struct /* Root System Descriptor Pointer */
@@ -58,6 +63,8 @@ typedef struct _ARC_DISK_SIGNATURE_EX
CHAR ArcName[MAX_PATH];
} ARC_DISK_SIGNATURE_EX, *PARC_DISK_SIGNATURE_EX;
+#endif
+
#define MAX_OPTIONS_LENGTH 255
typedef struct _LOADER_SYSTEM_BLOCK
@@ -79,38 +86,15 @@ typedef struct _LOADER_SYSTEM_BLOCK
extern PLOADER_SYSTEM_BLOCK WinLdrSystemBlock;
-///////////////////////////////////////////////////////////////////////////////////////
-//
-// ReactOS Loading Functions
-//
-///////////////////////////////////////////////////////////////////////////////////////
-VOID LoadAndBootWindows(IN OperatingSystemItem* OperatingSystem,
- IN USHORT OperatingSystemVersion);
// conversion.c
+#if 0
PVOID VaToPa(PVOID Va);
PVOID PaToVa(PVOID Pa);
VOID List_PaToVa(_In_ LIST_ENTRY *ListEntry);
+#endif
VOID ConvertConfigToVA(PCONFIGURATION_COMPONENT_DATA Start);
-// peloader.c
-BOOLEAN
-WinLdrLoadImage(IN PCHAR FileName,
- TYPE_OF_MEMORY MemoryType,
- OUT PVOID *ImageBasePA);
-
-
-BOOLEAN
-WinLdrAllocateDataTableEntry(IN OUT PLIST_ENTRY ModuleListHead,
- IN PCCH BaseDllName,
- IN PCCH FullDllName,
- IN PVOID BasePA,
- OUT PLDR_DATA_TABLE_ENTRY *NewEntry);
-
-BOOLEAN
-WinLdrScanImportDescriptorTable(IN OUT PLIST_ENTRY ModuleListHead,
- IN PCCH DirectoryPath,
- IN PLDR_DATA_TABLE_ENTRY ScanDTE);
// winldr.c
PVOID WinLdrLoadModule(PCSTR ModuleName, ULONG *Size,
@@ -121,18 +105,16 @@ BOOLEAN
WinLdrSetupMemoryLayout(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock);
// wlregistry.c
-BOOLEAN WinLdrInitSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
- IN LPCSTR DirectoryPath);
+BOOLEAN
+WinLdrInitSystemHive(
+ IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
+ IN PCSTR SystemRoot,
+ IN BOOLEAN Setup);
BOOLEAN WinLdrScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
IN LPCSTR DirectoryPath);
-
-BOOLEAN
-WinLdrCheckForLoadedDll(IN OUT PLIST_ENTRY ModuleListHead,
- IN PCH DllName,
- OUT PLDR_DATA_TABLE_ENTRY *LoadedEntry);
-
+// winldr.c
VOID
WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock,
LPCSTR Options,
@@ -160,17 +142,6 @@ WinLdrpDumpBootDriver(PLOADER_PARAMETER_BLOCK LoaderBlock);
VOID
WinLdrpDumpArcDisks(PLOADER_PARAMETER_BLOCK LoaderBlock);
-BOOLEAN
-MempSetupPaging(IN PFN_NUMBER StartPage,
- IN PFN_NUMBER NumberOfPages,
- IN BOOLEAN KernelMapping);
-
-VOID
-MempUnmapPage(PFN_NUMBER Page);
-
-VOID
-MempDump();
-
VOID
LoadAndBootWindowsCommon(
USHORT OperatingSystemVersion,
@@ -178,13 +149,3 @@ LoadAndBootWindowsCommon(
LPCSTR BootOptions,
LPCSTR BootPath,
BOOLEAN Setup);
-
-VOID
-LoadReactOSSetup(IN OperatingSystemItem* OperatingSystem,
- IN USHORT OperatingSystemVersion);
-
-VOID
-WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock);
-
-VOID
-WinLdrSetProcessorContext(VOID);
diff --git a/boot/freeldr/freeldr/ntldr/wlmemory.c
b/boot/freeldr/freeldr/ntldr/wlmemory.c
index 09638d82e5..99a1c9d9db 100644
--- a/boot/freeldr/freeldr/ntldr/wlmemory.c
+++ b/boot/freeldr/freeldr/ntldr/wlmemory.c
@@ -9,6 +9,7 @@
/* INCLUDES ***************************************************************/
#include <freeldr.h>
+#include "winldr.h"
#include <debug.h>
diff --git a/boot/freeldr/freeldr/ntldr/wlregistry.c
b/boot/freeldr/freeldr/ntldr/wlregistry.c
index 40e297e9cb..5fd438fd14 100644
--- a/boot/freeldr/freeldr/ntldr/wlregistry.c
+++ b/boot/freeldr/freeldr/ntldr/wlregistry.c
@@ -9,6 +9,7 @@
/* INCLUDES ***************************************************************/
#include <freeldr.h>
+#include "winldr.h"
#include "registry.h"
#include <debug.h>