···11/* Tell the linker that we want an x86_64 ELF64 output file */
22OUTPUT_FORMAT(elf64-x86-64)
3344-ENTRY(entry_point_bsp)
44+ENTRY(entry_point_from_limine)
5566/* Define the program headers we want so the bootloader gives us the right */
77/* MMU permissions; this also allows us to exert more control over the linking */
···77 let runner_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
88 // This folder contains Limine files such as `BOOTX64.EFI`
99 let limine_dir = PathBuf::from(env::var("LIMINE_PATH").unwrap());
1010+ // Cargo passes us the path to the kernel executable because it is an artifact dep
1111+ let kernel_executable_file = env::var("CARGO_BIN_FILE_KERNEL").unwrap();
10121113 // Symlink the out dir so we get a constant path to it
1214 ensure_symlink(&out_dir, runner_dir.join("out_dir")).unwrap();
···1618 // We will use symlinks instead of copying to avoid unnecessary disk space used
1719 let iso_dir = out_dir.join("iso_root");
1820 create_dir_all(&iso_dir).unwrap();
2121+2222+ // symlink the kernel binary to `kernel`
2323+ let kernel_dest = iso_dir.join("kernel");
2424+ ensure_symlink(&kernel_executable_file, &kernel_dest).unwrap();
19252026 // Limine config will be in `limine.conf`
2127 let limine_conf = iso_dir.join("limine.conf");
+4
runner/limine.conf
···11+# The entry name that will be displayed in the boot menu.
22+/DasOS
33+ protocol: limine
44+ kernel_path: boot():/kernel
+21-1
runner/src/main.rs
···11-use std::env;
11+use std::{env, process::{self, Command}};
2233fn main() {
44 let iso = env::var("ISO").unwrap();
55 println!("ISO path: {iso:?}");
66+77+ let ovmf = env::var("OVMF_PATH").unwrap();
88+99+ // Qemu runs our OS in a virtual container
1010+ let mut qemu = Command::new("qemu-system-x86_64");
1111+1212+ // Specify the path to the ISO
1313+ qemu.arg("-cdrom");
1414+ qemu.arg(env!("ISO"));
1515+ // For UEFI on qemu, the path to OVMF.fd is needed
1616+ qemu.arg("-bios").arg(ovmf);
1717+1818+ // Pass any args to qemu
1919+ env::args().skip(1).for_each(|arg| {
2020+ qemu.arg(arg);
2121+ });
2222+2323+ let exit_status = qemu.status().unwrap();
2424+2525+ process::exit(exit_status.code().unwrap_or(-1));
626}