]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SourceLevelDebugPkg/DebugCommLibUsb3Pei: Make sure alloc physical mem
authorStar Zeng <star.zeng@intel.com>
Thu, 31 Aug 2017 08:53:16 +0000 (16:53 +0800)
committerStar Zeng <star.zeng@intel.com>
Mon, 4 Sep 2017 02:37:46 +0000 (10:37 +0800)
PI 1.6 has supported pre permanent memory page allocation,
to make sure the allocated memory is physical memory for DMA,
the patch is to check memory discovered PPI installed or not first
before calling AllocatePages.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Pei.c
SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Pei.inf

index be3174e75fd643274e594bddcd075cc0bbc8d71e..902a3b626accf8a740b89b917fd0afb6168678ec 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Debug Port Library implementation based on usb3 debug port.\r
 \r
-  Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2014 - 2017, 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
@@ -14,6 +14,7 @@
 \r
 #include <PiPei.h>\r
 #include <Library/PeiServicesLib.h>\r
+#include <Ppi/MemoryDiscovered.h>\r
 #include "DebugCommunicationLibUsb3Internal.h"\r
 \r
 /**\r
@@ -32,13 +33,24 @@ AllocateAlignBuffer (
   VOID                     *Buf;\r
   EFI_PHYSICAL_ADDRESS     Address;\r
   EFI_STATUS               Status;\r
-  \r
-  Buf = NULL;  \r
-  Status = PeiServicesAllocatePages (EfiACPIMemoryNVS, EFI_SIZE_TO_PAGES (BufferSize), &Address);\r
-  if (EFI_ERROR (Status)) {\r
-    Buf = NULL;\r
-  } else {\r
-    Buf = (VOID *)(UINTN) Address;\r
+  VOID                     *MemoryDiscoveredPpi;\r
+\r
+  Buf = NULL;\r
+\r
+  //\r
+  // Make sure the allocated memory is physical memory.\r
+  //\r
+  Status = PeiServicesLocatePpi (\r
+             &gEfiPeiMemoryDiscoveredPpiGuid,\r
+             0,\r
+             NULL,\r
+             (VOID **) &MemoryDiscoveredPpi\r
+             );\r
+  if (!EFI_ERROR (Status)) {\r
+    Status = PeiServicesAllocatePages (EfiACPIMemoryNVS, EFI_SIZE_TO_PAGES (BufferSize), &Address);\r
+    if (!EFI_ERROR (Status)) {\r
+      Buf = (VOID *)(UINTN) Address;\r
+    }\r
   }\r
   return Buf;\r
 }\r
index 74dcdd124b4780ce48d0c22c00f52448a61be3fb..6cd5e106833343ec913a0df07313748229a94c97 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 #  Debug Communication Library instance based on usb3 debug port.\r
 #\r
-#  Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -40,6 +40,9 @@
   IntelFrameworkPkg/IntelFrameworkPkg.dec\r
   SourceLevelDebugPkg/SourceLevelDebugPkg.dec\r
 \r
+[Ppis]\r
+  gEfiPeiMemoryDiscoveredPpiGuid                ## CONSUMES\r
+\r
 [Pcd]\r
   # The memory BAR of ehci host controller, in which usb debug feature is enabled.\r
   # Note that the memory BAR address is only used before Pci bus resource allocation.\r