8000 boot-qemu.py: Add support for LoongArch · ClangBuiltLinux/boot-utils@5ad9899 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5ad9899

Browse files
committed
boot-qemu.py: Add support for LoongArch
LoongArch requires EFI firmware to boot, which is available as a precompiled blob from Loongson's GitHub, so it is downloaded when running 'boot-qemu.py -a loongarch' for the first time. There is no update mechanism like for the rootfs images for a simple implementation. If there comes a time where the firmware has to be updated for the machine to boot properly, such a mechanism can be implemented then. Other than that, the rest of the support is pretty straightforward. The defaults for cores and memory are a little higher than other machines, as that is what other folks are testing. Closes: #108 Signed-off-by: Nathan Chancellor <nathan@kernel.org>
1 parent a500d1b commit 5ad9899

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

boot-qemu.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
'arm32_v7',
2222
'arm64',
2323
'arm64be',
24+
'loongarch',
2425
'm68k',
2526
'mips',
2627
'mipsel',
@@ -476,6 +477,35 @@ def __init__(self):
476477
self._initrd_arch = 'arm64be'
477478

478479

480+
class LoongArchQEMURunner(QEMURunner):
481+
482+
def __init__(self):
483+
super().__init__()
484+
485+
self.cmdline.append('console=ttyS0,115200')
486+
self._default_kernel_path = Path('arch/loongarch/boot/vmlinuz.efi')
487+
self._initrd_arch = 'loongarch'
488+
489+
bios = Path(utils.BOOT_UTILS, 'images', self._initrd_arch,
490+
'edk2-loongarch64-code.fd')
491+
if not bios.exists():
492+
firmware_url = f"https://github.com/loongson/Firmware/raw/main/LoongArchVirtMachine/{bios.name}"
493+
utils.green(
494+
f"Downloading LoongArch firmware from {firmware_url}...")
495+
curl_cmd = ['curl', '-LSs', '-o', bios, firmware_url]
496+
subprocess.run(curl_cmd, check=True)
497+
498+
self._qemu_arch = 'loongarch64'
499+
self._qemu_args += [
500+
'-M', 'virt',
501+
'-cpu', 'la464',
502+
'-bios', bios,
503+
'-no-reboot',
504+
] # yapf: disable
505+
self._ram = '2G'
506+
self.smp = 2
507+
508+
479509
class M68KQEMURunner(QEMURunner):
480510

481511
def __init__(self):
@@ -699,6 +729,7 @@ def guess_arch(kernel_arg):
699729
'ELF 64-bit MSB executable, ARM aarch64': 'arm64be',
700730
'ELF 64-bit LSB pie executable, ARM aarch64': 'arm64',
701731
'ELF 64-bit MSB pie executable, ARM aarch64': 'arm64be',
732+
'ELF 64-bit LSB executable, LoongArch': 'loongarch',
702733
'ELF 32-bit MSB executable, Motorola m68k, 68020': 'm68k',
703734
'ELF 32-bit MSB executable, MIPS, MIPS32': 'mips',
704735
'ELF 32-bit LSB executable, MIPS, MIPS32': 'mipsel',
@@ -802,6 +833,7 @@ def parse_arguments():
802833
'arm32_v7': ARMV7QEMURunner,
803834
'arm64': ARM64QEMURunner,
804835
'arm64be': ARM64BEQEMURunner,
836+
'loongarch': LoongArchQEMURunner,
805837
'm68k': M68KQEMURunner,
806838
'mips': MIPSQEMURunner,
807839
'mipsel': MIPSELQEMURunner,

0 commit comments

Comments
 (0)
0