Small code refactoring

这个提交包含在:
2022-10-20 15:58:50 +02:00
父节点 1296b44ae0
当前提交 37a37c225f
共有 5 个文件被更改,包括 38 次插入5 次删除

查看文件

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