reactos/boot/freeldr/freeldr/ntldr/winldr.h

182 lines
4.7 KiB
C
Raw Normal View History

/*
* PROJECT: FreeLoader
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Windows-compatible NT OS Loader.
* COPYRIGHT: Copyright 2006-2019 Aleksey Bragin <aleksey@reactos.org>
*/
#pragma once
#include <arc/setupblk.h>
/* Entry-point to kernel */
typedef VOID (NTAPI *KERNEL_ENTRY_POINT) (PLOADER_PARAMETER_BLOCK LoaderBlock);
/* Descriptors */
#define NUM_GDT 128 // Must be 128
#define NUM_IDT 0x100 // Only 16 are used though. Must be 0x100
#if 0
#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_PERFORMANCE_DATA LoaderPerformanceData;
} LOADER_SYSTEM_BLOCK, *PLOADER_SYSTEM_BLOCK;
extern PLOADER_SYSTEM_BLOCK WinLdrSystemBlock;
/**/extern PCWSTR BootFileSystem;/**/
// 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
extern BOOLEAN SosEnabled;
#ifdef _M_IX86
extern BOOLEAN PaeModeOn;
#endif
FORCEINLINE
VOID
UiResetForSOS(VOID)
{
#ifdef _M_ARM
/* Re-initialize the UI */
UiInitialize(TRUE);
#else
/* Reset the UI and switch to MiniTui */
UiVtbl.UnInitialize();
UiVtbl = MiniTuiVtbl;
UiVtbl.Initialize();
#endif
/* Disable the progress bar */
UiProgressBar.Show = FALSE;
}
VOID
NtLdrOutputLoadMsg(
_In_ PCSTR FileName,
_In_opt_ PCSTR Description);
PVOID WinLdrLoadModule(PCSTR ModuleName, PULONG 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,
2019-08-10 17:47:49 +00:00
IN PCSTR SystemRoot);
BOOLEAN
WinLdrLoadNLSData(
_Inout_ PLOADER_PARAMETER_BLOCK LoaderBlock,
_In_ PCSTR DirectoryPath,
_In_ PCUNICODE_STRING AnsiFileName,
_In_ PCUNICODE_STRING OemFileName,
_In_ PCUNICODE_STRING LangFileName, // CaseTable
_In_ PCUNICODE_STRING OemHalFileName);
BOOLEAN
WinLdrAddDriverToList(
_Inout_ PLIST_ENTRY DriverListHead,
_In_ BOOLEAN InsertAtHead,
_In_ PCWSTR DriverName,
_In_opt_ PCWSTR ImagePath,
_In_opt_ PCWSTR GroupName,
_In_ ULONG ErrorControl,
_In_ ULONG Tag);
// winldr.c
VOID
WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock,
PCSTR Options,
PCSTR SystemPath,
PCSTR BootPath,
USHORT VersionToBoot);
VOID
WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock);
VOID
WinLdrpDumpBootDriver(PLOADER_PARAMETER_BLOCK LoaderBlock);
VOID
WinLdrpDumpArcDisks(PLOADER_PARAMETER_BLOCK LoaderBlock);
[FREELDR] Some ARC-spec compatibility refactoring + simplifications & fixes. CORE-9023 - During loading and initialization of the list of operating systems available in freeldr.ini, convert any legacy operating system entry encountered -- they are like those in NTLDR's boot.ini file, i.e.: ArcOsLoadPartition="LoadIdentifier" /List /of /Options into a new operating system INI entry, like those used by default in FreeLoader. This allows us to avoid treating this corner-case later in different parts of the code. Also, the "BootType" value is now determined there, only once. - Convert the OS loaders entry-points to ARC-compatible ones, following the "Advanced RISC Computing Specification, Version 1.2" specification https://www.netbsd.org/docs/Hardware/Machines/ARC/riscspec.pdf - Introduce helpers for retrieving options values from the argument vector in a simple way. - Simplify LoadOperatingSystem(), since now the "BootType" value has been determined once while loading the list of OSes (see above) and is well-defined there. Use the BuildArgvForOsLoader() helper to build the ARC-compatible argument vector from the corresponding INI settings for the selected operating system entry, and use it when calling the corresponding OS loader. - In the OS loaders, since we can now directly read the settings from the argument vector (instead of using INI settings), we can avoid using a bunch of fixed-size string buffers, and avoid potentially failing IniOpenSection() calls as well. - Simplify code in the Linux loader (and the RemoveQuotes() function). - Add UiShowMessageBoxesInArgv() that acts on the "MessageBox=" settings passed through the argument vector (equivalent to UiShowMessageBoxesInSection() ). - Use string-safe functions where needed (copy/concatenation/printf on fixed-size buffers).
2019-08-06 20:30:54 +00:00
ARC_STATUS
LoadAndBootWindowsCommon(
IN USHORT OperatingSystemVersion,
IN PLOADER_PARAMETER_BLOCK LoaderBlock,
IN PCSTR BootOptions,
IN PCSTR BootPath);
VOID
WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock);
VOID
WinLdrSetProcessorContext(
_In_ USHORT OperatingSystemVersion);
// arch/xxx/winldr.c
BOOLEAN
MempSetupPaging(IN PFN_NUMBER StartPage,
IN PFN_NUMBER NumberOfPages,
IN BOOLEAN KernelMapping);
VOID
MempUnmapPage(PFN_NUMBER Page);
VOID
MempDump(VOID);