Skip to content
Merged
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ kernel-x86_64.elf: $(X86ASM) FORCE
python3 scripts/embed_debug_info.py $@

x86_64_boot.img: kernel-x86_64.elf
RUSTFLAGS="$(RUSTC_MISC_ARGS)" cargo +$(RUSTV) run --release --package x86bootdisk -- --kernel $< --output $@
RUSTFLAGS="$(RUSTC_MISC_ARGS)" cargo +$(RUSTV) run --release --package x86bootdisk --no-default-features --features bios -- --kernel $< --output $@
Comment thread
kobayu858 marked this conversation as resolved.
Outdated

x86_64_uefi.img: kernel-x86_64.elf
RUSTFLAGS="$(RUSTC_MISC_ARGS)" cargo +$(RUSTV) run --release --package x86bootdisk -- --kernel $< --output $@ --pxe x86_64_uefi_pxe_boot --boot-type uefi
RUSTFLAGS="$(RUSTC_MISC_ARGS)" cargo +$(RUSTV) run --release --package x86bootdisk --no-default-features --features uefi -- --kernel $< --output $@ --pxe x86_64_uefi_pxe_boot --boot-type uefi

$(X86ASM): FORCE
$(MAKE) -C $@
Expand Down
1 change: 0 additions & 1 deletion mdbook/book.toml
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"

Expand Down
7 changes: 6 additions & 1 deletion x86bootdisk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 thread
nokosaaan marked this conversation as resolved.

[dependencies]
bootloader = "0.11"
bootloader = { version = "0.11", default-features = false }
ovmf-prebuilt = "0.2"
clap = { version = "4.2", features = ["derive"] }
home = "0.5"
27 changes: 25 additions & 2 deletions x86bootdisk/src/main.rs
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 thread
nokosaaan marked this conversation as resolved.
#[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)]
Expand All @@ -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,
}

Expand All @@ -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();
Expand All @@ -61,6 +83,7 @@ fn main() {
output_path.display()
)
}
#[cfg(feature = "bios")]
BootType::Bios => {
BiosBoot::new(kernel_path)
.create_disk_image(output_path)
Expand Down