VirtualBox

Ignore:
Timestamp:
Oct 16, 2024 11:36:33 AM (6 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
165165
Message:

Devices/EFI/Firmware: Expose ACPI tables if available, bugref:10733

This requires changing the VBox descriptor slightly to accomodate for the fact that
the XSDP will be located at the end of the ACPI region but the start + size of the
whole region are required for setting up the identity mapped page tables and have this region
covered in the address space. Doesn't need bumping the version because older firmware never
exposed ACPI tables.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/Firmware/ArmVirtPkg/ArmVirtQemu.dsc

    r105670 r106352  
    619619[Components.AARCH64]
    620620  MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
     621!ifndef $(VBOX)
    621622  OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf {
    622623    <LibraryClasses>
    623624      NULL|OvmfPkg/Fdt/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf
    624625  }
     626!else
     627  VBoxPkg/VBoxAcpiPlatformDxe/VBoxAcpiPlatformDxe.inf
     628!endif
  • trunk/src/VBox/Devices/EFI/Firmware/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc

    r105670 r106352  
    154154  INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
    155155  INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
     156!ifndef $(VBOX)
    156157  INF OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
     158!else
     159  INF VBoxPkg/VBoxAcpiPlatformDxe/VBoxAcpiPlatformDxe.inf
     160!endif
    157161!endif
    158162
  • trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.c

    r99404 r106352  
    1616#include <Library/UefiBootServicesTableLib.h>
    1717
     18#ifdef VBOX
     19# include <Library/VBoxArmPlatformLib.h>
     20#endif
     21
    1822EFI_STATUS
    1923EFIAPI
     
    3236  // errors here.
    3337  //
     38#ifndef VBOX
    3439  if ((MAX_UINTN == MAX_UINT64) &&
    3540      !PcdGetBool (PcdForceNoAcpi) &&
     
    4146           )
    4247         ))
     48#else
     49  if (   !PcdGetBool (PcdForceNoAcpi)
     50      && VBoxArmPlatformAcpiStartGetPhysAddr() != 0)
     51#endif
    4352  {
    4453    //
  • trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.inf

    r99404 r106352  
    2424  MdePkg/MdePkg.dec
    2525  OvmfPkg/OvmfPkg.dec
     26  VBoxPkg/VBoxPkg.dec             # VBox: Added
    2627
    2728[LibraryClasses]
     
    3233  UefiBootServicesTableLib
    3334  UefiDriverEntryPoint
     35  VBoxArmPlatformLib              # VBox: Added
    3436
    3537[Guids]
  • trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/Include/Library/VBoxArmPlatformLib.h

    r106061 r106352  
    143143UINTN EFIAPI VBoxArmPlatformMmio32SizeGet(VOID);
    144144
     145
     146/**
     147 * Returns the physical address of the start of the ACPI XSDP.
     148 *
     149 * @returns Physical address of the ACPI XSDP table.
     150 */
     151EFI_PHYSICAL_ADDRESS EFIAPI VBoxArmPlatformAcpiXsdpStartGetPhysAddr(VOID);
     152
     153
     154/**
     155 * Returns the size of the ACPI XSDP.
     156 *
     157 * @returns Size of the ACPI XSDP in bytes.
     158 */
     159UINTN EFIAPI VBoxArmPlatformAcpiXsdpSizeGet(VOID);
     160
     161
     162/**
     163 * Returns the physical address of the start of the ACPI tables.
     164 *
     165 * @returns Physical address of the ACPI table region start.
     166 */
     167EFI_PHYSICAL_ADDRESS EFIAPI VBoxArmPlatformAcpiStartGetPhysAddr(VOID);
     168
     169
     170/**
     171 * Returns the physical address of the start of the ACPI tables.
     172 *
     173 * @returns Size of the ACPI region in bytes.
     174 */
     175UINTN EFIAPI VBoxArmPlatformAcpiSizeGet(VOID);
     176
    145177#endif
    146178
  • trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/Library/VBoxArmPlatformLib/VBoxArmPlatformLib.c

    r106061 r106352  
    169169    return pDesc->cbMmio32;
    170170}
     171
     172
     173EFI_PHYSICAL_ADDRESS EFIAPI VBoxArmPlatformAcpiXsdpStartGetPhysAddr(VOID)
     174{
     175    PCVBOXPLATFORMARMV8 pDesc = (PCVBOXPLATFORMARMV8)VBoxArmPlatformDescGet();
     176    ASSERT(pDesc->u32Magic == VBOXPLATFORMARMV8_MAGIC);
     177
     178    if (!pDesc->cbAcpiXsdp)
     179        return 0;
     180
     181    return (EFI_PHYSICAL_ADDRESS)((UINTN)pDesc + pDesc->i64OffAcpiXsdp);
     182}
     183
     184
     185UINTN EFIAPI VBoxArmPlatformAcpiXsdpSizeGet(VOID)
     186{
     187    PCVBOXPLATFORMARMV8 pDesc = (PCVBOXPLATFORMARMV8)VBoxArmPlatformDescGet();
     188    ASSERT(pDesc->u32Magic == VBOXPLATFORMARMV8_MAGIC);
     189
     190    return pDesc->cbAcpiXsdp;
     191}
     192
     193
     194EFI_PHYSICAL_ADDRESS EFIAPI VBoxArmPlatformAcpiStartGetPhysAddr(VOID)
     195{
     196    PCVBOXPLATFORMARMV8 pDesc = (PCVBOXPLATFORMARMV8)VBoxArmPlatformDescGet();
     197    ASSERT(pDesc->u32Magic == VBOXPLATFORMARMV8_MAGIC);
     198
     199    if (!pDesc->cbAcpi)
     200        return 0;
     201
     202    return (EFI_PHYSICAL_ADDRESS)((UINTN)pDesc + pDesc->i64OffAcpi);
     203}
     204
     205
     206UINTN EFIAPI VBoxArmPlatformAcpiSizeGet(VOID)
     207{
     208    PCVBOXPLATFORMARMV8 pDesc = (PCVBOXPLATFORMARMV8)VBoxArmPlatformDescGet();
     209    ASSERT(pDesc->u32Magic == VBOXPLATFORMARMV8_MAGIC);
     210
     211    return pDesc->cbAcpi;
     212}
  • trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/Library/VBoxVirtMemInfoLib/VBoxVirtMemInfoLib.c

    r106061 r106352  
    4646
    4747// Number of Virtual Memory Map Descriptors
    48 #define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS  7
     48#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS  8
    4949
    5050/**
     
    8989{
    9090  ARM_MEMORY_REGION_DESCRIPTOR  *VirtualMemoryTable;
     91  UINT8 idxMemDesc = 0;
    9192
    9293  ASSERT (VirtualMemoryMap != NULL);
     
    103104
    104105  // System DRAM
    105   VirtualMemoryTable[0].PhysicalBase = VBoxArmPlatformRamBaseStartGetPhysAddr();
    106   VirtualMemoryTable[0].VirtualBase  = VirtualMemoryTable[0].PhysicalBase;
    107   VirtualMemoryTable[0].Length       = VBoxArmPlatformRamBaseSizeGet();
    108   VirtualMemoryTable[0].Attributes   = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
     106  VirtualMemoryTable[idxMemDesc].PhysicalBase = VBoxArmPlatformRamBaseStartGetPhysAddr();
     107  VirtualMemoryTable[idxMemDesc].VirtualBase  = VirtualMemoryTable[idxMemDesc].PhysicalBase;
     108  VirtualMemoryTable[idxMemDesc].Length       = VBoxArmPlatformRamBaseSizeGet();
     109  VirtualMemoryTable[idxMemDesc].Attributes   = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
     110  idxMemDesc++;
    109111
    110112  // Memory mapped peripherals
    111   VirtualMemoryTable[1].PhysicalBase = VBoxArmPlatformMmioStartGetPhysAddr();
    112   VirtualMemoryTable[1].VirtualBase  = VirtualMemoryTable[1].PhysicalBase;
    113   VirtualMemoryTable[1].Length       = VBoxArmPlatformMmioSizeGet();
    114   VirtualMemoryTable[1].Attributes   = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
     113  VirtualMemoryTable[idxMemDesc].PhysicalBase = VBoxArmPlatformMmioStartGetPhysAddr();
     114  VirtualMemoryTable[idxMemDesc].VirtualBase  = VirtualMemoryTable[idxMemDesc].PhysicalBase;
     115  VirtualMemoryTable[idxMemDesc].Length       = VBoxArmPlatformMmioSizeGet();
     116  VirtualMemoryTable[idxMemDesc].Attributes   = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
     117  idxMemDesc++;
    115118
    116119  // Map the FV region as normal executable memory
    117   VirtualMemoryTable[2].PhysicalBase = VBoxArmPlatformUefiRomStartGetPhysAddr();
    118   VirtualMemoryTable[2].VirtualBase  = VirtualMemoryTable[2].PhysicalBase;
    119   VirtualMemoryTable[2].Length       = FixedPcdGet32 (PcdFvSize);
    120   VirtualMemoryTable[2].Attributes   = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_RO;
     120  VirtualMemoryTable[idxMemDesc].PhysicalBase = VBoxArmPlatformUefiRomStartGetPhysAddr();
     121  VirtualMemoryTable[idxMemDesc].VirtualBase  = VirtualMemoryTable[idxMemDesc].PhysicalBase;
     122  VirtualMemoryTable[idxMemDesc].Length       = FixedPcdGet32 (PcdFvSize);
     123  VirtualMemoryTable[idxMemDesc].Attributes   = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_RO;
     124  idxMemDesc++;
    121125
    122126  // Map the FDT region readonnly.
    123   VirtualMemoryTable[3].PhysicalBase = VBoxArmPlatformFdtGet();
    124   VirtualMemoryTable[3].VirtualBase  = VirtualMemoryTable[3].PhysicalBase;
    125   VirtualMemoryTable[3].Length       = VBoxArmPlatformFdtSizeGet();
    126   VirtualMemoryTable[3].Attributes   = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_RO;
     127  VirtualMemoryTable[idxMemDesc].PhysicalBase = VBoxArmPlatformFdtGet();
     128  VirtualMemoryTable[idxMemDesc].VirtualBase  = VirtualMemoryTable[idxMemDesc].PhysicalBase;
     129  VirtualMemoryTable[idxMemDesc].Length       = VBoxArmPlatformFdtSizeGet();
     130  VirtualMemoryTable[idxMemDesc].Attributes   = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_RO;
     131  idxMemDesc++;
    127132
    128133  // Map the VBox descriptor region readonly.
    129   VirtualMemoryTable[4].PhysicalBase = VBoxArmPlatformDescGetPhysAddr();
    130   VirtualMemoryTable[4].VirtualBase  = VirtualMemoryTable[4].PhysicalBase;
    131   VirtualMemoryTable[4].Length       = VBoxArmPlatformDescSizeGet();
    132   VirtualMemoryTable[4].Attributes   = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_RO;
     134  VirtualMemoryTable[idxMemDesc].PhysicalBase = VBoxArmPlatformDescGetPhysAddr();
     135  VirtualMemoryTable[idxMemDesc].VirtualBase  = VirtualMemoryTable[idxMemDesc].PhysicalBase;
     136  VirtualMemoryTable[idxMemDesc].Length       = VBoxArmPlatformDescSizeGet();
     137  VirtualMemoryTable[idxMemDesc].Attributes   = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_RO;
     138  idxMemDesc++;
     139
     140  // Map the ACPI region if it exists.
     141  if (VBoxArmPlatformAcpiSizeGet() != 0)
     142  {
     143    VirtualMemoryTable[idxMemDesc].PhysicalBase = VBoxArmPlatformAcpiStartGetPhysAddr();
     144    VirtualMemoryTable[idxMemDesc].VirtualBase  = VirtualMemoryTable[idxMemDesc].PhysicalBase;
     145    VirtualMemoryTable[idxMemDesc].Length       = VBoxArmPlatformAcpiSizeGet();
     146    VirtualMemoryTable[idxMemDesc].Attributes   = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_RO;
     147    idxMemDesc++;
     148  }
    133149
    134150  // Map the MMIO32 region if it exists.
    135151  if (VBoxArmPlatformMmio32SizeGet() != 0)
    136152  {
    137     VirtualMemoryTable[5].PhysicalBase = VBoxArmPlatformMmio32StartGetPhysAddr();
    138     VirtualMemoryTable[5].VirtualBase  = VirtualMemoryTable[5].PhysicalBase;
    139     VirtualMemoryTable[5].Length       = VBoxArmPlatformMmio32SizeGet();
    140     VirtualMemoryTable[5].Attributes   = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
     153    VirtualMemoryTable[idxMemDesc].PhysicalBase = VBoxArmPlatformMmio32StartGetPhysAddr();
     154    VirtualMemoryTable[idxMemDesc].VirtualBase  = VirtualMemoryTable[idxMemDesc].PhysicalBase;
     155    VirtualMemoryTable[idxMemDesc].Length       = VBoxArmPlatformMmio32SizeGet();
     156    VirtualMemoryTable[idxMemDesc].Attributes   = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
     157    idxMemDesc++;
    141158  }
    142159
    143160  // End of Table
    144   ZeroMem (&VirtualMemoryTable[6], sizeof (ARM_MEMORY_REGION_DESCRIPTOR));
     161  ZeroMem (&VirtualMemoryTable[idxMemDesc], sizeof (ARM_MEMORY_REGION_DESCRIPTOR));
    145162
    146163  for (UINTN i = 0; i < MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS; i++)
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