[FREELDR]

Start splitting FreeLdr in the same spirit as our new UEFI boot manager/loader: split into a boot library, the boot manager code, and the NT loader.
- The boot library provides the basic support (read INI/INF files, memory management, debugging, ARC compatibility/emulation, ...).
- The boot manager code is FreeLdr proper.
- The NT loader is used for loading Windows or ReactOS. Because of that fact I rename its directory "windows" into "NTLDR" to underline the fact it can load NT-type OSes (more exactly version 5.x), to which both Windows 2k/XP/2k3 and ReactOS belong. The APIs will certainly be renamed "NtLdrXXX" instead of "WinLdrXXX".
- The general PE loader is put into the boot library since it is needed also by FreeLdr proper to be able to load SCSI drivers (on x86/64/... architectures; on ARC systems SCSI support is automatically provided).

svn path=/trunk/; revision=70692
This commit is contained in:
Hermès Bélusca-Maïto 2016-02-05 00:17:33 +00:00
parent ee1d2a2874
commit c62cd02730
29 changed files with 134 additions and 79 deletions

View file

@ -32,37 +32,55 @@ include_directories(${REACTOS_SOURCE_DIR}/include/reactos/elf)
add_definitions(-D_NTHAL_ -D_BLDR_ -D_NTSYSTEM_)
list(APPEND FREELDR_COMMON_SOURCE
include/freeldr.h
list(APPEND FREELDR_BOOTLIB_COMMON_SOURCE
lib/debug.c
lib/peloader.c
lib/comm/rs232.c
## add KD support
lib/fs/ext2.c
lib/fs/fat.c
lib/fs/fs.c
lib/fs/iso.c
lib/fs/ntfs.c
lib/inifile/ini_init.c
lib/inifile/inifile.c
lib/inifile/parse.c
lib/mm/meminit.c
lib/mm/mm.c
lib/mm/heap.c
)
list(APPEND FREELDR_NTLDR_COMMON_SOURCE
ntldr/conversion.c
ntldr/registry.c
ntldr/winldr.c
ntldr/wlmemory.c
ntldr/wlregistry.c
)
list(APPEND FREELDR_ARC_COMMON_SOURCE
arcname.c
cmdline.c
custom.c
debug.c
linuxboot.c
miscboot.c
machine.c
options.c
oslist.c
version.c
arch/archwsup.c
cache/blocklist.c
cache/cache.c
comm/rs232.c
disk/disk.c
disk/partition.c
disk/ramdisk.c
#disk/scsiport.c
fs/ext2.c
fs/fat.c
fs/fs.c
fs/iso.c
fs/ntfs.c
lib/inifile/ini_init.c
lib/inifile/inifile.c
lib/inifile/parse.c
mm/meminit.c
mm/mm.c
mm/heap.c
)
list(APPEND FREELDR_COMMON_SOURCE
include/freeldr.h
cmdline.c
custom.c
linuxboot.c
miscboot.c
options.c
oslist.c
version.c
ui/directui.c
ui/gui.c
ui/minitui.c
@ -73,12 +91,7 @@ list(APPEND FREELDR_COMMON_SOURCE
video/fade.c
video/palette.c
video/video.c
windows/conversion.c
windows/peloader.c
windows/registry.c
windows/winldr.c
windows/wlmemory.c
windows/wlregistry.c)
)
if(ARCH STREQUAL "i386")
list(APPEND FREELDR_COMMON_ASM_SOURCE
@ -86,9 +99,21 @@ if(ARCH STREQUAL "i386")
arch/i386/i386pnp.S
arch/i386/i386trap.S
arch/i386/linux.S
arch/i386/mb.S)
list(APPEND FREELDR_COMMON_SOURCE
fs/pxe.c
arch/i386/mb.S
)
list(APPEND FREELDR_NTLDR_COMMON_SOURCE
ntldr/arch/i386/winldr.c
ntldr/headless.c
)
## list(APPEND FREELDR_COMMON_SOURCE
list(APPEND FREELDR_ARC_COMMON_SOURCE
lib/fs/pxe.c
arch/i386/halstub.c
arch/i386/ntoskrnl.c
arch/i386/archmach.c
arch/i386/drivemap.c
arch/i386/hardware.c
@ -116,10 +141,6 @@ if(ARCH STREQUAL "i386")
arch/i386/xboxmem.c
arch/i386/xboxrtc.c
arch/i386/xboxvideo.c
windows/arch/i386/halstub.c
windows/arch/i386/ntoskrnl.c
windows/arch/i386/winldr.c
windows/headless.c
disk/scsiport.c)
if(NOT MSVC)
list(APPEND FREELDR_COMMON_ASM_SOURCE arch/i386/drvmap.S)
@ -129,8 +150,17 @@ elseif(ARCH STREQUAL "amd64")
arch/amd64/entry.S
arch/amd64/int386.S
arch/amd64/pnpbios.S)
list(APPEND FREELDR_COMMON_SOURCE
fs/pxe.c
list(APPEND FREELDR_NTLDR_COMMON_SOURCE
ntldr/arch/amd64/winldr.c
)
## list(APPEND FREELDR_COMMON_SOURCE
list(APPEND FREELDR_ARC_COMMON_SOURCE
lib/fs/pxe.c
arch/i386/ntoskrnl.c
arch/i386/drivemap.c
arch/i386/hardware.c
arch/i386/hwacpi.c
@ -146,22 +176,27 @@ elseif(ARCH STREQUAL "amd64")
arch/i386/pcdisk.c
arch/i386/pcmem.c
arch/i386/pcrtc.c
arch/i386/pcvideo.c
windows/arch/i386/ntoskrnl.c
windows/arch/amd64/winldr.c)
arch/i386/pcvideo.c)
elseif(ARCH STREQUAL "arm")
list(APPEND FREELDR_COMMON_ASM_SOURCE
arch/arm/boot.S)
list(APPEND FREELDR_COMMON_SOURCE
list(APPEND FREELDR_NTLDR_COMMON_SOURCE
ntldr/arch/arm/winldr.c
)
## list(APPEND FREELDR_COMMON_SOURCE
list(APPEND FREELDR_ARC_COMMON_SOURCE
arch/arm/entry.c
arch/arm/macharm.c
windows/arch/arm/winldr.c)
arch/arm/macharm.c)
else()
#TBD
endif()
add_asm_files(freeldr_common_asm ${FREELDR_COMMON_ASM_SOURCE})
add_library(freeldr_common ${FREELDR_COMMON_SOURCE} ${freeldr_common_asm})
add_library(freeldr_common ${FREELDR_BOOTLIB_COMMON_SOURCE} ${FREELDR_ARC_COMMON_SOURCE}
${FREELDR_NTLDR_COMMON_SOURCE}
${FREELDR_COMMON_SOURCE} ${freeldr_common_asm})
add_pch(freeldr_common include/freeldr.h FREELDR_COMMON_SOURCE)
add_dependencies(freeldr_common bugcodes asm xdk)
@ -173,7 +208,10 @@ endif()
list(APPEND FREELDR_BASE_SOURCE
bootmgr.c # This file is compiled with custom definitions
freeldr.c
windows/setupldr.c
ntldr/setupldr.c ## Strangely enough this file is needed in GCC builds
## even if ${FREELDR_NTLDR_COMMON_SOURCE} is not added,
## otherwise we get linking errors with Rtl**Bitmap** APIs.
## Do not happen on MSVC builds however...
lib/inffile/inffile.c
lib/rtl/libsupp.c)

