-
Notifications
You must be signed in to change notification settings - Fork 6
fix: boot on qemu x86_64 #677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7212b3d
bc02e1d
bb47a10
8841839
d69ffdc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| [book] | ||
| authors = ["Yuuki Takano"] | ||
| language = "en" | ||
| multilingual = false | ||
| src = "src" | ||
| title = "Awkernel" | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,8 +5,13 @@ edition = "2021" | |
|
|
||
| # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
|
||
| [features] | ||
| default = ["bios", "uefi"] | ||
| bios = ["bootloader/bios"] | ||
| uefi = ["bootloader/uefi"] | ||
|
Comment on lines
+8
to
+11
|
||
|
|
||
| [dependencies] | ||
| bootloader = "0.11" | ||
| bootloader = { version = "0.11", default-features = false } | ||
| ovmf-prebuilt = "0.2" | ||
| clap = { version = "4.2", features = ["derive"] } | ||
| home = "0.5" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,35 @@ | ||
| use bootloader::{BiosBoot, UefiBoot}; | ||
| use clap::Parser; | ||
| use ovmf_prebuilt::{Prebuilt, Source}; | ||
| use std::{fs::File, io::Write, path::Path}; | ||
|
|
||
| #[cfg(not(any(feature = "bios", feature = "uefi")))] | ||
| compile_error!("At least one of the `bios` or `uefi` features must be enabled."); | ||
|
|
||
| #[cfg(feature = "bios")] | ||
| use bootloader::BiosBoot; | ||
| #[cfg(feature = "uefi")] | ||
| use bootloader::UefiBoot; | ||
|
|
||
|
Comment on lines
+8
to
+12
|
||
| #[derive(Debug, clap::ValueEnum, Clone)] | ||
| enum BootType { | ||
| #[cfg(feature = "uefi")] | ||
| Uefi, | ||
| #[cfg(feature = "bios")] | ||
| Bios, | ||
| } | ||
|
|
||
| impl Default for BootType { | ||
| #[cfg(feature = "bios")] | ||
| fn default() -> Self { | ||
| Self::Bios | ||
| } | ||
|
|
||
| #[cfg(all(not(feature = "bios"), feature = "uefi"))] | ||
| fn default() -> Self { | ||
| Self::Uefi | ||
| } | ||
| } | ||
|
|
||
| /// Simple program to greet a person | ||
| #[derive(Parser, Debug)] | ||
| #[command(author, version, about, long_about = None)] | ||
|
|
@@ -26,7 +47,7 @@ struct Args { | |
| pxe: String, | ||
|
|
||
| /// uefi or bios. | ||
| #[arg(value_enum, long, default_value_t = BootType::Bios)] | ||
| #[arg(value_enum, long, default_value_t = BootType::default())] | ||
| boot_type: BootType, | ||
| } | ||
|
|
||
|
|
@@ -38,6 +59,7 @@ fn main() { | |
| let pxe_path = Path::new(&args.pxe); | ||
|
|
||
| match args.boot_type { | ||
| #[cfg(feature = "uefi")] | ||
| BootType::Uefi => { | ||
| let uefi = UefiBoot::new(kernel_path); | ||
| uefi.create_disk_image(output_path).unwrap(); | ||
|
|
@@ -61,6 +83,7 @@ fn main() { | |
| output_path.display() | ||
| ) | ||
| } | ||
| #[cfg(feature = "bios")] | ||
| BootType::Bios => { | ||
| BiosBoot::new(kernel_path) | ||
| .create_disk_image(output_path) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This target now relies on
BootType's CLI default to select BIOS (since--boot-type biosis not passed). To make the build resilient to future changes in the Rust-side defaulting logic (or feature defaults), consider passing--boot-type biosexplicitly here, similar to the UEFI target.