Refactor code and fix loader protocol support
Some checks failed
ci/woodpecker/push/build Pipeline failed
Some checks failed
ci/woodpecker/push/build Pipeline failed
This commit is contained in:
parent
09e58d0b67
commit
3fa2ec90aa
@ -74,11 +74,6 @@ BlGetVolumeDevicePath(IN PUCHAR SystemPath,
|
|||||||
OUT PEFI_DEVICE_PATH_PROTOCOL *DevicePath,
|
OUT PEFI_DEVICE_PATH_PROTOCOL *DevicePath,
|
||||||
OUT PUCHAR *Path);
|
OUT PUCHAR *Path);
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
BlGetXtLoaderProtocol(EFI_HANDLE ImageHandle,
|
|
||||||
PEFI_SYSTEM_TABLE SystemTable,
|
|
||||||
PXT_BOOT_LOADER_PROTOCOL *LoaderProtocol);
|
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
BlLoadEfiModules();
|
BlLoadEfiModules();
|
||||||
|
|
||||||
|
@ -7,28 +7,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xtbl.h>
|
#include <xtbl.h>
|
||||||
|
#include <blmod.h>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This routine locates and opens the XT boot loader protocol.
|
* This routine locates and opens the XT boot loader protocol.
|
||||||
*
|
*
|
||||||
* @param ImageHandle
|
|
||||||
* Firmware-allocated handle that identifies the image.
|
|
||||||
*
|
|
||||||
* @param SystemTable
|
|
||||||
* Provides the EFI system table.
|
|
||||||
*
|
|
||||||
* @param LoaderProtocol
|
|
||||||
* Supplies the address where a pointer to the bootloader protocol is returned.
|
|
||||||
*
|
|
||||||
* @return This routine returns status code.
|
* @return This routine returns status code.
|
||||||
*
|
*
|
||||||
* @since XT 1.0
|
* @since XT 1.0
|
||||||
*/
|
*/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
BlGetXtLoaderProtocol(EFI_HANDLE ImageHandle,
|
BlGetXtLoaderProtocol()
|
||||||
PEFI_SYSTEM_TABLE SystemTable,
|
|
||||||
PXT_BOOT_LOADER_PROTOCOL *LoaderProtocol)
|
|
||||||
{
|
{
|
||||||
EFI_GUID Guid = XT_BOOT_LOADER_PROTOCOL_GUID;
|
EFI_GUID Guid = XT_BOOT_LOADER_PROTOCOL_GUID;
|
||||||
PEFI_HANDLE Handles = NULL;
|
PEFI_HANDLE Handles = NULL;
|
||||||
@ -37,7 +27,7 @@ BlGetXtLoaderProtocol(EFI_HANDLE ImageHandle,
|
|||||||
UINT Index;
|
UINT Index;
|
||||||
|
|
||||||
/* Try to locate the handles */
|
/* Try to locate the handles */
|
||||||
Status = SystemTable->BootServices->LocateHandleBuffer(ByProtocol, &Guid, NULL, &Count, &Handles);
|
Status = EfiSystemTable->BootServices->LocateHandleBuffer(ByProtocol, &Guid, NULL, &Count, &Handles);
|
||||||
if(Status != STATUS_EFI_SUCCESS)
|
if(Status != STATUS_EFI_SUCCESS)
|
||||||
{
|
{
|
||||||
/* Unable to get handles */
|
/* Unable to get handles */
|
||||||
@ -51,23 +41,23 @@ BlGetXtLoaderProtocol(EFI_HANDLE ImageHandle,
|
|||||||
for(Index = 0; Index < Count; Index++)
|
for(Index = 0; Index < Count; Index++)
|
||||||
{
|
{
|
||||||
/* Try to open protocol */
|
/* Try to open protocol */
|
||||||
Status = SystemTable->BootServices->OpenProtocol(Handles[Index], &Guid, (PVOID *)&LoaderProtocol,
|
Status = EfiSystemTable->BootServices->OpenProtocol(Handles[Index], &Guid, (PVOID*)&EfiXtLdrProtocol,
|
||||||
ImageHandle, NULL, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL);
|
EfiImageHandle, NULL, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL);
|
||||||
|
|
||||||
/* Check if successfully opened the loader protocol */
|
/* Check if successfully opened the loader protocol */
|
||||||
if(Status == STATUS_EFI_SUCCESS)
|
if(Status == STATUS_EFI_SUCCESS)
|
||||||
{
|
{
|
||||||
/* Protocol found */
|
/* Protocol found and successfully opened */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free handles */
|
/* Free handles */
|
||||||
SystemTable->BootServices->FreePool(Handles);
|
EfiSystemTable->BootServices->FreePool(Handles);
|
||||||
|
|
||||||
/* Make sure the loaded protocol has been found */
|
/* Make sure the loaded protocol has been found */
|
||||||
if(LoaderProtocol == NULL)
|
if(EfiXtLdrProtocol == NULL)
|
||||||
{
|
{
|
||||||
/* Protocol not found */
|
/* Protocol not found */
|
||||||
return STATUS_EFI_NOT_FOUND;
|
return STATUS_EFI_NOT_FOUND;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xtbl.h>
|
#include <xtbl.h>
|
||||||
|
#include <blmod.h>
|
||||||
|
|
||||||
|
|
||||||
/* EFI Image Handle */
|
/* EFI Image Handle */
|
||||||
@ -40,7 +41,7 @@ BlXtLoaderModuleMain(EFI_HANDLE ImageHandle,
|
|||||||
EfiSystemTable = SystemTable;
|
EfiSystemTable = SystemTable;
|
||||||
|
|
||||||
/* Open the XTLDR protocol */
|
/* Open the XTLDR protocol */
|
||||||
BlGetXtLoaderProtocol(ImageHandle, SystemTable, &EfiXtLdrProtocol);
|
BlGetXtLoaderProtocol();
|
||||||
|
|
||||||
/* Print message and return success */
|
/* Print message and return success */
|
||||||
EfiXtLdrProtocol->EfiPrint(L"XTLDR dummy module initialized\n");
|
EfiXtLdrProtocol->EfiPrint(L"XTLDR dummy module initialized\n");
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
/* EFI Image Handle */
|
/* EFI Image Handle */
|
||||||
EFI_HANDLE EfiImageHandle;
|
EFI_HANDLE EfiImageHandle;
|
||||||
|
|
||||||
|
/* XT Boot Loader protocol */
|
||||||
|
XT_BOOT_LOADER_PROTOCOL EfiLdrProtocol;
|
||||||
|
|
||||||
/* EFI System Table */
|
/* EFI System Table */
|
||||||
PEFI_SYSTEM_TABLE EfiSystemTable;
|
PEFI_SYSTEM_TABLE EfiSystemTable;
|
||||||
|
|
||||||
@ -254,16 +257,15 @@ EFI_STATUS
|
|||||||
BlRegisterXtLoaderProtocol()
|
BlRegisterXtLoaderProtocol()
|
||||||
{
|
{
|
||||||
EFI_GUID Guid = XT_BOOT_LOADER_PROTOCOL_GUID;
|
EFI_GUID Guid = XT_BOOT_LOADER_PROTOCOL_GUID;
|
||||||
XT_BOOT_LOADER_PROTOCOL LoaderProtocol;
|
EFI_HANDLE Handle = NULL;
|
||||||
EFI_HANDLE Handle;
|
|
||||||
|
|
||||||
/* Set all routines available via loader protocol */
|
/* Set all routines available via loader protocol */
|
||||||
LoaderProtocol.DbgPrint = BlDbgPrint;
|
EfiLdrProtocol.DbgPrint = BlDbgPrint;
|
||||||
LoaderProtocol.EfiPrint = BlEfiPrint;
|
EfiLdrProtocol.EfiPrint = BlEfiPrint;
|
||||||
|
|
||||||
/* Register loader protocol */
|
/* Register loader protocol */
|
||||||
BlDbgPrint(L"Registering XT loader protocol\n");
|
BlDbgPrint(L"Registering XT loader protocol\n");
|
||||||
return EfiSystemTable->BootServices->InstallProtocolInterface(&Handle, &Guid, EFI_NATIVE_INTERFACE, &LoaderProtocol);
|
return EfiSystemTable->BootServices->InstallProtocolInterface(&Handle, &Guid, EFI_NATIVE_INTERFACE, &EfiLdrProtocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user