Add a qemu-uefi executable to start the UEFI disk image in QEMU

This commit is contained in:
Philipp Oppermann
2023-05-01 14:34:05 +02:00
parent ba8b0392b8
commit 2a49491fc7
3 changed files with 21 additions and 0 deletions

7
Cargo.lock generated
View File

@@ -132,6 +132,7 @@ version = "0.1.0"
dependencies = [
"bootloader",
"kernel",
"ovmf-prebuilt",
]
[[package]]
@@ -495,6 +496,12 @@ version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
name = "ovmf-prebuilt"
version = "0.1.0-alpha.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa50141d081512ab30fd9e7e7692476866df5098b028536ad6680212e717fa8d"
[[package]]
name = "parking"
version = "2.1.0"

View File

@@ -8,6 +8,7 @@ default-run = "blog_os"
members = ["kernel"]
[dependencies]
ovmf-prebuilt = "0.1.0-alpha"
[build-dependencies]
kernel = { path = "kernel", artifact = "bin", target = "x86_64-unknown-none" }

13
src/bin/qemu-uefi.rs Normal file
View File

@@ -0,0 +1,13 @@
use std::{
env,
process::{self, Command},
};
fn main() {
let mut qemu = Command::new("qemu-system-x86_64");
qemu.arg("-drive");
qemu.arg(format!("format=raw,file={}", env!("UEFI_IMAGE")));
qemu.arg("-bios").arg(ovmf_prebuilt::ovmf_pure_efi());
let exit_status = qemu.status().unwrap();
process::exit(exit_status.code().unwrap_or(-1));
}