git: 95f4e7f5e283 - main - LoongArch: sys/contrib/edk2: add support
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 22 Apr 2025 18:20:33 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=95f4e7f5e2833bf9e48ad8134258abb9a349157c
commit 95f4e7f5e2833bf9e48ad8134258abb9a349157c
Author: yu shan wei <mpysw@vip.163.com>
AuthorDate: 2025-03-30 23:55:47 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-04-22 18:19:39 +0000
LoongArch: sys/contrib/edk2: add support
copy from upstream:
https://github.com/tianocore/edk2/tree/edk2-stable202408
commit: https://github.com/tianocore/edk2/commit/cd24eb578bb77e6a55d37c2e9afef4a6814a82ac
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1624
---
sys/contrib/edk2/Include/Library/BaseLib.h | 23 +++++++++++++++++++++++
sys/contrib/edk2/Include/Uefi/UefiBaseType.h | 14 ++++++++++++++
sys/contrib/edk2/Include/Uefi/UefiSpec.h | 5 ++++-
3 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/sys/contrib/edk2/Include/Library/BaseLib.h b/sys/contrib/edk2/Include/Library/BaseLib.h
index 762cb9ac3abb..ac347f0adc2d 100644
--- a/sys/contrib/edk2/Include/Library/BaseLib.h
+++ b/sys/contrib/edk2/Include/Library/BaseLib.h
@@ -152,6 +152,29 @@ typedef struct {
#endif // defined (MDE_CPU_RISCV64)
+#if defined (MDE_CPU_LOONGARCH64)
+///
+/// The LoongArch architecture context buffer used by SetJump() and LongJump()
+///
+typedef struct {
+ UINT64 S0;
+ UINT64 S1;
+ UINT64 S2;
+ UINT64 S3;
+ UINT64 S4;
+ UINT64 S5;
+ UINT64 S6;
+ UINT64 S7;
+ UINT64 S8;
+ UINT64 SP;
+ UINT64 FP;
+ UINT64 RA;
+} BASE_LIBRARY_JUMP_BUFFER;
+
+#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
+
+#endif // defined (MDE_CPU_LOONGARCH64)
+
//
// String Services
//
diff --git a/sys/contrib/edk2/Include/Uefi/UefiBaseType.h b/sys/contrib/edk2/Include/Uefi/UefiBaseType.h
index 6a2f33039377..6637a28ea6d9 100644
--- a/sys/contrib/edk2/Include/Uefi/UefiBaseType.h
+++ b/sys/contrib/edk2/Include/Uefi/UefiBaseType.h
@@ -248,6 +248,13 @@ typedef union {
#define EFI_IMAGE_MACHINE_RISCV64 0x5064
#define EFI_IMAGE_MACHINE_RISCV128 0x5128
+///
+/// PE32+ Machine type for LoongArch 32/64 images.
+///
+#define EFI_IMAGE_MACHINE_LOONGARCH32 0x6232
+#define EFI_IMAGE_MACHINE_LOONGARCH64 0x6264
+
+
#if defined (MDE_CPU_IA32)
#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \
@@ -281,6 +288,13 @@ typedef union {
#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE)
+ #elif defined (MDE_CPU_LOONGARCH64)
+
+#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \
+ ((Machine) == EFI_IMAGE_MACHINE_LOONGARCH64)
+
+#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE)
+
#elif defined (MDE_CPU_EBC)
///
diff --git a/sys/contrib/edk2/Include/Uefi/UefiSpec.h b/sys/contrib/edk2/Include/Uefi/UefiSpec.h
index 0e165478d6c3..051834460512 100644
--- a/sys/contrib/edk2/Include/Uefi/UefiSpec.h
+++ b/sys/contrib/edk2/Include/Uefi/UefiSpec.h
@@ -2203,6 +2203,7 @@ typedef struct {
#define EFI_REMOVABLE_MEDIA_FILE_NAME_ARM L"\\EFI\\BOOT\\BOOTARM.EFI"
#define EFI_REMOVABLE_MEDIA_FILE_NAME_AARCH64 L"\\EFI\\BOOT\\BOOTAA64.EFI"
#define EFI_REMOVABLE_MEDIA_FILE_NAME_RISCV64 L"\\EFI\\BOOT\\BOOTRISCV64.EFI"
+#define EFI_REMOVABLE_MEDIA_FILE_NAME_LOONGARCH64 L"\\EFI\\BOOT\\BOOTLOONGARCH64.EFI"
#if defined (MDE_CPU_IA32)
#define EFI_REMOVABLE_MEDIA_FILE_NAME EFI_REMOVABLE_MEDIA_FILE_NAME_IA32
@@ -2215,7 +2216,9 @@ typedef struct {
#define EFI_REMOVABLE_MEDIA_FILE_NAME EFI_REMOVABLE_MEDIA_FILE_NAME_AARCH64
#elif defined (MDE_CPU_RISCV64)
#define EFI_REMOVABLE_MEDIA_FILE_NAME EFI_REMOVABLE_MEDIA_FILE_NAME_RISCV64
-#else
+ #elif defined (MDE_CPU_LOONGARCH64)
+#define EFI_REMOVABLE_MEDIA_FILE_NAME EFI_REMOVABLE_MEDIA_FILE_NAME_LOONGARCH64
+ #else
#error Unknown Processor Type
#endif