Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UefiPayloadPkg: Add AARCH64 support #6545

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
[Guids]
gUefiAcpiBoardInfoGuid
gUplPciSegmentInfoHobGuid
gUniversalPayloadPciRootBridgeInfoGuid

[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration
4 changes: 4 additions & 0 deletions UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,15 @@ PlatformHookSerialPortInitialize (
return Status;
}

#if FixedPcdGetBool (PcdUseUniversalPayloadSerialPort) == 1

Status = PcdSet32S (PcdSerialBaudRate, SerialPortInfo->BaudRate);
LinusvPelt marked this conversation as resolved.
Show resolved Hide resolved
if (RETURN_ERROR (Status)) {
return Status;
}

#endif

return RETURN_SUCCESS;
}

Expand Down
69 changes: 69 additions & 0 deletions UefiPayloadPkg/UefiPayloadEntry/AArch64/DxeHandoff.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/** @file
Generic version of arch-specific functionality for DxeLoad.

Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
Copyright 2024 Google LLC

SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#include <PiPei.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
#include <Library/HobLib.h>

#include "UefiPayloadEntry.h"

#define STACK_SIZE 0x20000

/**
Transfers control to DxeCore.

This function performs a CPU architecture specific operations to execute
the entry point of DxeCore with the parameters of HobList.
It also installs EFI_END_OF_PEI_PPI to signal the end of PEI phase.

@param DxeCoreEntryPoint The entry point of DxeCore.
@param HobList The start of HobList passed to DxeCore.

**/
VOID
HandOffToDxeCore (
IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,
IN EFI_PEI_HOB_POINTERS HobList
)
{
VOID *BaseOfStack;
VOID *TopOfStack;

//
// Allocate 128KB for the Stack
//
BaseOfStack = AllocatePages (EFI_SIZE_TO_PAGES (STACK_SIZE));
ASSERT (BaseOfStack != NULL);

//
// Compute the top of the stack we were allocated. Pre-allocate a UINTN
// for safety.
//
TopOfStack = (VOID *)((UINTN)BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);
TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);

//
// Update the contents of BSP stack HOB to reflect the real stack info passed to DxeCore.
//
UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN)BaseOfStack, STACK_SIZE);

