diff --git a/CMakeLists.txt b/CMakeLists.txt index 5146e4d..3fd4e4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,3 +63,4 @@ set_disk_image_size(128) # Build subprojects add_subdirectory(bootdata) +add_subdirectory(xtldr) diff --git a/xtldr/CMakeLists.txt b/xtldr/CMakeLists.txt new file mode 100644 index 0000000..5aa7134 --- /dev/null +++ b/xtldr/CMakeLists.txt @@ -0,0 +1,27 @@ +# XT Boot Loader +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}/xtldr.c) + +# Add executable +add_executable(xtldr ${XTLDR_SOURCE}) + +# 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, imagebase address, ordinals and subsystem +set_entrypoint(xtldr "XtLoaderStartup") +set_subsystem(xtldr efi_application) diff --git a/xtldr/includes/xtbl.h b/xtldr/includes/xtbl.h new file mode 100644 index 0000000..d4fc6d2 --- /dev/null +++ b/xtldr/includes/xtbl.h @@ -0,0 +1,25 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: xtldr/includes/xtbl.h + * DESCRIPTION: Top level header for XTLDR + * DEVELOPERS: Rafal Kupiec + */ + +#ifndef __XTLDR_XTBL_H +#define __XTLDR_XTBL_H + +#include + + +/* EFI Image Handle */ +EXTERN EFI_HANDLE EfiImageHandle; + +/* EFI System Table */ +EXTERN EFI_SYSTEM_TABLE *EfiSystemTable; + +EFI_STATUS +XtLoaderStartup(IN EFI_HANDLE ImageHandle, + IN PEFI_SYSTEM_TABLE SystemTable); + +#endif /* __XTLDR_XTBL_H */ diff --git a/xtldr/xtldr.c b/xtldr/xtldr.c new file mode 100644 index 0000000..9e2638f --- /dev/null +++ b/xtldr/xtldr.c @@ -0,0 +1,44 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: xtldr/xtldr.c + * DESCRIPTION: UEFI XT Bootloader + * DEVELOPERS: Rafal Kupiec + */ + +#include + + +/* EFI Image Handle */ +EFI_HANDLE EfiImageHandle; + +/* EFI System Table */ +PEFI_SYSTEM_TABLE EfiSystemTable; + +/** + * This routine is the entry point of the XT EFI boot loader. + * + * @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 + */ +EFI_STATUS +XtLoaderStartup(IN EFI_HANDLE ImageHandle, + IN PEFI_SYSTEM_TABLE SystemTable) +{ + /* Set the system table and image handle */ + EfiImageHandle = ImageHandle; + EfiSystemTable = SystemTable; + + /* Infinite bootloader loop */ + for(;;); + + /* Return success */ + return STATUS_EFI_SUCCESS; +}