VirtualBox

Changeset 99452 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Apr 19, 2023 8:08:30 AM (20 months ago)
Author:
vboxsync
Message:

Devices/EFI/FirmwareNew: Need to initialize the PcdPciExpressBaseAddress PCD earlier or the UC base address becomes wrong, bugref:4643

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/Library/PlatformInitLib/MemDetect.c

    r99451 r99452  
    4444#include <Library/PlatformInitLib.h>
    4545
     46#ifdef VBOX
     47# include "VBoxPkg.h"
     48# include "DevEFI.h"
     49# include "iprt/asm.h"
     50
     51static UINT32
     52GetVmVariable(UINT32 Variable, CHAR8 *pbBuf, UINT32 cbBuf)
     53{
     54  UINT32 cbVar, offBuf;
     55
     56  ASMOutU32(EFI_INFO_PORT, Variable);
     57  cbVar = ASMInU32(EFI_INFO_PORT);
     58
     59  for (offBuf = 0; offBuf < cbVar && offBuf < cbBuf; offBuf++)
     60    pbBuf[offBuf] = ASMInU8(EFI_INFO_PORT);
     61
     62  return cbVar;
     63}
     64#endif
     65
    4666#define MEGABYTE_SHIFT  20
    4767
     
    5272  )
    5373{
     74#ifdef VBOX
     75  UINT64 McfgBase = 0;
     76#endif
     77
    5478  if (PlatformInfoHob->HostBridgeDevId == 0xffff /* microvm */) {
    5579    return;
     
    6488  PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob);
    6589
     90#ifdef VBOX
     91  /*
     92   * Need to initialize the dynamic PcdPciExpressBaseAddress here after the low memory
     93   * gets known or the UC base address will become wrong.
     94   * The HOBs are not created however but this is done in PlatformMemMapInitialization()
     95   * which is called later.
     96   */
     97  GetVmVariable(EFI_INFO_INDEX_MCFG_BASE, (CHAR8 *)&McfgBase, sizeof(McfgBase));
     98  if (PlatformInfoHob->LowMemory < BASE_2GB)
     99    PlatformInfoHob->LowMemory = BASE_2GB;
     100  if (McfgBase == 0)
     101    McfgBase = PlatformInfoHob->LowMemory;   // backward compatibilit with old DevEFI
     102
     103  PcdSet64S (PcdPciExpressBaseAddress, McfgBase);
     104#endif
     105
    66106  if (PlatformInfoHob->HostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID) {
    67107    ASSERT (PcdGet64 (PcdPciExpressBaseAddress) <= MAX_UINT32);
    68     //ASSERT (PcdGet64 (PcdPciExpressBaseAddress) >= PlatformInfoHob->LowMemory);
     108    ASSERT (PcdGet64 (PcdPciExpressBaseAddress) >= PlatformInfoHob->LowMemory);
    69109
    70110    if (PlatformInfoHob->LowMemory <= BASE_2GB) {
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