diff --git a/reactos/boot/freeldr/freeldr/CMakeLists.txt b/reactos/boot/freeldr/freeldr/CMakeLists.txt index 7e237eb9127..475a1a1d5cc 100644 --- a/reactos/boot/freeldr/freeldr/CMakeLists.txt +++ b/reactos/boot/freeldr/freeldr/CMakeLists.txt @@ -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) diff --git a/reactos/boot/freeldr/freeldr/windows/arch/i386/halstub.c b/reactos/boot/freeldr/freeldr/arch/i386/halstub.c similarity index 99% rename from reactos/boot/freeldr/freeldr/windows/arch/i386/halstub.c rename to reactos/boot/freeldr/freeldr/arch/i386/halstub.c index 19366e01849..2bcff89969a 100644 --- a/reactos/boot/freeldr/freeldr/windows/arch/i386/halstub.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/halstub.c @@ -8,7 +8,7 @@ /* INCLUDES ******************************************************************/ -#include "ntoskrnl.h" +#include #define NDEBUG #include diff --git a/reactos/boot/freeldr/freeldr/windows/arch/i386/ntoskrnl.c b/reactos/boot/freeldr/freeldr/arch/i386/ntoskrnl.c similarity index 99% rename from reactos/boot/freeldr/freeldr/windows/arch/i386/ntoskrnl.c rename to reactos/boot/freeldr/freeldr/arch/i386/ntoskrnl.c index 0ab63b5f0a5..3c30cad41ce 100644 --- a/reactos/boot/freeldr/freeldr/windows/arch/i386/ntoskrnl.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/ntoskrnl.c @@ -8,7 +8,7 @@ /* INCLUDES ******************************************************************/ -#include "ntoskrnl.h" +#include /* For KeStallExecutionProcessor */ #if defined(_M_IX86) || defined(_M_AMD64) diff --git a/reactos/boot/freeldr/freeldr/include/conversion.h b/reactos/boot/freeldr/freeldr/include/conversion.h new file mode 100644 index 00000000000..3a0da85d508 --- /dev/null +++ b/reactos/boot/freeldr/freeldr/include/conversion.h @@ -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 diff --git a/reactos/boot/freeldr/freeldr/include/freeldr.h b/reactos/boot/freeldr/freeldr/include/freeldr.h index 0b6d953eecc..8dfb9c00439 100644 --- a/reactos/boot/freeldr/freeldr/include/freeldr.h +++ b/reactos/boot/freeldr/freeldr/include/freeldr.h @@ -81,6 +81,7 @@ /* NTOS loader */ #include +#include // More-or-less related to MM also... /* File system headers */ #include diff --git a/reactos/boot/freeldr/freeldr/windows/arch/i386/ntoskrnl.h b/reactos/boot/freeldr/freeldr/include/ntoskrnl.h similarity index 100% rename from reactos/boot/freeldr/freeldr/windows/arch/i386/ntoskrnl.h rename to reactos/boot/freeldr/freeldr/include/ntoskrnl.h diff --git a/reactos/boot/freeldr/freeldr/comm/rs232.c b/reactos/boot/freeldr/freeldr/lib/comm/rs232.c similarity index 100% rename from reactos/boot/freeldr/freeldr/comm/rs232.c rename to reactos/boot/freeldr/freeldr/lib/comm/rs232.c diff --git a/reactos/boot/freeldr/freeldr/debug.c b/reactos/boot/freeldr/freeldr/lib/debug.c similarity index 100% rename from reactos/boot/freeldr/freeldr/debug.c rename to reactos/boot/freeldr/freeldr/lib/debug.c diff --git a/reactos/boot/freeldr/freeldr/fs/ext2.c b/reactos/boot/freeldr/freeldr/lib/fs/ext2.c similarity index 100% rename from reactos/boot/freeldr/freeldr/fs/ext2.c rename to reactos/boot/freeldr/freeldr/lib/fs/ext2.c diff --git a/reactos/boot/freeldr/freeldr/fs/fat.c b/reactos/boot/freeldr/freeldr/lib/fs/fat.c similarity index 100% rename from reactos/boot/freeldr/freeldr/fs/fat.c rename to reactos/boot/freeldr/freeldr/lib/fs/fat.c diff --git a/reactos/boot/freeldr/freeldr/fs/fs.c b/reactos/boot/freeldr/freeldr/lib/fs/fs.c similarity index 100% rename from reactos/boot/freeldr/freeldr/fs/fs.c rename to reactos/boot/freeldr/freeldr/lib/fs/fs.c diff --git a/reactos/boot/freeldr/freeldr/fs/iso.c b/reactos/boot/freeldr/freeldr/lib/fs/iso.c similarity index 100% rename from reactos/boot/freeldr/freeldr/fs/iso.c rename to reactos/boot/freeldr/freeldr/lib/fs/iso.c diff --git a/reactos/boot/freeldr/freeldr/fs/ntfs.c b/reactos/boot/freeldr/freeldr/lib/fs/ntfs.c similarity index 100% rename from reactos/boot/freeldr/freeldr/fs/ntfs.c rename to reactos/boot/freeldr/freeldr/lib/fs/ntfs.c diff --git a/reactos/boot/freeldr/freeldr/fs/pxe.c b/reactos/boot/freeldr/freeldr/lib/fs/pxe.c similarity index 100% rename from reactos/boot/freeldr/freeldr/fs/pxe.c rename to reactos/boot/freeldr/freeldr/lib/fs/pxe.c diff --git a/reactos/boot/freeldr/freeldr/mm/heap.c b/reactos/boot/freeldr/freeldr/lib/mm/heap.c similarity index 100% rename from reactos/boot/freeldr/freeldr/mm/heap.c rename to reactos/boot/freeldr/freeldr/lib/mm/heap.c diff --git a/reactos/boot/freeldr/freeldr/mm/meminit.c b/reactos/boot/freeldr/freeldr/lib/mm/meminit.c similarity index 100% rename from reactos/boot/freeldr/freeldr/mm/meminit.c rename to reactos/boot/freeldr/freeldr/lib/mm/meminit.c diff --git a/reactos/boot/freeldr/freeldr/mm/mm.c b/reactos/boot/freeldr/freeldr/lib/mm/mm.c similarity index 100% rename from reactos/boot/freeldr/freeldr/mm/mm.c rename to reactos/boot/freeldr/freeldr/lib/mm/mm.c diff --git a/reactos/boot/freeldr/freeldr/windows/peloader.c b/reactos/boot/freeldr/freeldr/lib/peloader.c similarity index 99% rename from reactos/boot/freeldr/freeldr/windows/peloader.c rename to reactos/boot/freeldr/freeldr/lib/peloader.c index 1b5bed60fed..a41d422f63a 100644 --- a/reactos/boot/freeldr/freeldr/windows/peloader.c +++ b/reactos/boot/freeldr/freeldr/lib/peloader.c @@ -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 ***************************************************************/ diff --git a/reactos/boot/freeldr/freeldr/windows/arch/amd64/winldr.c b/reactos/boot/freeldr/freeldr/ntldr/arch/amd64/winldr.c similarity index 100% rename from reactos/boot/freeldr/freeldr/windows/arch/amd64/winldr.c rename to reactos/boot/freeldr/freeldr/ntldr/arch/amd64/winldr.c diff --git a/reactos/boot/freeldr/freeldr/windows/arch/arm/winldr.c b/reactos/boot/freeldr/freeldr/ntldr/arch/arm/winldr.c similarity index 100% rename from reactos/boot/freeldr/freeldr/windows/arch/arm/winldr.c rename to reactos/boot/freeldr/freeldr/ntldr/arch/arm/winldr.c diff --git a/reactos/boot/freeldr/freeldr/windows/arch/i386/winldr.c b/reactos/boot/freeldr/freeldr/ntldr/arch/i386/winldr.c similarity index 100% rename from reactos/boot/freeldr/freeldr/windows/arch/i386/winldr.c rename to reactos/boot/freeldr/freeldr/ntldr/arch/i386/winldr.c diff --git a/reactos/boot/freeldr/freeldr/windows/conversion.c b/reactos/boot/freeldr/freeldr/ntldr/conversion.c similarity index 91% rename from reactos/boot/freeldr/freeldr/windows/conversion.c rename to reactos/boot/freeldr/freeldr/ntldr/conversion.c index 94ac93a42f0..520b3046c82 100644 --- a/reactos/boot/freeldr/freeldr/windows/conversion.c +++ b/reactos/boot/freeldr/freeldr/ntldr/conversion.c @@ -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) { diff --git a/reactos/boot/freeldr/freeldr/windows/headless.c b/reactos/boot/freeldr/freeldr/ntldr/headless.c similarity index 100% rename from reactos/boot/freeldr/freeldr/windows/headless.c rename to reactos/boot/freeldr/freeldr/ntldr/headless.c diff --git a/reactos/boot/freeldr/freeldr/windows/registry.c b/reactos/boot/freeldr/freeldr/ntldr/registry.c similarity index 100% rename from reactos/boot/freeldr/freeldr/windows/registry.c rename to reactos/boot/freeldr/freeldr/ntldr/registry.c diff --git a/reactos/boot/freeldr/freeldr/windows/registry.h b/reactos/boot/freeldr/freeldr/ntldr/registry.h similarity index 100% rename from reactos/boot/freeldr/freeldr/windows/registry.h rename to reactos/boot/freeldr/freeldr/ntldr/registry.h diff --git a/reactos/boot/freeldr/freeldr/windows/setupldr.c b/reactos/boot/freeldr/freeldr/ntldr/setupldr.c similarity index 100% rename from reactos/boot/freeldr/freeldr/windows/setupldr.c rename to reactos/boot/freeldr/freeldr/ntldr/setupldr.c diff --git a/reactos/boot/freeldr/freeldr/windows/winldr.c b/reactos/boot/freeldr/freeldr/ntldr/winldr.c similarity index 100% rename from reactos/boot/freeldr/freeldr/windows/winldr.c rename to reactos/boot/freeldr/freeldr/ntldr/winldr.c diff --git a/reactos/boot/freeldr/freeldr/windows/wlmemory.c b/reactos/boot/freeldr/freeldr/ntldr/wlmemory.c similarity index 100% rename from reactos/boot/freeldr/freeldr/windows/wlmemory.c rename to reactos/boot/freeldr/freeldr/ntldr/wlmemory.c diff --git a/reactos/boot/freeldr/freeldr/windows/wlregistry.c b/reactos/boot/freeldr/freeldr/ntldr/wlregistry.c similarity index 100% rename from reactos/boot/freeldr/freeldr/windows/wlregistry.c rename to reactos/boot/freeldr/freeldr/ntldr/wlregistry.c