[FREELDR] Small code re-organization for the "ntldr" sub-module.
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Fri, 2 Jun 2017 00:52:36 +0000 (00:52 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Wed, 24 Oct 2018 22:40:04 +0000 (00:40 +0200)
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
boot/freeldr/freeldr/ntldr/setupldr.c
boot/freeldr/freeldr/ntldr/winldr.c
boot/freeldr/freeldr/ntldr/winldr.h [new file with mode: 0644]
boot/freeldr/freeldr/ntldr/wlmemory.c
boot/freeldr/freeldr/ntldr/wlregistry.c

index f5b3a88..56af2ed 100644 (file)
 
 #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);
index 20fc1b6..72e69f8 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <freeldr.h>
+#include "winldr.h"
 
 #include <ndk/ldrtypes.h>
 #include <arc/setupblk.h>
 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);
 
index b110156..6c8da87 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <freeldr.h>
+#include "winldr.h"
 #include "registry.h"
 
 #include <ndk/ldrtypes.h>
diff --git a/boot/freeldr/freeldr/ntldr/winldr.h b/boot/freeldr/freeldr/ntldr/winldr.h
new file mode 100644 (file)
index 0000000..31ca33d
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ *  FreeLoader
+ *  Copyright (C) 1998-2003  Brian Palmer    <brianp@sginet.com>
+ *  Copyright (C) 2006       Aleksey Bragin  <aleksey@reactos.org>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#pragma once
+
+#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
+
+#if 0
+
+// Descriptors
+#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 */
+{
+    CHAR             signature [8];          /* contains "RSD PTR " */
+    UCHAR            checksum;               /* to make sum of struct == 0 */
+    CHAR             oem_id [6];             /* OEM identification */
+    UCHAR            revision;               /* Must be 0 for 1.0, 2 for 2.0 */
+    ULONG            rsdt_physical_address;  /* 32-bit physical address of RSDT */
+    ULONG            length;                 /* XSDT Length in bytes including hdr */
+    ULONGLONG        xsdt_physical_address;  /* 64-bit physical address of XSDT */
+    UCHAR            extended_checksum;      /* Checksum of entire table */
+    CHAR             reserved [3];           /* reserved field must be 0 */
+} RSDP_DESCRIPTOR, *PRSDP_DESCRIPTOR;
+#include <poppack.h>
+
+typedef struct _ARC_DISK_SIGNATURE_EX
+{
+    ARC_DISK_SIGNATURE DiskSignature;
+    CHAR ArcName[MAX_PATH];
+} ARC_DISK_SIGNATURE_EX, *PARC_DISK_SIGNATURE_EX;
+
+#endif
+
+#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;
+
+
+// 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);
+
+
+// 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 PCSTR SystemRoot,
+    IN BOOLEAN Setup);
+
+BOOLEAN WinLdrScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
+                             IN LPCSTR DirectoryPath);
+
+// winldr.c
+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);
+
+VOID
+LoadAndBootWindowsCommon(
+    USHORT OperatingSystemVersion,
+    PLOADER_PARAMETER_BLOCK LoaderBlock,
+    LPCSTR BootOptions,
+    LPCSTR BootPath,
+    BOOLEAN Setup);
index 09638d8..99a1c9d 100644 (file)
@@ -9,6 +9,7 @@
 /* INCLUDES ***************************************************************/
 
 #include <freeldr.h>
+#include "winldr.h"
 
 #include <debug.h>
 
index 40e297e..5fd438f 100644 (file)
@@ -9,6 +9,7 @@
 /* INCLUDES ***************************************************************/
 
 #include <freeldr.h>
+#include "winldr.h"
 #include "registry.h"
 
 #include <debug.h>