View file

@ -8,7 +8,7 @@
/* INCLUDES ******************************************************************/
#include "ntoskrnl.h"
#include <ntoskrnl.h>
#define NDEBUG
#include <debug.h>

View file

@ -8,7 +8,7 @@
/* INCLUDES ******************************************************************/
#include "ntoskrnl.h"
#include <ntoskrnl.h>
/* For KeStallExecutionProcessor */
#if defined(_M_IX86) || defined(_M_AMD64)

View file

@ -0,0 +1,40 @@
/*
* PROJECT: EFI Windows Loader
* LICENSE: GPL - See COPYING in the top level directory
* FILE: boot/freeldr/freeldr/windows/conversion.c
* PURPOSE: Physical <-> Virtual addressing mode conversions (arch-specific)
* PROGRAMMERS: Aleksey Bragin (aleksey@reactos.org)
*/
#pragma once
#ifndef _ZOOM2_
/* Arch-specific addresses translation implementation */
FORCEINLINE
PVOID
VaToPa(PVOID Va)
{
return (PVOID)((ULONG_PTR)Va & ~KSEG0_BASE);
}
FORCEINLINE
PVOID
PaToVa(PVOID Pa)
{
return (PVOID)((ULONG_PTR)Pa | KSEG0_BASE);
}
#else
FORCEINLINE
PVOID
VaToPa(PVOID Va)
{
return Va;
}
FORCEINLINE
PVOID
PaToVa(PVOID Pa)
{
return Pa;
}
#endif

View file

@ -81,6 +81,7 @@
/* NTOS loader */
#include <winldr.h>
#include <conversion.h> // More-or-less related to MM also...
/* File system headers */
#include <fs/ext2.h>

View file

@ -2,15 +2,18 @@
* 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. To be merged with
* arch/i386/loader.c in future
* This article was very handy during development:
* http://msdn.microsoft.com/msdnmag/issues/02/03/PE2/
* 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)
*
* 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)
* (creating a native EFI loader for Windows).
*
* NOTE: This article was very handy during development:
* http://msdn.microsoft.com/msdnmag/issues/02/03/PE2/
*/
/* INCLUDES ***************************************************************/

View file

@ -17,33 +17,6 @@ DBG_DEFAULT_CHANNEL(WINDOWS);
/* FUNCTIONS **************************************************************/
#ifndef _ZOOM2_
/* Arch-specific addresses translation implementation */
PVOID
VaToPa(PVOID Va)
{
return (PVOID)((ULONG_PTR)Va & ~KSEG0_BASE);
}
PVOID
PaToVa(PVOID Pa)
{
return (PVOID)((ULONG_PTR)Pa | KSEG0_BASE);
}
#else
PVOID
VaToPa(PVOID Va)
{
return Va;
}
PVOID
PaToVa(PVOID Pa)
{
return Pa;
}
#endif
VOID
List_PaToVa(_In_ PLIST_ENTRY ListHeadPa)
{