From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from loongson.cn (loongson.cn [114.242.206.163]) by mx.groups.io with SMTP id smtpd.web11.98484.1671007037991560844 for ; Wed, 14 Dec 2022 00:37:18 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: loongson.cn, ip: 114.242.206.163, mailfrom: lichao@loongson.cn) Received: from loongson.cn (unknown [10.2.9.245]) by gateway (Coremail) with SMTP id _____8Bx3+s7i5ljnXsFAA--.12800S3; Wed, 14 Dec 2022 16:37:15 +0800 (CST) Received: from code-server.gen (unknown [10.2.9.245]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxoOI3i5lj3fMuAA--.48256S4; Wed, 14 Dec 2022 16:37:15 +0800 (CST) From: "Chao Li" To: devel@edk2.groups.io Cc: G Edhaya Chandran , Barton Gao , Carolyn Gjertsen , Samer El-Haj-Mahmoud , Eric Jin , Supreeth Venkatesh Subject: [PATCH v1 2/2] uefi-sct/SctPkg: Enable LoongArch64 building Date: Wed, 14 Dec 2022 16:36:58 +0800 Message-Id: <20221214083658.432422-3-lichao@loongson.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20221214083658.432422-1-lichao@loongson.cn> References: <20221214083658.432422-1-lichao@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxoOI3i5lj3fMuAA--.48256S4 X-CM-SenderInfo: xolfxt3r6o00pqjv00gofq/1tbiAQAACGOYa2g3EgAEsQ X-Coremail-Antispam: 1Uk129KBjvAXoWfXr1kKF48GF17GFykurWUCFg_yoW8ZF1kCo W8uayvgrs8J345u39rW3y3Ka18WrsY9FW8Jrs7WFWkJaySqFnxK3yUt3y7Ar1xXF18Jan8 Ga4UWas3JFWxGwn5n29KB7ZKAUJUUUUr529EdanIXcx71UUUUU7KY7ZEXasCq-sGcSsGvf J3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnRJU UUkm1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64 kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY 1x0267AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6x kF7I0E14v26r4UJVWxJr1ln4kS14v26r1Y6r17M2AIxVAIcxkEcVAq07x20xvEncxIr21l 57IF6xkI12xvs2x26I8E6xACxx1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6x8ErcxFaV Av8VWrMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCY1x0262kKe7AKxVWU AVWUtwCF04k20xvY0x0EwIxGrwCF04k20xvE74AGY7Cv6cx26rWl4I8I3I0E4IkC6x0Yz7 v_Jr0_Gr1l4IxYO2xFxVAFwI0_Jrv_JF1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8G jcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2I x0cI8IcVAFwI0_Gr0_Xr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK 8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I 0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvj4R_gAwDUUUU Content-Transfer-Encoding: 8bit BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4192 Cc: G Edhaya Chandran Cc: Barton Gao Cc: Carolyn Gjertsen Cc: Samer El-Haj-Mahmoud Cc: Eric Jin Cc: Supreeth Venkatesh Signed-off-by: Chao Li --- .../Application/InstallSct/InstallSctDef.h | 4 + uefi-sct/SctPkg/Library/SctLib/SctLib.inf | 6 ++ uefi-sct/SctPkg/SCRT/SCRTApp/SCRTApp.inf | 5 + .../SctPkg/SCRT/SCRTDriver/SCRTDriver.inf | 6 ++ .../BlackBoxTest/DebugSupportBBTest.inf | 6 ++ .../Usb2Hc/BlackBoxTest/Usb2HcTest.inf | 4 + .../Protocol/UsbHc/BlackBoxTest/UsbHcTest.inf | 4 + .../SCT/Framework/ENTS/EasLib/EntsLib.inf | 5 + .../SctPkg/Tools/Source/GenBin/GNUmakefile | 4 + uefi-sct/SctPkg/UEFI/IHV_SCT.dsc | 12 ++- uefi-sct/SctPkg/UEFI/Protocol/DebugSupport.h | 101 +++++++++++++++++- uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc | 15 ++- uefi-sct/SctPkg/build.sh | 10 +- 13 files changed, 176 insertions(+), 6 deletions(-) diff --git a/uefi-sct/SctPkg/Application/InstallSct/InstallSctDef.h b/uefi-sct/SctPkg/Application/InstallSct/InstallSctDef.h index 02f0283e..f7974bf6 100644 --- a/uefi-sct/SctPkg/Application/InstallSct/InstallSctDef.h +++ b/uefi-sct/SctPkg/Application/InstallSct/InstallSctDef.h @@ -4,6 +4,7 @@ Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
Portions copyright (c) 2014, ARM Ltd. All rights reserved.
(C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -36,6 +37,9 @@ #elif defined(EFIRISCV64) #define INSTALL_SCT_PLATFORM_SHORT_NAME L"riscv64" #define INSTALL_SCT_PLATFORM_NAME L"RISCV64" +#elif defined(EFILOONGARCH64) + #define INSTALL_SCT_PLATFORM_SHORT_NAME L"loongarch64" + #define INSTALL_SCT_PLATFORM_NAME L"LOONGARCH64" #else #error "Architecture not supported" #endif diff --git a/uefi-sct/SctPkg/Library/SctLib/SctLib.inf b/uefi-sct/SctPkg/Library/SctLib/SctLib.inf index 7527b203..44cb6357 100644 --- a/uefi-sct/SctPkg/Library/SctLib/SctLib.inf +++ b/uefi-sct/SctPkg/Library/SctLib/SctLib.inf @@ -4,6 +4,7 @@ # Copyright (c) 2013 - 2014, ARM Ltd. All rights reserved.
# Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -68,6 +69,11 @@ Riscv64/initplat.c Math.c +[sources.LOONGARCH64] + LoongArch64/SctLibPlat.h + LoongArch64/initplat.c + Math.c + [sources.ia32] ia32/SctLibPlat.h ia32/initplat.c diff --git a/uefi-sct/SctPkg/SCRT/SCRTApp/SCRTApp.inf b/uefi-sct/SctPkg/SCRT/SCRTApp/SCRTApp.inf index 8104a4ef..fc46f3a1 100644 --- a/uefi-sct/SctPkg/SCRT/SCRTApp/SCRTApp.inf +++ b/uefi-sct/SctPkg/SCRT/SCRTApp/SCRTApp.inf @@ -3,6 +3,7 @@ # Copyright 2006 - 2016 Unified EFI, Inc.
# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -44,6 +45,10 @@ Riscv64/VirtualMemory.c Riscv64/GoVirtual.S | GCC +[sources.LOONGARCH64] + LoongArch64/VirtualMemory.c + LoongArch64/GoVirtual.S | GCC + [sources.ia32] ia32/VirtualMemory.c ia32/GoVirtual.asm | MSFT diff --git a/uefi-sct/SctPkg/SCRT/SCRTDriver/SCRTDriver.inf b/uefi-sct/SctPkg/SCRT/SCRTDriver/SCRTDriver.inf index a3ef454e..fe905508 100644 --- a/uefi-sct/SctPkg/SCRT/SCRTDriver/SCRTDriver.inf +++ b/uefi-sct/SctPkg/SCRT/SCRTDriver/SCRTDriver.inf @@ -3,6 +3,7 @@ # Copyright 2006 - 2016 Unified EFI, Inc.
# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -75,6 +76,11 @@ Riscv64/Dump.c Riscv64/Debug.c +[sources.LOONGARCH64] + LoongArch64/Io.c + LoongArch64/Dump.c + LoongArch64/Debug.c + [sources.common] Guid.h Guid.c diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/DebugSupportBBTest.inf b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/DebugSupportBBTest.inf index 03bf7ccf..9127ee5f 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/DebugSupportBBTest.inf +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DebugSupport/BlackBoxTest/DebugSupportBBTest.inf @@ -4,6 +4,7 @@ # Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.
# Copyright (c) 2019, ARM Ltd. All rights reserved.
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -73,6 +74,11 @@ Riscv64/DebugSupportBBTestExceptionCallbackFunction.c Riscv64/DebugSupportBBTestCacheFunction.c +[sources.LOONGARCH64] + LoongArch64/PlatformIsa.c + LoongArch64/DebugSupportBBTestExceptionCallbackFunction.c + LoongArch64/DebugSupportBBTestCacheFunction.c + [Packages] SctPkg/SctPkg.dec SctPkg/UEFI/UEFI.dec diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/Usb2Hc/BlackBoxTest/Usb2HcTest.inf b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/Usb2Hc/BlackBoxTest/Usb2HcTest.inf index 95ae593e..451c41c9 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/Usb2Hc/BlackBoxTest/Usb2HcTest.inf +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/Usb2Hc/BlackBoxTest/Usb2HcTest.inf @@ -3,6 +3,7 @@ # Copyright 2006 - 2016 Unified EFI, Inc.
# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -59,6 +60,9 @@ #[sources.Riscv64] # IPF/TimerInterrupt.c +#[sources.LOONGARCH64] +# IPF/TimerInterrupt.c + [Packages] MdePkg/MdePkg.dec SctPkg/SctPkg.dec diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/UsbHc/BlackBoxTest/UsbHcTest.inf b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/UsbHc/BlackBoxTest/UsbHcTest.inf index d3bcd5ce..8ec6ef3b 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/UsbHc/BlackBoxTest/UsbHcTest.inf +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/UsbHc/BlackBoxTest/UsbHcTest.inf @@ -3,6 +3,7 @@ # Copyright 2006 - 2012 Unified EFI, Inc.
# Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -59,6 +60,9 @@ [sources.RISCV64] Riscv64/TimerInterrupt.c +[sources.LOONGARCH64] + LoongArch64/TimerInterrupt.c + [Packages] MdePkg/MdePkg.dec SctPkg/SctPkg.dec diff --git a/uefi-sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/EntsLib.inf b/uefi-sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/EntsLib.inf index b60e90b2..9165bc1f 100644 --- a/uefi-sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/EntsLib.inf +++ b/uefi-sct/SctPkg/TestInfrastructure/SCT/Framework/ENTS/EasLib/EntsLib.inf @@ -4,6 +4,7 @@ # Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.
# Copyright (c) 2019, ARM Ltd. All rights reserved.
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -71,6 +72,10 @@ Riscv64/EntsLibPlat.h Riscv64/InitPlat.c +[sources.LOONGARCH64] + LoongArch64/EntsLibPlat.h + LoongArch64/InitPlat.c + [Packages] MdePkg/MdePkg.dec SctPkg/SctPkg.dec diff --git a/uefi-sct/SctPkg/Tools/Source/GenBin/GNUmakefile b/uefi-sct/SctPkg/Tools/Source/GenBin/GNUmakefile index c492d441..44089903 100644 --- a/uefi-sct/SctPkg/Tools/Source/GenBin/GNUmakefile +++ b/uefi-sct/SctPkg/Tools/Source/GenBin/GNUmakefile @@ -2,6 +2,7 @@ # Copyright 2006 - 2010 Unified EFI, Inc.
# Copyright (c) 2010 Intel Corporation. All rights reserved.
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -35,6 +36,9 @@ ifndef ARCH ifneq (,$(findstring riscv64,$(uname_m))) ARCH=RISCV64 endif + ifneq (,$(findstring loongarch64,$(uname_m))) + ARCH=LOONGARCH64 + endif ifndef ARCH $(info Could not detected ARCH from uname results) $(error ARCH is not defined!) diff --git a/uefi-sct/SctPkg/UEFI/IHV_SCT.dsc b/uefi-sct/SctPkg/UEFI/IHV_SCT.dsc index 7a4393e0..ce55c35f 100644 --- a/uefi-sct/SctPkg/UEFI/IHV_SCT.dsc +++ b/uefi-sct/SctPkg/UEFI/IHV_SCT.dsc @@ -4,6 +4,7 @@ # Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
# Copyright (c) 2019,Microchip Technology Inc.
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -43,7 +44,7 @@ PLATFORM_VERSION = 0.1 DSC_SPECIFICATION = 0x00010005 OUTPUT_DIRECTORY = Build/IhvSct - SUPPORTED_ARCHITECTURES = IA32|X64|ARM|AARCH64|RISCV64 + SUPPORTED_ARCHITECTURES = IA32|X64|ARM|AARCH64|RISCV64|LOONGARCH64 BUILD_TARGETS = DEBUG|RELEASE SKUID_IDENTIFIER = DEFAULT @@ -116,6 +117,12 @@ *_*_RISCV64_APP_FLAGS = -D EFIRISCV64 $(GCC_VER_MACRO) *_*_RISCV64_PP_FLAGS = -D EFIRISCV64 $(GCC_VER_MACRO) + *_*_LOONGARCH64_CC_FLAGS = -D EFILOONGARCH64 $(GCC_VER_MACRO) + GCC:*_*_LOONGARCH64_CC_FLAGS = -D EFILOONGARCH64 $(GCC_VER_MACRO) -ffreestanding -nostdinc -nostdlib -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error + *_*_LOONGARCH64_VFRPP_FLAGS = -D EFILOONGARCH64 $(GCC_VER_MACRO) + *_*_LOONGARCH64_APP_FLAGS = -D EFILOONGARCH64 $(GCC_VER_MACRO) + *_*_LOONGARCH64_PP_FLAGS = -D EFILOONGARCH64 $(GCC_VER_MACRO) + DEBUG_*_*_CC_FLAGS = -DEFI_DEBUG RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG @@ -134,6 +141,9 @@ [Libraries.RISCV64] ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf +[Libraries.LOONGARCH64] + ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf + [Libraries.IA32,Libraries.X64] !include MdePkg/MdeLibs.dsc.inc diff --git a/uefi-sct/SctPkg/UEFI/Protocol/DebugSupport.h b/uefi-sct/SctPkg/UEFI/Protocol/DebugSupport.h index 1963d619..1793f27d 100644 --- a/uefi-sct/SctPkg/UEFI/Protocol/DebugSupport.h +++ b/uefi-sct/SctPkg/UEFI/Protocol/DebugSupport.h @@ -662,6 +662,98 @@ typedef struct { UINT64 X31; } EFI_SYSTEM_CONTEXT_RISCV64; +// +// LoongArch processor exception types. +// +#define EXCEPT_LOONGARCH_INT 0 +#define EXCEPT_LOONGARCH_PIL 1 +#define EXCEPT_LOONGARCH_PIS 2 +#define EXCEPT_LOONGARCH_PIF 3 +#define EXCEPT_LOONGARCH_PME 4 +#define EXCEPT_LOONGARCH_PNR 5 +#define EXCEPT_LOONGARCH_PNX 6 +#define EXCEPT_LOONGARCH_PPI 7 +#define EXCEPT_LOONGARCH_ADE 8 +#define EXCEPT_LOONGARCH_ALE 9 +#define EXCEPT_LOONGARCH_BCE 10 +#define EXCEPT_LOONGARCH_SYS 11 +#define EXCEPT_LOONGARCH_BRK 12 +#define EXCEPT_LOONGARCH_INE 13 +#define EXCEPT_LOONGARCH_IPE 14 +#define EXCEPT_LOONGARCH_FPD 15 +#define EXCEPT_LOONGARCH_SXD 16 +#define EXCEPT_LOONGARCH_ASXD 17 +#define EXCEPT_LOONGARCH_FPE 18 +#define EXCEPT_LOONGARCH_TBR 64 // For code only, there is no such type in the ISA spec, the TLB refill is defined for an independent exception. + +// +// LoongArch processor Interrupt types. +// +#define EXCEPT_LOONGARCH_INT_SIP0 0 +#define EXCEPT_LOONGARCH_INT_SIP1 1 +#define EXCEPT_LOONGARCH_INT_IP0 2 +#define EXCEPT_LOONGARCH_INT_IP1 3 +#define EXCEPT_LOONGARCH_INT_IP2 4 +#define EXCEPT_LOONGARCH_INT_IP3 5 +#define EXCEPT_LOONGARCH_INT_IP4 6 +#define EXCEPT_LOONGARCH_INT_IP5 7 +#define EXCEPT_LOONGARCH_INT_IP6 8 +#define EXCEPT_LOONGARCH_INT_IP7 9 +#define EXCEPT_LOONGARCH_INT_PMC 10 +#define EXCEPT_LOONGARCH_INT_TIMER 11 +#define EXCEPT_LOONGARCH_INT_IPI 12 + +// +// For coding convenience, define the maximum valid +// LoongArch interrupt. +// +#define MAX_LOONGARCH_INTERRUPT 14 + +typedef struct { + UINT64 R0; + UINT64 R1; + UINT64 R2; + UINT64 R3; + UINT64 R4; + UINT64 R5; + UINT64 R6; + UINT64 R7; + UINT64 R8; + UINT64 R9; + UINT64 R10; + UINT64 R11; + UINT64 R12; + UINT64 R13; + UINT64 R14; + UINT64 R15; + UINT64 R16; + UINT64 R17; + UINT64 R18; + UINT64 R19; + UINT64 R20; + UINT64 R21; + UINT64 R22; + UINT64 R23; + UINT64 R24; + UINT64 R25; + UINT64 R26; + UINT64 R27; + UINT64 R28; + UINT64 R29; + UINT64 R30; + UINT64 R31; + + UINT64 CRMD; // CuRrent MoDe information + UINT64 PRMD; // PRe-exception MoDe information + UINT64 EUEN; // Extended component Unit ENable + UINT64 MISC; // MISCellaneous controller + UINT64 ECFG; // Exception ConFiGuration + UINT64 ESTAT; // Exception STATus + UINT64 ERA; // Exception Return Address + UINT64 BADV; // BAD Virtual address + UINT64 BADI; // BAD Instruction +} EFI_SYSTEM_CONTEXT_LOONGARCH64; + // // Universal EFI_SYSTEM_CONTEXT definition // @@ -674,6 +766,7 @@ union { EFI_SYSTEM_CONTEXT_ARM *SystemContextArm; EFI_SYSTEM_CONTEXT_AARCH64 *SystemContextAArch64; EFI_SYSTEM_CONTEXT_RISCV64 *SystemContextRiscV64; + EFI_SYSTEM_CONTEXT_LOONGARCH64 *SystemContextLoongArch64; } EFI_SYSTEM_CONTEXT; // @@ -702,6 +795,7 @@ VOID #define IMAGE_FILE_MACHINE_ARMTHUMB_MIXED 0x01c2 #define IMAGE_FILE_MACHINE_ARM64 0xAA64 #define IMAGE_FILE_MACHINE_RISCV64 0x5064 +#define IMAGE_FILE_MACHINE_LOONGARCH64 0x6264 typedef @@ -710,9 +804,10 @@ enum { IsaX64 = IMAGE_FILE_MACHINE_X64, IsaIpf = IMAGE_FILE_MACHINE_IA64, IsaEbc = IMAGE_FILE_MACHINE_EBC, - IsaArm = IMAGE_FILE_MACHINE_ARMTHUMB_MIXED, ///< 0x01c2 - IsaAArch64 = IMAGE_FILE_MACHINE_ARM64, ///< 0xAA64 - IsaRiscv64 = IMAGE_FILE_MACHINE_RISCV64 ///< 0x5064 + IsaArm = IMAGE_FILE_MACHINE_ARMTHUMB_MIXED, ///< 0x01c2 + IsaAArch64 = IMAGE_FILE_MACHINE_ARM64, ///< 0xAA64 + IsaRiscv64 = IMAGE_FILE_MACHINE_RISCV64, ///< 0x5064 + IsaLoongArch64 = IMAGE_FILE_MACHINE_LOONGARCH64 ///< 0x6264 } EFI_INSTRUCTION_SET_ARCHITECTURE; typedef struct _EFI_DEBUG_SUPPORT_PROTOCOL EFI_DEBUG_SUPPORT_PROTOCOL;; diff --git a/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc b/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc index 88d7a317..58f35ce4 100644 --- a/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc +++ b/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc @@ -3,6 +3,7 @@ # Copyright 2006 - 2017 Unified EFI, Inc.
# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
# (C) Copyright 2017 - 2021 Hewlett Packard Enterprise Development LP
+# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -42,7 +43,7 @@ PLATFORM_VERSION = 0.1 DSC_SPECIFICATION = 0x00010005 OUTPUT_DIRECTORY = Build/UefiSct - SUPPORTED_ARCHITECTURES = IA32|X64|ARM|AARCH64|RISCV64 + SUPPORTED_ARCHITECTURES = IA32|X64|ARM|AARCH64|RISCV64|LOONGARCH64 BUILD_TARGETS = DEBUG|RELEASE SKUID_IDENTIFIER = DEFAULT @@ -118,6 +119,12 @@ *_*_RISCV64_APP_FLAGS = -D EFIRISCV64 $(GCC_VER_MACRO) *_*_RISCV64_PP_FLAGS = -D EFIRISCV64 $(GCC_VER_MACRO) + *_*_LOONGARCH64_CC_FLAGS = -D EFILOONGARCH64 $(GCC_VER_MACRO) + GCC:*_*_LOONGARCH64_CC_FLAGS = -D EFILOONGARCH64 $(GCC_VER_MACRO) -ffreestanding -nostdinc -nostdlib -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error + *_*_LOONGARCH64_VFRPP_FLAGS = -D EFILOONGARCH64 $(GCC_VER_MACRO) + *_*_LOONGARCH64_APP_FLAGS = -D EFILOONGARCH64 $(GCC_VER_MACRO) + *_*_LOONGARCH64_PP_FLAGS = -D EFILOONGARCH64 $(GCC_VER_MACRO) + DEBUG_*_*_CC_FLAGS = -DEFI_DEBUG RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG @@ -138,6 +145,9 @@ [Libraries.RISCV64] ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf +[Libraries.LOONGARCH64] + ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf + !include MdePkg/MdeLibs.dsc.inc [LibraryClasses.common] @@ -171,6 +181,9 @@ [LibraryClasses.RISCV64] NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf +[LibraryClasses.LOONGARCH64] + NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf + ############################################################################### # # These are the components that will be built by the master makefile diff --git a/uefi-sct/SctPkg/build.sh b/uefi-sct/SctPkg/build.sh index 79cb69c0..901bdc06 100755 --- a/uefi-sct/SctPkg/build.sh +++ b/uefi-sct/SctPkg/build.sh @@ -25,6 +25,8 @@ function get_build_arch BUILD_ARCH=AARCH64;; riscv64*) BUILD_ARCH=RISCV64;; + loongarch64*) + BUILD_ARCH=LOONGARCH64;; *) BUILD_ARCH=other;; esac @@ -56,6 +58,12 @@ function set_cross_compile else TEMP_CROSS_COMPILE=riscv64-unknown-elf- fi + elif [ "$SCT_TARGET_ARCH" == "LOONGARCH64" ]; then + if [ X"$CROSS_COMPILE_64" != X"" ]; then + TEMP_CROSS_COMPILE="$CROSS_COMPILE_64" + else + TEMP_CROSS_COMPILE=loongarch64-unknown-linux-gnu- + fi else echo "Unsupported target architecture '$SCT_TARGET_ARCH'!" >&2 fi @@ -119,7 +127,7 @@ PrintUsage() { #Print Help # echo "Usage:" - echo " $0 \ + echo " $0 \ \ [build type (RELEASE OR DEBUG, DEFAULT: DEBUG)]" } -- 2.27.0