]> git.proxmox.com Git - mirror_edk2.git/blobdiff - DuetPkg/Library/DuetBdsLib/BdsPlatform.c
Fix VS2013 build failure.
[mirror_edk2.git] / DuetPkg / Library / DuetBdsLib / BdsPlatform.c
index f73f824f2d7ce4c65b9d0675316ee0bdd0de87cd..1875dc963680c0fff3e397a16e9004a9008f6197 100644 (file)
@@ -1,7 +1,7 @@
 /*++\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
@@ -24,9 +24,13 @@ Abstract:
 \r
 #define IS_PCI_ISA_PDECODE(_p)        IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0)\r
 \r
-CHAR16  mFirmwareVendor[] = L"TianoCore.org";\r
 extern BOOLEAN  gConnectAllHappened;\r
 extern USB_CLASS_FORMAT_DEVICE_PATH gUsbClassKeyboardDevicePath;\r
+\r
+EFI_GUID                    *gTableGuidArray[] = {\r
+    &gEfiAcpi20TableGuid, &gEfiAcpiTableGuid, &gEfiSmbiosTableGuid, &gEfiMpsTableGuid\r
+  };\r
+\r
 //\r
 // BDS Platform Functions\r
 //\r
@@ -52,9 +56,6 @@ Returns:
   EFI_PEI_HOB_POINTERS        HobStart;\r
   EFI_PHYSICAL_ADDRESS        *Table;\r
   UINTN                       Index;\r
-  EFI_GUID                    *TableGuidArray[] = {\r
-    &gEfiAcpi20TableGuid, &gEfiAcpiTableGuid, &gEfiSmbiosTableGuid, &gEfiMpsTableGuid\r
-  };\r
 \r
   //\r
   // Get Hob List\r
@@ -63,8 +64,8 @@ Returns:
   //\r
   // Iteratively add ACPI Table, SMBIOS Table, MPS Table to EFI System Table\r
   //\r
-  for (Index = 0; Index < sizeof (TableGuidArray) / sizeof (*TableGuidArray); ++Index) {\r
-    GuidHob.Raw = GetNextGuidHob (TableGuidArray[Index], HobStart.Raw);\r
+  for (Index = 0; Index < sizeof (gTableGuidArray) / sizeof (*gTableGuidArray); ++Index) {\r
+    GuidHob.Raw = GetNextGuidHob (gTableGuidArray[Index], HobStart.Raw);\r
     if (GuidHob.Raw != NULL) {\r
       Table = GET_GUID_HOB_DATA (GuidHob.Guid);\r
       if (Table != NULL) {\r
@@ -73,8 +74,8 @@ Returns:
         // According to UEFI Spec, we should make sure Smbios table, \r
         // ACPI table and Mps tables kept in memory of specified type\r
         //\r
-        ConvertSystemTable(TableGuidArray[Index], &Table);\r
-        gBS->InstallConfigurationTable (TableGuidArray[Index], (VOID *)Table);\r
+        ConvertSystemTable(gTableGuidArray[Index], (VOID**)&Table);\r
+        gBS->InstallConfigurationTable (gTableGuidArray[Index], (VOID *)Table);\r
       }\r
     }\r
   }\r
@@ -82,21 +83,6 @@ Returns:
   return ;\r
 }\r
 \r
-#define EFI_LDR_MEMORY_DESCRIPTOR_GUID \\r
-  { 0x7701d7e5, 0x7d1d, 0x4432, 0xa4, 0x68, 0x67, 0x3d, 0xab, 0x8a, 0xde, 0x60 }\r
-\r
-EFI_GUID gEfiLdrMemoryDescriptorGuid = EFI_LDR_MEMORY_DESCRIPTOR_GUID;\r
-\r
-#pragma pack(1)\r
-\r
-typedef struct {\r
-  EFI_HOB_GUID_TYPE             Hob;\r
-  UINTN                         MemDescCount;\r
-  EFI_MEMORY_DESCRIPTOR         *MemDesc;\r
-} MEMORY_DESC_HOB;\r
-\r
-#pragma pack()\r
-\r
 #if 0\r
 VOID\r
 PrintMemoryMap (\r
@@ -145,19 +131,15 @@ UpdateMemoryMap (
   VOID\r
   )\r
 {\r
-  EFI_STATUS                  Status;\r
-  EFI_PEI_HOB_POINTERS        GuidHob;\r
-  VOID                        *Table;\r
-  MEMORY_DESC_HOB             MemoryDescHob;\r
-  UINTN                       Index;\r
-  EFI_PHYSICAL_ADDRESS        Memory;\r
-\r
-  //\r
-  // Get Hob List\r
-  //\r
-  GuidHob.Raw = GetHobList();\r
+  EFI_STATUS                      Status;\r
+  EFI_PEI_HOB_POINTERS            GuidHob;\r
+  VOID                            *Table;\r
+  MEMORY_DESC_HOB                 MemoryDescHob;\r
+  UINTN                           Index;\r
+  EFI_PHYSICAL_ADDRESS            Memory;\r
+  EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor;\r
   \r
-  GuidHob.Raw = GetNextGuidHob (&gEfiLdrMemoryDescriptorGuid, GuidHob.Raw);\r
+  GuidHob.Raw = GetFirstGuidHob (&gLdrMemoryDescriptorGuid);\r
   if (GuidHob.Raw == NULL) {\r
     DEBUG ((EFI_D_ERROR, "Fail to get gEfiLdrMemoryDescriptorGuid from GUID HOB LIST!\n"));\r
     return;\r
@@ -177,7 +159,7 @@ UpdateMemoryMap (
     if (MemoryDescHob.MemDesc[Index].PhysicalStart < 0x100000) {\r
       continue;\r
     }\r
-    if (MemoryDescHob.MemDesc[Index].PhysicalStart >= 0x100000000) {\r
+    if (MemoryDescHob.MemDesc[Index].PhysicalStart >= 0x100000000ULL) {\r
       continue;\r
     }\r
     if ((MemoryDescHob.MemDesc[Index].Type == EfiReservedMemoryType) ||\r
@@ -185,16 +167,62 @@ UpdateMemoryMap (
         (MemoryDescHob.MemDesc[Index].Type == EfiRuntimeServicesCode) ||\r
         (MemoryDescHob.MemDesc[Index].Type == EfiACPIReclaimMemory) ||\r
         (MemoryDescHob.MemDesc[Index].Type == EfiACPIMemoryNVS)) {\r
-      DEBUG ((EFI_D_ERROR, "PhysicalStart - 0x%x, ", MemoryDescHob.MemDesc[Index].PhysicalStart));\r
-      DEBUG ((EFI_D_ERROR, "PageNumber    - 0x%x, ", MemoryDescHob.MemDesc[Index].NumberOfPages));\r
-      DEBUG ((EFI_D_ERROR, "Type          - 0x%x\n", MemoryDescHob.MemDesc[Index].Type));\r
+      DEBUG ((EFI_D_ERROR, "PhysicalStart - 0x%016lx, ", MemoryDescHob.MemDesc[Index].PhysicalStart));\r
+      DEBUG ((EFI_D_ERROR, "PageNumber    - 0x%016lx, ", MemoryDescHob.MemDesc[Index].NumberOfPages));\r
+      DEBUG ((EFI_D_ERROR, "Attribute     - 0x%016lx, ", MemoryDescHob.MemDesc[Index].Attribute));\r
+      DEBUG ((EFI_D_ERROR, "Type          - 0x%08x\n", MemoryDescHob.MemDesc[Index].Type));\r
       if ((MemoryDescHob.MemDesc[Index].Type == EfiRuntimeServicesData) ||\r
           (MemoryDescHob.MemDesc[Index].Type == EfiRuntimeServicesCode)) {\r
         //\r
-        // Skip RuntimeSevicesData and RuntimeServicesCode, they are BFV\r
+        // For RuntimeSevicesData and RuntimeServicesCode, they are BFV or DxeCore.\r
+        // The memory type is assigned in EfiLdr\r
+        //\r
+        Status = gDS->GetMemorySpaceDescriptor (MemoryDescHob.MemDesc[Index].PhysicalStart, &Descriptor);\r
+        if (EFI_ERROR (Status)) {\r
+          continue;\r
+        }\r
+        if (Descriptor.GcdMemoryType != EfiGcdMemoryTypeReserved) {\r
+          //\r
+          // BFV or tested DXE core\r
+          //\r
+          continue;\r
+        }\r
+        //\r
+        // Untested DXE Core region, free and remove\r
+        //\r
+        Status = gDS->FreeMemorySpace (\r
+                        MemoryDescHob.MemDesc[Index].PhysicalStart,\r
+                        LShiftU64 (MemoryDescHob.MemDesc[Index].NumberOfPages, EFI_PAGE_SHIFT)\r
+                        );\r
+        if (EFI_ERROR (Status)) {\r
+          DEBUG ((EFI_D_ERROR, "FreeMemorySpace fail - %r!\n", Status));\r
+          continue;\r
+        }\r
+        Status = gDS->RemoveMemorySpace (\r
+                        MemoryDescHob.MemDesc[Index].PhysicalStart,\r
+                        LShiftU64 (MemoryDescHob.MemDesc[Index].NumberOfPages, EFI_PAGE_SHIFT)\r
+                        );\r
+        if (EFI_ERROR (Status)) {\r
+          DEBUG ((EFI_D_ERROR, "RemoveMemorySpace fail - %r!\n", Status));\r
+          continue;\r
+        }\r
+\r
+        //\r
+        // Convert Runtime type to BootTime type\r
+        //\r
+        if (MemoryDescHob.MemDesc[Index].Type == EfiRuntimeServicesData) {\r
+          MemoryDescHob.MemDesc[Index].Type = EfiBootServicesData;\r
+        } else {\r
+          MemoryDescHob.MemDesc[Index].Type = EfiBootServicesCode;\r
+        }\r
+\r
+        //\r
+        // PassThrough, let below code add and alloate.\r
         //\r
-        continue;\r
       }\r
+      //\r
+      // ACPI or reserved memory\r
+      //\r
       Status = gDS->AddMemorySpace (\r
                       EfiGcdMemoryTypeSystemMemory,\r
                       MemoryDescHob.MemDesc[Index].PhysicalStart,\r
@@ -202,7 +230,7 @@ UpdateMemoryMap (
                       MemoryDescHob.MemDesc[Index].Attribute\r
                       );\r
       if (EFI_ERROR (Status)) {\r
-        DEBUG ((EFI_D_ERROR, "AddMemorySpace fail!\n"));\r
+        DEBUG ((EFI_D_ERROR, "AddMemorySpace fail - %r!\n", Status));\r
         if ((MemoryDescHob.MemDesc[Index].Type == EfiACPIReclaimMemory) ||\r
             (MemoryDescHob.MemDesc[Index].Type == EfiACPIMemoryNVS)) {\r
           //\r
@@ -217,12 +245,12 @@ UpdateMemoryMap (
       Memory = MemoryDescHob.MemDesc[Index].PhysicalStart;\r
       Status = gBS->AllocatePages (\r
                       AllocateAddress,\r
-                      MemoryDescHob.MemDesc[Index].Type,\r
+                      (EFI_MEMORY_TYPE)MemoryDescHob.MemDesc[Index].Type,\r
                       (UINTN)MemoryDescHob.MemDesc[Index].NumberOfPages,\r
                       &Memory\r
                       );\r
       if (EFI_ERROR (Status)) {\r
-        DEBUG ((EFI_D_ERROR, "AllocatePages fail!\n"));\r
+        DEBUG ((EFI_D_ERROR, "AllocatePages fail - %r!\n", Status));\r
         //\r
         // For the page added, it must be allocated.\r
         //\r
@@ -289,13 +317,13 @@ Returns:
         if (!EFI_ERROR (Status)) {\r
           if ((PCI_CLASS_SERIAL == Class[2]) &&\r
               (PCI_CLASS_SERIAL_USB == Class[1])) {\r
-            if (PCI_CLASSC_PI_UHCI == Class[0]) {\r
+            if (PCI_IF_UHCI == Class[0]) {\r
               //\r
               // Found the UHCI, then disable the legacy support\r
               //\r
               Command = 0;\r
               Status = PciIo->Pci.Write (PciIo, EfiPciIoWidthUint16, 0xC0, 1, &Command);\r
-            } else if (PCI_CLASSC_PI_EHCI == Class[0]) {\r
+            } else if (PCI_IF_EHCI == Class[0]) {\r
               //\r
               // Found the EHCI, then disable the legacy support\r
               //\r
@@ -347,8 +375,9 @@ Returns:
 \r
 \r
 VOID\r
+EFIAPI\r
 PlatformBdsInit (\r
-  IN EFI_BDS_ARCH_PROTOCOL_INSTANCE  *PrivateData\r
+  VOID\r
   )\r
 /*++\r
 \r
@@ -359,30 +388,12 @@ Routine Description:
 \r
 Arguments:\r
 \r
-  PrivateData  - The EFI_BDS_ARCH_PROTOCOL_INSTANCE instance\r
-\r
 Returns:\r
 \r
   None.\r
 \r
 --*/\r
 {\r
-  //\r
-  // set firmwarevendor, here can be IBV/OEM customize\r
-  //\r
-  gST->FirmwareVendor = AllocateRuntimeCopyPool (\r
-                          sizeof (mFirmwareVendor),\r
-                          &mFirmwareVendor\r
-                          );\r
-  ASSERT (gST->FirmwareVendor != NULL);\r
-\r
-  gST->FirmwareRevision = 0;\r
-\r
-  //\r
-  // Fixup Tasble CRC after we updated Firmware Vendor and Revision\r
-  //\r
-  gBS->CalculateCrc32 ((VOID *) gST, sizeof (EFI_SYSTEM_TABLE), &gST->Hdr.CRC32);\r
-\r
   GetSystemTablesFromHob ();\r
 \r
   UpdateMemoryMap ();\r
@@ -422,23 +433,16 @@ Returns:
   UINT32                                   Number;\r
   EFI_PEI_HOB_POINTERS                     GuidHob;\r
 \r
-  BufferSize = 0;\r
-  //\r
-  // Get Hob List from configuration table\r
-  //\r
-  GuidHob.Raw = GetHobList ();\r
-\r
   //\r
   // Get PciExpressAddressInfo Hob\r
   //\r
-  GuidHob.Raw = GetNextGuidHob (&gEfiPciExpressBaseAddressGuid, GuidHob.Raw);\r
-  if (GuidHob.Raw == NULL) {\r
-    DEBUG ((EFI_D_ERROR, "Fail to get gEfiPciExpressBaseAddressGuid from GUID HOB\n"));\r
-    return 0;\r
-  }\r
-  PciExpressBaseAddressInfo = (EFI_PCI_EXPRESS_BASE_ADDRESS_INFORMATION *) GET_GUID_HOB_DATA (GuidHob.Guid);\r
-  if (PciExpressBaseAddressInfo == NULL) {\r
-    DEBUG ((EFI_D_ERROR, "Fail to get gEfiPciExpressBaseAddressGuid from GUID HOB\n"));\r
+  PciExpressBaseAddressInfo = NULL;\r
+  BufferSize                = 0;\r
+  GuidHob.Raw = GetFirstGuidHob (&gEfiPciExpressBaseAddressGuid);\r
+  if (GuidHob.Raw != NULL) {\r
+    PciExpressBaseAddressInfo = GET_GUID_HOB_DATA (GuidHob.Guid);\r
+    BufferSize                = GET_GUID_HOB_DATA_SIZE (GuidHob.Guid);\r
+  } else {\r
     return 0;\r
   }\r
 \r
@@ -456,7 +460,7 @@ Returns:
   //\r
   // Do not find the PciExpress Base Address in the Hob\r
   //\r
-  return 0;\r
+  return 0;  \r
 }\r
 \r
 VOID\r
@@ -469,7 +473,9 @@ PatchPciRootBridgeDevicePath (
   UINT64  PciExpressBase;\r
 \r
   PciExpressBase = GetPciExpressBaseAddressForRootBridge (HostBridgeNumber, RootBridgeNumber);\r
-\r
+  \r
+  DEBUG ((EFI_D_INFO, "Get PciExpress Address from Hob: 0x%X\n", PciExpressBase));\r
+  \r
   if (PciExpressBase != 0) {\r
     RootBridge->PciRootBridge.HID = EISA_PNP_ID(0x0A08);\r
   }\r
@@ -514,6 +520,8 @@ Returns:
                   &gPlatformRootBridges[0], \r
                   &RootHandle\r
                   );\r
+  DEBUG ((EFI_D_INFO, "Pci Root bridge handle is 0x%X\n", RootHandle));\r
+  \r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
@@ -557,7 +565,7 @@ Returns:
   Status = gBS->HandleProtocol (\r
                   DeviceHandle,\r
                   &gEfiDevicePathProtocolGuid,\r
-                  &DevicePath\r
+                  (VOID*)&DevicePath\r
                   );\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
@@ -655,7 +663,7 @@ GetGopDevicePath (
     // Add all the child handles as possible Console Device\r
     //\r
     for (Index = 0; Index < GopHandleCount; Index++) {\r
-      Status = gBS->HandleProtocol (GopHandleBuffer[Index], &gEfiDevicePathProtocolGuid, &TempDevicePath);\r
+      Status = gBS->HandleProtocol (GopHandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID*)&TempDevicePath);\r
       if (EFI_ERROR (Status)) {\r
         continue;\r
       }\r
@@ -713,11 +721,12 @@ Returns:
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
   EFI_DEVICE_PATH_PROTOCOL  *GopDevicePath;\r
 \r
-  DevicePath = NULL;\r
+  DevicePath    = NULL;\r
+  GopDevicePath = NULL;\r
   Status = gBS->HandleProtocol (\r
                   DeviceHandle,\r
                   &gEfiDevicePathProtocolGuid,\r
-                  &DevicePath\r
+                  (VOID*)&DevicePath\r
                   );\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
@@ -755,12 +764,12 @@ Returns:
 {\r
   EFI_STATUS                Status;\r
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-\r
+  \r
   DevicePath = NULL;\r
   Status = gBS->HandleProtocol (\r
                   DeviceHandle,\r
                   &gEfiDevicePathProtocolGuid,\r
-                  &DevicePath\r
+                  (VOID*)&DevicePath\r
                   );\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
@@ -821,7 +830,7 @@ Returns:
   }\r
 \r
   for (Index = 0; Index < HandleCount; Index++) {\r
-    Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiPciIoProtocolGuid, &PciIo);\r
+    Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiPciIoProtocolGuid, (VOID*)&PciIo);\r
     if (EFI_ERROR (Status)) {\r
       continue;\r
     }\r
@@ -932,6 +941,7 @@ Returns:
                &gEfiGlobalVariableGuid,\r
                &DevicePathSize\r
                );\r
