/**@file\r
Xen Platform PEI support\r
\r
- Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
Copyright (c) 2011, Andrei Warkentin <andreiw@motorola.com>\r
\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
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
#include <Library/MemoryAllocationLib.h>\r
#include <Library/PcdLib.h>\r
#include <Guid/XenInfo.h>\r
+#include <IndustryStandard/E820.h>\r
+#include <Library/ResourcePublicationLib.h>\r
+#include <Library/MtrrLib.h>\r
\r
#include "Platform.h"\r
#include "Xen.h"\r
\r
/**\r
Connects to the Hypervisor.\r
- \r
+\r
@param XenLeaf CPUID index used to connect.\r
\r
@return EFI_STATUS\r
mXenInfo.VersionMajor = (UINT16)(XenVersion >> 16);\r
mXenInfo.VersionMinor = (UINT16)(XenVersion & 0xFFFF);\r
\r
- /* TBD: Locate hvm_info and reserve it away. */\r
- mXenInfo.HvmInfo = NULL;\r
-\r
BuildGuidDataHob (\r
&gEfiXenInfoGuid,\r
&mXenInfo,\r
return FALSE;\r
}\r
\r
+\r
+VOID\r
+XenPublishRamRegions (\r
+ VOID\r
+ )\r
+{\r
+ EFI_E820_ENTRY64 *E820Map;\r
+ UINT32 E820EntriesCount;\r
+ EFI_STATUS Status;\r
+\r
+ if (!mXen) {\r
+ return;\r
+ }\r
+\r
+ DEBUG ((EFI_D_INFO, "Using memory map provided by Xen\n"));\r
+\r
+ //\r
+ // Parse RAM in E820 map\r
+ //\r
+ E820EntriesCount = 0;\r
+ Status = XenGetE820Map (&E820Map, &E820EntriesCount);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ if (E820EntriesCount > 0) {\r
+ EFI_E820_ENTRY64 *Entry;\r
+ UINT32 Loop;\r
+\r
+ for (Loop = 0; Loop < E820EntriesCount; Loop++) {\r
+ Entry = E820Map + Loop;\r
+\r
+ //\r
+ // Only care about RAM\r
+ //\r
+ if (Entry->Type != EfiAcpiAddressRangeMemory) {\r
+ continue;\r
+ }\r
+\r
+ AddMemoryBaseSizeHob (Entry->BaseAddr, Entry->Length);\r
+\r
+ MtrrSetMemoryAttribute (Entry->BaseAddr, Entry->Length, CacheWriteBack);\r
+ }\r
+ }\r
+}\r
+\r
+\r
/**\r
Perform Xen PEI initialization.\r
\r
VOID\r
)\r
{\r
+ RETURN_STATUS PcdStatus;\r
+\r
if (mXenLeaf == 0) {\r
return EFI_NOT_FOUND;\r
}\r
// Reserve away HVMLOADER reserved memory [0xFC000000,0xFD000000).\r
// This needs to match HVMLOADER RESERVED_MEMBASE/RESERVED_MEMSIZE.\r
//\r
- AddReservedMemoryBaseSizeHob (0xFC000000, 0x1000000);\r
+ AddReservedMemoryBaseSizeHob (0xFC000000, 0x1000000, FALSE);\r
+\r
+ PcdStatus = PcdSetBoolS (PcdPciDisableBusEnumeration, TRUE);\r
+ ASSERT_RETURN_ERROR (PcdStatus);\r
\r
return EFI_SUCCESS;\r
}\r