summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChao Li <lichao@loongson.cn>2025-01-21 14:59:47 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2025-01-22 03:57:16 +0000
commit336e7e06eb91fee6f87b2559772aed948fb7bbfe (patch)
treeb7ba475e2567cc116bea44432be7972c3a8f0c98
parent7bc51fc68e534f1ba4539f4fb38c12dba679eefc (diff)
downloadedk2-336e7e06eb91fee6f87b2559772aed948fb7bbfe.tar.gz
UefiCpuPkg/CpuMpPei: Add LoongArch64 support
Added LoongArch64 CPU multiple processor PPI support. Cc: Ray Ni <ray.ni@intel.com> Cc: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Zhiguang Liu <zhiguang.liu@intel.com> Cc: Dun Tan <dun.tan@intel.com> Cc: Rahul Kumar <rahul1.kumar@intel.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Chao Li <lichao@loongson.cn>
-rw-r--r--UefiCpuPkg/CpuMpPei/CpuMpPei.inf13
-rw-r--r--UefiCpuPkg/CpuMpPei/LoongArch64/CpuMpPei.c80
2 files changed, 90 insertions, 3 deletions
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
index 1f24aa6f2e..93e7eace00 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
@@ -19,17 +19,22 @@
#
# The following information is for reference only and not required by the build tools.
#
-# VALID_ARCHITECTURES = IA32 X64
+# VALID_ARCHITECTURES = IA32 X64 LOONGARCH64
#
[Sources]
CpuMpPei.h
CpuMp.c
CpuMp2.c
+
+[Sources.Ia32, Sources.X64]
CpuBist.c
CpuPaging.c
CpuMpPei.c
+[Sources.LoongArch64]
+ LoongArch64/CpuMpPei.c
+
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
@@ -39,16 +44,18 @@
BaseLib
DebugLib
HobLib
- LocalApicLib
PeimEntryPoint
PeiServicesLib
ReportStatusCodeLib
- CpuExceptionHandlerLib
MpInitLib
BaseMemoryLib
CpuLib
MemoryAllocationLib
+
+[LibraryClasses.Ia32, LibraryClasses.X64]
+ CpuExceptionHandlerLib
CpuPageTableLib
+ LocalApicLib
[Guids]
gEdkiiMigratedFvInfoGuid ## SOMETIMES_CONSUMES ## HOB
diff --git a/UefiCpuPkg/CpuMpPei/LoongArch64/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/LoongArch64/CpuMpPei.c
new file mode 100644
index 0000000000..705575b339
--- /dev/null
+++ b/UefiCpuPkg/CpuMpPei/LoongArch64/CpuMpPei.c
@@ -0,0 +1,80 @@
+/** @file
+ CPU PEI Module installs CPU Multiple Processor PPI.
+
+ Copyright (c) 2015 - 2022, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2025, Loongson Technology Corporation Limited. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "CpuMpPei.h"
+
+EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiList[] = {
+ {
+ EFI_PEI_PPI_DESCRIPTOR_PPI,
+ &gEdkiiPeiMpServices2PpiGuid,
+ &mMpServices2Ppi
+ },
+ {
+ (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+ &gEfiPeiMpServicesPpiGuid,
+ &mMpServicesPpi
+ }
+};
+
+/**
+ Initializes MP and exceptions handlers.
+
+ @param PeiServices The pointer to the PEI Services Table.
+
+ @retval EFI_SUCCESS MP was successfully initialized.
+ @retval others Error occurred in MP initialization.
+
+**/
+EFI_STATUS
+InitializeCpuMpWorker (
+ IN CONST EFI_PEI_SERVICES **PeiServices
+ )
+{
+ EFI_STATUS Status;
+
+ Status = MpInitLibInitialize ();
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Install CPU MP PPI
+ //
+ Status = PeiServicesInstallPpi (mPeiCpuMpPpiList);
+ ASSERT_EFI_ERROR (Status);
+
+ return Status;
+}
+
+/**
+ The Entry point of the MP CPU PEIM.
+
+ This function will wakeup APs and collect CPU AP count and install the
+ Mp Service Ppi.
+
+ @param FileHandle Handle of the file being invoked.
+ @param PeiServices Describes the list of possible PEI Services.
+
+ @retval EFI_SUCCESS MpServicePpi is installed successfully.
+
+**/
+EFI_STATUS
+EFIAPI
+CpuMpPeimInit (
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
+ )
+{
+ EFI_STATUS Status;
+
+ Status = InitializeCpuMpWorker ((CONST EFI_PEI_SERVICES **)PeiServices);
+ ASSERT_EFI_ERROR (Status);
+
+ return Status;
+}