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>
/** @file\r
Debug Port Library implementation based on usb3 debug port.\r
\r
/** @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
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
\r
#include <PiPei.h>\r
#include <Library/PeiServicesLib.h>\r
\r
#include <PiPei.h>\r
#include <Library/PeiServicesLib.h>\r
+#include <Ppi/MemoryDiscovered.h>\r
#include "DebugCommunicationLibUsb3Internal.h"\r
\r
/**\r
#include "DebugCommunicationLibUsb3Internal.h"\r
\r
/**\r
VOID *Buf;\r
EFI_PHYSICAL_ADDRESS Address;\r
EFI_STATUS Status;\r
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
## @file\r
# Debug Communication Library instance based on usb3 debug port.\r
#\r
## @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
#\r
# This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
IntelFrameworkPkg/IntelFrameworkPkg.dec\r
SourceLevelDebugPkg/SourceLevelDebugPkg.dec\r
\r
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
[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