代码拉取完成,页面将自动刷新
同步操作将从 谭玉刚/ToyBoot 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "Video.h"
EFI_STATUS GetGopHandle(
IN EFI_HANDLE ImageHandle,
OUT EFI_GRAPHICS_OUTPUT_PROTOCOL **Gop
)
{
EFI_STATUS Status = EFI_SUCCESS;
UINTN HandleCount = 0;
EFI_HANDLE *HandleBuffer;
Status = gBS->LocateHandleBuffer(
ByProtocol,
&gEfiGraphicsOutputProtocolGuid,
NULL,
&HandleCount,
&HandleBuffer
);
#ifdef DEBUG
if(EFI_ERROR(Status))
{
Print(L"ERROR:Failed to LocateHanleBuffer of GraphicsOutputProtocol.\n");
return Status;
}
Print(L"SUCCESS:Get %d handles that supported GraphicsOutputProtocol.\n", HandleCount);
#endif
Status = gBS->OpenProtocol(
HandleBuffer[0],
&gEfiGraphicsOutputProtocolGuid,
(VOID **)Gop,
ImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
#ifdef DEBUG
if(EFI_ERROR(Status))
{
Print(L"ERROR:Failed to open first handle that supported GraphicsOutputProtocol.\n");
return Status;
}
Print(L"SUCCESS:GraphicsOutputProtocol is opened with first handle.\n");
#endif
return Status;
}
EFI_STATUS SetVideoMode(
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop
)
{
EFI_STATUS Status = EFI_SUCCESS;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *ModeInfo;
UINTN ModeInfoSize = sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
UINTN H = 0;
UINTN V = 0;
UINTN ModeIndex = 0;
for(UINTN i = 0; i < Gop->Mode->MaxMode; i++)
{
Status = Gop->QueryMode(Gop, i, &ModeInfoSize, &ModeInfo);
H = ModeInfo->HorizontalResolution;
V = ModeInfo->VerticalResolution;
if(((H == 1024) && (V == 768)) || ((H == 1440) && (V == 900)))
{
ModeIndex = i;
}
}
Status = Gop->SetMode(Gop, ModeIndex);
#ifdef DEBUG
if(EFI_ERROR(Status))
{
Print(L"ERROR:Failed to SetMode.\n");
return Status;
}
Print(L"SUCCESS:SetMode to Index:%d.\n", ModeIndex);
#endif
return Status;
}
EFI_STATUS BmpTransform(
IN EFI_PHYSICAL_ADDRESS BmpBase,
OUT BMP_CONFIG *BmpConfig
)
{
EFI_STATUS Status = EFI_SUCCESS;
BmpConfig->Size = GetValue(BmpBase, 0x02, 4);
BmpConfig->PageSize = (BmpConfig->Size >> 12) + 1;
BmpConfig->Offset = GetValue(BmpBase, 0x0A, 4);
BmpConfig->Width = GetValue(BmpBase, 0x12, 4);
BmpConfig->Height = GetValue(BmpBase, 0x16, 4);
EFI_PHYSICAL_ADDRESS PixelStart;
Status = gBS->AllocatePages(
AllocateAnyPages,
EfiLoaderData,
BmpConfig->PageSize,
&PixelStart
);
#ifdef DEBUG
if(EFI_ERROR(Status))
{
Print(L"ERROR:Failed to AllocatePages for PixelArea.\n");
return Status;
}
Print(L"SUCCESS:Memory for PixelArea is ready.\n");
#endif
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *PixelFromFile = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)(BmpBase
+ BmpConfig->Offset
+ BmpConfig->Width * BmpConfig->Height * 4);
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *PixelToBuffer = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)PixelStart;
for(UINTN i = 0; i < BmpConfig->Height; i++)
{
PixelFromFile -= BmpConfig->Width;
for(UINTN j = 0; j < BmpConfig->Width; j++)
{
*PixelToBuffer = *PixelFromFile;
PixelToBuffer++;
PixelFromFile++;
}
PixelFromFile -= BmpConfig->Width;
}
BmpConfig->PixelStart = PixelStart;
return Status;
}
EFI_STATUS DrawBmp(
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop,
IN BMP_CONFIG BmpConfig,
IN UINTN X,
IN UINTN Y
)
{
EFI_STATUS Status = EFI_SUCCESS;
Status = Gop->Blt(
Gop,
(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)BmpConfig.PixelStart,
EfiBltBufferToVideo,
0,0,
X,Y,
BmpConfig.Width,BmpConfig.Height,0
);
#ifdef DEBUG
if(EFI_ERROR(Status))
{
Print(L"ERROR:Failed to Blt Logo.bmp, code=%d.\n", Status);
return Status;
}
Print(L"SUCCESS:You should see the Logo.\n");
#endif
return Status;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。