diff --git a/boot/freeldr/freeldr/CMakeLists.txt b/boot/freeldr/freeldr/CMakeLists.txt index d4263050ad4..0f6947b3b0d 100644 --- a/boot/freeldr/freeldr/CMakeLists.txt +++ b/boot/freeldr/freeldr/CMakeLists.txt @@ -40,6 +40,8 @@ list(APPEND FREELDR_BOOTLIB_SOURCE lib/arcsupp.c lib/debug.c lib/peloader.c + lib/cache/blocklist.c + lib/cache/cache.c lib/comm/rs232.c ## add KD support lib/fs/btrfs.c @@ -64,10 +66,8 @@ list(APPEND FREELDR_NTLDR_SOURCE list(APPEND FREELDR_ARC_SOURCE arcname.c - machine.c + arch/arcemul.c arch/archwsup.c - cache/blocklist.c - cache/cache.c disk/disk.c disk/partition.c disk/ramdisk.c) @@ -89,9 +89,7 @@ list(APPEND FREELDR_BOOTMGR_SOURCE ui/tui.c ui/tuimenu.c ui/ui.c - video/fade.c - video/palette.c - video/video.c) + ui/video.c) list(APPEND FREELDR_BASE_ASM_SOURCE) @@ -226,7 +224,7 @@ list(APPEND FREELDR_BASE_SOURCE ## even if ${FREELDR_NTLDR_SOURCE} is not added, ## otherwise we get linking errors with Rtl**Bitmap** APIs. ## Do not happen on MSVC builds however... - lib/inffile/inffile.c + ntldr/inffile.c lib/rtl/libsupp.c) if(ARCH STREQUAL "i386") diff --git a/boot/freeldr/freeldr/machine.c b/boot/freeldr/freeldr/arch/arcemul.c similarity index 100% rename from boot/freeldr/freeldr/machine.c rename to boot/freeldr/freeldr/arch/arcemul.c diff --git a/boot/freeldr/freeldr/arch/i386/machpc.c b/boot/freeldr/freeldr/arch/i386/machpc.c index 5ec2195638a..0d17add29c6 100644 --- a/boot/freeldr/freeldr/arch/i386/machpc.c +++ b/boot/freeldr/freeldr/arch/i386/machpc.c @@ -1215,6 +1215,12 @@ DetectPS2Mouse(PCONFIGURATION_COMPONENT_DATA BusKey) } } + +// Implemented in i386vid.c, returns the VESA version +USHORT BiosIsVesaSupported(VOID); +BOOLEAN BiosIsVesaDdcSupported(VOID); +BOOLEAN BiosVesaReadEdid(VOID); + static VOID DetectDisplayController(PCONFIGURATION_COMPONENT_DATA BusKey) { diff --git a/boot/freeldr/freeldr/include/freeldr.h b/boot/freeldr/freeldr/include/freeldr.h index 841fd4c64ee..67966616442 100644 --- a/boot/freeldr/freeldr/include/freeldr.h +++ b/boot/freeldr/freeldr/include/freeldr.h @@ -65,7 +65,6 @@ #include #include #include -#include #include #include #include @@ -79,11 +78,11 @@ #include #include #include -#include /* NTOS loader */ -#include +#include #include // More-or-less related to MM also... +#include /* File system headers */ #include @@ -98,6 +97,7 @@ #include #include #include +#include /* Arch specific includes */ #include diff --git a/boot/freeldr/freeldr/include/fs.h b/boot/freeldr/freeldr/include/fs.h index 9c68c791e17..5c5fdd4f425 100644 --- a/boot/freeldr/freeldr/include/fs.h +++ b/boot/freeldr/freeldr/include/fs.h @@ -19,6 +19,9 @@ #pragma once +// FIXME: This one has nothing to do here!! +#define SECTOR_SIZE 512 + typedef struct tagDEVVTBL { ARC_CLOSE Close; diff --git a/boot/freeldr/freeldr/include/ntldr/winldr.h b/boot/freeldr/freeldr/include/ntldr/winldr.h new file mode 100644 index 00000000000..42ee1ba1da1 --- /dev/null +++ b/boot/freeldr/freeldr/include/ntldr/winldr.h @@ -0,0 +1,62 @@ +/* + * 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 + */ + +#pragma once + +#include + +// See freeldr/ntldr/winldr.h +#define TAG_WLDR_DTE 'eDlW' +#define TAG_WLDR_BDE 'dBlW' +#define TAG_WLDR_NAME 'mNlW' + +// Some definitions + +#include +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 + +typedef struct _ARC_DISK_SIGNATURE_EX +{ + ARC_DISK_SIGNATURE DiskSignature; + CHAR ArcName[MAX_PATH]; +} ARC_DISK_SIGNATURE_EX, *PARC_DISK_SIGNATURE_EX; + +//////////////////////////////////////////////////////////////////////////////// +// +// ReactOS Loading Functions +// +//////////////////////////////////////////////////////////////////////////////// + +ARC_STATUS +LoadAndBootWindows( + IN ULONG Argc, + IN PCHAR Argv[], + IN PCHAR Envp[]); + +ARC_STATUS +LoadReactOSSetup( + IN ULONG Argc, + IN PCHAR Argv[], + IN PCHAR Envp[]); + + +// conversion.c and conversion.h +PVOID VaToPa(PVOID Va); +PVOID PaToVa(PVOID Pa); +VOID List_PaToVa(_In_ LIST_ENTRY *ListEntry); diff --git a/boot/freeldr/freeldr/include/peloader.h b/boot/freeldr/freeldr/include/peloader.h new file mode 100644 index 00000000000..9d4b1178819 --- /dev/null +++ b/boot/freeldr/freeldr/include/peloader.h @@ -0,0 +1,41 @@ +/* + * PROJECT: FreeLoader + * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) + * PURPOSE: Provides routines for loading PE files. + * (Deprecated remark) To be merged with arch/i386/loader.c in future. + * + * COPYRIGHT: Copyright 1998-2003 Brian Palmer + * Copyright 2006-2019 Aleksey Bragin + * + * NOTES: The source code in this file is based on the work of respective + * authors of PE loading code in ReactOS and Brian Palmer and + * Alex Ionescu's arch/i386/loader.c, and my research project + * (creating a native EFI loader for Windows). + * + * This article was very handy during development: + * http://msdn.microsoft.com/msdnmag/issues/02/03/PE2/ + */ + +#pragma once + +BOOLEAN +WinLdrLoadImage(IN PCHAR FileName, + TYPE_OF_MEMORY MemoryType, + OUT PVOID *ImageBasePA); + +BOOLEAN +WinLdrAllocateDataTableEntry(IN OUT PLIST_ENTRY ModuleListHead, + IN PCCH BaseDllName, + IN PCCH FullDllName, + IN PVOID BasePA, + OUT PLDR_DATA_TABLE_ENTRY *NewEntry); + +BOOLEAN +WinLdrScanImportDescriptorTable(IN OUT PLIST_ENTRY ModuleListHead, + IN PCCH DirectoryPath, + IN PLDR_DATA_TABLE_ENTRY ScanDTE); + +BOOLEAN +WinLdrCheckForLoadedDll(IN OUT PLIST_ENTRY ModuleListHead, + IN PCH DllName, + OUT PLDR_DATA_TABLE_ENTRY *LoadedEntry); diff --git a/boot/freeldr/freeldr/include/ui/video.h b/boot/freeldr/freeldr/include/ui/video.h new file mode 100644 index 00000000000..0e0f4ec3828 --- /dev/null +++ b/boot/freeldr/freeldr/include/ui/video.h @@ -0,0 +1,29 @@ +/* + * PROJECT: FreeLoader + * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) + * PURPOSE: UI Video helpers for special effects. + * COPYRIGHT: Copyright 1998-2003 Brian Palmer + */ + +#pragma once + +#include +typedef struct _PALETTE_ENTRY +{ + UCHAR Red; + UCHAR Green; + UCHAR Blue; +} PALETTE_ENTRY, *PPALETTE_ENTRY; +#include + +// extern PVOID VideoOffScreenBuffer; + +PVOID VideoAllocateOffScreenBuffer(VOID); // Returns a pointer to an off-screen buffer sufficient for the current video mode +VOID VideoCopyOffScreenBufferToVRAM(VOID); + +VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount); +VOID VideoRestorePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount); + +VOID VideoSetAllColorsToBlack(ULONG ColorCount); +VOID VideoFadeIn(PPALETTE_ENTRY Palette, ULONG ColorCount); +VOID VideoFadeOut(ULONG ColorCount); diff --git a/boot/freeldr/freeldr/include/video.h b/boot/freeldr/freeldr/include/video.h deleted file mode 100644 index 6162a47ecf9..00000000000 --- a/boot/freeldr/freeldr/include/video.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * FreeLoader - * Copyright (C) 1998-2003 Brian Palmer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#pragma once - -#include -typedef struct -{ - UCHAR Red; - UCHAR Green; - UCHAR Blue; -} PALETTE_ENTRY, *PPALETTE_ENTRY; -#include - -extern PVOID VideoOffScreenBuffer; - -USHORT BiosIsVesaSupported(VOID); // Implemented in i386vid.c, returns the VESA version -BOOLEAN BiosIsVesaDdcSupported(VOID); -BOOLEAN BiosVesaReadEdid(VOID); - -PVOID VideoAllocateOffScreenBuffer(VOID); // Returns a pointer to an off-screen buffer sufficient for the current video mode - -VOID VideoCopyOffScreenBufferToVRAM(VOID); - -VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount); -VOID VideoRestorePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount); - -VOID VideoSetAllColorsToBlack(ULONG ColorCount); -VOID VideoFadeIn(PPALETTE_ENTRY Palette, ULONG ColorCount); -VOID VideoFadeOut(ULONG ColorCount); diff --git a/boot/freeldr/freeldr/include/winldr.h b/boot/freeldr/freeldr/include/winldr.h deleted file mode 100644 index 7bd4b581f05..00000000000 --- a/boot/freeldr/freeldr/include/winldr.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * FreeLoader - * Copyright (C) 1998-2003 Brian Palmer - * Copyright (C) 2006 Aleksey Bragin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#pragma once - -#include - -// See freeldr/ntldr/winldr.h -#define TAG_WLDR_DTE 'eDlW' -#define TAG_WLDR_BDE 'dBlW' -#define TAG_WLDR_NAME 'mNlW' - - -// Some definitions - -// FIXME: This one has nothing to do here!! -#define SECTOR_SIZE 512 - -// Descriptors -#define NUM_GDT 128 // Must be 128 -#define NUM_IDT 0x100 // Only 16 are used though. Must be 0x100 - -#include -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 - -typedef struct _ARC_DISK_SIGNATURE_EX -{ - ARC_DISK_SIGNATURE DiskSignature; - CHAR ArcName[MAX_PATH]; -} ARC_DISK_SIGNATURE_EX, *PARC_DISK_SIGNATURE_EX; - -//////////////////////////////////////////////////////////////////////////////// -// -// ReactOS Loading Functions -// -//////////////////////////////////////////////////////////////////////////////// - -ARC_STATUS -LoadAndBootWindows( - IN ULONG Argc, - IN PCHAR Argv[], - IN PCHAR Envp[]); - -ARC_STATUS -LoadReactOSSetup( - IN ULONG Argc, - IN PCHAR Argv[], - IN PCHAR Envp[]); - - -// conversion.c and conversion.h -PVOID VaToPa(PVOID Va); -PVOID PaToVa(PVOID Pa); -VOID List_PaToVa(_In_ LIST_ENTRY *ListEntry); - - -// peloader.c -BOOLEAN -WinLdrLoadImage(IN PCHAR FileName, - TYPE_OF_MEMORY MemoryType, - OUT PVOID *ImageBasePA); - -BOOLEAN -WinLdrAllocateDataTableEntry(IN OUT PLIST_ENTRY ModuleListHead, - IN PCCH BaseDllName, - IN PCCH FullDllName, - IN PVOID BasePA, - OUT PLDR_DATA_TABLE_ENTRY *NewEntry); - -BOOLEAN -WinLdrScanImportDescriptorTable(IN OUT PLIST_ENTRY ModuleListHead, - IN PCCH DirectoryPath, - IN PLDR_DATA_TABLE_ENTRY ScanDTE); - -BOOLEAN -WinLdrCheckForLoadedDll(IN OUT PLIST_ENTRY ModuleListHead, - IN PCH DllName, - OUT PLDR_DATA_TABLE_ENTRY *LoadedEntry); - - -// 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); - -VOID -WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock); - -VOID -WinLdrSetProcessorContext(VOID); diff --git a/boot/freeldr/freeldr/cache/blocklist.c b/boot/freeldr/freeldr/lib/cache/blocklist.c similarity index 100% rename from boot/freeldr/freeldr/cache/blocklist.c rename to boot/freeldr/freeldr/lib/cache/blocklist.c diff --git a/boot/freeldr/freeldr/cache/cache.c b/boot/freeldr/freeldr/lib/cache/cache.c similarity index 100% rename from boot/freeldr/freeldr/cache/cache.c rename to boot/freeldr/freeldr/lib/cache/cache.c diff --git a/boot/freeldr/freeldr/lib/peloader.c b/boot/freeldr/freeldr/lib/peloader.c index 7f913f1c8d6..cf90eb851e7 100644 --- a/boot/freeldr/freeldr/lib/peloader.c +++ b/boot/freeldr/freeldr/lib/peloader.c @@ -1,27 +1,30 @@ /* - * PROJECT: FreeLoader - * LICENSE: GPL - See COPYING in the top level directory - * FILE: boot/freeldr/freeldr/windows/peloader.c - * PURPOSE: Provides routines for loading PE files. - * (Deprecated remark) To be merged with arch/i386/loader.c in future. + * PROJECT: FreeLoader + * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) + * PURPOSE: Provides routines for loading PE files. + * (Deprecated remark) To be merged with arch/i386/loader.c in future. * - * PROGRAMMERS: Aleksey Bragin (aleksey@reactos.org) + * COPYRIGHT: Copyright 1998-2003 Brian Palmer + * Copyright 2006-2019 Aleksey Bragin * - * The source code in this file is based on the work of respective - * authors of PE loading code in ReactOS and Brian Palmer and - * Alex Ionescu's arch/i386/loader.c, and my research project - * (creating a native EFI loader for Windows). + * NOTES: The source code in this file is based on the work of respective + * authors of PE loading code in ReactOS and Brian Palmer and + * Alex Ionescu's arch/i386/loader.c, and my research project + * (creating a native EFI loader for Windows). * - * NOTE: This article was very handy during development: - * http://msdn.microsoft.com/msdnmag/issues/02/03/PE2/ + * This article was very handy during development: + * http://msdn.microsoft.com/msdnmag/issues/02/03/PE2/ */ /* INCLUDES ***************************************************************/ + #include #include DBG_DEFAULT_CHANNEL(PELOADER); +/* FUNCTIONS **************************************************************/ + static BOOLEAN WinLdrpCompareDllName(IN PCH DllName, IN PUNICODE_STRING UnicodeName); @@ -50,9 +53,6 @@ WinLdrpScanImportAddressTable(IN OUT PLIST_ENTRY ModuleListHead, IN PCSTR DirectoryPath); - -/* FUNCTIONS **************************************************************/ - /* Returns TRUE if DLL has already been loaded - looks in LoadOrderList in LPB */ BOOLEAN WinLdrCheckForLoadedDll(IN OUT PLIST_ENTRY ModuleListHead, diff --git a/boot/freeldr/freeldr/ntldr/arch/amd64/winldr.c b/boot/freeldr/freeldr/ntldr/arch/amd64/winldr.c index 784f0e6c5ee..9540c63370a 100644 --- a/boot/freeldr/freeldr/ntldr/arch/amd64/winldr.c +++ b/boot/freeldr/freeldr/ntldr/arch/amd64/winldr.c @@ -9,14 +9,14 @@ /* INCLUDES ***************************************************************/ #include - #include +#include "../../winldr.h" + #include +DBG_DEFAULT_CHANNEL(WINDOWS); //extern ULONG LoaderPagesSpanned; -DBG_DEFAULT_CHANNEL(WINDOWS); - /* GLOBALS ***************************************************************/ PHARDWARE_PTE PxeBase; diff --git a/boot/freeldr/freeldr/ntldr/arch/arm/winldr.c b/boot/freeldr/freeldr/ntldr/arch/arm/winldr.c index 5ca93f02bd5..0bb69147e37 100644 --- a/boot/freeldr/freeldr/ntldr/arch/arm/winldr.c +++ b/boot/freeldr/freeldr/ntldr/arch/arm/winldr.c @@ -12,6 +12,7 @@ #include #include #include +#include "../../winldr.h" #define PFN_SHIFT 12 #define LARGE_PFN_SHIFT 20 diff --git a/boot/freeldr/freeldr/ntldr/arch/i386/winldr.c b/boot/freeldr/freeldr/ntldr/arch/i386/winldr.c index 5e289d19dd7..c3917709b32 100644 --- a/boot/freeldr/freeldr/ntldr/arch/i386/winldr.c +++ b/boot/freeldr/freeldr/ntldr/arch/i386/winldr.c @@ -9,9 +9,11 @@ /* INCLUDES ***************************************************************/ #include - #include +#include "../../winldr.h" + #include +DBG_DEFAULT_CHANNEL(WINDOWS); // This is needed because headers define wrong one for ReactOS #undef KIP0PCRADDRESS @@ -28,8 +30,6 @@ } GDTIDT; #pragma pack(4) -DBG_DEFAULT_CHANNEL(WINDOWS); - /* GLOBALS ***************************************************************/ PHARDWARE_PTE PDE; diff --git a/boot/freeldr/freeldr/lib/inffile/inffile.c b/boot/freeldr/freeldr/ntldr/inffile.c similarity index 96% rename from boot/freeldr/freeldr/lib/inffile/inffile.c rename to boot/freeldr/freeldr/ntldr/inffile.c index 3ca695ee98a..950accbe8a8 100644 --- a/boot/freeldr/freeldr/lib/inffile/inffile.c +++ b/boot/freeldr/freeldr/ntldr/inffile.c @@ -1,33 +1,15 @@ /* - * ReactOS kernel - * Copyright (C) 2002,2003 ReactOS Team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS text-mode setup - * FILE: boot/freeldr/freeldr/lib/inffile/inffile.c - * PURPOSE: INF file parser that caches contents of INF file in memory - * PROGRAMMER: Royce Mitchell III - * Eric Kohl + * PROJECT: FreeLoader + * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) + * PURPOSE: INF file parser that caches contents of INF file in memory. + * COPYRIGHT: Copyright 2002-2006 Royce Mitchell III + * Copyright 2003-2019 Eric Kohl */ /* INCLUDES *****************************************************************/ #include +#include "inffile.h" #define CONTROL_Z '\x1a' #define MAX_SECTION_NAME_LEN 255 diff --git a/boot/freeldr/freeldr/include/inffile.h b/boot/freeldr/freeldr/ntldr/inffile.h similarity index 64% rename from boot/freeldr/freeldr/include/inffile.h rename to boot/freeldr/freeldr/ntldr/inffile.h index 766f0125c70..be1ae482340 100644 --- a/boot/freeldr/freeldr/include/inffile.h +++ b/boot/freeldr/freeldr/ntldr/inffile.h @@ -1,28 +1,9 @@ /* - * ReactOS kernel - * Copyright (C) 2002, 2003 ReactOS Team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS text-mode setup - * FILE: boot/freeldr/freeldr/include/inffile.h - * PURPOSE: INF file parser that caches contents of INF file in memory - * PROGRAMMER: Royce Mitchell III - * Eric Kohl + * PROJECT: FreeLoader + * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) + * PURPOSE: INF file parser that caches contents of INF file in memory. + * COPYRIGHT: Copyright 2002-2006 Royce Mitchell III + * Copyright 2003-2019 Eric Kohl */ #pragma once diff --git a/boot/freeldr/freeldr/ntldr/setupldr.c b/boot/freeldr/freeldr/ntldr/setupldr.c index 95c70acb347..c1836fff223 100644 --- a/boot/freeldr/freeldr/ntldr/setupldr.c +++ b/boot/freeldr/freeldr/ntldr/setupldr.c @@ -1,32 +1,19 @@ /* - * FreeLoader - * - * Copyright (C) 2009 Aleksey Bragin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * PROJECT: FreeLoader + * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) + * PURPOSE: Windows-compatible NT OS Setup Loader. + * COPYRIGHT: Copyright 2009-2019 Aleksey Bragin */ #include -#include "winldr.h" - #include #include +#include "winldr.h" +#include "inffile.h" #include - DBG_DEFAULT_CHANNEL(WINDOWS); + #define TAG_BOOT_OPTIONS 'pOtB' // TODO: Move to .h diff --git a/boot/freeldr/freeldr/ntldr/winldr.c b/boot/freeldr/freeldr/ntldr/winldr.c index e68a6027e86..b114adbef27 100644 --- a/boot/freeldr/freeldr/ntldr/winldr.c +++ b/boot/freeldr/freeldr/ntldr/winldr.c @@ -1,30 +1,15 @@ /* - * FreeLoader - * - * Copyright (C) 1998-2003 Brian Palmer - * Copyright (C) 2006 Aleksey Bragin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * 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 */ #include +#include #include "winldr.h" #include "registry.h" -#include - #include DBG_DEFAULT_CHANNEL(WINDOWS); diff --git a/boot/freeldr/freeldr/ntldr/winldr.h b/boot/freeldr/freeldr/ntldr/winldr.h index 0471775304c..a2af29ff5a3 100644 --- a/boot/freeldr/freeldr/ntldr/winldr.h +++ b/boot/freeldr/freeldr/ntldr/winldr.h @@ -1,47 +1,23 @@ /* - * FreeLoader - * Copyright (C) 1998-2003 Brian Palmer - * Copyright (C) 2006 Aleksey Bragin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * 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 */ #pragma once #include -#if 0 -// See freeldr/include/winldr.h -#define TAG_WLDR_DTE 'eDlW' -#define TAG_WLDR_BDE 'dBlW' -#define TAG_WLDR_NAME 'mNlW' - -#endif - /* Entry-point to kernel */ typedef VOID (NTAPI *KERNEL_ENTRY_POINT) (PLOADER_PARAMETER_BLOCK LoaderBlock); - -// Some definitions - -#if 0 - -// Descriptors +/* Descriptors */ #define NUM_GDT 128 // Must be 128 #define NUM_IDT 0x100 // Only 16 are used though. Must be 0x100 +#if 0 + #include typedef struct /* Root System Descriptor Pointer */ { @@ -149,3 +125,21 @@ LoadAndBootWindowsCommon( PCSTR BootOptions, PCSTR BootPath, BOOLEAN Setup); + +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); diff --git a/boot/freeldr/freeldr/video/fade.c b/boot/freeldr/freeldr/ui/video.c similarity index 56% rename from boot/freeldr/freeldr/video/fade.c rename to boot/freeldr/freeldr/ui/video.c index 439718ab5d4..d44f8ee1eed 100644 --- a/boot/freeldr/freeldr/video/fade.c +++ b/boot/freeldr/freeldr/ui/video.c @@ -1,35 +1,72 @@ /* - * FreeLoader - * Copyright (C) 1998-2003 Brian Palmer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * PROJECT: FreeLoader + * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) + * PURPOSE: UI Video helpers for special effects. + * COPYRIGHT: Copyright 1998-2003 Brian Palmer */ + #ifndef _M_ARM #include -#define RGB_MAX 64 -#define RGB_MAX_PER_ITERATION 64 -#define TAG_PALETTE_COLORS 'claP' +#define RGB_MAX 64 +#define RGB_MAX_PER_ITERATION 64 +#define TAG_PALETTE_COLORS 'claP' -VOID VideoSetAllColorsToBlack(ULONG ColorCount) +static PVOID VideoOffScreenBuffer = NULL; + +PVOID VideoAllocateOffScreenBuffer(VOID) { - UCHAR Color; + ULONG BufferSize; + + if (VideoOffScreenBuffer != NULL) + { + MmFreeMemory(VideoOffScreenBuffer); + VideoOffScreenBuffer = NULL; + } + + BufferSize = MachVideoGetBufferSize(); + + VideoOffScreenBuffer = MmAllocateMemoryWithType(BufferSize, LoaderFirmwareTemporary); + + return VideoOffScreenBuffer; +} + +VOID VideoCopyOffScreenBufferToVRAM(VOID) +{ + MachVideoCopyOffScreenBufferToVRAM(VideoOffScreenBuffer); +} + + +VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount) +{ + ULONG Color; + + for (Color = 0; Color < ColorCount; Color++) + { + MachVideoGetPaletteColor((UCHAR)Color, &Palette[Color].Red, &Palette[Color].Green, &Palette[Color].Blue); + } +} + +VOID VideoRestorePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount) +{ + ULONG Color; MachVideoSync(); - for (Color=0; Color - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef _M_ARM -#include -VOID VideoSavePaletteState(PPALETTE_ENTRY Palette, ULONG ColorCount) -{ - ULONG Color; - - for (Color=0; Color - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef _M_ARM -#include - -PVOID VideoOffScreenBuffer = NULL; - -PVOID VideoAllocateOffScreenBuffer(VOID) -{ - ULONG BufferSize; - - if (VideoOffScreenBuffer != NULL) - { - MmFreeMemory(VideoOffScreenBuffer); - VideoOffScreenBuffer = NULL; - } - - BufferSize = MachVideoGetBufferSize(); - - VideoOffScreenBuffer = MmAllocateMemoryWithType(BufferSize, LoaderFirmwareTemporary); - - return VideoOffScreenBuffer; -} - -VOID VideoCopyOffScreenBufferToVRAM(VOID) -{ - MachVideoCopyOffScreenBufferToVRAM(VideoOffScreenBuffer); -} -#endif