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
29 files changed:
add_definitions(-D_NTHAL_ -D_BLDR_ -D_NTSYSTEM_)
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
- cmdline.c
- custom.c
- debug.c
- linuxboot.c
- miscboot.c
- options.c
- oslist.c
- version.c
arch/archwsup.c
cache/blocklist.c
cache/cache.c
arch/archwsup.c
cache/blocklist.c
cache/cache.c
disk/disk.c
disk/partition.c
disk/ramdisk.c
#disk/scsiport.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
ui/directui.c
ui/gui.c
ui/minitui.c
video/fade.c
video/palette.c
video/video.c
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
if(ARCH STREQUAL "i386")
list(APPEND FREELDR_COMMON_ASM_SOURCE
arch/i386/i386pnp.S
arch/i386/i386trap.S
arch/i386/linux.S
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
arch/i386/archmach.c
arch/i386/drivemap.c
arch/i386/hardware.c
arch/i386/xboxmem.c
arch/i386/xboxrtc.c
arch/i386/xboxvideo.c
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)
disk/scsiport.c)
if(NOT MSVC)
list(APPEND FREELDR_COMMON_ASM_SOURCE arch/i386/drvmap.S)
arch/amd64/entry.S
arch/amd64/int386.S
arch/amd64/pnpbios.S)
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
arch/i386/drivemap.c
arch/i386/hardware.c
arch/i386/hwacpi.c
arch/i386/pcdisk.c
arch/i386/pcmem.c
arch/i386/pcrtc.c
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)
elseif(ARCH STREQUAL "arm")
list(APPEND FREELDR_COMMON_ASM_SOURCE
arch/arm/boot.S)
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/macharm.c
- windows/arch/arm/winldr.c)
else()
#TBD
endif()
add_asm_files(freeldr_common_asm ${FREELDR_COMMON_ASM_SOURCE})
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)
add_pch(freeldr_common include/freeldr.h FREELDR_COMMON_SOURCE)
add_dependencies(freeldr_common bugcodes asm xdk)
list(APPEND FREELDR_BASE_SOURCE
bootmgr.c # This file is compiled with custom definitions
freeldr.c
list(APPEND FREELDR_BASE_SOURCE
bootmgr.c # This file is compiled with custom definitions
freeldr.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)
lib/inffile/inffile.c
lib/rtl/libsupp.c)
/* INCLUDES ******************************************************************/
/* INCLUDES ******************************************************************/
#define NDEBUG
#include <debug.h>
#define NDEBUG
#include <debug.h>
/* INCLUDES ******************************************************************/
/* INCLUDES ******************************************************************/
/* For KeStallExecutionProcessor */
#if defined(_M_IX86) || defined(_M_AMD64)
/* For KeStallExecutionProcessor */
#if defined(_M_IX86) || defined(_M_AMD64)
--- /dev/null
+/*
+ * 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
/* NTOS loader */
#include <winldr.h>
/* NTOS loader */
#include <winldr.h>
+#include <conversion.h> // More-or-less related to MM also...
/* File system headers */
#include <fs/ext2.h>
/* File system headers */
#include <fs/ext2.h>
* PROJECT: FreeLoader
* LICENSE: GPL - See COPYING in the top level directory
* FILE: boot/freeldr/freeldr/windows/peloader.c
* 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)
* 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
* 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 ***************************************************************/
*/
/* INCLUDES ***************************************************************/
/* FUNCTIONS **************************************************************/
/* 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)
{
VOID
List_PaToVa(_In_ PLIST_ENTRY ListHeadPa)
{