#include <Guid/MemoryTypeInformation.h>\r
#include <Ppi/MasterBootMode.h>\r
#include <IndustryStandard/Pci22.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 "Cmos.h"\r
AddUntestedMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase));\r
}\r
\r
+VOID\r
+XenMemMapInitialization (\r
+ VOID\r
+ )\r
+{\r
+ EFI_E820_ENTRY64 *E820Map;\r
+ UINT32 E820EntriesCount;\r
+ EFI_STATUS Status;\r
+\r
+ DEBUG ((EFI_D_INFO, "Using memory map provided by Xen\n"));\r
+\r
+ //\r
+ // Create Memory Type Information HOB\r
+ //\r
+ BuildGuidDataHob (\r
+ &gEfiMemoryTypeInformationGuid,\r
+ mDefaultMemoryTypeInformation,\r
+ sizeof(mDefaultMemoryTypeInformation)\r
+ );\r
+\r
+ //\r
+ // Add PCI IO Port space available for PCI resource allocations.\r
+ //\r
+ BuildResourceDescriptorHob (\r
+ EFI_RESOURCE_IO,\r
+ EFI_RESOURCE_ATTRIBUTE_PRESENT |\r
+ EFI_RESOURCE_ATTRIBUTE_INITIALIZED,\r
+ 0xC000,\r
+ 0x4000\r
+ );\r
+\r
+ //\r
+ // Video memory + Legacy BIOS region\r
+ //\r
+ AddIoMemoryRangeHob (0x0A0000, BASE_1MB);\r
+\r
+ //\r
+ // Parse RAM in E820 map\r
+ //\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
+ if (Entry->BaseAddr >= BASE_4GB) {\r
+ AddUntestedMemoryBaseSizeHob (Entry->BaseAddr, Entry->Length);\r
+ } else {\r
+ AddMemoryBaseSizeHob (Entry->BaseAddr, Entry->Length);\r
+ }\r
+\r
+ MtrrSetMemoryAttribute (Entry->BaseAddr, Entry->Length, CacheWriteBack);\r
+ }\r
+ }\r
+}\r
+\r
\r
VOID\r
MemMapInitialization (\r
#ifndef _PLATFORM_PEI_H_INCLUDED_\r
#define _PLATFORM_PEI_H_INCLUDED_\r
\r
+#include <IndustryStandard/E820.h>\r
+\r
VOID\r
AddIoMemoryBaseSizeHob (\r
EFI_PHYSICAL_ADDRESS MemoryBase,\r
VOID\r
);\r
\r
+EFI_STATUS\r
+XenGetE820Map (\r
+ EFI_E820_ENTRY64 **Entries,\r
+ UINT32 *Count\r
+ );\r
+\r
#endif // _PLATFORM_PEI_H_INCLUDED_\r
/**@file\r
Xen Platform PEI support\r
\r
- Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
Copyright (c) 2011, Andrei Warkentin <andreiw@motorola.com>\r
\r
This program and the accompanying materials\r
#include <Guid/XenInfo.h>\r
\r
#include "Platform.h"\r
+#include "Xen.h"\r
\r
EFI_XEN_INFO mXenInfo;\r
\r
+/**\r
+ Returns E820 map provided by Xen\r
+\r
+ @param Entries Pointer to E820 map\r
+ @param Count Number of entries\r
+\r
+ @return EFI_STATUS\r
+**/\r
+EFI_STATUS\r
+XenGetE820Map (\r
+ EFI_E820_ENTRY64 **Entries,\r
+ UINT32 *Count\r
+ )\r
+{\r
+ EFI_XEN_OVMF_INFO *Info =\r
+ (EFI_XEN_OVMF_INFO *)(UINTN) OVMF_INFO_PHYSICAL_ADDRESS;\r
+\r
+ if (AsciiStrCmp ((CHAR8 *) Info->Signature, "XenHVMOVMF")) {\r
+ return EFI_NOT_FOUND;\r
+ }\r
+\r
+ ASSERT (Info->E820 < MAX_ADDRESS);\r
+ *Entries = (EFI_E820_ENTRY64 *)(UINTN) Info->E820;\r
+ *Count = Info->E820EntriesCount;\r
+\r
+ return EFI_SUCCESS;\r
+}\r
\r
/**\r
Connects to the Hypervisor.\r