+  \r
   if (VarConout == NULL || VarConin == NULL) {\r
     //\r
     // Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut\r
@@ -1064,7 +1074,8 @@ Returns:
 VOID\r
 PlatformBdsDiagnostics (\r
   IN EXTENDMEM_COVERAGE_LEVEL    MemoryTestLevel,\r
-  IN BOOLEAN                     QuietBoot\r
+  IN BOOLEAN                     QuietBoot,\r
+  IN BASEM_MEMORY_TEST           BaseMemoryTest\r
   )\r
 /*++\r
 \r
@@ -1078,6 +1089,8 @@ Arguments:
   MemoryTestLevel  - The memory test intensive level\r
   \r
   QuietBoot        - Indicate if need to enable the quiet boot\r
+\r
+  BaseMemoryTest   - A pointer to BdsMemoryTest()\r
  \r
 Returns:\r
 \r
@@ -1094,7 +1107,7 @@ Returns:
   // from the graphic lib\r
   //\r
   if (QuietBoot) {\r
-    Status = EnableQuietBootEx (&gEfiDefaultBmpLogoGuid, mBdsImageHandle);\r
+    Status = EnableQuietBoot (PcdGetPtr(PcdLogoFile));\r
     if (EFI_ERROR (Status)) {\r
       DisableQuietBoot ();\r
       return;\r
@@ -1103,7 +1116,7 @@ Returns:
     //\r
     // Perform system diagnostic\r
     //\r
-    Status = BdsMemoryTest (MemoryTestLevel);\r
+    Status = BaseMemoryTest (MemoryTestLevel);\r
     if (EFI_ERROR (Status)) {\r
       DisableQuietBoot ();\r
     }\r
@@ -1113,14 +1126,16 @@ Returns:
   //\r
   // Perform system diagnostic\r
   //\r
-  Status = BdsMemoryTest (MemoryTestLevel);\r
+  Status = BaseMemoryTest (MemoryTestLevel);\r
 }\r
 \r
 VOID\r
+EFIAPI\r
 PlatformBdsPolicyBehavior (\r
-  IN EFI_BDS_ARCH_PROTOCOL_INSTANCE  *PrivateData,\r
   IN OUT LIST_ENTRY              *DriverOptionList,\r
-  IN OUT LIST_ENTRY              *BootOptionList\r
+  IN OUT LIST_ENTRY              *BootOptionList,\r
+  IN PROCESS_CAPSULES            ProcessCapsules,\r
+  IN BASEM_MEMORY_TEST           BaseMemoryTest\r
   )\r
 /*++\r
 \r
@@ -1132,8 +1147,6 @@ Routine Description:
   \r
 Arguments:\r
 \r
-  PrivateData      - The EFI_BDS_ARCH_PROTOCOL_INSTANCE instance\r
-  \r
   DriverOptionList - The header of the driver option link list\r
   \r
   BootOptionList   - The header of the boot option link list\r
@@ -1147,16 +1160,14 @@ Returns:
   EFI_STATUS                         Status;\r
   UINT16                             Timeout;\r
   EFI_EVENT                          UserInputDurationTime;\r
-  LIST_ENTRY                     *Link;\r
-  BDS_COMMON_OPTION                  *BootOption;\r
   UINTN                              Index;\r
   EFI_INPUT_KEY                      Key;\r
-  EFI_TPL                            OldTpl;\r
+  EFI_BOOT_MODE                      BootMode;\r
 \r
   //\r
   // Init the time out value\r
   //\r
-  Timeout = BdsLibGetTimeout ();\r
+  Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
 \r
   //\r
   // Load the driver option as the driver option list\r
@@ -1166,14 +1177,14 @@ Returns:
   //\r
   // Get current Boot Mode\r
   //\r
-  Status = BdsLibGetBootMode (&PrivateData->BootMode);\r
-  DEBUG ((EFI_D_ERROR, "Boot Mode:%x\n", PrivateData->BootMode));\r
+  Status = BdsLibGetBootMode (&BootMode);\r
+  DEBUG ((EFI_D_ERROR, "Boot Mode:%x\n", BootMode));\r
 \r
   //\r
   // Go the different platform policy with different boot mode\r
   // Notes: this part code can be change with the table policy\r
   //\r
-  ASSERT (PrivateData->BootMode == BOOT_WITH_FULL_CONFIGURATION);\r
+  ASSERT (BootMode == BOOT_WITH_FULL_CONFIGURATION);\r
   //\r
   // Connect platform console\r
   //\r
@@ -1188,7 +1199,7 @@ Returns:
   // Create a 300ms duration event to ensure user has enough input time to enter Setup\r
   //\r
   Status = gBS->CreateEvent (\r
-                  EFI_EVENT_TIMER,\r
+                  EVT_TIMER,\r
                   0,\r
                   NULL,\r
                   NULL,\r
@@ -1200,7 +1211,7 @@ Returns:
   //\r
   // Memory test and Logo show\r
   //\r
-  PlatformBdsDiagnostics (IGNORE, TRUE);\r
+  PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);\r
 \r
   //\r
   // Perform some platform specific connect sequence\r
@@ -1211,6 +1222,8 @@ Returns:
   // Give one chance to enter the setup if we\r
   // have the time out\r
   //\r
+  // BUGBUG: hard code timeout to 5 second to show logo in graphic mode.\r
+  Timeout = 5;  \r
   if (Timeout != 0) {\r
     PlatformBdsEnterFrontPage (Timeout, FALSE);\r
   }\r
@@ -1241,36 +1254,11 @@ Returns:
   //\r
   // To give the User a chance to enter Setup here, if user set TimeOut is 0.\r
   // BDS should still give user a chance to enter Setup\r
-  //\r
-  // Connect first boot option, and then check user input before exit \r
-  //\r
-  for (Link = BootOptionList->ForwardLink; Link != BootOptionList;Link = Link->ForwardLink) {\r
-    BootOption = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r
-    if (!IS_LOAD_OPTION_TYPE (BootOption->Attribute, LOAD_OPTION_ACTIVE)) {\r
-      //\r
-      // skip the header of the link list, becuase it has no boot option\r
-      //\r
-      continue;\r
-    } else {\r
-      //\r
-      // Make sure the boot option device path connected, but ignore the BBS device path\r
-      //\r
-      if (DevicePathType (BootOption->DevicePath) != BBS_DEVICE_PATH) {\r
-        BdsLibConnectDevicePath (BootOption->DevicePath);\r
-      }     \r
-      break;           \r
-    }\r
-  }       \r
-\r
-  //\r
   // Check whether the user input after the duration time has expired \r
   //\r
-  OldTpl = EfiGetCurrentTpl();\r
-  gBS->RestoreTPL (TPL_APPLICATION); \r
   gBS->WaitForEvent (1, &UserInputDurationTime, &Index);\r
   gBS->CloseEvent (UserInputDurationTime);\r
   Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
-  gBS->RaiseTPL (OldTpl);  \r
   \r
   if (!EFI_ERROR (Status)) {\r
     //\r
@@ -1285,6 +1273,7 @@ Returns:
 }\r
 \r
 VOID\r
+EFIAPI\r
 PlatformBdsBootSuccess (\r
   IN  BDS_COMMON_OPTION *Option\r
   )\r
@@ -1321,6 +1310,7 @@ Returns:
 }\r
 \r
 VOID\r
+EFIAPI\r
 PlatformBdsBootFail (\r
   IN  BDS_COMMON_OPTION  *Option,\r
   IN  EFI_STATUS         Status,\r
@@ -1460,38 +1450,6 @@ Returns:
   return EFI_UNSUPPORTED;\r
 }  \r
 \r
-UINT8\r
-GetBufferCheckSum (\r
-  IN VOID *      Buffer,\r
-  IN UINTN       Length\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-  Caculate buffer checksum (8-bit)\r
-\r
-Arguments:\r
-  Buffer - Pointer to Buffer that to be caculated\r
-  Length - How many bytes are to be caculated  \r
-\r
-Returns:\r
-  Checksum of the buffer\r
-\r
---*/\r
-{\r
-  UINT8   CheckSum;\r
-  UINT8   *Ptr8;\r
-  \r
-  CheckSum = 0;\r
-  Ptr8 = (UINT8 *) Buffer;\r
-  \r
-  while (Length > 0) {\r
-    CheckSum = (UINT8) (CheckSum + *Ptr8++);\r
-    Length--;\r
-  }\r
-  \r
-  return ((0xFF - CheckSum) + 1);\r
-}  \r
 \r
 EFI_STATUS\r
 ConvertAcpiTable (\r
@@ -1626,7 +1584,7 @@ Returns:
   SmbiosTableNew->TableAddress = (UINT32)BufferPtr;\r
   SmbiosTableNew->IntermediateChecksum = 0;\r
   SmbiosTableNew->IntermediateChecksum = \r
-          GetBufferCheckSum ((UINT8*)SmbiosTableNew + 0x10, SmbiosEntryLen -0x10);\r
+          CalculateCheckSum8 ((UINT8*)SmbiosTableNew + 0x10, SmbiosEntryLen -0x10);\r
   //\r
   // Change the SMBIOS pointer\r
   //\r
@@ -1725,10 +1683,10 @@ Returns:
         MpsTableNew->OemTablePointer = (UINT32)(UINTN)OemTableNew;\r
     }\r
     MpsTableNew->Checksum = 0;\r
-    MpsTableNew->Checksum = GetBufferCheckSum (MpsTableNew, MpsTableOri->BaseTableLength);\r
+    MpsTableNew->Checksum = CalculateCheckSum8 ((UINT8*)MpsTableNew, MpsTableOri->BaseTableLength);\r
     MpsFloatingPointerNew->PhysicalAddress = (UINT32)(UINTN)MpsTableNew;\r
     MpsFloatingPointerNew->Checksum = 0;\r
-    MpsFloatingPointerNew->Checksum = GetBufferCheckSum (MpsFloatingPointerNew, FPLength);\r
+    MpsFloatingPointerNew->Checksum = CalculateCheckSum8 ((UINT8*)MpsFloatingPointerNew, FPLength);\r
   }\r
   //\r
   // Change the pointer\r
@@ -1737,3 +1695,37 @@ Returns:
   \r
   return EFI_SUCCESS;  \r
 } \r
+  \r
+/**\r
+  Lock the ConsoleIn device in system table. All key\r
+  presses will be ignored until the Password is typed in. The only way to\r
+  disable the password is to type it in to a ConIn device.\r
+\r
+  @param  Password        Password used to lock ConIn device.\r
+\r
+  @retval EFI_SUCCESS     lock the Console In Spliter virtual handle successfully.\r
+  @retval EFI_UNSUPPORTED Password not found\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LockKeyboards (\r
+  IN  CHAR16    *Password\r
+  )\r
+{\r
+    return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  This function locks platform flash that is not allowed to be updated during normal boot path.\r
+  The flash layout is platform specific.\r
+\r
+  **/\r
+VOID\r
+EFIAPI\r
+PlatformBdsLockNonUpdatableFlash (\r
+  VOID\r
+  )\r
+{\r
+  return;\r
+}\r