]> git.proxmox.com Git - mirror_edk2.git/blame - SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicationLibUsb3Pei.c
SourceLevelDebugPkg/DebugCommLibUsb3Pei: Make sure alloc physical mem
[mirror_edk2.git] / SourceLevelDebugPkg / Library / DebugCommunicationLibUsb3 / DebugCommunicationLibUsb3Pei.c
CommitLineData
2cb6eabe
EL
1/** @file\r
2 Debug Port Library implementation based on usb3 debug port.\r
3\r
364f63c0 4 Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>\r
2cb6eabe
EL
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php.\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include <PiPei.h>\r
16#include <Library/PeiServicesLib.h>\r
364f63c0 17#include <Ppi/MemoryDiscovered.h>\r
2cb6eabe
EL
18#include "DebugCommunicationLibUsb3Internal.h"\r
19\r
20/**\r
21 Allocate aligned memory for XHC's usage.\r
22\r
23 @param BufferSize The size, in bytes, of the Buffer.\r
24 \r
25 @return A pointer to the allocated buffer or NULL if allocation fails.\r
26\r
27**/\r
28VOID*\r
29AllocateAlignBuffer (\r
30 IN UINTN BufferSize\r
31 )\r
32{\r
33 VOID *Buf;\r
34 EFI_PHYSICAL_ADDRESS Address;\r
35 EFI_STATUS Status;\r
364f63c0
SZ
36 VOID *MemoryDiscoveredPpi;\r
37\r
38 Buf = NULL;\r
39\r
40 //\r
41 // Make sure the allocated memory is physical memory.\r
42 //\r
43 Status = PeiServicesLocatePpi (\r
44 &gEfiPeiMemoryDiscoveredPpiGuid,\r
45 0,\r
46 NULL,\r
47 (VOID **) &MemoryDiscoveredPpi\r
48 );\r
49 if (!EFI_ERROR (Status)) {\r
50 Status = PeiServicesAllocatePages (EfiACPIMemoryNVS, EFI_SIZE_TO_PAGES (BufferSize), &Address);\r
51 if (!EFI_ERROR (Status)) {\r
52 Buf = (VOID *)(UINTN) Address;\r
53 }\r
2cb6eabe
EL
54 }\r
55 return Buf;\r
56}\r
57\r