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 PVOID WinLdrLoadModule(PCSTR ModuleName, PULONG Size, 77 TYPE_OF_MEMORY MemoryType); 78 79 // wlmemory.c 80 BOOLEAN 81 WinLdrSetupMemoryLayout(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock); 82 83 // wlregistry.c 84 BOOLEAN 85 WinLdrInitSystemHive( 86 IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, 87 IN PCSTR SystemRoot, 88 IN BOOLEAN Setup); 89 90 BOOLEAN WinLdrScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, 91 IN PCSTR SystemRoot); 92 93 // winldr.c 94 VOID 95 WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock, 96 PCSTR Options, 97 PCSTR SystemPath, 98 PCSTR BootPath, 99 USHORT VersionToBoot); 100 BOOLEAN 101 WinLdrLoadNLSData(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, 102 IN PCSTR DirectoryPath, 103 IN PCSTR AnsiFileName, 104 IN PCSTR OemFileName, 105 IN PCSTR LanguageFileName); 106 BOOLEAN 107 WinLdrAddDriverToList(LIST_ENTRY *BootDriverListHead, 108 PWSTR RegistryPath, 109 PWSTR ImagePath, 110 PWSTR ServiceName); 111 112 VOID 113 WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock); 114 115 VOID 116 WinLdrpDumpBootDriver(PLOADER_PARAMETER_BLOCK LoaderBlock); 117 118 VOID 119 WinLdrpDumpArcDisks(PLOADER_PARAMETER_BLOCK LoaderBlock); 120 121 ARC_STATUS 122 LoadAndBootWindowsCommon( 123 USHORT OperatingSystemVersion, 124 PLOADER_PARAMETER_BLOCK LoaderBlock, 125 PCSTR BootOptions, 126 PCSTR BootPath, 127 BOOLEAN Setup); 128 129 VOID 130 WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock); 131 132 VOID 133 WinLdrSetProcessorContext(VOID); 134 135 // arch/xxx/winldr.c 136 BOOLEAN 137 MempSetupPaging(IN PFN_NUMBER StartPage, 138 IN PFN_NUMBER NumberOfPages, 139 IN BOOLEAN KernelMapping); 140 141 VOID 142 MempUnmapPage(PFN_NUMBER Page); 143 144 VOID 145 MempDump(VOID); 146