forked from AbleOS/ableos
add --noaccel flag to disable vm acceleration, update repbuild help
This commit is contained in:
parent
aac6d61dc6
commit
82f5cdbe21
|
@ -7,7 +7,6 @@ use {
|
||||||
dev::Package,
|
dev::Package,
|
||||||
error_stack::{bail, report, Context, Report, Result, ResultExt},
|
error_stack::{bail, report, Context, Report, Result, ResultExt},
|
||||||
fatfs::{FileSystem, FormatVolumeOptions, FsOptions, ReadWriteSeek},
|
fatfs::{FileSystem, FormatVolumeOptions, FsOptions, ReadWriteSeek},
|
||||||
raw_cpuid::HypervisorInfo,
|
|
||||||
std::{
|
std::{
|
||||||
// fmt::Display,
|
// fmt::Display,
|
||||||
fs::{self, File},
|
fs::{self, File},
|
||||||
|
@ -50,6 +49,7 @@ fn main() -> Result<(), Error> {
|
||||||
let mut release = false;
|
let mut release = false;
|
||||||
let mut debuginfo = false;
|
let mut debuginfo = false;
|
||||||
let mut target = Target::X86_64;
|
let mut target = Target::X86_64;
|
||||||
|
let mut do_accel = true;
|
||||||
for arg in args {
|
for arg in args {
|
||||||
if arg == "-r" || arg == "--release" {
|
if arg == "-r" || arg == "--release" {
|
||||||
release = true;
|
release = true;
|
||||||
|
@ -59,13 +59,15 @@ fn main() -> Result<(), Error> {
|
||||||
target = Target::Riscv64Virt;
|
target = Target::Riscv64Virt;
|
||||||
} else if arg == "arm64" || arg == "aarch64" || arg == "aarch64-virt" {
|
} else if arg == "arm64" || arg == "aarch64" || arg == "aarch64-virt" {
|
||||||
target = Target::Aarch64;
|
target = Target::Aarch64;
|
||||||
|
} else if arg == "--noaccel" {
|
||||||
|
do_accel = false;
|
||||||
} else {
|
} else {
|
||||||
return Err(report!(Error::InvalidSubCom));
|
return Err(report!(Error::InvalidSubCom));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
build(release, target, debuginfo)?;
|
build(release, target, debuginfo)?;
|
||||||
run(release, target)
|
run(release, target, do_accel)
|
||||||
}
|
}
|
||||||
Some("help" | "h") => {
|
Some("help" | "h") => {
|
||||||
println!(concat!(
|
println!(concat!(
|
||||||
|
@ -75,8 +77,10 @@ fn main() -> Result<(), Error> {
|
||||||
" help (h): Print this message\n",
|
" help (h): Print this message\n",
|
||||||
" run (r): Build and run AbleOS in QEMU\n\n",
|
" run (r): Build and run AbleOS in QEMU\n\n",
|
||||||
"Options for build and run:\n",
|
"Options for build and run:\n",
|
||||||
" -r: build in release mode",
|
" -r / --release: build in release mode\n",
|
||||||
" [target]: sets target"
|
" -d / --debuginfo: build with debug info\n",
|
||||||
|
" --noaccel: run without acceleration (e.g, no kvm)\n",
|
||||||
|
"[ rv64 / riscv64 / riscv64-virt / aarch64 / arm64 / aarch64-virt ]: sets target"
|
||||||
),);
|
),);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -335,7 +339,7 @@ fn build(release: bool, target: Target, debuginfo: bool) -> Result<(), Error> {
|
||||||
.change_context(Error::Io)
|
.change_context(Error::Io)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run(release: bool, target: Target) -> Result<(), Error> {
|
fn run(release: bool, target: Target, do_accel: bool) -> Result<(), Error> {
|
||||||
let target_str = match target {
|
let target_str = match target {
|
||||||
Target::X86_64 => "qemu-system-x86_64",
|
Target::X86_64 => "qemu-system-x86_64",
|
||||||
Target::Riscv64Virt => "qemu-system-riscv64",
|
Target::Riscv64Virt => "qemu-system-riscv64",
|
||||||
|
@ -343,7 +347,7 @@ fn run(release: bool, target: Target) -> Result<(), Error> {
|
||||||
};
|
};
|
||||||
let (mut com, mut com2) = (Command::new(target_str), Command::new(target_str));
|
let (mut com, mut com2) = (Command::new(target_str), Command::new(target_str));
|
||||||
let ovmf_path = fetch_ovmf(target);
|
let ovmf_path = fetch_ovmf(target);
|
||||||
|
let accel = if do_accel {
|
||||||
let supported = String::from_utf8(
|
let supported = String::from_utf8(
|
||||||
com2.args(["--accel", "help"])
|
com2.args(["--accel", "help"])
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
|
@ -360,7 +364,7 @@ fn run(release: bool, target: Target) -> Result<(), Error> {
|
||||||
let vmx = cpuid.get_feature_info().unwrap().has_vmx();
|
let vmx = cpuid.get_feature_info().unwrap().has_vmx();
|
||||||
let svm = cpuid.get_svm_info().is_some();
|
let svm = cpuid.get_svm_info().is_some();
|
||||||
|
|
||||||
let accel = if supported.contains("kvm") && (vmx | svm) {
|
if supported.contains("kvm") && (vmx || svm) {
|
||||||
"accel=kvm"
|
"accel=kvm"
|
||||||
} else if cpuid
|
} else if cpuid
|
||||||
.get_processor_brand_string()
|
.get_processor_brand_string()
|
||||||
|
@ -374,6 +378,9 @@ fn run(release: bool, target: Target) -> Result<(), Error> {
|
||||||
"accel=whpx"
|
"accel=whpx"
|
||||||
} else {
|
} else {
|
||||||
"accel=tcg"
|
"accel=tcg"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
"accel=tcg"
|
||||||
};
|
};
|
||||||
|
|
||||||
match target {
|
match target {
|
||||||
|
|
|
@ -26,8 +26,8 @@ resolution = "1024x768x24"
|
||||||
# [boot.limine.ableos.modules.diskio_driver]
|
# [boot.limine.ableos.modules.diskio_driver]
|
||||||
# path = "boot:///diskio_driver.hbf"
|
# path = "boot:///diskio_driver.hbf"
|
||||||
|
|
||||||
[boot.limine.ableos.modules.render_example]
|
# [boot.limine.ableos.modules.render_example]
|
||||||
path = "boot:///render_example.hbf"
|
# path = "boot:///render_example.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.serial_driver_test]
|
# [boot.limine.ableos.modules.serial_driver_test]
|
||||||
# path = "boot:///serial_driver_test.hbf"
|
# path = "boot:///serial_driver_test.hbf"
|
||||||
|
@ -44,8 +44,8 @@ path = "boot:///render_example.hbf"
|
||||||
# [boot.limine.ableos.modules.svga_driver]
|
# [boot.limine.ableos.modules.svga_driver]
|
||||||
# path = "boot:///svga_driver.hbf"
|
# path = "boot:///svga_driver.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.ps2_driver]
|
[boot.limine.ableos.modules.ps2_driver]
|
||||||
# path = "boot:///ps2_driver.hbf"
|
path = "boot:///ps2_driver.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.filesystem_fat32]
|
# [boot.limine.ableos.modules.filesystem_fat32]
|
||||||
# path = "boot:///filesystem_fat32.hbf"
|
# path = "boot:///filesystem_fat32.hbf"
|
||||||
|
@ -53,5 +53,5 @@ path = "boot:///render_example.hbf"
|
||||||
# [boot.limine.ableos.modules.pumpkin_print]
|
# [boot.limine.ableos.modules.pumpkin_print]
|
||||||
# path = "boot:///pumpkin_print.hbf"
|
# path = "boot:///pumpkin_print.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.tetris]
|
[boot.limine.ableos.modules.tetris]
|
||||||
# path = "boot:///tetris.hbf"
|
path = "boot:///tetris.hbf"
|
||||||
|
|
Loading…
Reference in a new issue