lumine
UEFI x86_64 bootloader for linux kernel images
diff
+53 -21
README.md modified +46 -15
diff --git a/README.md b/README.md index ff0fa827e83f09436ff27f746e5dfcc3875b079a..8a409c3b1cdece10b751f00e91249243a057ed4a 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,23 @@ # lumine cheapskate x86_64/aarch64 UEFI bootloader -## config +## features > [!WARNING] -> - this rewrite is **EXTREMELY** incomplete, see `master` branch for a somewhat working c implementation. +> - lumine is yet somewhat incomplete, for a bootloader with a similar concept, see [limine](https://github.com/Limine-Bootloader/limine/) +> - aarch64 support is secondary, and as of writing this aarch64 for linux is broken. > - docs are written primarily for `x86_64`, just replace `BOOTX64` with `BOOTAA64` and the rest should be equivalent. +> - linux kernels should be built with efi stub, as linux boot protocol is not yet implemented. this should be enabled by default on most distributions. -config for lumine is currently written in zig object notation, see [default config](./config.zon) for reference. +- boot linux kernels +- chainload efi executables + +## config + +config for lumine is currently written in zig object notation, see [default config](./res/lumine.zon) for reference. see [installation](#installation) for instructions on where to put config file. + +TODO: config documentation ## compiling @@ -22,13 +31,19 @@ zig build -Doptimize=ReleaseSafe -Darch=x86_64 # efi executable is now in `zig-out/build/BOOTX64.efi` ``` -## emulation - -dependencies like edk2 ovmf firmware are already downloaded as a zig dependency (hmmmm, even if you dont want emulation?) +available build/run options: ```sh -# starts in serial console -zig build -Darch=x86_64 run +-Darch=[enum] cpu architecture + Supported Values: + x86_64 + aarch64 +-Dqemu=[string] override qemu executable +-Dno-serial=[bool] dont add stdio serial commands +-Dovmf=[lazy_path] override ovmf firmware dependency +-Dovmf-dep=[bool] use ovmf dependency instead +-Dlinux=[string] dir containing `vmlinuz` and `initrd` +-Dconfig=[string] path to config file ``` ## installation @@ -38,19 +53,35 @@ that you can literally do it manually and it works fine, or maybe automate finding of installations like grub's os-prober or whatever. therefore, lumine is only two files: + - efi executable: can be placed anywhere, partition default `/EFI/BOOT/BOOTX64.EFI` or really any location like `/lumine/lumine.efi` etc etc, you have the freedom. -- config file: for now, config MUST be placed in `/lumine.zon`. this WILL change soon however, because i dont like it. +- config file: must be placed in any of these paths in the same partition as lumine's EFI, checked in the same + order. i do plan to add support for path relative to lumine's efi. + - `/lumine/config.zon` + - `/lumine/lumine.zon` + - `/lumine.zon` + +## emulation -assuming your efi directory is `/boot`: +edk2 ovmf firmware will be downloaded as a zig dependency lazily when needed. otherwise, to specify a custom ovmf firmware +binary, use `-Dovmf=` flag with path to binary, which is used in qemu. to get them from dependency, use `-Dovmf-dep` flag. +qemu binary used can be overridden by `-Dqemu=` flag. + +for testing purposes, you can use the somewhat purpose-built [minimux](https://codeberg.org/dragsbruh/minimux) which supports +both x86_64 and aarch64 architectures, or [tinycorelinux](http://tinycorelinux.net/) which only supports x86_64 (that i tested). +both "distributions" are designed to have initramfs as root filesystem, and are what i tested extensively. + +put the initramfs and vmlinuz kernel image in the `res/<ARCH>/` directory, and the build system will automatically use it. +to specify a custom directory, use `-Dlinux=` flag. `vmlinuz` and `initrd` files from this directory are copied `/linux/` directory +in the qemu virtual machine. + +config file copied to `/lumine.zon` is `res/lumine.zon`, this can be overriden by `-Dconfig=` flag. ```sh -cp zig-out/build/BOOTX64.efi /boot/lumine/BOOTX64.EFI -cp config.zon /boot/lumine.zon +# starts in serial console +zig build -Darch=x86_64 -Dovmf-dep run ``` - -now just make a efi boot entry and set BootNext flag to try it out. i wont give you the steps because, well its incomplete -as shit and might not work if you smile a little gay, if you really wanna, you might already know how to do it anyway. ## license
build.zig modified +3 -3
diff --git a/build.zig b/build.zig index 5068f3d8d4cab96c2f833906101a8afa4d16f0b0..bf43280d96546f26553649860471c4dea86a4145 100644 --- a/build.zig +++ b/build.zig @@ -58,7 +58,7 @@ const arch_install = b.addInstallArtifact(arch_exe, .{}); all_step.dependOn(&arch_install.step); } - const qemu_exe = b.option([]const u8, "qemu", "ovveride qemu executable") orelse b.fmt("qemu-system-{t}", .{cpu_arch}); + const qemu_exe = b.option([]const u8, "qemu", "overide qemu executable") orelse b.fmt("qemu-system-{t}", .{cpu_arch}); const qemu_cmd = b.addSystemCommand(&.{ qemu_exe, "-m", "512M", "-no-reboot", "-no-shutdown" }); const no_serial = b.option(bool, "no-serial", "dont add stdio serial commands") orelse false; @@ -92,7 +92,7 @@ { // https://codeberg.org/ziglang/zig/issues/32041 // https://codeberg.org/dragsbruh/minimux/releases - const linux_dir = b.option([]const u8, "linux", "dir containing `vmlinuz` and `initrd.xz`") orelse b.fmt("res/{t}", .{cpu_arch}); + const linux_dir = b.option([]const u8, "linux", "dir containing `vmlinuz` and `initrd`") orelse b.fmt("res/{t}", .{cpu_arch}); const config_file = b.option([]const u8, "config", "path to config file") orelse "res/lumine.zon"; const boot_dir = b.addTempFiles(); @@ -101,7 +101,7 @@ _ = boot_dir.addCopyFile(b.path(config_file), "lumine.zon"); _ = boot_dir.addCopyFile(lumine_exe.getEmittedBin(), b.fmt("EFI/BOOT/BOOT{t}.EFI", .{cpu_arch.efi()})); _ = boot_dir.addCopyFile(b.path(linux_dir).path(b, "vmlinuz"), "linux/vmlinuz"); - _ = boot_dir.addCopyFile(b.path(linux_dir).path(b, "initrd.xz"), "linux/initrd.xz"); + _ = boot_dir.addCopyFile(b.path(linux_dir).path(b, "initrd"), "linux/initrd"); qemu_cmd.addArg("-drive"); qemu_cmd.addPrefixedDirectoryArg("format=raw,file=fat:rw:", boot_dir.getDirectory());
res/lumine.zon modified +1 -1
diff --git a/res/lumine.zon b/res/lumine.zon index de2f5c509c6087bd1793d3e567740eb296e80043..cc3d07363bc1746edddff47b57bc9a9f1f260d59 100644 --- a/res/lumine.zon +++ b/res/lumine.zon @@ -2,7 +2,7 @@ .{ .boot = .{ .linux = .{ .kernel_path = .{ .boot = "/linux/vmlinuz" }, - .initrd_path = .{ .boot = "/linux/initrd.xz" }, + .initrd_path = .{ .boot = "/linux/initrd" }, .kernel_cmdline = "console=ttyS0", }, },
src/main.zig modified +3 -2
diff --git a/src/main.zig b/src/main.zig index 5bc90544328023184f6fb9d4209e5c5ac736bfe8..638f39ad577a17641526348cff460cdf0dc5ee15 100644 --- a/src/main.zig +++ b/src/main.zig @@ -9,10 +9,11 @@ const Config = @import("./Config.zig"); const Console = @import("./Console.zig"); const luefi = @import("./luefi.zig"); +// TODO: relative to EFI const config_paths: []const Config.Path = &.{ + .{ .boot = "/lumine/config.zon" }, + .{ .boot = "/lumine/lumine.zon" }, .{ .boot = "/lumine.zon" }, - .{ .boot = "/lumine/lumine.zon" }, - .{ .boot = "/lumine/config.zon" }, }; pub fn bmain() !uefi.Status {