[FREELDR]
[reactos.git] / reactos / boot / freeldr / freeldr / include / winldr.h
1 /*
2 * FreeLoader
3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
4 * Copyright (C) 2006 Aleksey Bragin <aleksey@reactos.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #pragma once
22
23 #include <arc/setupblk.h>
24
25 #define TAG_WLDR_DTE 'eDlW'
26 #define TAG_WLDR_BDE 'dBlW'
27 #define TAG_WLDR_NAME 'mNlW'
28
29 /* Entry-point to kernel */
30 typedef VOID (NTAPI *KERNEL_ENTRY_POINT) (PLOADER_PARAMETER_BLOCK LoaderBlock);
31
32
33 // Some definitions
34 #define SECTOR_SIZE 512
35
36 // Descriptors
37 #define NUM_GDT 128 // Must be 128
38 #define NUM_IDT 0x100 // only 16 are used though. Must be 0x100
39
40 #include <pshpack1.h>
41 typedef struct /* Root System Descriptor Pointer */
42 {
43 CHAR signature [8]; /* contains "RSD PTR " */
44 UCHAR checksum; /* to make sum of struct == 0 */
45 CHAR oem_id [6]; /* OEM identification */
46 UCHAR revision; /* Must be 0 for 1.0, 2 for 2.0 */
47 ULONG rsdt_physical_address; /* 32-bit physical address of RSDT */
48 ULONG length; /* XSDT Length in bytes including hdr */
49 ULONGLONG xsdt_physical_address; /* 64-bit physical address of XSDT */
50 UCHAR extended_checksum; /* Checksum of entire table */
51 CHAR reserved [3]; /* reserved field must be 0 */
52 } RSDP_DESCRIPTOR, *PRSDP_DESCRIPTOR;
53 #include <poppack.h>
54
55 typedef struct _ARC_DISK_SIGNATURE_EX
56 {
57 ARC_DISK_SIGNATURE DiskSignature;
58 CHAR ArcName[MAX_PATH];
59 } ARC_DISK_SIGNATURE_EX, *PARC_DISK_SIGNATURE_EX;
60
61 #define MAX_OPTIONS_LENGTH 255
62
63 typedef struct _LOADER_SYSTEM_BLOCK
64 {
65 LOADER_PARAMETER_BLOCK LoaderBlock;
66 LOADER_PARAMETER_EXTENSION Extension;
67 SETUP_LOADER_BLOCK SetupBlock;
68 #ifdef _M_IX86
69 HEADLESS_LOADER_BLOCK HeadlessLoaderBlock;
70 #endif
71 NLS_DATA_BLOCK NlsDataBlock;
72 CHAR LoadOptions[MAX_OPTIONS_LENGTH+1];
73 CHAR ArcBootDeviceName[MAX_PATH+1];
74 // CHAR ArcHalDeviceName[MAX_PATH];
75 CHAR NtBootPathName[MAX_PATH+1];
76 CHAR NtHalPathName[MAX_PATH+1];
77 ARC_DISK_INFORMATION ArcDiskInformation;
78 } LOADER_SYSTEM_BLOCK, *PLOADER_SYSTEM_BLOCK;
79
80 extern PLOADER_SYSTEM_BLOCK WinLdrSystemBlock;
81
82 ///////////////////////////////////////////////////////////////////////////////////////
83 //
84 // ReactOS Loading Functions
85 //
86 ///////////////////////////////////////////////////////////////////////////////////////
87 VOID LoadAndBootWindows(IN OperatingSystemItem* OperatingSystem,
88 IN USHORT OperatingSystemVersion);
89
90 // conversion.c
91 PVOID VaToPa(PVOID Va);
92 PVOID PaToVa(PVOID Pa);
93 VOID List_PaToVa(_In_ LIST_ENTRY *ListEntry);
94 VOID ConvertConfigToVA(PCONFIGURATION_COMPONENT_DATA Start);
95
96 // peloader.c
97 BOOLEAN
98 WinLdrLoadImage(IN PCHAR FileName,
99 TYPE_OF_MEMORY MemoryType,
100 OUT PVOID *ImageBasePA);
101
102
103 BOOLEAN
104 WinLdrAllocateDataTableEntry(IN OUT PLIST_ENTRY ModuleListHead,
105 IN PCCH BaseDllName,
106 IN PCCH FullDllName,
107 IN PVOID BasePA,
108 OUT PLDR_DATA_TABLE_ENTRY *NewEntry);
109
110 BOOLEAN
111 WinLdrScanImportDescriptorTable(IN OUT PLIST_ENTRY ModuleListHead,
112 IN PCCH DirectoryPath,
113 IN PLDR_DATA_TABLE_ENTRY ScanDTE);
114
115 // winldr.c
116 PVOID WinLdrLoadModule(PCSTR ModuleName, ULONG *Size,
117 TYPE_OF_MEMORY MemoryType);
118
119 // wlmemory.c
120 BOOLEAN
121 WinLdrSetupMemoryLayout(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock);
122
123 // wlregistry.c
124 BOOLEAN WinLdrInitSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
125 IN LPCSTR DirectoryPath);
126
127 BOOLEAN WinLdrScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
128 IN LPCSTR DirectoryPath);
129
130
131 BOOLEAN
132 WinLdrCheckForLoadedDll(IN OUT PLIST_ENTRY ModuleListHead,
133 IN PCH DllName,
134 OUT PLDR_DATA_TABLE_ENTRY *LoadedEntry);
135
136 VOID
137 WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock,
138 LPCSTR Options,
139 LPCSTR SystemPath,
140 LPCSTR BootPath,
141 USHORT VersionToBoot);
142 BOOLEAN
143 WinLdrLoadNLSData(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
144 IN LPCSTR DirectoryPath,
145 IN LPCSTR AnsiFileName,
146 IN LPCSTR OemFileName,
147 IN LPCSTR LanguageFileName);
148 BOOLEAN
149 WinLdrAddDriverToList(LIST_ENTRY *BootDriverListHead,
150 LPWSTR RegistryPath,
151 LPWSTR ImagePath,
152 LPWSTR ServiceName);
153
154 VOID
155 WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock);
156
157 VOID
158 WinLdrpDumpBootDriver(PLOADER_PARAMETER_BLOCK LoaderBlock);
159
160 VOID
161 WinLdrpDumpArcDisks(PLOADER_PARAMETER_BLOCK LoaderBlock);
162
163 BOOLEAN
164 MempSetupPaging(IN PFN_NUMBER StartPage,
165 IN PFN_NUMBER NumberOfPages,
166 IN BOOLEAN KernelMapping);
167
168 VOID
169 MempUnmapPage(PFN_NUMBER Page);
170
171 VOID
172 MempDump();
173
174 VOID
175 LoadAndBootWindowsCommon(
176 USHORT OperatingSystemVersion,
177 PLOADER_PARAMETER_BLOCK LoaderBlock,
178 LPCSTR BootOptions,
179 LPCSTR BootPath,
180 BOOLEAN Setup);
181
182 VOID
183 LoadReactOSSetup(IN OperatingSystemItem* OperatingSystem,
184 IN USHORT OperatingSystemVersion);
185
186 VOID
187 WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock);
188
189 VOID
190 WinLdrSetProcessorContext(VOID);