[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [edk2] [PATCH v3 7/8] OvmfPkg: introduce XenMemMapInitialization



On Tue, Nov 26, 2013 at 11:26 AM, Wei Liu <wei.liu2@xxxxxxxxxx> wrote:
> This function parses Xen OVMF info and arrange memory maps accordingly.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
> ---
>  OvmfPkg/PlatformPei/Platform.c |   70 
> ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 70 insertions(+)
>
> diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
> index 9b7828f..c2e7ba9 100644
> --- a/OvmfPkg/PlatformPei/Platform.c
> +++ b/OvmfPkg/PlatformPei/Platform.c
> @@ -34,6 +34,10 @@
>  #include <Guid/MemoryTypeInformation.h>
>  #include <Ppi/MasterBootMode.h>
>  #include <IndustryStandard/Pci22.h>
> +#include <Guid/XenInfo.h>
> +#include <IndustryStandard/E820.h>
> +#include <Library/ResourcePublicationLib.h>
> +#include <Library/MtrrLib.h>
>
>  #include "Platform.h"
>  #include "Cmos.h"
> @@ -163,6 +167,72 @@ AddUntestedMemoryRangeHob (
>    AddUntestedMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - 
> MemoryBase));
>  }
>
> +VOID
> +XenMemMapInitialization (
> +  VOID
> +  )
> +{
> +  EFI_HOB_GUID_TYPE *GuidHob;
> +  EFI_XEN_INFO *Info;
> +
> +  DEBUG ((EFI_D_ERROR, "Using memory map provided by Xen\n"));
> +
> +  GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);
> +
> +  ASSERT (GuidHob != NULL);
> +
> +  Info = GET_GUID_HOB_DATA (GuidHob);
> +
> +  //
> +  // Create Memory Type Information HOB
> +  //
> +  BuildGuidDataHob (
> +    &gEfiMemoryTypeInformationGuid,
> +    mDefaultMemoryTypeInformation,
> +    sizeof(mDefaultMemoryTypeInformation)
> +    );
> +
> +  //
> +  // Add PCI IO Port space available for PCI resource allocations.
> +  //
> +  BuildResourceDescriptorHob (
> +    EFI_RESOURCE_IO,
> +    EFI_RESOURCE_ATTRIBUTE_PRESENT     |
> +    EFI_RESOURCE_ATTRIBUTE_INITIALIZED,
> +    0xC000,
> +    0x4000
> +    );
> +
> +  //
> +  // Video memory + Legacy BIOS region
> +  //
> +  AddIoMemoryRangeHob (0x0A0000, BASE_1MB);
> +
> +  //
> +  // Parse RAM in E820 map
> +  //
> +  if (Info->E820EntriesCount > 0) {
> +    EFI_E820_ENTRY64 *E820Map, *Entry;
> +    UINT16 Loop;
> +
> +    E820Map = (EFI_E820_ENTRY64 *) Info->E820;
> +    for (Loop = 0; Loop < Info->E820EntriesCount; Loop++) {
> +      Entry = E820Map + Loop;
> +
> +      // only care about RAM
> +      if (Entry->Type != EfiAcpiAddressRangeMemory)
> +        continue;

I think you are going to change this code base on the
XenGetE820Entries discussion in the patch 3 thread.

I just wanted to add that we always use curly-brackets:
  if () {
  }
even if the body is just a single line.

-Jordan

> +
> +      if (Entry->BaseAddr >= BASE_4GB)
> +        AddUntestedMemoryBaseSizeHob (Entry->BaseAddr, Entry->Length);
> +      else
> +        AddMemoryBaseSizeHob (Entry->BaseAddr, Entry->Length);
> +
> +      MtrrSetMemoryAttribute (Entry->BaseAddr, Entry->Length, 
> CacheWriteBack);
> +    }
> +  }
> +}
> +
>
>  VOID
>  MemMapInitialization (
> --
> 1.7.10.4
>
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.sourceforge.net/lists/listinfo/edk2-devel

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.