1 /*
2 * PROJECT: FreeLoader
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Windows-compatible NT OS Loader.
5 * COPYRIGHT: Copyright 2006-2019 Aleksey Bragin <aleksey@reactos.org>
6 */
7
8 #pragma once
9
10 #include <arc/setupblk.h>
11
12 /* Entry-point to kernel */
13 typedef VOID (NTAPI *KERNEL_ENTRY_POINT) (PLOADER_PARAMETER_BLOCK LoaderBlock);
14
15 /* Descriptors */
16 #define NUM_GDT 128 // Must be 128
17 #define NUM_IDT 0x100 // Only 16 are used though. Must be 0x100
18
19 #if 0
20
21 #include <pshpack1.h>
22 typedef struct /* Root System Descriptor Pointer */
23 {
24 CHAR signature [8]; /* contains "RSD PTR " */
25 UCHAR checksum; /* to make sum of struct == 0 */
26 CHAR oem_id [6]; /* OEM identification */
27 UCHAR revision; /* Must be 0 for 1.0, 2 for 2.0 */
28 ULONG rsdt_physical_address; /* 32-bit physical address of RSDT */
29 ULONG length; /* XSDT Length in bytes including hdr */
30 ULONGLONG xsdt_physical_address; /* 64-bit physical address of XSDT */
31 UCHAR extended_checksum; /* Checksum of entire table */
32 CHAR reserved [3]; /* reserved field must be 0 */
33 } RSDP_DESCRIPTOR, *PRSDP_DESCRIPTOR;
34 #include <poppack.h>
35
36 typedef struct _ARC_DISK_SIGNATURE_EX
37 {
38 ARC_DISK_SIGNATURE DiskSignature;
39 CHAR ArcName[MAX_PATH];
40 } ARC_DISK_SIGNATURE_EX, *PARC_DISK_SIGNATURE_EX;
41
42 #endif
43
44 #define MAX_OPTIONS_LENGTH 255
45
46 typedef struct _LOADER_SYSTEM_BLOCK
47 {
48 LOADER_PARAMETER_BLOCK LoaderBlock;
49 LOADER_PARAMETER_EXTENSION Extension;
50 SETUP_LOADER_BLOCK SetupBlock;
51 #ifdef _M_IX86
52 HEADLESS_LOADER_BLOCK HeadlessLoaderBlock;
53 #endif
54 NLS_DATA_BLOCK NlsDataBlock;
55 CHAR LoadOptions[MAX_OPTIONS_LENGTH+1];
56 CHAR ArcBootDeviceName[MAX_PATH+1];
57 // CHAR ArcHalDeviceName[MAX_PATH];
58 CHAR NtBootPathName[MAX_PATH+1];
59 CHAR NtHalPathName[MAX_PATH+1];
60 ARC_DISK_INFORMATION ArcDiskInformation;
61 LOADER_PERFORMANCE_DATA LoaderPerformanceData;
62 } LOADER_SYSTEM_BLOCK, *PLOADER_SYSTEM_BLOCK;
63
64 extern PLOADER_SYSTEM_BLOCK WinLdrSystemBlock;
65 /**/extern PCWSTR BootFileSystem;/**/
66
67
68 // conversion.c
69 #if 0
70 PVOID VaToPa(PVOID Va);
71 PVOID PaToVa(PVOID Pa);
72 VOID List_PaToVa(_In_ LIST_ENTRY *ListEntry);
73 #endif
74 VOID ConvertConfigToVA(PCONFIGURATION_COMPONENT_DATA Start);
75
76 // winldr.c
77 extern BOOLEAN SosEnabled;
78 #ifdef _M_IX86
79 extern BOOLEAN PaeModeOn;
80 #endif
81
82 FORCEINLINE
83 VOID
UiResetForSOS(VOID)84 UiResetForSOS(VOID)
85 {
86 #ifdef _M_ARM
87 /* Re-initialize the UI */
88 UiInitialize(TRUE);
89 #else
90 /* Reset the UI and switch to MiniTui */
91 UiVtbl.UnInitialize();
92 UiVtbl = MiniTuiVtbl;
93 UiVtbl.Initialize();
94 #endif
95 /* Disable the progress bar */
96 UiProgressBar.Show = FALSE;
97 }
98
99 VOID
100 NtLdrOutputLoadMsg(
101 _In_ PCSTR FileName,
102 _In_opt_ PCSTR Description);
103
104 PVOID WinLdrLoadModule(PCSTR ModuleName, PULONG Size,
105 TYPE_OF_MEMORY MemoryType);
106
107 // wlmemory.c
108 BOOLEAN
109 WinLdrSetupMemoryLayout(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock);
110
111 // wlregistry.c
112 BOOLEAN
113 WinLdrInitSystemHive(
114 IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
115 IN PCSTR SystemRoot,
116 IN BOOLEAN Setup);
117
118 BOOLEAN WinLdrScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
119 IN PCSTR SystemRoot);
120
121 BOOLEAN
122 WinLdrLoadNLSData(
123 _Inout_ PLOADER_PARAMETER_BLOCK LoaderBlock,
124 _In_ PCSTR DirectoryPath,
125 _In_ PCUNICODE_STRING AnsiFileName,
126 _In_ PCUNICODE_STRING OemFileName,
127 _In_ PCUNICODE_STRING LangFileName, // CaseTable
128 _In_ PCUNICODE_STRING OemHalFileName);
129
130 BOOLEAN
131 WinLdrAddDriverToList(
132 _Inout_ PLIST_ENTRY DriverListHead,
133 _In_ BOOLEAN InsertAtHead,
134 _In_ PCWSTR DriverName,
135 _In_opt_ PCWSTR ImagePath,
136 _In_opt_ PCWSTR GroupName,
137 _In_ ULONG ErrorControl,
138 _In_ ULONG Tag);
139
140 // winldr.c
141 VOID
142 WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock,
143 PCSTR Options,
144 PCSTR SystemPath,
145 PCSTR BootPath,
146 USHORT VersionToBoot);
147
148 VOID
149 WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock);
150
151 VOID
152 WinLdrpDumpBootDriver(PLOADER_PARAMETER_BLOCK LoaderBlock);
153
154 VOID
155 WinLdrpDumpArcDisks(PLOADER_PARAMETER_BLOCK LoaderBlock);
156
157 ARC_STATUS
158 LoadAndBootWindowsCommon(
159 IN USHORT OperatingSystemVersion,
160 IN PLOADER_PARAMETER_BLOCK LoaderBlock,
161 IN PCSTR BootOptions,
162 IN PCSTR BootPath);
163
164 VOID
165 WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock);
166
167 VOID
168 WinLdrSetProcessorContext(
169 _In_ USHORT OperatingSystemVersion);
170
171 // arch/xxx/winldr.c
172 BOOLEAN
173 MempSetupPaging(IN PFN_NUMBER StartPage,
174 IN PFN_NUMBER NumberOfPages,
175 IN BOOLEAN KernelMapping);
176
177 VOID
178 MempUnmapPage(PFN_NUMBER Page);
179
180 VOID
181 MempDump(VOID);
182