50 UINT32 RelocationPages;
57 ZeroMem (&RelocationMap,
sizeof (RelocationMap));
64 AsmGetRelocationMap (&RelocationMap);
65 if ((RelocationMap.RelocateApLoopFuncAddress == 0) || (RelocationMap.RelocateApLoopFuncSize == 0)) {
66 DEBUG ((DEBUG_ERROR,
"Failed to get the RelocationMap.\n"));
70 RelocationPages =
EFI_SIZE_TO_PAGES ((UINT32)RelocationMap.RelocateApLoopFuncSize) + 1;
73 if (EFI_ERROR (Status)) {
74 DEBUG ((DEBUG_ERROR,
"Failed to allocate pages for MailboxRelocation. %r\n", Status));
80 ApLoopFunc = (VOID *)((
UINTN)Address + EFI_PAGE_SIZE);
84 RelocationMap.RelocateApLoopFuncAddress,
85 RelocationMap.RelocateApLoopFuncSize
90 "Ap Relocation: mailbox %llx, loop %p\n",
99 RelocatedMailBox->Command = MpProtectedModeWakeupCommandNoop;
100 RelocatedMailBox->ApicId = MP_CPU_PROTECTED_MODE_MAILBOX_APICID_INVALID;
101 RelocatedMailBox->WakeUpVector = 0;
110 MpProtectedModeWakeupCommandWakeup,
112 (UINT64)RelocatedMailBox,
139 EFI_ACPI_TABLE_VERSION Version;
140 UINTN OriginalTableKey;
143 UINTN NewMadtTableLength;
152 Status =
gBS->LocateProtocol (&gEfiAcpiSdtProtocolGuid,
NULL, (
void **)&AcpiSdtProtocol);
153 if (EFI_ERROR (Status)) {
154 DEBUG ((DEBUG_ERROR,
"Unable to locate ACPI SDT protocol.\n"));
159 if (RelocateMailboxAddress == 0) {
161 DEBUG ((DEBUG_ERROR,
"Failed to relocate Td mailbox\n"));
166 Status = AcpiSdtProtocol->GetAcpiTable (Index, &Table, &Version, &OriginalTableKey);
169 Status =
gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid,
NULL, (
void **)&AcpiTableProtocol);
170 if (EFI_ERROR (Status)) {
171 DEBUG ((DEBUG_ERROR,
"Unable to locate ACPI Table protocol.\n"));
177 if (NewMadtTable ==
NULL) {
178 DEBUG ((DEBUG_ERROR,
"%a: OUT_OF_SOURCES error.\n", __func__));
182 CopyMem (NewMadtTable, (UINT8 *)Table, Table->Length);
184 MadtHeader->Header.Length = (UINT32)NewMadtTableLength;
187 MadtMpWk->Type = EFI_ACPI_6_4_MULTIPROCESSOR_WAKEUP;
189 MadtMpWk->MailBoxVersion = 0;
190 MadtMpWk->Reserved = 0;
191 MadtMpWk->MailBoxAddress = RelocateMailboxAddress;
193 Status = AcpiTableProtocol->InstallAcpiTable (AcpiTableProtocol, NewMadtTable, NewMadtTableLength, &NewTableKey);
194 if (EFI_ERROR (Status)) {
195 DEBUG ((DEBUG_ERROR,
"Failed to install new MADT table. %r\n", Status));
199 Status = AcpiTableProtocol->UninstallAcpiTable (AcpiTableProtocol, OriginalTableKey);
200 if (EFI_ERROR (Status)) {
201 DEBUG ((DEBUG_ERROR,
"Uninstall old MADT table error.\n"));
208 }
while (!EFI_ERROR (Status));
210 if (NewMadtTable !=
NULL) {
#define EFI_ACPI_1_0_APIC_SIGNATURE
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define DEBUG(Expression)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
EFI_PHYSICAL_ADDRESS EFIAPI RelocateMailbox(VOID)
VOID EFIAPI AlterAcpiTable(IN EFI_EVENT Event, IN VOID *Context)
VOID EFIAPI MpSerializeStart(VOID)
VOID EFIAPI MpSendWakeupCommand(IN UINT16 Command, IN UINT64 WakeupVector, IN UINT64 WakeupArgs1, IN UINT64 WakeupArgs2, IN UINT64 WakeupArgs3, IN UINT64 WakeupArgs4)
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_PAGES_TO_SIZE(Pages)
#define EFI_SIZE_TO_PAGES(Size)