diff --git a/xtldr/CMakeLists.txt b/xtldr/CMakeLists.txt index c3c6d57..b83193a 100644 --- a/xtldr/CMakeLists.txt +++ b/xtldr/CMakeLists.txt @@ -11,6 +11,7 @@ include_directories( # Specify list of source code files list(APPEND XTLDR_SOURCE + ${XTLDR_SOURCE_DIR}/blproto.c ${XTLDR_SOURCE_DIR}/console.c ${XTLDR_SOURCE_DIR}/efiutil.c ${XTLDR_SOURCE_DIR}/string.c diff --git a/xtldr/blproto.c b/xtldr/blproto.c index a642556..7217622 100644 --- a/xtldr/blproto.c +++ b/xtldr/blproto.c @@ -7,12 +7,15 @@ */ #include -#include +#include /** * This routine locates and opens the XT boot loader protocol. * + * @param LdrProtocol + * Supplies the address where a pointer to the loader protocol is returned. + * * @return This routine returns status code. * * @since XT 1.0 @@ -21,13 +24,35 @@ EFI_STATUS BlGetXtLoaderProtocol(PXT_BOOT_LOADER_PROTOCOL *LdrProtocol) { EFI_GUID Guid = XT_BOOT_LOADER_PROTOCOL_GUID; + + /* Load XTLDR protocol */ + return BlLoadXtProtocol((PVOID *)LdrProtocol, &Guid); +} + +/** + * This routine locates and opens the requested XT protocol. + * + * @param ProtocolHandler + * Supplies the address where a pointer to the opened protocol is returned. + * + * @param ProtocolGuid + * Supplies a pointer to the unique protocol GUID. + * + * @return This routine returns status code. + * + * @since XT 1.0 + */ +EFI_STATUS +BlLoadXtProtocol(PVOID *ProtocolHandler, + PEFI_GUID ProtocolGuid) +{ PEFI_HANDLE Handles = NULL; EFI_STATUS Status; UINT_PTR Count; UINT Index; /* Try to locate the handles */ - Status = EfiSystemTable->BootServices->LocateHandleBuffer(ByProtocol, &Guid, NULL, &Count, &Handles); + Status = EfiSystemTable->BootServices->LocateHandleBuffer(ByProtocol, ProtocolGuid, NULL, &Count, &Handles); if(Status != STATUS_EFI_SUCCESS) { /* Unable to get handles */ @@ -41,7 +66,7 @@ BlGetXtLoaderProtocol(PXT_BOOT_LOADER_PROTOCOL *LdrProtocol) for(Index = 0; Index < Count; Index++) { /* Try to open protocol */ - Status = EfiSystemTable->BootServices->OpenProtocol(Handles[Index], &Guid, (PVOID*)LdrProtocol, + Status = EfiSystemTable->BootServices->OpenProtocol(Handles[Index], ProtocolGuid, ProtocolHandler, EfiImageHandle, NULL, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL); /* Check if successfully opened the loader protocol */ @@ -57,7 +82,7 @@ BlGetXtLoaderProtocol(PXT_BOOT_LOADER_PROTOCOL *LdrProtocol) EfiSystemTable->BootServices->FreePool(Handles); /* Make sure the loaded protocol has been found */ - if(*LdrProtocol == NULL) + if(*ProtocolHandler == NULL) { /* Protocol not found */ return STATUS_EFI_NOT_FOUND; diff --git a/xtldr/includes/blmod.h b/xtldr/includes/blproto.h similarity index 82% rename from xtldr/includes/blmod.h rename to xtldr/includes/blproto.h index dbba0bc..d65b4b4 100644 --- a/xtldr/includes/blmod.h +++ b/xtldr/includes/blproto.h @@ -16,4 +16,8 @@ EFI_STATUS BlGetXtLoaderProtocol(PXT_BOOT_LOADER_PROTOCOL *LdrProtocol); +EFI_STATUS +BlLoadXtProtocol(PVOID *ProtocolHandler, + PEFI_GUID ProtocolGuid); + #endif /* __XTLDR_BLMOD_H */ diff --git a/xtldr/includes/xtbl.h b/xtldr/includes/xtbl.h index 24fddc9..ca29c30 100644 --- a/xtldr/includes/xtbl.h +++ b/xtldr/includes/xtbl.h @@ -16,6 +16,9 @@ /* EFI Image Handle */ EXTERN EFI_HANDLE EfiImageHandle; +/* XT Boot Loader protocol */ +EXTERN XT_BOOT_LOADER_PROTOCOL EfiLdrProtocol; + /* EFI System Table */ EXTERN PEFI_SYSTEM_TABLE EfiSystemTable; diff --git a/xtldr/modules/dummy/dummy.c b/xtldr/modules/dummy/dummy.c index 85b8f3f..3d0bb93 100644 --- a/xtldr/modules/dummy/dummy.c +++ b/xtldr/modules/dummy/dummy.c @@ -7,7 +7,7 @@ */ #include -#include +#include /* EFI Image Handle */