VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/ArmVirtPkg/CloudHvAcpiPlatformDxe/CloudHvAcpi.c

最後變更 在這個檔案是 101291,由 vboxsync 提交於 18 月 前

EFI/FirmwareNew: Make edk2-stable202308 build on all supported platforms (using gcc at least, msvc not tested yet), bugref:4643

  • 屬性 svn:eol-style 設為 native
檔案大小: 4.5 KB
 
1/** @file
2 Install Acpi tables for Cloud Hypervisor
3
4 Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7**/
8
9#include <Library/BaseLib.h>
10#include <Library/MemoryAllocationLib.h>
11#include <IndustryStandard/Acpi63.h>
12#include <Protocol/AcpiTable.h>
13#include <Library/UefiBootServicesTableLib.h>
14#include <Library/UefiDriverEntryPoint.h>
15#include <Library/DebugLib.h>
16
17/**
18 Find Acpi table Protocol and return it
19
20 @return AcpiTable Protocol, which is used to handle Acpi Table, on SUCCESS or NULL on FAILURE.
21
22**/
23STATIC
24EFI_ACPI_TABLE_PROTOCOL *
25FindAcpiTableProtocol (
26 VOID
27 )
28{
29 EFI_STATUS Status;
30 EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
31
32 Status = gBS->LocateProtocol (
33 &gEfiAcpiTableProtocolGuid,
34 NULL,
35 (VOID **)&AcpiTable
36 );
37 ASSERT_EFI_ERROR (Status);
38 return AcpiTable;
39}
40
41/** Install Acpi tables for Cloud Hypervisor
42
43 @param [in] AcpiProtocol Acpi Protocol which is used to install Acpi tables
44
45 @return EFI_SUCCESS The table was successfully inserted.
46 @return EFI_INVALID_PARAMETER Either AcpiProtocol, AcpiTablePtr or DsdtPtr is NULL
47 and the size field embedded in the ACPI table pointed
48 by AcpiTablePtr or DsdtPtr are not in sync.
49 @return EFI_OUT_OF_RESOURCES Insufficient resources exist to complete the request.
50 @return EFI_NOT_FOUND DSDT table not found.
51**/
52EFI_STATUS
53EFIAPI
54InstallCloudHvAcpiTables (
55 IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol
56 )
57{
58 UINTN InstalledKey;
59 UINTN TableSize;
60 UINTN AcpiTableLength;
61 UINT64 RsdpPtr;
62 UINT64 XsdtPtr;
63 UINT64 TableOffset;
64 UINT64 AcpiTablePtr;
65 UINT64 *DsdtPtr;
66 EFI_STATUS Status;
67
68 if (AcpiProtocol == NULL) {
69 return EFI_INVALID_PARAMETER;
70 }
71
72 RsdpPtr = PcdGet64 (PcdCloudHvAcpiRsdpBaseAddress);
73 XsdtPtr = ((EFI_ACPI_6_3_ROOT_SYSTEM_DESCRIPTION_POINTER *)RsdpPtr)->XsdtAddress;
74 AcpiTableLength = ((EFI_ACPI_COMMON_HEADER *)XsdtPtr)->Length;
75 TableOffset = sizeof (EFI_ACPI_DESCRIPTION_HEADER);
76 DsdtPtr = NULL;
77
78 while (TableOffset < AcpiTableLength) {
79 AcpiTablePtr = *(UINT64 *)(XsdtPtr + TableOffset);
80 TableSize = ((EFI_ACPI_COMMON_HEADER *)AcpiTablePtr)->Length;
81
82 //
83 // Install ACPI tables from XSDT
84 //
85 Status = AcpiProtocol->InstallAcpiTable (
86 AcpiProtocol,
87 (VOID *)AcpiTablePtr,
88 TableSize,
89 &InstalledKey
90 );
91 if (EFI_ERROR (Status)) {
92 return Status;
93 }
94
95 //
96 // Get DSDT from FADT
97 //
98 if ((DsdtPtr == NULL) &&
99 (EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE ==
100 ((EFI_ACPI_COMMON_HEADER *)AcpiTablePtr)->Signature))
101 {
102 DsdtPtr = (UINT64 *)((EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE *)AcpiTablePtr)->XDsdt;
103 }
104
105 TableOffset += sizeof (UINT64);
106 } // while
107
108 if (DsdtPtr == NULL) {
109 DEBUG ((DEBUG_ERROR, "%a: no DSDT found\n", __func__));
110 return EFI_NOT_FOUND;
111 }
112
113 //
114 // Install DSDT table
115 //
116 TableSize = ((EFI_ACPI_COMMON_HEADER *)DsdtPtr)->Length;
117 Status = AcpiProtocol->InstallAcpiTable (
118 AcpiProtocol,
119 DsdtPtr,
120 TableSize,
121 &InstalledKey
122 );
123
124 return Status;
125}
126
127/** Entry point for Cloud Hypervisor Platform Dxe
128
129 @param [in] ImageHandle Handle for this image.
130 @param [in] SystemTable Pointer to the EFI system table.
131
132 @return EFI_SUCCESS The table was successfully inserted.
133 @return EFI_INVALID_PARAMETER Either AcpiProtocol, AcpiTablePtr or DsdtPtr is NULL
134 and the size field embedded in the ACPI table pointed to
135 by AcpiTablePtr or DsdtPtr are not in sync.
136 @return EFI_OUT_OF_RESOURCES Insufficient resources exist to complete the request.
137 @return EFI_NOT_FOUND DSDT table not found
138**/
139EFI_STATUS
140EFIAPI
141CloudHvAcpiPlatformEntryPoint (
142 IN EFI_HANDLE ImageHandle,
143 IN EFI_SYSTEM_TABLE *SystemTable
144 )
145{
146 EFI_STATUS Status;
147
148 Status = InstallCloudHvAcpiTables (FindAcpiTableProtocol ());
149
150 if (EFI_ERROR (Status)) {
151 DEBUG ((
152 DEBUG_ERROR,
153 "%a: Fail to install Acpi table: %r\n",
154 __func__,
155 Status
156 ));
157 CpuDeadLoop ();
158 }
159
160 return EFI_SUCCESS;
161}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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