1 /** @file
2   Resource Publication Library that uses PEI Core Services to publish system memory.
3 
4   Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5   SPDX-License-Identifier: BSD-2-Clause-Patent
6 
7 **/
8 
9 
10 
11 #include <PiPei.h>
12 
13 
14 #include <Library/ResourcePublicationLib.h>
15 #include <Library/PeiServicesLib.h>
16 #include <Library/DebugLib.h>
17 
18 
19 /**
20   Declares the presence of permanent system memory in the platform.
21 
22   Declares that the system memory buffer specified by MemoryBegin and MemoryLength
23   as permanent memory that may be used for general purpose use by software.
24   The amount of memory available to software may be less than MemoryLength
25   if published memory has alignment restrictions.
26   If MemoryLength is 0, then ASSERT().
27   If MemoryLength is greater than (MAX_ADDRESS - MemoryBegin + 1), then ASSERT().
28 
29   @param  MemoryBegin               The start address of the memory being declared.
30   @param  MemoryLength              The number of bytes of memory being declared.
31 
32   @retval  RETURN_SUCCESS           The memory buffer was published.
33   @retval  RETURN_OUT_OF_RESOURCES  There are not enough resources to publish the memory buffer
34 
35 **/
36 RETURN_STATUS
37 EFIAPI
PublishSystemMemory(IN PHYSICAL_ADDRESS MemoryBegin,IN UINT64 MemoryLength)38 PublishSystemMemory (
39   IN PHYSICAL_ADDRESS       MemoryBegin,
40   IN UINT64                 MemoryLength
41   )
42 {
43   EFI_STATUS        Status;
44 
45   ASSERT (MemoryLength > 0);
46   ASSERT (MemoryLength <= (MAX_ADDRESS - MemoryBegin + 1));
47 
48   Status      = PeiServicesInstallPeiMemory (MemoryBegin, MemoryLength);
49 
50   return (RETURN_STATUS) Status;
51 }
52 
53