* [PATCH v2 3/9] EmulatorPkg/Win: Use FrameBufferBltLib for BLT operation
2018-08-30 2:02 [PATCH v2 0/9] Quality improvement for EmulatorPkg Win Host Ruiyu Ni
2018-08-30 2:02 ` [PATCH v2 1/9] EmulatorPkg/EmuGopDxe: Fix TxtInEx.SetState SCT conformance failure Ruiyu Ni
2018-08-30 2:02 ` [PATCH v2 2/9] EmulatorPkg/EmuGopDxe: Clear screen to black in GOP.SetMode Ruiyu Ni
@ 2018-08-30 2:02 ` Ruiyu Ni
2018-08-30 2:02 ` [PATCH v2 4/9] EmulatorPkg/Win: ReadKeyStrokeEx() always returns correct KeyState Ruiyu Ni
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Ruiyu Ni @ 2018-08-30 2:02 UTC (permalink / raw)
To: edk2-devel; +Cc: Hao Wu, Andrew Fish
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Andrew Fish <afish@apple.com>
---
EmulatorPkg/EmulatorPkg.dsc | 1 +
EmulatorPkg/Win/Host/WinGop.h | 4 +-
EmulatorPkg/Win/Host/WinGopScreen.c | 218 ++++++++++++------------------------
EmulatorPkg/Win/Host/WinHost.inf | 1 +
4 files changed, 73 insertions(+), 151 deletions(-)
diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
index 9f9f7d318d..ee85c9ef64 100644
--- a/EmulatorPkg/EmulatorPkg.dsc
+++ b/EmulatorPkg/EmulatorPkg.dsc
@@ -55,6 +55,7 @@ [LibraryClasses]
PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
+ FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
#
# UEFI & PI
diff --git a/EmulatorPkg/Win/Host/WinGop.h b/EmulatorPkg/Win/Host/WinGop.h
index de27238342..7843b60b91 100644
--- a/EmulatorPkg/Win/Host/WinGop.h
+++ b/EmulatorPkg/Win/Host/WinGop.h
@@ -31,6 +31,7 @@ Abstract:
#include <Protocol/SimpleTextIn.h>
#include <Protocol/SimpleTextInEx.h>
#include <Protocol/GraphicsOutput.h>
+#include <Library/FrameBufferBltLib.h>
//
// WM_SYSKEYDOWN/WM_SYSKEYUP Notification
@@ -86,9 +87,8 @@ typedef struct {
// updated in the main thread and displayed in the windows thread.
//
BITMAPV4HEADER *VirtualScreenInfo;
- RGBQUAD *VirtualScreen;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL *FillLine;
+ FRAME_BUFFER_CONFIGURE *FrameBufferConfigure;
//
// Keyboard Queue used by Simple Text In.
diff --git a/EmulatorPkg/Win/Host/WinGopScreen.c b/EmulatorPkg/Win/Host/WinGopScreen.c
index 2ca51d23d0..0e1f1ff205 100644
--- a/EmulatorPkg/Win/Host/WinGopScreen.c
+++ b/EmulatorPkg/Win/Host/WinGopScreen.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -193,64 +193,85 @@ WinNtWndSize (
IN UINT32 Height
)
{
- UINT32 Size;
- GRAPHICS_PRIVATE_DATA *Private;
- RECT Rect;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL *NewFillLine;
+ RETURN_STATUS RStatus;
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION Info;
+ GRAPHICS_PRIVATE_DATA *Private;
+ RECT Rect;
+ BITMAPV4HEADER *VirtualScreenInfo;
+ FRAME_BUFFER_CONFIGURE *FrameBufferConfigure;
+ UINTN FrameBufferConfigureSize;
Private = GRAPHICS_PRIVATE_DATA_FROM_THIS (GraphicsIo);
- Private->Width = Width;
- Private->Height = Height;
-
-
- //
- // Free the old buffer. We do not save the content of the old buffer since the
- // screen is to be cleared anyway. Clearing the screen is required by the EFI spec.
- // See UEFI spec -EFI_GRAPHICS_OUTPUT_PROTOCOL.SetMode()
- //
- if (Private->VirtualScreenInfo != NULL) {
- HeapFree (GetProcessHeap (), 0, Private->VirtualScreenInfo);
- }
//
// Allocate DIB frame buffer directly from NT for performance enhancement
- // This buffer is the virtual screen/frame buffer. This buffer is not the
- // same a a frame buffer. The first row of this buffer will be the bottom
- // line of the image. This is an artifact of the way we draw to the screen.
+ // This buffer is the virtual screen/frame buffer.
//
- Size = Private->Width * Private->Height * sizeof (RGBQUAD) + sizeof (BITMAPV4HEADER);
- Private->VirtualScreenInfo = HeapAlloc (
+ VirtualScreenInfo = HeapAlloc (
GetProcessHeap (),
HEAP_ZERO_MEMORY,
- Size
+ Width * Height * sizeof (RGBQUAD) + sizeof (BITMAPV4HEADER)
);
+ if (VirtualScreenInfo == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
//
// Update the virtual screen info data structure
+ // Use negative Height to make sure screen/buffer are using the same coordinate.
//
- Private->VirtualScreenInfo->bV4Size = sizeof (BITMAPV4HEADER);
- Private->VirtualScreenInfo->bV4Width = Private->Width;
- Private->VirtualScreenInfo->bV4Height = Private->Height;
- Private->VirtualScreenInfo->bV4Planes = 1;
- Private->VirtualScreenInfo->bV4BitCount = 32;
+ VirtualScreenInfo->bV4Size = sizeof (BITMAPV4HEADER);
+ VirtualScreenInfo->bV4Width = Width;
+ VirtualScreenInfo->bV4Height = -(LONG)Height;
+ VirtualScreenInfo->bV4Planes = 1;
+ VirtualScreenInfo->bV4BitCount = 32;
//
// uncompressed
//
- Private->VirtualScreenInfo->bV4V4Compression = BI_RGB;
+ VirtualScreenInfo->bV4V4Compression = BI_RGB;
+
+ Info.HorizontalResolution = Width;
+ Info.VerticalResolution = Height;
+ Info.PixelFormat = PixelBlueGreenRedReserved8BitPerColor;
+ Info.PixelsPerScanLine = Width;
+ FrameBufferConfigureSize = 0;
+ RStatus = FrameBufferBltConfigure (VirtualScreenInfo + 1, &Info, NULL, &FrameBufferConfigureSize);
+ ASSERT (RStatus == EFI_BUFFER_TOO_SMALL);
+ FrameBufferConfigure = AllocatePool (FrameBufferConfigureSize);
+ if (FrameBufferConfigure == NULL) {
+ HeapFree (GetProcessHeap (), 0, VirtualScreenInfo);
+ return EFI_OUT_OF_RESOURCES;
+ }
+ RStatus = FrameBufferBltConfigure (VirtualScreenInfo + 1, &Info, FrameBufferConfigure, &FrameBufferConfigureSize);
+ ASSERT_RETURN_ERROR (RStatus);
+
+
+ if (Private->FrameBufferConfigure != NULL) {
+ FreePool (Private->FrameBufferConfigure);
+ }
+ Private->FrameBufferConfigure = FrameBufferConfigure;
//
- // The rest of the allocated memory block is the virtual screen buffer
+ // Free the old buffer. We do not save the content of the old buffer since the
+ // screen is to be cleared anyway. Clearing the screen is required by the EFI spec.
+ // See UEFI spec -EFI_GRAPHICS_OUTPUT_PROTOCOL.SetMode()
//
- Private->VirtualScreen = (RGBQUAD *)(Private->VirtualScreenInfo + 1);
+ if (Private->VirtualScreenInfo != NULL) {
+ HeapFree (GetProcessHeap (), 0, Private->VirtualScreenInfo);
+ }
+ Private->VirtualScreenInfo = VirtualScreenInfo;
+
+ Private->Width = Width;
+ Private->Height = Height;
//
// Use the AdjuctWindowRect fuction to calculate the real width and height
// of the new window including the border and caption
//
- Rect.left = 0;
- Rect.top = 0;
- Rect.right = Private->Width;
- Rect.bottom = Private->Height;
+ Rect.left = 0;
+ Rect.top = 0;
+ Rect.right = Width;
+ Rect.bottom = Height;
AdjustWindowRect (&Rect, WS_OVERLAPPEDWINDOW, 0);
@@ -267,16 +288,6 @@ WinNtWndSize (
//
MoveWindow (Private->WindowHandle, Rect.left, Rect.top, (INT32)Width, (INT32)Height, TRUE);
- NewFillLine = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * Private->Width);
- if (NewFillLine == NULL) {
- return EFI_DEVICE_ERROR;
- }
-
- if (Private->FillLine != NULL) {
- FreePool (Private->FillLine);
- }
-
- Private->FillLine = NewFillLine;
return EFI_SUCCESS;
}
@@ -322,68 +333,22 @@ WinNtWndBlt (
IN EMU_GRAPHICS_WINDOWS__BLT_ARGS *Args
)
{
+ RETURN_STATUS RStatus;
GRAPHICS_PRIVATE_DATA *Private;
- UINTN DstY;
- UINTN SrcY;
- RGBQUAD *VScreen;
- RGBQUAD *VScreenSrc;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
- UINTN Index;
RECT Rect;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL *FillPixel;
- UINT32 VerticalResolution;
- UINT32 HorizontalResolution;
Private = GRAPHICS_PRIVATE_DATA_FROM_THIS (GraphicsIo);
-
- //
- // We need to fill the Virtual Screen buffer with the blt data.
- // The virtual screen is upside down, as the first row is the bootom row of
- // the image.
- //
- VerticalResolution = Private->VirtualScreenInfo->bV4Height;
- HorizontalResolution = Private->VirtualScreenInfo->bV4Width;
- if (BltOperation == EfiBltVideoToBltBuffer) {
-
- for (SrcY = Args->SourceY, DstY = Args->DestinationY; DstY < (Args->Height + Args->DestinationY); SrcY++, DstY++) {
- Blt = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) ((UINT8 *) BltBuffer + (DstY * Args->Delta) + Args->DestinationX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
- VScreen = &Private->VirtualScreen[(VerticalResolution - SrcY - 1) * HorizontalResolution + Args->SourceX];
- CopyMem (Blt, VScreen, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * Args->Width);
- }
- } else {
- if (BltOperation == EfiBltVideoFill) {
- FillPixel = BltBuffer;
- for (Index = 0; Index < Args->Width; Index++) {
- Private->FillLine[Index] = *FillPixel;
- }
- }
-
- for (Index = 0; Index < Args->Height; Index++) {
- if (Args->DestinationY <= Args->SourceY) {
- SrcY = Args->SourceY + Index;
- DstY = Args->DestinationY + Index;
- } else {
- SrcY = Args->SourceY + Args->Height - Index - 1;
- DstY = Args->DestinationY + Args->Height - Index - 1;
- }
-
- VScreen = &Private->VirtualScreen[(VerticalResolution - DstY - 1) * HorizontalResolution + Args->DestinationX];
- switch (BltOperation) {
- case EfiBltBufferToVideo:
- Blt = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) ((UINT8 *) BltBuffer + (SrcY * Args->Delta) + Args->SourceX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
- CopyMem (VScreen, Blt, Args->Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
- break;
-
- case EfiBltVideoToVideo:
- VScreenSrc = &Private->VirtualScreen[(VerticalResolution - SrcY - 1) * HorizontalResolution + Args->SourceX];
- CopyMem (VScreen, VScreenSrc, Args->Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
- break;
-
- case EfiBltVideoFill:
- CopyMem (VScreen, Private->FillLine, Args->Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
- break;
- }
- }
+ RStatus = FrameBufferBlt (
+ Private->FrameBufferConfigure,
+ BltBuffer,
+ BltOperation,
+ Args->SourceX, Args->SourceY,
+ Args->DestinationX, Args->DestinationY,
+ Args->Width, Args->Height,
+ Args->Delta
+ );
+ if (RETURN_ERROR (RStatus)) {
+ return (EFI_STATUS)RStatus;
}
if (BltOperation != EfiBltVideoToBltBuffer) {
@@ -435,21 +400,12 @@ WinNtGopThreadWindowProc (
)
{
GRAPHICS_PRIVATE_DATA *Private;
- UINTN Size;
HDC Handle;
PAINTSTRUCT PaintStruct;
LPARAM Index;
EFI_INPUT_KEY Key;
BOOLEAN AltIsPress;
- //
- // BugBug - if there are two instances of this DLL in memory (such as is
- // the case for ERM), the correct instance of this function may not be called.
- // This also means that the address of the mTlsIndex value will be wrong, and
- // the value may be wrong too.
- //
-
-
//
// Use mTlsIndex global to get a Thread Local Storage version of Private.
// This works since each Gop protocol has a unique Private data instance and
@@ -460,39 +416,7 @@ WinNtGopThreadWindowProc (
ASSERT (NULL != Private);
switch (iMsg) {
- case WM_CREATE:
- Size = Private->Width * Private->Height * sizeof (RGBQUAD);
-
- //
- // Allocate DIB frame buffer directly from NT for performance enhancement
- // This buffer is the virtual screen/frame buffer. This buffer is not the
- // same a a frame buffer. The first fow of this buffer will be the bottom
- // line of the image. This is an artifact of the way we draw to the screen.
- //
- Private->VirtualScreenInfo = HeapAlloc (
- GetProcessHeap (),
- HEAP_ZERO_MEMORY,
- Size
- );
-
- Private->VirtualScreenInfo->bV4Size = sizeof (BITMAPV4HEADER);
- Private->VirtualScreenInfo->bV4Width = Private->Width;
- Private->VirtualScreenInfo->bV4Height = Private->Height;
- Private->VirtualScreenInfo->bV4Planes = 1;
- Private->VirtualScreenInfo->bV4BitCount = 32;
- //
- // uncompressed
- //
- Private->VirtualScreenInfo->bV4V4Compression = BI_RGB;
- Private->VirtualScreen = (RGBQUAD *) (Private->VirtualScreenInfo + 1);
- return 0;
-
case WM_PAINT:
- //
- // I have not found a way to convert hwnd into a Private context. So for
- // now we use this API to convert hwnd to Private data.
- //
-
Handle = BeginPaint (hwnd, &PaintStruct);
SetDIBitsToDevice (
@@ -505,7 +429,7 @@ WinNtGopThreadWindowProc (
0, // Source Y
0, // DIB Start Scan Line
Private->Height, // Number of scan lines
- Private->VirtualScreen, // Address of array of DIB bits
+ Private->VirtualScreenInfo + 1, // Address of array of DIB bits
(BITMAPINFO *) Private->VirtualScreenInfo, // Address of structure with bitmap info
DIB_RGB_COLORS // RGB or palette indexes
);
@@ -691,10 +615,6 @@ WinNtGopThreadWinMain (
// This call will fail after the first time, but thats O.K. since we only need
// WIN_NT_GOP_CLASS_NAME to exist to create the window.
//
- // Note: Multiple instances of this DLL will use the same instance of this
- // Class, including the callback function, unless the Class is unregistered and
- // successfully registered again.
- //
RegisterClassEx (&Private->WindowsClass);
//
diff --git a/EmulatorPkg/Win/Host/WinHost.inf b/EmulatorPkg/Win/Host/WinHost.inf
index 501edac15e..940f24da53 100644
--- a/EmulatorPkg/Win/Host/WinHost.inf
+++ b/EmulatorPkg/Win/Host/WinHost.inf
@@ -56,6 +56,7 @@ [LibraryClasses]
ThunkProtocolList
PpiListLib
PeiServicesLib
+ FrameBufferBltLib
[Ppis]
gEmuThunkPpiGuid
--
2.16.1.windows.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 8/9] EmulatorPkg: Use MdeModulePkg/Bds module
2018-08-30 2:02 [PATCH v2 0/9] Quality improvement for EmulatorPkg Win Host Ruiyu Ni
` (6 preceding siblings ...)
2018-08-30 2:02 ` [PATCH v2 7/9] EmulatorPkg/Win: Add VS2017 project file Ruiyu Ni
@ 2018-08-30 2:02 ` Ruiyu Ni
2018-08-30 2:02 ` [PATCH v2 9/9] EmulatorPkg: IoThunk->Close() is called too early, may causing hang Ruiyu Ni
2018-08-30 5:22 ` [PATCH v2 0/9] Quality improvement for EmulatorPkg Win Host Wu, Hao A
9 siblings, 0 replies; 11+ messages in thread
From: Ruiyu Ni @ 2018-08-30 2:02 UTC (permalink / raw)
To: edk2-devel; +Cc: Hao Wu, Andrew Fish
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1120
Logo is enabled by adding a separate core driver LogoDxe.
UiApp and BootManagerMenuApp are added to provide two UIs.
LoadFileOnFv2 is added to auto-install LoadFile protocol for
applications in FV so the boot options for applications can be
auto-created from LoadFile.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Andrew Fish <afish@apple.com>
---
EmulatorPkg/EmulatorPkg.dsc | 31 +-
EmulatorPkg/EmulatorPkg.fdf | 21 +-
EmulatorPkg/Library/EmuBdsLib/BdsPlatform.c | 559 ---------------------
EmulatorPkg/Library/PlatformBmLib/PlatformBm.c | 435 ++++++++++++++++
.../BdsPlatform.h => PlatformBmLib/PlatformBm.h} | 63 ++-
.../PlatformBmData.c} | 13 +-
.../PlatformBmLib.inf} | 28 +-
.../Library/PlatformBmLib/PlatformBmMemoryTest.c | 133 +++++
8 files changed, 649 insertions(+), 634 deletions(-)
delete mode 100644 EmulatorPkg/Library/EmuBdsLib/BdsPlatform.c
create mode 100644 EmulatorPkg/Library/PlatformBmLib/PlatformBm.c
rename EmulatorPkg/Library/{EmuBdsLib/BdsPlatform.h => PlatformBmLib/PlatformBm.h} (60%)
rename EmulatorPkg/Library/{EmuBdsLib/PlatformData.c => PlatformBmLib/PlatformBmData.c} (77%)
rename EmulatorPkg/Library/{EmuBdsLib/EmuBdsLib.inf => PlatformBmLib/PlatformBmLib.inf} (71%)
create mode 100644 EmulatorPkg/Library/PlatformBmLib/PlatformBmMemoryTest.c
diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
index 72e8aa1788..78e9a3f1cc 100644
--- a/EmulatorPkg/EmulatorPkg.dsc
+++ b/EmulatorPkg/EmulatorPkg.dsc
@@ -79,7 +79,9 @@ [LibraryClasses]
UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf
DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf
OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
- GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
+ BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
+ FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
+ UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
@@ -90,7 +92,7 @@ [LibraryClasses]
#
# Platform
#
- PlatformBdsLib|EmulatorPkg/Library/EmuBdsLib/EmuBdsLib.inf
+ PlatformBootManagerLib|EmulatorPkg/Library/PlatformBmLib/PlatformBmLib.inf
KeyMapLib|EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.inf
#
@@ -107,7 +109,6 @@ [LibraryClasses]
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
SortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf
- UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
@@ -171,13 +172,6 @@ [LibraryClasses.common.DXE_RUNTIME_DRIVER, LibraryClasses.common.UEFI_DRIVER, Li
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
TimerLib|EmulatorPkg/Library/DxeTimerLib/DxeTimerLib.inf
-[LibraryClasses.common.UEFI_DRIVER]
- PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
-
-[LibraryClasses.common.UEFI_APPLICATION]
- PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
-
-
[PcdsFeatureFlag]
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|TRUE
@@ -198,6 +192,9 @@ [PcdsFixedAtBuild]
gEmulatorPkgTokenSpaceGuid.PcdEmuMemorySize|L"64!64"
+ # Change PcdBootManagerMenuFile to UiApp
+ gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 }
+
!ifndef $(USE_OLD_SHELL)
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 }
!endif
@@ -238,7 +235,7 @@ [PcdsDynamicDefault.common.DEFAULT]
[PcdsDynamicHii.common.DEFAULT]
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn|L"Setup"|gEmuSystemConfigGuid|0x0|80
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow|L"Setup"|gEmuSystemConfigGuid|0x4|25
-
+ gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|L"Timeout"|gEfiGlobalVariableGuid|0x0|10
[Components]
!ifdef $(UNIX_SEC_BUILD)
@@ -337,7 +334,17 @@ [Components]
}
MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
- IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf
+ MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
+ MdeModulePkg/Logo/LogoDxe.inf
+ MdeModulePkg/Universal/LoadFileOnFv2/LoadFileOnFv2.inf
+ MdeModulePkg/Application/UiApp/UiApp.inf {
+ <LibraryClasses>
+ NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf
+ NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf
+ NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf
+ }
+ MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf
+
MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
#{
# <LibraryClasses>
diff --git a/EmulatorPkg/EmulatorPkg.fdf b/EmulatorPkg/EmulatorPkg.fdf
index 314eb7b895..5b5f81443d 100644
--- a/EmulatorPkg/EmulatorPkg.fdf
+++ b/EmulatorPkg/EmulatorPkg.fdf
@@ -1,7 +1,7 @@
## @file
# This is Emulator FDF file with UEFI HII features enabled
#
-# Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
# Portions copyright (c) 2009 - 2011, Apple Inc. All rights reserved.<BR>
#
# This program and the accompanying materials
@@ -183,9 +183,12 @@ [FV.FvRecovery]
INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
INF MdeModulePkg/Universal/PrintDxe/PrintDxe.inf
-INF IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf
+INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
+INF MdeModulePkg/Logo/LogoDxe.inf
+INF MdeModulePkg/Universal/LoadFileOnFv2/LoadFileOnFv2.inf
+INF RuleOverride = UI MdeModulePkg/Application/UiApp/UiApp.inf
+INF MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf
INF MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf
-INF MdeModulePkg/Application/HelloWorld/HelloWorld.inf
#
# Network stack drivers
@@ -212,11 +215,6 @@ [FV.FvRecovery]
INF RuleOverride = BINARY EdkShellBinPkg/FullShell/FullShell.inf
!endif
-FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {
- SECTION RAW = MdeModulePkg/Logo/Logo.bmp
-}
-
-
[Rule.Common.SEC]
FILE SEC = $(NAMED_GUID) {
PE32 PE32 Align=Auto $(INF_OUTPUT)/$(MODULE_NAME).efi
@@ -296,6 +294,13 @@ [Rule.Common.UEFI_APPLICATION]
}
}
+[Rule.Common.UEFI_APPLICATION.UI]
+ FILE APPLICATION = $(NAMED_GUID) {
+ PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi
+ UI STRING="Enter Setup"
+ VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+ }
+
[Rule.Common.UEFI_DRIVER.BINARY]
FILE DRIVER = $(NAMED_GUID) {
DXE_DEPEX DXE_DEPEX Optional |.depex
diff --git a/EmulatorPkg/Library/EmuBdsLib/BdsPlatform.c b/EmulatorPkg/Library/EmuBdsLib/BdsPlatform.c
deleted file mode 100644
index 75fba847f4..0000000000
--- a/EmulatorPkg/Library/EmuBdsLib/BdsPlatform.c
+++ /dev/null
@@ -1,559 +0,0 @@
-/*++ @file
-
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
-Portions copyright (c) 2011, Apple Inc. All rights reserved.
-This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "BdsPlatform.h"
-
-EMU_SYSTEM_CONFIGURATION mSystemConfigData;
-
-VOID
-SetupVariableInit (
- VOID
- )
-{
- EFI_STATUS Status;
- UINTN Size;
-
- Size = sizeof (mSystemConfigData);
- Status = gRT->GetVariable (
- L"Setup",
- &gEmuSystemConfigGuid,
- NULL,
- &Size,
- (VOID *) &mSystemConfigData
- );
-
- if (EFI_ERROR (Status)) {
- //
- // SetupVariable is corrupt
- //
- mSystemConfigData.ConOutRow = PcdGet32 (PcdConOutColumn);
- mSystemConfigData.ConOutColumn = PcdGet32 (PcdConOutRow);
-
- Status = gRT->SetVariable (
- L"Setup",
- &gEmuSystemConfigGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
- sizeof (mSystemConfigData),
- (VOID *) &mSystemConfigData
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status));
- }
- }
-}
-
-//
-// BDS Platform Functions
-//
-VOID
-EFIAPI
-PlatformBdsInit (
- VOID
- )
-/*++
-
-Routine Description:
-
- Platform Bds init. Include the platform firmware vendor, revision
- and so crc check.
-
-Arguments:
-
-Returns:
-
- None.
-
-**/
-{
- SetupVariableInit ();
-
- EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);
-}
-
-EFI_STATUS
-PlatformBdsConnectConsole (
- IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole
- )
-/*++
-
-Routine Description:
-
- Connect the predefined platform default console device. Always try to find
- and enable the vga device if have.
-
-Arguments:
-
- PlatformConsole - Predefined platform default console device array.
-
-Returns:
-
- EFI_SUCCESS - Success connect at least one ConIn and ConOut
- device, there must have one ConOut device is
- active vga device.
-
- EFI_STATUS - Return the status of
- BdsLibConnectAllDefaultConsoles ()
-
-**/
-{
- EFI_STATUS Status;
- UINTN Index;
-
- Index = 0;
- Status = EFI_SUCCESS;
-
- //
- // Have chance to connect the platform default console,
- // the platform default console is the minimum device group
- // the platform should support
- //
- while (PlatformConsole[Index].DevicePath != NULL) {
- //
- // Update the console variable with the connect type
- //
- if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {
- BdsLibUpdateConsoleVariable (L"ConIn", PlatformConsole[Index].DevicePath, NULL);
- }
-
- if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {
- BdsLibUpdateConsoleVariable (L"ConOut", PlatformConsole[Index].DevicePath, NULL);
- }
-
- if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
- BdsLibUpdateConsoleVariable (L"ErrOut", PlatformConsole[Index].DevicePath, NULL);
- }
-
- Index++;
- }
- //
- // Connect the all the default console with current cosole variable
- //
- Status = BdsLibConnectAllDefaultConsoles ();
- return Status;
-}
-
-VOID
-PlatformBdsConnectSequence (
- VOID
- )
-/*++
-
-Routine Description:
-
- Connect with predefined platform connect sequence,
- the OEM/IBV can customize with their own connect sequence.
-
-Arguments:
-
- None.
-
-Returns:
-
- None.
-
-**/
-{
- UINTN Index;
-
- Index = 0;
-
- //
- // Here we can get the customized platform connect sequence
- // Notes: we can connect with new variable which record the
- // last time boots connect device path sequence
- //
- while (gPlatformConnectSequence[Index] != NULL) {
- //
- // Build the platform boot option
- //
- BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);
- Index++;
- }
-
- //
- // Just use the simple policy to connect all devices
- //
- BdsLibConnectAll ();
-}
-
-VOID
-PlatformBdsGetDriverOption (
- IN OUT LIST_ENTRY *BdsDriverLists
- )
-/*++
-
-Routine Description:
-
- Load the predefined driver option, OEM/IBV can customize this
- to load their own drivers
-
-Arguments:
-
- BdsDriverLists - The header of the driver option link list.
-
-Returns:
-
- None.
-
-**/
-{
- UINTN Index;
-
- Index = 0;
-
- //
- // Here we can get the customized platform driver option
- //
- while (gPlatformDriverOption[Index] != NULL) {
- //
- // Build the platform boot option
- //
- BdsLibRegisterNewOption (BdsDriverLists, gPlatformDriverOption[Index], NULL, L"DriverOrder");
- Index++;
- }
-
-}
-
-VOID
-PlatformBdsDiagnostics (
- IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,
- IN BOOLEAN QuietBoot,
- IN BASEM_MEMORY_TEST BaseMemoryTest
- )
-/*++
-
-Routine Description:
-
- Perform the platform diagnostic, such like test memory. OEM/IBV also
- can customize this fuction to support specific platform diagnostic.
-
-Arguments:
-
- MemoryTestLevel - The memory test intensive level
-
- QuietBoot - Indicate if need to enable the quiet boot
-
- BaseMemoryTest - A pointer to BdsMemoryTest()
-
-Returns:
-
- None.
-
-**/
-{
- EFI_STATUS Status;
-
- //
- // Here we can decide if we need to show
- // the diagnostics screen
- // Notes: this quiet boot code should be remove
- // from the graphic lib
- //
- if (QuietBoot) {
- EnableQuietBoot (PcdGetPtr(PcdLogoFile));
- //
- // Perform system diagnostic
- //
- Status = BaseMemoryTest (MemoryTestLevel);
- if (EFI_ERROR (Status)) {
- DisableQuietBoot ();
- }
-
- return ;
- }
- //
- // Perform system diagnostic
- //
- Status = BaseMemoryTest (MemoryTestLevel);
-}
-
-VOID
-EFIAPI
-PlatformBdsPolicyBehavior (
- IN OUT LIST_ENTRY *DriverOptionList,
- IN OUT LIST_ENTRY *BootOptionList,
- IN PROCESS_CAPSULES ProcessCapsules,
- IN BASEM_MEMORY_TEST BaseMemoryTest
- )
-/*++
-
-Routine Description:
-
- The function will execute with as the platform policy, current policy
- is driven by boot mode. IBV/OEM can customize this code for their specific
- policy action.
-
-Arguments:
-
- DriverOptionList - The header of the driver option link list
-
- BootOptionList - The header of the boot option link list
-
- ProcessCapsules - A pointer to ProcessCapsules()
-
- BaseMemoryTest - A pointer to BaseMemoryTest()
-
-Returns:
-
- None.
-
-**/
-{
- EFI_STATUS Status;
- UINT16 Timeout;
- EFI_BOOT_MODE BootMode;
-
- //
- // Init the time out value
- //
- Timeout = PcdGet16 (PcdPlatformBootTimeOut);
-
- //
- // Load the driver option as the driver option list
- //
- PlatformBdsGetDriverOption (DriverOptionList);
-
- //
- // Get current Boot Mode
- //
- Status = BdsLibGetBootMode (&BootMode);
-
- //
- // Go the different platform policy with different boot mode
- // Notes: this part code can be change with the table policy
- //
- switch (BootMode) {
-
- case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
- case BOOT_WITH_MINIMAL_CONFIGURATION:
- //
- // In no-configuration boot mode, we can connect the
- // console directly.
- //
- BdsLibConnectAllDefaultConsoles ();
- PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);
-
- //
- // Perform some platform specific connect sequence
- //
- PlatformBdsConnectSequence ();
-
- //
- // Notes: current time out = 0 can not enter the
- // front page
- //
- PlatformBdsEnterFrontPage (Timeout, FALSE);
-
- //
- // Check the boot option with the boot option list
- //
- BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");
- break;
-
- case BOOT_ON_FLASH_UPDATE:
- //
- // Boot with the specific configuration
- //
- PlatformBdsConnectConsole (gPlatformConsole);
- PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);
- BdsLibConnectAll ();
- ProcessCapsules (BOOT_ON_FLASH_UPDATE);
- break;
-
- case BOOT_IN_RECOVERY_MODE:
- //
- // In recovery mode, just connect platform console
- // and show up the front page
- //
- PlatformBdsConnectConsole (gPlatformConsole);
- PlatformBdsDiagnostics (EXTENSIVE, FALSE, BaseMemoryTest);
-
- //
- // In recovery boot mode, we still enter to the
- // frong page now
- //
- PlatformBdsEnterFrontPage (Timeout, FALSE);
- break;
-
- case BOOT_WITH_FULL_CONFIGURATION:
- case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:
- case BOOT_WITH_DEFAULT_SETTINGS:
- default:
- //
- // Connect platform console
- //
- Status = PlatformBdsConnectConsole (gPlatformConsole);
- if (EFI_ERROR (Status)) {
- //
- // Here OEM/IBV can customize with defined action
- //
- PlatformBdsNoConsoleAction ();
- }
-
- PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);
-
- //
- // Perform some platform specific connect sequence
- //
- PlatformBdsConnectSequence ();
-
- //
- // Give one chance to enter the setup if we
- // have the time out
- //
- PlatformBdsEnterFrontPage (Timeout, FALSE);
-
- //
- // Here we have enough time to do the enumeration of boot device
- //
- BdsLibEnumerateAllBootOption (BootOptionList);
- break;
- }
-
- return ;
-
-}
-
-VOID
-EFIAPI
-PlatformBdsBootSuccess (
- IN BDS_COMMON_OPTION *Option
- )
-/*++
-
-Routine Description:
-
- Hook point after a boot attempt succeeds. We don't expect a boot option to
- return, so the EFI 1.0 specification defines that you will default to an
- interactive mode and stop processing the BootOrder list in this case. This
- is alos a platform implementation and can be customized by IBV/OEM.
-
-Arguments:
-
- Option - Pointer to Boot Option that succeeded to boot.
-
-Returns:
-
- None.
-
-**/
-{
- CHAR16 *TmpStr;
-
- //
- // If Boot returned with EFI_SUCCESS and there is not in the boot device
- // select loop then we need to pop up a UI and wait for user input.
- //
- TmpStr = Option->StatusString;
- if (TmpStr != NULL) {
- BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);
- FreePool (TmpStr);
- }
-}
-
-VOID
-EFIAPI
-PlatformBdsBootFail (
- IN BDS_COMMON_OPTION *Option,
- IN EFI_STATUS Status,
- IN CHAR16 *ExitData,
- IN UINTN ExitDataSize
- )
-/*++
-
-Routine Description:
-
- Hook point after a boot attempt fails.
-
-Arguments:
-
- Option - Pointer to Boot Option that failed to boot.
-
- Status - Status returned from failed boot.
-
- ExitData - Exit data returned from failed boot.
-
- ExitDataSize - Exit data size returned from failed boot.
-
-Returns:
-
- None.
-
-**/
-{
- CHAR16 *TmpStr;
-
- //
- // If Boot returned with failed status then we need to pop up a UI and wait
- // for user input.
- //
- TmpStr = Option->StatusString;
- if (TmpStr != NULL) {
- BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);
- FreePool (TmpStr);
- }
-}
-
-EFI_STATUS
-PlatformBdsNoConsoleAction (
- VOID
- )
-/*++
-
-Routine Description:
-
- This function is remained for IBV/OEM to do some platform action,
- if there no console device can be connected.
-
-Arguments:
-
- None.
-
-Returns:
-
- EFI_SUCCESS - Direct return success now.
-
-**/
-{
- return EFI_SUCCESS;
-}
-
-VOID
-EFIAPI
-PlatformBdsLockNonUpdatableFlash (
- VOID
- )
-{
- return;
-}
-
-/**
- Lock the ConsoleIn device in system table. All key
- presses will be ignored until the Password is typed in. The only way to
- disable the password is to type it in to a ConIn device.
-
- @param Password Password used to lock ConIn device.
-
- @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.
- @retval EFI_UNSUPPORTED Password not found
-
-**/
-EFI_STATUS
-EFIAPI
-LockKeyboards (
- IN CHAR16 *Password
- )
-{
- return EFI_UNSUPPORTED;
-}
diff --git a/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c b/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c
new file mode 100644
index 0000000000..4e3297c984
--- /dev/null
+++ b/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c
@@ -0,0 +1,435 @@
+/*++ @file
+
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+Portions copyright (c) 2011, Apple Inc. All rights reserved.
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "PlatformBm.h"
+
+EFI_GUID mBootMenuFile = {
+ 0xEEC25BDC, 0x67F2, 0x4D95, { 0xB1, 0xD5, 0xF8, 0x1B, 0x20, 0x39, 0xD1, 0x1D }
+};
+
+/**
+ Initialize the "Setup" variable.
+**/
+VOID
+SetupVariableInit (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ UINTN Size;
+ EMU_SYSTEM_CONFIGURATION SystemConfigData;
+
+ Size = sizeof (SystemConfigData);
+ Status = gRT->GetVariable (
+ L"Setup",
+ &gEmuSystemConfigGuid,
+ NULL,
+ &Size,
+ (VOID *) &SystemConfigData
+ );
+
+ if (EFI_ERROR (Status)) {
+ //
+ // SetupVariable is corrupt
+ //
+ SystemConfigData.ConOutRow = PcdGet32 (PcdConOutColumn);
+ SystemConfigData.ConOutColumn = PcdGet32 (PcdConOutRow);
+
+ Status = gRT->SetVariable (
+ L"Setup",
+ &gEmuSystemConfigGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ sizeof (SystemConfigData),
+ (VOID *) &SystemConfigData
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status));
+ }
+ }
+}
+
+EFI_DEVICE_PATH *
+FvFilePath (
+ EFI_GUID *FileGuid
+ )
+{
+
+ EFI_STATUS Status;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
+
+ EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
+
+ Status = gBS->HandleProtocol (
+ gImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **) &LoadedImage
+ );
+ ASSERT_EFI_ERROR (Status);
+ return AppendDevicePathNode (
+ DevicePathFromHandle (LoadedImage->DeviceHandle),
+ (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
+ );
+}
+
+/**
+ Create one boot option for BootManagerMenuApp.
+
+ @param FileGuid Input file guid for the BootManagerMenuApp.
+ @param Description Description of the BootManagerMenuApp boot option.
+ @param Position Position of the new load option to put in the ****Order variable.
+ @param IsBootCategory Whether this is a boot category.
+
+
+ @retval OptionNumber Return the option number info.
+
+**/
+UINTN
+RegisterBootManagerMenuAppBootOption (
+ EFI_GUID *FileGuid,
+ CHAR16 *Description,
+ UINTN Position,
+ BOOLEAN IsBootCategory
+ )
+{
+ EFI_STATUS Status;
+ EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ UINTN OptionNumber;
+
+ DevicePath = FvFilePath (FileGuid);
+ Status = EfiBootManagerInitializeLoadOption (
+ &NewOption,
+ LoadOptionNumberUnassigned,
+ LoadOptionTypeBoot,
+ IsBootCategory ? LOAD_OPTION_ACTIVE : LOAD_OPTION_CATEGORY_APP,
+ Description,
+ DevicePath,
+ NULL,
+ 0
+ );
+ ASSERT_EFI_ERROR (Status);
+ FreePool (DevicePath);
+
+ Status = EfiBootManagerAddLoadOptionVariable (&NewOption, Position);
+ ASSERT_EFI_ERROR (Status);
+
+ OptionNumber = NewOption.OptionNumber;
+
+ EfiBootManagerFreeLoadOption (&NewOption);
+
+ return OptionNumber;
+}
+
+/**
+ Check if it's a Device Path pointing to BootManagerMenuApp.
+
+ @param DevicePath Input device path.
+
+ @retval TRUE The device path is BootManagerMenuApp File Device Path.
+ @retval FALSE The device path is NOT BootManagerMenuApp File Device Path.
+**/
+BOOLEAN
+IsBootManagerMenuAppFilePath (
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath
+)
+{
+ EFI_HANDLE FvHandle;
+ VOID *NameGuid;
+ EFI_STATUS Status;
+
+ Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &DevicePath, &FvHandle);
+ if (!EFI_ERROR (Status)) {
+ NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) DevicePath);
+ if (NameGuid != NULL) {
+ return CompareGuid (NameGuid, &mBootMenuFile);
+ }
+ }
+
+ return FALSE;
+}
+
+/**
+ Return the boot option number to the BootManagerMenuApp.
+
+ If not found it in the current boot option, create a new one.
+
+ @retval OptionNumber Return the boot option number to the BootManagerMenuApp.
+
+**/
+UINTN
+GetBootManagerMenuAppOption (
+ VOID
+ )
+{
+ UINTN BootOptionCount;
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
+ UINTN Index;
+ UINTN OptionNumber;
+
+ OptionNumber = 0;
+
+ BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
+
+ for (Index = 0; Index < BootOptionCount; Index++) {
+ if (IsBootManagerMenuAppFilePath (BootOptions[Index].FilePath)) {
+ OptionNumber = BootOptions[Index].OptionNumber;
+ break;
+ }
+ }
+
+ EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
+
+ if (Index >= BootOptionCount) {
+ //
+ // If not found the BootManagerMenuApp, create it.
+ //
+ OptionNumber = (UINT16) RegisterBootManagerMenuAppBootOption (&mBootMenuFile, L"UEFI BootManagerMenuApp", (UINTN) -1, FALSE);
+ }
+
+ return OptionNumber;
+}
+
+/**
+ Platform Bds init. Include the platform firmware vendor, revision
+ and so crc check.
+**/
+VOID
+EFIAPI
+PlatformBootManagerBeforeConsole (
+ VOID
+ )
+{
+ UINTN Index;
+
+ SetupVariableInit ();
+
+ EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);
+
+ Index = 0;
+ while (gPlatformConsole[Index].DevicePath != NULL) {
+ //
+ // Update the console variable with the connect type
+ //
+ if ((gPlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {
+ EfiBootManagerUpdateConsoleVariable (ConIn, gPlatformConsole[Index].DevicePath, NULL);
+ }
+
+ if ((gPlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {
+ EfiBootManagerUpdateConsoleVariable (ConOut, gPlatformConsole[Index].DevicePath, NULL);
+ }
+
+ if ((gPlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
+ EfiBootManagerUpdateConsoleVariable (ErrOut, gPlatformConsole[Index].DevicePath, NULL);
+ }
+
+ Index++;
+ }
+}
+
+/**
+ Connect with predefined platform connect sequence,
+ the OEM/IBV can customize with their own connect sequence.
+**/
+VOID
+PlatformBdsConnectSequence (
+ VOID
+ )
+{
+ //
+ // Just use the simple policy to connect all devices
+ //
+ EfiBootManagerConnectAll ();
+}
+
+/**
+ Perform the platform diagnostic, such like test memory. OEM/IBV also
+ can customize this fuction to support specific platform diagnostic.
+
+ @param MemoryTestLevel The memory test intensive level
+ @param QuietBoot Indicate if need to enable the quiet boot
+**/
+VOID
+PlatformBdsDiagnostics (
+ IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,
+ IN BOOLEAN QuietBoot
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Here we can decide if we need to show
+ // the diagnostics screen
+ //
+ if (QuietBoot) {
+ BootLogoEnableLogo ();
+
+ //
+ // Perform system diagnostic
+ //
+ Status = PlatformBootManagerMemoryTest (MemoryTestLevel);
+ if (EFI_ERROR (Status)) {
+ BootLogoDisableLogo ();
+ }
+
+ return;
+ }
+
+ //
+ // Perform system diagnostic
+ //
+ PlatformBootManagerMemoryTest (MemoryTestLevel);
+}
+
+/**
+ Register the static boot options.
+**/
+VOID
+PlatformBdsRegisterStaticBootOptions (
+ VOID
+ )
+{
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL Black;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL White;
+ EFI_INPUT_KEY Enter;
+ EFI_INPUT_KEY F2;
+ EFI_INPUT_KEY F7;
+ EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
+ UINTN OptionNumber;
+
+ Black.Blue = Black.Green = Black.Red = Black.Reserved = 0;
+ White.Blue = White.Green = White.Red = White.Reserved = 0xFF;
+
+ //
+ // Register ENTER as CONTINUE key
+ //
+ Enter.ScanCode = SCAN_NULL;
+ Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;
+ EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
+ //
+ // Map F2 to Boot Manager Menu
+ //
+ F2.ScanCode = SCAN_F2;
+ F2.UnicodeChar = CHAR_NULL;
+ EfiBootManagerGetBootManagerMenu (&BootOption);
+ EfiBootManagerAddKeyOptionVariable (NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL);
+
+ //
+ // 3. Boot Device List menu
+ //
+ F7.ScanCode = SCAN_F7;
+ F7.UnicodeChar = CHAR_NULL;
+ OptionNumber = GetBootManagerMenuAppOption ();
+ EfiBootManagerAddKeyOptionVariable (NULL, (UINT16)OptionNumber, 0, &F7, NULL);
+
+ PrintXY (10, 10, &White, &Black, L"F2 to enter Setup. ");
+ PrintXY (10, 30, &White, &Black, L"F7 to enter Boot Manager Menu.");
+ PrintXY (10, 50, &White, &Black, L"Enter to boot directly.");
+}
+
+/**
+ Do the platform specific action after the console is connected.
+
+ Such as:
+ Dynamically switch output mode;
+ Signal console ready platform customized event;
+ Run diagnostics like memory testing;
+ Connect certain devices;
+ Dispatch aditional option roms.
+**/
+VOID
+EFIAPI
+PlatformBootManagerAfterConsole (
+ VOID
+ )
+{
+
+ //
+ // Go the different platform policy with different boot mode
+ // Notes: this part code can be change with the table policy
+ //
+ switch (GetBootModeHob ()) {
+
+ case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
+ case BOOT_WITH_MINIMAL_CONFIGURATION:
+ PlatformBdsDiagnostics (IGNORE, TRUE);
+
+ //
+ // Perform some platform specific connect sequence
+ //
+ PlatformBdsConnectSequence ();
+ break;
+
+ case BOOT_IN_RECOVERY_MODE:
+ PlatformBdsDiagnostics (EXTENSIVE, FALSE);
+ break;
+
+ case BOOT_WITH_FULL_CONFIGURATION:
+ case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:
+ case BOOT_WITH_DEFAULT_SETTINGS:
+ default:
+ PlatformBdsDiagnostics (IGNORE, TRUE);
+ PlatformBdsRegisterStaticBootOptions ();
+ PlatformBdsConnectSequence ();
+ EfiBootManagerRefreshAllBootOption ();
+ break;
+ }
+}
+
+/**
+ This function is called each second during the boot manager waits the timeout.
+
+ @param TimeoutRemain The remaining timeout.
+**/
+VOID
+EFIAPI
+PlatformBootManagerWaitCallback (
+ UINT16 TimeoutRemain
+ )
+{
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;
+ UINT16 Timeout;
+
+ Timeout = PcdGet16 (PcdPlatformBootTimeOut);
+
+ Black.Raw = 0x00000000;
+ White.Raw = 0x00FFFFFF;
+
+ BootLogoUpdateProgress (
+ White.Pixel,
+ Black.Pixel,
+ L"Start boot option",
+ White.Pixel,
+ (Timeout - TimeoutRemain) * 100 / Timeout,
+ 0
+ );
+}
+
+/**
+ The function is called when no boot option could be launched,
+ including platform recovery options and options pointing to applications
+ built into firmware volumes.
+
+ If this function returns, BDS attempts to enter an infinite loop.
+**/
+VOID
+EFIAPI
+PlatformBootManagerUnableToBoot (
+ VOID
+ )
+{
+ return;
+}
+
diff --git a/EmulatorPkg/Library/EmuBdsLib/BdsPlatform.h b/EmulatorPkg/Library/PlatformBmLib/PlatformBm.h
similarity index 60%
rename from EmulatorPkg/Library/EmuBdsLib/BdsPlatform.h
rename to EmulatorPkg/Library/PlatformBmLib/PlatformBm.h
index 5ececd4bed..323a8bd19a 100644
--- a/EmulatorPkg/Library/EmuBdsLib/BdsPlatform.h
+++ b/EmulatorPkg/Library/PlatformBmLib/PlatformBm.h
@@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
-#ifndef _BDS_PLATFORM_H
-#define _BDS_PLATFORM_H
+#ifndef _PLATFORM_BM_H
+#define _PLATFORM_BM_H
#include <PiDxe.h>
@@ -22,6 +22,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/EmuThunk.h>
#include <Protocol/EmuIoThunk.h>
#include <Protocol/EmuGraphicsWindow.h>
+#include <Protocol/GenericMemoryTest.h>
+#include <Protocol/LoadedImage.h>
+#include <Protocol/FirmwareVolume2.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
@@ -30,15 +33,24 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/MemoryAllocationLib.h>
#include <Library/BaseLib.h>
#include <Library/PcdLib.h>
-#include <Library/GenericBdsLib.h>
-#include <Library/PlatformBdsLib.h>
+#include <Library/UefiBootManagerLib.h>
#include <Library/DevicePathLib.h>
#include <Library/UefiLib.h>
+#include <Library/BootLogoLib.h>
+#include <Library/HobLib.h>
+#include <Library/HiiLib.h>
+#define CONSOLE_OUT 0x00000001
+#define STD_ERROR 0x00000002
+#define CONSOLE_IN 0x00000004
+#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
+
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ UINTN ConnectType;
+} BDS_CONSOLE_CONNECT_ENTRY;
extern BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[];
-extern EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[];
-extern EFI_DEVICE_PATH_PROTOCOL *gPlatformDriverOption[];
#define gEndEntire \
{ \
@@ -61,41 +73,26 @@ typedef struct {
//
// Platform BDS Functions
//
-VOID
-PlatformBdsGetDriverOption (
- IN LIST_ENTRY *BdsDriverLists
- );
-EFI_STATUS
-BdsMemoryTest (
- EXTENDMEM_COVERAGE_LEVEL Level
- );
+/**
+ Perform the memory test base on the memory test intensive level,
+ and update the memory resource.
+ @param Level The memory test intensive level.
-VOID
-PlatformBdsConnectSequence (
- VOID
- );
+ @retval EFI_STATUS Success test all the system memory and update
+ the memory resource
+**/
EFI_STATUS
-ProcessCapsules (
- EFI_BOOT_MODE BootMode
+PlatformBootManagerMemoryTest (
+ IN EXTENDMEM_COVERAGE_LEVEL Level
);
-EFI_STATUS
-PlatformBdsConnectConsole (
- IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole
- );
-
-EFI_STATUS
-PlatformBdsNoConsoleAction (
- VOID
- );
VOID
-PlatformBdsEnterFrontPage (
- IN UINT16 TimeoutDefault,
- IN BOOLEAN ConnectAllHappened
+PlatformBdsConnectSequence (
+ VOID
);
-#endif // _BDS_PLATFORM_H
+#endif // _PLATFORM_BM_H
diff --git a/EmulatorPkg/Library/EmuBdsLib/PlatformData.c b/EmulatorPkg/Library/PlatformBmLib/PlatformBmData.c
similarity index 77%
rename from EmulatorPkg/Library/EmuBdsLib/PlatformData.c
rename to EmulatorPkg/Library/PlatformBmLib/PlatformBmData.c
index 3eb959b894..bb9d7fff2b 100644
--- a/EmulatorPkg/Library/EmuBdsLib/PlatformData.c
+++ b/EmulatorPkg/Library/PlatformBmLib/PlatformBmData.c
@@ -1,6 +1,6 @@
/*++ @file
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2011, Apple Inc. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
-#include "BdsPlatform.h"
+#include "PlatformBm.h"
@@ -62,12 +62,3 @@ BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
}
};
-//
-// Predefined platform specific driver option
-//
-EFI_DEVICE_PATH_PROTOCOL *gPlatformDriverOption[] = { NULL };
-
-//
-// Predefined platform connect sequence
-//
-EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[] = { NULL };
diff --git a/EmulatorPkg/Library/EmuBdsLib/EmuBdsLib.inf b/EmulatorPkg/Library/PlatformBmLib/PlatformBmLib.inf
similarity index 71%
rename from EmulatorPkg/Library/EmuBdsLib/EmuBdsLib.inf
rename to EmulatorPkg/Library/PlatformBmLib/PlatformBmLib.inf
index 755c50c789..af074c3c4b 100644
--- a/EmulatorPkg/Library/EmuBdsLib/EmuBdsLib.inf
+++ b/EmulatorPkg/Library/PlatformBmLib/PlatformBmLib.inf
@@ -1,5 +1,5 @@
## @file
-# Platfrom BDS driver
+# Platfrom Boot Manager library
#
# Do platform action customized by IBV/OEM.
# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
@@ -17,29 +17,29 @@
[Defines]
INF_VERSION = 0x00010005
- BASE_NAME = EmuBdsLib
- FILE_GUID = 59569181-CBF8-2E44-9C3E-C2AB2F5608E1
+ BASE_NAME = PlatformBmLib
+ FILE_GUID = 59569181-CBF8-2E44-9C3E-C2AB2F5608E1
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
- LIBRARY_CLASS = PlatformBdsLib|DXE_DRIVER
+ LIBRARY_CLASS = PlatformBootManagerLib|DXE_DRIVER
#
# The following information is for reference only and not required by the build tools.
#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+# VALID_ARCHITECTURES = IA32 X64
#
[Sources]
- BdsPlatform.c
- PlatformData.c
- BdsPlatform.h
+ PlatformBm.c
+ PlatformBm.h
+ PlatformBmData.c
+ PlatformBmMemoryTest.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
EmulatorPkg/EmulatorPkg.dec
- IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
[LibraryClasses]
BaseLib
@@ -49,19 +49,25 @@ [LibraryClasses]
BaseMemoryLib
DebugLib
PcdLib
- GenericBdsLib
+ UefiBootManagerLib
DevicePathLib
UefiLib
+ BootLogoLib
+ HobLib
+ HiiLib
[Guids]
gEmuSystemConfigGuid
gEfiEndOfDxeEventGroupGuid
+[Protocols]
+ gEfiGenericMemTestProtocolGuid
+
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
- gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile
+ gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand
[Depex]
gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid
diff --git a/EmulatorPkg/Library/PlatformBmLib/PlatformBmMemoryTest.c b/EmulatorPkg/Library/PlatformBmLib/PlatformBmMemoryTest.c
new file mode 100644
index 0000000000..5b39776453
--- /dev/null
+++ b/EmulatorPkg/Library/PlatformBmLib/PlatformBmMemoryTest.c
@@ -0,0 +1,133 @@
+/** @file
+ Perform the platform memory test
+
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "PlatformBm.h"
+
+//
+// BDS Platform Functions
+//
+
+/**
+ Perform the memory test base on the memory test intensive level,
+ and update the memory resource.
+
+ @param Level The memory test intensive level.
+
+ @retval EFI_STATUS Success test all the system memory and update
+ the memory resource
+
+**/
+EFI_STATUS
+PlatformBootManagerMemoryTest (
+ IN EXTENDMEM_COVERAGE_LEVEL Level
+ )
+{
+ EFI_STATUS Status;
+ EFI_STATUS KeyStatus;
+ EFI_STATUS InitStatus;
+ EFI_STATUS ReturnStatus;
+ BOOLEAN RequireSoftECCInit;
+ EFI_GENERIC_MEMORY_TEST_PROTOCOL *GenMemoryTest;
+ UINT64 TestedMemorySize;
+ UINT64 TotalMemorySize;
+ UINT64 PreviousValue;
+ BOOLEAN ErrorOut;
+ BOOLEAN TestAbort;
+ EFI_INPUT_KEY Key;
+ CHAR16 *StrTotalMemory;
+ CHAR16 *Pos;
+ UINTN StrTotalMemorySize;
+
+ ReturnStatus = EFI_SUCCESS;
+ ZeroMem (&Key, sizeof (EFI_INPUT_KEY));
+
+ StrTotalMemorySize = 128;
+ Pos = AllocateZeroPool (StrTotalMemorySize);
+ ASSERT (Pos != NULL);
+
+ StrTotalMemory = Pos;
+
+ TestedMemorySize = 0;
+ TotalMemorySize = 0;
+ PreviousValue = 0;
+ ErrorOut = FALSE;
+ TestAbort = FALSE;
+
+ RequireSoftECCInit = FALSE;
+
+ Status = gBS->LocateProtocol (
+ &gEfiGenericMemTestProtocolGuid,
+ NULL,
+ (VOID **) &GenMemoryTest
+ );
+ if (EFI_ERROR (Status)) {
+ FreePool (Pos);
+ return EFI_SUCCESS;
+ }
+
+ InitStatus = GenMemoryTest->MemoryTestInit (
+ GenMemoryTest,
+ Level,
+ &RequireSoftECCInit
+ );
+ if (InitStatus == EFI_NO_MEDIA) {
+ //
+ // The PEI codes also have the relevant memory test code to check the memory,
+ // it can select to test some range of the memory or all of them. If PEI code
+ // checks all the memory, this BDS memory test will has no not-test memory to
+ // do the test, and then the status of EFI_NO_MEDIA will be returned by
+ // "MemoryTestInit". So it does not need to test memory again, just return.
+ //
+ FreePool (Pos);
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "Enter memory test.\n"));
+ do {
+ Status = GenMemoryTest->PerformMemoryTest (
+ GenMemoryTest,
+ &TestedMemorySize,
+ &TotalMemorySize,
+ &ErrorOut,
+ TestAbort
+ );
+ if (ErrorOut && (Status == EFI_DEVICE_ERROR)) {
+ PrintXY (10, 10, NULL, NULL, L"Memory Testing failed!");
+ ASSERT (0);
+ }
+
+
+ DEBUG ((DEBUG_INFO, "Perform memory test (ESC to skip).\n"));
+
+ if (!PcdGetBool (PcdConInConnectOnDemand)) {
+ KeyStatus = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
+ if (!EFI_ERROR (KeyStatus) && (Key.ScanCode == SCAN_ESC)) {
+ if (!RequireSoftECCInit) {
+ Status = GenMemoryTest->Finished (GenMemoryTest);
+ goto Done;
+ }
+
+ TestAbort = TRUE;
+ }
+ }
+ } while (Status != EFI_NOT_FOUND);
+
+ Status = GenMemoryTest->Finished (GenMemoryTest);
+
+Done:
+ DEBUG ((DEBUG_INFO, "%d bytes of system memory tested OK\r\n", TotalMemorySize));
+
+ FreePool (Pos);
+ return ReturnStatus;
+}
--
2.16.1.windows.1
^ permalink raw reply related [flat|nested] 11+ messages in thread