EmulatorPkg: Use MdeModulePkg/Bds module
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> Reviewed-by: Hao Wu <hao.a.wu@intel.com> Cc: Andrew Fish <afish@apple.com>
This commit is contained in:
435
EmulatorPkg/Library/PlatformBmLib/PlatformBm.c
Normal file
435
EmulatorPkg/Library/PlatformBmLib/PlatformBm.c
Normal file
@@ -0,0 +1,435 @@
|
||||
/*++ @file
|
||||
|
||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
Portions copyright (c) 2011, Apple Inc. All rights reserved.
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include "PlatformBm.h"
|
||||
|
||||
EFI_GUID mBootMenuFile = {
|
||||
0xEEC25BDC, 0x67F2, 0x4D95, { 0xB1, 0xD5, 0xF8, 0x1B, 0x20, 0x39, 0xD1, 0x1D }
|
||||
};
|
||||
|
||||
/**
|
||||
Initialize the "Setup" variable.
|
||||
**/
|
||||
VOID
|
||||
SetupVariableInit (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN Size;
|
||||
EMU_SYSTEM_CONFIGURATION SystemConfigData;
|
||||
|
||||
Size = sizeof (SystemConfigData);
|
||||
Status = gRT->GetVariable (
|
||||
L"Setup",
|
||||
&gEmuSystemConfigGuid,
|
||||
NULL,
|
||||
&Size,
|
||||
(VOID *) &SystemConfigData
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
// SetupVariable is corrupt
|
||||
//
|
||||
SystemConfigData.ConOutRow = PcdGet32 (PcdConOutColumn);
|
||||
SystemConfigData.ConOutColumn = PcdGet32 (PcdConOutRow);
|
||||
|
||||
Status = gRT->SetVariable (
|
||||
L"Setup",
|
||||
&gEmuSystemConfigGuid,
|
||||
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
sizeof (SystemConfigData),
|
||||
(VOID *) &SystemConfigData
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "Failed to save Setup Variable to non-volatile storage, Status = %r\n", Status));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EFI_DEVICE_PATH *
|
||||
FvFilePath (
|
||||
EFI_GUID *FileGuid
|
||||
)
|
||||
{
|
||||
|
||||
EFI_STATUS Status;
|
||||
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
|
||||
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
|
||||
|
||||
EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
|
||||
|
||||
Status = gBS->HandleProtocol (
|
||||
gImageHandle,
|
||||
&gEfiLoadedImageProtocolGuid,
|
||||
(VOID **) &LoadedImage
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
return AppendDevicePathNode (
|
||||
DevicePathFromHandle (LoadedImage->DeviceHandle),
|
||||
(EFI_DEVICE_PATH_PROTOCOL *) &FileNode
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Create one boot option for BootManagerMenuApp.
|
||||
|
||||
@param FileGuid Input file guid for the BootManagerMenuApp.
|
||||
@param Description Description of the BootManagerMenuApp boot option.
|
||||
@param Position Position of the new load option to put in the ****Order variable.
|
||||
@param IsBootCategory Whether this is a boot category.
|
||||
|
||||
|
||||
@retval OptionNumber Return the option number info.
|
||||
|
||||
**/
|
||||
UINTN
|
||||
RegisterBootManagerMenuAppBootOption (
|
||||
EFI_GUID *FileGuid,
|
||||
CHAR16 *Description,
|
||||
UINTN Position,
|
||||
BOOLEAN IsBootCategory
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
UINTN OptionNumber;
|
||||
|
||||
DevicePath = FvFilePath (FileGuid);
|
||||
Status = EfiBootManagerInitializeLoadOption (
|
||||
&NewOption,
|
||||
LoadOptionNumberUnassigned,
|
||||
LoadOptionTypeBoot,
|
||||
IsBootCategory ? LOAD_OPTION_ACTIVE : LOAD_OPTION_CATEGORY_APP,
|
||||
Description,
|
||||
DevicePath,
|
||||
NULL,
|
||||
0
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
FreePool (DevicePath);
|
||||
|
||||
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, Position);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
OptionNumber = NewOption.OptionNumber;
|
||||
|
||||
EfiBootManagerFreeLoadOption (&NewOption);
|
||||
|
||||
return OptionNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
Check if it's a Device Path pointing to BootManagerMenuApp.
|
||||
|
||||
@param DevicePath Input device path.
|
||||
|
||||
@retval TRUE The device path is BootManagerMenuApp File Device Path.
|
||||
@retval FALSE The device path is NOT BootManagerMenuApp File Device Path.
|
||||
**/
|
||||
BOOLEAN
|
||||
IsBootManagerMenuAppFilePath (
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
EFI_HANDLE FvHandle;
|
||||
VOID *NameGuid;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &DevicePath, &FvHandle);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) DevicePath);
|
||||
if (NameGuid != NULL) {
|
||||
return CompareGuid (NameGuid, &mBootMenuFile);
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
Return the boot option number to the BootManagerMenuApp.
|
||||
|
||||
If not found it in the current boot option, create a new one.
|
||||
|
||||
@retval OptionNumber Return the boot option number to the BootManagerMenuApp.
|
||||
|
||||
**/
|
||||
UINTN
|
||||
GetBootManagerMenuAppOption (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN BootOptionCount;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
|
||||
UINTN Index;
|
||||
UINTN OptionNumber;
|
||||
|
||||
OptionNumber = 0;
|
||||
|
||||
BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
|
||||
|
||||
for (Index = 0; Index < BootOptionCount; Index++) {
|
||||
if (IsBootManagerMenuAppFilePath (BootOptions[Index].FilePath)) {
|
||||
OptionNumber = BootOptions[Index].OptionNumber;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
|
||||
|
||||
if (Index >= BootOptionCount) {
|
||||
//
|
||||
// If not found the BootManagerMenuApp, create it.
|
||||
//
|
||||
OptionNumber = (UINT16) RegisterBootManagerMenuAppBootOption (&mBootMenuFile, L"UEFI BootManagerMenuApp", (UINTN) -1, FALSE);
|
||||
}
|
||||
|
||||
return OptionNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
Platform Bds init. Include the platform firmware vendor, revision
|
||||
and so crc check.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
PlatformBootManagerBeforeConsole (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
SetupVariableInit ();
|
||||
|
||||
EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);
|
||||
|
||||
Index = 0;
|
||||
while (gPlatformConsole[Index].DevicePath != NULL) {
|
||||
//
|
||||
// Update the console variable with the connect type
|
||||
//
|
||||
if ((gPlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {
|
||||
EfiBootManagerUpdateConsoleVariable (ConIn, gPlatformConsole[Index].DevicePath, NULL);
|
||||
}
|
||||
|
||||
if ((gPlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {
|
||||
EfiBootManagerUpdateConsoleVariable (ConOut, gPlatformConsole[Index].DevicePath, NULL);
|
||||
}
|
||||
|
||||
if ((gPlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
|
||||
EfiBootManagerUpdateConsoleVariable (ErrOut, gPlatformConsole[Index].DevicePath, NULL);
|
||||
}
|
||||
|
||||
Index++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Connect with predefined platform connect sequence,
|
||||
the OEM/IBV can customize with their own connect sequence.
|
||||
**/
|
||||
VOID
|
||||
PlatformBdsConnectSequence (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
//
|
||||
// Just use the simple policy to connect all devices
|
||||
//
|
||||
EfiBootManagerConnectAll ();
|
||||
}
|
||||
|
||||
/**
|
||||
Perform the platform diagnostic, such like test memory. OEM/IBV also
|
||||
can customize this fuction to support specific platform diagnostic.
|
||||
|
||||
@param MemoryTestLevel The memory test intensive level
|
||||
@param QuietBoot Indicate if need to enable the quiet boot
|
||||
**/
|
||||
VOID
|
||||
PlatformBdsDiagnostics (
|
||||
IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,
|
||||
IN BOOLEAN QuietBoot
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Here we can decide if we need to show
|
||||
// the diagnostics screen
|
||||
//
|
||||
if (QuietBoot) {
|
||||
BootLogoEnableLogo ();
|
||||
|
||||
//
|
||||
// Perform system diagnostic
|
||||
//
|
||||
Status = PlatformBootManagerMemoryTest (MemoryTestLevel);
|
||||
if (EFI_ERROR (Status)) {
|
||||
BootLogoDisableLogo ();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Perform system diagnostic
|
||||
//
|
||||
PlatformBootManagerMemoryTest (MemoryTestLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
Register the static boot options.
|
||||
**/
|
||||
VOID
|
||||
PlatformBdsRegisterStaticBootOptions (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Black;
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL White;
|
||||
EFI_INPUT_KEY Enter;
|
||||
EFI_INPUT_KEY F2;
|
||||
EFI_INPUT_KEY F7;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
|
||||
UINTN OptionNumber;
|
||||
|
||||
Black.Blue = Black.Green = Black.Red = Black.Reserved = 0;
|
||||
White.Blue = White.Green = White.Red = White.Reserved = 0xFF;
|
||||
|
||||
//
|
||||
// Register ENTER as CONTINUE key
|
||||
//
|
||||
Enter.ScanCode = SCAN_NULL;
|
||||
Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;
|
||||
EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
|
||||
//
|
||||
// Map F2 to Boot Manager Menu
|
||||
//
|
||||
F2.ScanCode = SCAN_F2;
|
||||
F2.UnicodeChar = CHAR_NULL;
|
||||
EfiBootManagerGetBootManagerMenu (&BootOption);
|
||||
EfiBootManagerAddKeyOptionVariable (NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL);
|
||||
|
||||
//
|
||||
// 3. Boot Device List menu
|
||||
//
|
||||
F7.ScanCode = SCAN_F7;
|
||||
F7.UnicodeChar = CHAR_NULL;
|
||||
OptionNumber = GetBootManagerMenuAppOption ();
|
||||
EfiBootManagerAddKeyOptionVariable (NULL, (UINT16)OptionNumber, 0, &F7, NULL);
|
||||
|
||||
PrintXY (10, 10, &White, &Black, L"F2 to enter Setup. ");
|
||||
PrintXY (10, 30, &White, &Black, L"F7 to enter Boot Manager Menu.");
|
||||
PrintXY (10, 50, &White, &Black, L"Enter to boot directly.");
|
||||
}
|
||||
|
||||
/**
|
||||
Do the platform specific action after the console is connected.
|
||||
|
||||
Such as:
|
||||
Dynamically switch output mode;
|
||||
Signal console ready platform customized event;
|
||||
Run diagnostics like memory testing;
|
||||
Connect certain devices;
|
||||
Dispatch aditional option roms.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
PlatformBootManagerAfterConsole (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
|
||||
//
|
||||
// Go the different platform policy with different boot mode
|
||||
// Notes: this part code can be change with the table policy
|
||||
//
|
||||
switch (GetBootModeHob ()) {
|
||||
|
||||
case BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
|
||||
case BOOT_WITH_MINIMAL_CONFIGURATION:
|
||||
PlatformBdsDiagnostics (IGNORE, TRUE);
|
||||
|
||||
//
|
||||
// Perform some platform specific connect sequence
|
||||
//
|
||||
PlatformBdsConnectSequence ();
|
||||
break;
|
||||
|
||||
case BOOT_IN_RECOVERY_MODE:
|
||||
PlatformBdsDiagnostics (EXTENSIVE, FALSE);
|
||||
break;
|
||||
|
||||
case BOOT_WITH_FULL_CONFIGURATION:
|
||||
case BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS:
|
||||
case BOOT_WITH_DEFAULT_SETTINGS:
|
||||
default:
|
||||
PlatformBdsDiagnostics (IGNORE, TRUE);
|
||||
PlatformBdsRegisterStaticBootOptions ();
|
||||
PlatformBdsConnectSequence ();
|
||||
EfiBootManagerRefreshAllBootOption ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
This function is called each second during the boot manager waits the timeout.
|
||||
|
||||
@param TimeoutRemain The remaining timeout.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
PlatformBootManagerWaitCallback (
|
||||
UINT16 TimeoutRemain
|
||||
)
|
||||
{
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;
|
||||
UINT16 Timeout;
|
||||
|
||||
Timeout = PcdGet16 (PcdPlatformBootTimeOut);
|
||||
|
||||
Black.Raw = 0x00000000;
|
||||
White.Raw = 0x00FFFFFF;
|
||||
|
||||
BootLogoUpdateProgress (
|
||||
White.Pixel,
|
||||
Black.Pixel,
|
||||
L"Start boot option",
|
||||
White.Pixel,
|
||||
(Timeout - TimeoutRemain) * 100 / Timeout,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
The function is called when no boot option could be launched,
|
||||
including platform recovery options and options pointing to applications
|
||||
built into firmware volumes.
|
||||
|
||||
If this function returns, BDS attempts to enter an infinite loop.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
PlatformBootManagerUnableToBoot (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
98
EmulatorPkg/Library/PlatformBmLib/PlatformBm.h
Normal file
98
EmulatorPkg/Library/PlatformBmLib/PlatformBm.h
Normal file
@@ -0,0 +1,98 @@
|
||||
/*++ @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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _PLATFORM_BM_H
|
||||
#define _PLATFORM_BM_H
|
||||
|
||||
#include <PiDxe.h>
|
||||
|
||||
#include <Guid/EmuSystemConfig.h>
|
||||
#include <Guid/EventGroup.h>
|
||||
#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>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/PcdLib.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[];
|
||||
|
||||
#define gEndEntire \
|
||||
{ \
|
||||
END_DEVICE_PATH_TYPE,\
|
||||
END_ENTIRE_DEVICE_PATH_SUBTYPE,\
|
||||
{ \
|
||||
END_DEVICE_PATH_LENGTH,\
|
||||
0\
|
||||
}\
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
EMU_VENDOR_DEVICE_PATH_NODE EmuBus;
|
||||
EMU_VENDOR_DEVICE_PATH_NODE EmuGraphicsWindow;
|
||||
EFI_DEVICE_PATH_PROTOCOL End;
|
||||
} EMU_PLATFORM_UGA_DEVICE_PATH;
|
||||
|
||||
|
||||
//
|
||||
// Platform BDS 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
|
||||
);
|
||||
|
||||
|
||||
VOID
|
||||
PlatformBdsConnectSequence (
|
||||
VOID
|
||||
);
|
||||
|
||||
#endif // _PLATFORM_BM_H
|
64
EmulatorPkg/Library/PlatformBmLib/PlatformBmData.c
Normal file
64
EmulatorPkg/Library/PlatformBmLib/PlatformBmData.c
Normal file
@@ -0,0 +1,64 @@
|
||||
/*++ @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"
|
||||
|
||||
|
||||
|
||||
EMU_PLATFORM_UGA_DEVICE_PATH gGopDevicePath = {
|
||||
{
|
||||
{
|
||||
{
|
||||
HARDWARE_DEVICE_PATH,
|
||||
HW_VENDOR_DP,
|
||||
{
|
||||
(UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
|
||||
(UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
|
||||
}
|
||||
},
|
||||
EMU_THUNK_PROTOCOL_GUID
|
||||
},
|
||||
0
|
||||
},
|
||||
{
|
||||
{
|
||||
{
|
||||
HARDWARE_DEVICE_PATH,
|
||||
HW_VENDOR_DP,
|
||||
{
|
||||
(UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
|
||||
(UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
|
||||
},
|
||||
},
|
||||
EMU_GRAPHICS_WINDOW_PROTOCOL_GUID,
|
||||
},
|
||||
0
|
||||
},
|
||||
gEndEntire
|
||||
};
|
||||
|
||||
//
|
||||
// Predefined platform default console device path
|
||||
//
|
||||
BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
|
||||
{
|
||||
(EFI_DEVICE_PATH_PROTOCOL *) &gGopDevicePath,
|
||||
(CONSOLE_OUT | CONSOLE_IN)
|
||||
},
|
||||
{
|
||||
NULL,
|
||||
0
|
||||
}
|
||||
};
|
||||
|
73
EmulatorPkg/Library/PlatformBmLib/PlatformBmLib.inf
Normal file
73
EmulatorPkg/Library/PlatformBmLib/PlatformBmLib.inf
Normal file
@@ -0,0 +1,73 @@
|
||||
## @file
|
||||
# Platfrom Boot Manager library
|
||||
#
|
||||
# Do platform action customized by IBV/OEM.
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
##
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = PlatformBmLib
|
||||
FILE_GUID = 59569181-CBF8-2E44-9C3E-C2AB2F5608E1
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = PlatformBootManagerLib|DXE_DRIVER
|
||||
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64
|
||||
#
|
||||
|
||||
[Sources]
|
||||
PlatformBm.c
|
||||
PlatformBm.h
|
||||
PlatformBmData.c
|
||||
PlatformBmMemoryTest.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
EmulatorPkg/EmulatorPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib
|
||||
MemoryAllocationLib
|
||||
UefiBootServicesTableLib
|
||||
UefiRuntimeServicesTableLib
|
||||
BaseMemoryLib
|
||||
DebugLib
|
||||
PcdLib
|
||||
UefiBootManagerLib
|
||||
DevicePathLib
|
||||
UefiLib
|
||||
BootLogoLib
|
||||
HobLib
|
||||
HiiLib
|
||||
|
||||
[Guids]
|
||||
gEmuSystemConfigGuid
|
||||
gEfiEndOfDxeEventGroupGuid
|
||||
|
||||
[Protocols]
|
||||
gEfiGenericMemTestProtocolGuid
|
||||
|
||||
[Pcd]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn
|
||||
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand
|
||||
|
||||
[Depex]
|
||||
gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid
|
133
EmulatorPkg/Library/PlatformBmLib/PlatformBmMemoryTest.c
Normal file
133
EmulatorPkg/Library/PlatformBmLib/PlatformBmMemoryTest.c
Normal file
@@ -0,0 +1,133 @@
|
||||
/** @file
|
||||
Perform the platform memory test
|
||||
|
||||
Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include "PlatformBm.h"
|
||||
|
||||
//
|
||||
// BDS Platform Functions
|
||||
//
|
||||
|
||||
/**
|
||||
Perform the memory test base on the memory test intensive level,
|
||||
and update the memory resource.
|
||||
|
||||
@param Level The memory test intensive level.
|
||||
|
||||
@retval EFI_STATUS Success test all the system memory and update
|
||||
the memory resource
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
PlatformBootManagerMemoryTest (
|
||||
IN EXTENDMEM_COVERAGE_LEVEL Level
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS KeyStatus;
|
||||
EFI_STATUS InitStatus;
|
||||
EFI_STATUS ReturnStatus;
|
||||
BOOLEAN RequireSoftECCInit;
|
||||
EFI_GENERIC_MEMORY_TEST_PROTOCOL *GenMemoryTest;
|
||||
UINT64 TestedMemorySize;
|
||||
UINT64 TotalMemorySize;
|
||||
UINT64 PreviousValue;
|
||||
BOOLEAN ErrorOut;
|
||||
BOOLEAN TestAbort;
|
||||
EFI_INPUT_KEY Key;
|
||||
CHAR16 *StrTotalMemory;
|
||||
CHAR16 *Pos;
|
||||
UINTN StrTotalMemorySize;
|
||||
|
||||
ReturnStatus = EFI_SUCCESS;
|
||||
ZeroMem (&Key, sizeof (EFI_INPUT_KEY));
|
||||
|
||||
StrTotalMemorySize = 128;
|
||||
Pos = AllocateZeroPool (StrTotalMemorySize);
|
||||
ASSERT (Pos != NULL);
|
||||
|
||||
StrTotalMemory = Pos;
|
||||
|
||||
TestedMemorySize = 0;
|
||||
TotalMemorySize = 0;
|
||||
PreviousValue = 0;
|
||||
ErrorOut = FALSE;
|
||||
TestAbort = FALSE;
|
||||
|
||||
RequireSoftECCInit = FALSE;
|
||||
|
||||
Status = gBS->LocateProtocol (
|
||||
&gEfiGenericMemTestProtocolGuid,
|
||||
NULL,
|
||||
(VOID **) &GenMemoryTest
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
FreePool (Pos);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
InitStatus = GenMemoryTest->MemoryTestInit (
|
||||
GenMemoryTest,
|
||||
Level,
|
||||
&RequireSoftECCInit
|
||||
);
|
||||
if (InitStatus == EFI_NO_MEDIA) {
|
||||
//
|
||||
// The PEI codes also have the relevant memory test code to check the memory,
|
||||
// it can select to test some range of the memory or all of them. If PEI code
|
||||
// checks all the memory, this BDS memory test will has no not-test memory to
|
||||
// do the test, and then the status of EFI_NO_MEDIA will be returned by
|
||||
// "MemoryTestInit". So it does not need to test memory again, just return.
|
||||
//
|
||||
FreePool (Pos);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "Enter memory test.\n"));
|
||||
do {
|
||||
Status = GenMemoryTest->PerformMemoryTest (
|
||||
GenMemoryTest,
|
||||
&TestedMemorySize,
|
||||
&TotalMemorySize,
|
||||
&ErrorOut,
|
||||
TestAbort
|
||||
);
|
||||
if (ErrorOut && (Status == EFI_DEVICE_ERROR)) {
|
||||
PrintXY (10, 10, NULL, NULL, L"Memory Testing failed!");
|
||||
ASSERT (0);
|
||||
}
|
||||
|
||||
|
||||
DEBUG ((DEBUG_INFO, "Perform memory test (ESC to skip).\n"));
|
||||
|
||||
if (!PcdGetBool (PcdConInConnectOnDemand)) {
|
||||
KeyStatus = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
|
||||
if (!EFI_ERROR (KeyStatus) && (Key.ScanCode == SCAN_ESC)) {
|
||||
if (!RequireSoftECCInit) {
|
||||
Status = GenMemoryTest->Finished (GenMemoryTest);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
TestAbort = TRUE;
|
||||
}
|
||||
}
|
||||
} while (Status != EFI_NOT_FOUND);
|
||||
|
||||
Status = GenMemoryTest->Finished (GenMemoryTest);
|
||||
|
||||
Done:
|
||||
DEBUG ((DEBUG_INFO, "%d bytes of system memory tested OK\r\n", TotalMemorySize));
|
||||
|
||||
FreePool (Pos);
|
||||
return ReturnStatus;
|
||||
}
|
Reference in New Issue
Block a user