VirtualBox

Changeset 101439 in vbox for trunk/src/VBox/Devices/EFI


Ignore:
Timestamp:
Oct 13, 2023 1:18:45 PM (18 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
159498
Message:

Devices/EFI/Firmware/{VBoxPkg,ArmVirtPkg}: Don't rely on the hardcoded base RAM start addresses and sizes, allows to move the base RAM region (almost) freely in the physical address space of the guest, bugref:10528

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/Firmware/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c

    r99464 r101439  
    1717#include <Library/PcdLib.h>
    1818#include <Library/CacheMaintenanceLib.h>
     19
     20#ifdef VBOX
     21# include <Library/VBoxArmPlatformLib.h>
     22#endif
     23
    1924
    2025VOID
     
    5661  VOID                         *Hob;
    5762
     63#ifndef VBOX
    5864  // Ensure PcdSystemMemorySize has been set
    5965  ASSERT (PcdGet64 (PcdSystemMemorySize) != 0);
    6066
    6167  SystemMemorySize = PcdGet64 (PcdSystemMemorySize);
     68#else
     69  // Ensure we have memory
     70  ASSERT (VBoxArmPlatformRamBaseSizeGet() != 0);
     71
     72  SystemMemorySize = VBoxArmPlatformRamBaseSizeGet();
     73#endif
    6274
    6375  Hob = GetFirstGuidHob (&gArmVirtSystemMemorySizeGuid);
     
    7688                        );
    7789
     90#ifndef VBOX
    7891  SystemMemoryTop = PcdGet64 (PcdSystemMemoryBase) + SystemMemorySize;
     92#else
     93  SystemMemoryTop = (UINTN)VBoxArmPlatformRamBaseStartGetPhysAddr() + SystemMemorySize;
     94#endif
    7995
    8096  if (SystemMemoryTop - 1 > MAX_ALLOC_ADDRESS) {
     
    8298      EFI_RESOURCE_SYSTEM_MEMORY,
    8399      ResourceAttributes,
     100#ifndef VBOX
    84101      PcdGet64 (PcdSystemMemoryBase),
    85102      (UINT64)MAX_ALLOC_ADDRESS - PcdGet64 (PcdSystemMemoryBase) + 1
     103#else
     104      (UINT64)VBoxArmPlatformRamBaseStartGetPhysAddr(),
     105      (UINT64)MAX_ALLOC_ADDRESS - VBoxArmPlatformRamBaseStartGetPhysAddr() + 1
     106#endif
    86107      );
    87108    BuildResourceDescriptorHob (
     
    95116      EFI_RESOURCE_SYSTEM_MEMORY,
    96117      ResourceAttributes,
     118#ifndef VBOX
    97119      PcdGet64 (PcdSystemMemoryBase),
     120#else
     121      (UINT64)VBoxArmPlatformRamBaseStartGetPhysAddr(),
     122#endif
    98123      SystemMemorySize
    99124      );
  • trunk/src/VBox/Devices/EFI/Firmware/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.inf

    r99464 r101439  
    2525  ArmPlatformPkg/ArmPlatformPkg.dec
    2626  ArmVirtPkg/ArmVirtPkg.dec
     27  VBoxPkg/VBoxPkg.dec               # VBox: Added
    2728
    2829[LibraryClasses]
     
    3334  ArmVirtMemInfoLib
    3435  CacheMaintenanceLib
     36  VBoxArmPlatformLib                # VBox: Added
    3537
    3638[Guids]
  • trunk/src/VBox/Devices/EFI/Firmware/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.c

    r99464 r101439  
    1616#include <Library/PcdLib.h>
    1717#include <Guid/MemoryTypeInformation.h>
     18
     19#ifdef VBOX
     20# include <Library/VBoxArmPlatformLib.h>
     21#endif
    1822
    1923EFI_STATUS
     
    8084  EFI_STATUS  Status;
    8185
     86#ifndef VBOX
    8287  ASSERT (FixedPcdGet64 (PcdSystemMemoryBase) < (UINT64)MAX_ALLOC_ADDRESS);
    8388
     
    8893  UefiMemoryBase = (UINTN)FixedPcdGet64 (PcdSystemMemoryBase) + SIZE_128MB
    8994                   - FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);
     95#else
     96  ASSERT (VBoxArmPlatformRamBaseStartGetPhysAddr() < (UINT64)MAX_ALLOC_ADDRESS);
     97
     98  //
     99  // Put the permanent PEI memory at the top of the base DRAM region.
     100  //
     101  UefiMemoryBase = (UINTN)VBoxArmPlatformRamBaseStartGetPhysAddr() + VBoxArmPlatformRamBaseSizeGet()
     102                   - FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);
     103#endif
    90104
    91105  Status = PeiServicesInstallPeiMemory (
  • trunk/src/VBox/Devices/EFI/Firmware/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf

    r99464 r101439  
    2727  ArmPkg/ArmPkg.dec
    2828  ArmPlatformPkg/ArmPlatformPkg.dec
     29  VBoxPkg/VBoxPkg.dec               # VBox: Added
    2930
    3031[LibraryClasses]
     
    3536  ArmPlatformLib
    3637  MemoryInitPeiLib
     38  VBoxArmPlatformLib                # VBox: Added
    3739
    3840[Guids]
     
    4345
    4446[FixedPcd]
    45   gArmTokenSpaceGuid.PcdSystemMemoryBase
     47#  gArmTokenSpaceGuid.PcdSystemMemoryBase VBox: Commented out
    4648  gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize
    4749
  • trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/Library/VBoxVirtMemInfoLib/VBoxVirtMemInfoPeiLib.inf

    r101434 r101439  
    6969  gArmTokenSpaceGuid.PcdFdBaseAddress
    7070  gArmTokenSpaceGuid.PcdFvBaseAddress
    71   gArmTokenSpaceGuid.PcdSystemMemoryBase
    72   gArmTokenSpaceGuid.PcdSystemMemorySize
    7371  gArmTokenSpaceGuid.PcdFdSize
    7472  gArmTokenSpaceGuid.PcdFvSize
  • trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/Library/VBoxVirtMemInfoLib/VBoxVirtMemInfoPeiLibConstructor.c

    r101434 r101439  
    5656
    5757  /** @todo This will go away soon when we change the other places to deal with dynamic RAM ranges. */
    58   //
    59   // Make sure the start of DRAM matches our expectation
    60   //
    61   ASSERT (PcdGet64 (PcdSystemMemoryBase) == NewBase);
    62 
    6358  Hob = BuildGuidDataHob (
    6459          &gArmVirtSystemMemorySizeGuid,
Note: See TracChangeset for help on using the changeset viewer.

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