Skip to content

Commit 7312cb6

Browse files
committed
managarm-kernel-uefi: enable for RISC-V
1 parent 2d7bbb6 commit 7312cb6

File tree

4 files changed

+73
-28
lines changed

4 files changed

+73
-28
lines changed

bootstrap.d/tasks.y4.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ tasks:
6161
- limine
6262
- managarm-kernel
6363
- !managarm::arch_dep
64-
arch: [x86_64]
64+
arch: [x86_64, riscv64]
6565
item: managarm-kernel-uefi
6666
- managarm-system
6767
tools_required:
@@ -84,7 +84,7 @@ tasks:
8484
- limine
8585
- managarm-kernel
8686
- !managarm::arch_dep
87-
arch: [x86_64]
87+
arch: [x86_64, riscv64]
8888
item: managarm-kernel-uefi
8989
- managarm-system
9090
tools_required:
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[binaries]
2+
c = 'clang'
3+
cpp = 'clang++'
4+
c_ld = 'lld'
5+
cpp_ld = 'lld'
6+
pkgconfig = 'riscv64-managarm-pkg-config'
7+
strip = 'true'
8+
9+
[built-in options]
10+
c_args = [
11+
'-target', 'riscv64-linux-gnu',
12+
'-march=rva22u64',
13+
'-mcmodel=medany',
14+
'-msmall-data-limit=0',
15+
'-mno-relax',
16+
'-fno-stack-protector',
17+
'-fno-asynchronous-unwind-tables',
18+
'-fno-unwind-tables',
19+
'-fpack-struct=8',
20+
'-flto']
21+
cpp_args = c_args
22+
cpp_link_args = [
23+
'-target', 'riscv64-linux-gnu',
24+
'-march=rva22u64',
25+
'-mcmodel=medany',
26+
'-msmall-data-limit=0',
27+
'-mno-relax',
28+
'-Wl,-melf64lriscv,--oformat=elf64-littleriscv,--no-relax',
29+
'-fno-strict-aliasing',
30+
'-fno-asynchronous-unwind-tables',
31+
'-fno-unwind-tables',
32+
'-fpack-struct=8',
33+
'-flto',
34+
'-Wl,-q,--gc-sections,-static,-pie,--no-dynamic-linker,-z,text']
35+
36+
[host_machine]
37+
system = 'linux'
38+
cpu_family = 'riscv64'
39+
cpu = 'riscv64'
40+
endian = 'little'
41+
42+
[properties]
43+
native_pe_toolchain = false
44+
pecoff_header_size = 0x240

scripts/update-image.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ def generate_plan(arch, root_uuid, scriptdir):
439439
), "boot/", "@ROOT_UUID@", root_uuid
440440
elif arch == "riscv64-managarm":
441441
yield FsAction.INSTALL, "usr/managarm/bin/eir-limine", "boot/managarm"
442+
yield FsAction.INSTALL, "usr/managarm/bin/eir-uefi", "boot/managarm"
442443
yield (
443444
FsAction.CP,
444445
"system-root/usr/share/limine/BOOTRISCV64.EFI",

scripts/vm-util.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,9 @@ def do_qemu(args):
180180
elif args.arch == "riscv64":
181181
# Use the virt machine and -kernel, similar to aarch64.
182182
qemu_args += ["-machine", "virt"]
183-
qemu_args += ["-kernel", "system-root/usr/managarm/bin/eir-virt"]
184183
qemu_args += ["-serial", "stdio"]
184+
if not args.uefi:
185+
qemu_args += ["-kernel", "system-root/usr/managarm/bin/eir-virt"]
185186
else:
186187
assert args.arch == "x86_64"
187188
qemu_args += ["-debugcon", "stdio"]
@@ -279,31 +280,30 @@ def do_qemu(args):
279280
]
280281

281282
# Add the boot medium.
282-
if args.arch != "riscv64":
283-
qemu_args += ["-drive", "id=boot-drive,file=image,format=raw,if=none"]
284-
285-
if args.boot_drive == "virtio":
286-
qemu_args += ["-device", "virtio-blk-pci,drive=boot-drive"]
287-
elif args.boot_drive == "virtio-legacy":
288-
qemu_args += [
289-
"-device",
290-
"virtio-blk-pci,disable-modern=on,drive=boot-drive",
291-
]
292-
elif args.boot_drive == "ahci":
293-
qemu_args += [
294-
"-device",
295-
"ahci,id=ahci",
296-
"-device",
297-
"ide-hd,drive=boot-drive,bus=ahci.0",
298-
]
299-
elif args.boot_drive == "usb":
300-
# Use EHCI for now since XHCI hangs on boot.
301-
qemu_args += ["-device", "usb-storage,drive=boot-drive,bus=ehci.0"]
302-
elif args.boot_drive == "nvme":
303-
qemu_args += ["-device", "nvme,serial=deadbeef,drive=boot-drive"]
304-
else:
305-
assert args.boot_drive == "ide"
306-
qemu_args += ["-device", "ide-hd,drive=boot-drive,bus=ide.0"]
283+
qemu_args += ["-drive", "id=boot-drive,file=image,format=raw,if=none"]
284+
285+
if args.boot_drive == "virtio":
286+
qemu_args += ["-device", "virtio-blk-pci,drive=boot-drive"]
287+
elif args.boot_drive == "virtio-legacy":
288+
qemu_args += [
289+
"-device",
290+
"virtio-blk-pci,disable-modern=on,drive=boot-drive",
291+
]
292+
elif args.boot_drive == "ahci":
293+
qemu_args += [
294+
"-device",
295+
"ahci,id=ahci",
296+
"-device",
297+
"ide-hd,drive=boot-drive,bus=ahci.0",
298+
]
299+
elif args.boot_drive == "usb":
300+
# Use EHCI for now since XHCI hangs on boot.
301+
qemu_args += ["-device", "usb-storage,drive=boot-drive,bus=ehci.0"]
302+
elif args.boot_drive == "nvme":
303+
qemu_args += ["-device", "nvme,serial=deadbeef,drive=boot-drive"]
304+
else:
305+
assert args.boot_drive == "ide"
306+
qemu_args += ["-device", "ide-hd,drive=boot-drive,bus=ide.0"]
307307

308308
# Add networking.
309309
if args.net_bridge:

0 commit comments

Comments
 (0)