public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/6] Fine tune SimicsOpenBoardPkg
@ 2023-05-24 12:28 Ni, Ray
  2023-05-24 12:28 ` [PATCH 1/6] SimicsOpenBoardPkg: Remove un-used PlatformBootManagerLib Ni, Ray
                   ` (11 more replies)
  0 siblings, 12 replies; 15+ messages in thread
From: Ni, Ray @ 2023-05-24 12:28 UTC (permalink / raw)
  To: devel


Ray Ni (6):
  SimicsOpenBoardPkg: Remove un-used PlatformBootManagerLib
  SimicsOpenBoardPkg: Remove logic that loads variable from disk file
  SimicsOpenBoardPkg: Enable serial terminal
  MinPlatform/build_bios.py: Support performance enabled build
  SimicsOpenBoardPkg: Add "dp" command in performance build
  SimicsOpenBoardPkg: Disable DriverBindingSupport perf logging

 .../BoardX58Ich10/OpenBoardPkg.dsc            |   10 +-
 .../BoardX58Ich10/OpenBoardPkg.fdf            |    4 +-
 .../BoardX58Ich10/OpenBoardPkgPcd.dsc         |   12 +-
 .../Include/Library/SerializeVariablesLib.h   |  224 ---
 .../Library/BoardBdsHookLib/BoardBdsHookLib.c |  180 +-
 .../BoardBdsHookLib/BoardBdsHookLib.inf       |    3 -
 .../Library/NvVarsFileLib/FsAccess.c          |  507 ------
 .../Library/NvVarsFileLib/NvVarsFileLib.c     |   77 -
 .../Library/NvVarsFileLib/NvVarsFileLib.h     |   55 -
 .../Library/NvVarsFileLib/NvVarsFileLib.inf   |   53 -
 .../PlatformBootManagerLib/BdsPlatform.c      | 1532 -----------------
 .../PlatformBootManagerLib/BdsPlatform.h      |  172 --
 .../PlatformBootManagerLib.inf                |   72 -
 .../PlatformBootManagerLib/PlatformData.c     |   35 -
 .../SerializeVariablesLib.c                   |  869 ----------
 .../SerializeVariablesLib.h                   |   33 -
 .../SerializeVariablesLib.inf                 |   36 -
 .../Intel/SimicsOpenBoardPkg/OpenBoardPkg.dec |    3 -
 Platform/Intel/build_bios.py                  |    6 +-
 19 files changed, 50 insertions(+), 3833 deletions(-)
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Include/Library/SerializeVariablesLib.h
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/FsAccess.c
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.c
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.h
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/BdsPlatform.c
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/BdsPlatform.h
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/PlatformData.c
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeVariablesLib.h
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf

-- 
2.39.1.windows.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/6] SimicsOpenBoardPkg: Remove un-used PlatformBootManagerLib
  2023-05-24 12:28 [PATCH 0/6] Fine tune SimicsOpenBoardPkg Ni, Ray
@ 2023-05-24 12:28 ` Ni, Ray
  2023-05-24 12:28 ` [PATCH 2/6] SimicsOpenBoardPkg: Remove logic that loads variable from disk file Ni, Ray
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Ni, Ray @ 2023-05-24 12:28 UTC (permalink / raw)
  To: devel; +Cc: Nate DeSimone, Zhiguang Liu

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Zhiguang Liu <zhiguang@liu@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
---
 .../PlatformBootManagerLib/BdsPlatform.c      | 1532 -----------------
 .../PlatformBootManagerLib/BdsPlatform.h      |  172 --
 .../PlatformBootManagerLib.inf                |   72 -
 .../PlatformBootManagerLib/PlatformData.c     |   35 -
 4 files changed, 1811 deletions(-)
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/BdsPlatform.c
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/BdsPlatform.h
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/PlatformData.c

diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/BdsPlatform.c
deleted file mode 100644
index 2f9c6aaa85..0000000000
--- a/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/BdsPlatform.c
+++ /dev/null
@@ -1,1532 +0,0 @@
-/** @file
-  Platform BDS customizations.
-
-  Copyright (c) 2004 - 2019 Intel Corporation. All rights reserved. <BR>
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-**/
-
-#include "BdsPlatform.h"
-#include <Guid/RootBridgesConnectedEventGroup.h>
-#include <Protocol/FirmwareVolume2.h>
-
-#define LEGACY_8259_MASK_REGISTER_MASTER                  0x21
-#define LEGACY_8259_MASK_REGISTER_SLAVE                   0xA1
-#define LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_MASTER  0x4D0
-#define LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_SLAVE   0x4D1
-
-//
-// Global data
-//
-
-VOID          *mEfiDevPathNotifyReg;
-EFI_EVENT     mEfiDevPathEvent;
-VOID          *mEmuVariableEventReg;
-EFI_EVENT     mEmuVariableEvent;
-BOOLEAN       mDetectVgaOnly;
-UINT16        mHostBridgeDevId;
-
-//
-// Table of host IRQs matching PCI IRQs A-D
-// (for configuring PCI Interrupt Line register)
-//
-CONST UINT8 PciHostIrqs[] = {
-  0x0a, 0x0a, 0x0b, 0x0b
-};
-
-//
-// Type definitions
-//
-
-typedef
-EFI_STATUS
-(EFIAPI *PROTOCOL_INSTANCE_CALLBACK)(
-  IN EFI_HANDLE           Handle,
-  IN VOID                 *Instance,
-  IN VOID                 *Context
-  );
-
-/**
-  @param[in]  Handle - Handle of PCI device instance
-  @param[in]  PciIo - PCI IO protocol instance
-  @param[in]  Pci - PCI Header register block
-**/
-typedef
-EFI_STATUS
-(EFIAPI *VISIT_PCI_INSTANCE_CALLBACK)(
-  IN EFI_HANDLE           Handle,
-  IN EFI_PCI_IO_PROTOCOL  *PciIo,
-  IN PCI_TYPE00           *Pci
-  );
-
-
-//
-// Function prototypes
-//
-
-EFI_STATUS
-VisitAllInstancesOfProtocol (
-  IN EFI_GUID                    *Id,
-  IN PROTOCOL_INSTANCE_CALLBACK  CallBackFunction,
-  IN VOID                        *Context
-  );
-
-EFI_STATUS
-VisitAllPciInstancesOfProtocol (
-  IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
-  );
-
-VOID
-InstallDevicePathCallback (
-  VOID
-  );
-
-VOID
-PlatformRegisterFvBootOption (
-  EFI_GUID                         *FileGuid,
-  CHAR16                           *Description,
-  UINT32                           Attributes
-  )
-{
-  EFI_STATUS                        Status;
-  INTN                              OptionIndex;
-  EFI_BOOT_MANAGER_LOAD_OPTION      NewOption;
-  EFI_BOOT_MANAGER_LOAD_OPTION      *BootOptions;
-  UINTN                             BootOptionCount;
-  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
-  EFI_LOADED_IMAGE_PROTOCOL         *LoadedImage;
-  EFI_DEVICE_PATH_PROTOCOL          *DevicePath;
-
-  Status = gBS->HandleProtocol (
-                  gImageHandle,
-                  &gEfiLoadedImageProtocolGuid,
-                  (VOID **) &LoadedImage
-                  );
-  ASSERT_EFI_ERROR (Status);
-
-  EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
-  DevicePath = DevicePathFromHandle (LoadedImage->DeviceHandle);
-  ASSERT (DevicePath != NULL);
-  DevicePath = AppendDevicePathNode (
-                 DevicePath,
-                 (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
-                 );
-  ASSERT (DevicePath != NULL);
-
-  Status = EfiBootManagerInitializeLoadOption (
-             &NewOption,
-             LoadOptionNumberUnassigned,
-             LoadOptionTypeBoot,
-             Attributes,
-             Description,
-             DevicePath,
-             NULL,
-             0
-             );
-  ASSERT_EFI_ERROR (Status);
-  FreePool (DevicePath);
-
-  BootOptions = EfiBootManagerGetLoadOptions (
-                  &BootOptionCount, LoadOptionTypeBoot
-                  );
-
-  OptionIndex = EfiBootManagerFindLoadOption (
-                  &NewOption, BootOptions, BootOptionCount
-                  );
-
-  if (OptionIndex == -1) {
-    Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
-    ASSERT_EFI_ERROR (Status);
-  }
-  EfiBootManagerFreeLoadOption (&NewOption);
-  EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
-}
-
-/**
-  Remove all MemoryMapped(...)/FvFile(...) and Fv(...)/FvFile(...) boot options
-  whose device paths do not resolve exactly to an FvFile in the system.
-
-  This removes any boot options that point to binaries built into the firmware
-  and have become stale due to any of the following:
-  - DXEFV's base address or size changed (historical),
-  - DXEFV's FvNameGuid changed,
-  - the FILE_GUID of the pointed-to binary changed,
-  - the referenced binary is no longer built into the firmware.
-
-  EfiBootManagerFindLoadOption() used in PlatformRegisterFvBootOption() only
-  avoids exact duplicates.
-**/
-VOID
-RemoveStaleFvFileOptions (
-  VOID
-  )
-{
-  EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
-  UINTN                        BootOptionCount;
-  UINTN                        Index;
-
-  BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount,
-                  LoadOptionTypeBoot);
-
-  for (Index = 0; Index < BootOptionCount; ++Index) {
-    EFI_DEVICE_PATH_PROTOCOL *Node1, *Node2, *SearchNode;
-    EFI_STATUS               Status;
-    EFI_HANDLE               FvHandle;
-
-    //
-    // If the device path starts with neither MemoryMapped(...) nor Fv(...),
-    // then keep the boot option.
-    //
-    Node1 = BootOptions[Index].FilePath;
-    if (!(DevicePathType (Node1) == HARDWARE_DEVICE_PATH &&
-          DevicePathSubType (Node1) == HW_MEMMAP_DP) &&
-        !(DevicePathType (Node1) == MEDIA_DEVICE_PATH &&
-          DevicePathSubType (Node1) == MEDIA_PIWG_FW_VOL_DP)) {
-      continue;
-    }
-
-    //
-    // If the second device path node is not FvFile(...), then keep the boot
-    // option.
-    //
-    Node2 = NextDevicePathNode (Node1);
-    if (DevicePathType (Node2) != MEDIA_DEVICE_PATH ||
-        DevicePathSubType (Node2) != MEDIA_PIWG_FW_FILE_DP) {
-      continue;
-    }
-
-    //
-    // Locate the Firmware Volume2 protocol instance that is denoted by the
-    // boot option. If this lookup fails (i.e., the boot option references a
-    // firmware volume that doesn't exist), then we'll proceed to delete the
-    // boot option.
-    //
-    SearchNode = Node1;
-    Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid,
-                    &SearchNode, &FvHandle);
-
-    if (!EFI_ERROR (Status)) {
-      //
-      // The firmware volume was found; now let's see if it contains the FvFile
-      // identified by GUID.
-      //
-      EFI_FIRMWARE_VOLUME2_PROTOCOL     *FvProtocol;
-      MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileNode;
-      UINTN                             BufferSize;
-      EFI_FV_FILETYPE                   FoundType;
-      EFI_FV_FILE_ATTRIBUTES            FileAttributes;
-      UINT32                            AuthenticationStatus;
-
-      Status = gBS->HandleProtocol (FvHandle, &gEfiFirmwareVolume2ProtocolGuid,
-                      (VOID **)&FvProtocol);
-      ASSERT_EFI_ERROR (Status);
-
-      FvFileNode = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)Node2;
-      //
-      // Buffer==NULL means we request metadata only: BufferSize, FoundType,
-      // FileAttributes.
-      //
-      Status = FvProtocol->ReadFile (
-                             FvProtocol,
-                             &FvFileNode->FvFileName, // NameGuid
-                             NULL,                    // Buffer
-                             &BufferSize,
-                             &FoundType,
-                             &FileAttributes,
-                             &AuthenticationStatus
-                             );
-      if (!EFI_ERROR (Status)) {
-        //
-        // The FvFile was found. Keep the boot option.
-        //
-        continue;
-      }
-    }
-
-    //
-    // Delete the boot option.
-    //
-    Status = EfiBootManagerDeleteLoadOptionVariable (
-               BootOptions[Index].OptionNumber, LoadOptionTypeBoot);
-    DEBUG_CODE (
-      CHAR16 *DevicePathString;
-
-      DevicePathString = ConvertDevicePathToText(BootOptions[Index].FilePath,
-                           FALSE, FALSE);
-      DEBUG ((
-        EFI_ERROR (Status) ? EFI_D_WARN : EFI_D_VERBOSE,
-        "%a: removing stale Boot#%04x %s: %r\n",
-        __FUNCTION__,
-        (UINT32)BootOptions[Index].OptionNumber,
-        DevicePathString == NULL ? L"<unavailable>" : DevicePathString,
-        Status
-        ));
-      if (DevicePathString != NULL) {
-        FreePool (DevicePathString);
-      }
-      );
-  }
-
-  EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
-}
-
-VOID
-PlatformRegisterOptionsAndKeys (
-  VOID
-  )
-{
-  EFI_STATUS                   Status;
-  EFI_INPUT_KEY                Enter;
-  EFI_INPUT_KEY                F2;
-  EFI_INPUT_KEY                Esc;
-  EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
-
-  //
-  // Register ENTER as CONTINUE key
-  //
-  Enter.ScanCode    = SCAN_NULL;
-  Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;
-  Status = EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
-  ASSERT_EFI_ERROR (Status);
-
-  //
-  // Map F2 to Boot Manager Menu
-  //
-  F2.ScanCode     = SCAN_F2;
-  F2.UnicodeChar  = CHAR_NULL;
-  Esc.ScanCode    = SCAN_ESC;
-  Esc.UnicodeChar = CHAR_NULL;
-  Status = EfiBootManagerGetBootManagerMenu (&BootOption);
-  ASSERT_EFI_ERROR (Status);
-  Status = EfiBootManagerAddKeyOptionVariable (
-             NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL
-             );
-  ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
-  Status = EfiBootManagerAddKeyOptionVariable (
-             NULL, (UINT16) BootOption.OptionNumber, 0, &Esc, NULL
-             );
-  ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
-}
-
-EFI_STATUS
-EFIAPI
-ConnectRootBridge (
-  IN EFI_HANDLE  RootBridgeHandle,
-  IN VOID        *Instance,
-  IN VOID        *Context
-  );
-
-//
-// BDS Platform Functions
-//
-/**
-  Do the platform init, can be customized by OEM/IBV
-
-  Possible things that can be done in PlatformBootManagerBeforeConsole:
-
-  > Update console variable: 1. include hot-plug devices;
-  >                          2. Clear ConIn and add SOL for AMT
-  > Register new Driver#### or Boot####
-  > Register new Key####: e.g.: F12
-  > Signal ReadyToLock event
-  > Authentication action: 1. connect Auth devices;
-  >                        2. Identify auto logon user.
-**/
-VOID
-EFIAPI
-PlatformBootManagerBeforeConsole (
-  VOID
-  )
-{
-  EFI_BOOT_MANAGER_LOAD_OPTION  *NvBootOptions;
-  UINTN                         NvBootOptionCount;
-  UINTN                         Index;
-  EFI_STATUS                    Status;
-
-  DEBUG ((DEBUG_INFO, "PlatformBootManagerBeforeConsole\n"));
-
-  NvBootOptions = EfiBootManagerGetLoadOptions (&NvBootOptionCount, LoadOptionTypeBoot);
-  for (Index = 0; Index < NvBootOptionCount; Index++) {
-    Status = EfiBootManagerDeleteLoadOptionVariable (NvBootOptions[Index].OptionNumber, LoadOptionTypeBoot);
-    if (EFI_ERROR (Status)) {
-      DEBUG ((
-        DEBUG_ERROR,
-        "%a: removing Boot#%04x %r\n",
-        __FUNCTION__,
-        (UINT32) NvBootOptions[Index].OptionNumber,
-        Status
-        ));
-    }
-  }
-
-  InstallDevicePathCallback ();
-
-  VisitAllInstancesOfProtocol (&gEfiPciRootBridgeIoProtocolGuid,
-    ConnectRootBridge, NULL);
-  //
-  // Enable LPC
-  //
-  PciOr16(POWER_MGMT_REGISTER_ICH10(0x04),
-           BIT0 | BIT1 | BIT2);
-  //
-  // We can't signal End-of-Dxe earlier than this. Namely, End-of-Dxe triggers
-  // the preparation of S3 system information. That logic has a hard dependency
-  // on the presence of the FACS ACPI table. Since our ACPI tables are only
-  // installed after PCI enumeration completes, we must not trigger the S3 save
-  // earlier, hence we can't signal End-of-Dxe earlier.
-  //
-  EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);
-
-  PlatformInitializeConsole (gPlatformConsole);
-
-  PlatformRegisterOptionsAndKeys ();
-}
-
-
-EFI_STATUS
-EFIAPI
-ConnectRootBridge (
-  IN EFI_HANDLE  RootBridgeHandle,
-  IN VOID        *Instance,
-  IN VOID        *Context
-  )
-{
-  EFI_STATUS Status;
-
-  //
-  // Make the PCI bus driver connect the root bridge, non-recursively. This
-  // will produce a number of child handles with PciIo on them.
-  //
-  Status = gBS->ConnectController (
-                  RootBridgeHandle, // ControllerHandle
-                  NULL,             // DriverImageHandle
-                  NULL,             // RemainingDevicePath -- produce all
-                                    //   children
-                  FALSE             // Recursive
-                  );
-  return Status;
-}
-
-
-/**
-  Add IsaKeyboard to ConIn; add IsaSerial to ConOut, ConIn, ErrOut.
-
-  @param[in] DeviceHandle  Handle of the LPC Bridge device.
-
-  @retval EFI_SUCCESS  Console devices on the LPC bridge have been added to
-                       ConOut, ConIn, and ErrOut.
-
-  @return              Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing
-                       from DeviceHandle.
-**/
-EFI_STATUS
-PrepareLpcBridgeDevicePath (
-  IN EFI_HANDLE                DeviceHandle
-  )
-{
-  EFI_STATUS                Status;
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
-  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;
-  CHAR16                    *DevPathStr;
-
-  DevicePath = NULL;
-  Status = gBS->HandleProtocol (
-                  DeviceHandle,
-                  &gEfiDevicePathProtocolGuid,
-                  (VOID*)&DevicePath
-                  );
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-  TempDevicePath = DevicePath;
-
-  //
-  // Register Keyboard
-  //
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnpPs2KeyboardDeviceNode);
-
-  EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
-
-  //
-  // Register COM1
-  //
-  DevicePath = TempDevicePath;
-  gPnp16550ComPortDeviceNode.UID = 0;
-
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
-
-  //
-  // Print Device Path
-  //
-  DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
-  if (DevPathStr != NULL) {
-    DEBUG((
-      EFI_D_INFO,
-      "BdsPlatform.c+%d: COM%d DevPath: %s\n",
-      __LINE__,
-      gPnp16550ComPortDeviceNode.UID + 1,
-      DevPathStr
-      ));
-    FreePool(DevPathStr);
-  }
-
-  EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
-  EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
-  EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
-
-  //
-  // Register COM2
-  //
-  DevicePath = TempDevicePath;
-  gPnp16550ComPortDeviceNode.UID = 1;
-
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
-
-  //
-  // Print Device Path
-  //
-  DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
-  if (DevPathStr != NULL) {
-    DEBUG((
-      EFI_D_INFO,
-      "BdsPlatform.c+%d: COM%d DevPath: %s\n",
-      __LINE__,
-      gPnp16550ComPortDeviceNode.UID + 1,
-      DevPathStr
-      ));
-    FreePool(DevPathStr);
-  }
-
-  EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
-  EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
-  EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
-
-  return EFI_SUCCESS;
-}
-
-EFI_STATUS
-GetGopDevicePath (
-   IN  EFI_DEVICE_PATH_PROTOCOL *PciDevicePath,
-   OUT EFI_DEVICE_PATH_PROTOCOL **GopDevicePath
-   )
-{
-  UINTN                           Index;
-  EFI_STATUS                      Status;
-  EFI_HANDLE                      PciDeviceHandle;
-  EFI_DEVICE_PATH_PROTOCOL        *TempDevicePath;
-  EFI_DEVICE_PATH_PROTOCOL        *TempPciDevicePath;
-  UINTN                           GopHandleCount;
-  EFI_HANDLE                      *GopHandleBuffer;
-
-  if (PciDevicePath == NULL || GopDevicePath == NULL) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  //
-  // Initialize the GopDevicePath to be PciDevicePath
-  //
-  *GopDevicePath    = PciDevicePath;
-  TempPciDevicePath = PciDevicePath;
-
-  Status = gBS->LocateDevicePath (
-                  &gEfiDevicePathProtocolGuid,
-                  &TempPciDevicePath,
-                  &PciDeviceHandle
-                  );
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  //
-  // Try to connect this handle, so that GOP driver could start on this
-  // device and create child handles with GraphicsOutput Protocol installed
-  // on them, then we get device paths of these child handles and select
-  // them as possible console device.
-  //
-  gBS->ConnectController (PciDeviceHandle, NULL, NULL, FALSE);
-
-  Status = gBS->LocateHandleBuffer (
-                  ByProtocol,
-                  &gEfiGraphicsOutputProtocolGuid,
-                  NULL,
-                  &GopHandleCount,
-                  &GopHandleBuffer
-                  );
-  if (!EFI_ERROR (Status)) {
-    //
-    // Add all the child handles as possible Console Device
-    //
-    for (Index = 0; Index < GopHandleCount; Index++) {
-      Status = gBS->HandleProtocol (GopHandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID*)&TempDevicePath);
-      if (EFI_ERROR (Status)) {
-        continue;
-      }
-      if (CompareMem (
-            PciDevicePath,
-            TempDevicePath,
-            GetDevicePathSize (PciDevicePath) - END_DEVICE_PATH_LENGTH
-            ) == 0) {
-        //
-        // In current implementation, we only enable one of the child handles
-        // as console device, i.e. sotre one of the child handle's device
-        // path to variable "ConOut"
-        // In future, we could select all child handles to be console device
-        //
-
-        *GopDevicePath = TempDevicePath;
-
-        //
-        // Delete the PCI device's path that added by
-        // GetPlugInPciVgaDevicePath(). Add the integrity GOP device path.
-        //
-        EfiBootManagerUpdateConsoleVariable (ConOutDev, NULL, PciDevicePath);
-        EfiBootManagerUpdateConsoleVariable (ConOutDev, TempDevicePath, NULL);
-      }
-    }
-    gBS->FreePool (GopHandleBuffer);
-  }
-
-  return EFI_SUCCESS;
-}
-
-/**
-  Add PCI display to ConOut.
-
-  @param[in] DeviceHandle  Handle of the PCI display device.
-
-  @retval EFI_SUCCESS  The PCI display device has been added to ConOut.
-
-  @return              Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing
-                       from DeviceHandle.
-**/
-EFI_STATUS
-PreparePciDisplayDevicePath (
-  IN EFI_HANDLE                DeviceHandle
-  )
-{
-  EFI_STATUS                Status;
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
-  EFI_DEVICE_PATH_PROTOCOL  *GopDevicePath;
-
-  DevicePath    = NULL;
-  GopDevicePath = NULL;
-  Status = gBS->HandleProtocol (
-                  DeviceHandle,
-                  &gEfiDevicePathProtocolGuid,
-                  (VOID*)&DevicePath
-                  );
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  GetGopDevicePath (DevicePath, &GopDevicePath);
-  DevicePath = GopDevicePath;
-
-  EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
-
-  return EFI_SUCCESS;
-}
-
-/**
-  Add PCI Serial to ConOut, ConIn, ErrOut.
-
-  @param[in] DeviceHandle  Handle of the PCI serial device.
-
-  @retval EFI_SUCCESS  The PCI serial device has been added to ConOut, ConIn,
-                       ErrOut.
-
-  @return              Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing
-                       from DeviceHandle.
-**/
-EFI_STATUS
-PreparePciSerialDevicePath (
-  IN EFI_HANDLE                DeviceHandle
-  )
-{
-  EFI_STATUS                Status;
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
-
-  DevicePath = NULL;
-  Status = gBS->HandleProtocol (
-                  DeviceHandle,
-                  &gEfiDevicePathProtocolGuid,
-                  (VOID*)&DevicePath
-                  );
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
-  DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
-
-  EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
-  EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
-  EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
-
-  return EFI_SUCCESS;
-}
-
-EFI_STATUS
-VisitAllInstancesOfProtocol (
-  IN EFI_GUID                    *Id,
-  IN PROTOCOL_INSTANCE_CALLBACK  CallBackFunction,
-  IN VOID                        *Context
-  )
-{
-  EFI_STATUS                Status;
-  UINTN                     HandleCount;
-  EFI_HANDLE                *HandleBuffer;
-  UINTN                     Index;
-  VOID                      *Instance;
-
-  //
-  // Start to check all the PciIo to find all possible device
-  //
-  HandleCount = 0;
-  HandleBuffer = NULL;
-  Status = gBS->LocateHandleBuffer (
-                  ByProtocol,
-                  Id,
-                  NULL,
-                  &HandleCount,
-                  &HandleBuffer
-                  );
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  for (Index = 0; Index < HandleCount; Index++) {
-    Status = gBS->HandleProtocol (HandleBuffer[Index], Id, &Instance);
-    if (EFI_ERROR (Status)) {
-      continue;
-    }
-
-    Status = (*CallBackFunction) (
-               HandleBuffer[Index],
-               Instance,
-               Context
-               );
-  }
-
-  gBS->FreePool (HandleBuffer);
-
-  return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-EFIAPI
-VisitingAPciInstance (
-  IN EFI_HANDLE  Handle,
-  IN VOID        *Instance,
-  IN VOID        *Context
-  )
-{
-  EFI_STATUS                Status;
-  EFI_PCI_IO_PROTOCOL       *PciIo;
-  PCI_TYPE00                Pci;
-
-  PciIo = (EFI_PCI_IO_PROTOCOL*) Instance;
-
-  //
-  // Check for all PCI device
-  //
-  Status = PciIo->Pci.Read (
-                    PciIo,
-                    EfiPciIoWidthUint32,
-                    0,
-                    sizeof (Pci) / sizeof (UINT32),
-                    &Pci
-                    );
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  return (*(VISIT_PCI_INSTANCE_CALLBACK)(UINTN) Context) (
-           Handle,
-           PciIo,
-           &Pci
-           );
-
-}
-
-
-
-EFI_STATUS
-VisitAllPciInstances (
-  IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
-  )
-{
-  return VisitAllInstancesOfProtocol (
-           &gEfiPciIoProtocolGuid,
-           VisitingAPciInstance,
-           (VOID*)(UINTN) CallBackFunction
-           );
-}
-
-
-/**
-  Do platform specific PCI Device check and add them to
-  ConOut, ConIn, ErrOut.
-
-  @param[in]  Handle - Handle of PCI device instance
-  @param[in]  PciIo - PCI IO protocol instance
-  @param[in]  Pci - PCI Header register block
-
-  @retval EFI_SUCCESS - PCI Device check and Console variable update
-                        successfully.
-  @retval EFI_STATUS - PCI Device check or Console variable update fail.
-
-**/
-EFI_STATUS
-EFIAPI
-DetectAndPreparePlatformPciDevicePath (
-  IN EFI_HANDLE           Handle,
-  IN EFI_PCI_IO_PROTOCOL  *PciIo,
-  IN PCI_TYPE00           *Pci
-  )
-{
-  EFI_STATUS                Status;
-
-  Status = PciIo->Attributes (
-    PciIo,
-    EfiPciIoAttributeOperationEnable,
-    EFI_PCI_DEVICE_ENABLE,
-    NULL
-    );
-  ASSERT_EFI_ERROR (Status);
-
-  if (!mDetectVgaOnly) {
-    //
-    // Here we decide whether it is LPC Bridge
-    //
-    if ((IS_PCI_LPC (Pci)) ||
-        ((IS_PCI_ISA_PDECODE (Pci)) &&
-         (Pci->Hdr.VendorId == 0x8086) &&
-         (Pci->Hdr.DeviceId == 0x7000)
-        )
-       ) {
-      //
-      // Add IsaKeyboard to ConIn,
-      // add IsaSerial to ConOut, ConIn, ErrOut
-      //
-      DEBUG ((EFI_D_INFO, "Found LPC Bridge device\n"));
-      PrepareLpcBridgeDevicePath (Handle);
-      return EFI_SUCCESS;
-    }
-    //
-    // Here we decide which Serial device to enable in PCI bus
-    //
-    if (IS_PCI_16550SERIAL (Pci)) {
-      //
-      // Add them to ConOut, ConIn, ErrOut.
-      //
-      DEBUG ((EFI_D_INFO, "Found PCI 16550 SERIAL device\n"));
-      PreparePciSerialDevicePath (Handle);
-      return EFI_SUCCESS;
-    }
-  }
-
-  //
-  // Here we decide which display device to enable in PCI bus
-  //
-  if (IS_PCI_DISPLAY (Pci)) {
-    //
-    // Add them to ConOut.
-    //
-    DEBUG ((EFI_D_INFO, "Found PCI display device\n"));
-    PreparePciDisplayDevicePath (Handle);
-    return EFI_SUCCESS;
-  }
-
-  return Status;
-}
-
-
-/**
-  Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut
-
-  @param[in]  DetectVgaOnly - Only detect VGA device if it's TRUE.
-
-  @retval EFI_SUCCESS - PCI Device check and Console variable update successfully.
-  @retval EFI_STATUS - PCI Device check or Console variable update fail.
-
-**/
-EFI_STATUS
-DetectAndPreparePlatformPciDevicePaths (
-  BOOLEAN DetectVgaOnly
-  )
-{
-  mDetectVgaOnly = DetectVgaOnly;
-  return VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath);
-}
-
-/**
-  Connect the predefined platform default console device.
-
-  Always try to find and enable PCI display devices.
-
-  @param[in] PlatformConsole  Predefined platform default console device array.
-**/
-VOID
-PlatformInitializeConsole (
-  IN PLATFORM_CONSOLE_CONNECT_ENTRY   *PlatformConsole
-  )
-{
-  UINTN                              Index;
-  EFI_DEVICE_PATH_PROTOCOL           *VarConout;
-  EFI_DEVICE_PATH_PROTOCOL           *VarConin;
-
-  //
-  // Connect RootBridge
-  //
-  GetEfiGlobalVariable2 (EFI_CON_OUT_VARIABLE_NAME, (VOID **) &VarConout, NULL);
-  GetEfiGlobalVariable2 (EFI_CON_IN_VARIABLE_NAME, (VOID **) &VarConin, NULL);
-
-  if (VarConout == NULL || VarConin == NULL) {
-    //
-    // Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut
-    //
-    DetectAndPreparePlatformPciDevicePaths (FALSE);
-    DetectAndPreparePlatformPciDevicePaths(TRUE);
-    //
-    // Have chance to connect the platform default console,
-    // the platform default console is the minimue device group
-    // the platform should support
-    //
-    for (Index = 0; PlatformConsole[Index].DevicePath != NULL; ++Index) {
-      //
-      // Update the console variable with the connect type
-      //
-      if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {
-        EfiBootManagerUpdateConsoleVariable (ConIn, PlatformConsole[Index].DevicePath, NULL);
-      }
-      if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {
-        EfiBootManagerUpdateConsoleVariable (ConOut, PlatformConsole[Index].DevicePath, NULL);
-      }
-      if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
-        EfiBootManagerUpdateConsoleVariable (ErrOut, PlatformConsole[Index].DevicePath, NULL);
-      }
-    }
-  } else {
-    //
-    // Only detect VGA device and add them to ConOut
-    //
-    DetectAndPreparePlatformPciDevicePaths (TRUE);
-  }
-}
-
-
-/**
-  Configure PCI Interrupt Line register for applicable devices
-  Ported from SeaBIOS, src/fw/pciinit.c, *_pci_slot_get_irq()
-
-  @param[in]  Handle - Handle of PCI device instance
-  @param[in]  PciIo - PCI IO protocol instance
-  @param[in]  PciHdr - PCI Header register block
-
-  @retval EFI_SUCCESS - PCI Interrupt Line register configured successfully.
-
-**/
-EFI_STATUS
-EFIAPI
-SetPciIntLine (
-  IN EFI_HANDLE           Handle,
-  IN EFI_PCI_IO_PROTOCOL  *PciIo,
-  IN PCI_TYPE00           *PciHdr
-  )
-{
-  EFI_DEVICE_PATH_PROTOCOL  *DevPathNode;
-  EFI_DEVICE_PATH_PROTOCOL  *DevPath;
-  UINTN                     RootSlot;
-  UINTN                     Idx;
-  UINT8                     IrqLine;
-  EFI_STATUS                Status;
-  UINT32                    RootBusNumber;
-
-  Status = EFI_SUCCESS;
-
-  if (PciHdr->Device.InterruptPin != 0) {
-
-    DevPathNode = DevicePathFromHandle (Handle);
-    ASSERT (DevPathNode != NULL);
-    DevPath = DevPathNode;
-
-    RootBusNumber = 0;
-    if (DevicePathType (DevPathNode) == ACPI_DEVICE_PATH &&
-        DevicePathSubType (DevPathNode) == ACPI_DP &&
-        ((ACPI_HID_DEVICE_PATH *)DevPathNode)->HID == EISA_PNP_ID(0x0A03)) {
-      RootBusNumber = ((ACPI_HID_DEVICE_PATH *)DevPathNode)->UID;
-    }
-
-    //
-    // Compute index into PciHostIrqs[] table by walking
-    // the device path and adding up all device numbers
-    //
-    Status = EFI_NOT_FOUND;
-    RootSlot = 0;
-    Idx = PciHdr->Device.InterruptPin - 1;
-    while (!IsDevicePathEnd (DevPathNode)) {
-      if (DevicePathType (DevPathNode) == HARDWARE_DEVICE_PATH &&
-          DevicePathSubType (DevPathNode) == HW_PCI_DP) {
-
-        Idx += ((PCI_DEVICE_PATH *)DevPathNode)->Device;
-
-        //
-        // Unlike SeaBIOS, which starts climbing from the leaf device
-        // up toward the root, we traverse the device path starting at
-        // the root moving toward the leaf node.
-        // The slot number of the top-level parent bridge is needed
-        // with more than 24 slots on the root bus.
-        //
-        if (Status != EFI_SUCCESS) {
-          Status = EFI_SUCCESS;
-          RootSlot = ((PCI_DEVICE_PATH *)DevPathNode)->Device;
-        }
-      }
-
-      DevPathNode = NextDevicePathNode (DevPathNode);
-    }
-    if (EFI_ERROR (Status)) {
-      return Status;
-    }
-    if (RootBusNumber == 0 && RootSlot == 0) {
-      return Status; //bugbug: workaround; need SIMICS change B0/D0/F0 PCI_IntPin reg(0x3D) = 0X0
-//      DEBUG((
-//        EFI_D_ERROR,
-//       "%a: PCI host bridge (00:00.0) should have no interrupts!\n",
-//        __FUNCTION__
-//        ));
-//      ASSERT (FALSE);
-    }
-
-    //
-    // Final PciHostIrqs[] index calculation depends on the platform
-    // and should match SeaBIOS src/fw/pciinit.c *_pci_slot_get_irq()
-    //
-    switch (mHostBridgeDevId) {
-      case INTEL_82441_DEVICE_ID:
-        Idx -= 1;
-        break;
-      case INTEL_ICH10_DEVICE_ID:
-        //
-        // SeaBIOS contains the following comment:
-        // "Slots 0-24 rotate slot:pin mapping similar to piix above, but
-        //  with a different starting index.
-        //
-        //  Slots 25-31 all use LNKA mapping (or LNKE, but A:D = E:H)"
-        //
-        if (RootSlot > 24) {
-          //
-          // in this case, subtract back out RootSlot from Idx
-          // (SeaBIOS never adds it to begin with, but that would make our
-          //  device path traversal loop above too awkward)
-          //
-          Idx -= RootSlot;
-        }
-        break;
-      default:
-        ASSERT (FALSE); // should never get here
-    }
-    Idx %= ARRAY_SIZE (PciHostIrqs);
-    IrqLine = PciHostIrqs[Idx];
-
-    DEBUG_CODE_BEGIN ();
-    {
-      CHAR16        *DevPathString;
-      STATIC CHAR16 Fallback[] = L"<failed to convert>";
-      UINTN         Segment, Bus, Device, Function;
-
-      DevPathString = ConvertDevicePathToText (DevPath, FALSE, FALSE);
-      if (DevPathString == NULL) {
-        DevPathString = Fallback;
-      }
-      Status = PciIo->GetLocation (PciIo, &Segment, &Bus, &Device, &Function);
-      ASSERT_EFI_ERROR (Status);
-
-      DEBUG ((EFI_D_VERBOSE, "%a: [%02x:%02x.%x] %s -> 0x%02x\n", __FUNCTION__,
-        (UINT32)Bus, (UINT32)Device, (UINT32)Function, DevPathString,
-        IrqLine));
-
-      if (DevPathString != Fallback) {
-        FreePool (DevPathString);
-      }
-    }
-    DEBUG_CODE_END ();
-
-    //
-    // Set PCI Interrupt Line register for this device to PciHostIrqs[Idx]
-    //
-    Status = PciIo->Pci.Write (
-               PciIo,
-               EfiPciIoWidthUint8,
-               PCI_INT_LINE_OFFSET,
-               1,
-               &IrqLine
-               );
-  }
-
-  return Status;
-}
-
-/**
-Write to mask and edge/level triggered registers of master and slave 8259 PICs.
-
-@param[in]  Mask       low byte for master PIC mask register,
-high byte for slave PIC mask register.
-@param[in]  EdgeLevel  low byte for master PIC edge/level triggered register,
-high byte for slave PIC edge/level triggered register.
-
-**/
-VOID
-Interrupt8259WriteMask(
-  IN UINT16  Mask,
-  IN UINT16  EdgeLevel
-)
-{
-  IoWrite8(LEGACY_8259_MASK_REGISTER_MASTER, (UINT8)Mask);
-  IoWrite8(LEGACY_8259_MASK_REGISTER_SLAVE, (UINT8)(Mask >> 8));
-  IoWrite8(LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_MASTER, (UINT8)EdgeLevel);
-  IoWrite8(LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_SLAVE, (UINT8)(EdgeLevel >> 8));
-}
-
-VOID
-PciAcpiInitialization (
-  )
-{
-  UINTN  Pmba;
-
-  //
-  // Query Host Bridge DID to determine platform type
-  //
-  mHostBridgeDevId = PcdGet16 (PcdSimicsX58HostBridgePciDevId);
-  switch (mHostBridgeDevId) {
-    case INTEL_82441_DEVICE_ID:
-      Pmba = POWER_MGMT_REGISTER_PIIX4 (PIIX4_PMBA);
-      //
-      // 00:01.0 ISA Bridge (PIIX4) LNK routing targets
-      //
-      PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x60), 0x0b); // A
-      PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x61), 0x0b); // B
-      PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x62), 0x0a); // C
-      PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x63), 0x0a); // D
-      break;
-    case INTEL_ICH10_DEVICE_ID:
-      Pmba = POWER_MGMT_REGISTER_ICH10 (ICH10_PMBASE);
-      //
-      // 00:1f.0 LPC Bridge LNK routing targets
-      //
-      PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x60), 0x0a); // A
-      PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x61), 0x0a); // B
-      PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x62), 0x0b); // C
-      PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x63), 0x0b); // D
-      PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x68), 0x0a); // E
-      PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x69), 0x0a); // F
-      PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x6a), 0x0b); // G
-      PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x6b), 0x0b); // H
-      break;
-    default:
-      DEBUG ((EFI_D_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",
-        __FUNCTION__, mHostBridgeDevId));
-      ASSERT (FALSE);
-      return;
-  }
-
-  //
-  // Initialize PCI_INTERRUPT_LINE for applicable present PCI devices
-  //
-  VisitAllPciInstances (SetPciIntLine);
-
-  //
-  // Set ACPI SCI_EN bit in PMCNTRL
-  //
-  IoOr16 ((PciRead32 (Pmba) & ~BIT0) + 4, BIT0);
-  //
-  // Set all 8259 interrupts to edge triggered and disabled
-  //
-  Interrupt8259WriteMask(0xFFFF, 0x0000);
-}
-
-EFI_STATUS
-EFIAPI
-ConnectRecursivelyIfPciMassStorage (
-  IN EFI_HANDLE           Handle,
-  IN EFI_PCI_IO_PROTOCOL  *Instance,
-  IN PCI_TYPE00           *PciHeader
-  )
-{
-  EFI_STATUS                Status;
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
-  CHAR16                    *DevPathStr;
-
-  //
-  // Recognize PCI Mass Storage
-  //
-  if (IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE)) {
-    DevicePath = NULL;
-    Status = gBS->HandleProtocol (
-                    Handle,
-                    &gEfiDevicePathProtocolGuid,
-                    (VOID*)&DevicePath
-                    );
-    if (EFI_ERROR (Status)) {
-      return Status;
-    }
-
-    //
-    // Print Device Path
-    //
-    DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
-    if (DevPathStr != NULL) {
-      DEBUG((
-        EFI_D_INFO,
-        "Found Mass Storage device: %s\n",
-        DevPathStr
-        ));
-      FreePool(DevPathStr);
-    }
-
-    Status = gBS->ConnectController (Handle, NULL, NULL, TRUE);
-    if (EFI_ERROR (Status)) {
-      return Status;
-    }
-
-  }
-
-  return EFI_SUCCESS;
-}
-
-
-/**
-  This notification function is invoked when the
-  EMU Variable FVB has been changed.
-
-  @param  Event                 The event that occurred
-  @param  Context               For EFI compatibility.  Not used.
-
-**/
-VOID
-EFIAPI
-EmuVariablesUpdatedCallback (
-  IN  EFI_EVENT Event,
-  IN  VOID      *Context
-  )
-{
-  DEBUG ((EFI_D_INFO, "EmuVariablesUpdatedCallback\n"));
-  UpdateNvVarsOnFileSystem ();
-}
-
-
-EFI_STATUS
-EFIAPI
-VisitingFileSystemInstance (
-  IN EFI_HANDLE  Handle,
-  IN VOID        *Instance,
-  IN VOID        *Context
-  )
-{
-  EFI_STATUS      Status;
-  STATIC BOOLEAN  ConnectedToFileSystem = FALSE;
-
-  if (ConnectedToFileSystem) {
-    return EFI_ALREADY_STARTED;
-  }
-
-  Status = ConnectNvVarsToFileSystem (Handle);
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  ConnectedToFileSystem = TRUE;
-  mEmuVariableEvent =
-    EfiCreateProtocolNotifyEvent (
-      &gEfiDevicePathProtocolGuid,
-      TPL_CALLBACK,
-      EmuVariablesUpdatedCallback,
-      NULL,
-      &mEmuVariableEventReg
-      );
-  PcdSet64 (PcdEmuVariableEvent, (UINT64)(UINTN) mEmuVariableEvent);
-
-  return EFI_SUCCESS;
-}
-
-
-VOID
-PlatformBdsRestoreNvVarsFromHardDisk (
-  )
-{
-  VisitAllPciInstances (ConnectRecursivelyIfPciMassStorage);
-  VisitAllInstancesOfProtocol (
-    &gEfiSimpleFileSystemProtocolGuid,
-    VisitingFileSystemInstance,
-    NULL
-    );
-
-}
-
-/**
-  Connect with predefined platform connect sequence.
-
-  The OEM/IBV can customize with their own connect sequence.
-**/
-VOID
-PlatformBdsConnectSequence (
-  VOID
-  )
-{
-  UINTN Index;
-
-  DEBUG ((EFI_D_INFO, "PlatformBdsConnectSequence\n"));
-
-  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
-    //
-    EfiBootManagerConnectDevicePath (gPlatformConnectSequence[Index], NULL);
-    Index++;
-  }
-
-  //
-  // Just use the simple policy to connect all devices
-  //
-  DEBUG ((EFI_D_INFO, "EfiBootManagerConnectAll\n"));
-  EfiBootManagerConnectAll ();
-
-  PciAcpiInitialization ();
-}
-
-/**
-  Do the platform specific action after the console is ready
-
-  Possible things that can be done in PlatformBootManagerAfterConsole:
-
-  > Console post action:
-    > Dynamically switch output mode from 100x31 to 80x25 for certain senarino
-    > Signal console ready platform customized event
-  > Run diagnostics like memory testing
-  > Connect certain devices
-  > Dispatch aditional option roms
-  > Special boot: e.g.: USB boot, enter UI
-**/
-VOID
-EFIAPI
-PlatformBootManagerAfterConsole (
-  VOID
-  )
-{
-  EFI_BOOT_MODE                      BootMode;
-  EFI_HANDLE                         Handle;
-  EFI_STATUS                         Status;
-
-  DEBUG ((EFI_D_INFO, "PlatformBootManagerAfterConsole\n"));
-
-  //
-  // Prevent further changes to LockBoxes or SMRAM.
-  //
-  Handle = NULL;
-  Status = gBS->InstallProtocolInterface(&Handle,
-    &gEfiDxeSmmReadyToLockProtocolGuid, EFI_NATIVE_INTERFACE,
-      NULL);
-  ASSERT_EFI_ERROR(Status);
-
-  if (PcdGetBool (PcdOvmfFlashVariablesEnable)) {
-    DEBUG ((EFI_D_INFO, "PlatformBdsPolicyBehavior: not restoring NvVars "
-      "from disk since flash variables appear to be supported.\n"));
-  } else {
-    //
-    // Try to restore variables from the hard disk early so
-    // they can be used for the other BDS connect operations.
-    //
-    PlatformBdsRestoreNvVarsFromHardDisk ();
-  }
-
-  //
-  // Get current Boot Mode
-  //
-  BootMode = GetBootModeHob ();
-  DEBUG ((EFI_D_ERROR, "Boot Mode:%x\n", BootMode));
-
-  //
-  // Go the different platform policy with different boot mode
-  // Notes: this part code can be change with the table policy
-  //
-  ASSERT (BootMode == BOOT_WITH_FULL_CONFIGURATION);
-
-  // Perform some platform specific connect sequence
-  //
-  PlatformBdsConnectSequence ();
-  //
-  // Logo show
-  //
-  EnableBootLogo(PcdGetPtr(PcdLogoFile));
-
-  EfiBootManagerRefreshAllBootOption ();
-
-  //
-  // Register UEFI Shell
-  //
-  PlatformRegisterFvBootOption (
-    PcdGetPtr (PcdShellFile), L"EFI Internal Shell", LOAD_OPTION_ACTIVE
-    );
-
-  RemoveStaleFvFileOptions ();
-}
-
-/**
-  This notification function is invoked when an instance of the
-  EFI_DEVICE_PATH_PROTOCOL is produced.
-
-  @param  Event                 The event that occurred
-  @param  Context               For EFI compatibility.  Not used.
-
-**/
-VOID
-EFIAPI
-NotifyDevPath (
-  IN  EFI_EVENT Event,
-  IN  VOID      *Context
-  )
-{
-  EFI_HANDLE                            Handle;
-  EFI_STATUS                            Status;
-  UINTN                                 BufferSize;
-  EFI_DEVICE_PATH_PROTOCOL             *DevPathNode;
-  ATAPI_DEVICE_PATH                    *Atapi;
-
-  //
-  // Examine all new handles
-  //
-  for (;;) {
-    //
-    // Get the next handle
-    //
-    BufferSize = sizeof (Handle);
-    Status = gBS->LocateHandle (
-              ByRegisterNotify,
-              NULL,
-              mEfiDevPathNotifyReg,
-              &BufferSize,
-              &Handle
-              );
-
-    //
-    // If not found, we're done
-    //
-    if (EFI_NOT_FOUND == Status) {
-      break;
-    }
-
-    if (EFI_ERROR (Status)) {
-      continue;
-    }
-
-    //
-    // Get the DevicePath protocol on that handle
-    //
-    Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **)&DevPathNode);
-    ASSERT_EFI_ERROR (Status);
-
-    while (!IsDevicePathEnd (DevPathNode)) {
-      //
-      // Find the handler to dump this device path node
-      //
-      if (
-           (DevicePathType(DevPathNode) == MESSAGING_DEVICE_PATH) &&
-           (DevicePathSubType(DevPathNode) == MSG_ATAPI_DP)
-         ) {
-        Atapi = (ATAPI_DEVICE_PATH*) DevPathNode;
-        PciOr16 (
-          PCI_LIB_ADDRESS (
-            0,
-            1,
-            1,
-            (Atapi->PrimarySecondary == 1) ? 0x42: 0x40
-            ),
-          BIT15
-          );
-      }
-
-      //
-      // Next device path node
-      //
-      DevPathNode = NextDevicePathNode (DevPathNode);
-    }
-  }
-
-  return;
-}
-
-
-VOID
-InstallDevicePathCallback (
-  VOID
-  )
-{
-  DEBUG ((EFI_D_INFO, "Registered NotifyDevPath Event\n"));
-  mEfiDevPathEvent = EfiCreateProtocolNotifyEvent (
-                          &gEfiDevicePathProtocolGuid,
-                          TPL_CALLBACK,
-                          NotifyDevPath,
-                          NULL,
-                          &mEfiDevPathNotifyReg
-                          );
-}
-
-/**
-  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
-  )
-{
-  // BUGBUG- will do it if need
-}
diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/BdsPlatform.h b/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/BdsPlatform.h
deleted file mode 100644
index 01ba20d2da..0000000000
--- a/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/BdsPlatform.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/** @file
-  Platform BDS customizations include file.
-
-  Copyright (c) 2006 - 2019 Intel Corporation. All rights reserved. <BR>
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-**/
-
-#ifndef _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
-#define _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
-
-
-#include <PiDxe.h>
-
-#include <IndustryStandard/Pci.h>
-#include <IndustryStandard/Acpi.h>
-#include <IndustryStandard/SmBios.h>
-#include <IndustryStandard/PeImage.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/PciLib.h>
-#include <Library/UefiBootManagerLib.h>
-#include <Library/BootLogoLib.h>
-#include <Library/HobLib.h>
-#include <Library/UefiLib.h>
-#include <Library/DxeServicesTableLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/IoLib.h>
-#include <Library/NvVarsFileLib.h>
-
-#include <Protocol/Decompress.h>
-#include <Protocol/PciIo.h>
-#include <Protocol/FirmwareVolume2.h>
-#include <Protocol/SimpleFileSystem.h>
-#include <Protocol/PciRootBridgeIo.h>
-#include <Protocol/S3SaveState.h>
-#include <Protocol/DxeSmmReadyToLock.h>
-#include <Protocol/LoadedImage.h>
-
-#include <Guid/Acpi.h>
-#include <Guid/SmBios.h>
-#include <Guid/Mps.h>
-#include <Guid/HobList.h>
-#include <Guid/GlobalVariable.h>
-#include <Guid/EventGroup.h>
-
-#include <SimicsPlatforms.h>
-
-extern EFI_DEVICE_PATH_PROTOCOL   *gPlatformConnectSequence[];
-extern ACPI_HID_DEVICE_PATH       gPnpPs2KeyboardDeviceNode;
-extern ACPI_HID_DEVICE_PATH       gPnp16550ComPortDeviceNode;
-extern UART_DEVICE_PATH           gUartDeviceNode;
-extern VENDOR_DEVICE_PATH         gTerminalTypeDeviceNode;
-
-#define PCI_DEVICE_PATH_NODE(Func, Dev) \
-  { \
-    { \
-      HARDWARE_DEVICE_PATH, \
-      HW_PCI_DP, \
-      { \
-        (UINT8) (sizeof (PCI_DEVICE_PATH)), \
-        (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8) \
-      } \
-    }, \
-    (Func), \
-    (Dev) \
-  }
-
-#define PNPID_DEVICE_PATH_NODE(PnpId) \
-  { \
-    { \
-      ACPI_DEVICE_PATH, \
-      ACPI_DP, \
-      { \
-        (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
-        (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
-      }, \
-    }, \
-    EISA_PNP_ID((PnpId)), \
-    0 \
-  }
-
-#define gPciIsaBridge \
-  PCI_DEVICE_PATH_NODE(0, 0x1f)
-
-#define gP2PBridge \
-  PCI_DEVICE_PATH_NODE(0, 0x1e)
-
-#define gPnpPs2Keyboard \
-  PNPID_DEVICE_PATH_NODE(0x0303)
-
-#define gPnp16550ComPort \
-  PNPID_DEVICE_PATH_NODE(0x0501)
-
-#define gUart \
-  { \
-    { \
-      MESSAGING_DEVICE_PATH, \
-      MSG_UART_DP, \
-      { \
-        (UINT8) (sizeof (UART_DEVICE_PATH)), \
-        (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8) \
-      } \
-    }, \
-    0, \
-    115200, \
-    8, \
-    1, \
-    1 \
-  }
-
-#define gPcAnsiTerminal \
-  { \
-    { \
-      MESSAGING_DEVICE_PATH, \
-      MSG_VENDOR_DP, \
-      { \
-        (UINT8) (sizeof (VENDOR_DEVICE_PATH)), \
-        (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) \
-      } \
-    }, \
-    DEVICE_PATH_MESSAGING_PC_ANSI \
-  }
-
-#define PCI_CLASS_SCC          0x07
-#define PCI_SUBCLASS_SERIAL    0x00
-#define PCI_IF_16550           0x02
-#define IS_PCI_16550SERIAL(_p)           IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS_SERIAL, PCI_IF_16550)
-#define IS_PCI_ISA_PDECODE(_p)        IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0)
-
-typedef struct {
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
-  UINTN                     ConnectType;
-} PLATFORM_CONSOLE_CONNECT_ENTRY;
-
-#define CONSOLE_OUT BIT0
-#define CONSOLE_IN  BIT1
-#define STD_ERROR   BIT2
-extern PLATFORM_CONSOLE_CONNECT_ENTRY  gPlatformConsole[];
-
-//
-// Platform BDS Functions
-//
-
-VOID
-PlatformInitializeConsole (
-  IN PLATFORM_CONSOLE_CONNECT_ENTRY   *PlatformConsole
-  );
-
-/**
-  Use SystemTable ConOut to stop video based Simple Text Out consoles from going
-  to the video device. Put up LogoFile on every video device that is a console.
-
-  @param[in]  LogoFile   The file name of logo to display on the center of the screen.
-
-  @retval EFI_SUCCESS     ConsoleControl has been flipped to graphics and logo displayed.
-  @retval EFI_UNSUPPORTED Logo not found.
-
-**/
-EFI_STATUS
-EFIAPI
-EnableBootLogo(
-  IN  EFI_GUID  *LogoFile
-);
-
-#endif // _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
deleted file mode 100644
index 3fb76c3564..0000000000
--- a/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+++ /dev/null
@@ -1,72 +0,0 @@
-## @file
-#  Platform BDS customizations library.
-#
-# Copyright (c) 2007 - 2019 Intel Corporation. All rights reserved. <BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
-  INF_VERSION                    = 0x00010005
-  BASE_NAME                      = PlatformBootManagerLib
-  FILE_GUID                      = 8AE4756F-0C71-4C06-84D4-4C71F204D514
-  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 EBC
-#
-
-[Sources]
-  BdsPlatform.c
-  PlatformData.c
-  BdsPlatform.h
-
-[Packages]
-  MdePkg/MdePkg.dec
-  MdeModulePkg/MdeModulePkg.dec
-  SimicsOpenBoardPkg/OpenBoardPkg.dec
-  OvmfPkg/OvmfPkg.dec
-  SimicsIch10Pkg/Ich10Pkg.dec
-
-[LibraryClasses]
-  BaseLib
-  MemoryAllocationLib
-  UefiBootServicesTableLib
-  BaseMemoryLib
-  DebugLib
-  PcdLib
-  UefiBootManagerLib
-  BootLogoLib
-  DevicePathLib
-  PciLib
-  NvVarsFileLib
-  DxeLoadLinuxLib
-  UefiLib
-  LogoLib
-
-[Pcd]
-  gSimicsOpenBoardPkgTokenSpaceGuid.PcdEmuVariableEvent
-  gSimicsOpenBoardPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable
-  gSimicsOpenBoardPkgTokenSpaceGuid.PcdSimicsX58HostBridgePciDevId
-  gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
-  gSimicsOpenBoardPkgTokenSpaceGuid.PcdShellFile
-  gSimicsOpenBoardPkgTokenSpaceGuid.PcdLogoFile
-
-[Pcd.IA32, Pcd.X64]
-  gEfiMdePkgTokenSpaceGuid.PcdFSBClock
-
-[Protocols]
-  gEfiDecompressProtocolGuid
-  gEfiPciRootBridgeIoProtocolGuid
-  gEfiS3SaveStateProtocolGuid                   # PROTOCOL SOMETIMES_CONSUMED
-  gEfiDxeSmmReadyToLockProtocolGuid             # PROTOCOL SOMETIMES_PRODUCED
-  gEfiLoadedImageProtocolGuid                   # PROTOCOL SOMETIMES_PRODUCED
-  gEfiFirmwareVolume2ProtocolGuid               # PROTOCOL SOMETIMES_CONSUMED
-
-[Guids]
-  gEfiEndOfDxeEventGroupGuid
diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/PlatformData.c b/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/PlatformData.c
deleted file mode 100644
index 768843a8bf..0000000000
--- a/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/PlatformData.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/** @file
-  Defined the platform specific device path which will be used by
-  platform Bbd to perform the platform policy connect.
-
-  Copyright (c) 2004 - 2019 Intel Corporation. All rights reserved. <BR>
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-**/
-
-#include "BdsPlatform.h"
-
-ACPI_HID_DEVICE_PATH       gPnpPs2KeyboardDeviceNode  = gPnpPs2Keyboard;
-ACPI_HID_DEVICE_PATH       gPnp16550ComPortDeviceNode = gPnp16550ComPort;
-UART_DEVICE_PATH           gUartDeviceNode            = gUart;
-VENDOR_DEVICE_PATH         gTerminalTypeDeviceNode    = gPcAnsiTerminal;
-
-//
-// Platform specific keyboard device path
-//
-
-//
-// Predefined platform default console device path
-//
-PLATFORM_CONSOLE_CONNECT_ENTRY   gPlatformConsole[] = {
-  {
-    NULL,
-    0
-  }
-};
-
-//
-// Predefined platform connect sequence
-//
-EFI_DEVICE_PATH_PROTOCOL    *gPlatformConnectSequence[] = { NULL };
-
-- 
2.39.1.windows.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 2/6] SimicsOpenBoardPkg: Remove logic that loads variable from disk file
  2023-05-24 12:28 [PATCH 0/6] Fine tune SimicsOpenBoardPkg Ni, Ray
  2023-05-24 12:28 ` [PATCH 1/6] SimicsOpenBoardPkg: Remove un-used PlatformBootManagerLib Ni, Ray
@ 2023-05-24 12:28 ` Ni, Ray
  2023-05-24 12:28 ` [PATCH 3/6] SimicsOpenBoardPkg: Enable serial terminal Ni, Ray
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Ni, Ray @ 2023-05-24 12:28 UTC (permalink / raw)
  To: devel; +Cc: Nate DeSimone, Zhiguang Liu

Simics QSP platform always supports flash devices.
The logic that was ported from OVMF where the flash devices might
not be supported in some configurations is useless in QSP platform.
So, the patch removes all of them.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Zhiguang Liu <zhiguang@liu@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
---
 .../BoardX58Ich10/OpenBoardPkg.dsc            |   2 -
 .../Include/Library/SerializeVariablesLib.h   | 224 -----
 .../Library/BoardBdsHookLib/BoardBdsHookLib.c | 124 ---
 .../BoardBdsHookLib/BoardBdsHookLib.inf       |   3 -
 .../Library/NvVarsFileLib/FsAccess.c          | 507 ----------
 .../Library/NvVarsFileLib/NvVarsFileLib.c     |  77 --
 .../Library/NvVarsFileLib/NvVarsFileLib.h     |  55 --
 .../Library/NvVarsFileLib/NvVarsFileLib.inf   |  53 --
 .../SerializeVariablesLib.c                   | 869 ------------------
 .../SerializeVariablesLib.h                   |  33 -
 .../SerializeVariablesLib.inf                 |  36 -
 .../Intel/SimicsOpenBoardPkg/OpenBoardPkg.dec |   3 -
 12 files changed, 1986 deletions(-)
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Include/Library/SerializeVariablesLib.h
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/FsAccess.c
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.c
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.h
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeVariablesLib.h
 delete mode 100644 Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf

diff --git a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
index 5ac260a26f..4e8991dbdf 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
+++ b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
@@ -114,9 +114,7 @@
   #######################################
   DxeLoadLinuxLib|$(BOARD_PKG)/Library/LoadLinuxLib/DxeLoadLinuxLib.inf
   LogoLib|$(BOARD_PKG)/Library/DxeLogoLib/DxeLogoLib.inf
-  NvVarsFileLib|$(BOARD_PKG)/Library/NvVarsFileLib/NvVarsFileLib.inf
   ReportFvLib|$(BOARD_PKG)/Library/PeiReportFvLib/PeiReportFvLib.inf
-  SerializeVariablesLib|$(BOARD_PKG)/Library/SerializeVariablesLib/SerializeVariablesLib.inf
   SiliconPolicyInitLib|$(BOARD_PKG)/Policy/Library/SiliconPolicyInitLib/SiliconPolicyInitLib.inf
   SiliconPolicyUpdateLib|$(BOARD_PKG)/Policy/Library/SiliconPolicyUpdateLib/SiliconPolicyUpdateLib.inf
   PlatformCmosAccessLib|BoardModulePkg/Library/PlatformCmosAccessLibNull/PlatformCmosAccessLibNull.inf
diff --git a/Platform/Intel/SimicsOpenBoardPkg/Include/Library/SerializeVariablesLib.h b/Platform/Intel/SimicsOpenBoardPkg/Include/Library/SerializeVariablesLib.h
deleted file mode 100644
index c32f97d787..0000000000
--- a/Platform/Intel/SimicsOpenBoardPkg/Include/Library/SerializeVariablesLib.h
+++ /dev/null
@@ -1,224 +0,0 @@
-/** @file
-  Serialize & Deserialize UEFI Variables
-
-  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef __SERIALIZE_VARIABLES_LIB__
-#define __SERIALIZE_VARIABLES_LIB__
-
-
-/**
-  Callback function for each variable
-
-  @param[in] Context - Context as sent to the iteration function
-  @param[in] VariableName - Refer to RuntimeServices GetNextVariableName
-  @param[in] VendorGuid - Refer to RuntimeServices GetNextVariableName
-  @param[in] Attributes - Refer to RuntimeServices GetVariable
-  @param[in] DataSize - Refer to RuntimeServices GetVariable
-  @param[in] Data - Refer to RuntimeServices GetVariable
-
-  @retval RETURN_SUCCESS         Continue iterating through the variables
-  @return Any RETURN_ERROR       Stop iterating through the variables
-
-**/
-typedef
-RETURN_STATUS
-(EFIAPI *VARIABLE_SERIALIZATION_ITERATION_CALLBACK)(
-  IN  VOID                         *Context,
-  IN  CHAR16                       *VariableName,
-  IN  EFI_GUID                     *VendorGuid,
-  IN  UINT32                       Attributes,
-  IN  UINTN                        DataSize,
-  IN  VOID                         *Data
-  );
-
-
-/**
-  Creates a new variable serialization instance
-
-  @param[out]  Handle - Handle for a variable serialization instance
-
-  @retval      RETURN_SUCCESS - The variable serialization instance was
-                 successfully created.
-  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources to
-                 create the variable serialization instance.
-
-**/
-RETURN_STATUS
-EFIAPI
-SerializeVariablesNewInstance (
-  OUT EFI_HANDLE                      *Handle
-  );
-
-
-/**
-  Free memory associated with a variable serialization instance
-
-  @param[in]  Handle - Handle for a variable serialization instance
-
-  @retval      RETURN_SUCCESS - The variable serialization instance was
-                 successfully freed.
-  @retval      RETURN_INVALID_PARAMETER - Handle was not a valid
-                 variable serialization instance.
-
-**/
-RETURN_STATUS
-EFIAPI
-SerializeVariablesFreeInstance (
-  IN EFI_HANDLE Handle
-  );
-
-
-/**
-  Creates a new variable serialization instance using the given
-  binary representation of the variables to fill the new instance
-
-  @param[out] Handle - Handle for a variable serialization instance
-  @param[in]  Buffer - A buffer with the serialized representation
-                of the variables.  Must be the same format as produced
-                by SerializeVariablesToBuffer.
-  @param[in]  Size - This is the size of the binary representation
-                of the variables.
-
-  @retval      RETURN_SUCCESS - The binary representation was successfully
-                 imported into a new variable serialization instance
-  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources to
-                 create the new variable serialization instance
-
-**/
-RETURN_STATUS
-EFIAPI
-SerializeVariablesNewInstanceFromBuffer (
-  OUT EFI_HANDLE                          *Handle,
-  IN  VOID                                *Buffer,
-  IN  UINTN                               Size
-  );
-
-
-/**
-  Iterates all variables found with RuntimeServices GetNextVariableName
-
-  @param[in]   CallbackFunction - Function called for each variable instance
-  @param[in]   Context - Passed to each call of CallbackFunction
-
-  @retval      RETURN_SUCCESS - All variables were iterated without the
-                 CallbackFunction returning an error
-  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources to
-                 iterate through the variables
-  @return      Any of RETURN_ERROR indicates an error reading the variable
-                 or an error was returned from CallbackFunction
-
-**/
-RETURN_STATUS
-EFIAPI
-SerializeVariablesIterateSystemVariables (
-  IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction,
-  IN VOID                                      *Context
-  );
-
-
-/**
-  Iterates all variables found in the variable serialization instance
-
-  @param[in]   Handle - Handle for a variable serialization instance
-  @param[in]   CallbackFunction - Function called for each variable instance
-  @param[in]   Context - Passed to each call of CallbackFunction
-
-  @retval      RETURN_SUCCESS - All variables were iterated without the
-                 CallbackFunction returning an error
-  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources to
-                 iterate through the variables
-  @return      Any of RETURN_ERROR indicates an error reading the variable
-                 or an error was returned from CallbackFunction
-
-**/
-RETURN_STATUS
-EFIAPI
-SerializeVariablesIterateInstanceVariables (
-  IN EFI_HANDLE                                Handle,
-  IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction,
-  IN VOID                                      *Context
-  );
-
-
-/**
-  Sets all variables found in the variable serialization instance
-
-  @param[in]   Handle - Handle for a variable serialization instance
-
-  @retval      RETURN_SUCCESS - All variables were set successfully
-  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources to
-                 set all the variables
-  @return      Any of RETURN_ERROR indicates an error reading the variables
-                 or in attempting to set a variable
-
-**/
-RETURN_STATUS
-EFIAPI
-SerializeVariablesSetSerializedVariables (
-  IN EFI_HANDLE                       Handle
-  );
-
-
-/**
-  Adds a variable to the variable serialization instance
-
-  @param[in] Handle - Handle for a variable serialization instance
-  @param[in] VariableName - Refer to RuntimeServices GetVariable
-  @param[in] VendorGuid - Refer to RuntimeServices GetVariable
-  @param[in] Attributes - Refer to RuntimeServices GetVariable
-  @param[in] DataSize - Refer to RuntimeServices GetVariable
-  @param[in] Data - Refer to RuntimeServices GetVariable
-
-  @retval      RETURN_SUCCESS - All variables were set successfully
-  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources to
-                 add the variable
-
-**/
-RETURN_STATUS
-EFIAPI
-SerializeVariablesAddVariable (
-  IN EFI_HANDLE                   Handle,
-  IN CHAR16                       *VariableName,
-  IN EFI_GUID                     *VendorGuid,
-  IN UINT32                       Attributes,
-  IN UINTN                        DataSize,
-  IN VOID                         *Data
-  );
-
-
-/**
-  Serializes the variables known to this instance into the
-  provided buffer.
-
-  @param[in]     Handle - Handle for a variable serialization instance
-  @param[out]    Buffer - A buffer to store the binary representation
-                   of the variables.
-  @param[in,out] Size - On input this is the size of the buffer.
-                   On output this is the size of the binary representation
-                   of the variables.
-
-  @retval      RETURN_SUCCESS - The binary representation was successfully
-                 completed and returned in the buffer.
-  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources to
-                 save the variables to the buffer.
-  @retval      RETURN_INVALID_PARAMETER - Handle was not a valid
-                 variable serialization instance or
-                 Size or Buffer were NULL.
-
-**/
-RETURN_STATUS
-EFIAPI
-SerializeVariablesToBuffer (
-  IN     EFI_HANDLE                       Handle,
-  OUT    VOID                             *Buffer,
-  IN OUT UINTN                            *Size
-  );
-
-
-#endif
-
diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
index ba4d2b02d8..3c6385c12f 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
+++ b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
@@ -1111,119 +1111,6 @@ PciAcpiInitialization (
   Interrupt8259WriteMask(0xFFFF, 0x0000);
 }
 
-EFI_STATUS
-EFIAPI
-ConnectRecursivelyIfPciMassStorage (
-  IN EFI_HANDLE           Handle,
-  IN EFI_PCI_IO_PROTOCOL  *Instance,
-  IN PCI_TYPE00           *PciHeader
-  )
-{
-  EFI_STATUS                Status;
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
-  CHAR16                    *DevPathStr;
-
-  //
-  // Recognize PCI Mass Storage
-  //
-  if (IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE)) {
-    DevicePath = NULL;
-    Status = gBS->HandleProtocol (
-                    Handle,
-                    &gEfiDevicePathProtocolGuid,
-                    (VOID*)&DevicePath
-                    );
-    if (EFI_ERROR (Status)) {
-      return Status;
-    }
-
-    //
-    // Print Device Path
-    //
-    DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
-    if (DevPathStr != NULL) {
-      DEBUG(( DEBUG_INFO, "Found Mass Storage device: %s\n", DevPathStr));
-      FreePool(DevPathStr);
-    }
-
-    Status = gBS->ConnectController (Handle, NULL, NULL, TRUE);
-    if (EFI_ERROR (Status)) {
-      return Status;
-    }
-
-   }
-
-  return EFI_SUCCESS;
-}
-
-
-/**
-  This notification function is invoked when the
-  EMU Variable FVB has been changed.
-
-  @param  Event                 The event that occurred
-  @param  Context               For EFI compatibility.  Not used.
-
-**/
-VOID
-EFIAPI
-EmuVariablesUpdatedCallback (
-  IN  EFI_EVENT Event,
-  IN  VOID      *Context
-  )
-{
-  DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
-  UpdateNvVarsOnFileSystem ();
-}
-
-
-EFI_STATUS
-EFIAPI
-VisitingFileSystemInstance (
-  IN EFI_HANDLE  Handle,
-  IN VOID        *Instance,
-  IN VOID        *Context
-  )
-{
-  EFI_STATUS      Status;
-  STATIC BOOLEAN  ConnectedToFileSystem = FALSE;
-
-  if (ConnectedToFileSystem) {
-    return EFI_ALREADY_STARTED;
-  }
-
-  Status = ConnectNvVarsToFileSystem (Handle);
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  ConnectedToFileSystem = TRUE;
-  mEmuVariableEvent =
-    EfiCreateProtocolNotifyEvent (
-      &gEfiDevicePathProtocolGuid,
-      TPL_CALLBACK,
-      EmuVariablesUpdatedCallback,
-      NULL,
-      &mEmuVariableEventReg
-      );
-  PcdSet64S (PcdEmuVariableEvent, (UINT64)(UINTN) mEmuVariableEvent);
-
-  return EFI_SUCCESS;
-}
-
-
-VOID
-PlatformBdsRestoreNvVarsFromHardDisk (
-  )
-{
-  VisitAllPciInstances (ConnectRecursivelyIfPciMassStorage);
-  VisitAllInstancesOfProtocol (
-    &gEfiSimpleFileSystemProtocolGuid,
-    VisitingFileSystemInstance,
-    NULL
-    );
-}
-
 /**
   Connect with predefined platform connect sequence.
 
@@ -1584,17 +1471,6 @@ BdsAfterConsoleReadyBeforeBootOptionCallback (
 
   DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
 
-  if (PcdGetBool (PcdOvmfFlashVariablesEnable)) {
-    DEBUG ((DEBUG_INFO, "PlatformBdsPolicyBehavior: not restoring NvVars "
-      "from disk since flash variables appear to be supported.\n"));
-  } else {
-    //
-    // Try to restore variables from the hard disk early so
-    // they can be used for the other BDS connect operations.
-    //
-    PlatformBdsRestoreNvVarsFromHardDisk ();
-  }
-
   //
   // Get current Boot Mode
   //
diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
index a77edf2699..bcfbdca996 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
+++ b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
@@ -45,14 +45,11 @@
   BootLogoLib
   DevicePathLib
   PciLib
-  NvVarsFileLib
   DxeLoadLinuxLib
   UefiLib
   LogoLib
 
 [Pcd]
-  gSimicsOpenBoardPkgTokenSpaceGuid.PcdEmuVariableEvent
-  gSimicsOpenBoardPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable
   gSimicsOpenBoardPkgTokenSpaceGuid.PcdSimicsX58HostBridgePciDevId
   gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
   gSimicsOpenBoardPkgTokenSpaceGuid.PcdShellFile
diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/FsAccess.c b/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/FsAccess.c
deleted file mode 100644
index 3d98291410..0000000000
--- a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/FsAccess.c
+++ /dev/null
@@ -1,507 +0,0 @@
-/** @file
-  File System Access for NvVarsFileLib
-
-  Copyright (c) 2004 - 2019 Intel Corporation. All rights reserved. <BR>
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-**/
-
-#include "NvVarsFileLib.h"
-
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-
-
-/**
-  Open the NvVars file for reading or writing
-
-  @param[in]  FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid instance
-  @param[in]  ReadingFile - TRUE: open the file for reading.  FALSE: writing
-  @param[out] NvVarsFile - If EFI_SUCCESS is returned, then this is updated
-                           with the opened NvVars file.
-
-  @return     EFI_SUCCESS if the file was opened
-
-**/
-EFI_STATUS
-GetNvVarsFile (
-  IN  EFI_HANDLE            FsHandle,
-  IN  BOOLEAN               ReadingFile,
-  OUT EFI_FILE_HANDLE       *NvVarsFile
-  )
-{
-  EFI_STATUS                            Status;
-  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL       *Fs;
-  EFI_FILE_HANDLE                       Root;
-
-  //
-  // Get the FileSystem protocol on that handle
-  //
-  Status = gBS->HandleProtocol (
-                  FsHandle,
-                  &gEfiSimpleFileSystemProtocolGuid,
-                  (VOID **)&Fs
-                  );
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  //
-  // Get the volume (the root directory)
-  //
-  Status = Fs->OpenVolume (Fs, &Root);
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  //
-  // Attempt to open the NvVars file in the root directory
-  //
-  Status = Root->Open (
-                   Root,
-                   NvVarsFile,
-                   L"NvVars",
-                   ReadingFile ?
-                     EFI_FILE_MODE_READ :
-                     (
-                       EFI_FILE_MODE_CREATE |
-                       EFI_FILE_MODE_READ |
-                       EFI_FILE_MODE_WRITE
-                     ),
-                   0
-                   );
-
-  return Status;
-}
-
-
-/**
-  Open the NvVars file for reading or writing
-
-  @param[in]  File - The file to inspect
-  @param[out] Exists - Returns whether the file exists
-  @param[out] Size - Returns the size of the file
-                     (0 if the file does not exist)
-
-**/
-VOID
-NvVarsFileReadCheckup (
-  IN  EFI_FILE_HANDLE        File,
-  OUT BOOLEAN                *Exists,
-  OUT UINTN                  *Size
-  )
-{
-  EFI_FILE_INFO               *FileInfo;
-
-  *Exists = FALSE;
-  *Size = 0;
-
-  FileInfo = FileHandleGetInfo (File);
-  if (FileInfo == NULL) {
-    return;
-  }
-
-  if ((FileInfo->Attribute & EFI_FILE_DIRECTORY) != 0) {
-    FreePool (FileInfo);
-    return;
-  }
-
-  *Exists = TRUE;
-  *Size = (UINTN) FileInfo->FileSize;
-
-  FreePool (FileInfo);
-}
-
-
-/**
-  Open the NvVars file for reading or writing
-
-  @param[in]  File - The file to inspect
-  @param[out] Exists - Returns whether the file exists
-  @param[out] Size - Returns the size of the file
-                     (0 if the file does not exist)
-
-**/
-EFI_STATUS
-FileHandleEmpty (
-  IN  EFI_FILE_HANDLE        File
-  )
-{
-  EFI_STATUS                  Status;
-  EFI_FILE_INFO               *FileInfo;
-
-  //
-  // Retrieve the FileInfo structure
-  //
-  FileInfo = FileHandleGetInfo (File);
-  if (FileInfo == NULL) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  //
-  // If the path is a directory, then return an error
-  //
-  if ((FileInfo->Attribute & EFI_FILE_DIRECTORY) != 0) {
-    FreePool (FileInfo);
-    return EFI_INVALID_PARAMETER;
-  }
-
-  //
-  // If the file size is already 0, then it is empty, so
-  // we can return success.
-  //
-  if (FileInfo->FileSize == 0) {
-    FreePool (FileInfo);
-    return EFI_SUCCESS;
-  }
-
-  //
-  // Set the file size to 0.
-  //
-  FileInfo->FileSize = 0;
-  Status = FileHandleSetInfo (File, FileInfo);
-
-  FreePool (FileInfo);
-
-  return Status;
-}
-
-
-/**
-  Reads a file to a newly allocated buffer
-
-  @param[in]  File - The file to read
-  @param[in]  ReadSize - The size of data to read from the file
-
-  @return     Pointer to buffer allocated to hold the file
-              contents.  NULL if an error occurred.
-
-**/
-VOID*
-FileHandleReadToNewBuffer (
-  IN EFI_FILE_HANDLE            FileHandle,
-  IN UINTN                      ReadSize
-  )
-{
-  EFI_STATUS                  Status;
-  UINTN                       ActualReadSize;
-  VOID                        *FileContents;
-
-  ActualReadSize = ReadSize;
-  FileContents = AllocatePool (ReadSize);
-  if (FileContents != NULL) {
-    Status = FileHandleRead (
-               FileHandle,
-               &ReadSize,
-               FileContents
-               );
-    if (EFI_ERROR (Status) || (ActualReadSize != ReadSize)) {
-      FreePool (FileContents);
-      return NULL;
-    }
-  }
-
-  return FileContents;
-}
-
-
-/**
-  Reads the contents of the NvVars file on the file system
-
-  @param[in]  FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid instance
-
-  @return     EFI_STATUS based on the success or failure of the file read
-
-**/
-EFI_STATUS
-ReadNvVarsFile (
-  IN  EFI_HANDLE            FsHandle
-  )
-{
-  EFI_STATUS                  Status;
-  EFI_FILE_HANDLE             File;
-  UINTN                       FileSize;
-  BOOLEAN                     FileExists;
-  VOID                        *FileContents;
-  EFI_HANDLE                  SerializedVariables;
-
-  Status = GetNvVarsFile (FsHandle, TRUE, &File);
-  if (EFI_ERROR (Status)) {
-    DEBUG ((EFI_D_INFO, "FsAccess.c: Could not open NV Variables file on this file system\n"));
-    return Status;
-  }
-
-  NvVarsFileReadCheckup (File, &FileExists, &FileSize);
-  if (FileSize == 0) {
-    FileHandleClose (File);
-    return EFI_UNSUPPORTED;
-  }
-
-  FileContents = FileHandleReadToNewBuffer (File, FileSize);
-  if (FileContents == NULL) {
-    FileHandleClose (File);
-    return EFI_UNSUPPORTED;
-  }
-
-  DEBUG ((
-    EFI_D_INFO,
-    "FsAccess.c: Read %Lu bytes from NV Variables file\n",
-    (UINT64)FileSize
-    ));
-
-  Status = SerializeVariablesNewInstanceFromBuffer (
-             &SerializedVariables,
-             FileContents,
-             FileSize
-             );
-  if (!RETURN_ERROR (Status)) {
-    Status = SerializeVariablesSetSerializedVariables (SerializedVariables);
-  }
-
-  FreePool (FileContents);
-  FileHandleClose (File);
-
-  return Status;
-}
-
-
-/**
-  Writes a variable to indicate that the NV variables
-  have been loaded from the file system.
-
-**/
-STATIC
-VOID
-SetNvVarsVariable (
-  VOID
-  )
-{
-  BOOLEAN                        VarData;
-  UINTN                          Size;
-
-  //
-  // Write a variable to indicate we've already loaded the
-  // variable data.  If it is found, we skip the loading on
-  // subsequent attempts.
-  //
-  Size = sizeof (VarData);
-  VarData = TRUE;
-  gRT->SetVariable (
-         L"NvVars",
-         &gEfiSimpleFileSystemProtocolGuid,
-         EFI_VARIABLE_NON_VOLATILE |
-           EFI_VARIABLE_BOOTSERVICE_ACCESS |
-           EFI_VARIABLE_RUNTIME_ACCESS,
-         Size,
-         (VOID*) &VarData
-         );
-}
-
-
-/**
-  Loads the non-volatile variables from the NvVars file on the
-  given file system.
-
-  @param[in]  FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid instance
-
-  @return     EFI_STATUS based on the success or failure of load operation
-
-**/
-EFI_STATUS
-LoadNvVarsFromFs (
-  EFI_HANDLE                            FsHandle
-  )
-{
-  EFI_STATUS                     Status;
-  BOOLEAN                        VarData;
-  UINTN                          Size;
-
-  DEBUG ((EFI_D_INFO, "FsAccess.c: LoadNvVarsFromFs\n"));
-
-  //
-  // We write a variable to indicate we've already loaded the
-  // variable data.  If it is found, we skip the loading.
-  //
-  // This is relevant if the non-volatile variable have been
-  // able to survive a reboot operation.  In that case, we don't
-  // want to re-load the file as it would overwrite newer changes
-  // made to the variables.
-  //
-  Size = sizeof (VarData);
-  VarData = TRUE;
-  Status = gRT->GetVariable (
-                  L"NvVars",
-                  &gEfiSimpleFileSystemProtocolGuid,
-                  NULL,
-                  &Size,
-                  (VOID*) &VarData
-                  );
-  if (Status == EFI_SUCCESS) {
-    DEBUG ((EFI_D_INFO, "NV Variables were already loaded\n"));
-    return EFI_ALREADY_STARTED;
-  }
-
-  //
-  // Attempt to restore the variables from the NvVars file.
-  //
-  Status = ReadNvVarsFile (FsHandle);
-  if (EFI_ERROR (Status)) {
-    DEBUG ((EFI_D_INFO, "Error while restoring NV variable data\n"));
-    return Status;
-  }
-
-  //
-  // Write a variable to indicate we've already loaded the
-  // variable data.  If it is found, we skip the loading on
-  // subsequent attempts.
-  //
-  SetNvVarsVariable();
-
-  DEBUG ((
-    EFI_D_INFO,
-    "FsAccess.c: Read NV Variables file (size=%Lu)\n",
-    (UINT64)Size
-    ));
-
-  return Status;
-}
-
-
-STATIC
-RETURN_STATUS
-EFIAPI
-IterateVariablesCallbackAddAllNvVariables (
-  IN  VOID                         *Context,
-  IN  CHAR16                       *VariableName,
-  IN  EFI_GUID                     *VendorGuid,
-  IN  UINT32                       Attributes,
-  IN  UINTN                        DataSize,
-  IN  VOID                         *Data
-  )
-{
-  EFI_HANDLE  Instance;
-
-  Instance = (EFI_HANDLE) Context;
-
-  //
-  // Only save non-volatile variables
-  //
-  if ((Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) {
-    return RETURN_SUCCESS;
-  }
-
-  return SerializeVariablesAddVariable (
-           Instance,
-           VariableName,
-           VendorGuid,
-           Attributes,
-           DataSize,
-           Data
-           );
-}
-
-
-/**
-  Saves the non-volatile variables into the NvVars file on the
-  given file system.
-
-  @param[in]  FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid instance
-
-  @return     EFI_STATUS based on the success or failure of load operation
-
-**/
-EFI_STATUS
-SaveNvVarsToFs (
-  EFI_HANDLE                            FsHandle
-  )
-{
-  EFI_STATUS                  Status;
-  EFI_FILE_HANDLE             File;
-  UINTN                       WriteSize;
-  UINTN                       VariableDataSize;
-  VOID                        *VariableData;
-  EFI_HANDLE                  SerializedVariables;
-
-  SerializedVariables = NULL;
-
-  Status = SerializeVariablesNewInstance (&SerializedVariables);
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  Status = SerializeVariablesIterateSystemVariables (
-             IterateVariablesCallbackAddAllNvVariables,
-             (VOID*) SerializedVariables
-             );
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  VariableData = NULL;
-  VariableDataSize = 0;
-  Status = SerializeVariablesToBuffer (
-             SerializedVariables,
-             NULL,
-             &VariableDataSize
-             );
-  if (Status == RETURN_BUFFER_TOO_SMALL) {
-    VariableData = AllocatePool (VariableDataSize);
-    if (VariableData == NULL) {
-      Status = EFI_OUT_OF_RESOURCES;
-    } else {
-      Status = SerializeVariablesToBuffer (
-                 SerializedVariables,
-                 VariableData,
-                 &VariableDataSize
-                 );
-    }
-  }
-
-  SerializeVariablesFreeInstance (SerializedVariables);
-
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  //
-  // Open the NvVars file for writing.
-  //
-  Status = GetNvVarsFile (FsHandle, FALSE, &File);
-  if (EFI_ERROR (Status)) {
-    DEBUG ((EFI_D_INFO, "FsAccess.c: Unable to open file to saved NV Variables\n"));
-    return Status;
-  }
-
-  //
-  // Empty the starting file contents.
-  //
-  Status = FileHandleEmpty (File);
-  if (EFI_ERROR (Status)) {
-    FileHandleClose (File);
-    return Status;
-  }
-
-  WriteSize = VariableDataSize;
-  Status = FileHandleWrite (File, &WriteSize, VariableData);
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  FileHandleClose (File);
-
-  if (!EFI_ERROR (Status)) {
-    //
-    // Write a variable to indicate we've already loaded the
-    // variable data.  If it is found, we skip the loading on
-    // subsequent attempts.
-    //
-    SetNvVarsVariable();
-
-	DEBUG ((EFI_D_INFO, "Saved NV Variables to NvVars file\n"));
-  }
-
-  return Status;
-}
-
-
diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.c b/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.c
deleted file mode 100644
index 2e9618455d..0000000000
--- a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/** @file
-  Save Non-Volatile Variables to a file system.
-
-  Copyright (c) 2019 Intel Corporation. All rights reserved. <BR>
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-**/
-
-#include "NvVarsFileLib.h"
-#include <Library/DebugLib.h>
-#include <Library/NvVarsFileLib.h>
-
-EFI_HANDLE    mNvVarsFileLibFsHandle = NULL;
-
-
-/**
-  Attempts to connect the NvVarsFileLib to the specified file system.
-
-  @param[in]  FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid instance
-
-  @return     The EFI_STATUS while attempting to connect the NvVarsFileLib
-              to the file system instance.
-  @retval     EFI_SUCCESS - The given file system was connected successfully
-
-**/
-EFI_STATUS
-EFIAPI
-ConnectNvVarsToFileSystem (
-  IN EFI_HANDLE    FsHandle
-  )
-{
-  EFI_STATUS Status;
-
-  //
-  // We might fail to load the variable, since the file system initially
-  // will not have the NvVars file.
-  //
-  LoadNvVarsFromFs (FsHandle);
-
-  //
-  // We must be able to save the variables successfully to the file system
-  // to have connected successfully.
-  //
-  Status = SaveNvVarsToFs (FsHandle);
-  if (!EFI_ERROR (Status)) {
-    mNvVarsFileLibFsHandle = FsHandle;
-  }
-
-  return Status;
-}
-
-
-/**
-  Update non-volatile variables stored on the file system.
-
-  @return     The EFI_STATUS while attempting to update the variable on
-              the connected file system.
-  @retval     EFI_SUCCESS - The non-volatile variables were saved to the disk
-  @retval     EFI_NOT_STARTED - A file system has not been connected
-
-**/
-EFI_STATUS
-EFIAPI
-UpdateNvVarsOnFileSystem (
-  )
-{
-  if (mNvVarsFileLibFsHandle == NULL) {
-    //
-    // A file system had not been connected to the library.
-    //
-    return EFI_NOT_STARTED;
-  } else {
-    return SaveNvVarsToFs (mNvVarsFileLibFsHandle);
-  }
-}
-
-
diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.h b/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.h
deleted file mode 100644
index 80776fd003..0000000000
--- a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/** @file
-  Save Non-Volatile Variables to a file system.
-
-  Copyright (c) 2009 - 2019 Intel Corporation. All rights reserved. <BR>
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-**/
-
-#ifndef __NV_VARS_FILE_LIB_INSTANCE__
-#define __NV_VARS_FILE_LIB_INSTANCE__
-
-#include <Uefi.h>
-
-#include <Guid/FileInfo.h>
-
-#include <Protocol/SimpleFileSystem.h>
-
-#include <Library/BaseLib.h>
-#include <Library/FileHandleLib.h>
-#include <Library/SerializeVariablesLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/UefiLib.h>
-
-/**
-  Loads the non-volatile variables from the NvVars file on the
-  given file system.
-
-  @param[in]  FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid instance
-
-  @return     EFI_STATUS based on the success or failure of load operation
-
-**/
-EFI_STATUS
-LoadNvVarsFromFs (
-  EFI_HANDLE                            FsHandle
-  );
-
-
-/**
-  Saves the non-volatile variables into the NvVars file on the
-  given file system.
-
-  @param[in]  FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid instance
-
-  @return     EFI_STATUS based on the success or failure of load operation
-
-**/
-EFI_STATUS
-SaveNvVarsToFs (
-  EFI_HANDLE                            FsHandle
-  );
-
-#endif
-
diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.inf b/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
deleted file mode 100644
index 4731e77865..0000000000
--- a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
+++ /dev/null
@@ -1,53 +0,0 @@
-## @file
-#  NvVarsFileLib
-#
-#  This library saves and restores non-volatile variables in a
-#  file within a file system.
-#
-# Copyright (c) 2006 - 2019 Intel Corporation. All rights reserved. <BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
-  INF_VERSION                    = 0x00010005
-  BASE_NAME                      = NvVarsFileLib
-  FILE_GUID                      = 8ECD4CC0-1772-4583-8A74-83633A15FAA0
-  MODULE_TYPE                    = UEFI_DRIVER
-  VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = NvVarsFileLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-#  VALID_ARCHITECTURES           = IA32 X64 EBC
-#
-
-[Sources]
-  FsAccess.c
-  NvVarsFileLib.c
-
-[Packages]
-  MdePkg/MdePkg.dec
-  MdeModulePkg/MdeModulePkg.dec
-  ShellPkg/ShellPkg.dec
-  OvmfPkg/OvmfPkg.dec
-
-[LibraryClasses]
-  BaseLib
-  BaseMemoryLib
-  DebugLib
-  FileHandleLib
-  MemoryAllocationLib
-  SerializeVariablesLib
-
-[Protocols]
-  gEfiSimpleFileSystemProtocolGuid              ## CONSUMES
-
-[Guids]
-  gEfiFileInfoGuid
-
-[Depex]
-  gEfiVariableWriteArchProtocolGuid
-
diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c b/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c
deleted file mode 100644
index be619c838a..0000000000
--- a/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeVariablesLib.c
+++ /dev/null
@@ -1,869 +0,0 @@
-/** @file
-  Serialize Variables Library implementation
-
-  Copyright (c) 2004 - 2019 Intel Corporation. All rights reserved. <BR>
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-**/
-
-#include "SerializeVariablesLib.h"
-
-/**
-  Serialization format:
-
-  The SerializeVariablesLib interface does not specify a format
-  for the serialization of the variable data.  This library uses
-  a packed array of a non-uniformly sized data structure elements.
-
-  Each variable is stored (packed) as:
-    UINT32   VendorNameSize;  // Name size in bytes
-    CHAR16   VendorName[?];   // The variable unicode name including the
-                              // null terminating character.
-    EFI_GUID VendorGuid;      // The variable GUID
-    UINT32   DataSize;        // The size of variable data in bytes
-    UINT8    Data[?];         // The variable data
-
-**/
-
-
-/**
-  Unpacks the next variable from the buffer
-
-  @param[in]  Buffer - Buffer pointing to the next variable instance
-                On subsequent calls, the pointer should be incremented
-                by the returned SizeUsed value.
-  @param[in]  MaxSize - Max allowable size for the variable data
-                On subsequent calls, this should be decremented
-                by the returned SizeUsed value.
-  @param[out] Name - Variable name string (address in Buffer)
-  @param[out] NameSize - Size of Name in bytes
-  @param[out] Guid - GUID of variable (address in Buffer)
-  @param[out] Attributes - Attributes of variable
-  @param[out] Data - Buffer containing Data for variable (address in Buffer)
-  @param[out] DataSize - Size of Data in bytes
-  @param[out] SizeUsed - Total size used for this variable instance in Buffer
-
-  @return     EFI_STATUS based on the success or failure of the operation
-
-**/
-STATIC
-EFI_STATUS
-UnpackVariableFromBuffer (
-  IN  VOID     *Buffer,
-  IN  UINTN    MaxSize,
-  OUT CHAR16   **Name,
-  OUT UINT32   *NameSize,
-  OUT EFI_GUID **Guid,
-  OUT UINT32   *Attributes,
-  OUT UINT32   *DataSize,
-  OUT VOID     **Data,
-  OUT UINTN    *SizeUsed
-  )
-{
-  UINT8  *BytePtr;
-  UINTN  Offset;
-
-  BytePtr = (UINT8*)Buffer;
-  Offset = 0;
-
-  *NameSize = *(UINT32*) (BytePtr + Offset);
-  Offset = Offset + sizeof (UINT32);
-
-  if (Offset > MaxSize) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  *Name = (CHAR16*) (BytePtr + Offset);
-  Offset = Offset + *(UINT32*)BytePtr;
-  if (Offset > MaxSize) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  *Guid = (EFI_GUID*) (BytePtr + Offset);
-  Offset = Offset + sizeof (EFI_GUID);
-  if (Offset > MaxSize) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  *Attributes = *(UINT32*) (BytePtr + Offset);
-  Offset = Offset + sizeof (UINT32);
-  if (Offset > MaxSize) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  *DataSize = *(UINT32*) (BytePtr + Offset);
-  Offset = Offset + sizeof (UINT32);
-  if (Offset > MaxSize) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  *Data = (VOID*) (BytePtr + Offset);
-  Offset = Offset + *DataSize;
-  if (Offset > MaxSize) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  *SizeUsed = Offset;
-
-  return EFI_SUCCESS;
-}
-
-
-/**
-  Iterates through the variables in the buffer, and calls a callback
-  function for each variable found.
-
-  @param[in]  CallbackFunction - Function called for each variable instance
-  @param[in]  Context - Passed to each call of CallbackFunction
-  @param[in]  Buffer - Buffer containing serialized variables
-  @param[in]  MaxSize - Size of Buffer in bytes
-
-  @return     EFI_STATUS based on the success or failure of the operation
-
-**/
-STATIC
-EFI_STATUS
-IterateVariablesInBuffer (
-  IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK  CallbackFunction,
-  IN VOID                                       *CallbackContext,
-  IN VOID                                       *Buffer,
-  IN UINTN                                      MaxSize
-  )
-{
-  RETURN_STATUS Status;
-  UINTN         TotalSizeUsed;
-  UINTN         SizeUsed;
-
-  CHAR16        *Name;
-  UINT32        NameSize;
-  CHAR16        *AlignedName;
-  UINT32        AlignedNameMaxSize;
-  EFI_GUID      *Guid;
-  UINT32        Attributes;
-  UINT32        DataSize;
-  VOID          *Data;
-
-  SizeUsed = 0;
-  AlignedName = NULL;
-  AlignedNameMaxSize = 0;
-  Name = NULL;
-  Guid = NULL;
-  Attributes = 0;
-  DataSize = 0;
-  Data = NULL;
-
-  for (
-    Status = EFI_SUCCESS, TotalSizeUsed = 0;
-    !EFI_ERROR (Status) && (TotalSizeUsed < MaxSize);
-    ) {
-    Status = UnpackVariableFromBuffer (
-               (VOID*) ((UINT8*) Buffer + TotalSizeUsed),
-               (MaxSize - TotalSizeUsed),
-               &Name,
-               &NameSize,
-               &Guid,
-               &Attributes,
-               &DataSize,
-               &Data,
-               &SizeUsed
-               );
-    if (EFI_ERROR (Status)) {
-      return Status;
-    }
-
-    //
-    // We copy the name to a separately allocated buffer,
-    // to be sure it is 16-bit aligned.
-    //
-    if (NameSize > AlignedNameMaxSize) {
-      if (AlignedName != NULL) {
-        FreePool (AlignedName);
-      }
-      AlignedName = AllocatePool (NameSize);
-    }
-    if (AlignedName == NULL) {
-      return EFI_OUT_OF_RESOURCES;
-    }
-    CopyMem (AlignedName, Name, NameSize);
-
-    TotalSizeUsed = TotalSizeUsed + SizeUsed;
-
-    //
-    // Run the callback function
-    //
-    Status = (*CallbackFunction) (
-               CallbackContext,
-               AlignedName,
-               Guid,
-               Attributes,
-               DataSize,
-               Data
-               );
-
-  }
-
-  if (AlignedName != NULL) {
-    FreePool (AlignedName);
-  }
-
-  //
-  // Make sure the entire buffer was used, or else return an error
-  //
-  if (TotalSizeUsed != MaxSize) {
-    DEBUG ((
-      EFI_D_ERROR,
-      "Deserialize variables error: TotalSizeUsed(%Lu) != MaxSize(%Lu)\n",
-      (UINT64)TotalSizeUsed,
-      (UINT64)MaxSize
-      ));
-    return EFI_INVALID_PARAMETER;
-  }
-
-  return EFI_SUCCESS;
-}
-
-
-STATIC
-RETURN_STATUS
-EFIAPI
-IterateVariablesCallbackNop (
-  IN  VOID                         *Context,
-  IN  CHAR16                       *VariableName,
-  IN  EFI_GUID                     *VendorGuid,
-  IN  UINT32                       Attributes,
-  IN  UINTN                        DataSize,
-  IN  VOID                         *Data
-  )
-{
-  return RETURN_SUCCESS;
-}
-
-
-STATIC
-RETURN_STATUS
-EFIAPI
-IterateVariablesCallbackSetInInstance (
-  IN  VOID                         *Context,
-  IN  CHAR16                       *VariableName,
-  IN  EFI_GUID                     *VendorGuid,
-  IN  UINT32                       Attributes,
-  IN  UINTN                        DataSize,
-  IN  VOID                         *Data
-  )
-{
-  EFI_HANDLE  Instance;
-
-  Instance = (EFI_HANDLE) Context;
-
-  return SerializeVariablesAddVariable (
-           Instance,
-           VariableName,
-           VendorGuid,
-           Attributes,
-           DataSize,
-           Data
-           );
-}
-
-
-STATIC
-RETURN_STATUS
-EFIAPI
-IterateVariablesCallbackSetSystemVariable (
-  IN  VOID                         *Context,
-  IN  CHAR16                       *VariableName,
-  IN  EFI_GUID                     *VendorGuid,
-  IN  UINT32                       Attributes,
-  IN  UINTN                        DataSize,
-  IN  VOID                         *Data
-  )
-{
-  EFI_STATUS          Status;
-  STATIC CONST UINT32 AuthMask =
-                        EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS |
-                        EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS;
-
-  Status = gRT->SetVariable (
-             VariableName,
-             VendorGuid,
-             Attributes,
-             DataSize,
-             Data
-             );
-
-  if (Status == EFI_SECURITY_VIOLATION && (Attributes & AuthMask) != 0) {
-    DEBUG ((DEBUG_WARN, "%a: setting authenticated variable \"%s\" "
-            "failed with EFI_SECURITY_VIOLATION, ignoring\n", __FUNCTION__,
-            VariableName));
-    Status = EFI_SUCCESS;
-  } else if (Status == EFI_WRITE_PROTECTED) {
-    DEBUG ((DEBUG_WARN, "%a: setting ReadOnly variable \"%s\" "
-            "failed with EFI_WRITE_PROTECTED, ignoring\n", __FUNCTION__,
-            VariableName));
-    Status = EFI_SUCCESS;
-  }
-  return Status;
-}
-
-
-STATIC
-RETURN_STATUS
-EnsureExtraBufferSpace (
-  IN  SV_INSTANCE  *Instance,
-  IN  UINTN        Size
-  )
-{
-  VOID *NewBuffer;
-  UINTN NewSize;
-
-  NewSize = Instance->DataSize + Size;
-  if (NewSize <= Instance->BufferSize) {
-    return RETURN_SUCCESS;
-  }
-
-  //
-  // Double the required size to lessen the need to re-allocate in the future
-  //
-  NewSize = 2 * NewSize;
-
-  NewBuffer = AllocatePool (NewSize);
-  if (NewBuffer == NULL) {
-    return RETURN_OUT_OF_RESOURCES;
-  }
-
-  if (Instance->BufferPtr != NULL) {
-    CopyMem (NewBuffer, Instance->BufferPtr, Instance->DataSize);
-    FreePool (Instance->BufferPtr);
-  }
-
-  Instance->BufferPtr = NewBuffer;
-  Instance->BufferSize = NewSize;
-
-  return RETURN_SUCCESS;
-}
-
-
-STATIC
-VOID
-AppendToBuffer (
-  IN  SV_INSTANCE  *Instance,
-  IN  VOID         *Data,
-  IN  UINTN        Size
-  )
-{
-  UINTN NewSize;
-
-  ASSERT (Instance != NULL);
-  ASSERT (Data != NULL);
-
-  NewSize = Instance->DataSize + Size;
-  ASSERT ((Instance->DataSize + Size) <= Instance->BufferSize);
-
-  CopyMem (
-    (VOID*) (((UINT8*) (Instance->BufferPtr)) + Instance->DataSize),
-    Data,
-    Size
-    );
-
-  Instance->DataSize = NewSize;
-}
-
-
-/**
-  Creates a new variable serialization instance
-
-  @param[out]  Handle - Handle for a variable serialization instance
-
-  @retval      RETURN_SUCCESS - The variable serialization instance was
-                 successfully created.
-  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources to
-                 create the variable serialization instance.
-
-**/
-RETURN_STATUS
-EFIAPI
-SerializeVariablesNewInstance (
-  OUT EFI_HANDLE                      *Handle
-  )
-{
-  SV_INSTANCE  *New;
-
-  New = AllocateZeroPool (sizeof (*New));
-  if (New == NULL) {
-    return RETURN_OUT_OF_RESOURCES;
-  }
-
-  New->Signature = SV_SIGNATURE;
-
-  *Handle = (EFI_HANDLE) New;
-  return RETURN_SUCCESS;
-}
-
-
-/**
-  Free memory associated with a variable serialization instance
-
-  @param[in]  Handle - Handle for a variable serialization instance
-
-  @retval      RETURN_SUCCESS - The variable serialization instance was
-                 successfully freed.
-  @retval      RETURN_INVALID_PARAMETER - Handle was not a valid
-                 variable serialization instance.
-
-**/
-RETURN_STATUS
-EFIAPI
-SerializeVariablesFreeInstance (
-  IN EFI_HANDLE Handle
-  )
-{
-  SV_INSTANCE    *Instance;
-
-  Instance = SV_FROM_HANDLE (Handle);
-
-  if (Instance->Signature != SV_SIGNATURE) {
-    return RETURN_INVALID_PARAMETER;
-  }
-
-  Instance->Signature = 0;
-
-  if (Instance->BufferPtr != NULL) {
-    FreePool (Instance->BufferPtr);
-  }
-
-  FreePool (Instance);
-
-  return RETURN_SUCCESS;
-}
-
-
-/**
-  Creates a new variable serialization instance using the given
-  binary representation of the variables to fill the new instance
-
-  @param[out] Handle - Handle for a variable serialization instance
-  @param[in]  Buffer - A buffer with the serialized representation
-                of the variables.  Must be the same format as produced
-                by SerializeVariablesToBuffer.
-  @param[in]  Size - This is the size of the binary representation
-                of the variables.
-
-  @retval      RETURN_SUCCESS - The binary representation was successfully
-                 imported into a new variable serialization instance
-  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources to
-                 create the new variable serialization instance
-
-**/
-RETURN_STATUS
-EFIAPI
-SerializeVariablesNewInstanceFromBuffer (
-  OUT EFI_HANDLE                          *Handle,
-  IN  VOID                                *Buffer,
-  IN  UINTN                               Size
-  )
-{
-  RETURN_STATUS Status;
-
-  Status = SerializeVariablesNewInstance (Handle);
-  if (RETURN_ERROR (Status)) {
-    return Status;
-  }
-
-  Status = IterateVariablesInBuffer (
-             IterateVariablesCallbackNop,
-             NULL,
-             Buffer,
-             Size
-             );
-  if (RETURN_ERROR (Status)) {
-    SerializeVariablesFreeInstance (*Handle);
-    return Status;
-  }
-
-  Status = IterateVariablesInBuffer (
-             IterateVariablesCallbackSetInInstance,
-             (VOID*) *Handle,
-             Buffer,
-             Size
-             );
-  if (RETURN_ERROR (Status)) {
-    SerializeVariablesFreeInstance (*Handle);
-    return Status;
-  }
-
-  return Status;
-}
-
-
-/**
-  Iterates all variables found with RuntimeServices GetNextVariableName
-
-  @param[in]   CallbackFunction - Function called for each variable instance
-  @param[in]   Context - Passed to each call of CallbackFunction
-
-  @retval      RETURN_SUCCESS - All variables were iterated without the
-                 CallbackFunction returning an error
-  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources to
-                 iterate through the variables
-  @return      Any of RETURN_ERROR indicates an error reading the variable
-                 or an error was returned from CallbackFunction
-
-**/
-RETURN_STATUS
-EFIAPI
-SerializeVariablesIterateSystemVariables (
-  IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction,
-  IN VOID                                      *Context
-  )
-{
-  RETURN_STATUS               Status;
-  UINTN                       VariableNameBufferSize;
-  UINTN                       VariableNameSize;
-  CHAR16                      *VariableName;
-  EFI_GUID                    VendorGuid;
-  UINTN                       VariableDataBufferSize;
-  UINTN                       VariableDataSize;
-  VOID                        *VariableData;
-  UINT32                      VariableAttributes;
-  VOID                        *NewBuffer;
-
-  //
-  // Initialize the variable name and data buffer variables.
-  //
-  VariableNameBufferSize = sizeof (CHAR16);
-  VariableName = AllocateZeroPool (VariableNameBufferSize);
-
-  VariableDataBufferSize = 0;
-  VariableData = NULL;
-
-  for (;;) {
-    //
-    // Get the next variable name and guid
-    //
-    VariableNameSize = VariableNameBufferSize;
-    Status = gRT->GetNextVariableName (
-                    &VariableNameSize,
-                    VariableName,
-                    &VendorGuid
-                    );
-    if (Status == EFI_BUFFER_TOO_SMALL) {
-      //
-      // The currently allocated VariableName buffer is too small,
-      // so we allocate a larger buffer, and copy the old buffer
-      // to it.
-      //
-      NewBuffer = AllocatePool (VariableNameSize);
-      if (NewBuffer == NULL) {
-        Status = EFI_OUT_OF_RESOURCES;
-        break;
-      }
-      CopyMem (NewBuffer, VariableName, VariableNameBufferSize);
-      if (VariableName != NULL) {
-        FreePool (VariableName);
-      }
-      VariableName = NewBuffer;
-      VariableNameBufferSize = VariableNameSize;
-
-      //
-      // Try to get the next variable name again with the larger buffer.
-      //
-      Status = gRT->GetNextVariableName (
-                      &VariableNameSize,
-                      VariableName,
-                      &VendorGuid
-                      );
-    }
-
-    if (EFI_ERROR (Status)) {
-      if (Status == EFI_NOT_FOUND) {
-        Status = EFI_SUCCESS;
-      }
-      break;
-    }
-
-    //
-    // Get the variable data and attributes
-    //
-    VariableDataSize = VariableDataBufferSize;
-    Status = gRT->GetVariable (
-                    VariableName,
-                    &VendorGuid,
-                    &VariableAttributes,
-                    &VariableDataSize,
-                    VariableData
-                    );
-    if (Status == EFI_BUFFER_TOO_SMALL) {
-      //
-      // The currently allocated VariableData buffer is too small,
-      // so we allocate a larger buffer.
-      //
-      if (VariableDataBufferSize != 0) {
-        FreePool (VariableData);
-        VariableData = NULL;
-        VariableDataBufferSize = 0;
-      }
-      VariableData = AllocatePool (VariableDataSize);
-      if (VariableData == NULL) {
-        Status = EFI_OUT_OF_RESOURCES;
-        break;
-      }
-      VariableDataBufferSize = VariableDataSize;
-
-      //
-      // Try to read the variable again with the larger buffer.
-      //
-      Status = gRT->GetVariable (
-                      VariableName,
-                      &VendorGuid,
-                      &VariableAttributes,
-                      &VariableDataSize,
-                      VariableData
-                      );
-    }
-    if (EFI_ERROR (Status)) {
-      break;
-    }
-
-    //
-    // Run the callback function
-    //
-    Status = (*CallbackFunction) (
-               Context,
-               VariableName,
-               &VendorGuid,
-               VariableAttributes,
-               VariableDataSize,
-               VariableData
-               );
-    if (EFI_ERROR (Status)) {
-      break;
-    }
-
-  }
-
-  if (VariableName != NULL) {
-    FreePool (VariableName);
-  }
-
-  if (VariableData != NULL) {
-    FreePool (VariableData);
-  }
-
-  return Status;
-}
-
-
-/**
-  Iterates all variables found in the variable serialization instance
-
-  @param[in]   Handle - Handle for a variable serialization instance
-  @param[in]   CallbackFunction - Function called for each variable instance
-  @param[in]   Context - Passed to each call of CallbackFunction
-
-  @retval      RETURN_SUCCESS - All variables were iterated without the
-                 CallbackFunction returning an error
-  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources to
-                 iterate through the variables
-  @return      Any of RETURN_ERROR indicates an error reading the variable
-                 or an error was returned from CallbackFunction
-
-**/
-RETURN_STATUS
-EFIAPI
-SerializeVariablesIterateInstanceVariables (
-  IN EFI_HANDLE                                Handle,
-  IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction,
-  IN VOID                                      *Context
-  )
-{
-  SV_INSTANCE    *Instance;
-
-  Instance = SV_FROM_HANDLE (Handle);
-
-  if ((Instance->BufferPtr != NULL) && (Instance->DataSize != 0)) {
-    return IterateVariablesInBuffer (
-             CallbackFunction,
-             Context,
-             Instance->BufferPtr,
-             Instance->DataSize
-             );
-  } else {
-    return RETURN_SUCCESS;
-  }
-}
-
-
-/**
-  Sets all variables found in the variable serialization instance
-
-  @param[in]   Handle - Handle for a variable serialization instance
-
-  @retval      RETURN_SUCCESS - All variables were set successfully
-  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources to
-                 set all the variables
-  @return      Any of RETURN_ERROR indicates an error reading the variables
-                 or in attempting to set a variable
-
-**/
-RETURN_STATUS
-EFIAPI
-SerializeVariablesSetSerializedVariables (
-  IN EFI_HANDLE                       Handle
-  )
-{
-  return SerializeVariablesIterateInstanceVariables (
-           Handle,
-           IterateVariablesCallbackSetSystemVariable,
-           NULL
-           );
-}
-
-
-/**
-  Adds a variable to the variable serialization instance
-
-  @param[in] Handle - Handle for a variable serialization instance
-  @param[in] VariableName - Refer to RuntimeServices GetVariable
-  @param[in] VendorGuid - Refer to RuntimeServices GetVariable
-  @param[in] Attributes - Refer to RuntimeServices GetVariable
-  @param[in] DataSize - Refer to RuntimeServices GetVariable
-  @param[in] Data - Refer to RuntimeServices GetVariable
-
-  @retval      RETURN_SUCCESS - All variables were set successfully
-  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources to
-                 add the variable
-  @retval      RETURN_INVALID_PARAMETER - Handle was not a valid
-                 variable serialization instance or
-                 VariableName, VariableGuid or Data are NULL.
-
-**/
-RETURN_STATUS
-EFIAPI
-SerializeVariablesAddVariable (
-  IN EFI_HANDLE                   Handle,
-  IN CHAR16                       *VariableName,
-  IN EFI_GUID                     *VendorGuid,
-  IN UINT32                       Attributes,
-  IN UINTN                        DataSize,
-  IN VOID                         *Data
-  )
-{
-  RETURN_STATUS  Status;
-  SV_INSTANCE    *Instance;
-  UINT32         SerializedNameSize;
-  UINT32         SerializedDataSize;
-  UINTN          SerializedSize;
-
-  Instance = SV_FROM_HANDLE (Handle);
-
-  if ((Instance->Signature != SV_SIGNATURE) ||
-      (VariableName == NULL) || (VendorGuid == NULL) || (Data == NULL)) {
-  }
-
-  SerializedNameSize = (UINT32) StrSize (VariableName);
-
-  SerializedSize =
-    sizeof (SerializedNameSize) +
-    SerializedNameSize +
-    sizeof (*VendorGuid) +
-    sizeof (Attributes) +
-    sizeof (SerializedDataSize) +
-    DataSize;
-
-  Status = EnsureExtraBufferSpace (
-             Instance,
-             SerializedSize
-             );
-  if (RETURN_ERROR (Status)) {
-    return Status;
-  }
-
-  //
-  // Add name size (UINT32)
-  //
-  AppendToBuffer (Instance, (VOID*) &SerializedNameSize, sizeof (SerializedNameSize));
-
-  //
-  // Add variable unicode name string
-  //
-  AppendToBuffer (Instance, (VOID*) VariableName, SerializedNameSize);
-
-  //
-  // Add variable GUID
-  //
-  AppendToBuffer (Instance, (VOID*) VendorGuid, sizeof (*VendorGuid));
-
-  //
-  // Add variable attributes
-  //
-  AppendToBuffer (Instance, (VOID*) &Attributes, sizeof (Attributes));
-
-  //
-  // Add variable data size (UINT32)
-  //
-  SerializedDataSize = (UINT32) DataSize;
-  AppendToBuffer (Instance, (VOID*) &SerializedDataSize, sizeof (SerializedDataSize));
-
-  //
-  // Add variable data
-  //
-  AppendToBuffer (Instance, Data, DataSize);
-
-  return RETURN_SUCCESS;
-}
-
-
-/**
-  Serializes the variables known to this instance into the
-  provided buffer.
-
-  @param[in]     Handle - Handle for a variable serialization instance
-  @param[out]    Buffer - A buffer to store the binary representation
-                   of the variables.
-  @param[in,out] Size - On input this is the size of the buffer.
-                   On output this is the size of the binary representation
-                   of the variables.
-
-  @retval      RETURN_SUCCESS - The binary representation was successfully
-                 completed and returned in the buffer.
-  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources to
-                 save the variables to the buffer.
-  @retval      RETURN_INVALID_PARAMETER - Handle was not a valid
-                 variable serialization instance or
-                 Size or Buffer were NULL.
-  @retval      RETURN_BUFFER_TOO_SMALL - The Buffer size as indicated by
-                 the Size parameter was too small for the serialized
-                 variable data.  Size is returned with the required size.
-
-**/
-RETURN_STATUS
-EFIAPI
-SerializeVariablesToBuffer (
-  IN     EFI_HANDLE                       Handle,
-  OUT    VOID                             *Buffer,
-  IN OUT UINTN                            *Size
-  )
-{
-  SV_INSTANCE    *Instance;
-
-  Instance = SV_FROM_HANDLE (Handle);
-
-  if (Size == NULL) {
-    return RETURN_INVALID_PARAMETER;
-  }
-
-  if (*Size < Instance->DataSize) {
-    *Size = Instance->DataSize;
-    return RETURN_BUFFER_TOO_SMALL;
-  }
-
-  if (Buffer == NULL) {
-    return RETURN_INVALID_PARAMETER;
-  }
-
-  *Size = Instance->DataSize;
-  CopyMem (Buffer, Instance->BufferPtr, Instance->DataSize);
-
-  return RETURN_SUCCESS;
-}
-
diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeVariablesLib.h b/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeVariablesLib.h
deleted file mode 100644
index 9b4c2a629a..0000000000
--- a/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeVariablesLib.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/** @file
-  Serialize Variables Library implementation
-
-  Copyright (c) 2009 - 2019 Intel Corporation. All rights reserved. <BR>
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-**/
-
-#ifndef __SERIALIZE_VARIABLES_LIB_INSTANCE__
-#define __SERIALIZE_VARIABLES_LIB_INSTANCE__
-
-#include <Uefi.h>
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/SerializeVariablesLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-
-#define SV_FROM_HANDLE(a)       CR (a, SV_INSTANCE, Signature, SV_SIGNATURE)
-#define SV_SIGNATURE            SIGNATURE_32 ('S', 'V', 'A', 'R')
-
-typedef struct {
-  UINT32                              Signature;
-  VOID                                *BufferPtr;
-  UINTN                               BufferSize;
-  UINTN                               DataSize;
-} SV_INSTANCE;
-
-#endif
-
diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf b/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf
deleted file mode 100644
index 08c561f586..0000000000
--- a/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf
+++ /dev/null
@@ -1,36 +0,0 @@
-## @file
-#  Serialize Variables Library implementation
-#
-#  This library serializes and deserializes UEFI variables
-#
-# Copyright (c) 2006 - 2019 Intel Corporation. All rights reserved. <BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
-  INF_VERSION                    = 0x00010005
-  BASE_NAME                      = DxeSerializeVariablesLib
-  FILE_GUID                      = 266A1434-6B22-441F-A8D2-D54AA8FDF95C
-  MODULE_TYPE                    = UEFI_DRIVER
-  VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = SerializeVariablesLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER
-
-[Sources]
-  SerializeVariablesLib.c
-
-[Packages]
-  MdePkg/MdePkg.dec
-  MdeModulePkg/MdeModulePkg.dec
-  ShellPkg/ShellPkg.dec
-  SimicsOpenBoardPkg/OpenBoardPkg.dec
-
-[LibraryClasses]
-  BaseLib
-  BaseMemoryLib
-  DebugLib
-  MemoryAllocationLib
-  UefiBootServicesTableLib
-  UefiRuntimeServicesTableLib
-
diff --git a/Platform/Intel/SimicsOpenBoardPkg/OpenBoardPkg.dec b/Platform/Intel/SimicsOpenBoardPkg/OpenBoardPkg.dec
index e8aefdd893..c4e24f1e0c 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/OpenBoardPkg.dec
+++ b/Platform/Intel/SimicsOpenBoardPkg/OpenBoardPkg.dec
@@ -48,9 +48,6 @@
 
 [PcdsDynamic, PcdsDynamicEx]
 
-  # TODO: investigate whether next two Pcds are needed
-  gSimicsOpenBoardPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|0x28
-  gSimicsOpenBoardPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable|FALSE|BOOLEAN|0x10
   gSimicsOpenBoardPkgTokenSpaceGuid.PcdSimicsX58HostBridgePciDevId|0|UINT16|0x1b
 
   ## The IO port aperture shared by all PCI root bridges.
-- 
2.39.1.windows.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3/6] SimicsOpenBoardPkg: Enable serial terminal
  2023-05-24 12:28 [PATCH 0/6] Fine tune SimicsOpenBoardPkg Ni, Ray
  2023-05-24 12:28 ` [PATCH 1/6] SimicsOpenBoardPkg: Remove un-used PlatformBootManagerLib Ni, Ray
  2023-05-24 12:28 ` [PATCH 2/6] SimicsOpenBoardPkg: Remove logic that loads variable from disk file Ni, Ray
@ 2023-05-24 12:28 ` Ni, Ray
  2023-05-24 12:28 ` [PATCH 4/6] MinPlatform/build_bios.py: Support performance enabled build Ni, Ray
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Ni, Ray @ 2023-05-24 12:28 UTC (permalink / raw)
  To: devel; +Cc: Nate DeSimone, Zhiguang Liu

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Zhiguang Liu <zhiguang@liu@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
---
 .../BoardX58Ich10/OpenBoardPkg.fdf            |  1 -
 .../BoardX58Ich10/OpenBoardPkgPcd.dsc         |  1 +
 .../Library/BoardBdsHookLib/BoardBdsHookLib.c | 56 ++++++++-----------
 3 files changed, 24 insertions(+), 34 deletions(-)

diff --git a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
index 6ecff76362..aa44c01784 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
+++ b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
@@ -198,7 +198,6 @@ INF  UefiCpuPkg/CpuDxe/CpuDxe.inf
 INF  MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf
 INF  MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf
 INF  UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf
-INF  MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
 INF  MdeModulePkg/Universal/PrintDxe/PrintDxe.inf
 INF  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
 INF  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
diff --git a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc
index 732d95e44f..b6672d1a78 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc
+++ b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc
@@ -69,6 +69,7 @@
   ######################################
   gNetworkFeaturePkgTokenSpaceGuid.PcdNetworkFeatureEnable|TRUE
   gSmbiosFeaturePkgTokenSpaceGuid.PcdSmbiosFeatureEnable|TRUE
+  gMinPlatformPkgTokenSpaceGuid.PcdSerialTerminalEnable|TRUE
 
 [PcdsFeatureFlag.X64]
   ######################################
diff --git a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
index 3c6385c12f..238513f666 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
+++ b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
@@ -837,45 +837,35 @@ PlatformInitializeConsole (
   )
 {
   UINTN                              Index;
-  EFI_DEVICE_PATH_PROTOCOL           *VarConout;
-  EFI_DEVICE_PATH_PROTOCOL           *VarConin;
 
   //
-  // Connect RootBridge
+  // Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut
+  // Note: Why perform the ConIn/ConOut/ErrOut variables update without checking
+  //          whether "ConIn", "ConOut" or "ErrOut" is present in the variable store?
+  //       Because SerialPortTerminalLib.constructor() adds the serial terminal device
+  //          to "ConIn", "ConOut" and "ErrOut" variables always, checking presence of
+  //          the three variables will lead to the following update logic never runs.
   //
-  GetEfiGlobalVariable2 (EFI_CON_OUT_VARIABLE_NAME, (VOID **) &VarConout, NULL);
-  GetEfiGlobalVariable2 (EFI_CON_IN_VARIABLE_NAME, (VOID **) &VarConin, NULL);
-
-  if (VarConout == NULL || VarConin == NULL) {
-    //
-    // Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut
-    //
-    DetectAndPreparePlatformPciDevicePaths (FALSE);
-    DetectAndPreparePlatformPciDevicePaths(TRUE);
+  DetectAndPreparePlatformPciDevicePaths (FALSE);
+  DetectAndPreparePlatformPciDevicePaths(TRUE);
+  //
+  // Have chance to connect the platform default console,
+  // the platform default console is the minimue device group
+  // the platform should support
+  //
+  for (Index = 0; PlatformConsole[Index].DevicePath != NULL; ++Index) {
     //
-    // Have chance to connect the platform default console,
-    // the platform default console is the minimue device group
-    // the platform should support
+    // Update the console variable with the connect type
     //
-    for (Index = 0; PlatformConsole[Index].DevicePath != NULL; ++Index) {
-      //
-      // Update the console variable with the connect type
-      //
-      if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {
-        EfiBootManagerUpdateConsoleVariable (ConIn, PlatformConsole[Index].DevicePath, NULL);
-      }
-      if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {
-        EfiBootManagerUpdateConsoleVariable (ConOut, PlatformConsole[Index].DevicePath, NULL);
-      }
-      if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
-        EfiBootManagerUpdateConsoleVariable (ErrOut, PlatformConsole[Index].DevicePath, NULL);
-      }
+    if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {
+      EfiBootManagerUpdateConsoleVariable (ConIn, PlatformConsole[Index].DevicePath, NULL);
+    }
+    if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {
+      EfiBootManagerUpdateConsoleVariable (ConOut, PlatformConsole[Index].DevicePath, NULL);
+    }
+    if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
+      EfiBootManagerUpdateConsoleVariable (ErrOut, PlatformConsole[Index].DevicePath, NULL);
     }
-  } else {
-    //
-    // Only detect VGA device and add them to ConOut
-    //
-    DetectAndPreparePlatformPciDevicePaths (TRUE);
   }
 }
 
-- 
2.39.1.windows.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 4/6] MinPlatform/build_bios.py: Support performance enabled build
  2023-05-24 12:28 [PATCH 0/6] Fine tune SimicsOpenBoardPkg Ni, Ray
                   ` (2 preceding siblings ...)
  2023-05-24 12:28 ` [PATCH 3/6] SimicsOpenBoardPkg: Enable serial terminal Ni, Ray
@ 2023-05-24 12:28 ` Ni, Ray
  2023-05-24 23:07   ` Chiu, Chasel
  2023-05-24 12:28 ` [PATCH 5/6] SimicsOpenBoardPkg: Add "dp" command in performance build Ni, Ray
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 15+ messages in thread
From: Ni, Ray @ 2023-05-24 12:28 UTC (permalink / raw)
  To: devel; +Cc: Chasel Chiu, Nate DeSimone, Isaac Oram, Liming Gao, Eric Dong

build_bios.py supports caller to pass in "--performance" flag but the
script implemnetation just ignores this flag.

The patch adds the missing logic to invoke build.py with
"--pcd gMinPlatformPkgTokenSpaceGuid.PcdPerformanceEnable=True"
when "--performance" is supplied.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Eric Dong <eric.dong@intel.com>
---
 Platform/Intel/build_bios.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Platform/Intel/build_bios.py b/Platform/Intel/build_bios.py
index da4097d5db..9c95cfff76 100755
--- a/Platform/Intel/build_bios.py
+++ b/Platform/Intel/build_bios.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env python3
 #
 # @ build_bios.py
 # Builds BIOS using configuration files and dynamically
@@ -421,6 +421,10 @@ def build(config):
         command.append("--pcd")
         command.append("gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelection=1")
 
+    if config.get("PERFORMANCE_BUILD", "FALSE") == "TRUE":
+        command.append("--pcd")
+        command.append("gMinPlatformPkgTokenSpaceGuid.PcdPerformanceEnable=True")
+
     shell = True
     if os.name == "posix":
         shell = False
-- 
2.39.1.windows.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 5/6] SimicsOpenBoardPkg: Add "dp" command in performance build
  2023-05-24 12:28 [PATCH 0/6] Fine tune SimicsOpenBoardPkg Ni, Ray
                   ` (3 preceding siblings ...)
  2023-05-24 12:28 ` [PATCH 4/6] MinPlatform/build_bios.py: Support performance enabled build Ni, Ray
@ 2023-05-24 12:28 ` Ni, Ray
  2023-05-24 12:28 ` [PATCH 6/6] SimicsOpenBoardPkg: Disable DriverBindingSupport perf logging Ni, Ray
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Ni, Ray @ 2023-05-24 12:28 UTC (permalink / raw)
  To: devel; +Cc: Nate DeSimone, Zhiguang Liu

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Zhiguang Liu <zhiguang@liu@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
---
 .../SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc     | 8 ++++++++
 .../SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf     | 3 +++
 2 files changed, 11 insertions(+)

diff --git a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
index 4e8991dbdf..3257156d23 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
+++ b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
@@ -265,6 +265,14 @@
       ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
   }
 
+
+!if gMinPlatformPkgTokenSpaceGuid.PcdPerformanceEnable == TRUE
+  ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf {
+    <PcdsFixedAtBuild>
+      gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
+  }
+!endif
+
   #######################################
   # Silicon Initialization Package
   #######################################
diff --git a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
index aa44c01784..ceace433a6 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
+++ b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
@@ -227,6 +227,9 @@ FILE FREEFORM = 7BB28B99-61BB-11D5-9A5D-0090273FC14D {
 }
 
 INF  ShellPkg/Application/Shell/Shell.inf
+!if gMinPlatformPkgTokenSpaceGuid.PcdPerformanceEnable == TRUE
+INF  ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf
+!endif
 
 #
 # Network modules
-- 
2.39.1.windows.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 6/6] SimicsOpenBoardPkg: Disable DriverBindingSupport perf logging
  2023-05-24 12:28 [PATCH 0/6] Fine tune SimicsOpenBoardPkg Ni, Ray
                   ` (4 preceding siblings ...)
  2023-05-24 12:28 ` [PATCH 5/6] SimicsOpenBoardPkg: Add "dp" command in performance build Ni, Ray
@ 2023-05-24 12:28 ` Ni, Ray
       [not found] ` <17621420EF808DC9.12947@groups.io>
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Ni, Ray @ 2023-05-24 12:28 UTC (permalink / raw)
  To: devel; +Cc: Nate DeSimone, Zhiguang Liu

DriverBindingSupport() is called lots of time during post.
If it's also included in the perf logging, it's very easy to use all
the FPDT table memory pre-allocated at EndOfDxe because the
driver binding connect process happens after EndOfDxe.

PcdExtFpdtBootRecordPadSize was added for holding the
perf-logging records after EndOfDxe. But the DriverBindingSupport
records are just too many. For example, SimicsOpenBoardPkg has
to set this PCD to almost 100x bigger than the default value in order
to hold all the perf-logging records.

Platform developers are usually not aware of missing some records
after EndOfDxe because those records are all about driverbinding
support/start/stop. But if we add more perf-logging inside SMM,
those SMM records will be missed in the final FPDT table because
DxeCorePerformanceLib collects those SMM records at ReadyToBoot
event. Since the FPDT cannot hold all driverbinding records, it
definitely cannot hold those SMM records as well.

So in order to hold all SMM perf loggings, either platform should
set PcdExtFpdtBootRecordPadSize to a large enough value, or
as what this patch does, to disable the driverbinding support
perf-logging.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Zhiguang Liu <zhiguang@liu@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
---
 .../BoardX58Ich10/OpenBoardPkgPcd.dsc                 | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc
index b6672d1a78..6b969ab1f5 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc
+++ b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.dsc
@@ -132,7 +132,16 @@
   gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
   gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask|0x0
 !if gMinPlatformPkgTokenSpaceGuid.PcdPerformanceEnable == TRUE
-  gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask|0x1
+  #  BIT0 - Enable Performance Measurement.<BR>
+  #  BIT1 - Disable Start Image Logging.<BR>
+  #  BIT2 - Disable Load Image logging.<BR>
+  #  BIT3 - Disable Binding Support logging.<BR>
+  #  BIT4 - Disable Binding Start logging.<BR>
+  #  BIT5 - Disable Binding Stop logging.<BR>
+  #  BIT6 - Disable all other general Perfs.<BR>
+  #  BIT1-BIT6 are evaluated when BIT0 is set.<BR>
+  #  Enable performance measurement but disable driver binding support logging.
+  gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask|0x09
 !endif
 !if $(TARGET) == "RELEASE"
   gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x03
-- 
2.39.1.windows.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 4/6] MinPlatform/build_bios.py: Support performance enabled build
  2023-05-24 12:28 ` [PATCH 4/6] MinPlatform/build_bios.py: Support performance enabled build Ni, Ray
@ 2023-05-24 23:07   ` Chiu, Chasel
  2023-05-25  0:44     ` Ni, Ray
  0 siblings, 1 reply; 15+ messages in thread
From: Chiu, Chasel @ 2023-05-24 23:07 UTC (permalink / raw)
  To: Ni, Ray, devel@edk2.groups.io
  Cc: Desimone, Nathaniel L, Oram, Isaac W, Gao, Liming, Dong, Eric


Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>

Thanks,
Chasel



> -----Original Message-----
> From: Ni, Ray <ray.ni@intel.com>
> Sent: Wednesday, May 24, 2023 5:29 AM
> To: devel@edk2.groups.io
> Cc: Chiu, Chasel <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>; Oram, Isaac W <isaac.w.oram@intel.com>;
> Gao, Liming <gaoliming@byosoft.com.cn>; Dong, Eric <eric.dong@intel.com>
> Subject: [PATCH 4/6] MinPlatform/build_bios.py: Support performance enabled
> build
> 
> build_bios.py supports caller to pass in "--performance" flag but the script
> implemnetation just ignores this flag.
> 
> The patch adds the missing logic to invoke build.py with "--pcd
> gMinPlatformPkgTokenSpaceGuid.PcdPerformanceEnable=True"
> when "--performance" is supplied.
> 
> Signed-off-by: Ray Ni <ray.ni@intel.com>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Isaac Oram <isaac.w.oram@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Eric Dong <eric.dong@intel.com>
> ---
>  Platform/Intel/build_bios.py | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/Platform/Intel/build_bios.py b/Platform/Intel/build_bios.py index
> da4097d5db..9c95cfff76 100755
> --- a/Platform/Intel/build_bios.py
> +++ b/Platform/Intel/build_bios.py
> @@ -1,4 +1,4 @@
> -#!/usr/bin/env python3
> +#!/usr/bin/env python3 # # @ build_bios.py # Builds BIOS using configuration
> files and dynamically@@ -421,6 +421,10 @@ def build(config):
>          command.append("--pcd")
> command.append("gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelection=1
> ") +    if config.get("PERFORMANCE_BUILD", "FALSE") == "TRUE":+
> command.append("--pcd")+
> command.append("gMinPlatformPkgTokenSpaceGuid.PcdPerformanceEnable=T
> rue")+     shell = True     if os.name == "posix":         shell = False--
> 2.39.1.windows.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 4/6] MinPlatform/build_bios.py: Support performance enabled build
  2023-05-24 23:07   ` Chiu, Chasel
@ 2023-05-25  0:44     ` Ni, Ray
  0 siblings, 0 replies; 15+ messages in thread
From: Ni, Ray @ 2023-05-25  0:44 UTC (permalink / raw)
  To: Chiu, Chasel, devel@edk2.groups.io
  Cc: Desimone, Nathaniel L, Oram, Isaac W, Gao, Liming, Dong, Eric

Thank you!

> -----Original Message-----
> From: Chiu, Chasel <chasel.chiu@intel.com>
> Sent: Thursday, May 25, 2023 7:07 AM
> To: Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io
> Cc: Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Oram, Isaac W
> <isaac.w.oram@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; Dong,
> Eric <eric.dong@intel.com>
> Subject: RE: [PATCH 4/6] MinPlatform/build_bios.py: Support performance
> enabled build
> 
> 
> Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
> 
> Thanks,
> Chasel
> 
> 
> 
> > -----Original Message-----
> > From: Ni, Ray <ray.ni@intel.com>
> > Sent: Wednesday, May 24, 2023 5:29 AM
> > To: devel@edk2.groups.io
> > Cc: Chiu, Chasel <chasel.chiu@intel.com>; Desimone, Nathaniel L
> > <nathaniel.l.desimone@intel.com>; Oram, Isaac W
> <isaac.w.oram@intel.com>;
> > Gao, Liming <gaoliming@byosoft.com.cn>; Dong, Eric
> <eric.dong@intel.com>
> > Subject: [PATCH 4/6] MinPlatform/build_bios.py: Support performance
> enabled
> > build
> >
> > build_bios.py supports caller to pass in "--performance" flag but the script
> > implemnetation just ignores this flag.
> >
> > The patch adds the missing logic to invoke build.py with "--pcd
> > gMinPlatformPkgTokenSpaceGuid.PcdPerformanceEnable=True"
> > when "--performance" is supplied.
> >
> > Signed-off-by: Ray Ni <ray.ni@intel.com>
> > Cc: Chasel Chiu <chasel.chiu@intel.com>
> > Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> > Cc: Isaac Oram <isaac.w.oram@intel.com>
> > Cc: Liming Gao <gaoliming@byosoft.com.cn>
> > Cc: Eric Dong <eric.dong@intel.com>
> > ---
> >  Platform/Intel/build_bios.py | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/Platform/Intel/build_bios.py b/Platform/Intel/build_bios.py index
> > da4097d5db..9c95cfff76 100755
> > --- a/Platform/Intel/build_bios.py
> > +++ b/Platform/Intel/build_bios.py
> > @@ -1,4 +1,4 @@
> > -#!/usr/bin/env python3
> > +#!/usr/bin/env python3 # # @ build_bios.py # Builds BIOS using
> configuration
> > files and dynamically@@ -421,6 +421,10 @@ def build(config):
> >          command.append("--pcd")
> >
> command.append("gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelectio
> n=1
> > ") +    if config.get("PERFORMANCE_BUILD", "FALSE") == "TRUE":+
> > command.append("--pcd")+
> >
> command.append("gMinPlatformPkgTokenSpaceGuid.PcdPerformanceEnable
> =T
> > rue")+     shell = True     if os.name == "posix":         shell = False--
> > 2.39.1.windows.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [edk2-devel] [PATCH 1/6] SimicsOpenBoardPkg: Remove un-used PlatformBootManagerLib
       [not found] ` <17621420EF808DC9.12947@groups.io>
@ 2023-05-25  2:10   ` Ni, Ray
  0 siblings, 0 replies; 15+ messages in thread
From: Ni, Ray @ 2023-05-25  2:10 UTC (permalink / raw)
  To: devel@edk2.groups.io, Ni, Ray, Liu, Zhiguang
  Cc: Desimone, Nathaniel L, Kinney, Michael D

Sending to correct address of Zhiguang.

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Ni, Ray
> Sent: Wednesday, May 24, 2023 8:29 PM
> To: devel@edk2.groups.io
> Cc: Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Zhiguang Liu
> <zhiguang@liu@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: [edk2-devel] [PATCH 1/6] SimicsOpenBoardPkg: Remove un-used
> PlatformBootManagerLib
> 
> Signed-off-by: Ray Ni <ray.ni@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Zhiguang Liu <zhiguang@liu@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> ---
>  .../PlatformBootManagerLib/BdsPlatform.c      | 1532 -----------------
>  .../PlatformBootManagerLib/BdsPlatform.h      |  172 --
>  .../PlatformBootManagerLib.inf                |   72 -
>  .../PlatformBootManagerLib/PlatformData.c     |   35 -
>  4 files changed, 1811 deletions(-)
>  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/BdsPl
> atform.c
>  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/BdsPl
> atform.h
>  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/Platfo
> rmBootManagerLib.inf
>  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/Platfo
> rmData.c
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/Bds
> Platform.c
> b/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/Bds
> Platform.c
> deleted file mode 100644
> index 2f9c6aaa85..0000000000
> ---
> a/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/Bds
> Platform.c
> +++ /dev/null
> @@ -1,1532 +0,0 @@
> -/** @file
> 
> -  Platform BDS customizations.
> 
> -
> 
> -  Copyright (c) 2004 - 2019 Intel Corporation. All rights reserved. <BR>
> 
> -
> 
> -  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> -**/
> 
> -
> 
> -#include "BdsPlatform.h"
> 
> -#include <Guid/RootBridgesConnectedEventGroup.h>
> 
> -#include <Protocol/FirmwareVolume2.h>
> 
> -
> 
> -#define LEGACY_8259_MASK_REGISTER_MASTER                  0x21
> 
> -#define LEGACY_8259_MASK_REGISTER_SLAVE                   0xA1
> 
> -#define LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_MASTER  0x4D0
> 
> -#define LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_SLAVE   0x4D1
> 
> -
> 
> -//
> 
> -// Global data
> 
> -//
> 
> -
> 
> -VOID          *mEfiDevPathNotifyReg;
> 
> -EFI_EVENT     mEfiDevPathEvent;
> 
> -VOID          *mEmuVariableEventReg;
> 
> -EFI_EVENT     mEmuVariableEvent;
> 
> -BOOLEAN       mDetectVgaOnly;
> 
> -UINT16        mHostBridgeDevId;
> 
> -
> 
> -//
> 
> -// Table of host IRQs matching PCI IRQs A-D
> 
> -// (for configuring PCI Interrupt Line register)
> 
> -//
> 
> -CONST UINT8 PciHostIrqs[] = {
> 
> -  0x0a, 0x0a, 0x0b, 0x0b
> 
> -};
> 
> -
> 
> -//
> 
> -// Type definitions
> 
> -//
> 
> -
> 
> -typedef
> 
> -EFI_STATUS
> 
> -(EFIAPI *PROTOCOL_INSTANCE_CALLBACK)(
> 
> -  IN EFI_HANDLE           Handle,
> 
> -  IN VOID                 *Instance,
> 
> -  IN VOID                 *Context
> 
> -  );
> 
> -
> 
> -/**
> 
> -  @param[in]  Handle - Handle of PCI device instance
> 
> -  @param[in]  PciIo - PCI IO protocol instance
> 
> -  @param[in]  Pci - PCI Header register block
> 
> -**/
> 
> -typedef
> 
> -EFI_STATUS
> 
> -(EFIAPI *VISIT_PCI_INSTANCE_CALLBACK)(
> 
> -  IN EFI_HANDLE           Handle,
> 
> -  IN EFI_PCI_IO_PROTOCOL  *PciIo,
> 
> -  IN PCI_TYPE00           *Pci
> 
> -  );
> 
> -
> 
> -
> 
> -//
> 
> -// Function prototypes
> 
> -//
> 
> -
> 
> -EFI_STATUS
> 
> -VisitAllInstancesOfProtocol (
> 
> -  IN EFI_GUID                    *Id,
> 
> -  IN PROTOCOL_INSTANCE_CALLBACK  CallBackFunction,
> 
> -  IN VOID                        *Context
> 
> -  );
> 
> -
> 
> -EFI_STATUS
> 
> -VisitAllPciInstancesOfProtocol (
> 
> -  IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
> 
> -  );
> 
> -
> 
> -VOID
> 
> -InstallDevicePathCallback (
> 
> -  VOID
> 
> -  );
> 
> -
> 
> -VOID
> 
> -PlatformRegisterFvBootOption (
> 
> -  EFI_GUID                         *FileGuid,
> 
> -  CHAR16                           *Description,
> 
> -  UINT32                           Attributes
> 
> -  )
> 
> -{
> 
> -  EFI_STATUS                        Status;
> 
> -  INTN                              OptionIndex;
> 
> -  EFI_BOOT_MANAGER_LOAD_OPTION      NewOption;
> 
> -  EFI_BOOT_MANAGER_LOAD_OPTION      *BootOptions;
> 
> -  UINTN                             BootOptionCount;
> 
> -  MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
> 
> -  EFI_LOADED_IMAGE_PROTOCOL         *LoadedImage;
> 
> -  EFI_DEVICE_PATH_PROTOCOL          *DevicePath;
> 
> -
> 
> -  Status = gBS->HandleProtocol (
> 
> -                  gImageHandle,
> 
> -                  &gEfiLoadedImageProtocolGuid,
> 
> -                  (VOID **) &LoadedImage
> 
> -                  );
> 
> -  ASSERT_EFI_ERROR (Status);
> 
> -
> 
> -  EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
> 
> -  DevicePath = DevicePathFromHandle (LoadedImage->DeviceHandle);
> 
> -  ASSERT (DevicePath != NULL);
> 
> -  DevicePath = AppendDevicePathNode (
> 
> -                 DevicePath,
> 
> -                 (EFI_DEVICE_PATH_PROTOCOL *) &FileNode
> 
> -                 );
> 
> -  ASSERT (DevicePath != NULL);
> 
> -
> 
> -  Status = EfiBootManagerInitializeLoadOption (
> 
> -             &NewOption,
> 
> -             LoadOptionNumberUnassigned,
> 
> -             LoadOptionTypeBoot,
> 
> -             Attributes,
> 
> -             Description,
> 
> -             DevicePath,
> 
> -             NULL,
> 
> -             0
> 
> -             );
> 
> -  ASSERT_EFI_ERROR (Status);
> 
> -  FreePool (DevicePath);
> 
> -
> 
> -  BootOptions = EfiBootManagerGetLoadOptions (
> 
> -                  &BootOptionCount, LoadOptionTypeBoot
> 
> -                  );
> 
> -
> 
> -  OptionIndex = EfiBootManagerFindLoadOption (
> 
> -                  &NewOption, BootOptions, BootOptionCount
> 
> -                  );
> 
> -
> 
> -  if (OptionIndex == -1) {
> 
> -    Status = EfiBootManagerAddLoadOptionVariable (&NewOption,
> MAX_UINTN);
> 
> -    ASSERT_EFI_ERROR (Status);
> 
> -  }
> 
> -  EfiBootManagerFreeLoadOption (&NewOption);
> 
> -  EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
> 
> -}
> 
> -
> 
> -/**
> 
> -  Remove all MemoryMapped(...)/FvFile(...) and Fv(...)/FvFile(...) boot
> options
> 
> -  whose device paths do not resolve exactly to an FvFile in the system.
> 
> -
> 
> -  This removes any boot options that point to binaries built into the firmware
> 
> -  and have become stale due to any of the following:
> 
> -  - DXEFV's base address or size changed (historical),
> 
> -  - DXEFV's FvNameGuid changed,
> 
> -  - the FILE_GUID of the pointed-to binary changed,
> 
> -  - the referenced binary is no longer built into the firmware.
> 
> -
> 
> -  EfiBootManagerFindLoadOption() used in PlatformRegisterFvBootOption()
> only
> 
> -  avoids exact duplicates.
> 
> -**/
> 
> -VOID
> 
> -RemoveStaleFvFileOptions (
> 
> -  VOID
> 
> -  )
> 
> -{
> 
> -  EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
> 
> -  UINTN                        BootOptionCount;
> 
> -  UINTN                        Index;
> 
> -
> 
> -  BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount,
> 
> -                  LoadOptionTypeBoot);
> 
> -
> 
> -  for (Index = 0; Index < BootOptionCount; ++Index) {
> 
> -    EFI_DEVICE_PATH_PROTOCOL *Node1, *Node2, *SearchNode;
> 
> -    EFI_STATUS               Status;
> 
> -    EFI_HANDLE               FvHandle;
> 
> -
> 
> -    //
> 
> -    // If the device path starts with neither MemoryMapped(...) nor Fv(...),
> 
> -    // then keep the boot option.
> 
> -    //
> 
> -    Node1 = BootOptions[Index].FilePath;
> 
> -    if (!(DevicePathType (Node1) == HARDWARE_DEVICE_PATH &&
> 
> -          DevicePathSubType (Node1) == HW_MEMMAP_DP) &&
> 
> -        !(DevicePathType (Node1) == MEDIA_DEVICE_PATH &&
> 
> -          DevicePathSubType (Node1) == MEDIA_PIWG_FW_VOL_DP)) {
> 
> -      continue;
> 
> -    }
> 
> -
> 
> -    //
> 
> -    // If the second device path node is not FvFile(...), then keep the boot
> 
> -    // option.
> 
> -    //
> 
> -    Node2 = NextDevicePathNode (Node1);
> 
> -    if (DevicePathType (Node2) != MEDIA_DEVICE_PATH ||
> 
> -        DevicePathSubType (Node2) != MEDIA_PIWG_FW_FILE_DP) {
> 
> -      continue;
> 
> -    }
> 
> -
> 
> -    //
> 
> -    // Locate the Firmware Volume2 protocol instance that is denoted by the
> 
> -    // boot option. If this lookup fails (i.e., the boot option references a
> 
> -    // firmware volume that doesn't exist), then we'll proceed to delete the
> 
> -    // boot option.
> 
> -    //
> 
> -    SearchNode = Node1;
> 
> -    Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid,
> 
> -                    &SearchNode, &FvHandle);
> 
> -
> 
> -    if (!EFI_ERROR (Status)) {
> 
> -      //
> 
> -      // The firmware volume was found; now let's see if it contains the FvFile
> 
> -      // identified by GUID.
> 
> -      //
> 
> -      EFI_FIRMWARE_VOLUME2_PROTOCOL     *FvProtocol;
> 
> -      MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFileNode;
> 
> -      UINTN                             BufferSize;
> 
> -      EFI_FV_FILETYPE                   FoundType;
> 
> -      EFI_FV_FILE_ATTRIBUTES            FileAttributes;
> 
> -      UINT32                            AuthenticationStatus;
> 
> -
> 
> -      Status = gBS->HandleProtocol (FvHandle,
> &gEfiFirmwareVolume2ProtocolGuid,
> 
> -                      (VOID **)&FvProtocol);
> 
> -      ASSERT_EFI_ERROR (Status);
> 
> -
> 
> -      FvFileNode = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)Node2;
> 
> -      //
> 
> -      // Buffer==NULL means we request metadata only: BufferSize, FoundType,
> 
> -      // FileAttributes.
> 
> -      //
> 
> -      Status = FvProtocol->ReadFile (
> 
> -                             FvProtocol,
> 
> -                             &FvFileNode->FvFileName, // NameGuid
> 
> -                             NULL,                    // Buffer
> 
> -                             &BufferSize,
> 
> -                             &FoundType,
> 
> -                             &FileAttributes,
> 
> -                             &AuthenticationStatus
> 
> -                             );
> 
> -      if (!EFI_ERROR (Status)) {
> 
> -        //
> 
> -        // The FvFile was found. Keep the boot option.
> 
> -        //
> 
> -        continue;
> 
> -      }
> 
> -    }
> 
> -
> 
> -    //
> 
> -    // Delete the boot option.
> 
> -    //
> 
> -    Status = EfiBootManagerDeleteLoadOptionVariable (
> 
> -               BootOptions[Index].OptionNumber, LoadOptionTypeBoot);
> 
> -    DEBUG_CODE (
> 
> -      CHAR16 *DevicePathString;
> 
> -
> 
> -      DevicePathString = ConvertDevicePathToText(BootOptions[Index].FilePath,
> 
> -                           FALSE, FALSE);
> 
> -      DEBUG ((
> 
> -        EFI_ERROR (Status) ? EFI_D_WARN : EFI_D_VERBOSE,
> 
> -        "%a: removing stale Boot#%04x %s: %r\n",
> 
> -        __FUNCTION__,
> 
> -        (UINT32)BootOptions[Index].OptionNumber,
> 
> -        DevicePathString == NULL ? L"<unavailable>" : DevicePathString,
> 
> -        Status
> 
> -        ));
> 
> -      if (DevicePathString != NULL) {
> 
> -        FreePool (DevicePathString);
> 
> -      }
> 
> -      );
> 
> -  }
> 
> -
> 
> -  EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
> 
> -}
> 
> -
> 
> -VOID
> 
> -PlatformRegisterOptionsAndKeys (
> 
> -  VOID
> 
> -  )
> 
> -{
> 
> -  EFI_STATUS                   Status;
> 
> -  EFI_INPUT_KEY                Enter;
> 
> -  EFI_INPUT_KEY                F2;
> 
> -  EFI_INPUT_KEY                Esc;
> 
> -  EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
> 
> -
> 
> -  //
> 
> -  // Register ENTER as CONTINUE key
> 
> -  //
> 
> -  Enter.ScanCode    = SCAN_NULL;
> 
> -  Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;
> 
> -  Status = EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
> 
> -  ASSERT_EFI_ERROR (Status);
> 
> -
> 
> -  //
> 
> -  // Map F2 to Boot Manager Menu
> 
> -  //
> 
> -  F2.ScanCode     = SCAN_F2;
> 
> -  F2.UnicodeChar  = CHAR_NULL;
> 
> -  Esc.ScanCode    = SCAN_ESC;
> 
> -  Esc.UnicodeChar = CHAR_NULL;
> 
> -  Status = EfiBootManagerGetBootManagerMenu (&BootOption);
> 
> -  ASSERT_EFI_ERROR (Status);
> 
> -  Status = EfiBootManagerAddKeyOptionVariable (
> 
> -             NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL
> 
> -             );
> 
> -  ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
> 
> -  Status = EfiBootManagerAddKeyOptionVariable (
> 
> -             NULL, (UINT16) BootOption.OptionNumber, 0, &Esc, NULL
> 
> -             );
> 
> -  ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
> 
> -}
> 
> -
> 
> -EFI_STATUS
> 
> -EFIAPI
> 
> -ConnectRootBridge (
> 
> -  IN EFI_HANDLE  RootBridgeHandle,
> 
> -  IN VOID        *Instance,
> 
> -  IN VOID        *Context
> 
> -  );
> 
> -
> 
> -//
> 
> -// BDS Platform Functions
> 
> -//
> 
> -/**
> 
> -  Do the platform init, can be customized by OEM/IBV
> 
> -
> 
> -  Possible things that can be done in PlatformBootManagerBeforeConsole:
> 
> -
> 
> -  > Update console variable: 1. include hot-plug devices;
> 
> -  >                          2. Clear ConIn and add SOL for AMT
> 
> -  > Register new Driver#### or Boot####
> 
> -  > Register new Key####: e.g.: F12
> 
> -  > Signal ReadyToLock event
> 
> -  > Authentication action: 1. connect Auth devices;
> 
> -  >                        2. Identify auto logon user.
> 
> -**/
> 
> -VOID
> 
> -EFIAPI
> 
> -PlatformBootManagerBeforeConsole (
> 
> -  VOID
> 
> -  )
> 
> -{
> 
> -  EFI_BOOT_MANAGER_LOAD_OPTION  *NvBootOptions;
> 
> -  UINTN                         NvBootOptionCount;
> 
> -  UINTN                         Index;
> 
> -  EFI_STATUS                    Status;
> 
> -
> 
> -  DEBUG ((DEBUG_INFO, "PlatformBootManagerBeforeConsole\n"));
> 
> -
> 
> -  NvBootOptions = EfiBootManagerGetLoadOptions (&NvBootOptionCount,
> LoadOptionTypeBoot);
> 
> -  for (Index = 0; Index < NvBootOptionCount; Index++) {
> 
> -    Status = EfiBootManagerDeleteLoadOptionVariable
> (NvBootOptions[Index].OptionNumber, LoadOptionTypeBoot);
> 
> -    if (EFI_ERROR (Status)) {
> 
> -      DEBUG ((
> 
> -        DEBUG_ERROR,
> 
> -        "%a: removing Boot#%04x %r\n",
> 
> -        __FUNCTION__,
> 
> -        (UINT32) NvBootOptions[Index].OptionNumber,
> 
> -        Status
> 
> -        ));
> 
> -    }
> 
> -  }
> 
> -
> 
> -  InstallDevicePathCallback ();
> 
> -
> 
> -  VisitAllInstancesOfProtocol (&gEfiPciRootBridgeIoProtocolGuid,
> 
> -    ConnectRootBridge, NULL);
> 
> -  //
> 
> -  // Enable LPC
> 
> -  //
> 
> -  PciOr16(POWER_MGMT_REGISTER_ICH10(0x04),
> 
> -           BIT0 | BIT1 | BIT2);
> 
> -  //
> 
> -  // We can't signal End-of-Dxe earlier than this. Namely, End-of-Dxe triggers
> 
> -  // the preparation of S3 system information. That logic has a hard
> dependency
> 
> -  // on the presence of the FACS ACPI table. Since our ACPI tables are only
> 
> -  // installed after PCI enumeration completes, we must not trigger the S3
> save
> 
> -  // earlier, hence we can't signal End-of-Dxe earlier.
> 
> -  //
> 
> -  EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);
> 
> -
> 
> -  PlatformInitializeConsole (gPlatformConsole);
> 
> -
> 
> -  PlatformRegisterOptionsAndKeys ();
> 
> -}
> 
> -
> 
> -
> 
> -EFI_STATUS
> 
> -EFIAPI
> 
> -ConnectRootBridge (
> 
> -  IN EFI_HANDLE  RootBridgeHandle,
> 
> -  IN VOID        *Instance,
> 
> -  IN VOID        *Context
> 
> -  )
> 
> -{
> 
> -  EFI_STATUS Status;
> 
> -
> 
> -  //
> 
> -  // Make the PCI bus driver connect the root bridge, non-recursively. This
> 
> -  // will produce a number of child handles with PciIo on them.
> 
> -  //
> 
> -  Status = gBS->ConnectController (
> 
> -                  RootBridgeHandle, // ControllerHandle
> 
> -                  NULL,             // DriverImageHandle
> 
> -                  NULL,             // RemainingDevicePath -- produce all
> 
> -                                    //   children
> 
> -                  FALSE             // Recursive
> 
> -                  );
> 
> -  return Status;
> 
> -}
> 
> -
> 
> -
> 
> -/**
> 
> -  Add IsaKeyboard to ConIn; add IsaSerial to ConOut, ConIn, ErrOut.
> 
> -
> 
> -  @param[in] DeviceHandle  Handle of the LPC Bridge device.
> 
> -
> 
> -  @retval EFI_SUCCESS  Console devices on the LPC bridge have been added
> to
> 
> -                       ConOut, ConIn, and ErrOut.
> 
> -
> 
> -  @return              Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing
> 
> -                       from DeviceHandle.
> 
> -**/
> 
> -EFI_STATUS
> 
> -PrepareLpcBridgeDevicePath (
> 
> -  IN EFI_HANDLE                DeviceHandle
> 
> -  )
> 
> -{
> 
> -  EFI_STATUS                Status;
> 
> -  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
> 
> -  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;
> 
> -  CHAR16                    *DevPathStr;
> 
> -
> 
> -  DevicePath = NULL;
> 
> -  Status = gBS->HandleProtocol (
> 
> -                  DeviceHandle,
> 
> -                  &gEfiDevicePathProtocolGuid,
> 
> -                  (VOID*)&DevicePath
> 
> -                  );
> 
> -  if (EFI_ERROR (Status)) {
> 
> -    return Status;
> 
> -  }
> 
> -  TempDevicePath = DevicePath;
> 
> -
> 
> -  //
> 
> -  // Register Keyboard
> 
> -  //
> 
> -  DevicePath = AppendDevicePathNode (DevicePath,
> (EFI_DEVICE_PATH_PROTOCOL *)&gPnpPs2KeyboardDeviceNode);
> 
> -
> 
> -  EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
> 
> -
> 
> -  //
> 
> -  // Register COM1
> 
> -  //
> 
> -  DevicePath = TempDevicePath;
> 
> -  gPnp16550ComPortDeviceNode.UID = 0;
> 
> -
> 
> -  DevicePath = AppendDevicePathNode (DevicePath,
> (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);
> 
> -  DevicePath = AppendDevicePathNode (DevicePath,
> (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
> 
> -  DevicePath = AppendDevicePathNode (DevicePath,
> (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
> 
> -
> 
> -  //
> 
> -  // Print Device Path
> 
> -  //
> 
> -  DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
> 
> -  if (DevPathStr != NULL) {
> 
> -    DEBUG((
> 
> -      EFI_D_INFO,
> 
> -      "BdsPlatform.c+%d: COM%d DevPath: %s\n",
> 
> -      __LINE__,
> 
> -      gPnp16550ComPortDeviceNode.UID + 1,
> 
> -      DevPathStr
> 
> -      ));
> 
> -    FreePool(DevPathStr);
> 
> -  }
> 
> -
> 
> -  EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
> 
> -  EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
> 
> -  EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
> 
> -
> 
> -  //
> 
> -  // Register COM2
> 
> -  //
> 
> -  DevicePath = TempDevicePath;
> 
> -  gPnp16550ComPortDeviceNode.UID = 1;
> 
> -
> 
> -  DevicePath = AppendDevicePathNode (DevicePath,
> (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);
> 
> -  DevicePath = AppendDevicePathNode (DevicePath,
> (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
> 
> -  DevicePath = AppendDevicePathNode (DevicePath,
> (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
> 
> -
> 
> -  //
> 
> -  // Print Device Path
> 
> -  //
> 
> -  DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
> 
> -  if (DevPathStr != NULL) {
> 
> -    DEBUG((
> 
> -      EFI_D_INFO,
> 
> -      "BdsPlatform.c+%d: COM%d DevPath: %s\n",
> 
> -      __LINE__,
> 
> -      gPnp16550ComPortDeviceNode.UID + 1,
> 
> -      DevPathStr
> 
> -      ));
> 
> -    FreePool(DevPathStr);
> 
> -  }
> 
> -
> 
> -  EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
> 
> -  EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
> 
> -  EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
> 
> -
> 
> -  return EFI_SUCCESS;
> 
> -}
> 
> -
> 
> -EFI_STATUS
> 
> -GetGopDevicePath (
> 
> -   IN  EFI_DEVICE_PATH_PROTOCOL *PciDevicePath,
> 
> -   OUT EFI_DEVICE_PATH_PROTOCOL **GopDevicePath
> 
> -   )
> 
> -{
> 
> -  UINTN                           Index;
> 
> -  EFI_STATUS                      Status;
> 
> -  EFI_HANDLE                      PciDeviceHandle;
> 
> -  EFI_DEVICE_PATH_PROTOCOL        *TempDevicePath;
> 
> -  EFI_DEVICE_PATH_PROTOCOL        *TempPciDevicePath;
> 
> -  UINTN                           GopHandleCount;
> 
> -  EFI_HANDLE                      *GopHandleBuffer;
> 
> -
> 
> -  if (PciDevicePath == NULL || GopDevicePath == NULL) {
> 
> -    return EFI_INVALID_PARAMETER;
> 
> -  }
> 
> -
> 
> -  //
> 
> -  // Initialize the GopDevicePath to be PciDevicePath
> 
> -  //
> 
> -  *GopDevicePath    = PciDevicePath;
> 
> -  TempPciDevicePath = PciDevicePath;
> 
> -
> 
> -  Status = gBS->LocateDevicePath (
> 
> -                  &gEfiDevicePathProtocolGuid,
> 
> -                  &TempPciDevicePath,
> 
> -                  &PciDeviceHandle
> 
> -                  );
> 
> -  if (EFI_ERROR (Status)) {
> 
> -    return Status;
> 
> -  }
> 
> -
> 
> -  //
> 
> -  // Try to connect this handle, so that GOP driver could start on this
> 
> -  // device and create child handles with GraphicsOutput Protocol installed
> 
> -  // on them, then we get device paths of these child handles and select
> 
> -  // them as possible console device.
> 
> -  //
> 
> -  gBS->ConnectController (PciDeviceHandle, NULL, NULL, FALSE);
> 
> -
> 
> -  Status = gBS->LocateHandleBuffer (
> 
> -                  ByProtocol,
> 
> -                  &gEfiGraphicsOutputProtocolGuid,
> 
> -                  NULL,
> 
> -                  &GopHandleCount,
> 
> -                  &GopHandleBuffer
> 
> -                  );
> 
> -  if (!EFI_ERROR (Status)) {
> 
> -    //
> 
> -    // Add all the child handles as possible Console Device
> 
> -    //
> 
> -    for (Index = 0; Index < GopHandleCount; Index++) {
> 
> -      Status = gBS->HandleProtocol (GopHandleBuffer[Index],
> &gEfiDevicePathProtocolGuid, (VOID*)&TempDevicePath);
> 
> -      if (EFI_ERROR (Status)) {
> 
> -        continue;
> 
> -      }
> 
> -      if (CompareMem (
> 
> -            PciDevicePath,
> 
> -            TempDevicePath,
> 
> -            GetDevicePathSize (PciDevicePath) - END_DEVICE_PATH_LENGTH
> 
> -            ) == 0) {
> 
> -        //
> 
> -        // In current implementation, we only enable one of the child handles
> 
> -        // as console device, i.e. sotre one of the child handle's device
> 
> -        // path to variable "ConOut"
> 
> -        // In future, we could select all child handles to be console device
> 
> -        //
> 
> -
> 
> -        *GopDevicePath = TempDevicePath;
> 
> -
> 
> -        //
> 
> -        // Delete the PCI device's path that added by
> 
> -        // GetPlugInPciVgaDevicePath(). Add the integrity GOP device path.
> 
> -        //
> 
> -        EfiBootManagerUpdateConsoleVariable (ConOutDev, NULL,
> PciDevicePath);
> 
> -        EfiBootManagerUpdateConsoleVariable (ConOutDev, TempDevicePath,
> NULL);
> 
> -      }
> 
> -    }
> 
> -    gBS->FreePool (GopHandleBuffer);
> 
> -  }
> 
> -
> 
> -  return EFI_SUCCESS;
> 
> -}
> 
> -
> 
> -/**
> 
> -  Add PCI display to ConOut.
> 
> -
> 
> -  @param[in] DeviceHandle  Handle of the PCI display device.
> 
> -
> 
> -  @retval EFI_SUCCESS  The PCI display device has been added to ConOut.
> 
> -
> 
> -  @return              Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing
> 
> -                       from DeviceHandle.
> 
> -**/
> 
> -EFI_STATUS
> 
> -PreparePciDisplayDevicePath (
> 
> -  IN EFI_HANDLE                DeviceHandle
> 
> -  )
> 
> -{
> 
> -  EFI_STATUS                Status;
> 
> -  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
> 
> -  EFI_DEVICE_PATH_PROTOCOL  *GopDevicePath;
> 
> -
> 
> -  DevicePath    = NULL;
> 
> -  GopDevicePath = NULL;
> 
> -  Status = gBS->HandleProtocol (
> 
> -                  DeviceHandle,
> 
> -                  &gEfiDevicePathProtocolGuid,
> 
> -                  (VOID*)&DevicePath
> 
> -                  );
> 
> -  if (EFI_ERROR (Status)) {
> 
> -    return Status;
> 
> -  }
> 
> -
> 
> -  GetGopDevicePath (DevicePath, &GopDevicePath);
> 
> -  DevicePath = GopDevicePath;
> 
> -
> 
> -  EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
> 
> -
> 
> -  return EFI_SUCCESS;
> 
> -}
> 
> -
> 
> -/**
> 
> -  Add PCI Serial to ConOut, ConIn, ErrOut.
> 
> -
> 
> -  @param[in] DeviceHandle  Handle of the PCI serial device.
> 
> -
> 
> -  @retval EFI_SUCCESS  The PCI serial device has been added to ConOut,
> ConIn,
> 
> -                       ErrOut.
> 
> -
> 
> -  @return              Error codes, due to EFI_DEVICE_PATH_PROTOCOL missing
> 
> -                       from DeviceHandle.
> 
> -**/
> 
> -EFI_STATUS
> 
> -PreparePciSerialDevicePath (
> 
> -  IN EFI_HANDLE                DeviceHandle
> 
> -  )
> 
> -{
> 
> -  EFI_STATUS                Status;
> 
> -  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
> 
> -
> 
> -  DevicePath = NULL;
> 
> -  Status = gBS->HandleProtocol (
> 
> -                  DeviceHandle,
> 
> -                  &gEfiDevicePathProtocolGuid,
> 
> -                  (VOID*)&DevicePath
> 
> -                  );
> 
> -  if (EFI_ERROR (Status)) {
> 
> -    return Status;
> 
> -  }
> 
> -
> 
> -  DevicePath = AppendDevicePathNode (DevicePath,
> (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
> 
> -  DevicePath = AppendDevicePathNode (DevicePath,
> (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
> 
> -
> 
> -  EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
> 
> -  EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
> 
> -  EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
> 
> -
> 
> -  return EFI_SUCCESS;
> 
> -}
> 
> -
> 
> -EFI_STATUS
> 
> -VisitAllInstancesOfProtocol (
> 
> -  IN EFI_GUID                    *Id,
> 
> -  IN PROTOCOL_INSTANCE_CALLBACK  CallBackFunction,
> 
> -  IN VOID                        *Context
> 
> -  )
> 
> -{
> 
> -  EFI_STATUS                Status;
> 
> -  UINTN                     HandleCount;
> 
> -  EFI_HANDLE                *HandleBuffer;
> 
> -  UINTN                     Index;
> 
> -  VOID                      *Instance;
> 
> -
> 
> -  //
> 
> -  // Start to check all the PciIo to find all possible device
> 
> -  //
> 
> -  HandleCount = 0;
> 
> -  HandleBuffer = NULL;
> 
> -  Status = gBS->LocateHandleBuffer (
> 
> -                  ByProtocol,
> 
> -                  Id,
> 
> -                  NULL,
> 
> -                  &HandleCount,
> 
> -                  &HandleBuffer
> 
> -                  );
> 
> -  if (EFI_ERROR (Status)) {
> 
> -    return Status;
> 
> -  }
> 
> -
> 
> -  for (Index = 0; Index < HandleCount; Index++) {
> 
> -    Status = gBS->HandleProtocol (HandleBuffer[Index], Id, &Instance);
> 
> -    if (EFI_ERROR (Status)) {
> 
> -      continue;
> 
> -    }
> 
> -
> 
> -    Status = (*CallBackFunction) (
> 
> -               HandleBuffer[Index],
> 
> -               Instance,
> 
> -               Context
> 
> -               );
> 
> -  }
> 
> -
> 
> -  gBS->FreePool (HandleBuffer);
> 
> -
> 
> -  return EFI_SUCCESS;
> 
> -}
> 
> -
> 
> -
> 
> -EFI_STATUS
> 
> -EFIAPI
> 
> -VisitingAPciInstance (
> 
> -  IN EFI_HANDLE  Handle,
> 
> -  IN VOID        *Instance,
> 
> -  IN VOID        *Context
> 
> -  )
> 
> -{
> 
> -  EFI_STATUS                Status;
> 
> -  EFI_PCI_IO_PROTOCOL       *PciIo;
> 
> -  PCI_TYPE00                Pci;
> 
> -
> 
> -  PciIo = (EFI_PCI_IO_PROTOCOL*) Instance;
> 
> -
> 
> -  //
> 
> -  // Check for all PCI device
> 
> -  //
> 
> -  Status = PciIo->Pci.Read (
> 
> -                    PciIo,
> 
> -                    EfiPciIoWidthUint32,
> 
> -                    0,
> 
> -                    sizeof (Pci) / sizeof (UINT32),
> 
> -                    &Pci
> 
> -                    );
> 
> -  if (EFI_ERROR (Status)) {
> 
> -    return Status;
> 
> -  }
> 
> -
> 
> -  return (*(VISIT_PCI_INSTANCE_CALLBACK)(UINTN) Context) (
> 
> -           Handle,
> 
> -           PciIo,
> 
> -           &Pci
> 
> -           );
> 
> -
> 
> -}
> 
> -
> 
> -
> 
> -
> 
> -EFI_STATUS
> 
> -VisitAllPciInstances (
> 
> -  IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
> 
> -  )
> 
> -{
> 
> -  return VisitAllInstancesOfProtocol (
> 
> -           &gEfiPciIoProtocolGuid,
> 
> -           VisitingAPciInstance,
> 
> -           (VOID*)(UINTN) CallBackFunction
> 
> -           );
> 
> -}
> 
> -
> 
> -
> 
> -/**
> 
> -  Do platform specific PCI Device check and add them to
> 
> -  ConOut, ConIn, ErrOut.
> 
> -
> 
> -  @param[in]  Handle - Handle of PCI device instance
> 
> -  @param[in]  PciIo - PCI IO protocol instance
> 
> -  @param[in]  Pci - PCI Header register block
> 
> -
> 
> -  @retval EFI_SUCCESS - PCI Device check and Console variable update
> 
> -                        successfully.
> 
> -  @retval EFI_STATUS - PCI Device check or Console variable update fail.
> 
> -
> 
> -**/
> 
> -EFI_STATUS
> 
> -EFIAPI
> 
> -DetectAndPreparePlatformPciDevicePath (
> 
> -  IN EFI_HANDLE           Handle,
> 
> -  IN EFI_PCI_IO_PROTOCOL  *PciIo,
> 
> -  IN PCI_TYPE00           *Pci
> 
> -  )
> 
> -{
> 
> -  EFI_STATUS                Status;
> 
> -
> 
> -  Status = PciIo->Attributes (
> 
> -    PciIo,
> 
> -    EfiPciIoAttributeOperationEnable,
> 
> -    EFI_PCI_DEVICE_ENABLE,
> 
> -    NULL
> 
> -    );
> 
> -  ASSERT_EFI_ERROR (Status);
> 
> -
> 
> -  if (!mDetectVgaOnly) {
> 
> -    //
> 
> -    // Here we decide whether it is LPC Bridge
> 
> -    //
> 
> -    if ((IS_PCI_LPC (Pci)) ||
> 
> -        ((IS_PCI_ISA_PDECODE (Pci)) &&
> 
> -         (Pci->Hdr.VendorId == 0x8086) &&
> 
> -         (Pci->Hdr.DeviceId == 0x7000)
> 
> -        )
> 
> -       ) {
> 
> -      //
> 
> -      // Add IsaKeyboard to ConIn,
> 
> -      // add IsaSerial to ConOut, ConIn, ErrOut
> 
> -      //
> 
> -      DEBUG ((EFI_D_INFO, "Found LPC Bridge device\n"));
> 
> -      PrepareLpcBridgeDevicePath (Handle);
> 
> -      return EFI_SUCCESS;
> 
> -    }
> 
> -    //
> 
> -    // Here we decide which Serial device to enable in PCI bus
> 
> -    //
> 
> -    if (IS_PCI_16550SERIAL (Pci)) {
> 
> -      //
> 
> -      // Add them to ConOut, ConIn, ErrOut.
> 
> -      //
> 
> -      DEBUG ((EFI_D_INFO, "Found PCI 16550 SERIAL device\n"));
> 
> -      PreparePciSerialDevicePath (Handle);
> 
> -      return EFI_SUCCESS;
> 
> -    }
> 
> -  }
> 
> -
> 
> -  //
> 
> -  // Here we decide which display device to enable in PCI bus
> 
> -  //
> 
> -  if (IS_PCI_DISPLAY (Pci)) {
> 
> -    //
> 
> -    // Add them to ConOut.
> 
> -    //
> 
> -    DEBUG ((EFI_D_INFO, "Found PCI display device\n"));
> 
> -    PreparePciDisplayDevicePath (Handle);
> 
> -    return EFI_SUCCESS;
> 
> -  }
> 
> -
> 
> -  return Status;
> 
> -}
> 
> -
> 
> -
> 
> -/**
> 
> -  Do platform specific PCI Device check and add them to ConOut, ConIn,
> ErrOut
> 
> -
> 
> -  @param[in]  DetectVgaOnly - Only detect VGA device if it's TRUE.
> 
> -
> 
> -  @retval EFI_SUCCESS - PCI Device check and Console variable update
> successfully.
> 
> -  @retval EFI_STATUS - PCI Device check or Console variable update fail.
> 
> -
> 
> -**/
> 
> -EFI_STATUS
> 
> -DetectAndPreparePlatformPciDevicePaths (
> 
> -  BOOLEAN DetectVgaOnly
> 
> -  )
> 
> -{
> 
> -  mDetectVgaOnly = DetectVgaOnly;
> 
> -  return VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath);
> 
> -}
> 
> -
> 
> -/**
> 
> -  Connect the predefined platform default console device.
> 
> -
> 
> -  Always try to find and enable PCI display devices.
> 
> -
> 
> -  @param[in] PlatformConsole  Predefined platform default console device
> array.
> 
> -**/
> 
> -VOID
> 
> -PlatformInitializeConsole (
> 
> -  IN PLATFORM_CONSOLE_CONNECT_ENTRY   *PlatformConsole
> 
> -  )
> 
> -{
> 
> -  UINTN                              Index;
> 
> -  EFI_DEVICE_PATH_PROTOCOL           *VarConout;
> 
> -  EFI_DEVICE_PATH_PROTOCOL           *VarConin;
> 
> -
> 
> -  //
> 
> -  // Connect RootBridge
> 
> -  //
> 
> -  GetEfiGlobalVariable2 (EFI_CON_OUT_VARIABLE_NAME, (VOID **)
> &VarConout, NULL);
> 
> -  GetEfiGlobalVariable2 (EFI_CON_IN_VARIABLE_NAME, (VOID **)
> &VarConin, NULL);
> 
> -
> 
> -  if (VarConout == NULL || VarConin == NULL) {
> 
> -    //
> 
> -    // Do platform specific PCI Device check and add them to ConOut, ConIn,
> ErrOut
> 
> -    //
> 
> -    DetectAndPreparePlatformPciDevicePaths (FALSE);
> 
> -    DetectAndPreparePlatformPciDevicePaths(TRUE);
> 
> -    //
> 
> -    // Have chance to connect the platform default console,
> 
> -    // the platform default console is the minimue device group
> 
> -    // the platform should support
> 
> -    //
> 
> -    for (Index = 0; PlatformConsole[Index].DevicePath != NULL; ++Index) {
> 
> -      //
> 
> -      // Update the console variable with the connect type
> 
> -      //
> 
> -      if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) ==
> CONSOLE_IN) {
> 
> -        EfiBootManagerUpdateConsoleVariable (ConIn,
> PlatformConsole[Index].DevicePath, NULL);
> 
> -      }
> 
> -      if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) ==
> CONSOLE_OUT) {
> 
> -        EfiBootManagerUpdateConsoleVariable (ConOut,
> PlatformConsole[Index].DevicePath, NULL);
> 
> -      }
> 
> -      if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
> 
> -        EfiBootManagerUpdateConsoleVariable (ErrOut,
> PlatformConsole[Index].DevicePath, NULL);
> 
> -      }
> 
> -    }
> 
> -  } else {
> 
> -    //
> 
> -    // Only detect VGA device and add them to ConOut
> 
> -    //
> 
> -    DetectAndPreparePlatformPciDevicePaths (TRUE);
> 
> -  }
> 
> -}
> 
> -
> 
> -
> 
> -/**
> 
> -  Configure PCI Interrupt Line register for applicable devices
> 
> -  Ported from SeaBIOS, src/fw/pciinit.c, *_pci_slot_get_irq()
> 
> -
> 
> -  @param[in]  Handle - Handle of PCI device instance
> 
> -  @param[in]  PciIo - PCI IO protocol instance
> 
> -  @param[in]  PciHdr - PCI Header register block
> 
> -
> 
> -  @retval EFI_SUCCESS - PCI Interrupt Line register configured successfully.
> 
> -
> 
> -**/
> 
> -EFI_STATUS
> 
> -EFIAPI
> 
> -SetPciIntLine (
> 
> -  IN EFI_HANDLE           Handle,
> 
> -  IN EFI_PCI_IO_PROTOCOL  *PciIo,
> 
> -  IN PCI_TYPE00           *PciHdr
> 
> -  )
> 
> -{
> 
> -  EFI_DEVICE_PATH_PROTOCOL  *DevPathNode;
> 
> -  EFI_DEVICE_PATH_PROTOCOL  *DevPath;
> 
> -  UINTN                     RootSlot;
> 
> -  UINTN                     Idx;
> 
> -  UINT8                     IrqLine;
> 
> -  EFI_STATUS                Status;
> 
> -  UINT32                    RootBusNumber;
> 
> -
> 
> -  Status = EFI_SUCCESS;
> 
> -
> 
> -  if (PciHdr->Device.InterruptPin != 0) {
> 
> -
> 
> -    DevPathNode = DevicePathFromHandle (Handle);
> 
> -    ASSERT (DevPathNode != NULL);
> 
> -    DevPath = DevPathNode;
> 
> -
> 
> -    RootBusNumber = 0;
> 
> -    if (DevicePathType (DevPathNode) == ACPI_DEVICE_PATH &&
> 
> -        DevicePathSubType (DevPathNode) == ACPI_DP &&
> 
> -        ((ACPI_HID_DEVICE_PATH *)DevPathNode)->HID ==
> EISA_PNP_ID(0x0A03)) {
> 
> -      RootBusNumber = ((ACPI_HID_DEVICE_PATH *)DevPathNode)->UID;
> 
> -    }
> 
> -
> 
> -    //
> 
> -    // Compute index into PciHostIrqs[] table by walking
> 
> -    // the device path and adding up all device numbers
> 
> -    //
> 
> -    Status = EFI_NOT_FOUND;
> 
> -    RootSlot = 0;
> 
> -    Idx = PciHdr->Device.InterruptPin - 1;
> 
> -    while (!IsDevicePathEnd (DevPathNode)) {
> 
> -      if (DevicePathType (DevPathNode) == HARDWARE_DEVICE_PATH &&
> 
> -          DevicePathSubType (DevPathNode) == HW_PCI_DP) {
> 
> -
> 
> -        Idx += ((PCI_DEVICE_PATH *)DevPathNode)->Device;
> 
> -
> 
> -        //
> 
> -        // Unlike SeaBIOS, which starts climbing from the leaf device
> 
> -        // up toward the root, we traverse the device path starting at
> 
> -        // the root moving toward the leaf node.
> 
> -        // The slot number of the top-level parent bridge is needed
> 
> -        // with more than 24 slots on the root bus.
> 
> -        //
> 
> -        if (Status != EFI_SUCCESS) {
> 
> -          Status = EFI_SUCCESS;
> 
> -          RootSlot = ((PCI_DEVICE_PATH *)DevPathNode)->Device;
> 
> -        }
> 
> -      }
> 
> -
> 
> -      DevPathNode = NextDevicePathNode (DevPathNode);
> 
> -    }
> 
> -    if (EFI_ERROR (Status)) {
> 
> -      return Status;
> 
> -    }
> 
> -    if (RootBusNumber == 0 && RootSlot == 0) {
> 
> -      return Status; //bugbug: workaround; need SIMICS change B0/D0/F0
> PCI_IntPin reg(0x3D) = 0X0
> 
> -//      DEBUG((
> 
> -//        EFI_D_ERROR,
> 
> -//       "%a: PCI host bridge (00:00.0) should have no interrupts!\n",
> 
> -//        __FUNCTION__
> 
> -//        ));
> 
> -//      ASSERT (FALSE);
> 
> -    }
> 
> -
> 
> -    //
> 
> -    // Final PciHostIrqs[] index calculation depends on the platform
> 
> -    // and should match SeaBIOS src/fw/pciinit.c *_pci_slot_get_irq()
> 
> -    //
> 
> -    switch (mHostBridgeDevId) {
> 
> -      case INTEL_82441_DEVICE_ID:
> 
> -        Idx -= 1;
> 
> -        break;
> 
> -      case INTEL_ICH10_DEVICE_ID:
> 
> -        //
> 
> -        // SeaBIOS contains the following comment:
> 
> -        // "Slots 0-24 rotate slot:pin mapping similar to piix above, but
> 
> -        //  with a different starting index.
> 
> -        //
> 
> -        //  Slots 25-31 all use LNKA mapping (or LNKE, but A:D = E:H)"
> 
> -        //
> 
> -        if (RootSlot > 24) {
> 
> -          //
> 
> -          // in this case, subtract back out RootSlot from Idx
> 
> -          // (SeaBIOS never adds it to begin with, but that would make our
> 
> -          //  device path traversal loop above too awkward)
> 
> -          //
> 
> -          Idx -= RootSlot;
> 
> -        }
> 
> -        break;
> 
> -      default:
> 
> -        ASSERT (FALSE); // should never get here
> 
> -    }
> 
> -    Idx %= ARRAY_SIZE (PciHostIrqs);
> 
> -    IrqLine = PciHostIrqs[Idx];
> 
> -
> 
> -    DEBUG_CODE_BEGIN ();
> 
> -    {
> 
> -      CHAR16        *DevPathString;
> 
> -      STATIC CHAR16 Fallback[] = L"<failed to convert>";
> 
> -      UINTN         Segment, Bus, Device, Function;
> 
> -
> 
> -      DevPathString = ConvertDevicePathToText (DevPath, FALSE, FALSE);
> 
> -      if (DevPathString == NULL) {
> 
> -        DevPathString = Fallback;
> 
> -      }
> 
> -      Status = PciIo->GetLocation (PciIo, &Segment, &Bus, &Device, &Function);
> 
> -      ASSERT_EFI_ERROR (Status);
> 
> -
> 
> -      DEBUG ((EFI_D_VERBOSE, "%a: [%02x:%02x.%x] %s -> 0x%02x\n",
> __FUNCTION__,
> 
> -        (UINT32)Bus, (UINT32)Device, (UINT32)Function, DevPathString,
> 
> -        IrqLine));
> 
> -
> 
> -      if (DevPathString != Fallback) {
> 
> -        FreePool (DevPathString);
> 
> -      }
> 
> -    }
> 
> -    DEBUG_CODE_END ();
> 
> -
> 
> -    //
> 
> -    // Set PCI Interrupt Line register for this device to PciHostIrqs[Idx]
> 
> -    //
> 
> -    Status = PciIo->Pci.Write (
> 
> -               PciIo,
> 
> -               EfiPciIoWidthUint8,
> 
> -               PCI_INT_LINE_OFFSET,
> 
> -               1,
> 
> -               &IrqLine
> 
> -               );
> 
> -  }
> 
> -
> 
> -  return Status;
> 
> -}
> 
> -
> 
> -/**
> 
> -Write to mask and edge/level triggered registers of master and slave 8259
> PICs.
> 
> -
> 
> -@param[in]  Mask       low byte for master PIC mask register,
> 
> -high byte for slave PIC mask register.
> 
> -@param[in]  EdgeLevel  low byte for master PIC edge/level triggered register,
> 
> -high byte for slave PIC edge/level triggered register.
> 
> -
> 
> -**/
> 
> -VOID
> 
> -Interrupt8259WriteMask(
> 
> -  IN UINT16  Mask,
> 
> -  IN UINT16  EdgeLevel
> 
> -)
> 
> -{
> 
> -  IoWrite8(LEGACY_8259_MASK_REGISTER_MASTER, (UINT8)Mask);
> 
> -  IoWrite8(LEGACY_8259_MASK_REGISTER_SLAVE, (UINT8)(Mask >> 8));
> 
> -  IoWrite8(LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_MASTER,
> (UINT8)EdgeLevel);
> 
> -  IoWrite8(LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_SLAVE,
> (UINT8)(EdgeLevel >> 8));
> 
> -}
> 
> -
> 
> -VOID
> 
> -PciAcpiInitialization (
> 
> -  )
> 
> -{
> 
> -  UINTN  Pmba;
> 
> -
> 
> -  //
> 
> -  // Query Host Bridge DID to determine platform type
> 
> -  //
> 
> -  mHostBridgeDevId = PcdGet16 (PcdSimicsX58HostBridgePciDevId);
> 
> -  switch (mHostBridgeDevId) {
> 
> -    case INTEL_82441_DEVICE_ID:
> 
> -      Pmba = POWER_MGMT_REGISTER_PIIX4 (PIIX4_PMBA);
> 
> -      //
> 
> -      // 00:01.0 ISA Bridge (PIIX4) LNK routing targets
> 
> -      //
> 
> -      PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x60), 0x0b); // A
> 
> -      PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x61), 0x0b); // B
> 
> -      PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x62), 0x0a); // C
> 
> -      PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x63), 0x0a); // D
> 
> -      break;
> 
> -    case INTEL_ICH10_DEVICE_ID:
> 
> -      Pmba = POWER_MGMT_REGISTER_ICH10 (ICH10_PMBASE);
> 
> -      //
> 
> -      // 00:1f.0 LPC Bridge LNK routing targets
> 
> -      //
> 
> -      PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x60), 0x0a); // A
> 
> -      PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x61), 0x0a); // B
> 
> -      PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x62), 0x0b); // C
> 
> -      PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x63), 0x0b); // D
> 
> -      PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x68), 0x0a); // E
> 
> -      PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x69), 0x0a); // F
> 
> -      PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x6a), 0x0b); // G
> 
> -      PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x6b), 0x0b); // H
> 
> -      break;
> 
> -    default:
> 
> -      DEBUG ((EFI_D_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",
> 
> -        __FUNCTION__, mHostBridgeDevId));
> 
> -      ASSERT (FALSE);
> 
> -      return;
> 
> -  }
> 
> -
> 
> -  //
> 
> -  // Initialize PCI_INTERRUPT_LINE for applicable present PCI devices
> 
> -  //
> 
> -  VisitAllPciInstances (SetPciIntLine);
> 
> -
> 
> -  //
> 
> -  // Set ACPI SCI_EN bit in PMCNTRL
> 
> -  //
> 
> -  IoOr16 ((PciRead32 (Pmba) & ~BIT0) + 4, BIT0);
> 
> -  //
> 
> -  // Set all 8259 interrupts to edge triggered and disabled
> 
> -  //
> 
> -  Interrupt8259WriteMask(0xFFFF, 0x0000);
> 
> -}
> 
> -
> 
> -EFI_STATUS
> 
> -EFIAPI
> 
> -ConnectRecursivelyIfPciMassStorage (
> 
> -  IN EFI_HANDLE           Handle,
> 
> -  IN EFI_PCI_IO_PROTOCOL  *Instance,
> 
> -  IN PCI_TYPE00           *PciHeader
> 
> -  )
> 
> -{
> 
> -  EFI_STATUS                Status;
> 
> -  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
> 
> -  CHAR16                    *DevPathStr;
> 
> -
> 
> -  //
> 
> -  // Recognize PCI Mass Storage
> 
> -  //
> 
> -  if (IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE)) {
> 
> -    DevicePath = NULL;
> 
> -    Status = gBS->HandleProtocol (
> 
> -                    Handle,
> 
> -                    &gEfiDevicePathProtocolGuid,
> 
> -                    (VOID*)&DevicePath
> 
> -                    );
> 
> -    if (EFI_ERROR (Status)) {
> 
> -      return Status;
> 
> -    }
> 
> -
> 
> -    //
> 
> -    // Print Device Path
> 
> -    //
> 
> -    DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
> 
> -    if (DevPathStr != NULL) {
> 
> -      DEBUG((
> 
> -        EFI_D_INFO,
> 
> -        "Found Mass Storage device: %s\n",
> 
> -        DevPathStr
> 
> -        ));
> 
> -      FreePool(DevPathStr);
> 
> -    }
> 
> -
> 
> -    Status = gBS->ConnectController (Handle, NULL, NULL, TRUE);
> 
> -    if (EFI_ERROR (Status)) {
> 
> -      return Status;
> 
> -    }
> 
> -
> 
> -  }
> 
> -
> 
> -  return EFI_SUCCESS;
> 
> -}
> 
> -
> 
> -
> 
> -/**
> 
> -  This notification function is invoked when the
> 
> -  EMU Variable FVB has been changed.
> 
> -
> 
> -  @param  Event                 The event that occurred
> 
> -  @param  Context               For EFI compatibility.  Not used.
> 
> -
> 
> -**/
> 
> -VOID
> 
> -EFIAPI
> 
> -EmuVariablesUpdatedCallback (
> 
> -  IN  EFI_EVENT Event,
> 
> -  IN  VOID      *Context
> 
> -  )
> 
> -{
> 
> -  DEBUG ((EFI_D_INFO, "EmuVariablesUpdatedCallback\n"));
> 
> -  UpdateNvVarsOnFileSystem ();
> 
> -}
> 
> -
> 
> -
> 
> -EFI_STATUS
> 
> -EFIAPI
> 
> -VisitingFileSystemInstance (
> 
> -  IN EFI_HANDLE  Handle,
> 
> -  IN VOID        *Instance,
> 
> -  IN VOID        *Context
> 
> -  )
> 
> -{
> 
> -  EFI_STATUS      Status;
> 
> -  STATIC BOOLEAN  ConnectedToFileSystem = FALSE;
> 
> -
> 
> -  if (ConnectedToFileSystem) {
> 
> -    return EFI_ALREADY_STARTED;
> 
> -  }
> 
> -
> 
> -  Status = ConnectNvVarsToFileSystem (Handle);
> 
> -  if (EFI_ERROR (Status)) {
> 
> -    return Status;
> 
> -  }
> 
> -
> 
> -  ConnectedToFileSystem = TRUE;
> 
> -  mEmuVariableEvent =
> 
> -    EfiCreateProtocolNotifyEvent (
> 
> -      &gEfiDevicePathProtocolGuid,
> 
> -      TPL_CALLBACK,
> 
> -      EmuVariablesUpdatedCallback,
> 
> -      NULL,
> 
> -      &mEmuVariableEventReg
> 
> -      );
> 
> -  PcdSet64 (PcdEmuVariableEvent, (UINT64)(UINTN) mEmuVariableEvent);
> 
> -
> 
> -  return EFI_SUCCESS;
> 
> -}
> 
> -
> 
> -
> 
> -VOID
> 
> -PlatformBdsRestoreNvVarsFromHardDisk (
> 
> -  )
> 
> -{
> 
> -  VisitAllPciInstances (ConnectRecursivelyIfPciMassStorage);
> 
> -  VisitAllInstancesOfProtocol (
> 
> -    &gEfiSimpleFileSystemProtocolGuid,
> 
> -    VisitingFileSystemInstance,
> 
> -    NULL
> 
> -    );
> 
> -
> 
> -}
> 
> -
> 
> -/**
> 
> -  Connect with predefined platform connect sequence.
> 
> -
> 
> -  The OEM/IBV can customize with their own connect sequence.
> 
> -**/
> 
> -VOID
> 
> -PlatformBdsConnectSequence (
> 
> -  VOID
> 
> -  )
> 
> -{
> 
> -  UINTN Index;
> 
> -
> 
> -  DEBUG ((EFI_D_INFO, "PlatformBdsConnectSequence\n"));
> 
> -
> 
> -  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
> 
> -    //
> 
> -    EfiBootManagerConnectDevicePath (gPlatformConnectSequence[Index],
> NULL);
> 
> -    Index++;
> 
> -  }
> 
> -
> 
> -  //
> 
> -  // Just use the simple policy to connect all devices
> 
> -  //
> 
> -  DEBUG ((EFI_D_INFO, "EfiBootManagerConnectAll\n"));
> 
> -  EfiBootManagerConnectAll ();
> 
> -
> 
> -  PciAcpiInitialization ();
> 
> -}
> 
> -
> 
> -/**
> 
> -  Do the platform specific action after the console is ready
> 
> -
> 
> -  Possible things that can be done in PlatformBootManagerAfterConsole:
> 
> -
> 
> -  > Console post action:
> 
> -    > Dynamically switch output mode from 100x31 to 80x25 for certain
> senarino
> 
> -    > Signal console ready platform customized event
> 
> -  > Run diagnostics like memory testing
> 
> -  > Connect certain devices
> 
> -  > Dispatch aditional option roms
> 
> -  > Special boot: e.g.: USB boot, enter UI
> 
> -**/
> 
> -VOID
> 
> -EFIAPI
> 
> -PlatformBootManagerAfterConsole (
> 
> -  VOID
> 
> -  )
> 
> -{
> 
> -  EFI_BOOT_MODE                      BootMode;
> 
> -  EFI_HANDLE                         Handle;
> 
> -  EFI_STATUS                         Status;
> 
> -
> 
> -  DEBUG ((EFI_D_INFO, "PlatformBootManagerAfterConsole\n"));
> 
> -
> 
> -  //
> 
> -  // Prevent further changes to LockBoxes or SMRAM.
> 
> -  //
> 
> -  Handle = NULL;
> 
> -  Status = gBS->InstallProtocolInterface(&Handle,
> 
> -    &gEfiDxeSmmReadyToLockProtocolGuid, EFI_NATIVE_INTERFACE,
> 
> -      NULL);
> 
> -  ASSERT_EFI_ERROR(Status);
> 
> -
> 
> -  if (PcdGetBool (PcdOvmfFlashVariablesEnable)) {
> 
> -    DEBUG ((EFI_D_INFO, "PlatformBdsPolicyBehavior: not restoring NvVars "
> 
> -      "from disk since flash variables appear to be supported.\n"));
> 
> -  } else {
> 
> -    //
> 
> -    // Try to restore variables from the hard disk early so
> 
> -    // they can be used for the other BDS connect operations.
> 
> -    //
> 
> -    PlatformBdsRestoreNvVarsFromHardDisk ();
> 
> -  }
> 
> -
> 
> -  //
> 
> -  // Get current Boot Mode
> 
> -  //
> 
> -  BootMode = GetBootModeHob ();
> 
> -  DEBUG ((EFI_D_ERROR, "Boot Mode:%x\n", BootMode));
> 
> -
> 
> -  //
> 
> -  // Go the different platform policy with different boot mode
> 
> -  // Notes: this part code can be change with the table policy
> 
> -  //
> 
> -  ASSERT (BootMode == BOOT_WITH_FULL_CONFIGURATION);
> 
> -
> 
> -  // Perform some platform specific connect sequence
> 
> -  //
> 
> -  PlatformBdsConnectSequence ();
> 
> -  //
> 
> -  // Logo show
> 
> -  //
> 
> -  EnableBootLogo(PcdGetPtr(PcdLogoFile));
> 
> -
> 
> -  EfiBootManagerRefreshAllBootOption ();
> 
> -
> 
> -  //
> 
> -  // Register UEFI Shell
> 
> -  //
> 
> -  PlatformRegisterFvBootOption (
> 
> -    PcdGetPtr (PcdShellFile), L"EFI Internal Shell", LOAD_OPTION_ACTIVE
> 
> -    );
> 
> -
> 
> -  RemoveStaleFvFileOptions ();
> 
> -}
> 
> -
> 
> -/**
> 
> -  This notification function is invoked when an instance of the
> 
> -  EFI_DEVICE_PATH_PROTOCOL is produced.
> 
> -
> 
> -  @param  Event                 The event that occurred
> 
> -  @param  Context               For EFI compatibility.  Not used.
> 
> -
> 
> -**/
> 
> -VOID
> 
> -EFIAPI
> 
> -NotifyDevPath (
> 
> -  IN  EFI_EVENT Event,
> 
> -  IN  VOID      *Context
> 
> -  )
> 
> -{
> 
> -  EFI_HANDLE                            Handle;
> 
> -  EFI_STATUS                            Status;
> 
> -  UINTN                                 BufferSize;
> 
> -  EFI_DEVICE_PATH_PROTOCOL             *DevPathNode;
> 
> -  ATAPI_DEVICE_PATH                    *Atapi;
> 
> -
> 
> -  //
> 
> -  // Examine all new handles
> 
> -  //
> 
> -  for (;;) {
> 
> -    //
> 
> -    // Get the next handle
> 
> -    //
> 
> -    BufferSize = sizeof (Handle);
> 
> -    Status = gBS->LocateHandle (
> 
> -              ByRegisterNotify,
> 
> -              NULL,
> 
> -              mEfiDevPathNotifyReg,
> 
> -              &BufferSize,
> 
> -              &Handle
> 
> -              );
> 
> -
> 
> -    //
> 
> -    // If not found, we're done
> 
> -    //
> 
> -    if (EFI_NOT_FOUND == Status) {
> 
> -      break;
> 
> -    }
> 
> -
> 
> -    if (EFI_ERROR (Status)) {
> 
> -      continue;
> 
> -    }
> 
> -
> 
> -    //
> 
> -    // Get the DevicePath protocol on that handle
> 
> -    //
> 
> -    Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid,
> (VOID **)&DevPathNode);
> 
> -    ASSERT_EFI_ERROR (Status);
> 
> -
> 
> -    while (!IsDevicePathEnd (DevPathNode)) {
> 
> -      //
> 
> -      // Find the handler to dump this device path node
> 
> -      //
> 
> -      if (
> 
> -           (DevicePathType(DevPathNode) == MESSAGING_DEVICE_PATH) &&
> 
> -           (DevicePathSubType(DevPathNode) == MSG_ATAPI_DP)
> 
> -         ) {
> 
> -        Atapi = (ATAPI_DEVICE_PATH*) DevPathNode;
> 
> -        PciOr16 (
> 
> -          PCI_LIB_ADDRESS (
> 
> -            0,
> 
> -            1,
> 
> -            1,
> 
> -            (Atapi->PrimarySecondary == 1) ? 0x42: 0x40
> 
> -            ),
> 
> -          BIT15
> 
> -          );
> 
> -      }
> 
> -
> 
> -      //
> 
> -      // Next device path node
> 
> -      //
> 
> -      DevPathNode = NextDevicePathNode (DevPathNode);
> 
> -    }
> 
> -  }
> 
> -
> 
> -  return;
> 
> -}
> 
> -
> 
> -
> 
> -VOID
> 
> -InstallDevicePathCallback (
> 
> -  VOID
> 
> -  )
> 
> -{
> 
> -  DEBUG ((EFI_D_INFO, "Registered NotifyDevPath Event\n"));
> 
> -  mEfiDevPathEvent = EfiCreateProtocolNotifyEvent (
> 
> -                          &gEfiDevicePathProtocolGuid,
> 
> -                          TPL_CALLBACK,
> 
> -                          NotifyDevPath,
> 
> -                          NULL,
> 
> -                          &mEfiDevPathNotifyReg
> 
> -                          );
> 
> -}
> 
> -
> 
> -/**
> 
> -  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
> 
> -  )
> 
> -{
> 
> -  // BUGBUG- will do it if need
> 
> -}
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/Bds
> Platform.h
> b/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/Bds
> Platform.h
> deleted file mode 100644
> index 01ba20d2da..0000000000
> ---
> a/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/Bds
> Platform.h
> +++ /dev/null
> @@ -1,172 +0,0 @@
> -/** @file
> 
> -  Platform BDS customizations include file.
> 
> -
> 
> -  Copyright (c) 2006 - 2019 Intel Corporation. All rights reserved. <BR>
> 
> -
> 
> -  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> -**/
> 
> -
> 
> -#ifndef _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
> 
> -#define _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
> 
> -
> 
> -
> 
> -#include <PiDxe.h>
> 
> -
> 
> -#include <IndustryStandard/Pci.h>
> 
> -#include <IndustryStandard/Acpi.h>
> 
> -#include <IndustryStandard/SmBios.h>
> 
> -#include <IndustryStandard/PeImage.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/PciLib.h>
> 
> -#include <Library/UefiBootManagerLib.h>
> 
> -#include <Library/BootLogoLib.h>
> 
> -#include <Library/HobLib.h>
> 
> -#include <Library/UefiLib.h>
> 
> -#include <Library/DxeServicesTableLib.h>
> 
> -#include <Library/DevicePathLib.h>
> 
> -#include <Library/IoLib.h>
> 
> -#include <Library/NvVarsFileLib.h>
> 
> -
> 
> -#include <Protocol/Decompress.h>
> 
> -#include <Protocol/PciIo.h>
> 
> -#include <Protocol/FirmwareVolume2.h>
> 
> -#include <Protocol/SimpleFileSystem.h>
> 
> -#include <Protocol/PciRootBridgeIo.h>
> 
> -#include <Protocol/S3SaveState.h>
> 
> -#include <Protocol/DxeSmmReadyToLock.h>
> 
> -#include <Protocol/LoadedImage.h>
> 
> -
> 
> -#include <Guid/Acpi.h>
> 
> -#include <Guid/SmBios.h>
> 
> -#include <Guid/Mps.h>
> 
> -#include <Guid/HobList.h>
> 
> -#include <Guid/GlobalVariable.h>
> 
> -#include <Guid/EventGroup.h>
> 
> -
> 
> -#include <SimicsPlatforms.h>
> 
> -
> 
> -extern EFI_DEVICE_PATH_PROTOCOL   *gPlatformConnectSequence[];
> 
> -extern ACPI_HID_DEVICE_PATH       gPnpPs2KeyboardDeviceNode;
> 
> -extern ACPI_HID_DEVICE_PATH       gPnp16550ComPortDeviceNode;
> 
> -extern UART_DEVICE_PATH           gUartDeviceNode;
> 
> -extern VENDOR_DEVICE_PATH         gTerminalTypeDeviceNode;
> 
> -
> 
> -#define PCI_DEVICE_PATH_NODE(Func, Dev) \
> 
> -  { \
> 
> -    { \
> 
> -      HARDWARE_DEVICE_PATH, \
> 
> -      HW_PCI_DP, \
> 
> -      { \
> 
> -        (UINT8) (sizeof (PCI_DEVICE_PATH)), \
> 
> -        (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8) \
> 
> -      } \
> 
> -    }, \
> 
> -    (Func), \
> 
> -    (Dev) \
> 
> -  }
> 
> -
> 
> -#define PNPID_DEVICE_PATH_NODE(PnpId) \
> 
> -  { \
> 
> -    { \
> 
> -      ACPI_DEVICE_PATH, \
> 
> -      ACPI_DP, \
> 
> -      { \
> 
> -        (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
> 
> -        (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
> 
> -      }, \
> 
> -    }, \
> 
> -    EISA_PNP_ID((PnpId)), \
> 
> -    0 \
> 
> -  }
> 
> -
> 
> -#define gPciIsaBridge \
> 
> -  PCI_DEVICE_PATH_NODE(0, 0x1f)
> 
> -
> 
> -#define gP2PBridge \
> 
> -  PCI_DEVICE_PATH_NODE(0, 0x1e)
> 
> -
> 
> -#define gPnpPs2Keyboard \
> 
> -  PNPID_DEVICE_PATH_NODE(0x0303)
> 
> -
> 
> -#define gPnp16550ComPort \
> 
> -  PNPID_DEVICE_PATH_NODE(0x0501)
> 
> -
> 
> -#define gUart \
> 
> -  { \
> 
> -    { \
> 
> -      MESSAGING_DEVICE_PATH, \
> 
> -      MSG_UART_DP, \
> 
> -      { \
> 
> -        (UINT8) (sizeof (UART_DEVICE_PATH)), \
> 
> -        (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8) \
> 
> -      } \
> 
> -    }, \
> 
> -    0, \
> 
> -    115200, \
> 
> -    8, \
> 
> -    1, \
> 
> -    1 \
> 
> -  }
> 
> -
> 
> -#define gPcAnsiTerminal \
> 
> -  { \
> 
> -    { \
> 
> -      MESSAGING_DEVICE_PATH, \
> 
> -      MSG_VENDOR_DP, \
> 
> -      { \
> 
> -        (UINT8) (sizeof (VENDOR_DEVICE_PATH)), \
> 
> -        (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) \
> 
> -      } \
> 
> -    }, \
> 
> -    DEVICE_PATH_MESSAGING_PC_ANSI \
> 
> -  }
> 
> -
> 
> -#define PCI_CLASS_SCC          0x07
> 
> -#define PCI_SUBCLASS_SERIAL    0x00
> 
> -#define PCI_IF_16550           0x02
> 
> -#define IS_PCI_16550SERIAL(_p)           IS_CLASS3 (_p, PCI_CLASS_SCC,
> PCI_SUBCLASS_SERIAL, PCI_IF_16550)
> 
> -#define IS_PCI_ISA_PDECODE(_p)        IS_CLASS3 (_p, PCI_CLASS_BRIDGE,
> PCI_CLASS_BRIDGE_ISA_PDECODE, 0)
> 
> -
> 
> -typedef struct {
> 
> -  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
> 
> -  UINTN                     ConnectType;
> 
> -} PLATFORM_CONSOLE_CONNECT_ENTRY;
> 
> -
> 
> -#define CONSOLE_OUT BIT0
> 
> -#define CONSOLE_IN  BIT1
> 
> -#define STD_ERROR   BIT2
> 
> -extern PLATFORM_CONSOLE_CONNECT_ENTRY  gPlatformConsole[];
> 
> -
> 
> -//
> 
> -// Platform BDS Functions
> 
> -//
> 
> -
> 
> -VOID
> 
> -PlatformInitializeConsole (
> 
> -  IN PLATFORM_CONSOLE_CONNECT_ENTRY   *PlatformConsole
> 
> -  );
> 
> -
> 
> -/**
> 
> -  Use SystemTable ConOut to stop video based Simple Text Out consoles from
> going
> 
> -  to the video device. Put up LogoFile on every video device that is a console.
> 
> -
> 
> -  @param[in]  LogoFile   The file name of logo to display on the center of the
> screen.
> 
> -
> 
> -  @retval EFI_SUCCESS     ConsoleControl has been flipped to graphics and
> logo displayed.
> 
> -  @retval EFI_UNSUPPORTED Logo not found.
> 
> -
> 
> -**/
> 
> -EFI_STATUS
> 
> -EFIAPI
> 
> -EnableBootLogo(
> 
> -  IN  EFI_GUID  *LogoFile
> 
> -);
> 
> -
> 
> -#endif // _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/Pla
> tformBootManagerLib.inf
> b/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/Pla
> tformBootManagerLib.inf
> deleted file mode 100644
> index 3fb76c3564..0000000000
> ---
> a/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/Pla
> tformBootManagerLib.inf
> +++ /dev/null
> @@ -1,72 +0,0 @@
> -## @file
> 
> -#  Platform BDS customizations library.
> 
> -#
> 
> -# Copyright (c) 2007 - 2019 Intel Corporation. All rights reserved. <BR>
> 
> -#
> 
> -# SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> -#
> 
> -##
> 
> -
> 
> -[Defines]
> 
> -  INF_VERSION                    = 0x00010005
> 
> -  BASE_NAME                      = PlatformBootManagerLib
> 
> -  FILE_GUID                      = 8AE4756F-0C71-4C06-84D4-4C71F204D514
> 
> -  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 EBC
> 
> -#
> 
> -
> 
> -[Sources]
> 
> -  BdsPlatform.c
> 
> -  PlatformData.c
> 
> -  BdsPlatform.h
> 
> -
> 
> -[Packages]
> 
> -  MdePkg/MdePkg.dec
> 
> -  MdeModulePkg/MdeModulePkg.dec
> 
> -  SimicsOpenBoardPkg/OpenBoardPkg.dec
> 
> -  OvmfPkg/OvmfPkg.dec
> 
> -  SimicsIch10Pkg/Ich10Pkg.dec
> 
> -
> 
> -[LibraryClasses]
> 
> -  BaseLib
> 
> -  MemoryAllocationLib
> 
> -  UefiBootServicesTableLib
> 
> -  BaseMemoryLib
> 
> -  DebugLib
> 
> -  PcdLib
> 
> -  UefiBootManagerLib
> 
> -  BootLogoLib
> 
> -  DevicePathLib
> 
> -  PciLib
> 
> -  NvVarsFileLib
> 
> -  DxeLoadLinuxLib
> 
> -  UefiLib
> 
> -  LogoLib
> 
> -
> 
> -[Pcd]
> 
> -  gSimicsOpenBoardPkgTokenSpaceGuid.PcdEmuVariableEvent
> 
> -  gSimicsOpenBoardPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable
> 
> -  gSimicsOpenBoardPkgTokenSpaceGuid.PcdSimicsX58HostBridgePciDevId
> 
> -  gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
> 
> -  gSimicsOpenBoardPkgTokenSpaceGuid.PcdShellFile
> 
> -  gSimicsOpenBoardPkgTokenSpaceGuid.PcdLogoFile
> 
> -
> 
> -[Pcd.IA32, Pcd.X64]
> 
> -  gEfiMdePkgTokenSpaceGuid.PcdFSBClock
> 
> -
> 
> -[Protocols]
> 
> -  gEfiDecompressProtocolGuid
> 
> -  gEfiPciRootBridgeIoProtocolGuid
> 
> -  gEfiS3SaveStateProtocolGuid                   # PROTOCOL
> SOMETIMES_CONSUMED
> 
> -  gEfiDxeSmmReadyToLockProtocolGuid             # PROTOCOL
> SOMETIMES_PRODUCED
> 
> -  gEfiLoadedImageProtocolGuid                   # PROTOCOL
> SOMETIMES_PRODUCED
> 
> -  gEfiFirmwareVolume2ProtocolGuid               # PROTOCOL
> SOMETIMES_CONSUMED
> 
> -
> 
> -[Guids]
> 
> -  gEfiEndOfDxeEventGroupGuid
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/Pla
> tformData.c
> b/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/Pla
> tformData.c
> deleted file mode 100644
> index 768843a8bf..0000000000
> ---
> a/Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/Pla
> tformData.c
> +++ /dev/null
> @@ -1,35 +0,0 @@
> -/** @file
> 
> -  Defined the platform specific device path which will be used by
> 
> -  platform Bbd to perform the platform policy connect.
> 
> -
> 
> -  Copyright (c) 2004 - 2019 Intel Corporation. All rights reserved. <BR>
> 
> -
> 
> -  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> -**/
> 
> -
> 
> -#include "BdsPlatform.h"
> 
> -
> 
> -ACPI_HID_DEVICE_PATH       gPnpPs2KeyboardDeviceNode  =
> gPnpPs2Keyboard;
> 
> -ACPI_HID_DEVICE_PATH       gPnp16550ComPortDeviceNode =
> gPnp16550ComPort;
> 
> -UART_DEVICE_PATH           gUartDeviceNode            = gUart;
> 
> -VENDOR_DEVICE_PATH         gTerminalTypeDeviceNode    = gPcAnsiTerminal;
> 
> -
> 
> -//
> 
> -// Platform specific keyboard device path
> 
> -//
> 
> -
> 
> -//
> 
> -// Predefined platform default console device path
> 
> -//
> 
> -PLATFORM_CONSOLE_CONNECT_ENTRY   gPlatformConsole[] = {
> 
> -  {
> 
> -    NULL,
> 
> -    0
> 
> -  }
> 
> -};
> 
> -
> 
> -//
> 
> -// Predefined platform connect sequence
> 
> -//
> 
> -EFI_DEVICE_PATH_PROTOCOL    *gPlatformConnectSequence[] = { NULL };
> 
> -
> 
> --
> 2.39.1.windows.1
> 
> 
> 
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#105230):
> https://edk2.groups.io/g/devel/message/105230
> Mute This Topic: https://groups.io/mt/99107253/1712937
> Group Owner: devel+owner@edk2.groups.io
> Unsubscribe:
> https://edk2.groups.io/g/devel/leave/3759105/1712937/893644498/xyzzy
> [ray.ni@intel.com]
> -=-=-=-=-=-=
> 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [edk2-devel] [PATCH 2/6] SimicsOpenBoardPkg: Remove logic that loads variable from disk file
       [not found] ` <17621421B6E6FB43.8048@groups.io>
@ 2023-05-25  2:10   ` Ni, Ray
  0 siblings, 0 replies; 15+ messages in thread
From: Ni, Ray @ 2023-05-25  2:10 UTC (permalink / raw)
  To: devel@edk2.groups.io, Ni, Ray, Liu, Zhiguang
  Cc: Desimone, Nathaniel L, Kinney, Michael D

Sending to correct address of Zhiguang.

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Ni, Ray
> Sent: Wednesday, May 24, 2023 8:29 PM
> To: devel@edk2.groups.io
> Cc: Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Zhiguang Liu
> <zhiguang@liu@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: [edk2-devel] [PATCH 2/6] SimicsOpenBoardPkg: Remove logic that
> loads variable from disk file
> 
> Simics QSP platform always supports flash devices.
> The logic that was ported from OVMF where the flash devices might
> not be supported in some configurations is useless in QSP platform.
> So, the patch removes all of them.
> 
> Signed-off-by: Ray Ni <ray.ni@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Zhiguang Liu <zhiguang@liu@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> ---
>  .../BoardX58Ich10/OpenBoardPkg.dsc            |   2 -
>  .../Include/Library/SerializeVariablesLib.h   | 224 -----
>  .../Library/BoardBdsHookLib/BoardBdsHookLib.c | 124 ---
>  .../BoardBdsHookLib/BoardBdsHookLib.inf       |   3 -
>  .../Library/NvVarsFileLib/FsAccess.c          | 507 ----------
>  .../Library/NvVarsFileLib/NvVarsFileLib.c     |  77 --
>  .../Library/NvVarsFileLib/NvVarsFileLib.h     |  55 --
>  .../Library/NvVarsFileLib/NvVarsFileLib.inf   |  53 --
>  .../SerializeVariablesLib.c                   | 869 ------------------
>  .../SerializeVariablesLib.h                   |  33 -
>  .../SerializeVariablesLib.inf                 |  36 -
>  .../Intel/SimicsOpenBoardPkg/OpenBoardPkg.dec |   3 -
>  12 files changed, 1986 deletions(-)
>  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Include/Library/SerializeVariablesLib.h
>  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/FsAccess.c
>  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.c
>  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.h
>  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
>  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeVari
> ablesLib.c
>  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeVari
> ablesLib.h
>  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeVari
> ablesLib.inf
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
> index 5ac260a26f..4e8991dbdf 100644
> ---
> a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
> +++
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
> @@ -114,9 +114,7 @@
>    #######################################
> 
>    DxeLoadLinuxLib|$(BOARD_PKG)/Library/LoadLinuxLib/DxeLoadLinuxLib.inf
> 
>    LogoLib|$(BOARD_PKG)/Library/DxeLogoLib/DxeLogoLib.inf
> 
> -  NvVarsFileLib|$(BOARD_PKG)/Library/NvVarsFileLib/NvVarsFileLib.inf
> 
>    ReportFvLib|$(BOARD_PKG)/Library/PeiReportFvLib/PeiReportFvLib.inf
> 
> -
> SerializeVariablesLib|$(BOARD_PKG)/Library/SerializeVariablesLib/SerializeVari
> ablesLib.inf
> 
> 
> SiliconPolicyInitLib|$(BOARD_PKG)/Policy/Library/SiliconPolicyInitLib/SiliconPo
> licyInitLib.inf
> 
> 
> SiliconPolicyUpdateLib|$(BOARD_PKG)/Policy/Library/SiliconPolicyUpdateLib/
> SiliconPolicyUpdateLib.inf
> 
> 
> PlatformCmosAccessLib|BoardModulePkg/Library/PlatformCmosAccessLibNu
> ll/PlatformCmosAccessLibNull.inf
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/Include/Library/SerializeVariablesLib.h
> b/Platform/Intel/SimicsOpenBoardPkg/Include/Library/SerializeVariablesLib.h
> deleted file mode 100644
> index c32f97d787..0000000000
> ---
> a/Platform/Intel/SimicsOpenBoardPkg/Include/Library/SerializeVariablesLib.h
> +++ /dev/null
> @@ -1,224 +0,0 @@
> -/** @file
> 
> -  Serialize & Deserialize UEFI Variables
> 
> -
> 
> -  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> 
> -
> 
> -  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> -
> 
> -**/
> 
> -
> 
> -#ifndef __SERIALIZE_VARIABLES_LIB__
> 
> -#define __SERIALIZE_VARIABLES_LIB__
> 
> -
> 
> -
> 
> -/**
> 
> -  Callback function for each variable
> 
> -
> 
> -  @param[in] Context - Context as sent to the iteration function
> 
> -  @param[in] VariableName - Refer to RuntimeServices GetNextVariableName
> 
> -  @param[in] VendorGuid - Refer to RuntimeServices GetNextVariableName
> 
> -  @param[in] Attributes - Refer to RuntimeServices GetVariable
> 
> -  @param[in] DataSize - Refer to RuntimeServices GetVariable
> 
> -  @param[in] Data - Refer to RuntimeServices GetVariable
> 
> -
> 
> -  @retval RETURN_SUCCESS         Continue iterating through the variables
> 
> -  @return Any RETURN_ERROR       Stop iterating through the variables
> 
> -
> 
> -**/
> 
> -typedef
> 
> -RETURN_STATUS
> 
> -(EFIAPI *VARIABLE_SERIALIZATION_ITERATION_CALLBACK)(
> 
> -  IN  VOID                         *Context,
> 
> -  IN  CHAR16                       *VariableName,
> 
> -  IN  EFI_GUID                     *VendorGuid,
> 
> -  IN  UINT32                       Attributes,
> 
> -  IN  UINTN                        DataSize,
> 
> -  IN  VOID                         *Data
> 
> -  );
> 
> -
> 
> -
> 
> -/**
> 
> -  Creates a new variable serialization instance
> 
> -
> 
> -  @param[out]  Handle - Handle for a variable serialization instance
> 
> -
> 
> -  @retval      RETURN_SUCCESS - The variable serialization instance was
> 
> -                 successfully created.
> 
> -  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources
> to
> 
> -                 create the variable serialization instance.
> 
> -
> 
> -**/
> 
> -RETURN_STATUS
> 
> -EFIAPI
> 
> -SerializeVariablesNewInstance (
> 
> -  OUT EFI_HANDLE                      *Handle
> 
> -  );
> 
> -
> 
> -
> 
> -/**
> 
> -  Free memory associated with a variable serialization instance
> 
> -
> 
> -  @param[in]  Handle - Handle for a variable serialization instance
> 
> -
> 
> -  @retval      RETURN_SUCCESS - The variable serialization instance was
> 
> -                 successfully freed.
> 
> -  @retval      RETURN_INVALID_PARAMETER - Handle was not a valid
> 
> -                 variable serialization instance.
> 
> -
> 
> -**/
> 
> -RETURN_STATUS
> 
> -EFIAPI
> 
> -SerializeVariablesFreeInstance (
> 
> -  IN EFI_HANDLE Handle
> 
> -  );
> 
> -
> 
> -
> 
> -/**
> 
> -  Creates a new variable serialization instance using the given
> 
> -  binary representation of the variables to fill the new instance
> 
> -
> 
> -  @param[out] Handle - Handle for a variable serialization instance
> 
> -  @param[in]  Buffer - A buffer with the serialized representation
> 
> -                of the variables.  Must be the same format as produced
> 
> -                by SerializeVariablesToBuffer.
> 
> -  @param[in]  Size - This is the size of the binary representation
> 
> -                of the variables.
> 
> -
> 
> -  @retval      RETURN_SUCCESS - The binary representation was successfully
> 
> -                 imported into a new variable serialization instance
> 
> -  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources
> to
> 
> -                 create the new variable serialization instance
> 
> -
> 
> -**/
> 
> -RETURN_STATUS
> 
> -EFIAPI
> 
> -SerializeVariablesNewInstanceFromBuffer (
> 
> -  OUT EFI_HANDLE                          *Handle,
> 
> -  IN  VOID                                *Buffer,
> 
> -  IN  UINTN                               Size
> 
> -  );
> 
> -
> 
> -
> 
> -/**
> 
> -  Iterates all variables found with RuntimeServices GetNextVariableName
> 
> -
> 
> -  @param[in]   CallbackFunction - Function called for each variable instance
> 
> -  @param[in]   Context - Passed to each call of CallbackFunction
> 
> -
> 
> -  @retval      RETURN_SUCCESS - All variables were iterated without the
> 
> -                 CallbackFunction returning an error
> 
> -  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources
> to
> 
> -                 iterate through the variables
> 
> -  @return      Any of RETURN_ERROR indicates an error reading the variable
> 
> -                 or an error was returned from CallbackFunction
> 
> -
> 
> -**/
> 
> -RETURN_STATUS
> 
> -EFIAPI
> 
> -SerializeVariablesIterateSystemVariables (
> 
> -  IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction,
> 
> -  IN VOID                                      *Context
> 
> -  );
> 
> -
> 
> -
> 
> -/**
> 
> -  Iterates all variables found in the variable serialization instance
> 
> -
> 
> -  @param[in]   Handle - Handle for a variable serialization instance
> 
> -  @param[in]   CallbackFunction - Function called for each variable instance
> 
> -  @param[in]   Context - Passed to each call of CallbackFunction
> 
> -
> 
> -  @retval      RETURN_SUCCESS - All variables were iterated without the
> 
> -                 CallbackFunction returning an error
> 
> -  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources
> to
> 
> -                 iterate through the variables
> 
> -  @return      Any of RETURN_ERROR indicates an error reading the variable
> 
> -                 or an error was returned from CallbackFunction
> 
> -
> 
> -**/
> 
> -RETURN_STATUS
> 
> -EFIAPI
> 
> -SerializeVariablesIterateInstanceVariables (
> 
> -  IN EFI_HANDLE                                Handle,
> 
> -  IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction,
> 
> -  IN VOID                                      *Context
> 
> -  );
> 
> -
> 
> -
> 
> -/**
> 
> -  Sets all variables found in the variable serialization instance
> 
> -
> 
> -  @param[in]   Handle - Handle for a variable serialization instance
> 
> -
> 
> -  @retval      RETURN_SUCCESS - All variables were set successfully
> 
> -  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources
> to
> 
> -                 set all the variables
> 
> -  @return      Any of RETURN_ERROR indicates an error reading the variables
> 
> -                 or in attempting to set a variable
> 
> -
> 
> -**/
> 
> -RETURN_STATUS
> 
> -EFIAPI
> 
> -SerializeVariablesSetSerializedVariables (
> 
> -  IN EFI_HANDLE                       Handle
> 
> -  );
> 
> -
> 
> -
> 
> -/**
> 
> -  Adds a variable to the variable serialization instance
> 
> -
> 
> -  @param[in] Handle - Handle for a variable serialization instance
> 
> -  @param[in] VariableName - Refer to RuntimeServices GetVariable
> 
> -  @param[in] VendorGuid - Refer to RuntimeServices GetVariable
> 
> -  @param[in] Attributes - Refer to RuntimeServices GetVariable
> 
> -  @param[in] DataSize - Refer to RuntimeServices GetVariable
> 
> -  @param[in] Data - Refer to RuntimeServices GetVariable
> 
> -
> 
> -  @retval      RETURN_SUCCESS - All variables were set successfully
> 
> -  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources
> to
> 
> -                 add the variable
> 
> -
> 
> -**/
> 
> -RETURN_STATUS
> 
> -EFIAPI
> 
> -SerializeVariablesAddVariable (
> 
> -  IN EFI_HANDLE                   Handle,
> 
> -  IN CHAR16                       *VariableName,
> 
> -  IN EFI_GUID                     *VendorGuid,
> 
> -  IN UINT32                       Attributes,
> 
> -  IN UINTN                        DataSize,
> 
> -  IN VOID                         *Data
> 
> -  );
> 
> -
> 
> -
> 
> -/**
> 
> -  Serializes the variables known to this instance into the
> 
> -  provided buffer.
> 
> -
> 
> -  @param[in]     Handle - Handle for a variable serialization instance
> 
> -  @param[out]    Buffer - A buffer to store the binary representation
> 
> -                   of the variables.
> 
> -  @param[in,out] Size - On input this is the size of the buffer.
> 
> -                   On output this is the size of the binary representation
> 
> -                   of the variables.
> 
> -
> 
> -  @retval      RETURN_SUCCESS - The binary representation was successfully
> 
> -                 completed and returned in the buffer.
> 
> -  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources
> to
> 
> -                 save the variables to the buffer.
> 
> -  @retval      RETURN_INVALID_PARAMETER - Handle was not a valid
> 
> -                 variable serialization instance or
> 
> -                 Size or Buffer were NULL.
> 
> -
> 
> -**/
> 
> -RETURN_STATUS
> 
> -EFIAPI
> 
> -SerializeVariablesToBuffer (
> 
> -  IN     EFI_HANDLE                       Handle,
> 
> -  OUT    VOID                             *Buffer,
> 
> -  IN OUT UINTN                            *Size
> 
> -  );
> 
> -
> 
> -
> 
> -#endif
> 
> -
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsH
> ookLib.c
> b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsH
> ookLib.c
> index ba4d2b02d8..3c6385c12f 100644
> ---
> a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsH
> ookLib.c
> +++
> b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsH
> ookLib.c
> @@ -1111,119 +1111,6 @@ PciAcpiInitialization (
>    Interrupt8259WriteMask(0xFFFF, 0x0000);
> 
>  }
> 
> 
> 
> -EFI_STATUS
> 
> -EFIAPI
> 
> -ConnectRecursivelyIfPciMassStorage (
> 
> -  IN EFI_HANDLE           Handle,
> 
> -  IN EFI_PCI_IO_PROTOCOL  *Instance,
> 
> -  IN PCI_TYPE00           *PciHeader
> 
> -  )
> 
> -{
> 
> -  EFI_STATUS                Status;
> 
> -  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
> 
> -  CHAR16                    *DevPathStr;
> 
> -
> 
> -  //
> 
> -  // Recognize PCI Mass Storage
> 
> -  //
> 
> -  if (IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE)) {
> 
> -    DevicePath = NULL;
> 
> -    Status = gBS->HandleProtocol (
> 
> -                    Handle,
> 
> -                    &gEfiDevicePathProtocolGuid,
> 
> -                    (VOID*)&DevicePath
> 
> -                    );
> 
> -    if (EFI_ERROR (Status)) {
> 
> -      return Status;
> 
> -    }
> 
> -
> 
> -    //
> 
> -    // Print Device Path
> 
> -    //
> 
> -    DevPathStr = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
> 
> -    if (DevPathStr != NULL) {
> 
> -      DEBUG(( DEBUG_INFO, "Found Mass Storage device: %s\n", DevPathStr));
> 
> -      FreePool(DevPathStr);
> 
> -    }
> 
> -
> 
> -    Status = gBS->ConnectController (Handle, NULL, NULL, TRUE);
> 
> -    if (EFI_ERROR (Status)) {
> 
> -      return Status;
> 
> -    }
> 
> -
> 
> -   }
> 
> -
> 
> -  return EFI_SUCCESS;
> 
> -}
> 
> -
> 
> -
> 
> -/**
> 
> -  This notification function is invoked when the
> 
> -  EMU Variable FVB has been changed.
> 
> -
> 
> -  @param  Event                 The event that occurred
> 
> -  @param  Context               For EFI compatibility.  Not used.
> 
> -
> 
> -**/
> 
> -VOID
> 
> -EFIAPI
> 
> -EmuVariablesUpdatedCallback (
> 
> -  IN  EFI_EVENT Event,
> 
> -  IN  VOID      *Context
> 
> -  )
> 
> -{
> 
> -  DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
> 
> -  UpdateNvVarsOnFileSystem ();
> 
> -}
> 
> -
> 
> -
> 
> -EFI_STATUS
> 
> -EFIAPI
> 
> -VisitingFileSystemInstance (
> 
> -  IN EFI_HANDLE  Handle,
> 
> -  IN VOID        *Instance,
> 
> -  IN VOID        *Context
> 
> -  )
> 
> -{
> 
> -  EFI_STATUS      Status;
> 
> -  STATIC BOOLEAN  ConnectedToFileSystem = FALSE;
> 
> -
> 
> -  if (ConnectedToFileSystem) {
> 
> -    return EFI_ALREADY_STARTED;
> 
> -  }
> 
> -
> 
> -  Status = ConnectNvVarsToFileSystem (Handle);
> 
> -  if (EFI_ERROR (Status)) {
> 
> -    return Status;
> 
> -  }
> 
> -
> 
> -  ConnectedToFileSystem = TRUE;
> 
> -  mEmuVariableEvent =
> 
> -    EfiCreateProtocolNotifyEvent (
> 
> -      &gEfiDevicePathProtocolGuid,
> 
> -      TPL_CALLBACK,
> 
> -      EmuVariablesUpdatedCallback,
> 
> -      NULL,
> 
> -      &mEmuVariableEventReg
> 
> -      );
> 
> -  PcdSet64S (PcdEmuVariableEvent, (UINT64)(UINTN) mEmuVariableEvent);
> 
> -
> 
> -  return EFI_SUCCESS;
> 
> -}
> 
> -
> 
> -
> 
> -VOID
> 
> -PlatformBdsRestoreNvVarsFromHardDisk (
> 
> -  )
> 
> -{
> 
> -  VisitAllPciInstances (ConnectRecursivelyIfPciMassStorage);
> 
> -  VisitAllInstancesOfProtocol (
> 
> -    &gEfiSimpleFileSystemProtocolGuid,
> 
> -    VisitingFileSystemInstance,
> 
> -    NULL
> 
> -    );
> 
> -}
> 
> -
> 
>  /**
> 
>    Connect with predefined platform connect sequence.
> 
> 
> 
> @@ -1584,17 +1471,6 @@ BdsAfterConsoleReadyBeforeBootOptionCallback
> (
> 
> 
>    DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
> 
> 
> 
> -  if (PcdGetBool (PcdOvmfFlashVariablesEnable)) {
> 
> -    DEBUG ((DEBUG_INFO, "PlatformBdsPolicyBehavior: not restoring NvVars "
> 
> -      "from disk since flash variables appear to be supported.\n"));
> 
> -  } else {
> 
> -    //
> 
> -    // Try to restore variables from the hard disk early so
> 
> -    // they can be used for the other BDS connect operations.
> 
> -    //
> 
> -    PlatformBdsRestoreNvVarsFromHardDisk ();
> 
> -  }
> 
> -
> 
>    //
> 
>    // Get current Boot Mode
> 
>    //
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsH
> ookLib.inf
> b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsH
> ookLib.inf
> index a77edf2699..bcfbdca996 100644
> ---
> a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsH
> ookLib.inf
> +++
> b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsH
> ookLib.inf
> @@ -45,14 +45,11 @@
>    BootLogoLib
> 
>    DevicePathLib
> 
>    PciLib
> 
> -  NvVarsFileLib
> 
>    DxeLoadLinuxLib
> 
>    UefiLib
> 
>    LogoLib
> 
> 
> 
>  [Pcd]
> 
> -  gSimicsOpenBoardPkgTokenSpaceGuid.PcdEmuVariableEvent
> 
> -  gSimicsOpenBoardPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable
> 
>    gSimicsOpenBoardPkgTokenSpaceGuid.PcdSimicsX58HostBridgePciDevId
> 
>    gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
> 
>    gSimicsOpenBoardPkgTokenSpaceGuid.PcdShellFile
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/FsAccess.c
> b/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/FsAccess.c
> deleted file mode 100644
> index 3d98291410..0000000000
> --- a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/FsAccess.c
> +++ /dev/null
> @@ -1,507 +0,0 @@
> -/** @file
> 
> -  File System Access for NvVarsFileLib
> 
> -
> 
> -  Copyright (c) 2004 - 2019 Intel Corporation. All rights reserved. <BR>
> 
> -
> 
> -  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> -**/
> 
> -
> 
> -#include "NvVarsFileLib.h"
> 
> -
> 
> -#include <Library/BaseMemoryLib.h>
> 
> -#include <Library/DebugLib.h>
> 
> -#include <Library/MemoryAllocationLib.h>
> 
> -
> 
> -
> 
> -/**
> 
> -  Open the NvVars file for reading or writing
> 
> -
> 
> -  @param[in]  FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid
> instance
> 
> -  @param[in]  ReadingFile - TRUE: open the file for reading.  FALSE: writing
> 
> -  @param[out] NvVarsFile - If EFI_SUCCESS is returned, then this is updated
> 
> -                           with the opened NvVars file.
> 
> -
> 
> -  @return     EFI_SUCCESS if the file was opened
> 
> -
> 
> -**/
> 
> -EFI_STATUS
> 
> -GetNvVarsFile (
> 
> -  IN  EFI_HANDLE            FsHandle,
> 
> -  IN  BOOLEAN               ReadingFile,
> 
> -  OUT EFI_FILE_HANDLE       *NvVarsFile
> 
> -  )
> 
> -{
> 
> -  EFI_STATUS                            Status;
> 
> -  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL       *Fs;
> 
> -  EFI_FILE_HANDLE                       Root;
> 
> -
> 
> -  //
> 
> -  // Get the FileSystem protocol on that handle
> 
> -  //
> 
> -  Status = gBS->HandleProtocol (
> 
> -                  FsHandle,
> 
> -                  &gEfiSimpleFileSystemProtocolGuid,
> 
> -                  (VOID **)&Fs
> 
> -                  );
> 
> -  if (EFI_ERROR (Status)) {
> 
> -    return Status;
> 
> -  }
> 
> -
> 
> -  //
> 
> -  // Get the volume (the root directory)
> 
> -  //
> 
> -  Status = Fs->OpenVolume (Fs, &Root);
> 
> -  if (EFI_ERROR (Status)) {
> 
> -    return Status;
> 
> -  }
> 
> -
> 
> -  //
> 
> -  // Attempt to open the NvVars file in the root directory
> 
> -  //
> 
> -  Status = Root->Open (
> 
> -                   Root,
> 
> -                   NvVarsFile,
> 
> -                   L"NvVars",
> 
> -                   ReadingFile ?
> 
> -                     EFI_FILE_MODE_READ :
> 
> -                     (
> 
> -                       EFI_FILE_MODE_CREATE |
> 
> -                       EFI_FILE_MODE_READ |
> 
> -                       EFI_FILE_MODE_WRITE
> 
> -                     ),
> 
> -                   0
> 
> -                   );
> 
> -
> 
> -  return Status;
> 
> -}
> 
> -
> 
> -
> 
> -/**
> 
> -  Open the NvVars file for reading or writing
> 
> -
> 
> -  @param[in]  File - The file to inspect
> 
> -  @param[out] Exists - Returns whether the file exists
> 
> -  @param[out] Size - Returns the size of the file
> 
> -                     (0 if the file does not exist)
> 
> -
> 
> -**/
> 
> -VOID
> 
> -NvVarsFileReadCheckup (
> 
> -  IN  EFI_FILE_HANDLE        File,
> 
> -  OUT BOOLEAN                *Exists,
> 
> -  OUT UINTN                  *Size
> 
> -  )
> 
> -{
> 
> -  EFI_FILE_INFO               *FileInfo;
> 
> -
> 
> -  *Exists = FALSE;
> 
> -  *Size = 0;
> 
> -
> 
> -  FileInfo = FileHandleGetInfo (File);
> 
> -  if (FileInfo == NULL) {
> 
> -    return;
> 
> -  }
> 
> -
> 
> -  if ((FileInfo->Attribute & EFI_FILE_DIRECTORY) != 0) {
> 
> -    FreePool (FileInfo);
> 
> -    return;
> 
> -  }
> 
> -
> 
> -  *Exists = TRUE;
> 
> -  *Size = (UINTN) FileInfo->FileSize;
> 
> -
> 
> -  FreePool (FileInfo);
> 
> -}
> 
> -
> 
> -
> 
> -/**
> 
> -  Open the NvVars file for reading or writing
> 
> -
> 
> -  @param[in]  File - The file to inspect
> 
> -  @param[out] Exists - Returns whether the file exists
> 
> -  @param[out] Size - Returns the size of the file
> 
> -                     (0 if the file does not exist)
> 
> -
> 
> -**/
> 
> -EFI_STATUS
> 
> -FileHandleEmpty (
> 
> -  IN  EFI_FILE_HANDLE        File
> 
> -  )
> 
> -{
> 
> -  EFI_STATUS                  Status;
> 
> -  EFI_FILE_INFO               *FileInfo;
> 
> -
> 
> -  //
> 
> -  // Retrieve the FileInfo structure
> 
> -  //
> 
> -  FileInfo = FileHandleGetInfo (File);
> 
> -  if (FileInfo == NULL) {
> 
> -    return EFI_INVALID_PARAMETER;
> 
> -  }
> 
> -
> 
> -  //
> 
> -  // If the path is a directory, then return an error
> 
> -  //
> 
> -  if ((FileInfo->Attribute & EFI_FILE_DIRECTORY) != 0) {
> 
> -    FreePool (FileInfo);
> 
> -    return EFI_INVALID_PARAMETER;
> 
> -  }
> 
> -
> 
> -  //
> 
> -  // If the file size is already 0, then it is empty, so
> 
> -  // we can return success.
> 
> -  //
> 
> -  if (FileInfo->FileSize == 0) {
> 
> -    FreePool (FileInfo);
> 
> -    return EFI_SUCCESS;
> 
> -  }
> 
> -
> 
> -  //
> 
> -  // Set the file size to 0.
> 
> -  //
> 
> -  FileInfo->FileSize = 0;
> 
> -  Status = FileHandleSetInfo (File, FileInfo);
> 
> -
> 
> -  FreePool (FileInfo);
> 
> -
> 
> -  return Status;
> 
> -}
> 
> -
> 
> -
> 
> -/**
> 
> -  Reads a file to a newly allocated buffer
> 
> -
> 
> -  @param[in]  File - The file to read
> 
> -  @param[in]  ReadSize - The size of data to read from the file
> 
> -
> 
> -  @return     Pointer to buffer allocated to hold the file
> 
> -              contents.  NULL if an error occurred.
> 
> -
> 
> -**/
> 
> -VOID*
> 
> -FileHandleReadToNewBuffer (
> 
> -  IN EFI_FILE_HANDLE            FileHandle,
> 
> -  IN UINTN                      ReadSize
> 
> -  )
> 
> -{
> 
> -  EFI_STATUS                  Status;
> 
> -  UINTN                       ActualReadSize;
> 
> -  VOID                        *FileContents;
> 
> -
> 
> -  ActualReadSize = ReadSize;
> 
> -  FileContents = AllocatePool (ReadSize);
> 
> -  if (FileContents != NULL) {
> 
> -    Status = FileHandleRead (
> 
> -               FileHandle,
> 
> -               &ReadSize,
> 
> -               FileContents
> 
> -               );
> 
> -    if (EFI_ERROR (Status) || (ActualReadSize != ReadSize)) {
> 
> -      FreePool (FileContents);
> 
> -      return NULL;
> 
> -    }
> 
> -  }
> 
> -
> 
> -  return FileContents;
> 
> -}
> 
> -
> 
> -
> 
> -/**
> 
> -  Reads the contents of the NvVars file on the file system
> 
> -
> 
> -  @param[in]  FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid
> instance
> 
> -
> 
> -  @return     EFI_STATUS based on the success or failure of the file read
> 
> -
> 
> -**/
> 
> -EFI_STATUS
> 
> -ReadNvVarsFile (
> 
> -  IN  EFI_HANDLE            FsHandle
> 
> -  )
> 
> -{
> 
> -  EFI_STATUS                  Status;
> 
> -  EFI_FILE_HANDLE             File;
> 
> -  UINTN                       FileSize;
> 
> -  BOOLEAN                     FileExists;
> 
> -  VOID                        *FileContents;
> 
> -  EFI_HANDLE                  SerializedVariables;
> 
> -
> 
> -  Status = GetNvVarsFile (FsHandle, TRUE, &File);
> 
> -  if (EFI_ERROR (Status)) {
> 
> -    DEBUG ((EFI_D_INFO, "FsAccess.c: Could not open NV Variables file on this
> file system\n"));
> 
> -    return Status;
> 
> -  }
> 
> -
> 
> -  NvVarsFileReadCheckup (File, &FileExists, &FileSize);
> 
> -  if (FileSize == 0) {
> 
> -    FileHandleClose (File);
> 
> -    return EFI_UNSUPPORTED;
> 
> -  }
> 
> -
> 
> -  FileContents = FileHandleReadToNewBuffer (File, FileSize);
> 
> -  if (FileContents == NULL) {
> 
> -    FileHandleClose (File);
> 
> -    return EFI_UNSUPPORTED;
> 
> -  }
> 
> -
> 
> -  DEBUG ((
> 
> -    EFI_D_INFO,
> 
> -    "FsAccess.c: Read %Lu bytes from NV Variables file\n",
> 
> -    (UINT64)FileSize
> 
> -    ));
> 
> -
> 
> -  Status = SerializeVariablesNewInstanceFromBuffer (
> 
> -             &SerializedVariables,
> 
> -             FileContents,
> 
> -             FileSize
> 
> -             );
> 
> -  if (!RETURN_ERROR (Status)) {
> 
> -    Status = SerializeVariablesSetSerializedVariables (SerializedVariables);
> 
> -  }
> 
> -
> 
> -  FreePool (FileContents);
> 
> -  FileHandleClose (File);
> 
> -
> 
> -  return Status;
> 
> -}
> 
> -
> 
> -
> 
> -/**
> 
> -  Writes a variable to indicate that the NV variables
> 
> -  have been loaded from the file system.
> 
> -
> 
> -**/
> 
> -STATIC
> 
> -VOID
> 
> -SetNvVarsVariable (
> 
> -  VOID
> 
> -  )
> 
> -{
> 
> -  BOOLEAN                        VarData;
> 
> -  UINTN                          Size;
> 
> -
> 
> -  //
> 
> -  // Write a variable to indicate we've already loaded the
> 
> -  // variable data.  If it is found, we skip the loading on
> 
> -  // subsequent attempts.
> 
> -  //
> 
> -  Size = sizeof (VarData);
> 
> -  VarData = TRUE;
> 
> -  gRT->SetVariable (
> 
> -         L"NvVars",
> 
> -         &gEfiSimpleFileSystemProtocolGuid,
> 
> -         EFI_VARIABLE_NON_VOLATILE |
> 
> -           EFI_VARIABLE_BOOTSERVICE_ACCESS |
> 
> -           EFI_VARIABLE_RUNTIME_ACCESS,
> 
> -         Size,
> 
> -         (VOID*) &VarData
> 
> -         );
> 
> -}
> 
> -
> 
> -
> 
> -/**
> 
> -  Loads the non-volatile variables from the NvVars file on the
> 
> -  given file system.
> 
> -
> 
> -  @param[in]  FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid
> instance
> 
> -
> 
> -  @return     EFI_STATUS based on the success or failure of load operation
> 
> -
> 
> -**/
> 
> -EFI_STATUS
> 
> -LoadNvVarsFromFs (
> 
> -  EFI_HANDLE                            FsHandle
> 
> -  )
> 
> -{
> 
> -  EFI_STATUS                     Status;
> 
> -  BOOLEAN                        VarData;
> 
> -  UINTN                          Size;
> 
> -
> 
> -  DEBUG ((EFI_D_INFO, "FsAccess.c: LoadNvVarsFromFs\n"));
> 
> -
> 
> -  //
> 
> -  // We write a variable to indicate we've already loaded the
> 
> -  // variable data.  If it is found, we skip the loading.
> 
> -  //
> 
> -  // This is relevant if the non-volatile variable have been
> 
> -  // able to survive a reboot operation.  In that case, we don't
> 
> -  // want to re-load the file as it would overwrite newer changes
> 
> -  // made to the variables.
> 
> -  //
> 
> -  Size = sizeof (VarData);
> 
> -  VarData = TRUE;
> 
> -  Status = gRT->GetVariable (
> 
> -                  L"NvVars",
> 
> -                  &gEfiSimpleFileSystemProtocolGuid,
> 
> -                  NULL,
> 
> -                  &Size,
> 
> -                  (VOID*) &VarData
> 
> -                  );
> 
> -  if (Status == EFI_SUCCESS) {
> 
> -    DEBUG ((EFI_D_INFO, "NV Variables were already loaded\n"));
> 
> -    return EFI_ALREADY_STARTED;
> 
> -  }
> 
> -
> 
> -  //
> 
> -  // Attempt to restore the variables from the NvVars file.
> 
> -  //
> 
> -  Status = ReadNvVarsFile (FsHandle);
> 
> -  if (EFI_ERROR (Status)) {
> 
> -    DEBUG ((EFI_D_INFO, "Error while restoring NV variable data\n"));
> 
> -    return Status;
> 
> -  }
> 
> -
> 
> -  //
> 
> -  // Write a variable to indicate we've already loaded the
> 
> -  // variable data.  If it is found, we skip the loading on
> 
> -  // subsequent attempts.
> 
> -  //
> 
> -  SetNvVarsVariable();
> 
> -
> 
> -  DEBUG ((
> 
> -    EFI_D_INFO,
> 
> -    "FsAccess.c: Read NV Variables file (size=%Lu)\n",
> 
> -    (UINT64)Size
> 
> -    ));
> 
> -
> 
> -  return Status;
> 
> -}
> 
> -
> 
> -
> 
> -STATIC
> 
> -RETURN_STATUS
> 
> -EFIAPI
> 
> -IterateVariablesCallbackAddAllNvVariables (
> 
> -  IN  VOID                         *Context,
> 
> -  IN  CHAR16                       *VariableName,
> 
> -  IN  EFI_GUID                     *VendorGuid,
> 
> -  IN  UINT32                       Attributes,
> 
> -  IN  UINTN                        DataSize,
> 
> -  IN  VOID                         *Data
> 
> -  )
> 
> -{
> 
> -  EFI_HANDLE  Instance;
> 
> -
> 
> -  Instance = (EFI_HANDLE) Context;
> 
> -
> 
> -  //
> 
> -  // Only save non-volatile variables
> 
> -  //
> 
> -  if ((Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) {
> 
> -    return RETURN_SUCCESS;
> 
> -  }
> 
> -
> 
> -  return SerializeVariablesAddVariable (
> 
> -           Instance,
> 
> -           VariableName,
> 
> -           VendorGuid,
> 
> -           Attributes,
> 
> -           DataSize,
> 
> -           Data
> 
> -           );
> 
> -}
> 
> -
> 
> -
> 
> -/**
> 
> -  Saves the non-volatile variables into the NvVars file on the
> 
> -  given file system.
> 
> -
> 
> -  @param[in]  FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid
> instance
> 
> -
> 
> -  @return     EFI_STATUS based on the success or failure of load operation
> 
> -
> 
> -**/
> 
> -EFI_STATUS
> 
> -SaveNvVarsToFs (
> 
> -  EFI_HANDLE                            FsHandle
> 
> -  )
> 
> -{
> 
> -  EFI_STATUS                  Status;
> 
> -  EFI_FILE_HANDLE             File;
> 
> -  UINTN                       WriteSize;
> 
> -  UINTN                       VariableDataSize;
> 
> -  VOID                        *VariableData;
> 
> -  EFI_HANDLE                  SerializedVariables;
> 
> -
> 
> -  SerializedVariables = NULL;
> 
> -
> 
> -  Status = SerializeVariablesNewInstance (&SerializedVariables);
> 
> -  if (EFI_ERROR (Status)) {
> 
> -    return Status;
> 
> -  }
> 
> -
> 
> -  Status = SerializeVariablesIterateSystemVariables (
> 
> -             IterateVariablesCallbackAddAllNvVariables,
> 
> -             (VOID*) SerializedVariables
> 
> -             );
> 
> -  if (EFI_ERROR (Status)) {
> 
> -    return Status;
> 
> -  }
> 
> -
> 
> -  VariableData = NULL;
> 
> -  VariableDataSize = 0;
> 
> -  Status = SerializeVariablesToBuffer (
> 
> -             SerializedVariables,
> 
> -             NULL,
> 
> -             &VariableDataSize
> 
> -             );
> 
> -  if (Status == RETURN_BUFFER_TOO_SMALL) {
> 
> -    VariableData = AllocatePool (VariableDataSize);
> 
> -    if (VariableData == NULL) {
> 
> -      Status = EFI_OUT_OF_RESOURCES;
> 
> -    } else {
> 
> -      Status = SerializeVariablesToBuffer (
> 
> -                 SerializedVariables,
> 
> -                 VariableData,
> 
> -                 &VariableDataSize
> 
> -                 );
> 
> -    }
> 
> -  }
> 
> -
> 
> -  SerializeVariablesFreeInstance (SerializedVariables);
> 
> -
> 
> -  if (EFI_ERROR (Status)) {
> 
> -    return Status;
> 
> -  }
> 
> -
> 
> -  //
> 
> -  // Open the NvVars file for writing.
> 
> -  //
> 
> -  Status = GetNvVarsFile (FsHandle, FALSE, &File);
> 
> -  if (EFI_ERROR (Status)) {
> 
> -    DEBUG ((EFI_D_INFO, "FsAccess.c: Unable to open file to saved NV
> Variables\n"));
> 
> -    return Status;
> 
> -  }
> 
> -
> 
> -  //
> 
> -  // Empty the starting file contents.
> 
> -  //
> 
> -  Status = FileHandleEmpty (File);
> 
> -  if (EFI_ERROR (Status)) {
> 
> -    FileHandleClose (File);
> 
> -    return Status;
> 
> -  }
> 
> -
> 
> -  WriteSize = VariableDataSize;
> 
> -  Status = FileHandleWrite (File, &WriteSize, VariableData);
> 
> -  if (EFI_ERROR (Status)) {
> 
> -    return Status;
> 
> -  }
> 
> -
> 
> -  FileHandleClose (File);
> 
> -
> 
> -  if (!EFI_ERROR (Status)) {
> 
> -    //
> 
> -    // Write a variable to indicate we've already loaded the
> 
> -    // variable data.  If it is found, we skip the loading on
> 
> -    // subsequent attempts.
> 
> -    //
> 
> -    SetNvVarsVariable();
> 
> -
> 
> -	DEBUG ((EFI_D_INFO, "Saved NV Variables to NvVars file\n"));
> 
> -  }
> 
> -
> 
> -  return Status;
> 
> -}
> 
> -
> 
> -
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.c
> b/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.c
> deleted file mode 100644
> index 2e9618455d..0000000000
> ---
> a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.c
> +++ /dev/null
> @@ -1,77 +0,0 @@
> -/** @file
> 
> -  Save Non-Volatile Variables to a file system.
> 
> -
> 
> -  Copyright (c) 2019 Intel Corporation. All rights reserved. <BR>
> 
> -
> 
> -  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> -**/
> 
> -
> 
> -#include "NvVarsFileLib.h"
> 
> -#include <Library/DebugLib.h>
> 
> -#include <Library/NvVarsFileLib.h>
> 
> -
> 
> -EFI_HANDLE    mNvVarsFileLibFsHandle = NULL;
> 
> -
> 
> -
> 
> -/**
> 
> -  Attempts to connect the NvVarsFileLib to the specified file system.
> 
> -
> 
> -  @param[in]  FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid
> instance
> 
> -
> 
> -  @return     The EFI_STATUS while attempting to connect the NvVarsFileLib
> 
> -              to the file system instance.
> 
> -  @retval     EFI_SUCCESS - The given file system was connected successfully
> 
> -
> 
> -**/
> 
> -EFI_STATUS
> 
> -EFIAPI
> 
> -ConnectNvVarsToFileSystem (
> 
> -  IN EFI_HANDLE    FsHandle
> 
> -  )
> 
> -{
> 
> -  EFI_STATUS Status;
> 
> -
> 
> -  //
> 
> -  // We might fail to load the variable, since the file system initially
> 
> -  // will not have the NvVars file.
> 
> -  //
> 
> -  LoadNvVarsFromFs (FsHandle);
> 
> -
> 
> -  //
> 
> -  // We must be able to save the variables successfully to the file system
> 
> -  // to have connected successfully.
> 
> -  //
> 
> -  Status = SaveNvVarsToFs (FsHandle);
> 
> -  if (!EFI_ERROR (Status)) {
> 
> -    mNvVarsFileLibFsHandle = FsHandle;
> 
> -  }
> 
> -
> 
> -  return Status;
> 
> -}
> 
> -
> 
> -
> 
> -/**
> 
> -  Update non-volatile variables stored on the file system.
> 
> -
> 
> -  @return     The EFI_STATUS while attempting to update the variable on
> 
> -              the connected file system.
> 
> -  @retval     EFI_SUCCESS - The non-volatile variables were saved to the disk
> 
> -  @retval     EFI_NOT_STARTED - A file system has not been connected
> 
> -
> 
> -**/
> 
> -EFI_STATUS
> 
> -EFIAPI
> 
> -UpdateNvVarsOnFileSystem (
> 
> -  )
> 
> -{
> 
> -  if (mNvVarsFileLibFsHandle == NULL) {
> 
> -    //
> 
> -    // A file system had not been connected to the library.
> 
> -    //
> 
> -    return EFI_NOT_STARTED;
> 
> -  } else {
> 
> -    return SaveNvVarsToFs (mNvVarsFileLibFsHandle);
> 
> -  }
> 
> -}
> 
> -
> 
> -
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.h
> b/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.h
> deleted file mode 100644
> index 80776fd003..0000000000
> ---
> a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.h
> +++ /dev/null
> @@ -1,55 +0,0 @@
> -/** @file
> 
> -  Save Non-Volatile Variables to a file system.
> 
> -
> 
> -  Copyright (c) 2009 - 2019 Intel Corporation. All rights reserved. <BR>
> 
> -
> 
> -  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> -**/
> 
> -
> 
> -#ifndef __NV_VARS_FILE_LIB_INSTANCE__
> 
> -#define __NV_VARS_FILE_LIB_INSTANCE__
> 
> -
> 
> -#include <Uefi.h>
> 
> -
> 
> -#include <Guid/FileInfo.h>
> 
> -
> 
> -#include <Protocol/SimpleFileSystem.h>
> 
> -
> 
> -#include <Library/BaseLib.h>
> 
> -#include <Library/FileHandleLib.h>
> 
> -#include <Library/SerializeVariablesLib.h>
> 
> -#include <Library/UefiBootServicesTableLib.h>
> 
> -#include <Library/UefiRuntimeServicesTableLib.h>
> 
> -#include <Library/UefiLib.h>
> 
> -
> 
> -/**
> 
> -  Loads the non-volatile variables from the NvVars file on the
> 
> -  given file system.
> 
> -
> 
> -  @param[in]  FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid
> instance
> 
> -
> 
> -  @return     EFI_STATUS based on the success or failure of load operation
> 
> -
> 
> -**/
> 
> -EFI_STATUS
> 
> -LoadNvVarsFromFs (
> 
> -  EFI_HANDLE                            FsHandle
> 
> -  );
> 
> -
> 
> -
> 
> -/**
> 
> -  Saves the non-volatile variables into the NvVars file on the
> 
> -  given file system.
> 
> -
> 
> -  @param[in]  FsHandle - Handle for a gEfiSimpleFileSystemProtocolGuid
> instance
> 
> -
> 
> -  @return     EFI_STATUS based on the success or failure of load operation
> 
> -
> 
> -**/
> 
> -EFI_STATUS
> 
> -SaveNvVarsToFs (
> 
> -  EFI_HANDLE                            FsHandle
> 
> -  );
> 
> -
> 
> -#endif
> 
> -
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.in
> f
> b/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.in
> f
> deleted file mode 100644
> index 4731e77865..0000000000
> ---
> a/Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.in
> f
> +++ /dev/null
> @@ -1,53 +0,0 @@
> -## @file
> 
> -#  NvVarsFileLib
> 
> -#
> 
> -#  This library saves and restores non-volatile variables in a
> 
> -#  file within a file system.
> 
> -#
> 
> -# Copyright (c) 2006 - 2019 Intel Corporation. All rights reserved. <BR>
> 
> -#
> 
> -# SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> -#
> 
> -##
> 
> -
> 
> -[Defines]
> 
> -  INF_VERSION                    = 0x00010005
> 
> -  BASE_NAME                      = NvVarsFileLib
> 
> -  FILE_GUID                      = 8ECD4CC0-1772-4583-8A74-83633A15FAA0
> 
> -  MODULE_TYPE                    = UEFI_DRIVER
> 
> -  VERSION_STRING                 = 1.0
> 
> -  LIBRARY_CLASS                  = NvVarsFileLib|DXE_DRIVER
> DXE_RUNTIME_DRIVER UEFI_DRIVER
> 
> -
> 
> -#
> 
> -# The following information is for reference only and not required by the build
> tools.
> 
> -#
> 
> -#  VALID_ARCHITECTURES           = IA32 X64 EBC
> 
> -#
> 
> -
> 
> -[Sources]
> 
> -  FsAccess.c
> 
> -  NvVarsFileLib.c
> 
> -
> 
> -[Packages]
> 
> -  MdePkg/MdePkg.dec
> 
> -  MdeModulePkg/MdeModulePkg.dec
> 
> -  ShellPkg/ShellPkg.dec
> 
> -  OvmfPkg/OvmfPkg.dec
> 
> -
> 
> -[LibraryClasses]
> 
> -  BaseLib
> 
> -  BaseMemoryLib
> 
> -  DebugLib
> 
> -  FileHandleLib
> 
> -  MemoryAllocationLib
> 
> -  SerializeVariablesLib
> 
> -
> 
> -[Protocols]
> 
> -  gEfiSimpleFileSystemProtocolGuid              ## CONSUMES
> 
> -
> 
> -[Guids]
> 
> -  gEfiFileInfoGuid
> 
> -
> 
> -[Depex]
> 
> -  gEfiVariableWriteArchProtocolGuid
> 
> -
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeV
> ariablesLib.c
> b/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeV
> ariablesLib.c
> deleted file mode 100644
> index be619c838a..0000000000
> ---
> a/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeV
> ariablesLib.c
> +++ /dev/null
> @@ -1,869 +0,0 @@
> -/** @file
> 
> -  Serialize Variables Library implementation
> 
> -
> 
> -  Copyright (c) 2004 - 2019 Intel Corporation. All rights reserved. <BR>
> 
> -
> 
> -  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> -**/
> 
> -
> 
> -#include "SerializeVariablesLib.h"
> 
> -
> 
> -/**
> 
> -  Serialization format:
> 
> -
> 
> -  The SerializeVariablesLib interface does not specify a format
> 
> -  for the serialization of the variable data.  This library uses
> 
> -  a packed array of a non-uniformly sized data structure elements.
> 
> -
> 
> -  Each variable is stored (packed) as:
> 
> -    UINT32   VendorNameSize;  // Name size in bytes
> 
> -    CHAR16   VendorName[?];   // The variable unicode name including the
> 
> -                              // null terminating character.
> 
> -    EFI_GUID VendorGuid;      // The variable GUID
> 
> -    UINT32   DataSize;        // The size of variable data in bytes
> 
> -    UINT8    Data[?];         // The variable data
> 
> -
> 
> -**/
> 
> -
> 
> -
> 
> -/**
> 
> -  Unpacks the next variable from the buffer
> 
> -
> 
> -  @param[in]  Buffer - Buffer pointing to the next variable instance
> 
> -                On subsequent calls, the pointer should be incremented
> 
> -                by the returned SizeUsed value.
> 
> -  @param[in]  MaxSize - Max allowable size for the variable data
> 
> -                On subsequent calls, this should be decremented
> 
> -                by the returned SizeUsed value.
> 
> -  @param[out] Name - Variable name string (address in Buffer)
> 
> -  @param[out] NameSize - Size of Name in bytes
> 
> -  @param[out] Guid - GUID of variable (address in Buffer)
> 
> -  @param[out] Attributes - Attributes of variable
> 
> -  @param[out] Data - Buffer containing Data for variable (address in Buffer)
> 
> -  @param[out] DataSize - Size of Data in bytes
> 
> -  @param[out] SizeUsed - Total size used for this variable instance in Buffer
> 
> -
> 
> -  @return     EFI_STATUS based on the success or failure of the operation
> 
> -
> 
> -**/
> 
> -STATIC
> 
> -EFI_STATUS
> 
> -UnpackVariableFromBuffer (
> 
> -  IN  VOID     *Buffer,
> 
> -  IN  UINTN    MaxSize,
> 
> -  OUT CHAR16   **Name,
> 
> -  OUT UINT32   *NameSize,
> 
> -  OUT EFI_GUID **Guid,
> 
> -  OUT UINT32   *Attributes,
> 
> -  OUT UINT32   *DataSize,
> 
> -  OUT VOID     **Data,
> 
> -  OUT UINTN    *SizeUsed
> 
> -  )
> 
> -{
> 
> -  UINT8  *BytePtr;
> 
> -  UINTN  Offset;
> 
> -
> 
> -  BytePtr = (UINT8*)Buffer;
> 
> -  Offset = 0;
> 
> -
> 
> -  *NameSize = *(UINT32*) (BytePtr + Offset);
> 
> -  Offset = Offset + sizeof (UINT32);
> 
> -
> 
> -  if (Offset > MaxSize) {
> 
> -    return EFI_INVALID_PARAMETER;
> 
> -  }
> 
> -
> 
> -  *Name = (CHAR16*) (BytePtr + Offset);
> 
> -  Offset = Offset + *(UINT32*)BytePtr;
> 
> -  if (Offset > MaxSize) {
> 
> -    return EFI_INVALID_PARAMETER;
> 
> -  }
> 
> -
> 
> -  *Guid = (EFI_GUID*) (BytePtr + Offset);
> 
> -  Offset = Offset + sizeof (EFI_GUID);
> 
> -  if (Offset > MaxSize) {
> 
> -    return EFI_INVALID_PARAMETER;
> 
> -  }
> 
> -
> 
> -  *Attributes = *(UINT32*) (BytePtr + Offset);
> 
> -  Offset = Offset + sizeof (UINT32);
> 
> -  if (Offset > MaxSize) {
> 
> -    return EFI_INVALID_PARAMETER;
> 
> -  }
> 
> -
> 
> -  *DataSize = *(UINT32*) (BytePtr + Offset);
> 
> -  Offset = Offset + sizeof (UINT32);
> 
> -  if (Offset > MaxSize) {
> 
> -    return EFI_INVALID_PARAMETER;
> 
> -  }
> 
> -
> 
> -  *Data = (VOID*) (BytePtr + Offset);
> 
> -  Offset = Offset + *DataSize;
> 
> -  if (Offset > MaxSize) {
> 
> -    return EFI_INVALID_PARAMETER;
> 
> -  }
> 
> -
> 
> -  *SizeUsed = Offset;
> 
> -
> 
> -  return EFI_SUCCESS;
> 
> -}
> 
> -
> 
> -
> 
> -/**
> 
> -  Iterates through the variables in the buffer, and calls a callback
> 
> -  function for each variable found.
> 
> -
> 
> -  @param[in]  CallbackFunction - Function called for each variable instance
> 
> -  @param[in]  Context - Passed to each call of CallbackFunction
> 
> -  @param[in]  Buffer - Buffer containing serialized variables
> 
> -  @param[in]  MaxSize - Size of Buffer in bytes
> 
> -
> 
> -  @return     EFI_STATUS based on the success or failure of the operation
> 
> -
> 
> -**/
> 
> -STATIC
> 
> -EFI_STATUS
> 
> -IterateVariablesInBuffer (
> 
> -  IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK  CallbackFunction,
> 
> -  IN VOID                                       *CallbackContext,
> 
> -  IN VOID                                       *Buffer,
> 
> -  IN UINTN                                      MaxSize
> 
> -  )
> 
> -{
> 
> -  RETURN_STATUS Status;
> 
> -  UINTN         TotalSizeUsed;
> 
> -  UINTN         SizeUsed;
> 
> -
> 
> -  CHAR16        *Name;
> 
> -  UINT32        NameSize;
> 
> -  CHAR16        *AlignedName;
> 
> -  UINT32        AlignedNameMaxSize;
> 
> -  EFI_GUID      *Guid;
> 
> -  UINT32        Attributes;
> 
> -  UINT32        DataSize;
> 
> -  VOID          *Data;
> 
> -
> 
> -  SizeUsed = 0;
> 
> -  AlignedName = NULL;
> 
> -  AlignedNameMaxSize = 0;
> 
> -  Name = NULL;
> 
> -  Guid = NULL;
> 
> -  Attributes = 0;
> 
> -  DataSize = 0;
> 
> -  Data = NULL;
> 
> -
> 
> -  for (
> 
> -    Status = EFI_SUCCESS, TotalSizeUsed = 0;
> 
> -    !EFI_ERROR (Status) && (TotalSizeUsed < MaxSize);
> 
> -    ) {
> 
> -    Status = UnpackVariableFromBuffer (
> 
> -               (VOID*) ((UINT8*) Buffer + TotalSizeUsed),
> 
> -               (MaxSize - TotalSizeUsed),
> 
> -               &Name,
> 
> -               &NameSize,
> 
> -               &Guid,
> 
> -               &Attributes,
> 
> -               &DataSize,
> 
> -               &Data,
> 
> -               &SizeUsed
> 
> -               );
> 
> -    if (EFI_ERROR (Status)) {
> 
> -      return Status;
> 
> -    }
> 
> -
> 
> -    //
> 
> -    // We copy the name to a separately allocated buffer,
> 
> -    // to be sure it is 16-bit aligned.
> 
> -    //
> 
> -    if (NameSize > AlignedNameMaxSize) {
> 
> -      if (AlignedName != NULL) {
> 
> -        FreePool (AlignedName);
> 
> -      }
> 
> -      AlignedName = AllocatePool (NameSize);
> 
> -    }
> 
> -    if (AlignedName == NULL) {
> 
> -      return EFI_OUT_OF_RESOURCES;
> 
> -    }
> 
> -    CopyMem (AlignedName, Name, NameSize);
> 
> -
> 
> -    TotalSizeUsed = TotalSizeUsed + SizeUsed;
> 
> -
> 
> -    //
> 
> -    // Run the callback function
> 
> -    //
> 
> -    Status = (*CallbackFunction) (
> 
> -               CallbackContext,
> 
> -               AlignedName,
> 
> -               Guid,
> 
> -               Attributes,
> 
> -               DataSize,
> 
> -               Data
> 
> -               );
> 
> -
> 
> -  }
> 
> -
> 
> -  if (AlignedName != NULL) {
> 
> -    FreePool (AlignedName);
> 
> -  }
> 
> -
> 
> -  //
> 
> -  // Make sure the entire buffer was used, or else return an error
> 
> -  //
> 
> -  if (TotalSizeUsed != MaxSize) {
> 
> -    DEBUG ((
> 
> -      EFI_D_ERROR,
> 
> -      "Deserialize variables error: TotalSizeUsed(%Lu) != MaxSize(%Lu)\n",
> 
> -      (UINT64)TotalSizeUsed,
> 
> -      (UINT64)MaxSize
> 
> -      ));
> 
> -    return EFI_INVALID_PARAMETER;
> 
> -  }
> 
> -
> 
> -  return EFI_SUCCESS;
> 
> -}
> 
> -
> 
> -
> 
> -STATIC
> 
> -RETURN_STATUS
> 
> -EFIAPI
> 
> -IterateVariablesCallbackNop (
> 
> -  IN  VOID                         *Context,
> 
> -  IN  CHAR16                       *VariableName,
> 
> -  IN  EFI_GUID                     *VendorGuid,
> 
> -  IN  UINT32                       Attributes,
> 
> -  IN  UINTN                        DataSize,
> 
> -  IN  VOID                         *Data
> 
> -  )
> 
> -{
> 
> -  return RETURN_SUCCESS;
> 
> -}
> 
> -
> 
> -
> 
> -STATIC
> 
> -RETURN_STATUS
> 
> -EFIAPI
> 
> -IterateVariablesCallbackSetInInstance (
> 
> -  IN  VOID                         *Context,
> 
> -  IN  CHAR16                       *VariableName,
> 
> -  IN  EFI_GUID                     *VendorGuid,
> 
> -  IN  UINT32                       Attributes,
> 
> -  IN  UINTN                        DataSize,
> 
> -  IN  VOID                         *Data
> 
> -  )
> 
> -{
> 
> -  EFI_HANDLE  Instance;
> 
> -
> 
> -  Instance = (EFI_HANDLE) Context;
> 
> -
> 
> -  return SerializeVariablesAddVariable (
> 
> -           Instance,
> 
> -           VariableName,
> 
> -           VendorGuid,
> 
> -           Attributes,
> 
> -           DataSize,
> 
> -           Data
> 
> -           );
> 
> -}
> 
> -
> 
> -
> 
> -STATIC
> 
> -RETURN_STATUS
> 
> -EFIAPI
> 
> -IterateVariablesCallbackSetSystemVariable (
> 
> -  IN  VOID                         *Context,
> 
> -  IN  CHAR16                       *VariableName,
> 
> -  IN  EFI_GUID                     *VendorGuid,
> 
> -  IN  UINT32                       Attributes,
> 
> -  IN  UINTN                        DataSize,
> 
> -  IN  VOID                         *Data
> 
> -  )
> 
> -{
> 
> -  EFI_STATUS          Status;
> 
> -  STATIC CONST UINT32 AuthMask =
> 
> -                        EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS |
> 
> -                        EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS;
> 
> -
> 
> -  Status = gRT->SetVariable (
> 
> -             VariableName,
> 
> -             VendorGuid,
> 
> -             Attributes,
> 
> -             DataSize,
> 
> -             Data
> 
> -             );
> 
> -
> 
> -  if (Status == EFI_SECURITY_VIOLATION && (Attributes & AuthMask) != 0) {
> 
> -    DEBUG ((DEBUG_WARN, "%a: setting authenticated variable \"%s\" "
> 
> -            "failed with EFI_SECURITY_VIOLATION, ignoring\n", __FUNCTION__,
> 
> -            VariableName));
> 
> -    Status = EFI_SUCCESS;
> 
> -  } else if (Status == EFI_WRITE_PROTECTED) {
> 
> -    DEBUG ((DEBUG_WARN, "%a: setting ReadOnly variable \"%s\" "
> 
> -            "failed with EFI_WRITE_PROTECTED, ignoring\n", __FUNCTION__,
> 
> -            VariableName));
> 
> -    Status = EFI_SUCCESS;
> 
> -  }
> 
> -  return Status;
> 
> -}
> 
> -
> 
> -
> 
> -STATIC
> 
> -RETURN_STATUS
> 
> -EnsureExtraBufferSpace (
> 
> -  IN  SV_INSTANCE  *Instance,
> 
> -  IN  UINTN        Size
> 
> -  )
> 
> -{
> 
> -  VOID *NewBuffer;
> 
> -  UINTN NewSize;
> 
> -
> 
> -  NewSize = Instance->DataSize + Size;
> 
> -  if (NewSize <= Instance->BufferSize) {
> 
> -    return RETURN_SUCCESS;
> 
> -  }
> 
> -
> 
> -  //
> 
> -  // Double the required size to lessen the need to re-allocate in the future
> 
> -  //
> 
> -  NewSize = 2 * NewSize;
> 
> -
> 
> -  NewBuffer = AllocatePool (NewSize);
> 
> -  if (NewBuffer == NULL) {
> 
> -    return RETURN_OUT_OF_RESOURCES;
> 
> -  }
> 
> -
> 
> -  if (Instance->BufferPtr != NULL) {
> 
> -    CopyMem (NewBuffer, Instance->BufferPtr, Instance->DataSize);
> 
> -    FreePool (Instance->BufferPtr);
> 
> -  }
> 
> -
> 
> -  Instance->BufferPtr = NewBuffer;
> 
> -  Instance->BufferSize = NewSize;
> 
> -
> 
> -  return RETURN_SUCCESS;
> 
> -}
> 
> -
> 
> -
> 
> -STATIC
> 
> -VOID
> 
> -AppendToBuffer (
> 
> -  IN  SV_INSTANCE  *Instance,
> 
> -  IN  VOID         *Data,
> 
> -  IN  UINTN        Size
> 
> -  )
> 
> -{
> 
> -  UINTN NewSize;
> 
> -
> 
> -  ASSERT (Instance != NULL);
> 
> -  ASSERT (Data != NULL);
> 
> -
> 
> -  NewSize = Instance->DataSize + Size;
> 
> -  ASSERT ((Instance->DataSize + Size) <= Instance->BufferSize);
> 
> -
> 
> -  CopyMem (
> 
> -    (VOID*) (((UINT8*) (Instance->BufferPtr)) + Instance->DataSize),
> 
> -    Data,
> 
> -    Size
> 
> -    );
> 
> -
> 
> -  Instance->DataSize = NewSize;
> 
> -}
> 
> -
> 
> -
> 
> -/**
> 
> -  Creates a new variable serialization instance
> 
> -
> 
> -  @param[out]  Handle - Handle for a variable serialization instance
> 
> -
> 
> -  @retval      RETURN_SUCCESS - The variable serialization instance was
> 
> -                 successfully created.
> 
> -  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources
> to
> 
> -                 create the variable serialization instance.
> 
> -
> 
> -**/
> 
> -RETURN_STATUS
> 
> -EFIAPI
> 
> -SerializeVariablesNewInstance (
> 
> -  OUT EFI_HANDLE                      *Handle
> 
> -  )
> 
> -{
> 
> -  SV_INSTANCE  *New;
> 
> -
> 
> -  New = AllocateZeroPool (sizeof (*New));
> 
> -  if (New == NULL) {
> 
> -    return RETURN_OUT_OF_RESOURCES;
> 
> -  }
> 
> -
> 
> -  New->Signature = SV_SIGNATURE;
> 
> -
> 
> -  *Handle = (EFI_HANDLE) New;
> 
> -  return RETURN_SUCCESS;
> 
> -}
> 
> -
> 
> -
> 
> -/**
> 
> -  Free memory associated with a variable serialization instance
> 
> -
> 
> -  @param[in]  Handle - Handle for a variable serialization instance
> 
> -
> 
> -  @retval      RETURN_SUCCESS - The variable serialization instance was
> 
> -                 successfully freed.
> 
> -  @retval      RETURN_INVALID_PARAMETER - Handle was not a valid
> 
> -                 variable serialization instance.
> 
> -
> 
> -**/
> 
> -RETURN_STATUS
> 
> -EFIAPI
> 
> -SerializeVariablesFreeInstance (
> 
> -  IN EFI_HANDLE Handle
> 
> -  )
> 
> -{
> 
> -  SV_INSTANCE    *Instance;
> 
> -
> 
> -  Instance = SV_FROM_HANDLE (Handle);
> 
> -
> 
> -  if (Instance->Signature != SV_SIGNATURE) {
> 
> -    return RETURN_INVALID_PARAMETER;
> 
> -  }
> 
> -
> 
> -  Instance->Signature = 0;
> 
> -
> 
> -  if (Instance->BufferPtr != NULL) {
> 
> -    FreePool (Instance->BufferPtr);
> 
> -  }
> 
> -
> 
> -  FreePool (Instance);
> 
> -
> 
> -  return RETURN_SUCCESS;
> 
> -}
> 
> -
> 
> -
> 
> -/**
> 
> -  Creates a new variable serialization instance using the given
> 
> -  binary representation of the variables to fill the new instance
> 
> -
> 
> -  @param[out] Handle - Handle for a variable serialization instance
> 
> -  @param[in]  Buffer - A buffer with the serialized representation
> 
> -                of the variables.  Must be the same format as produced
> 
> -                by SerializeVariablesToBuffer.
> 
> -  @param[in]  Size - This is the size of the binary representation
> 
> -                of the variables.
> 
> -
> 
> -  @retval      RETURN_SUCCESS - The binary representation was successfully
> 
> -                 imported into a new variable serialization instance
> 
> -  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources
> to
> 
> -                 create the new variable serialization instance
> 
> -
> 
> -**/
> 
> -RETURN_STATUS
> 
> -EFIAPI
> 
> -SerializeVariablesNewInstanceFromBuffer (
> 
> -  OUT EFI_HANDLE                          *Handle,
> 
> -  IN  VOID                                *Buffer,
> 
> -  IN  UINTN                               Size
> 
> -  )
> 
> -{
> 
> -  RETURN_STATUS Status;
> 
> -
> 
> -  Status = SerializeVariablesNewInstance (Handle);
> 
> -  if (RETURN_ERROR (Status)) {
> 
> -    return Status;
> 
> -  }
> 
> -
> 
> -  Status = IterateVariablesInBuffer (
> 
> -             IterateVariablesCallbackNop,
> 
> -             NULL,
> 
> -             Buffer,
> 
> -             Size
> 
> -             );
> 
> -  if (RETURN_ERROR (Status)) {
> 
> -    SerializeVariablesFreeInstance (*Handle);
> 
> -    return Status;
> 
> -  }
> 
> -
> 
> -  Status = IterateVariablesInBuffer (
> 
> -             IterateVariablesCallbackSetInInstance,
> 
> -             (VOID*) *Handle,
> 
> -             Buffer,
> 
> -             Size
> 
> -             );
> 
> -  if (RETURN_ERROR (Status)) {
> 
> -    SerializeVariablesFreeInstance (*Handle);
> 
> -    return Status;
> 
> -  }
> 
> -
> 
> -  return Status;
> 
> -}
> 
> -
> 
> -
> 
> -/**
> 
> -  Iterates all variables found with RuntimeServices GetNextVariableName
> 
> -
> 
> -  @param[in]   CallbackFunction - Function called for each variable instance
> 
> -  @param[in]   Context - Passed to each call of CallbackFunction
> 
> -
> 
> -  @retval      RETURN_SUCCESS - All variables were iterated without the
> 
> -                 CallbackFunction returning an error
> 
> -  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources
> to
> 
> -                 iterate through the variables
> 
> -  @return      Any of RETURN_ERROR indicates an error reading the variable
> 
> -                 or an error was returned from CallbackFunction
> 
> -
> 
> -**/
> 
> -RETURN_STATUS
> 
> -EFIAPI
> 
> -SerializeVariablesIterateSystemVariables (
> 
> -  IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction,
> 
> -  IN VOID                                      *Context
> 
> -  )
> 
> -{
> 
> -  RETURN_STATUS               Status;
> 
> -  UINTN                       VariableNameBufferSize;
> 
> -  UINTN                       VariableNameSize;
> 
> -  CHAR16                      *VariableName;
> 
> -  EFI_GUID                    VendorGuid;
> 
> -  UINTN                       VariableDataBufferSize;
> 
> -  UINTN                       VariableDataSize;
> 
> -  VOID                        *VariableData;
> 
> -  UINT32                      VariableAttributes;
> 
> -  VOID                        *NewBuffer;
> 
> -
> 
> -  //
> 
> -  // Initialize the variable name and data buffer variables.
> 
> -  //
> 
> -  VariableNameBufferSize = sizeof (CHAR16);
> 
> -  VariableName = AllocateZeroPool (VariableNameBufferSize);
> 
> -
> 
> -  VariableDataBufferSize = 0;
> 
> -  VariableData = NULL;
> 
> -
> 
> -  for (;;) {
> 
> -    //
> 
> -    // Get the next variable name and guid
> 
> -    //
> 
> -    VariableNameSize = VariableNameBufferSize;
> 
> -    Status = gRT->GetNextVariableName (
> 
> -                    &VariableNameSize,
> 
> -                    VariableName,
> 
> -                    &VendorGuid
> 
> -                    );
> 
> -    if (Status == EFI_BUFFER_TOO_SMALL) {
> 
> -      //
> 
> -      // The currently allocated VariableName buffer is too small,
> 
> -      // so we allocate a larger buffer, and copy the old buffer
> 
> -      // to it.
> 
> -      //
> 
> -      NewBuffer = AllocatePool (VariableNameSize);
> 
> -      if (NewBuffer == NULL) {
> 
> -        Status = EFI_OUT_OF_RESOURCES;
> 
> -        break;
> 
> -      }
> 
> -      CopyMem (NewBuffer, VariableName, VariableNameBufferSize);
> 
> -      if (VariableName != NULL) {
> 
> -        FreePool (VariableName);
> 
> -      }
> 
> -      VariableName = NewBuffer;
> 
> -      VariableNameBufferSize = VariableNameSize;
> 
> -
> 
> -      //
> 
> -      // Try to get the next variable name again with the larger buffer.
> 
> -      //
> 
> -      Status = gRT->GetNextVariableName (
> 
> -                      &VariableNameSize,
> 
> -                      VariableName,
> 
> -                      &VendorGuid
> 
> -                      );
> 
> -    }
> 
> -
> 
> -    if (EFI_ERROR (Status)) {
> 
> -      if (Status == EFI_NOT_FOUND) {
> 
> -        Status = EFI_SUCCESS;
> 
> -      }
> 
> -      break;
> 
> -    }
> 
> -
> 
> -    //
> 
> -    // Get the variable data and attributes
> 
> -    //
> 
> -    VariableDataSize = VariableDataBufferSize;
> 
> -    Status = gRT->GetVariable (
> 
> -                    VariableName,
> 
> -                    &VendorGuid,
> 
> -                    &VariableAttributes,
> 
> -                    &VariableDataSize,
> 
> -                    VariableData
> 
> -                    );
> 
> -    if (Status == EFI_BUFFER_TOO_SMALL) {
> 
> -      //
> 
> -      // The currently allocated VariableData buffer is too small,
> 
> -      // so we allocate a larger buffer.
> 
> -      //
> 
> -      if (VariableDataBufferSize != 0) {
> 
> -        FreePool (VariableData);
> 
> -        VariableData = NULL;
> 
> -        VariableDataBufferSize = 0;
> 
> -      }
> 
> -      VariableData = AllocatePool (VariableDataSize);
> 
> -      if (VariableData == NULL) {
> 
> -        Status = EFI_OUT_OF_RESOURCES;
> 
> -        break;
> 
> -      }
> 
> -      VariableDataBufferSize = VariableDataSize;
> 
> -
> 
> -      //
> 
> -      // Try to read the variable again with the larger buffer.
> 
> -      //
> 
> -      Status = gRT->GetVariable (
> 
> -                      VariableName,
> 
> -                      &VendorGuid,
> 
> -                      &VariableAttributes,
> 
> -                      &VariableDataSize,
> 
> -                      VariableData
> 
> -                      );
> 
> -    }
> 
> -    if (EFI_ERROR (Status)) {
> 
> -      break;
> 
> -    }
> 
> -
> 
> -    //
> 
> -    // Run the callback function
> 
> -    //
> 
> -    Status = (*CallbackFunction) (
> 
> -               Context,
> 
> -               VariableName,
> 
> -               &VendorGuid,
> 
> -               VariableAttributes,
> 
> -               VariableDataSize,
> 
> -               VariableData
> 
> -               );
> 
> -    if (EFI_ERROR (Status)) {
> 
> -      break;
> 
> -    }
> 
> -
> 
> -  }
> 
> -
> 
> -  if (VariableName != NULL) {
> 
> -    FreePool (VariableName);
> 
> -  }
> 
> -
> 
> -  if (VariableData != NULL) {
> 
> -    FreePool (VariableData);
> 
> -  }
> 
> -
> 
> -  return Status;
> 
> -}
> 
> -
> 
> -
> 
> -/**
> 
> -  Iterates all variables found in the variable serialization instance
> 
> -
> 
> -  @param[in]   Handle - Handle for a variable serialization instance
> 
> -  @param[in]   CallbackFunction - Function called for each variable instance
> 
> -  @param[in]   Context - Passed to each call of CallbackFunction
> 
> -
> 
> -  @retval      RETURN_SUCCESS - All variables were iterated without the
> 
> -                 CallbackFunction returning an error
> 
> -  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources
> to
> 
> -                 iterate through the variables
> 
> -  @return      Any of RETURN_ERROR indicates an error reading the variable
> 
> -                 or an error was returned from CallbackFunction
> 
> -
> 
> -**/
> 
> -RETURN_STATUS
> 
> -EFIAPI
> 
> -SerializeVariablesIterateInstanceVariables (
> 
> -  IN EFI_HANDLE                                Handle,
> 
> -  IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction,
> 
> -  IN VOID                                      *Context
> 
> -  )
> 
> -{
> 
> -  SV_INSTANCE    *Instance;
> 
> -
> 
> -  Instance = SV_FROM_HANDLE (Handle);
> 
> -
> 
> -  if ((Instance->BufferPtr != NULL) && (Instance->DataSize != 0)) {
> 
> -    return IterateVariablesInBuffer (
> 
> -             CallbackFunction,
> 
> -             Context,
> 
> -             Instance->BufferPtr,
> 
> -             Instance->DataSize
> 
> -             );
> 
> -  } else {
> 
> -    return RETURN_SUCCESS;
> 
> -  }
> 
> -}
> 
> -
> 
> -
> 
> -/**
> 
> -  Sets all variables found in the variable serialization instance
> 
> -
> 
> -  @param[in]   Handle - Handle for a variable serialization instance
> 
> -
> 
> -  @retval      RETURN_SUCCESS - All variables were set successfully
> 
> -  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources
> to
> 
> -                 set all the variables
> 
> -  @return      Any of RETURN_ERROR indicates an error reading the variables
> 
> -                 or in attempting to set a variable
> 
> -
> 
> -**/
> 
> -RETURN_STATUS
> 
> -EFIAPI
> 
> -SerializeVariablesSetSerializedVariables (
> 
> -  IN EFI_HANDLE                       Handle
> 
> -  )
> 
> -{
> 
> -  return SerializeVariablesIterateInstanceVariables (
> 
> -           Handle,
> 
> -           IterateVariablesCallbackSetSystemVariable,
> 
> -           NULL
> 
> -           );
> 
> -}
> 
> -
> 
> -
> 
> -/**
> 
> -  Adds a variable to the variable serialization instance
> 
> -
> 
> -  @param[in] Handle - Handle for a variable serialization instance
> 
> -  @param[in] VariableName - Refer to RuntimeServices GetVariable
> 
> -  @param[in] VendorGuid - Refer to RuntimeServices GetVariable
> 
> -  @param[in] Attributes - Refer to RuntimeServices GetVariable
> 
> -  @param[in] DataSize - Refer to RuntimeServices GetVariable
> 
> -  @param[in] Data - Refer to RuntimeServices GetVariable
> 
> -
> 
> -  @retval      RETURN_SUCCESS - All variables were set successfully
> 
> -  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources
> to
> 
> -                 add the variable
> 
> -  @retval      RETURN_INVALID_PARAMETER - Handle was not a valid
> 
> -                 variable serialization instance or
> 
> -                 VariableName, VariableGuid or Data are NULL.
> 
> -
> 
> -**/
> 
> -RETURN_STATUS
> 
> -EFIAPI
> 
> -SerializeVariablesAddVariable (
> 
> -  IN EFI_HANDLE                   Handle,
> 
> -  IN CHAR16                       *VariableName,
> 
> -  IN EFI_GUID                     *VendorGuid,
> 
> -  IN UINT32                       Attributes,
> 
> -  IN UINTN                        DataSize,
> 
> -  IN VOID                         *Data
> 
> -  )
> 
> -{
> 
> -  RETURN_STATUS  Status;
> 
> -  SV_INSTANCE    *Instance;
> 
> -  UINT32         SerializedNameSize;
> 
> -  UINT32         SerializedDataSize;
> 
> -  UINTN          SerializedSize;
> 
> -
> 
> -  Instance = SV_FROM_HANDLE (Handle);
> 
> -
> 
> -  if ((Instance->Signature != SV_SIGNATURE) ||
> 
> -      (VariableName == NULL) || (VendorGuid == NULL) || (Data == NULL)) {
> 
> -  }
> 
> -
> 
> -  SerializedNameSize = (UINT32) StrSize (VariableName);
> 
> -
> 
> -  SerializedSize =
> 
> -    sizeof (SerializedNameSize) +
> 
> -    SerializedNameSize +
> 
> -    sizeof (*VendorGuid) +
> 
> -    sizeof (Attributes) +
> 
> -    sizeof (SerializedDataSize) +
> 
> -    DataSize;
> 
> -
> 
> -  Status = EnsureExtraBufferSpace (
> 
> -             Instance,
> 
> -             SerializedSize
> 
> -             );
> 
> -  if (RETURN_ERROR (Status)) {
> 
> -    return Status;
> 
> -  }
> 
> -
> 
> -  //
> 
> -  // Add name size (UINT32)
> 
> -  //
> 
> -  AppendToBuffer (Instance, (VOID*) &SerializedNameSize, sizeof
> (SerializedNameSize));
> 
> -
> 
> -  //
> 
> -  // Add variable unicode name string
> 
> -  //
> 
> -  AppendToBuffer (Instance, (VOID*) VariableName, SerializedNameSize);
> 
> -
> 
> -  //
> 
> -  // Add variable GUID
> 
> -  //
> 
> -  AppendToBuffer (Instance, (VOID*) VendorGuid, sizeof (*VendorGuid));
> 
> -
> 
> -  //
> 
> -  // Add variable attributes
> 
> -  //
> 
> -  AppendToBuffer (Instance, (VOID*) &Attributes, sizeof (Attributes));
> 
> -
> 
> -  //
> 
> -  // Add variable data size (UINT32)
> 
> -  //
> 
> -  SerializedDataSize = (UINT32) DataSize;
> 
> -  AppendToBuffer (Instance, (VOID*) &SerializedDataSize, sizeof
> (SerializedDataSize));
> 
> -
> 
> -  //
> 
> -  // Add variable data
> 
> -  //
> 
> -  AppendToBuffer (Instance, Data, DataSize);
> 
> -
> 
> -  return RETURN_SUCCESS;
> 
> -}
> 
> -
> 
> -
> 
> -/**
> 
> -  Serializes the variables known to this instance into the
> 
> -  provided buffer.
> 
> -
> 
> -  @param[in]     Handle - Handle for a variable serialization instance
> 
> -  @param[out]    Buffer - A buffer to store the binary representation
> 
> -                   of the variables.
> 
> -  @param[in,out] Size - On input this is the size of the buffer.
> 
> -                   On output this is the size of the binary representation
> 
> -                   of the variables.
> 
> -
> 
> -  @retval      RETURN_SUCCESS - The binary representation was successfully
> 
> -                 completed and returned in the buffer.
> 
> -  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources
> to
> 
> -                 save the variables to the buffer.
> 
> -  @retval      RETURN_INVALID_PARAMETER - Handle was not a valid
> 
> -                 variable serialization instance or
> 
> -                 Size or Buffer were NULL.
> 
> -  @retval      RETURN_BUFFER_TOO_SMALL - The Buffer size as indicated by
> 
> -                 the Size parameter was too small for the serialized
> 
> -                 variable data.  Size is returned with the required size.
> 
> -
> 
> -**/
> 
> -RETURN_STATUS
> 
> -EFIAPI
> 
> -SerializeVariablesToBuffer (
> 
> -  IN     EFI_HANDLE                       Handle,
> 
> -  OUT    VOID                             *Buffer,
> 
> -  IN OUT UINTN                            *Size
> 
> -  )
> 
> -{
> 
> -  SV_INSTANCE    *Instance;
> 
> -
> 
> -  Instance = SV_FROM_HANDLE (Handle);
> 
> -
> 
> -  if (Size == NULL) {
> 
> -    return RETURN_INVALID_PARAMETER;
> 
> -  }
> 
> -
> 
> -  if (*Size < Instance->DataSize) {
> 
> -    *Size = Instance->DataSize;
> 
> -    return RETURN_BUFFER_TOO_SMALL;
> 
> -  }
> 
> -
> 
> -  if (Buffer == NULL) {
> 
> -    return RETURN_INVALID_PARAMETER;
> 
> -  }
> 
> -
> 
> -  *Size = Instance->DataSize;
> 
> -  CopyMem (Buffer, Instance->BufferPtr, Instance->DataSize);
> 
> -
> 
> -  return RETURN_SUCCESS;
> 
> -}
> 
> -
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeV
> ariablesLib.h
> b/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeV
> ariablesLib.h
> deleted file mode 100644
> index 9b4c2a629a..0000000000
> ---
> a/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeV
> ariablesLib.h
> +++ /dev/null
> @@ -1,33 +0,0 @@
> -/** @file
> 
> -  Serialize Variables Library implementation
> 
> -
> 
> -  Copyright (c) 2009 - 2019 Intel Corporation. All rights reserved. <BR>
> 
> -
> 
> -  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> -**/
> 
> -
> 
> -#ifndef __SERIALIZE_VARIABLES_LIB_INSTANCE__
> 
> -#define __SERIALIZE_VARIABLES_LIB_INSTANCE__
> 
> -
> 
> -#include <Uefi.h>
> 
> -
> 
> -#include <Library/BaseLib.h>
> 
> -#include <Library/BaseMemoryLib.h>
> 
> -#include <Library/DebugLib.h>
> 
> -#include <Library/MemoryAllocationLib.h>
> 
> -#include <Library/SerializeVariablesLib.h>
> 
> -#include <Library/UefiBootServicesTableLib.h>
> 
> -#include <Library/UefiRuntimeServicesTableLib.h>
> 
> -
> 
> -#define SV_FROM_HANDLE(a)       CR (a, SV_INSTANCE, Signature,
> SV_SIGNATURE)
> 
> -#define SV_SIGNATURE            SIGNATURE_32 ('S', 'V', 'A', 'R')
> 
> -
> 
> -typedef struct {
> 
> -  UINT32                              Signature;
> 
> -  VOID                                *BufferPtr;
> 
> -  UINTN                               BufferSize;
> 
> -  UINTN                               DataSize;
> 
> -} SV_INSTANCE;
> 
> -
> 
> -#endif
> 
> -
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeV
> ariablesLib.inf
> b/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeV
> ariablesLib.inf
> deleted file mode 100644
> index 08c561f586..0000000000
> ---
> a/Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeV
> ariablesLib.inf
> +++ /dev/null
> @@ -1,36 +0,0 @@
> -## @file
> 
> -#  Serialize Variables Library implementation
> 
> -#
> 
> -#  This library serializes and deserializes UEFI variables
> 
> -#
> 
> -# Copyright (c) 2006 - 2019 Intel Corporation. All rights reserved. <BR>
> 
> -#
> 
> -# SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> -#
> 
> -##
> 
> -
> 
> -[Defines]
> 
> -  INF_VERSION                    = 0x00010005
> 
> -  BASE_NAME                      = DxeSerializeVariablesLib
> 
> -  FILE_GUID                      = 266A1434-6B22-441F-A8D2-D54AA8FDF95C
> 
> -  MODULE_TYPE                    = UEFI_DRIVER
> 
> -  VERSION_STRING                 = 1.0
> 
> -  LIBRARY_CLASS                  = SerializeVariablesLib|DXE_DRIVER
> DXE_RUNTIME_DRIVER UEFI_DRIVER
> 
> -
> 
> -[Sources]
> 
> -  SerializeVariablesLib.c
> 
> -
> 
> -[Packages]
> 
> -  MdePkg/MdePkg.dec
> 
> -  MdeModulePkg/MdeModulePkg.dec
> 
> -  ShellPkg/ShellPkg.dec
> 
> -  SimicsOpenBoardPkg/OpenBoardPkg.dec
> 
> -
> 
> -[LibraryClasses]
> 
> -  BaseLib
> 
> -  BaseMemoryLib
> 
> -  DebugLib
> 
> -  MemoryAllocationLib
> 
> -  UefiBootServicesTableLib
> 
> -  UefiRuntimeServicesTableLib
> 
> -
> 
> diff --git a/Platform/Intel/SimicsOpenBoardPkg/OpenBoardPkg.dec
> b/Platform/Intel/SimicsOpenBoardPkg/OpenBoardPkg.dec
> index e8aefdd893..c4e24f1e0c 100644
> --- a/Platform/Intel/SimicsOpenBoardPkg/OpenBoardPkg.dec
> +++ b/Platform/Intel/SimicsOpenBoardPkg/OpenBoardPkg.dec
> @@ -48,9 +48,6 @@
> 
> 
>  [PcdsDynamic, PcdsDynamicEx]
> 
> 
> 
> -  # TODO: investigate whether next two Pcds are needed
> 
> -
> gSimicsOpenBoardPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|0x2
> 8
> 
> -
> gSimicsOpenBoardPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable|FALSE|
> BOOLEAN|0x10
> 
> 
> gSimicsOpenBoardPkgTokenSpaceGuid.PcdSimicsX58HostBridgePciDevId|0|U
> INT16|0x1b
> 
> 
> 
>    ## The IO port aperture shared by all PCI root bridges.
> 
> --
> 2.39.1.windows.1
> 
> 
> 
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#105231):
> https://edk2.groups.io/g/devel/message/105231
> Mute This Topic: https://groups.io/mt/99107257/1712937
> Group Owner: devel+owner@edk2.groups.io
> Unsubscribe:
> https://edk2.groups.io/g/devel/leave/3759105/1712937/893644498/xyzzy
> [ray.ni@intel.com]
> -=-=-=-=-=-=
> 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [edk2-devel] [PATCH 6/6] SimicsOpenBoardPkg: Disable DriverBindingSupport perf logging
       [not found] ` <17621422F0AEB994.8048@groups.io>
@ 2023-05-25  2:11   ` Ni, Ray
  0 siblings, 0 replies; 15+ messages in thread
From: Ni, Ray @ 2023-05-25  2:11 UTC (permalink / raw)
  To: devel@edk2.groups.io, Ni, Ray, Liu, Zhiguang
  Cc: Desimone, Nathaniel L, Kinney, Michael D

Sending to correct address of Zhiguang.

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Ni, Ray
> Sent: Wednesday, May 24, 2023 8:29 PM
> To: devel@edk2.groups.io
> Cc: Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Zhiguang Liu
> <zhiguang@liu@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: [edk2-devel] [PATCH 6/6] SimicsOpenBoardPkg: Disable
> DriverBindingSupport perf logging
> 
> DriverBindingSupport() is called lots of time during post.
> If it's also included in the perf logging, it's very easy to use all
> the FPDT table memory pre-allocated at EndOfDxe because the
> driver binding connect process happens after EndOfDxe.
> 
> PcdExtFpdtBootRecordPadSize was added for holding the
> perf-logging records after EndOfDxe. But the DriverBindingSupport
> records are just too many. For example, SimicsOpenBoardPkg has
> to set this PCD to almost 100x bigger than the default value in order
> to hold all the perf-logging records.
> 
> Platform developers are usually not aware of missing some records
> after EndOfDxe because those records are all about driverbinding
> support/start/stop. But if we add more perf-logging inside SMM,
> those SMM records will be missed in the final FPDT table because
> DxeCorePerformanceLib collects those SMM records at ReadyToBoot
> event. Since the FPDT cannot hold all driverbinding records, it
> definitely cannot hold those SMM records as well.
> 
> So in order to hold all SMM perf loggings, either platform should
> set PcdExtFpdtBootRecordPadSize to a large enough value, or
> as what this patch does, to disable the driverbinding support
> perf-logging.
> 
> Signed-off-by: Ray Ni <ray.ni@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Zhiguang Liu <zhiguang@liu@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> ---
>  .../BoardX58Ich10/OpenBoardPkgPcd.dsc                 | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.ds
> c
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.ds
> c
> index b6672d1a78..6b969ab1f5 100644
> ---
> a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.ds
> c
> +++
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.ds
> c
> @@ -132,7 +132,16 @@
>    gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10
> 
>    gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask|0x0
> 
>  !if gMinPlatformPkgTokenSpaceGuid.PcdPerformanceEnable == TRUE
> 
> -  gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask|0x1
> 
> +  #  BIT0 - Enable Performance Measurement.<BR>
> 
> +  #  BIT1 - Disable Start Image Logging.<BR>
> 
> +  #  BIT2 - Disable Load Image logging.<BR>
> 
> +  #  BIT3 - Disable Binding Support logging.<BR>
> 
> +  #  BIT4 - Disable Binding Start logging.<BR>
> 
> +  #  BIT5 - Disable Binding Stop logging.<BR>
> 
> +  #  BIT6 - Disable all other general Perfs.<BR>
> 
> +  #  BIT1-BIT6 are evaluated when BIT0 is set.<BR>
> 
> +  #  Enable performance measurement but disable driver binding support
> logging.
> 
> +  gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask|0x09
> 
>  !endif
> 
>  !if $(TARGET) == "RELEASE"
> 
>    gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x03
> 
> --
> 2.39.1.windows.1
> 
> 
> 
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#105235):
> https://edk2.groups.io/g/devel/message/105235
> Mute This Topic: https://groups.io/mt/99107262/1712937
> Group Owner: devel+owner@edk2.groups.io
> Unsubscribe:
> https://edk2.groups.io/g/devel/leave/3759105/1712937/893644498/xyzzy
> [ray.ni@intel.com]
> -=-=-=-=-=-=
> 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [edk2-devel] [PATCH 5/6] SimicsOpenBoardPkg: Add "dp" command in performance build
       [not found] ` <176214229D12BE31.8048@groups.io>
@ 2023-05-25  2:11   ` Ni, Ray
  0 siblings, 0 replies; 15+ messages in thread
From: Ni, Ray @ 2023-05-25  2:11 UTC (permalink / raw)
  To: devel@edk2.groups.io, Ni, Ray, Liu, Zhiguang
  Cc: Desimone, Nathaniel L, Kinney, Michael D

Sending to correct address of Zhiguang.

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Ni, Ray
> Sent: Wednesday, May 24, 2023 8:29 PM
> To: devel@edk2.groups.io
> Cc: Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Zhiguang Liu
> <zhiguang@liu@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: [edk2-devel] [PATCH 5/6] SimicsOpenBoardPkg: Add "dp" command
> in performance build
> 
> Signed-off-by: Ray Ni <ray.ni@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Zhiguang Liu <zhiguang@liu@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> ---
>  .../SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc     | 8 ++++++++
>  .../SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf     | 3 +++
>  2 files changed, 11 insertions(+)
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
> index 4e8991dbdf..3257156d23 100644
> ---
> a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
> +++
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.dsc
> @@ -265,6 +265,14 @@
>        ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
> 
>    }
> 
> 
> 
> +
> 
> +!if gMinPlatformPkgTokenSpaceGuid.PcdPerformanceEnable == TRUE
> 
> +
> ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf
> {
> 
> +    <PcdsFixedAtBuild>
> 
> +      gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> 
> +  }
> 
> +!endif
> 
> +
> 
>    #######################################
> 
>    # Silicon Initialization Package
> 
>    #######################################
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
> index aa44c01784..ceace433a6 100644
> --- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
> +++
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
> @@ -227,6 +227,9 @@ FILE FREEFORM = 7BB28B99-61BB-11D5-9A5D-
> 0090273FC14D {
>  }
> 
> 
> 
>  INF  ShellPkg/Application/Shell/Shell.inf
> 
> +!if gMinPlatformPkgTokenSpaceGuid.PcdPerformanceEnable == TRUE
> 
> +INF
> ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf
> 
> +!endif
> 
> 
> 
>  #
> 
>  # Network modules
> 
> --
> 2.39.1.windows.1
> 
> 
> 
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#105234):
> https://edk2.groups.io/g/devel/message/105234
> Mute This Topic: https://groups.io/mt/99107261/1712937
> Group Owner: devel+owner@edk2.groups.io
> Unsubscribe:
> https://edk2.groups.io/g/devel/leave/3759105/1712937/893644498/xyzzy
> [ray.ni@intel.com]
> -=-=-=-=-=-=
> 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [edk2-devel] [PATCH 3/6] SimicsOpenBoardPkg: Enable serial terminal
       [not found] ` <17621421D3F4CA3E.12947@groups.io>
@ 2023-05-25  2:11   ` Ni, Ray
  0 siblings, 0 replies; 15+ messages in thread
From: Ni, Ray @ 2023-05-25  2:11 UTC (permalink / raw)
  To: devel@edk2.groups.io, Ni, Ray, Liu, Zhiguang
  Cc: Desimone, Nathaniel L, Kinney, Michael D

Sending to correct address of Zhiguang.

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Ni, Ray
> Sent: Wednesday, May 24, 2023 8:29 PM
> To: devel@edk2.groups.io
> Cc: Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Zhiguang Liu
> <zhiguang@liu@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: [edk2-devel] [PATCH 3/6] SimicsOpenBoardPkg: Enable serial
> terminal
> 
> Signed-off-by: Ray Ni <ray.ni@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Zhiguang Liu <zhiguang@liu@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> ---
>  .../BoardX58Ich10/OpenBoardPkg.fdf            |  1 -
>  .../BoardX58Ich10/OpenBoardPkgPcd.dsc         |  1 +
>  .../Library/BoardBdsHookLib/BoardBdsHookLib.c | 56 ++++++++-----------
>  3 files changed, 24 insertions(+), 34 deletions(-)
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
> index 6ecff76362..aa44c01784 100644
> --- a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
> +++
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkg.fdf
> @@ -198,7 +198,6 @@ INF  UefiCpuPkg/CpuDxe/CpuDxe.inf
>  INF  MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf
> 
>  INF
> MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDx
> e.inf
> 
>  INF  UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf
> 
> -INF  MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
> 
>  INF  MdeModulePkg/Universal/PrintDxe/PrintDxe.inf
> 
>  INF  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
> 
>  INF  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.ds
> c
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.ds
> c
> index 732d95e44f..b6672d1a78 100644
> ---
> a/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.ds
> c
> +++
> b/Platform/Intel/SimicsOpenBoardPkg/BoardX58Ich10/OpenBoardPkgPcd.ds
> c
> @@ -69,6 +69,7 @@
>    ######################################
> 
>    gNetworkFeaturePkgTokenSpaceGuid.PcdNetworkFeatureEnable|TRUE
> 
>    gSmbiosFeaturePkgTokenSpaceGuid.PcdSmbiosFeatureEnable|TRUE
> 
> +  gMinPlatformPkgTokenSpaceGuid.PcdSerialTerminalEnable|TRUE
> 
> 
> 
>  [PcdsFeatureFlag.X64]
> 
>    ######################################
> 
> diff --git
> a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsH
> ookLib.c
> b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsH
> ookLib.c
> index 3c6385c12f..238513f666 100644
> ---
> a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsH
> ookLib.c
> +++
> b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsH
> ookLib.c
> @@ -837,45 +837,35 @@ PlatformInitializeConsole (
>    )
> 
>  {
> 
>    UINTN                              Index;
> 
> -  EFI_DEVICE_PATH_PROTOCOL           *VarConout;
> 
> -  EFI_DEVICE_PATH_PROTOCOL           *VarConin;
> 
> 
> 
>    //
> 
> -  // Connect RootBridge
> 
> +  // Do platform specific PCI Device check and add them to ConOut, ConIn,
> ErrOut
> 
> +  // Note: Why perform the ConIn/ConOut/ErrOut variables update without
> checking
> 
> +  //          whether "ConIn", "ConOut" or "ErrOut" is present in the variable
> store?
> 
> +  //       Because SerialPortTerminalLib.constructor() adds the serial terminal
> device
> 
> +  //          to "ConIn", "ConOut" and "ErrOut" variables always, checking
> presence of
> 
> +  //          the three variables will lead to the following update logic never runs.
> 
>    //
> 
> -  GetEfiGlobalVariable2 (EFI_CON_OUT_VARIABLE_NAME, (VOID **)
> &VarConout, NULL);
> 
> -  GetEfiGlobalVariable2 (EFI_CON_IN_VARIABLE_NAME, (VOID **)
> &VarConin, NULL);
> 
> -
> 
> -  if (VarConout == NULL || VarConin == NULL) {
> 
> -    //
> 
> -    // Do platform specific PCI Device check and add them to ConOut, ConIn,
> ErrOut
> 
> -    //
> 
> -    DetectAndPreparePlatformPciDevicePaths (FALSE);
> 
> -    DetectAndPreparePlatformPciDevicePaths(TRUE);
> 
> +  DetectAndPreparePlatformPciDevicePaths (FALSE);
> 
> +  DetectAndPreparePlatformPciDevicePaths(TRUE);
> 
> +  //
> 
> +  // Have chance to connect the platform default console,
> 
> +  // the platform default console is the minimue device group
> 
> +  // the platform should support
> 
> +  //
> 
> +  for (Index = 0; PlatformConsole[Index].DevicePath != NULL; ++Index) {
> 
>      //
> 
> -    // Have chance to connect the platform default console,
> 
> -    // the platform default console is the minimue device group
> 
> -    // the platform should support
> 
> +    // Update the console variable with the connect type
> 
>      //
> 
> -    for (Index = 0; PlatformConsole[Index].DevicePath != NULL; ++Index) {
> 
> -      //
> 
> -      // Update the console variable with the connect type
> 
> -      //
> 
> -      if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) ==
> CONSOLE_IN) {
> 
> -        EfiBootManagerUpdateConsoleVariable (ConIn,
> PlatformConsole[Index].DevicePath, NULL);
> 
> -      }
> 
> -      if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) ==
> CONSOLE_OUT) {
> 
> -        EfiBootManagerUpdateConsoleVariable (ConOut,
> PlatformConsole[Index].DevicePath, NULL);
> 
> -      }
> 
> -      if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
> 
> -        EfiBootManagerUpdateConsoleVariable (ErrOut,
> PlatformConsole[Index].DevicePath, NULL);
> 
> -      }
> 
> +    if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN)
> {
> 
> +      EfiBootManagerUpdateConsoleVariable (ConIn,
> PlatformConsole[Index].DevicePath, NULL);
> 
> +    }
> 
> +    if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) ==
> CONSOLE_OUT) {
> 
> +      EfiBootManagerUpdateConsoleVariable (ConOut,
> PlatformConsole[Index].DevicePath, NULL);
> 
> +    }
> 
> +    if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
> 
> +      EfiBootManagerUpdateConsoleVariable (ErrOut,
> PlatformConsole[Index].DevicePath, NULL);
> 
>      }
> 
> -  } else {
> 
> -    //
> 
> -    // Only detect VGA device and add them to ConOut
> 
> -    //
> 
> -    DetectAndPreparePlatformPciDevicePaths (TRUE);
> 
>    }
> 
>  }
> 
> 
> 
> --
> 2.39.1.windows.1
> 
> 
> 
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#105232):
> https://edk2.groups.io/g/devel/message/105232
> Mute This Topic: https://groups.io/mt/99107258/1712937
> Group Owner: devel+owner@edk2.groups.io
> Unsubscribe:
> https://edk2.groups.io/g/devel/leave/3759105/1712937/893644498/xyzzy
> [ray.ni@intel.com]
> -=-=-=-=-=-=
> 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [edk2-devel] [PATCH 0/6] Fine tune SimicsOpenBoardPkg
  2023-05-24 12:28 [PATCH 0/6] Fine tune SimicsOpenBoardPkg Ni, Ray
                   ` (10 preceding siblings ...)
       [not found] ` <17621421D3F4CA3E.12947@groups.io>
@ 2023-05-26  6:36 ` Zhiguang Liu
  11 siblings, 0 replies; 15+ messages in thread
From: Zhiguang Liu @ 2023-05-26  6:36 UTC (permalink / raw)
  To: devel@edk2.groups.io, Ni, Ray

Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Ni, Ray
> Sent: Wednesday, May 24, 2023 8:29 PM
> To: devel@edk2.groups.io
> Subject: [edk2-devel] [PATCH 0/6] Fine tune SimicsOpenBoardPkg
> 
> 
> Ray Ni (6):
>   SimicsOpenBoardPkg: Remove un-used PlatformBootManagerLib
>   SimicsOpenBoardPkg: Remove logic that loads variable from disk file
>   SimicsOpenBoardPkg: Enable serial terminal
>   MinPlatform/build_bios.py: Support performance enabled build
>   SimicsOpenBoardPkg: Add "dp" command in performance build
>   SimicsOpenBoardPkg: Disable DriverBindingSupport perf logging
> 
>  .../BoardX58Ich10/OpenBoardPkg.dsc            |   10 +-
>  .../BoardX58Ich10/OpenBoardPkg.fdf            |    4 +-
>  .../BoardX58Ich10/OpenBoardPkgPcd.dsc         |   12 +-
>  .../Include/Library/SerializeVariablesLib.h   |  224 ---
>  .../Library/BoardBdsHookLib/BoardBdsHookLib.c |  180 +-
>  .../BoardBdsHookLib/BoardBdsHookLib.inf       |    3 -
>  .../Library/NvVarsFileLib/FsAccess.c          |  507 ------
>  .../Library/NvVarsFileLib/NvVarsFileLib.c     |   77 -
>  .../Library/NvVarsFileLib/NvVarsFileLib.h     |   55 -
>  .../Library/NvVarsFileLib/NvVarsFileLib.inf   |   53 -
>  .../PlatformBootManagerLib/BdsPlatform.c      | 1532 -----------------
>  .../PlatformBootManagerLib/BdsPlatform.h      |  172 --
>  .../PlatformBootManagerLib.inf                |   72 -
>  .../PlatformBootManagerLib/PlatformData.c     |   35 -
>  .../SerializeVariablesLib.c                   |  869 ----------
>  .../SerializeVariablesLib.h                   |   33 -
>  .../SerializeVariablesLib.inf                 |   36 -
>  .../Intel/SimicsOpenBoardPkg/OpenBoardPkg.dec |    3 -
>  Platform/Intel/build_bios.py                  |    6 +-
>  19 files changed, 50 insertions(+), 3833 deletions(-)  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Include/Library/SerializeVariablesLib.h
>  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/FsAccess.c
>  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.c
>  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.h
>  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
>  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/BdsPl
> atform.c
>  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/BdsPl
> atform.h
>  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/Platf
> ormBootManagerLib.inf
>  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/PlatformBootManagerLib/Platf
> ormData.c
>  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeVa
> riablesLib.c
>  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeVa
> riablesLib.h
>  delete mode 100644
> Platform/Intel/SimicsOpenBoardPkg/Library/SerializeVariablesLib/SerializeVa
> riablesLib.inf
> 
> --
> 2.39.1.windows.1
> 
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2023-05-26  6:36 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-24 12:28 [PATCH 0/6] Fine tune SimicsOpenBoardPkg Ni, Ray
2023-05-24 12:28 ` [PATCH 1/6] SimicsOpenBoardPkg: Remove un-used PlatformBootManagerLib Ni, Ray
2023-05-24 12:28 ` [PATCH 2/6] SimicsOpenBoardPkg: Remove logic that loads variable from disk file Ni, Ray
2023-05-24 12:28 ` [PATCH 3/6] SimicsOpenBoardPkg: Enable serial terminal Ni, Ray
2023-05-24 12:28 ` [PATCH 4/6] MinPlatform/build_bios.py: Support performance enabled build Ni, Ray
2023-05-24 23:07   ` Chiu, Chasel
2023-05-25  0:44     ` Ni, Ray
2023-05-24 12:28 ` [PATCH 5/6] SimicsOpenBoardPkg: Add "dp" command in performance build Ni, Ray
2023-05-24 12:28 ` [PATCH 6/6] SimicsOpenBoardPkg: Disable DriverBindingSupport perf logging Ni, Ray
     [not found] ` <17621420EF808DC9.12947@groups.io>
2023-05-25  2:10   ` [edk2-devel] [PATCH 1/6] SimicsOpenBoardPkg: Remove un-used PlatformBootManagerLib Ni, Ray
     [not found] ` <17621421B6E6FB43.8048@groups.io>
2023-05-25  2:10   ` [edk2-devel] [PATCH 2/6] SimicsOpenBoardPkg: Remove logic that loads variable from disk file Ni, Ray
     [not found] ` <17621422F0AEB994.8048@groups.io>
2023-05-25  2:11   ` [edk2-devel] [PATCH 6/6] SimicsOpenBoardPkg: Disable DriverBindingSupport perf logging Ni, Ray
     [not found] ` <176214229D12BE31.8048@groups.io>
2023-05-25  2:11   ` [edk2-devel] [PATCH 5/6] SimicsOpenBoardPkg: Add "dp" command in performance build Ni, Ray
     [not found] ` <17621421D3F4CA3E.12947@groups.io>
2023-05-25  2:11   ` [edk2-devel] [PATCH 3/6] SimicsOpenBoardPkg: Enable serial terminal Ni, Ray
2023-05-26  6:36 ` [edk2-devel] [PATCH 0/6] Fine tune SimicsOpenBoardPkg Zhiguang Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox