diff --git a/reactos/boot/CMakeLists.txt b/reactos/boot/CMakeLists.txt index 53086bcbb7e..7dbf421bf03 100644 --- a/reactos/boot/CMakeLists.txt +++ b/reactos/boot/CMakeLists.txt @@ -16,7 +16,7 @@ else() endif() add_custom_target(efisys - COMMAND native-fatten ${CMAKE_CURRENT_BINARY_DIR}/efisys.bin -format 2880 EFIBOOT -boot ${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/fat.bin -mkdir EFI -mkdir EFI/BOOT -add $ EFI/BOOT/boot${EFI_PLATFORM_ID}.efi -add ${CMAKE_BINARY_DIR}/boot/bootdata/BCD EFI/BOOT/BCD + COMMAND native-fatten ${CMAKE_CURRENT_BINARY_DIR}/efisys.bin -format 2880 EFIBOOT -boot ${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/fat.bin -mkdir EFI -mkdir EFI/BOOT -add $ EFI/BOOT/boot${EFI_PLATFORM_ID}.efi DEPENDS native-fatten fat bootmgfw bcd_hive VERBATIM) diff --git a/reactos/boot/environ/CMakeLists.txt b/reactos/boot/environ/CMakeLists.txt index f9abc29ff9e..2eb49c1e766 100644 --- a/reactos/boot/environ/CMakeLists.txt +++ b/reactos/boot/environ/CMakeLists.txt @@ -18,6 +18,7 @@ list(APPEND BOOTLIB_SOURCE lib/misc/image.c lib/misc/resource.c lib/misc/font.c + lib/misc/rtlcompat.c lib/firmware/fwutil.c lib/firmware/efi/firmware.c lib/mm/mm.c @@ -73,7 +74,6 @@ add_dependencies(bootlib bugcodes bootmsg xdk) list(APPEND BOOTMGR_BASE_SOURCE app/bootmgr/efiemu.c app/bootmgr/bootmgr.c - app/bootmgr/rtlcompat.c ) add_executable(bootmgfw ${BOOTMGR_BASE_SOURCE} app/bootmgr/bootmgr.rc) @@ -105,3 +105,37 @@ endif() add_dependencies(bootmgfw asm bugcodes) +list(APPEND ROSLOAD_BASE_SOURCE + app/rosload/rosload.c + ) + +add_executable(rosload ${ROSLOAD_BASE_SOURCE}) +set_target_properties(rosload PROPERTIES SUFFIX ".efi") + +if(MSVC) + add_target_link_flags(rosload "/ignore:4078 /ignore:4254 /DRIVER /FIXED") +else() + add_target_link_flags(rosload "-Wl,--strip-all,--exclude-all-symbols") +endif() + +set_image_base(rosload 0x10000) + +if(MSVC) + set_subsystem(rosload BOOT_APPLICATION) +else() + set_subsystem(rosload 14) +endif() + +set_entrypoint(rosload OslMain@4) + +target_link_libraries(rosload bootlib cportlib cmlib rtl libcntpr) + +if(STACK_PROTECTOR) + target_link_libraries(rosload gcc_ssp) +elseif(RUNTIME_CHECKS) + target_link_libraries(rosload runtmchk) +endif() + +add_dependencies(rosload asm bugcodes) + +add_cd_file(TARGET rosload DESTINATION reactos/system32/boot NO_CAB FOR all) diff --git a/reactos/boot/environ/app/bootmgr/bootmgr.c b/reactos/boot/environ/app/bootmgr/bootmgr.c index 6fcdfd7a55b..47c562beb1a 100644 --- a/reactos/boot/environ/app/bootmgr/bootmgr.c +++ b/reactos/boot/environ/app/bootmgr/bootmgr.c @@ -2862,7 +2862,7 @@ BmMain ( goto Failure; } XmlLoaded = TRUE; - EfiStall(100000000); + /* Check if there's an active bitmap visible */ if (!BlDisplayValidOemBitmap()) { diff --git a/reactos/boot/environ/app/bootmgr/efiemu.c b/reactos/boot/environ/app/bootmgr/efiemu.c index 55fda499ccc..d9fc91b7c39 100644 --- a/reactos/boot/environ/app/bootmgr/efiemu.c +++ b/reactos/boot/environ/app/bootmgr/efiemu.c @@ -22,8 +22,6 @@ typedef struct _BOOT_APPLICATION_PARAMETER_BLOCK_SCRATCH /* DATA VARIABLES ************************************************************/ -ULONG BlpApplicationFlags; - BOOT_APPLICATION_PARAMETER_BLOCK_SCRATCH EfiInitScratch; /* FUNCTIONS *****************************************************************/ diff --git a/reactos/boot/environ/app/rosload/rosload.c b/reactos/boot/environ/app/rosload/rosload.c new file mode 100644 index 00000000000..e581b8faac5 --- /dev/null +++ b/reactos/boot/environ/app/rosload/rosload.c @@ -0,0 +1,39 @@ +/* + * COPYRIGHT: See COPYING.ARM in the top level directory + * PROJECT: ReactOS UEFI OS Loader + * FILE: boot/environ/app/rosload/rosload.c + * PURPOSE: OS Loader Entrypoint + * PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org) + */ + +/* INCLUDES ******************************************************************/ + +#include "rosload.h" + +/* DATA VARIABLES ************************************************************/ + +/* FUNCTIONS *****************************************************************/ + +/*++ + * @name OslMain + * + * The BmMain function implements the Windows Boot Application entrypoint for + * the OS Loader. + * + * @param BootParameters + * Pointer to the Boot Application Parameter Block. + * + * @return NT_SUCCESS if the image was loaded correctly, relevant error code + * otherwise. + * + *--*/ +NTSTATUS +NTAPI +OslMain ( + _In_ PBOOT_APPLICATION_PARAMETER_BLOCK BootParameters + ) +{ + EfiPrintf(L"ReactOS UEFI OS Loader Initializing...\r\n"); + return STATUS_NOT_IMPLEMENTED; +} + diff --git a/reactos/boot/environ/app/rosload/rosload.h b/reactos/boot/environ/app/rosload/rosload.h new file mode 100644 index 00000000000..21f487f9863 --- /dev/null +++ b/reactos/boot/environ/app/rosload/rosload.h @@ -0,0 +1,36 @@ +/* + * COPYRIGHT: See COPYING.ARM in the top level directory + * PROJECT: ReactOS UEFI OS Loader + * FILE: boot/environ/app/rosload/rosload.h + * PURPOSE: Main OS Loader Header + * PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org) +*/ + +#ifndef _ROSLOAD_H +#define _ROSLOAD_H + +/* INCLUDES ******************************************************************/ + +/* C Headers */ +#include +#include +#include + +/* NT Base Headers */ +#include +#include + +/* UEFI Headers */ +#include + +/* Boot Library Headers */ +#include + +/* BCD Headers */ +#include + +/* STRUCTURES ****************************************************************/ + +/* FUNCTIONS *****************************************************************/ + +#endif diff --git a/reactos/boot/environ/include/bl.h b/reactos/boot/environ/include/bl.h index 417ac4db25c..fb74dbaf856 100644 --- a/reactos/boot/environ/include/bl.h +++ b/reactos/boot/environ/include/bl.h @@ -134,6 +134,9 @@ DEFINE_GUID(BadMemoryGuid, 0x54B8275B, 0xD431, 0x473F, 0xAC, 0xFB, 0xE5, 0x36, 0 #define BL_FILE_ENTRY_READ_ACCESS 0x02 #define BL_FILE_ENTRY_WRITE_ACCESS 0x04 #define BL_FILE_ENTRY_UNKNOWN_ACCESS 0x10 +#define BL_FILE_ENTRY_DIRECTORY 0x10000 + +#define BL_ETFS_FILE_ENTRY_DIRECTORY 0x01 #define BL_IMG_VALID_FILE 0x01 #define BL_IMG_MEMORY_FILE 0x02 diff --git a/reactos/boot/environ/lib/bootlib.c b/reactos/boot/environ/lib/bootlib.c index 0506e58058c..052aa9dcdfe 100644 --- a/reactos/boot/environ/lib/bootlib.c +++ b/reactos/boot/environ/lib/bootlib.c @@ -18,6 +18,7 @@ PWCHAR BlpApplicationBaseDirectory; PBOOT_APPLICATION_PARAMETER_BLOCK BlpApplicationParameters; BL_LOADED_APPLICATION_ENTRY BlpApplicationEntry; BOOLEAN BlpLibraryParametersInitialized; +ULONG BlpApplicationFlags; ULONG PdPersistAllocations; LIST_ENTRY BlpPdListHead; diff --git a/reactos/boot/environ/lib/io/etfs.c b/reactos/boot/environ/lib/io/etfs.c index 0ef571a5bcc..081f2059dbc 100644 --- a/reactos/boot/environ/lib/io/etfs.c +++ b/reactos/boot/environ/lib/io/etfs.c @@ -573,15 +573,18 @@ EtfsOpen ( &FileSize, &IsDirectory); + /* Allocate a file entry */ NewFile = BlMmAllocateHeap(sizeof(*NewFile)); if (!NewFile) { return STATUS_NO_MEMORY; } + + /* Zero it out */ RtlZeroMemory(NewFile, sizeof(*NewFile)); + /* Figure out the size of the path and filename plus a slash and NUL */ Size = wcslen(Directory->FilePath) + wcslen(FileName) + 2; - FilePath = BlMmAllocateHeap(Size * sizeof(WCHAR)); if (!FilePath) { @@ -589,6 +592,7 @@ EtfsOpen ( goto Quickie; } + /* Allocate an ETFS file entry */ EtfsFile = (PBL_ETFS_FILE)BlMmAllocateHeap(sizeof(*EtfsFile)); if (!EtfsFile) { @@ -596,48 +600,63 @@ EtfsOpen ( goto Quickie; } + /* Zero it out */ RtlZeroMemory(NewFile, sizeof(*EtfsFile)); + /* Capture the device ID of the directory */ NewFile->DeviceId = Directory->DeviceId; + + /* Check if this is the root or a filename\directory under */ FormatString = L"%ls%ls"; if (Directory->FilePath[1]) { FormatString = L"%ls\\%ls"; } + /* Combine the paths, and save the final path in the file entry */ _snwprintf(FilePath, Size, FormatString, Directory->FilePath, FileName); NewFile->FilePath = FilePath; + /* Copy the ETFS function callbacks into the file netry */ RtlCopyMemory(&NewFile->Callbacks, &EtfsFunctionTable, sizeof(NewFile->Callbacks)); + + /* Fill out the rest of the details */ EtfsFile->DiskOffset = FileOffset; EtfsFile->DirOffset = DirOffset; EtfsFile->Size = FileSize; EtfsFile->DeviceId = DeviceId; + + /* Check if this is a directory */ if (IsDirectory) { - EtfsFile->Flags |= 1; - NewFile->Flags |= 0x10000; + EtfsFile->Flags |= BL_ETFS_FILE_ENTRY_DIRECTORY; + NewFile->Flags |= BL_FILE_ENTRY_DIRECTORY; } + + /* Write down the name of the filesytem */ EtfsFile->FsName = L"cdfs"; + /* All done, return the file entry, and save the ETFS side */ NewFile->FsSpecificData = EtfsFile; *FileEntry = NewFile; return Status; Quickie: - + /* Failure path -- free the file path if we had one */ if (NewFile->FilePath) { BlMmFreeHeap(NewFile->FilePath); } + /* Free the ETFS file entry if we had one */ if (NewFile->FsSpecificData) { BlMmFreeHeap(NewFile->FsSpecificData); } + /* Free the file entry itself, and return the error code */ BlMmFreeHeap(NewFile); return Status; } diff --git a/reactos/boot/environ/app/bootmgr/rtlcompat.c b/reactos/boot/environ/lib/misc/rtlcompat.c similarity index 95% rename from reactos/boot/environ/app/bootmgr/rtlcompat.c rename to reactos/boot/environ/lib/misc/rtlcompat.c index 4a255c2d621..0a0e1d55bca 100644 --- a/reactos/boot/environ/app/bootmgr/rtlcompat.c +++ b/reactos/boot/environ/lib/misc/rtlcompat.c @@ -1,14 +1,14 @@ /* * COPYRIGHT: See COPYING.ARM in the top level directory * PROJECT: ReactOS UEFI Boot Manager -* FILE: boot/environ/app/bootmgr/rtlcompat.c +* FILE: boot/environ/lib/misc/rtlcompat.c * PURPOSE: RTL Library Compatibility Routines * PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org) */ /* INCLUDES ******************************************************************/ -#include "bootmgr.h" +#include "bl.h" /* FUNCTIONS *****************************************************************/