//
// Transfer the control to the entry point of DxeCore.
//
SwitchStack (
(SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,
HobList.Raw,
NULL,
TopOfStack
);
}
26 changes: 26 additions & 0 deletions UefiPayloadPkg/UefiPayloadEntry/AArch64/DxeLoadFuncFit.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/** @file
aarch64-specifc functionality for Module Entry Point.

Copyright 2024 Google LLC

SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#include "UefiPayloadEntry.h"

/**
Entry point to the C language phase of UEFI payload.
@param[in] FdtBaseAddr Pointer to the FDT
@param[in] AdditionalPara Not used yet
@retval It will not return if SUCCESS, and return error
when passing bootloader parameter.
**/
EFI_STATUS
EFIAPI
_ModuleEntryPoint (
IN UINTN FdtBaseAddr,
IN UINTN AddtionalPara
)
{
return FitUplEntryPoint (FdtBaseAddr);
}
17 changes: 17 additions & 0 deletions UefiPayloadPkg/UefiPayloadEntry/AArch64/StubLib.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/** @file
Null instance of CPU related Library for AArch64 specific services.

Copyright 2024 Google LLC

SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#include "UefiPayloadEntry.h"

VOID
EFIAPI
InitializeFloatingPointUnits (
VOID
)
{
}
9 changes: 7 additions & 2 deletions UefiPayloadPkg/UefiPayloadEntry/FitUniversalPayloadEntry.inf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# This is the first module for UEFI payload.
#
# Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
# Copyright 2024 Google LLC
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
Expand All @@ -17,7 +18,7 @@
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64
# VALID_ARCHITECTURES = IA32 X64 AARCH64
#

[Sources]
Expand All @@ -42,6 +43,10 @@
RiscV64/DxeLoadFunc.c
RiscV64/DxeLoadFuncFit.c

[Sources.AARCH64]
AArch64/DxeHandoff.c
AArch64/DxeLoadFuncFit.c

[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
Expand Down Expand Up @@ -86,7 +91,7 @@
[FeaturePcd.X64]
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplBuildPageTables ## CONSUMES

[Pcd.IA32,Pcd.X64,Pcd.RISCV64]
[Pcd.IA32,Pcd.X64,Pcd.RISCV64,Pcd.AARCH64]
gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile
gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES
Expand Down
2 changes: 2 additions & 0 deletions UefiPayloadPkg/UefiPayloadEntry/PrintHob.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ PrintMemoryTypeInfoGuidHob (
//
GUID_HOB_PRINT_HANDLE GuidHobPrintHandleTable[] = {
{ &gUniversalPayloadAcpiTableGuid, PrintAcpiGuidHob, "gUniversalPayloadAcpiTableGuid(ACPI table Guid)" },
#if FixedPcdGetBool (PcdUseUniversalPayloadSerialPort) == 1
{ &gUniversalPayloadSerialPortInfoGuid, PrintSerialGuidHob, "gUniversalPayloadSerialPortInfoGuid(Serial Port Info)" },
#endif
{ &gUniversalPayloadSmbios3TableGuid, PrintSmbios3GuidHob, "gUniversalPayloadSmbios3TableGuid(SmBios Guid)" },
{ &gUniversalPayloadSmbiosTableGuid, PrintSmbiosTablGuidHob, "gUniversalPayloadSmbiosTableGuid(SmBios Guid)" },
{ &gUefiAcpiBoardInfoGuid, PrintAcpiBoardInfoGuidHob, "gUefiAcpiBoardInfoGuid(Acpi Guid)" },
Expand Down
6 changes: 6 additions & 0 deletions UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,10 @@ UplEntryPoint (
IN UINTN BootloaderParameter
);

VOID
EFIAPI
InitializeFloatingPointUnits (
VOID
);

#endif
9 changes: 7 additions & 2 deletions UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64
# VALID_ARCHITECTURES = IA32 X64 AARCH64
#

[Sources]
Expand All @@ -38,6 +38,11 @@
X64/VirtualMemory.c
X64/DxeLoadFunc.c

[Sources.AARCH64]
AArch64/DxeHandoff.c
AArch64/DxeLoadFuncFit.c
AArch64/StubLib.c

[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
Expand Down Expand Up @@ -73,7 +78,7 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplBuildPageTables ## CONSUMES


[Pcd.IA32,Pcd.X64]
[Pcd.IA32,Pcd.X64,Pcd.AARCH64]
gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ## CONSUMES
Expand Down
8 changes: 6 additions & 2 deletions UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64
# VALID_ARCHITECTURES = IA32 X64 AARCH64
#
[Sources]
UniversalPayloadEntry.c
Expand All @@ -32,6 +32,10 @@
X64/VirtualMemory.h
X64/VirtualMemory.c
X64/DxeLoadFunc.c
[Sources.AARCH64]
AArch64/DxeHandoff.c
AArch64/DxeLoadFuncFit.c
AArch64/StubLib.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
Expand Down Expand Up @@ -67,7 +71,7 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## CONSUMES
[FeaturePcd.X64]
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplBuildPageTables ## CONSUMES
[Pcd.IA32,Pcd.X64]
[Pcd.IA32,Pcd.X64,Pcd.AARCH64]
gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile
gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES
Expand Down
5 changes: 5 additions & 0 deletions UefiPayloadPkg/UefiPayloadPkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,8 @@ gUefiPayloadPkgTokenSpaceGuid.PcdPciReservedPMemAbove4GBLimit|0x0000000000000000

gUefiPayloadPkgTokenSpaceGuid.SizeOfIoSpace|0|UINT8|0x0000002B
gUefiPayloadPkgTokenSpaceGuid.PcdFDTPageSize|8|UINT8|0x0000002C

## Indicates if Universal Payload Serial Port feature is used
#- PcdUseUniversalPayloadSerialPort is TRUE, Serial Port parameters will be updated
#- PcdUseUniversalPayloadSerialPort is FALSE, Serial Port parameters are fixed
gUefiPayloadPkgTokenSpaceGuid.PcdUseUniversalPayloadSerialPort|TRUE|BOOLEAN|0x0000002D
Loading
Loading