]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: Add RISCV32 and LoongArch support
authorJan Janssen <medhefgo@web.de>
Tue, 28 Feb 2023 17:05:18 +0000 (18:05 +0100)
committerJan Janssen <medhefgo@web.de>
Fri, 10 Mar 2023 10:41:08 +0000 (11:41 +0100)
This is completely untested, but should work in theory, as it's just
adding a couple defines according to the specs.

meson.build
src/boot/efi/pe.c
tools/elf2efi.py

index cde0c88e48a734b02feeabe78659bdc2af18b1ce..b1521e5937b9be9a27e0f1c70595806074c4f93e 100644 (file)
@@ -1960,11 +1960,14 @@ python_39 = python.language_version().version_compare('>=3.9')
 #####################################################################
 
 efi_arch = {
-        'aarch64' : 'aa64',
-        'arm'     : 'arm',
-        'riscv64' : 'riscv64',
-        'x86_64'  : 'x64',
-        'x86'     : 'ia32',
+        'aarch64'     : 'aa64',
+        'arm'         : 'arm',
+        'loongarch32' : 'loongarch32',
+        'loongarch64' : 'loongarch64',
+        'riscv32'     : 'riscv32',
+        'riscv64'     : 'riscv64',
+        'x86_64'      : 'x64',
+        'x86'         : 'ia32',
 }.get(host_machine.cpu_family(), '')
 
 if get_option('bootloader') != 'false' and efi_arch != ''
index 5128eeecb5674597d96dd2de1b63004c0aefbe6f..9b1b10d4a12cf74af9cb17b010a653242c0d6aac 100644 (file)
 #  define TARGET_MACHINE_TYPE 0xAA64U
 #elif defined(__arm__)
 #  define TARGET_MACHINE_TYPE 0x01C2U
+#elif defined(__riscv) && __riscv_xlen == 32
+#  define TARGET_MACHINE_TYPE 0x5032U
 #elif defined(__riscv) && __riscv_xlen == 64
 #  define TARGET_MACHINE_TYPE 0x5064U
+#elif defined(__loongarch__) && __loongarch_grlen == 32
+#  define TARGET_MACHINE_TYPE 0x6232U
+#elif defined(__loongarch__) && __loongarch_grlen == 64
+#  define TARGET_MACHINE_TYPE 0x6264U
 #else
 #  error Unknown EFI arch
 #endif
index b26af1f38d9e26980e94f34b4f0d79421d20eee3..2ca9d248e7da975802c1454ed5a4a28cad10193a 100755 (executable)
@@ -336,6 +336,7 @@ def convert_elf_reloc_table(
         "EM_386": ENUM_RELOC_TYPE_i386["R_386_NONE"],
         "EM_AARCH64": ENUM_RELOC_TYPE_AARCH64["R_AARCH64_NONE"],
         "EM_ARM": ENUM_RELOC_TYPE_ARM["R_ARM_NONE"],
+        "EM_LOONGARCH": 0,
         "EM_RISCV": 0,
         "EM_X86_64": ENUM_RELOC_TYPE_x64["R_X86_64_NONE"],
     }[elf["e_machine"]]
@@ -344,6 +345,7 @@ def convert_elf_reloc_table(
         "EM_386": ENUM_RELOC_TYPE_i386["R_386_RELATIVE"],
         "EM_AARCH64": ENUM_RELOC_TYPE_AARCH64["R_AARCH64_RELATIVE"],
         "EM_ARM": ENUM_RELOC_TYPE_ARM["R_ARM_RELATIVE"],
+        "EM_LOONGARCH": 3,
         "EM_RISCV": 3,
         "EM_X86_64": ENUM_RELOC_TYPE_x64["R_X86_64_RELATIVE"],
     }[elf["e_machine"]]
@@ -465,7 +467,8 @@ def elf2efi(args: argparse.Namespace):
         "EM_386": 0x014C,
         "EM_AARCH64": 0xAA64,
         "EM_ARM": 0x01C2,
-        "EM_RISCV": 0x5064,
+        "EM_LOONGARCH": 0x6232 if elf.elfclass == 32 else 0x6264,
+        "EM_RISCV": 0x5032 if elf.elfclass == 32 else 0x5064,
         "EM_X86_64": 0x8664,
     }.get(elf["e_machine"])
     if pe_arch is None: