Small code refactoring
ci/woodpecker/push/build Pipeline was successful Details

This commit is contained in:
Rafal Kupiec 2022-10-20 15:58:50 +02:00
parent 1296b44ae0
commit 37a37c225f
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
5 changed files with 38 additions and 5 deletions

View File

@ -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

View File

@ -7,12 +7,15 @@
*/
#include <xtbl.h>
#include <blmod.h>
#include <blproto.h>
/**
* 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;

View File

@ -16,4 +16,8 @@
EFI_STATUS
BlGetXtLoaderProtocol(PXT_BOOT_LOADER_PROTOCOL *LdrProtocol);
EFI_STATUS
BlLoadXtProtocol(PVOID *ProtocolHandler,
PEFI_GUID ProtocolGuid);
#endif /* __XTLDR_BLMOD_H */

View File

@ -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;

View File

@ -7,7 +7,7 @@
*/
#include <xtbl.h>
#include <blmod.h>
#include <blproto.h>
/* EFI Image Handle */