VirtualBox

Ignore:
Timestamp:
Oct 28, 2015 8:17:18 PM (9 years ago)
Author:
vboxsync
Message:

EFI/Firmware: 'svn merge /vendor/edk2/UDK2010.SR1 /vendor/edk2/current .', reverting and removing files+dirs listed in ReadMe.vbox, resolving conflicts with help from ../UDK2014.SP1/. This is a raw untested merge.

Location:
trunk/src/VBox/Devices/EFI/Firmware
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/Firmware

  • trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/PlatformPei/Fv.c

    r48674 r58459  
    22  Build FV related hobs for platform.
    33
    4   Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
    55  This program and the accompanying materials
    66  are licensed and made available under the terms and conditions of the BSD License
     
    1414
    1515#include "PiPei.h"
     16#include "Platform.h"
    1617#include <Library/DebugLib.h>
    1718#include <Library/HobLib.h>
     
    2122
    2223/**
    23   Perform a call-back into the SEC simulator to get address of the Firmware Hub
    24 
    25   @param  FfsHeader     Ffs Header availible to every PEIM
    26   @param  PeiServices   General purpose services available to every PEIM.
     24  Publish PEI & DXE (Decompressed) Memory based FVs to let PEI
     25  and DXE know about them.
    2726
    2827  @retval EFI_SUCCESS   Platform PEI FVs were initialized successfully.
     
    3433  )
    3534{
    36   DEBUG ((EFI_D_ERROR, "Platform PEI Firmware Volume Initialization\n"));
     35  DEBUG ((EFI_D_INFO, "Platform PEI Firmware Volume Initialization\n"));
    3736
    38   DEBUG (
    39     (EFI_D_ERROR, "Firmware Volume HOB: 0x%x 0x%x\n",
    40       PcdGet32 (PcdOvmfMemFvBase),
    41       PcdGet32 (PcdOvmfMemFvSize)
    42       )
     37  //
     38  // Create a memory allocation HOB for the PEI FV.
     39  //
     40  // Allocate as ACPI NVS is S3 is supported
     41  //
     42  BuildMemoryAllocationHob (
     43    PcdGet32 (PcdOvmfPeiMemFvBase),
     44    PcdGet32 (PcdOvmfPeiMemFvSize),
     45    mS3Supported ? EfiACPIMemoryNVS : EfiBootServicesData
    4346    );
    4447
    45   BuildFvHob (PcdGet32 (PcdOvmfMemFvBase), PcdGet32 (PcdOvmfMemFvSize));
     48  //
     49  // Let DXE know about the DXE FV
     50  //
     51  BuildFvHob (PcdGet32 (PcdOvmfDxeMemFvBase), PcdGet32 (PcdOvmfDxeMemFvSize));
    4652
    4753  //
    48   // Create a memory allocation HOB.
     54  // Create a memory allocation HOB for the DXE FV.
    4955  //
    5056  BuildMemoryAllocationHob (
    51     PcdGet32 (PcdOvmfMemFvBase),
    52     PcdGet32 (PcdOvmfMemFvSize),
     57    PcdGet32 (PcdOvmfDxeMemFvBase),
     58    PcdGet32 (PcdOvmfDxeMemFvSize),
    5359    EfiBootServicesData
     60    );
     61
     62  //
     63  // Let PEI know about the DXE FV so it can find the DXE Core
     64  //
     65  PeiServicesInstallFvInfoPpi (
     66    NULL,
     67    (VOID *)(UINTN) PcdGet32 (PcdOvmfDxeMemFvBase),
     68    PcdGet32 (PcdOvmfDxeMemFvSize),
     69    NULL,
     70    NULL
    5471    );
    5572
  • trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/PlatformPei/MemDetect.c

    r58173 r58459  
    22  Memory Detection for Virtual Machines.
    33
    4   Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
    55  This program and the accompanying materials
    66  are licensed and made available under the terms and conditions of the BSD License
     
    2525// The Library classes this module consumes
    2626//
     27#include <Library/BaseMemoryLib.h>
    2728#include <Library/DebugLib.h>
    2829#include <Library/HobLib.h>
     
    3637#include "Cmos.h"
    3738
    38 STATIC
    39 UINTN
     39UINT32
    4040GetSystemMemorySizeBelow4gb (
     41  VOID
    4142  )
    4243{
     
    8485}
    8586
    86 
    8787/**
    88   Peform Memory Detection
     88  Publish PEI core memory
    8989
    9090  @return EFI_SUCCESS     The PEIM initialized successfully.
    9191
    9292**/
    93 EFI_PHYSICAL_ADDRESS
    94 MemDetect (
     93EFI_STATUS
     94PublishPeiMemory (
     95  VOID
    9596  )
    9697{
     
    99100  UINT64                      MemorySize;
    100101  UINT64                      LowerMemorySize;
    101   UINT64                      UpperMemorySize;
    102 
    103   DEBUG ((EFI_D_ERROR, "MemDetect called\n"));
    104 
    105   //
    106   // Determine total memory size available
    107   //
    108   LowerMemorySize = GetSystemMemorySizeBelow4gb ();
    109   UpperMemorySize = GetSystemMemorySizeAbove4gb ();
    110 
    111   //
    112   // Determine the range of memory to use during PEI
    113   //
    114   MemoryBase = PcdGet32 (PcdOvmfMemFvBase) + PcdGet32 (PcdOvmfMemFvSize);
    115   MemorySize = LowerMemorySize - MemoryBase;
    116   if (MemorySize > SIZE_64MB) {
    117     MemoryBase = LowerMemorySize - SIZE_64MB;
    118     MemorySize = SIZE_64MB;
     102
     103  if (mBootMode == BOOT_ON_S3_RESUME) {
     104    MemoryBase = PcdGet32 (PcdS3AcpiReservedMemoryBase);
     105    MemorySize = PcdGet32 (PcdS3AcpiReservedMemorySize);
     106  } else {
     107    LowerMemorySize = GetSystemMemorySizeBelow4gb ();
     108
     109    //
     110    // Determine the range of memory to use during PEI
     111    //
     112    MemoryBase = PcdGet32 (PcdOvmfDxeMemFvBase) + PcdGet32 (PcdOvmfDxeMemFvSize);
     113    MemorySize = LowerMemorySize - MemoryBase;
     114    if (MemorySize > SIZE_64MB) {
     115      MemoryBase = LowerMemorySize - SIZE_64MB;
     116      MemorySize = SIZE_64MB;
     117    }
    119118  }
    120119#ifdef VBOX
     
    128127  ASSERT_EFI_ERROR (Status);
    129128
     129  return Status;
     130}
     131
     132
     133#ifndef VBOX
     134/**
     135  Peform Memory Detection for QEMU / KVM
     136
     137**/
     138STATIC
     139VOID
     140QemuInitializeRam (
     141  VOID
     142  )
     143{
     144  UINT64                      LowerMemorySize;
     145  UINT64                      UpperMemorySize;
     146
     147  DEBUG ((EFI_D_INFO, "%a called\n", __FUNCTION__));
     148
     149  //
     150  // Determine total memory size available
     151  //
     152  LowerMemorySize = GetSystemMemorySizeBelow4gb ();
     153  UpperMemorySize = GetSystemMemorySizeAbove4gb ();
     154
     155  if (mBootMode != BOOT_ON_S3_RESUME) {
     156    //
     157    // Create memory HOBs
     158    //
     159    AddMemoryRangeHob (BASE_1MB, LowerMemorySize);
     160    AddMemoryRangeHob (0, BASE_512KB + BASE_128KB);
     161  }
     162
     163  MtrrSetMemoryAttribute (BASE_1MB, LowerMemorySize - BASE_1MB, CacheWriteBack);
     164
     165  MtrrSetMemoryAttribute (0, BASE_512KB + BASE_128KB, CacheWriteBack);
     166
     167  if (UpperMemorySize != 0) {
     168    if (mBootMode != BOOT_ON_S3_RESUME) {
     169      AddUntestedMemoryBaseSizeHob (BASE_4GB, UpperMemorySize);
     170    }
     171
     172    MtrrSetMemoryAttribute (BASE_4GB, UpperMemorySize, CacheWriteBack);
     173  }
     174}
     175#else
     176VOID
     177VBoxInitializeRam (
     178  VOID
     179  )
     180{
     181  UINT64                      LowerMemorySize;
     182  UINT64                      UpperMemorySize;
     183  EFI_PHYSICAL_ADDRESS        MemoryBase;
     184  UINT64                      MemorySize;
     185
     186  DEBUG ((EFI_D_INFO, "%a called\n", __FUNCTION__));
     187
     188  //
     189  // Determine total memory size available
     190  //
     191  LowerMemorySize = GetSystemMemorySizeBelow4gb ();
     192  UpperMemorySize = GetSystemMemorySizeAbove4gb ();
     193
     194  if (mBootMode == BOOT_ON_S3_RESUME) {
     195    MemoryBase = PcdGet32 (PcdS3AcpiReservedMemoryBase);
     196    MemorySize = PcdGet32 (PcdS3AcpiReservedMemorySize);
     197  } else {
     198    LowerMemorySize = GetSystemMemorySizeBelow4gb ();
     199
     200    //
     201    // Determine the range of memory to use during PEI
     202    //
     203    MemoryBase = PcdGet32 (PcdOvmfDxeMemFvBase) + PcdGet32 (PcdOvmfDxeMemFvSize);
     204    MemorySize = LowerMemorySize - MemoryBase;
     205    if (MemorySize > SIZE_64MB) {
     206      MemoryBase = LowerMemorySize - SIZE_64MB;
     207      MemorySize = SIZE_64MB;
     208    }
     209  }
     210  MemorySize -= BASE_64KB; /* Reserves 64KB for ACPI tables. */
     211
    130212  //
    131213  // Create memory HOBs
     
    133215  AddMemoryBaseSizeHob (MemoryBase, MemorySize);
    134216  AddMemoryRangeHob (BASE_1MB, MemoryBase);
     217  MtrrSetMemoryAttribute (BASE_1MB, MemoryBase + MemorySize - BASE_1MB, CacheWriteBack);
     218  AddMemoryRangeHob (0, BASE_512KB + BASE_128KB);
     219  MtrrSetMemoryAttribute (0, BASE_512KB + BASE_128KB, CacheWriteBack);
     220
     221  if (UpperMemorySize != 0) {
     222      AddUntestedMemoryBaseSizeHob (BASE_4GB, UpperMemorySize);
     223
     224    MtrrSetMemoryAttribute (BASE_4GB, UpperMemorySize, CacheWriteBack);
     225  }
     226}
     227#endif
     228
     229/**
     230  Publish system RAM and reserve memory regions
     231
     232**/
     233VOID
     234InitializeRamRegions (
     235  VOID
     236  )
     237{
    135238#ifndef VBOX
    136   AddMemoryRangeHob (0, BASE_512KB + BASE_128KB);
     239  if (!mXen) {
     240    QemuInitializeRam ();
     241  } else {
     242    XenPublishRamRegions ();
     243  }
     244#else
     245  VBoxInitializeRam();
    137246#endif
    138247
    139   MtrrSetMemoryAttribute (BASE_1MB, MemoryBase + MemorySize - BASE_1MB, CacheWriteBack);
    140 
    141 #ifdef VBOX
    142   AddMemoryRangeHob (0, BASE_512KB + BASE_128KB);
     248  if (mS3Supported && mBootMode != BOOT_ON_S3_RESUME) {
     249    //
     250    // This is the memory range that will be used for PEI on S3 resume
     251    //
     252    BuildMemoryAllocationHob (
     253      (EFI_PHYSICAL_ADDRESS)(UINTN) PcdGet32 (PcdS3AcpiReservedMemoryBase),
     254      (UINT64)(UINTN) PcdGet32 (PcdS3AcpiReservedMemorySize),
     255      EfiACPIMemoryNVS
     256      );
     257
     258    //
     259    // Cover the initial RAM area used as stack and temporary PEI heap.
     260    //
     261    // This is reserved as ACPI NVS so it can be used on S3 resume.
     262    //
     263    BuildMemoryAllocationHob (
     264      PcdGet32 (PcdOvmfSecPeiTempRamBase),
     265      PcdGet32 (PcdOvmfSecPeiTempRamSize),
     266      EfiACPIMemoryNVS
     267      );
     268
     269    //
     270    // SEC stores its table of GUIDed section handlers here.
     271    //
     272    BuildMemoryAllocationHob (
     273      PcdGet64 (PcdGuidedExtractHandlerTableAddress),
     274      PcdGet32 (PcdGuidedExtractHandlerTableSize),
     275      EfiACPIMemoryNVS
     276      );
     277
     278#ifdef MDE_CPU_X64
     279    //
     280    // Reserve the initial page tables built by the reset vector code.
     281    //
     282    // Since this memory range will be used by the Reset Vector on S3
     283    // resume, it must be reserved as ACPI NVS.
     284    //
     285    BuildMemoryAllocationHob (
     286      (EFI_PHYSICAL_ADDRESS)(UINTN) PcdGet32 (PcdOvmfSecPageTablesBase),
     287      (UINT64)(UINTN) PcdGet32 (PcdOvmfSecPageTablesSize),
     288      EfiACPIMemoryNVS
     289      );
    143290#endif
    144   MtrrSetMemoryAttribute (0, BASE_512KB + BASE_128KB, CacheWriteBack);
    145 
    146   if (UpperMemorySize != 0) {
    147     AddUntestedMemoryBaseSizeHob (BASE_4GB, UpperMemorySize);
    148 
    149     MtrrSetMemoryAttribute (BASE_4GB, UpperMemorySize, CacheWriteBack);
    150   }
    151 
    152   return MemoryBase + MemorySize;
    153 }
    154 
     291  }
     292
     293  if (mBootMode != BOOT_ON_S3_RESUME) {
     294    //
     295    // Reserve the lock box storage area
     296    //
     297    // Since this memory range will be used on S3 resume, it must be
     298    // reserved as ACPI NVS.
     299    //
     300    // If S3 is unsupported, then various drivers might still write to the
     301    // LockBox area. We ought to prevent DXE from serving allocation requests
     302    // such that they would overlap the LockBox storage.
     303    //
     304    ZeroMem (
     305      (VOID*)(UINTN) PcdGet32 (PcdOvmfLockBoxStorageBase),
     306      (UINTN) PcdGet32 (PcdOvmfLockBoxStorageSize)
     307      );
     308    BuildMemoryAllocationHob (
     309      (EFI_PHYSICAL_ADDRESS)(UINTN) PcdGet32 (PcdOvmfLockBoxStorageBase),
     310      (UINT64)(UINTN) PcdGet32 (PcdOvmfLockBoxStorageSize),
     311      mS3Supported ? EfiACPIMemoryNVS : EfiBootServicesData
     312      );
     313  }
     314}
  • trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/PlatformPei/Platform.c

    r58174 r58459  
    22  Platform PEI driver
    33
    4   Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
    55  Copyright (c) 2011, Andrei Warkentin <[email protected]>
    66
     
    3131#include <Library/PeimEntryPoint.h>
    3232#include <Library/PeiServicesLib.h>
     33#include <Library/QemuFwCfgLib.h>
    3334#include <Library/ResourcePublicationLib.h>
    3435#include <Guid/MemoryTypeInformation.h>
    3536#include <Ppi/MasterBootMode.h>
     37#include <IndustryStandard/Pci22.h>
    3638
    3739#include "Platform.h"
     
    5961
    6062
     63EFI_BOOT_MODE mBootMode = BOOT_WITH_FULL_CONFIGURATION;
     64
     65BOOLEAN mS3Supported = FALSE;
     66
     67
    6168VOID
    6269AddIoMemoryBaseSizeHob (
     
    210217}
    211218
    212 
    213219VOID
    214220MemMapInitialization (
    215   EFI_PHYSICAL_ADDRESS  TopOfMemory
     221  VOID
    216222  )
    217223{
     
    241247
    242248  //
    243   // Add PCI MMIO space available to PCI resource allocations
    244   //
    245   if (TopOfMemory < BASE_2GB) {
    246     AddIoMemoryBaseSizeHob (BASE_2GB, 0xFC000000 - BASE_2GB);
    247   } else {
    248     AddIoMemoryBaseSizeHob (TopOfMemory, 0xFC000000 - TopOfMemory);
    249   }
    250 
    251   //
    252   // Local APIC range
    253   //
    254   AddIoMemoryBaseSizeHob (0xFEC80000, SIZE_512KB);
    255 
    256   //
    257   // I/O APIC range
    258   //
    259   AddIoMemoryBaseSizeHob (0xFEC00000, SIZE_512KB);
    260 
    261   //
    262249  // Video memory + Legacy BIOS region
    263250#ifdef VBOX
     
    267254  AddIoMemoryRangeHob (0x0A0000, BASE_1MB);
    268255
     256  if (!mXen) {
     257    UINT32  TopOfLowRam;
     258    TopOfLowRam = GetSystemMemorySizeBelow4gb ();
     259
     260    //
     261    // address       purpose   size
     262    // ------------  --------  -------------------------
     263    // max(top, 2g)  PCI MMIO  0xFC000000 - max(top, 2g)
     264    // 0xFC000000    gap                           44 MB
     265    // 0xFEC00000    IO-APIC                        4 KB
     266    // 0xFEC01000    gap                         1020 KB
     267    // 0xFED00000    HPET                           1 KB
     268    // 0xFED00400    gap                         1023 KB
     269    // 0xFEE00000    LAPIC                          1 MB
     270    //
     271    AddIoMemoryRangeHob (TopOfLowRam < BASE_2GB ?
     272                         BASE_2GB : TopOfLowRam, 0xFC000000);
     273    AddIoMemoryBaseSizeHob (0xFEC00000, SIZE_4KB);
     274    AddIoMemoryBaseSizeHob (0xFED00000, SIZE_1KB);
     275    AddIoMemoryBaseSizeHob (PcdGet32(PcdCpuLocalApicBaseAddress), SIZE_1MB);
     276  }
     277
    269278#ifdef VBOX
    270279  //
     
    284293VOID
    285294MiscInitialization (
    286   BOOLEAN Xen
     295  VOID
    287296  )
    288297{
     
    297306  BuildCpuHob (36, 16);
    298307
    299   if (!Xen) {
    300     //
    301     // Set the PM I/O base address to 0x400
    302     //
    303     PciAndThenOr32 (PCI_LIB_ADDRESS (0, 1, 3, 0x40), (UINT32) ~0xfc0, 0x400);
     308  //
     309  // If PMREGMISC/PMIOSE is set, assume the ACPI PMBA has been configured (for
     310  // example by Xen) and skip the setup here. This matches the logic in
     311  // AcpiTimerLibConstructor ().
     312  //
     313  if ((PciRead8 (PCI_LIB_ADDRESS (0, 1, 3, 0x80)) & 0x01) == 0) {
     314    //
     315    // The PEI phase should be exited with fully accessibe PIIX4 IO space:
     316    // 1. set PMBA
     317    //
     318    PciAndThenOr32 (
     319      PCI_LIB_ADDRESS (0, 1, 3, 0x40),
     320      (UINT32) ~0xFFC0,
     321      PcdGet16 (PcdAcpiPmBaseAddress)
     322      );
     323
     324    //
     325    // 2. set PCICMD/IOSE
     326    //
     327    PciOr8 (
     328      PCI_LIB_ADDRESS (0, 1, 3, PCI_COMMAND_OFFSET),
     329      EFI_PCI_COMMAND_IO_SPACE
     330      );
     331
     332    //
     333    // 3. set PMREGMISC/PMIOSE
     334    //
     335    PciOr8 (PCI_LIB_ADDRESS (0, 1, 3, 0x80), 0x01);
    304336  }
    305337}
     
    308340VOID
    309341BootModeInitialization (
    310   )
    311 {
    312   EFI_STATUS Status;
    313 
    314   Status = PeiServicesSetBootMode (BOOT_WITH_FULL_CONFIGURATION);
     342  VOID
     343  )
     344{
     345  EFI_STATUS    Status;
     346
     347  if (CmosRead8 (0xF) == 0xFE) {
     348    mBootMode = BOOT_ON_S3_RESUME;
     349  }
     350
     351  Status = PeiServicesSetBootMode (mBootMode);
    315352  ASSERT_EFI_ERROR (Status);
    316353
     
    334371  VariableStore =
    335372    (EFI_PHYSICAL_ADDRESS)(UINTN)
    336       AllocateRuntimePool (
    337         2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)
     373      AllocateAlignedRuntimePages (
     374        EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)),
     375        PcdGet32 (PcdFlashNvStorageFtwSpareSize)
    338376        );
    339377  DEBUG ((EFI_D_INFO,
     
    383421  )
    384422{
    385 #ifndef VBOX
    386   EFI_STATUS            Status;
    387 #endif
    388   EFI_PHYSICAL_ADDRESS  TopOfMemory;
    389   BOOLEAN               Xen;
    390 
    391423  DEBUG ((EFI_D_ERROR, "Platform PEIM Loaded\n"));
    392424
    393425  DebugDumpCmos ();
    394426
    395   TopOfMemory = MemDetect ();
    396 
    397 #ifndef VBOX
    398   Status = InitializeXen ();
    399   Xen = EFI_ERROR (Status) ? FALSE : TRUE;
    400 #else
    401   Xen = FALSE;
    402 #endif
    403 
    404   ReserveEmuVariableNvStore ();
    405 
    406   PeiFvInitialization ();
    407 
    408   MemMapInitialization (TopOfMemory);
    409 
    410   MiscInitialization (Xen);
     427  XenDetect ();
     428
     429  if (QemuFwCfgS3Enabled ()) {
     430    DEBUG ((EFI_D_INFO, "S3 support was detected on QEMU\n"));
     431    mS3Supported = TRUE;
     432  }
    411433
    412434  BootModeInitialization ();
    413435
     436  PublishPeiMemory ();
     437
     438  InitializeRamRegions ();
     439
     440  if (mXen) {
     441    DEBUG ((EFI_D_INFO, "Xen was detected\n"));
     442    InitializeXen ();
     443  }
     444
     445  if (mBootMode != BOOT_ON_S3_RESUME) {
     446    ReserveEmuVariableNvStore ();
     447
     448    PeiFvInitialization ();
     449
     450    MemMapInitialization ();
     451  }
     452
     453  MiscInitialization ();
     454
    414455  return EFI_SUCCESS;
    415456}
  • trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/PlatformPei/Platform.h

    r48674 r58459  
    22  Platform PEI module include file.
    33
    4   Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
    55  This program and the accompanying materials
    66  are licensed and made available under the terms and conditions of the BSD License
     
    1515#ifndef _PLATFORM_PEI_H_INCLUDED_
    1616#define _PLATFORM_PEI_H_INCLUDED_
     17
     18#include <IndustryStandard/E820.h>
    1719
    1820VOID
     
    5860  );
    5961
    60 EFI_PHYSICAL_ADDRESS
    61 MemDetect (
     62EFI_STATUS
     63PublishPeiMemory (
     64  VOID
     65  );
     66
     67UINT32
     68GetSystemMemorySizeBelow4gb (
     69  VOID
     70  );
     71
     72VOID
     73InitializeRamRegions (
    6274  VOID
    6375  );
     
    7385  );
    7486
     87BOOLEAN
     88XenDetect (
     89  VOID
     90  );
     91
     92extern BOOLEAN mXen;
     93
     94VOID
     95XenPublishRamRegions (
     96  VOID
     97  );
     98
     99extern EFI_BOOT_MODE mBootMode;
     100
     101extern BOOLEAN mS3Supported;
     102
    75103#endif // _PLATFORM_PEI_H_INCLUDED_
  • trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/PlatformPei/PlatformPei.inf

    r48674 r58459  
    33#
    44#  This module provides platform specific function to detect boot mode.
    5 #  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
     5#  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
    66#
    77#  This program and the accompanying materials
     
    3737
    3838[Packages]
     39  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
    3940  MdePkg/MdePkg.dec
    4041  MdeModulePkg/MdeModulePkg.dec
     
    5556  PeiServicesTablePointerLib
    5657  PeimEntryPoint
     58  QemuFwCfgLib
    5759  MtrrLib
     60  PcdLib
    5861
    5962[Pcd]
    60   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvBase
    61   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvSize
     63  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase
     64  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize
     65  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase
     66  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize
     67  gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress
     68  gUefiOvmfPkgTokenSpaceGuid.PcdS3AcpiReservedMemoryBase
     69  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase
     70  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize
     71  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase
     72  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesSize
     73  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageBase
     74  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageSize
     75  gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize
     76  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize
     77  gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress
    6278  gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize
    6379  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
    6480  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
    6581  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved
     82  gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration
     83  gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress
    6684
    6785[Ppis]
  • trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/PlatformPei/Xen.c

    r48674 r58459  
    22  Xen Platform PEI support
    33
    4   Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
    55  Copyright (c) 2011, Andrei Warkentin <[email protected]>
    66
     
    2828#include <Library/PcdLib.h>
    2929#include <Guid/XenInfo.h>
     30#include <IndustryStandard/E820.h>
     31#include <Library/ResourcePublicationLib.h>
     32#include <Library/MtrrLib.h>
    3033
    3134#include "Platform.h"
     35#include "Xen.h"
     36
     37BOOLEAN mXen = FALSE;
     38
     39STATIC UINT32 mXenLeaf = 0;
    3240
    3341EFI_XEN_INFO mXenInfo;
    3442
     43/**
     44  Returns E820 map provided by Xen
     45
     46  @param Entries      Pointer to E820 map
     47  @param Count        Number of entries
     48
     49  @return EFI_STATUS
     50**/
     51EFI_STATUS
     52XenGetE820Map (
     53  EFI_E820_ENTRY64 **Entries,
     54  UINT32 *Count
     55  )
     56{
     57  EFI_XEN_OVMF_INFO *Info =
     58    (EFI_XEN_OVMF_INFO *)(UINTN) OVMF_INFO_PHYSICAL_ADDRESS;
     59
     60  if (AsciiStrCmp ((CHAR8 *) Info->Signature, "XenHVMOVMF")) {
     61    return EFI_NOT_FOUND;
     62  }
     63
     64  ASSERT (Info->E820 < MAX_ADDRESS);
     65  *Entries = (EFI_E820_ENTRY64 *)(UINTN) Info->E820;
     66  *Count = Info->E820EntriesCount;
     67
     68  return EFI_SUCCESS;
     69}
    3570
    3671/**
     
    85120  Figures out if we are running inside Xen HVM.
    86121
    87   @return UINT32     CPUID index used to connect to HV.
    88 
    89 **/
    90 UINT32
     122  @retval TRUE   Xen was detected
     123  @retval FALSE  Xen was not detected
     124
     125**/
     126BOOLEAN
    91127XenDetect (
    92128  VOID
    93129  )
    94130{
    95 
    96   UINT32 XenLeaf;
    97131  UINT8 Signature[13];
    98132
    99   for (XenLeaf = 0x40000000; XenLeaf < 0x40010000; XenLeaf += 0x100) {
    100     AsmCpuid (XenLeaf, NULL, (UINT32 *) &Signature[0],
     133  if (mXenLeaf != 0) {
     134    return TRUE;
     135  }
     136
     137  Signature[12] = '\0';
     138  for (mXenLeaf = 0x40000000; mXenLeaf < 0x40010000; mXenLeaf += 0x100) {
     139    AsmCpuid (mXenLeaf,
     140              NULL,
     141              (UINT32 *) &Signature[0],
    101142              (UINT32 *) &Signature[4],
    102143              (UINT32 *) &Signature[8]);
    103     Signature[12] = '\0';
    104144
    105145    if (!AsciiStrCmp ((CHAR8 *) Signature, "XenVMMXenVMM")) {
    106       return XenLeaf;
     146      mXen = TRUE;
     147      return TRUE;
    107148    }
    108149  }
    109150
    110   return 0;
    111 }
     151  mXenLeaf = 0;
     152  return FALSE;
     153}
     154
     155
     156VOID
     157XenPublishRamRegions (
     158  VOID
     159  )
     160{
     161  EFI_E820_ENTRY64  *E820Map;
     162  UINT32            E820EntriesCount;
     163  EFI_STATUS        Status;
     164
     165  if (!mXen) {
     166    return;
     167  }
     168
     169  DEBUG ((EFI_D_INFO, "Using memory map provided by Xen\n"));
     170
     171  //
     172  // Parse RAM in E820 map
     173  //
     174  Status = XenGetE820Map (&E820Map, &E820EntriesCount);
     175
     176  ASSERT_EFI_ERROR (Status);
     177
     178  if (E820EntriesCount > 0) {
     179    EFI_E820_ENTRY64 *Entry;
     180    UINT32 Loop;
     181
     182    for (Loop = 0; Loop < E820EntriesCount; Loop++) {
     183      Entry = E820Map + Loop;
     184
     185      //
     186      // Only care about RAM
     187      //
     188      if (Entry->Type != EfiAcpiAddressRangeMemory) {
     189        continue;
     190      }
     191
     192      if (Entry->BaseAddr >= BASE_4GB) {
     193        AddUntestedMemoryBaseSizeHob (Entry->BaseAddr, Entry->Length);
     194      } else {
     195        AddMemoryBaseSizeHob (Entry->BaseAddr, Entry->Length);
     196      }
     197
     198      MtrrSetMemoryAttribute (Entry->BaseAddr, Entry->Length, CacheWriteBack);
     199    }
     200  }
     201}
     202
    112203
    113204/**
     
    123214  )
    124215{
    125   UINT32 XenLeaf;
    126 
    127   XenLeaf = XenDetect ();
    128 
    129   if (XenLeaf == 0) {
     216  if (mXenLeaf == 0) {
    130217    return EFI_NOT_FOUND;
    131218  }
    132219
    133   DEBUG ((EFI_D_INFO, "Xen was detected\n"));
    134 
    135   XenConnect (XenLeaf);
     220  XenConnect (mXenLeaf);
    136221
    137222  //
     
    141226  AddReservedMemoryBaseSizeHob (0xFC000000, 0x1000000);
    142227
     228  PcdSetBool (PcdPciDisableBusEnumeration, TRUE);
     229
    143230  return EFI_SUCCESS;
    144231}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette