From 2d3e88c2df151b9201f5891a3d0722fb0d7e9af9 Mon Sep 17 00:00:00 2001 From: Kenny Strawn Date: Sun, 22 Oct 2023 08:03:29 -0700 Subject: [PATCH] Don't depend on a patched bootloader anymore (still doesn't resolve rust-osdev/bootloader#396 though) --- .vscode/tasks.json | 24 ++++++++++++++++++++++++ Cargo.lock | 13 +++++++++---- Cargo.toml | 4 ---- runner/Cargo.toml | 3 ++- runner/src/main.rs | 28 +++++++++++++++++----------- src/drivers/xhci/mod.rs | 3 ++- 6 files changed, 54 insertions(+), 21 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 619fe37..575bd09 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -57,5 +57,29 @@ "isDefault": true }, }, + { + "label": "Clean and rebuild", + "type": "shell", + "command": [ + "cargo", + "cache", + "-r", + "all", + "&&", + "cargo", + "clean", + "&&", + "cargo", + "run", + "--package", + "runner", + "--", + "--boot", + ], + "group": { + "kind": "build", + "isDefault": true + }, + } ] } \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index c4782c5..baff62e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -282,7 +282,8 @@ dependencies = [ [[package]] name = "bootloader" version = "0.11.4" -source = "git+https://github.com/kennystrawnmusic/bootloader#fb182e71a80100aa7850bb08f54424a014c67196" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e092090f6e2b68cee8dc291ec60e4706f6b0c5cd90b666a5248a20f30591ccb0" dependencies = [ "anyhow", "async-process", @@ -300,7 +301,8 @@ dependencies = [ [[package]] name = "bootloader-boot-config" version = "0.11.4" -source = "git+https://github.com/kennystrawnmusic/bootloader#fb182e71a80100aa7850bb08f54424a014c67196" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a36c0df7b26b44254828ece99ed72aa01695cc37f007a97afe8aee29feb26e3e" dependencies = [ "serde", ] @@ -308,7 +310,8 @@ dependencies = [ [[package]] name = "bootloader-x86_64-common" version = "0.11.4" -source = "git+https://github.com/kennystrawnmusic/bootloader#fb182e71a80100aa7850bb08f54424a014c67196" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5584af34405de754cf55a0a77f056e45b38bc34db880bae03e9f57d805a15da5" dependencies = [ "bootloader-boot-config", "bootloader_api", @@ -328,7 +331,8 @@ dependencies = [ [[package]] name = "bootloader_api" version = "0.11.4" -source = "git+https://github.com/kennystrawnmusic/bootloader#fb182e71a80100aa7850bb08f54424a014c67196" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88f843888771a490c3ad246e58bf25e62da70d2c653d74a3eca92acbab599e02" [[package]] name = "buddy_system_allocator" @@ -1264,6 +1268,7 @@ dependencies = [ "bootloader-boot-config", "cryptos", "ovmf-prebuilt", + "raw-cpuid 11.0.1", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 0423186..405c47e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,10 +67,6 @@ incremental = true codegen-units = 256 [patch.crates-io] -bootloader = { git = "https://github.com/kennystrawnmusic/bootloader" } -bootloader-boot-config = { git = "https://github.com/kennystrawnmusic/bootloader" } -bootloader-x86_64-common = { git = "https://github.com/kennystrawnmusic/bootloader" } -bootloader_api = { git = "https://github.com/kennystrawnmusic/bootloader" } redox_syscall = { git = "https://gitlab.redox-os.org/redox-os/syscall" } [features] diff --git a/runner/Cargo.toml b/runner/Cargo.toml index 751338b..b92b9f2 100644 --- a/runner/Cargo.toml +++ b/runner/Cargo.toml @@ -9,4 +9,5 @@ edition = "2021" cryptos = { path = "..", artifact = "bin", target = "x86_64-unknown-none" } bootloader = "^0.11" bootloader-boot-config = "^0.11" -ovmf-prebuilt = { git = "https://github.com/rust-osdev/ovmf-prebuilt", artifact = "bin", version = "0.1.0" } \ No newline at end of file +ovmf-prebuilt = { git = "https://github.com/rust-osdev/ovmf-prebuilt", artifact = "bin", version = "0.1.0" } +raw-cpuid = "11.0.1" diff --git a/runner/src/main.rs b/runner/src/main.rs index 687e919..2ac318e 100644 --- a/runner/src/main.rs +++ b/runner/src/main.rs @@ -7,6 +7,7 @@ use std::{ path::Path, process::{exit, Command, Stdio}, }; +use raw_cpuid::{CpuId, Hypervisor}; fn main() { if cfg!(target_os = "linux") { @@ -20,15 +21,24 @@ fn main() { let kdir = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap(); let out_path = kdir.join("cryptos.img"); - let mut fb_phys = FrameBuffer::default(); - fb_phys.minimum_framebuffer_width = Some(1920); - fb_phys.minimum_framebuffer_height = Some(1080); - - let fb_virt = FrameBuffer::default(); + let framebuf = if let Some(hypervisor) = CpuId::new().get_hypervisor_info() { + if let Hypervisor::QEMU = hypervisor.identify() { + FrameBuffer::default() + } else { + let mut fb = FrameBuffer::default(); + fb.minimum_framebuffer_height = Some(1920); + fb.minimum_framebuffer_width = Some(1080); + fb + } + } else { + let mut fb = FrameBuffer::default(); + fb.minimum_framebuffer_height = Some(1920); + fb.minimum_framebuffer_width = Some(1080); + fb + }; let mut c = BootConfig::default(); - c.frame_buffer_physical = fb_phys; - c.frame_buffer_virtual = fb_virt; + c.frame_buffer = framebuf; // Suppress excessive output in release mode if cfg!(opt_level = "0") { @@ -405,10 +415,6 @@ fn run_qemu(kdir: &Path, out_path: &Path) { let mut uefi_cmd = Command::new("qemu-system-x86_64"); - if cfg!(target_os = "linux") { - uefi_cmd.arg("-accel").arg("kvm"); - } - uefi_cmd .arg("-drive") .arg(format!( diff --git a/src/drivers/xhci/mod.rs b/src/drivers/xhci/mod.rs index 7d39fec..b86812e 100644 --- a/src/drivers/xhci/mod.rs +++ b/src/drivers/xhci/mod.rs @@ -726,7 +726,8 @@ impl XhciImpl { while port.portsc.port_reset() { core::hint::spin_loop(); } - // TODO: timeout + + log::info!("Ports successfully reset"); } } });