]> git.proxmox.com Git - mirror_edk2.git/blobdiff - DuetPkg/Library/DuetBdsLib/BdsPlatform.c
Fix some bugs in FSVariable and BdsPlatform for duet platform.
[mirror_edk2.git] / DuetPkg / Library / DuetBdsLib / BdsPlatform.c
index 71e9b5db507fb88eb8bc01f7f52dc16e044a640d..f73f824f2d7ce4c65b9d0675316ee0bdd0de87cd 100644 (file)
@@ -48,9 +48,8 @@ Returns:
 \r
 --*/\r
 {\r
-  EFI_STATUS                  Status;\r
-  EFI_HOB_HANDOFF_INFO_TABLE  *HobList;\r
-  EFI_HOB_HANDOFF_INFO_TABLE  *HobStart;\r
+  EFI_PEI_HOB_POINTERS        GuidHob;\r
+  EFI_PEI_HOB_POINTERS        HobStart;\r
   EFI_PHYSICAL_ADDRESS        *Table;\r
   UINTN                       Index;\r
   EFI_GUID                    *TableGuidArray[] = {\r
@@ -60,19 +59,14 @@ Returns:
   //\r
   // Get Hob List\r
   //\r
-  Status = EfiGetSystemConfigurationTable (&gEfiHobListGuid, (VOID *) &HobList);\r
-  if (EFI_ERROR (Status)) {\r
-    return;\r
-  }\r
-\r
+  HobStart.Raw = GetHobList ();\r
   //\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
-    HobStart = HobList;\r
-    Table = NULL;\r
-    Table = GetNextGuidHob (TableGuidArray[Index], &HobStart);\r
-    if (!EFI_ERROR (Status)) {\r
+    GuidHob.Raw = GetNextGuidHob (TableGuidArray[Index], HobStart.Raw);\r
+    if (GuidHob.Raw != NULL) {\r
+      Table = GET_GUID_HOB_DATA (GuidHob.Guid);\r
       if (Table != NULL) {\r
         //\r
         // Check if Mps Table/Smbios Table/Acpi Table exists in E/F seg,\r
@@ -152,7 +146,7 @@ UpdateMemoryMap (
   )\r
 {\r
   EFI_STATUS                  Status;\r
-  EFI_HOB_HANDOFF_INFO_TABLE  *HobList;\r
+  EFI_PEI_HOB_POINTERS        GuidHob;\r
   VOID                        *Table;\r
   MEMORY_DESC_HOB             MemoryDescHob;\r
   UINTN                       Index;\r
@@ -161,12 +155,18 @@ UpdateMemoryMap (
   //\r
   // Get Hob List\r
   //\r
-  Status = EfiGetSystemConfigurationTable (&gEfiHobListGuid, (VOID *) &HobList);\r
-  if (EFI_ERROR (Status)) {\r
+  GuidHob.Raw = GetHobList();\r
+  \r
+  GuidHob.Raw = GetNextGuidHob (&gEfiLdrMemoryDescriptorGuid, GuidHob.Raw);\r
+  if (GuidHob.Raw == NULL) {\r
+    DEBUG ((EFI_D_ERROR, "Fail to get gEfiLdrMemoryDescriptorGuid from GUID HOB LIST!\n"));\r
+    return;\r
+  }\r
+  Table = GET_GUID_HOB_DATA (GuidHob.Guid);\r
+  if (Table == NULL) {\r
+    DEBUG ((EFI_D_ERROR, "Fail to get gEfiLdrMemoryDescriptorGuid from GUID HOB LIST!\n"));\r
     return;\r
   }\r
-\r
-  Table = GetNextGuidHob (&gEfiLdrMemoryDescriptorGuid, &HobList);\r
   MemoryDescHob.MemDescCount = *(UINTN *)Table;\r
   MemoryDescHob.MemDesc      = *(EFI_MEMORY_DESCRIPTOR **)((UINTN)Table + sizeof(UINTN));\r
 \r
@@ -382,6 +382,19 @@ Returns:
   // 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
+  \r
+  //\r
+  // Append Usb Keyboard short form DevicePath into "ConInDev" \r
+  //\r
+  BdsLibUpdateConsoleVariable (\r
+    VarConsoleInpDev,\r
+    (EFI_DEVICE_PATH_PROTOCOL *) &gUsbClassKeyboardDevicePath,\r
+    NULL\r
+    );\r
 }\r
 \r
 UINT64\r
@@ -407,23 +420,27 @@ Returns:
   UINTN                                    BufferSize;\r
   UINT32                                   Index;\r
   UINT32                                   Number;\r
-  VOID                                     *HobList;\r
-  EFI_STATUS                               Status;\r
+  EFI_PEI_HOB_POINTERS                     GuidHob;\r
 \r
   BufferSize = 0;\r
   //\r
   // Get Hob List from configuration table\r
   //\r
-  Status = EfiGetSystemConfigurationTable (&gEfiHobListGuid, &HobList);\r
-  if (EFI_ERROR (Status)) {\r
-    return 0;\r
-  }\r
+  GuidHob.Raw = GetHobList ();\r
 \r
   //\r
   // Get PciExpressAddressInfo Hob\r
   //\r
-  PciExpressBaseAddressInfo = NULL;\r
-  PciExpressBaseAddressInfo = GetNextGuidHob (&gEfiPciExpressBaseAddressGuid, &HobList);\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
+    return 0;\r
+  }\r
 \r
   //\r
   // Search the PciExpress Base Address in the Hob for current RootBridge\r
@@ -585,7 +602,6 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
 EFI_STATUS\r
 GetGopDevicePath (\r
    IN  EFI_DEVICE_PATH_PROTOCOL *PciDevicePath,\r
@@ -670,7 +686,6 @@ GetGopDevicePath (
 \r
   return EFI_SUCCESS;\r
 }\r
-#endif\r
 \r
 EFI_STATUS\r
 PreparePciVgaDevicePath (\r
@@ -696,9 +711,7 @@ Returns:
 {\r
   EFI_STATUS                Status;\r
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
   EFI_DEVICE_PATH_PROTOCOL  *GopDevicePath;\r
-#endif  \r
 \r
   DevicePath = NULL;\r
   Status = gBS->HandleProtocol (\r
@@ -710,10 +723,8 @@ Returns:
     return Status;\r
   }\r
   \r
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
   GetGopDevicePath (DevicePath, &GopDevicePath);\r
   DevicePath = GopDevicePath;\r
-#endif\r
 \r
   BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r
   \r
@@ -839,6 +850,7 @@ Returns:
         // Add IsaKeyboard to ConIn,\r
         // add IsaSerial to ConOut, ConIn, ErrOut\r
         //\r
+        DEBUG ((EFI_D_INFO, "Find the LPC Bridge device\n"));\r
         PrepareLpcBridgeDevicePath (HandleBuffer[Index]);\r
         continue;\r
       }\r
@@ -849,6 +861,7 @@ Returns:
         //\r
         // Add them to ConOut, ConIn, ErrOut.\r
         //\r
+        DEBUG ((EFI_D_INFO, "Find the 16550 SERIAL device\n"));\r
         PreparePciSerialDevicePath (HandleBuffer[Index]);\r
         continue;\r
       }\r
@@ -861,6 +874,7 @@ Returns:
       //\r
       // Add them to ConOut.\r
       //\r
+      DEBUG ((EFI_D_INFO, "Find the VGA device\n"));\r
       PreparePciVgaDevicePath (HandleBuffer[Index]);\r
       continue;\r
     }\r