2017-06-02 00:52:36 +00:00
|
|
|
/*
|
2019-08-11 16:56:40 +00:00
|
|
|
* 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>
|
2017-06-02 00:52:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <arc/setupblk.h>
|
|
|
|
|
|
|
|
/* Entry-point to kernel */
|
|
|
|
typedef VOID (NTAPI *KERNEL_ENTRY_POINT) (PLOADER_PARAMETER_BLOCK LoaderBlock);
|
|
|
|
|
2019-08-11 16:56:40 +00:00
|
|
|
/* Descriptors */
|
2017-06-02 00:52:36 +00:00
|
|
|
#define NUM_GDT 128 // Must be 128
|
|
|
|
#define NUM_IDT 0x100 // Only 16 are used though. Must be 0x100
|
|
|
|
|
2019-08-11 16:56:40 +00:00
|
|
|
#if 0
|
|
|
|
|
2017-06-02 00:52:36 +00:00
|
|
|
#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_SYSTEM_BLOCK, *PLOADER_SYSTEM_BLOCK;
|
|
|
|
|
|
|
|
extern PLOADER_SYSTEM_BLOCK WinLdrSystemBlock;
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
2019-08-10 17:13:20 +00:00
|
|
|
PVOID WinLdrLoadModule(PCSTR ModuleName, PULONG Size,
|
2017-06-02 00:52:36 +00:00
|
|
|
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);
|
2017-06-02 00:52:36 +00:00
|
|
|
|
|
|
|
// winldr.c
|
|
|
|
VOID
|
|
|
|
WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock,
|
2019-08-10 17:13:20 +00:00
|
|
|
PCSTR Options,
|
|
|
|
PCSTR SystemPath,
|
|
|
|
PCSTR BootPath,
|
2017-06-02 00:52:36 +00:00
|
|
|
USHORT VersionToBoot);
|
|
|
|
BOOLEAN
|
|
|
|
WinLdrLoadNLSData(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
|
2019-08-10 17:13:20 +00:00
|
|
|
IN PCSTR DirectoryPath,
|
|
|
|
IN PCSTR AnsiFileName,
|
|
|
|
IN PCSTR OemFileName,
|
|
|
|
IN PCSTR LanguageFileName);
|
2017-06-02 00:52:36 +00:00
|
|
|
BOOLEAN
|
|
|
|
WinLdrAddDriverToList(LIST_ENTRY *BootDriverListHead,
|
2019-08-10 17:47:49 +00:00
|
|
|
PWSTR RegistryPath,
|
|
|
|
PWSTR ImagePath,
|
|
|
|
PWSTR ServiceName);
|
2017-06-02 00:52:36 +00:00
|
|
|
|
|
|
|
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
|
2017-06-02 00:52:36 +00:00
|
|
|
LoadAndBootWindowsCommon(
|
2020-11-02 23:13:05 +00:00
|
|
|
IN USHORT OperatingSystemVersion,
|
|
|
|
IN PLOADER_PARAMETER_BLOCK LoaderBlock,
|
|
|
|
IN PCSTR BootOptions,
|
|
|
|
IN PCSTR BootPath);
|
2019-08-11 16:56:40 +00:00
|
|
|
|
|
|
|
VOID
|
|
|
|
WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
WinLdrSetProcessorContext(VOID);
|
|
|
|
|
|
|
|
// 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);
|