* [PATCH 01/10] EmulatorPkg/EmuGopDxe: Fix TxtInEx.SetState SCT conformance failure
2018-08-27 7:53 [PATCH 00/10] Quality improvement for EmulatorPkg Win Host Ruiyu Ni
@ 2018-08-27 7:53 ` Ruiyu Ni
2018-08-27 7:53 ` [PATCH 02/10] EmulatorPkg/EmuGopDxe: Clear screen to black in GOP.SetMode Ruiyu Ni
` (9 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: Ruiyu Ni @ 2018-08-27 7:53 UTC (permalink / raw)
To: edk2-devel; +Cc: Hao Wu, Andrew Fish
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1118
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/EmuGopDxe/GopInput.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/EmulatorPkg/EmuGopDxe/GopInput.c b/EmulatorPkg/EmuGopDxe/GopInput.c
index cf37a7bd70..8ac1b996d8 100644
--- a/EmulatorPkg/EmuGopDxe/GopInput.c
+++ b/EmulatorPkg/EmuGopDxe/GopInput.c
@@ -1,6 +1,6 @@
/*++ @file
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2010 0 2011,Apple Inc. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -442,11 +442,20 @@ EmuGopSimpleTextInExSetState (
EFI_STATUS Status;
EFI_TPL OldTpl;
+ if (KeyToggleState == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This);
if (Private->EmuGraphicsWindow == NULL) {
return EFI_NOT_READY;
}
+ if (((Private->KeyState.KeyToggleState & EFI_TOGGLE_STATE_VALID) != EFI_TOGGLE_STATE_VALID) ||
+ ((*KeyToggleState & EFI_TOGGLE_STATE_VALID) != EFI_TOGGLE_STATE_VALID)) {
+ return EFI_UNSUPPORTED;
+ }
+
//
// Enter critical section
//
--
2.16.1.windows.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 02/10] EmulatorPkg/EmuGopDxe: Clear screen to black in GOP.SetMode
2018-08-27 7:53 [PATCH 00/10] Quality improvement for EmulatorPkg Win Host Ruiyu Ni
2018-08-27 7:53 ` [PATCH 01/10] EmulatorPkg/EmuGopDxe: Fix TxtInEx.SetState SCT conformance failure Ruiyu Ni
@ 2018-08-27 7:53 ` Ruiyu Ni
2018-08-27 7:53 ` [PATCH 03/10] EmulatorPkg/Win: Use FrameBufferBltLib for BLT operation Ruiyu Ni
` (8 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: Ruiyu Ni @ 2018-08-27 7:53 UTC (permalink / raw)
To: edk2-devel; +Cc: Hao Wu, Andrew Fish
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1118
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/EmuGopDxe/GopScreen.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/EmulatorPkg/EmuGopDxe/GopScreen.c b/EmulatorPkg/EmuGopDxe/GopScreen.c
index aa21fa68de..0ff7005ab6 100644
--- a/EmulatorPkg/EmuGopDxe/GopScreen.c
+++ b/EmulatorPkg/EmuGopDxe/GopScreen.c
@@ -1,6 +1,6 @@
/*++ @file
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2010 - 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
@@ -146,9 +146,9 @@ EmuGopSetMode (
);
- Fill.Red = 0x7f;
- Fill.Green = 0x7F;
- Fill.Blue = 0x7f;
+ Fill.Red = 0;
+ Fill.Green = 0;
+ Fill.Blue = 0;
This->Blt (
This,
&Fill,
--
2.16.1.windows.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 03/10] EmulatorPkg/Win: Use FrameBufferBltLib for BLT operation
2018-08-27 7:53 [PATCH 00/10] Quality improvement for EmulatorPkg Win Host Ruiyu Ni
2018-08-27 7:53 ` [PATCH 01/10] EmulatorPkg/EmuGopDxe: Fix TxtInEx.SetState SCT conformance failure Ruiyu Ni
2018-08-27 7:53 ` [PATCH 02/10] EmulatorPkg/EmuGopDxe: Clear screen to black in GOP.SetMode Ruiyu Ni
@ 2018-08-27 7:53 ` Ruiyu Ni
2018-08-27 7:53 ` [PATCH 04/10] EmulatorPkg/Win: ReadKeyStrokeEx() always returns correct KeyState Ruiyu Ni
` (7 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: Ruiyu Ni @ 2018-08-27 7:53 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] 16+ messages in thread
* [PATCH 04/10] EmulatorPkg/Win: ReadKeyStrokeEx() always returns correct KeyState
2018-08-27 7:53 [PATCH 00/10] Quality improvement for EmulatorPkg Win Host Ruiyu Ni
` (2 preceding siblings ...)
2018-08-27 7:53 ` [PATCH 03/10] EmulatorPkg/Win: Use FrameBufferBltLib for BLT operation Ruiyu Ni
@ 2018-08-27 7:53 ` Ruiyu Ni
2018-08-27 7:53 ` [PATCH 05/10] EmulatorPkg/Win: Do not zero out file content Ruiyu Ni
` (6 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: Ruiyu Ni @ 2018-08-27 7:53 UTC (permalink / raw)
To: edk2-devel; +Cc: Hao Wu, Andrew Fish
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1118
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/Win/Host/WinGopInput.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/EmulatorPkg/Win/Host/WinGopInput.c b/EmulatorPkg/Win/Host/WinGopInput.c
index 6c218ab98a..17d35bb52c 100644
--- a/EmulatorPkg/Win/Host/WinGopInput.c
+++ b/EmulatorPkg/Win/Host/WinGopInput.c
@@ -363,6 +363,23 @@ WinNtWndKeySetState (
GRAPHICS_PRIVATE_DATA *Private;
Private = GRAPHICS_PRIVATE_DATA_FROM_THIS (GraphicsIo);
+ Private->ScrollLock = FALSE;
+ Private->NumLock = FALSE;
+ Private->CapsLock = FALSE;
+ Private->IsPartialKeySupport = FALSE;
+
+ if ((*KeyToggleState & EFI_SCROLL_LOCK_ACTIVE) == EFI_SCROLL_LOCK_ACTIVE) {
+ Private->ScrollLock = TRUE;
+ }
+ if ((*KeyToggleState & EFI_NUM_LOCK_ACTIVE) == EFI_NUM_LOCK_ACTIVE) {
+ Private->NumLock = TRUE;
+ }
+ if ((*KeyToggleState & EFI_CAPS_LOCK_ACTIVE) == EFI_CAPS_LOCK_ACTIVE) {
+ Private->CapsLock = TRUE;
+ }
+ if ((*KeyToggleState & EFI_KEY_STATE_EXPOSED) == EFI_KEY_STATE_EXPOSED) {
+ Private->IsPartialKeySupport = TRUE;
+ }
Private->KeyState.KeyToggleState = *KeyToggleState;
return EFI_SUCCESS;
}
--
2.16.1.windows.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 05/10] EmulatorPkg/Win: Do not zero out file content
2018-08-27 7:53 [PATCH 00/10] Quality improvement for EmulatorPkg Win Host Ruiyu Ni
` (3 preceding siblings ...)
2018-08-27 7:53 ` [PATCH 04/10] EmulatorPkg/Win: ReadKeyStrokeEx() always returns correct KeyState Ruiyu Ni
@ 2018-08-27 7:53 ` Ruiyu Ni
2018-08-29 1:51 ` Wu, Hao A
2018-08-27 7:53 ` [PATCH 06/10] EmulatorPkg/Win: Enable 64bit (SEC, PEI, DXE all run at 64bit) Ruiyu Ni
` (5 subsequent siblings)
10 siblings, 1 reply; 16+ messages in thread
From: Ruiyu Ni @ 2018-08-27 7:53 UTC (permalink / raw)
To: edk2-devel; +Cc: Hao Wu, Andrew Fish
The patch changes the behavior to not zero out file content
when the file size is not multiple of block size.
Instead, it just provides access to the contents that are
multiple of block size and leaves the remaining content (less than
block size) untouched.
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/Win/Host/WinBlockIo.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/EmulatorPkg/Win/Host/WinBlockIo.c b/EmulatorPkg/Win/Host/WinBlockIo.c
index 14491a6e90..7df7d42c7c 100644
--- a/EmulatorPkg/Win/Host/WinBlockIo.c
+++ b/EmulatorPkg/Win/Host/WinBlockIo.c
@@ -90,6 +90,7 @@ WinNtBlockIoOpenDevice (
{
EFI_STATUS Status;
UINT64 FileSize;
+ UINT64 EndOfFile;
//
// If the device is already opened, close it
@@ -112,7 +113,7 @@ WinNtBlockIoOpenDevice (
);
if (Private->NtHandle == INVALID_HANDLE_VALUE) {
- DEBUG ((EFI_D_INFO, "OpenBlock: Could not open %S, %x\n", Private->FileName, GetLastError ()));
+ DEBUG ((EFI_D_INFO, "PlOpenBlock: Could not open %S, %x\n", Private->FileName, GetLastError ()));
Media->MediaPresent = FALSE;
Status = EFI_NO_MEDIA;
goto Done;
@@ -124,14 +125,35 @@ WinNtBlockIoOpenDevice (
Status = SetFilePointer64 (Private, 0, &FileSize, FILE_END);
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "OpenBlock: Could not get filesize of %s\n", Private->FileName));
+ DEBUG ((EFI_D_ERROR, "PlOpenBlock: Could not get filesize of %s\n", Private->FileName));
Status = EFI_UNSUPPORTED;
goto Done;
}
Media->LastBlock = DivU64x32 (FileSize, (UINT32)Private->BlockSize) - 1;
- DEBUG ((EFI_D_INIT, "OpenBlock: opened %S\n", Private->FileName));
+ EndOfFile = MultU64x32 (Media->LastBlock + 1, (UINT32)Private->BlockSize);
+
+ if (FileSize != EndOfFile) {
+ //
+ // file is not the proper size, change it
+ //
+ DEBUG ((EFI_D_INIT, "PlOpenBlock: Initializing block device: %hs\n", Private->FileName));
+
+ //
+ // first set it to 0
+ //
+ SetFilePointer64 (Private, 0, NULL, FILE_BEGIN);
+ SetEndOfFile (Private->NtHandle);
+
+ //
+ // then set it to the needed file size (OS will zero fill it)
+ //
+ SetFilePointer64 (Private, EndOfFile, NULL, FILE_BEGIN);
+ SetEndOfFile (Private->NtHandle);
+ }
+
+ DEBUG ((EFI_D_INIT, "PlOpenBlock: opened %S\n", Private->FileName));
Status = EFI_SUCCESS;
Done:
--
2.16.1.windows.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 05/10] EmulatorPkg/Win: Do not zero out file content
2018-08-27 7:53 ` [PATCH 05/10] EmulatorPkg/Win: Do not zero out file content Ruiyu Ni
@ 2018-08-29 1:51 ` Wu, Hao A
0 siblings, 0 replies; 16+ messages in thread
From: Wu, Hao A @ 2018-08-29 1:51 UTC (permalink / raw)
To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Andrew Fish
> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Monday, August 27, 2018 3:53 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A; Andrew Fish
> Subject: [PATCH 05/10] EmulatorPkg/Win: Do not zero out file content
>
> The patch changes the behavior to not zero out file content
> when the file size is not multiple of block size.
> Instead, it just provides access to the contents that are
> multiple of block size and leaves the remaining content (less than
> block size) untouched.
>
> 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/Win/Host/WinBlockIo.c | 28 +++++++++++++++++++++++++---
> 1 file changed, 25 insertions(+), 3 deletions(-)
>
> diff --git a/EmulatorPkg/Win/Host/WinBlockIo.c
> b/EmulatorPkg/Win/Host/WinBlockIo.c
> index 14491a6e90..7df7d42c7c 100644
> --- a/EmulatorPkg/Win/Host/WinBlockIo.c
> +++ b/EmulatorPkg/Win/Host/WinBlockIo.c
> @@ -90,6 +90,7 @@ WinNtBlockIoOpenDevice (
> {
> EFI_STATUS Status;
> UINT64 FileSize;
> + UINT64 EndOfFile;
>
> //
> // If the device is already opened, close it
> @@ -112,7 +113,7 @@ WinNtBlockIoOpenDevice (
> );
>
> if (Private->NtHandle == INVALID_HANDLE_VALUE) {
> - DEBUG ((EFI_D_INFO, "OpenBlock: Could not open %S, %x\n", Private-
> >FileName, GetLastError ()));
> + DEBUG ((EFI_D_INFO, "PlOpenBlock: Could not open %S, %x\n", Private-
> >FileName, GetLastError ()));
> Media->MediaPresent = FALSE;
> Status = EFI_NO_MEDIA;
> goto Done;
> @@ -124,14 +125,35 @@ WinNtBlockIoOpenDevice (
> Status = SetFilePointer64 (Private, 0, &FileSize, FILE_END);
>
> if (EFI_ERROR (Status)) {
> - DEBUG ((EFI_D_ERROR, "OpenBlock: Could not get filesize of %s\n", Private-
> >FileName));
> + DEBUG ((EFI_D_ERROR, "PlOpenBlock: Could not get filesize of %s\n",
> Private->FileName));
> Status = EFI_UNSUPPORTED;
> goto Done;
> }
>
> Media->LastBlock = DivU64x32 (FileSize, (UINT32)Private->BlockSize) - 1;
>
> - DEBUG ((EFI_D_INIT, "OpenBlock: opened %S\n", Private->FileName));
> + EndOfFile = MultU64x32 (Media->LastBlock + 1, (UINT32)Private->BlockSize);
> +
Hi Ray,
The below logic seems actually zeroing out the file content if the file
size is not a multiple of block size. Could you help to double confirm
this one?
Best Regards,
Hao Wu
> + if (FileSize != EndOfFile) {
> + //
> + // file is not the proper size, change it
> + //
> + DEBUG ((EFI_D_INIT, "PlOpenBlock: Initializing block device: %hs\n",
> Private->FileName));
> +
> + //
> + // first set it to 0
> + //
> + SetFilePointer64 (Private, 0, NULL, FILE_BEGIN);
> + SetEndOfFile (Private->NtHandle);
> +
> + //
> + // then set it to the needed file size (OS will zero fill it)
> + //
> + SetFilePointer64 (Private, EndOfFile, NULL, FILE_BEGIN);
> + SetEndOfFile (Private->NtHandle);
> + }
> +
> + DEBUG ((EFI_D_INIT, "PlOpenBlock: opened %S\n", Private->FileName));
> Status = EFI_SUCCESS;
>
> Done:
> --
> 2.16.1.windows.1
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 06/10] EmulatorPkg/Win: Enable 64bit (SEC, PEI, DXE all run at 64bit)
2018-08-27 7:53 [PATCH 00/10] Quality improvement for EmulatorPkg Win Host Ruiyu Ni
` (4 preceding siblings ...)
2018-08-27 7:53 ` [PATCH 05/10] EmulatorPkg/Win: Do not zero out file content Ruiyu Ni
@ 2018-08-27 7:53 ` Ruiyu Ni
2018-08-27 7:53 ` [PATCH 07/10] EmulatorPkg/AutoScanPei: Report the correct CPU address size Ruiyu Ni
` (4 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: Ruiyu Ni @ 2018-08-27 7:53 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 | 6 +-----
EmulatorPkg/Win/Host/WinBlockIo.c | 2 +-
EmulatorPkg/Win/Host/WinHost.c | 2 +-
3 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
index ee85c9ef64..72e8aa1788 100644
--- a/EmulatorPkg/EmulatorPkg.dsc
+++ b/EmulatorPkg/EmulatorPkg.dsc
@@ -22,11 +22,7 @@ [Defines]
PLATFORM_GUID = 05FD064D-1073-E844-936C-A0E16317107D
PLATFORM_VERSION = 0.3
DSC_SPECIFICATION = 0x00010005
-!if $(BUILD_32)
- OUTPUT_DIRECTORY = Build/Emulator32
-!else
- OUTPUT_DIRECTORY = Build/Emulator
-!endif
+ OUTPUT_DIRECTORY = Build/Emulator$(ARCH)
SUPPORTED_ARCHITECTURES = X64|IA32
BUILD_TARGETS = DEBUG|RELEASE
diff --git a/EmulatorPkg/Win/Host/WinBlockIo.c b/EmulatorPkg/Win/Host/WinBlockIo.c
index 7df7d42c7c..33c1ce21b0 100644
--- a/EmulatorPkg/Win/Host/WinBlockIo.c
+++ b/EmulatorPkg/Win/Host/WinBlockIo.c
@@ -24,7 +24,7 @@ typedef struct {
BOOLEAN Readonly;
HANDLE NtHandle;
- UINTN BlockSize;
+ UINT32 BlockSize;
EFI_BLOCK_IO_MEDIA *Media;
EMU_BLOCK_IO_PROTOCOL EmuBlockIo;
diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c
index 0cf02044c2..9b98d5330f 100644
--- a/EmulatorPkg/Win/Host/WinHost.c
+++ b/EmulatorPkg/Win/Host/WinHost.c
@@ -466,7 +466,7 @@ Returns:
SecPrint ("ERROR : Can not allocate enough space for SecStack\n");
exit (1);
}
- SetMemN (TemporaryRam, TemporaryRamSize, PcdGet32 (PcdInitValueInTempStack));
+ SetMem32 (TemporaryRam, TemporaryRamSize, PcdGet32 (PcdInitValueInTempStack));
SecPrint (" OS Emulator passing in %u KB of temp RAM at 0x%08lx to SEC\n",
TemporaryRamSize / SIZE_1KB,
--
2.16.1.windows.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 07/10] EmulatorPkg/AutoScanPei: Report the correct CPU address size
2018-08-27 7:53 [PATCH 00/10] Quality improvement for EmulatorPkg Win Host Ruiyu Ni
` (5 preceding siblings ...)
2018-08-27 7:53 ` [PATCH 06/10] EmulatorPkg/Win: Enable 64bit (SEC, PEI, DXE all run at 64bit) Ruiyu Ni
@ 2018-08-27 7:53 ` Ruiyu Ni
2018-08-29 1:54 ` Wu, Hao A
2018-08-27 7:53 ` [PATCH 08/10] EmulatorPkg/Win: Add VS2017 project file Ruiyu Ni
` (3 subsequent siblings)
10 siblings, 1 reply; 16+ messages in thread
From: Ruiyu Ni @ 2018-08-27 7:53 UTC (permalink / raw)
To: edk2-devel; +Cc: Hao Wu, Andrew Fish
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1119
Today's implementation unconditionally reports CPU address size
as 36 through CPU HOB. But when WinHost is running at 64bit,
the system memory might be allocated above 2^36.
It causes system asserts when DxeCore code tries to find the
corresponding GCD entry for a given valid address.
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/AutoScanPei/AutoScanPei.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/EmulatorPkg/AutoScanPei/AutoScanPei.c b/EmulatorPkg/AutoScanPei/AutoScanPei.c
index 78a40db3a2..bf9958a4a9 100644
--- a/EmulatorPkg/AutoScanPei/AutoScanPei.c
+++ b/EmulatorPkg/AutoScanPei/AutoScanPei.c
@@ -1,6 +1,6 @@
/*++ @file
-Copyright (c) 2006 - 2008, 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
@@ -51,7 +51,8 @@ Returns:
EFI_PHYSICAL_ADDRESS MemoryBase;
UINTN Index;
EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;
-
+ UINTN HighBitSet;
+ UINT8 SizeOfMemorySpace;
DEBUG ((EFI_D_ERROR, "Emu Autoscan PEIM Loaded\n"));
@@ -66,7 +67,8 @@ Returns:
);
ASSERT_EFI_ERROR (Status);
- Index = 0;
+ SizeOfMemorySpace = 0;
+ Index = 0;
do {
Status = Thunk->MemoryAutoScan (Index, &MemoryBase, &MemorySize);
if (!EFI_ERROR (Status)) {
@@ -96,6 +98,12 @@ Returns:
MemoryBase,
MemorySize
);
+ HighBitSet = HighBitSet64 (MemoryBase + MemorySize);
+ SizeOfMemorySpace = MAX (SizeOfMemorySpace, (UINT8)HighBitSet + 1);
+ DEBUG ((
+ DEBUG_INFO, "Emu Memory Discoverred[%d]: Base = %016lx / Size = %016x\n",
+ Index, MemoryBase, MemorySize
+ ));
}
Index++;
} while (!EFI_ERROR (Status));
@@ -103,7 +111,8 @@ Returns:
//
// Build the CPU hob with 36-bit addressing and 16-bits of IO space.
//
- BuildCpuHob (36, 16);
+ DEBUG ((DEBUG_INFO, "Emu SizeOfMemorySpace = %d\n", SizeOfMemorySpace));
+ BuildCpuHob (SizeOfMemorySpace, 16);
return Status;
}
--
2.16.1.windows.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 07/10] EmulatorPkg/AutoScanPei: Report the correct CPU address size
2018-08-27 7:53 ` [PATCH 07/10] EmulatorPkg/AutoScanPei: Report the correct CPU address size Ruiyu Ni
@ 2018-08-29 1:54 ` Wu, Hao A
2018-08-29 2:53 ` Ni, Ruiyu
0 siblings, 1 reply; 16+ messages in thread
From: Wu, Hao A @ 2018-08-29 1:54 UTC (permalink / raw)
To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Andrew Fish
> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Monday, August 27, 2018 3:53 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A; Andrew Fish
> Subject: [PATCH 07/10] EmulatorPkg/AutoScanPei: Report the correct CPU
> address size
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1119
>
> Today's implementation unconditionally reports CPU address size
> as 36 through CPU HOB. But when WinHost is running at 64bit,
> the system memory might be allocated above 2^36.
>
> It causes system asserts when DxeCore code tries to find the
> corresponding GCD entry for a given valid address.
>
> 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/AutoScanPei/AutoScanPei.c | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/EmulatorPkg/AutoScanPei/AutoScanPei.c
> b/EmulatorPkg/AutoScanPei/AutoScanPei.c
> index 78a40db3a2..bf9958a4a9 100644
> --- a/EmulatorPkg/AutoScanPei/AutoScanPei.c
> +++ b/EmulatorPkg/AutoScanPei/AutoScanPei.c
> @@ -1,6 +1,6 @@
> /*++ @file
>
> -Copyright (c) 2006 - 2008, 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
> @@ -51,7 +51,8 @@ Returns:
> EFI_PHYSICAL_ADDRESS MemoryBase;
> UINTN Index;
> EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;
> -
> + UINTN HighBitSet;
> + UINT8 SizeOfMemorySpace;
>
> DEBUG ((EFI_D_ERROR, "Emu Autoscan PEIM Loaded\n"));
>
> @@ -66,7 +67,8 @@ Returns:
> );
> ASSERT_EFI_ERROR (Status);
>
> - Index = 0;
> + SizeOfMemorySpace = 0;
> + Index = 0;
> do {
> Status = Thunk->MemoryAutoScan (Index, &MemoryBase, &MemorySize);
> if (!EFI_ERROR (Status)) {
> @@ -96,6 +98,12 @@ Returns:
> MemoryBase,
> MemorySize
> );
> + HighBitSet = HighBitSet64 (MemoryBase + MemorySize);
> + SizeOfMemorySpace = MAX (SizeOfMemorySpace, (UINT8)HighBitSet + 1);
> + DEBUG ((
> + DEBUG_INFO, "Emu Memory Discoverred[%d]: Base = %016lx / Size
> = %016x\n",
> + Index, MemoryBase, MemorySize
> + ));
> }
> Index++;
> } while (!EFI_ERROR (Status));
> @@ -103,7 +111,8 @@ Returns:
> //
> // Build the CPU hob with 36-bit addressing and 16-bits of IO space.
> //
> - BuildCpuHob (36, 16);
> + DEBUG ((DEBUG_INFO, "Emu SizeOfMemorySpace = %d\n",
> SizeOfMemorySpace));
> + BuildCpuHob (SizeOfMemorySpace, 16);
Hi Ray,
Just a question, I saw the implementation in Nt32Pkg just hard-code the
address size to 52 to support both 32-bit and 64-bit. Is there a concern
for hard coding it to 52?
Best Regards,
Hao Wu
>
> return Status;
> }
> --
> 2.16.1.windows.1
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 07/10] EmulatorPkg/AutoScanPei: Report the correct CPU address size
2018-08-29 1:54 ` Wu, Hao A
@ 2018-08-29 2:53 ` Ni, Ruiyu
0 siblings, 0 replies; 16+ messages in thread
From: Ni, Ruiyu @ 2018-08-29 2:53 UTC (permalink / raw)
To: Wu, Hao A, edk2-devel@lists.01.org; +Cc: Andrew Fish
On 8/29/2018 9:54 AM, Wu, Hao A wrote:
>> -----Original Message-----
>> From: Ni, Ruiyu
>> Sent: Monday, August 27, 2018 3:53 PM
>> To: edk2-devel@lists.01.org
>> Cc: Wu, Hao A; Andrew Fish
>> Subject: [PATCH 07/10] EmulatorPkg/AutoScanPei: Report the correct CPU
>> address size
>>
>> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1119
>>
>> Today's implementation unconditionally reports CPU address size
>> as 36 through CPU HOB. But when WinHost is running at 64bit,
>> the system memory might be allocated above 2^36.
>>
>> It causes system asserts when DxeCore code tries to find the
>> corresponding GCD entry for a given valid address.
>>
>> 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/AutoScanPei/AutoScanPei.c | 17 +++++++++++++----
>> 1 file changed, 13 insertions(+), 4 deletions(-)
>>
>> diff --git a/EmulatorPkg/AutoScanPei/AutoScanPei.c
>> b/EmulatorPkg/AutoScanPei/AutoScanPei.c
>> index 78a40db3a2..bf9958a4a9 100644
>> --- a/EmulatorPkg/AutoScanPei/AutoScanPei.c
>> +++ b/EmulatorPkg/AutoScanPei/AutoScanPei.c
>> @@ -1,6 +1,6 @@
>> /*++ @file
>>
>> -Copyright (c) 2006 - 2008, 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
>> @@ -51,7 +51,8 @@ Returns:
>> EFI_PHYSICAL_ADDRESS MemoryBase;
>> UINTN Index;
>> EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;
>> -
>> + UINTN HighBitSet;
>> + UINT8 SizeOfMemorySpace;
>>
>> DEBUG ((EFI_D_ERROR, "Emu Autoscan PEIM Loaded\n"));
>>
>> @@ -66,7 +67,8 @@ Returns:
>> );
>> ASSERT_EFI_ERROR (Status);
>>
>> - Index = 0;
>> + SizeOfMemorySpace = 0;
>> + Index = 0;
>> do {
>> Status = Thunk->MemoryAutoScan (Index, &MemoryBase, &MemorySize);
>> if (!EFI_ERROR (Status)) {
>> @@ -96,6 +98,12 @@ Returns:
>> MemoryBase,
>> MemorySize
>> );
>> + HighBitSet = HighBitSet64 (MemoryBase + MemorySize);
>> + SizeOfMemorySpace = MAX (SizeOfMemorySpace, (UINT8)HighBitSet + 1);
>> + DEBUG ((
>> + DEBUG_INFO, "Emu Memory Discoverred[%d]: Base = %016lx / Size
>> = %016x\n",
>> + Index, MemoryBase, MemorySize
>> + ));
>> }
>> Index++;
>> } while (!EFI_ERROR (Status));
>> @@ -103,7 +111,8 @@ Returns:
>> //
>> // Build the CPU hob with 36-bit addressing and 16-bits of IO space.
>> //
>> - BuildCpuHob (36, 16);
>> + DEBUG ((DEBUG_INFO, "Emu SizeOfMemorySpace = %d\n",
>> SizeOfMemorySpace));
>> + BuildCpuHob (SizeOfMemorySpace, 16);
>
> Hi Ray,
>
> Just a question, I saw the implementation in Nt32Pkg just hard-code the
> address size to 52 to support both 32-bit and 64-bit. Is there a concern
> for hard coding it to 52?
I didn't check the NT32 implementation. I will try to use 64 directly.
52 may become insufficient when 5-level paging is widely used in OS.
>
> Best Regards,
> Hao Wu
>
>>
>> return Status;
>> }
>> --
>> 2.16.1.windows.1
>
--
Thanks,
Ray
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 08/10] EmulatorPkg/Win: Add VS2017 project file
2018-08-27 7:53 [PATCH 00/10] Quality improvement for EmulatorPkg Win Host Ruiyu Ni
` (6 preceding siblings ...)
2018-08-27 7:53 ` [PATCH 07/10] EmulatorPkg/AutoScanPei: Report the correct CPU address size Ruiyu Ni
@ 2018-08-27 7:53 ` Ruiyu Ni
2018-08-27 7:53 ` [PATCH 09/10] EmulatorPkg: Use MdeModulePkg/Bds module Ruiyu Ni
` (2 subsequent siblings)
10 siblings, 0 replies; 16+ messages in thread
From: Ruiyu Ni @ 2018-08-27 7:53 UTC (permalink / raw)
To: edk2-devel; +Cc: Hao Wu, Andrew Fish
Developer can build the Win Host in VS2017 and launch to debug it.
Platform 'x64' is to build 64bit EmulatorWin.
Platform 'Win32' is to build 32bit EmulatorWin.
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/Win/VS2017/BuildVS.bat | 3 +
EmulatorPkg/Win/VS2017/Win.sln | 31 ++++++++
EmulatorPkg/Win/VS2017/Win.vcxproj | 120 +++++++++++++++++++++++++++++
EmulatorPkg/Win/VS2017/Win.vcxproj.filters | 50 ++++++++++++
EmulatorPkg/Win/VS2017/Win.vcxproj.user | 13 ++++
5 files changed, 217 insertions(+)
create mode 100644 EmulatorPkg/Win/VS2017/BuildVS.bat
create mode 100644 EmulatorPkg/Win/VS2017/Win.sln
create mode 100644 EmulatorPkg/Win/VS2017/Win.vcxproj
create mode 100644 EmulatorPkg/Win/VS2017/Win.vcxproj.filters
create mode 100644 EmulatorPkg/Win/VS2017/Win.vcxproj.user
diff --git a/EmulatorPkg/Win/VS2017/BuildVS.bat b/EmulatorPkg/Win/VS2017/BuildVS.bat
new file mode 100644
index 0000000000..a485a3c563
--- /dev/null
+++ b/EmulatorPkg/Win/VS2017/BuildVS.bat
@@ -0,0 +1,3 @@
+cd ../../../
+@call edksetup.bat
+build -p EmulatorPkg\EmulatorPkg.dsc -t VS2017 -D WIN_SEC_BUILD %*
diff --git a/EmulatorPkg/Win/VS2017/Win.sln b/EmulatorPkg/Win/VS2017/Win.sln
new file mode 100644
index 0000000000..650b404463
--- /dev/null
+++ b/EmulatorPkg/Win/VS2017/Win.sln
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.28010.2003
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Win", "Win.vcxproj", "{B4E1783F-FD72-4214-B0F7-69271BAD5DDF}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|Win32 = Debug|Win32
+ Release|x64 = Release|x64
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {B4E1783F-FD72-4214-B0F7-69271BAD5DDF}.Debug|x64.ActiveCfg = Debug|x64
+ {B4E1783F-FD72-4214-B0F7-69271BAD5DDF}.Debug|x64.Build.0 = Debug|x64
+ {B4E1783F-FD72-4214-B0F7-69271BAD5DDF}.Debug|Win32.ActiveCfg = Debug|Win32
+ {B4E1783F-FD72-4214-B0F7-69271BAD5DDF}.Debug|Win32.Build.0 = Debug|Win32
+ {B4E1783F-FD72-4214-B0F7-69271BAD5DDF}.Release|x64.ActiveCfg = Release|x64
+ {B4E1783F-FD72-4214-B0F7-69271BAD5DDF}.Release|x64.Build.0 = Release|x64
+ {B4E1783F-FD72-4214-B0F7-69271BAD5DDF}.Release|Win32.ActiveCfg = Release|Win32
+ {B4E1783F-FD72-4214-B0F7-69271BAD5DDF}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {870972CA-19D5-4FC0-BF7A-E4C7A46679F0}
+ EndGlobalSection
+EndGlobal
diff --git a/EmulatorPkg/Win/VS2017/Win.vcxproj b/EmulatorPkg/Win/VS2017/Win.vcxproj
new file mode 100644
index 0000000000..0f574a8e7f
--- /dev/null
+++ b/EmulatorPkg/Win/VS2017/Win.vcxproj
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <VCProjectVersion>15.0</VCProjectVersion>
+ <ProjectGuid>{B4E1783F-FD72-4214-B0F7-69271BAD5DDF}</ProjectGuid>
+ <Keyword>MakeFileProj</Keyword>
+ <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Makefile</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Makefile</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Makefile</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Makefile</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <NMakeBuildCommandLine>BuildVS.bat -a IA32</NMakeBuildCommandLine>
+ <NMakeReBuildCommandLine>BuildVS.bat -a IA32 all</NMakeReBuildCommandLine>
+ <NMakeCleanCommandLine>BuildVS.bat -a IA32 clean</NMakeCleanCommandLine>
+ <OutDir>..\..\..\Build\EmulatorIA32\DEBUG_VS2017\</OutDir>
+ <IntDir>..\..\..\Build\EmulatorIA32\DEBUG_VS2017\</IntDir>
+ <IncludePath>..\..\..\MdePkg\Include;..\..\..\MdePkg\Include\Ia32;..\..\..\MdeModulePkg\Include;..\..\..\EmulatorPkg\Include;$(IncludePath)</IncludePath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <NMakeBuildCommandLine>BuildVS.bat -a IA32 -b RELEASE</NMakeBuildCommandLine>
+ <NMakePreprocessorDefinitions>
+ </NMakePreprocessorDefinitions>
+ <NMakeReBuildCommandLine>BuildVS.bat -a IA32 -b RELEASE all</NMakeReBuildCommandLine>
+ <NMakeCleanCommandLine>BuildVS.bat -a IA32 -b RELEASE clean</NMakeCleanCommandLine>
+ <OutDir>..\..\..\Build\EmulatorIA32\DEBUG_VS2017\</OutDir>
+ <IntDir>..\..\..\Build\EmulatorIA32\DEBUG_VS2017\</IntDir>
+ <IncludePath>..\..\..\MdePkg\Include;..\..\..\MdePkg\Include\Ia32;..\..\..\MdeModulePkg\Include;..\..\..\EmulatorPkg\Include;$(IncludePath)</IncludePath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <NMakeBuildCommandLine>BuildVS.bat -a X64</NMakeBuildCommandLine>
+ <NMakeReBuildCommandLine>BuildVS.bat -a X64 all</NMakeReBuildCommandLine>
+ <NMakeCleanCommandLine>BuildVS.bat -a X64 clean</NMakeCleanCommandLine>
+ <OutDir>..\..\..\Build\EmulatorX64\DEBUG_VS2017\</OutDir>
+ <IntDir>..\..\..\Build\EmulatorX64\DEBUG_VS2017\</IntDir>
+ <IncludePath>..\..\..\MdePkg\Include;..\..\..\MdePkg\Include\X64;..\..\..\MdeModulePkg\Include;..\..\..\EmulatorPkg\Include;$(IncludePath)</IncludePath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <NMakeBuildCommandLine>BuildVS.bat -a X64 -b RELEASE</NMakeBuildCommandLine>
+ <NMakeReBuildCommandLine>BuildVS.bat -a X64 -b RELEASE all</NMakeReBuildCommandLine>
+ <NMakeCleanCommandLine>BuildVS.bat -a X64 -b RELEASE clean</NMakeCleanCommandLine>
+ <OutDir>..\..\Build\EmulatorX64\DEBUG_VS2017\</OutDir>
+ <IntDir>..\..\Build\EmulatorX64\DEBUG_VS2017\</IntDir>
+ <IncludePath>..\..\..\MdePkg\Include;..\..\..\MdePkg\Include\X64;..\..\..\MdeModulePkg\Include;..\..\..\EmulatorPkg\Include;$(IncludePath)</IncludePath>
+ </PropertyGroup>
+ <ItemGroup>
+ <ClCompile Include="..\Host\WinBlockIo.c" />
+ <ClCompile Include="..\Host\WinFileSystem.c" />
+ <ClCompile Include="..\Host\WinGopInput.c" />
+ <ClCompile Include="..\Host\WinGopScreen.c" />
+ <ClCompile Include="..\Host\WinHost.c" />
+ <ClCompile Include="..\Host\WinMemoryAllocationLib.c" />
+ <ClCompile Include="..\Host\WinThunk.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\Host\WinGop.h" />
+ <ClInclude Include="..\Host\WinHost.h" />
+ <ClInclude Include="..\Host\WinInclude.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="..\Host\WinHost.inf" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
diff --git a/EmulatorPkg/Win/VS2017/Win.vcxproj.filters b/EmulatorPkg/Win/VS2017/Win.vcxproj.filters
new file mode 100644
index 0000000000..3e176597ba
--- /dev/null
+++ b/EmulatorPkg/Win/VS2017/Win.vcxproj.filters
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="host\WinBlockIo.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="host\WinFileSystem.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="host\WinGopInput.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="host\WinGopScreen.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="host\WinHost.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="host\WinMemoryAllocationLib.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="host\WinThunk.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="host\WinGop.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="host\WinHost.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="host\WinInclude.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Host\WinHost.inf" />
+ </ItemGroup>
+</Project>
\ No newline at end of file
diff --git a/EmulatorPkg/Win/VS2017/Win.vcxproj.user b/EmulatorPkg/Win/VS2017/Win.vcxproj.user
new file mode 100644
index 0000000000..7ccf83f132
--- /dev/null
+++ b/EmulatorPkg/Win/VS2017/Win.vcxproj.user
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LocalDebuggerCommand>WinHost.exe</LocalDebuggerCommand>
+ <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
+ <LocalDebuggerWorkingDirectory>$(ProjectDir)..\..\..\Build\EmulatorIA32\DEBUG_VS2017\IA32\</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LocalDebuggerCommand>WinHost.exe</LocalDebuggerCommand>
+ <LocalDebuggerWorkingDirectory>$(ProjectDir)..\..\..\Build\EmulatorX64\DEBUG_VS2017\X64\</LocalDebuggerWorkingDirectory>
+ <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
+ </PropertyGroup>
+</Project>
\ No newline at end of file
--
2.16.1.windows.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 09/10] EmulatorPkg: Use MdeModulePkg/Bds module
2018-08-27 7:53 [PATCH 00/10] Quality improvement for EmulatorPkg Win Host Ruiyu Ni
` (7 preceding siblings ...)
2018-08-27 7:53 ` [PATCH 08/10] EmulatorPkg/Win: Add VS2017 project file Ruiyu Ni
@ 2018-08-27 7:53 ` Ruiyu Ni
2018-08-27 7:53 ` [PATCH 10/10] EmulatorPkg: IoThunk->Close() is called too early, may causing hang Ruiyu Ni
2018-08-29 1:58 ` [PATCH 00/10] Quality improvement for EmulatorPkg Win Host Wu, Hao A
10 siblings, 0 replies; 16+ messages in thread
From: Ruiyu Ni @ 2018-08-27 7:53 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} | 57 +--
.../PlatformBmData.c} | 13 +-
.../PlatformBmLib.inf} | 28 +-
.../Library/PlatformBmLib/PlatformBmMemoryTest.c | 133 +++++
8 files changed, 646 insertions(+), 631 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} (62%)
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..325d32fa2f 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/LoadFileOnFv2/LoadFileOnFv2.inf
+ MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
+ MdeModulePkg/Logo/LogoDxe.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..fa9d483087 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/Logo/LogoDxe.inf
+INF MdeModulePkg/Universal/LoadFileOnFv2/LoadFileOnFv2.inf
+INF MdeModulePkg/Universal/BdsDxe/BdsDxe.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..14a7eea989
--- /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 ((EFI_D_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 62%
rename from EmulatorPkg/Library/EmuBdsLib/BdsPlatform.h
rename to EmulatorPkg/Library/PlatformBmLib/PlatformBm.h
index 5ececd4bed..5ac2fa519a 100644
--- a/EmulatorPkg/Library/EmuBdsLib/BdsPlatform.h
+++ b/EmulatorPkg/Library/PlatformBmLib/PlatformBm.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
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..e1864e2b9b
--- /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 ((EFI_D_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 ((EFI_D_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 ((EFI_D_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] 16+ messages in thread
* [PATCH 10/10] EmulatorPkg: IoThunk->Close() is called too early, may causing hang
2018-08-27 7:53 [PATCH 00/10] Quality improvement for EmulatorPkg Win Host Ruiyu Ni
` (8 preceding siblings ...)
2018-08-27 7:53 ` [PATCH 09/10] EmulatorPkg: Use MdeModulePkg/Bds module Ruiyu Ni
@ 2018-08-27 7:53 ` Ruiyu Ni
2018-08-29 1:58 ` [PATCH 00/10] Quality improvement for EmulatorPkg Win Host Wu, Hao A
10 siblings, 0 replies; 16+ messages in thread
From: Ruiyu Ni @ 2018-08-27 7:53 UTC (permalink / raw)
To: edk2-devel; +Cc: Andrew Fish, Hao Wu
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1121
To produce a EFI_BLOCK_IO_PROTOCOL instance in Emulator platform,
EmulatorPkg defines the EMU_IO_THUNK_PROTOCOL. OS dependent layer
needs to produce this protocol implementation and a generic OS
independent layer consumes this protocol to produce
EFI_BLOCK_IO_PROTOCOL.
EMU_IO_THUNK_PROTOCOL can also be used to abstract the OS dependent
IO operation for other UEFI protocols, e.g.: GOP, SimpleFileSystem
and etc.
It contains two interfaces Open() and Close(). Open() creates the
specific IO instances, e.g. for Block IO access, File System access,
Screen access, etc. Close() destroys the specific IO instances.
Later on the Emulator generic module (e.g.: EmuBlockIoDxe) calls
Open() to create the IO instance in DriverBindingStart() and calls
Close() in DriverBindingStop().
But today's implementation of DriverBindingStop() contains a bug
that it calls Close() before uninstalling the EFI_BLOCK_IO_PROTOCOL.
It's a mistake in code. Take EFI_BLOCK_IO for example,
the uninstallation may cause the upper layer driver that consumes
EFI_BLOCK_IO call BlockIo.Reset(), which consequently calls
EmuBlockIo.Reset(). But the EmuBlockIo instance is already destroyed
by Close() that happens before uninstallation.
So a proper implementation is to call Close() after uninstallation
succeeds.
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1121
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Hao Wu <hao.a.wu@intel.com>
---
EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.c | 14 ++++++----
.../EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c | 10 ++++---
EmulatorPkg/EmuSnpDxe/EmuSnpDxe.c | 32 ++++++++++++++++------
3 files changed, 38 insertions(+), 18 deletions(-)
diff --git a/EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.c b/EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.c
index e77de2c7bc..3f62b9fabb 100644
--- a/EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.c
+++ b/EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.c
@@ -1,6 +1,6 @@
/**@file
-Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>
+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
@@ -662,7 +662,6 @@ EmuBlockIoDriverBindingStop (
}
Private = EMU_BLOCK_IO_PRIVATE_DATA_FROM_THIS (BlockIo);
- Status = Private->IoThunk->Close (Private->IoThunk);
Status = gBS->UninstallMultipleProtocolInterfaces (
Private->EfiHandle,
@@ -677,14 +676,17 @@ EmuBlockIoDriverBindingStop (
This->DriverBindingHandle,
Handle
);
- }
-
- if (!EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ //
+ // Destroy the IO interface.
+ //
+ Status = Private->IoThunk->Close (Private->IoThunk);
+ ASSERT_EFI_ERROR (Status);
//
// Free our instance data
//
FreeUnicodeStringTable (Private->ControllerNameTable);
- gBS->FreePool (Private);
+ FreePool (Private);
}
return Status;
diff --git a/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c b/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c
index b5e19bb840..28abfd6bef 100644
--- a/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c
+++ b/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c
@@ -866,7 +866,6 @@ EmuSimpleFileSystemDriverBindingStop (
}
Private = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (SimpleFileSystem);
- Status = Private->IoThunk->Close (Private->IoThunk);
//
// Uninstall the Simple File System Protocol from ControllerHandle
@@ -883,9 +882,12 @@ EmuSimpleFileSystemDriverBindingStop (
This->DriverBindingHandle,
ControllerHandle
);
- }
-
- if (!EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ //
+ // Destroy the IO interface.
+ //
+ Status = Private->IoThunk->Close (Private->IoThunk);
+ ASSERT_EFI_ERROR (Status);
//
// Free our instance data
//
diff --git a/EmulatorPkg/EmuSnpDxe/EmuSnpDxe.c b/EmulatorPkg/EmuSnpDxe/EmuSnpDxe.c
index 09d16fd8b6..eee9b60437 100644
--- a/EmulatorPkg/EmuSnpDxe/EmuSnpDxe.c
+++ b/EmulatorPkg/EmuSnpDxe/EmuSnpDxe.c
@@ -870,6 +870,7 @@ EmuSnpDriverBindingStop (
EFI_STATUS Status;
EMU_SNP_PRIVATE_DATA *Private = NULL;
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
+ VOID *EmuIoThunk;
//
// Complete all outstanding transactions to Controller.
@@ -914,27 +915,42 @@ EmuSnpDriverBindingStop (
}
Private = EMU_SNP_PRIVATE_DATA_FROM_SNP_THIS (Snp);
- Status = Private->IoThunk->Close (Private->IoThunk);
+ ASSERT (Private->DeviceHandle == ChildHandleBuffer[0]);
+ ASSERT (Private->EfiHandle == ControllerHandle);
Status = gBS->CloseProtocol(
- ChildHandleBuffer[0],
+ ControllerHandle,
&gEmuIoThunkProtocolGuid,
This->DriverBindingHandle,
Private->DeviceHandle
);
+ ASSERT_EFI_ERROR (Status);
Status = gBS->UninstallMultipleProtocolInterfaces(
- ChildHandleBuffer[0],
+ Private->DeviceHandle,
&gEfiSimpleNetworkProtocolGuid, &Private->Snp,
&gEfiDevicePathProtocolGuid, Private->DevicePath,
NULL
);
+ if (EFI_ERROR (Status)) {
+ gBS->OpenProtocol (
+ ControllerHandle,
+ &gEmuIoThunkProtocolGuid,
+ &EmuIoThunk,
+ This->DriverBindingHandle,
+ Private->DeviceHandle,
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
+ );
+ } else {
+ Status = Private->IoThunk->Close (Private->IoThunk);
+ ASSERT_EFI_ERROR (Status);
+
+ FreePool (Private->DevicePath);
+ FreeUnicodeStringTable (Private->ControllerNameTable);
+ FreePool (Private);
+ }
- FreePool (Private->DevicePath);
- FreeUnicodeStringTable (Private->ControllerNameTable);
- FreePool (Private);
-
- return EFI_SUCCESS;
+ return Status;
}
--
2.16.1.windows.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 00/10] Quality improvement for EmulatorPkg Win Host
2018-08-27 7:53 [PATCH 00/10] Quality improvement for EmulatorPkg Win Host Ruiyu Ni
` (9 preceding siblings ...)
2018-08-27 7:53 ` [PATCH 10/10] EmulatorPkg: IoThunk->Close() is called too early, may causing hang Ruiyu Ni
@ 2018-08-29 1:58 ` Wu, Hao A
2018-08-29 3:41 ` Ni, Ruiyu
10 siblings, 1 reply; 16+ messages in thread
From: Wu, Hao A @ 2018-08-29 1:58 UTC (permalink / raw)
To: Ni, Ruiyu, edk2-devel@lists.01.org
Hi Ray,
One general-level comment, I saw some file was originally with Unix line
ending format (LF), but after the series, the line ending is in a mixed
state (both containing Unix LF & Windows CRLF). Can you help to perform
the line ending format cleanup for those files?
Also, please help to run the PatchCheck tool to verify the format of the
commits. Thanks in advance.
Best Regards,
Hao Wu
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiyu
> Ni
> Sent: Monday, August 27, 2018 3:53 PM
> To: edk2-devel@lists.01.org
> Subject: [edk2] [PATCH 00/10] Quality improvement for EmulatorPkg Win Host
>
> The patch sets make Win Host boot in 64 bit, fix all SCT issues
> regarding to console input/output, switch to use MdeModulePkg/Bds.
>
> Ruiyu Ni (10):
> EmulatorPkg/EmuGopDxe: Fix TxtInEx.SetState SCT conformance failure
> EmulatorPkg/EmuGopDxe: Clear screen to black in GOP.SetMode
> EmulatorPkg/Win: Use FrameBufferBltLib for BLT operation
> EmulatorPkg/Win: ReadKeyStrokeEx() always returns correct KeyState
> EmulatorPkg/Win: Do not zero out file content
> EmulatorPkg/Win: Enable 64bit (SEC,PEI,DXE all run at 64bit)
> EmulatorPkg/AutoScanPei: Report the correct CPU address size
> EmulatorPkg/Win: Add VS2017 project file
> EmulatorPkg: Use MdeModulePkg/Bds module
> EmulatorPkg: IoThunk->Close() is called too early, may causing hang
>
> EmulatorPkg/AutoScanPei/AutoScanPei.c | 17 +-
> EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.c | 14 +-
> EmulatorPkg/EmuGopDxe/GopInput.c | 11 +-
> EmulatorPkg/EmuGopDxe/GopScreen.c | 8 +-
> .../EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c | 10 +-
> EmulatorPkg/EmuSnpDxe/EmuSnpDxe.c | 32 +-
> EmulatorPkg/EmulatorPkg.dsc | 38 +-
> EmulatorPkg/EmulatorPkg.fdf | 21 +-
> EmulatorPkg/Library/EmuBdsLib/BdsPlatform.c | 559 ---------------------
> EmulatorPkg/Library/PlatformBmLib/PlatformBm.c | 435
> ++++++++++++++++
> .../BdsPlatform.h => PlatformBmLib/PlatformBm.h} | 57 +--
> .../PlatformBmData.c} | 13 +-
> .../PlatformBmLib.inf} | 28 +-
> .../Library/PlatformBmLib/PlatformBmMemoryTest.c | 133 +++++
> EmulatorPkg/Win/Host/WinBlockIo.c | 30 +-
> EmulatorPkg/Win/Host/WinGop.h | 4 +-
> EmulatorPkg/Win/Host/WinGopInput.c | 17 +
> EmulatorPkg/Win/Host/WinGopScreen.c | 218 +++-----
> EmulatorPkg/Win/Host/WinHost.c | 2 +-
> EmulatorPkg/Win/Host/WinHost.inf | 1 +
> EmulatorPkg/Win/VS2017/BuildVS.bat | 3 +
> EmulatorPkg/Win/VS2017/Win.sln | 31 ++
> EmulatorPkg/Win/VS2017/Win.vcxproj | 120 +++++
> EmulatorPkg/Win/VS2017/Win.vcxproj.filters | 50 ++
> EmulatorPkg/Win/VS2017/Win.vcxproj.user | 13 +
> 25 files changed, 1046 insertions(+), 819 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} (62%)
> 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
> create mode 100644 EmulatorPkg/Win/VS2017/BuildVS.bat
> create mode 100644 EmulatorPkg/Win/VS2017/Win.sln
> create mode 100644 EmulatorPkg/Win/VS2017/Win.vcxproj
> create mode 100644 EmulatorPkg/Win/VS2017/Win.vcxproj.filters
> create mode 100644 EmulatorPkg/Win/VS2017/Win.vcxproj.user
>
> --
> 2.16.1.windows.1
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 00/10] Quality improvement for EmulatorPkg Win Host
2018-08-29 1:58 ` [PATCH 00/10] Quality improvement for EmulatorPkg Win Host Wu, Hao A
@ 2018-08-29 3:41 ` Ni, Ruiyu
0 siblings, 0 replies; 16+ messages in thread
From: Ni, Ruiyu @ 2018-08-29 3:41 UTC (permalink / raw)
To: Wu, Hao A, edk2-devel@lists.01.org
Hao,
Thanks for the comments.
I just sent out a patch with title "[edk2] [PATCH] EmulatorPkg: formalize line endings".
My patch sets will be re-generated after the line ending formalization patch is commit.
Thanks/Ray
> -----Original Message-----
> From: Wu, Hao A
> Sent: Wednesday, August 29, 2018 9:58 AM
> To: Ni, Ruiyu <ruiyu.ni@intel.com>; edk2-devel@lists.01.org
> Subject: RE: [edk2] [PATCH 00/10] Quality improvement for EmulatorPkg Win
> Host
>
> Hi Ray,
>
> One general-level comment, I saw some file was originally with Unix line
> ending format (LF), but after the series, the line ending is in a mixed state
> (both containing Unix LF & Windows CRLF). Can you help to perform the line
> ending format cleanup for those files?
>
> Also, please help to run the PatchCheck tool to verify the format of the
> commits. Thanks in advance.
>
> Best Regards,
> Hao Wu
>
>
> > -----Original Message-----
> > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> > Ruiyu Ni
> > Sent: Monday, August 27, 2018 3:53 PM
> > To: edk2-devel@lists.01.org
> > Subject: [edk2] [PATCH 00/10] Quality improvement for EmulatorPkg Win
> > Host
> >
> > The patch sets make Win Host boot in 64 bit, fix all SCT issues
> > regarding to console input/output, switch to use MdeModulePkg/Bds.
> >
> > Ruiyu Ni (10):
> > EmulatorPkg/EmuGopDxe: Fix TxtInEx.SetState SCT conformance failure
> > EmulatorPkg/EmuGopDxe: Clear screen to black in GOP.SetMode
> > EmulatorPkg/Win: Use FrameBufferBltLib for BLT operation
> > EmulatorPkg/Win: ReadKeyStrokeEx() always returns correct KeyState
> > EmulatorPkg/Win: Do not zero out file content
> > EmulatorPkg/Win: Enable 64bit (SEC,PEI,DXE all run at 64bit)
> > EmulatorPkg/AutoScanPei: Report the correct CPU address size
> > EmulatorPkg/Win: Add VS2017 project file
> > EmulatorPkg: Use MdeModulePkg/Bds module
> > EmulatorPkg: IoThunk->Close() is called too early, may causing hang
> >
> > EmulatorPkg/AutoScanPei/AutoScanPei.c | 17 +-
> > EmulatorPkg/EmuBlockIoDxe/EmuBlockIo.c | 14 +-
> > EmulatorPkg/EmuGopDxe/GopInput.c | 11 +-
> > EmulatorPkg/EmuGopDxe/GopScreen.c | 8 +-
> > .../EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c | 10 +-
> > EmulatorPkg/EmuSnpDxe/EmuSnpDxe.c | 32 +-
> > EmulatorPkg/EmulatorPkg.dsc | 38 +-
> > EmulatorPkg/EmulatorPkg.fdf | 21 +-
> > EmulatorPkg/Library/EmuBdsLib/BdsPlatform.c | 559 ---------------------
> > EmulatorPkg/Library/PlatformBmLib/PlatformBm.c | 435
> > ++++++++++++++++
> > .../BdsPlatform.h => PlatformBmLib/PlatformBm.h} | 57 +--
> > .../PlatformBmData.c} | 13 +-
> > .../PlatformBmLib.inf} | 28 +-
> > .../Library/PlatformBmLib/PlatformBmMemoryTest.c | 133 +++++
> > EmulatorPkg/Win/Host/WinBlockIo.c | 30 +-
> > EmulatorPkg/Win/Host/WinGop.h | 4 +-
> > EmulatorPkg/Win/Host/WinGopInput.c | 17 +
> > EmulatorPkg/Win/Host/WinGopScreen.c | 218 +++-----
> > EmulatorPkg/Win/Host/WinHost.c | 2 +-
> > EmulatorPkg/Win/Host/WinHost.inf | 1 +
> > EmulatorPkg/Win/VS2017/BuildVS.bat | 3 +
> > EmulatorPkg/Win/VS2017/Win.sln | 31 ++
> > EmulatorPkg/Win/VS2017/Win.vcxproj | 120 +++++
> > EmulatorPkg/Win/VS2017/Win.vcxproj.filters | 50 ++
> > EmulatorPkg/Win/VS2017/Win.vcxproj.user | 13 +
> > 25 files changed, 1046 insertions(+), 819 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} (62%) 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
> > create mode 100644 EmulatorPkg/Win/VS2017/BuildVS.bat
> > create mode 100644 EmulatorPkg/Win/VS2017/Win.sln create mode
> 100644
> > EmulatorPkg/Win/VS2017/Win.vcxproj
> > create mode 100644 EmulatorPkg/Win/VS2017/Win.vcxproj.filters
> > create mode 100644 EmulatorPkg/Win/VS2017/Win.vcxproj.user
> >
> > --
> > 2.16.1.windows.1
> >
> > _______________________________________________
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 16+ messages in thread