diff --git a/CMakeLists.txt b/CMakeLists.txt index bc2200c..b9bf79e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,5 +70,5 @@ set_disk_image_size(128) # Build all subprojects add_subdirectory(bootdata) -add_subdirectory(xtldr) +add_subdirectory(xtldr2) add_subdirectory(xtoskrnl) diff --git a/xtldr2/CMakeLists.txt b/xtldr2/CMakeLists.txt new file mode 100644 index 0000000..084d603 --- /dev/null +++ b/xtldr2/CMakeLists.txt @@ -0,0 +1,34 @@ +# XT Boot Manager +PROJECT(XTLDR) + +# Specify include directories +include_directories( + ${EXECTOS_SOURCE_DIR}/sdk/xtdk + ${XTLDR_SOURCE_DIR}/includes) + +# Specify list of source code files +list(APPEND XTLDR_SOURCE + ${XTLDR_SOURCE_DIR}/globals.c + ${XTLDR_SOURCE_DIR}/xtldr.c) + +# Link static XTLDR library +add_library(libxtldr ${XTLDR_SOURCE}) + +# Link bootloader executable +add_executable(xtldr ${XTLDR_SOURCE}) + +# Add linker libraries +target_link_libraries(xtldr libxtos) + +# Set proper binary name and install target +if(ARCH STREQUAL "i686") + set(BINARY_NAME "bootia32") +elseif(ARCH STREQUAL "amd64") + set(BINARY_NAME "bootx64") +endif() +set_target_properties(xtldr PROPERTIES OUTPUT_NAME ${BINARY_NAME} SUFFIX .efi) +set_install_target(xtldr efi/boot) + +# Set loader entrypoint and subsystem +set_entrypoint(xtldr "BmStartXtLoader") +set_subsystem(xtldr efi_application) diff --git a/xtldr2/README.md b/xtldr2/README.md new file mode 100644 index 0000000..ae4fe9f --- /dev/null +++ b/xtldr2/README.md @@ -0,0 +1,14 @@ +## XT Boot Manager (XTLDR) +The XTLDR, or XTOS Boot Loader, is an EFI (Extensible Firmware Interface) boot loader specifically designed for XTOS. +As an EFI boot loader, XTLDR operates exclusively with EFI-based hardware and is not compatible with non-EFI systems, +like old and deprecated BIOS. + +One of the notable features of XTLDR is its modular design. The boot loader is divided into different modules, with only +the essential core being loaded during the boot process. This modular approach allows for a more efficient and +streamlined boot experience, as only the necessary functionality is loaded, reducing the boot time and system resource +usage. + +XTLDR includes various modules that provide specific functionalities required for the boot process. For example, there is +a module dedicated to supporting the XTOS boot protocol, which is the specific protocol used by XTOS for loading and +executing the OS kernel. Additionally, there is a module for handling PE/COFF (Portable Executable) binaries, which is +a commonly used format of executable files used by the XTOS. diff --git a/xtldr2/globals.c b/xtldr2/globals.c new file mode 100644 index 0000000..dda53f5 --- /dev/null +++ b/xtldr2/globals.c @@ -0,0 +1,16 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: xtldr/globals.c + * DESCRIPTION: XT Boot Manager global variables + * DEVELOPERS: Rafal Kupiec + */ + +#include + + +/* EFI Image Handle */ +EFI_HANDLE EfiImageHandle; + +/* EFI System Table */ +PEFI_SYSTEM_TABLE EfiSystemTable; diff --git a/xtldr2/includes/xtbm.h b/xtldr2/includes/xtbm.h new file mode 100644 index 0000000..252d1e2 --- /dev/null +++ b/xtldr2/includes/xtbm.h @@ -0,0 +1,29 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: xtldr/includes/xtbm.h + * DESCRIPTION: Top level header for XTLDR + * DEVELOPERS: Rafal Kupiec + */ + +#ifndef __XTLDR_XTBM_H +#define __XTLDR_XTBM_H + +#include +#include + + +/* EFI Image Handle */ +EXTERN EFI_HANDLE EfiImageHandle; + +/* EFI System Table */ +EXTERN PEFI_SYSTEM_TABLE EfiSystemTable; + + +/* XTLDR routines forward references */ +XTCDECL +EFI_STATUS +BmStartXtLoader(IN EFI_HANDLE ImageHandle, + IN PEFI_SYSTEM_TABLE SystemTable); + +#endif /* __XTLDR_XTBM_H */ diff --git a/xtldr2/xtldr.c b/xtldr2/xtldr.c new file mode 100644 index 0000000..5c1df65 --- /dev/null +++ b/xtldr2/xtldr.c @@ -0,0 +1,38 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: xtldr/xtldr.c + * DESCRIPTION: XTOS UEFI Boot Manager + * DEVELOPERS: Rafal Kupiec + */ + +#include + + +/** + * This routine is the entry point of the XT EFI boot manager. + * + * @param ImageHandle + * Firmware-allocated handle that identifies the image. + * + * @param SystemTable + * Provides the EFI system table. + * + * @return This routine returns status code. + * + * @since XT 1.0 + */ +XTCDECL +EFI_STATUS +BmStartXtLoader(IN EFI_HANDLE ImageHandle, + IN PEFI_SYSTEM_TABLE SystemTable) +{ + EFI_STATUS Status; + + /* Set the system table and image handle */ + EfiImageHandle = ImageHandle; + EfiSystemTable = SystemTable; + + /* This point should be never reached, if this happen return error code */ + return STATUS_EFI_LOAD_ERROR; +}