xref: /reactos/boot/freeldr/freeldr/ntldr/winldr.h (revision 0c42866e)
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_SYSTEM_BLOCK, *PLOADER_SYSTEM_BLOCK;
62 
63 extern PLOADER_SYSTEM_BLOCK WinLdrSystemBlock;
64 
65 
66 // conversion.c
67 #if 0
68 PVOID VaToPa(PVOID Va);
69 PVOID PaToVa(PVOID Pa);
70 VOID List_PaToVa(_In_ LIST_ENTRY *ListEntry);
71 #endif
72 VOID ConvertConfigToVA(PCONFIGURATION_COMPONENT_DATA Start);
73 
74 
75 // winldr.c
76 extern BOOLEAN SosEnabled;
77 #ifdef _M_IX86
78 extern BOOLEAN PaeModeOn;
79 #endif
80 
81 FORCEINLINE
82 VOID
83 UiResetForSOS(VOID)
84 {
85 #ifdef _M_ARM
86     /* Re-initialize the UI */
87     UiInitialize(TRUE);
88 #else
89     /* Reset the UI and switch to MiniTui */
90     UiVtbl.UnInitialize();
91     UiVtbl = MiniTuiVtbl;
92     UiVtbl.Initialize();
93 #endif
94     /* Disable the progress bar */
95     UiProgressBar.Show = FALSE;
96 }
97 
98 VOID
99 NtLdrOutputLoadMsg(
100     _In_ PCSTR FileName,
101     _In_opt_ PCSTR Description);
102 
103 PVOID WinLdrLoadModule(PCSTR ModuleName, PULONG Size,
104                        TYPE_OF_MEMORY MemoryType);
105 
106 // wlmemory.c
107 BOOLEAN
108 WinLdrSetupMemoryLayout(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock);
109 
110 // wlregistry.c
111 BOOLEAN
112 WinLdrInitSystemHive(
113     IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
114     IN PCSTR SystemRoot,
115     IN BOOLEAN Setup);
116 
117 BOOLEAN WinLdrScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
118                              IN PCSTR SystemRoot);
119 
120 // winldr.c
121 VOID
122 WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock,
123                        PCSTR Options,
124                        PCSTR SystemPath,
125                        PCSTR BootPath,
126                        USHORT VersionToBoot);
127 BOOLEAN
128 WinLdrLoadNLSData(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
129                   IN PCSTR DirectoryPath,
130                   IN PCSTR AnsiFileName,
131                   IN PCSTR OemFileName,
132                   IN PCSTR LanguageFileName);
133 BOOLEAN
134 WinLdrAddDriverToList(LIST_ENTRY *BootDriverListHead,
135                       PWSTR RegistryPath,
136                       PWSTR ImagePath,
137                       PWSTR ServiceName);
138 
139 VOID
140 WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock);
141 
142 VOID
143 WinLdrpDumpBootDriver(PLOADER_PARAMETER_BLOCK LoaderBlock);
144 
145 VOID
146 WinLdrpDumpArcDisks(PLOADER_PARAMETER_BLOCK LoaderBlock);
147 
148 ARC_STATUS
149 LoadAndBootWindowsCommon(
150     IN USHORT OperatingSystemVersion,
151     IN PLOADER_PARAMETER_BLOCK LoaderBlock,
152     IN PCSTR BootOptions,
153     IN PCSTR BootPath);
154 
155 VOID
156 WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock);
157 
158 VOID
159 WinLdrSetProcessorContext(VOID);
160 
161 // arch/xxx/winldr.c
162 BOOLEAN
163 MempSetupPaging(IN PFN_NUMBER StartPage,
164                 IN PFN_NUMBER NumberOfPages,
165                 IN BOOLEAN KernelMapping);
166 
167 VOID
168 MempUnmapPage(PFN_NUMBER Page);
169 
170 VOID
171 MempDump(VOID);
172