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,35 +347,38 @@ 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(
|
||||||
|
com2.args(["--accel", "help"])
|
||||||
|
.stdout(Stdio::piped())
|
||||||
|
.stderr(Stdio::piped())
|
||||||
|
.spawn()
|
||||||
|
.unwrap()
|
||||||
|
.wait_with_output()
|
||||||
|
.unwrap()
|
||||||
|
.stdout,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let supported = String::from_utf8(
|
let cpuid = raw_cpuid::CpuId::new();
|
||||||
com2.args(["--accel", "help"])
|
let vmx = cpuid.get_feature_info().unwrap().has_vmx();
|
||||||
.stdout(Stdio::piped())
|
let svm = cpuid.get_svm_info().is_some();
|
||||||
.stderr(Stdio::piped())
|
|
||||||
.spawn()
|
|
||||||
.unwrap()
|
|
||||||
.wait_with_output()
|
|
||||||
.unwrap()
|
|
||||||
.stdout,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let cpuid = raw_cpuid::CpuId::new();
|
if supported.contains("kvm") && (vmx || svm) {
|
||||||
let vmx = cpuid.get_feature_info().unwrap().has_vmx();
|
"accel=kvm"
|
||||||
let svm = cpuid.get_svm_info().is_some();
|
} else if cpuid
|
||||||
|
.get_processor_brand_string()
|
||||||
let accel = if supported.contains("kvm") && (vmx | svm) {
|
.filter(|a| a.as_str() == "GenuineIntel")
|
||||||
"accel=kvm"
|
.is_some()
|
||||||
} else if cpuid
|
&& supported.contains("hax")
|
||||||
.get_processor_brand_string()
|
&& vmx
|
||||||
.filter(|a| a.as_str() == "GenuineIntel")
|
{
|
||||||
.is_some()
|
"accel=hax"
|
||||||
&& supported.contains("hax")
|
} else if supported.contains("whpx") {
|
||||||
&& vmx
|
"accel=whpx"
|
||||||
{
|
} else {
|
||||||
"accel=hax"
|
"accel=tcg"
|
||||||
} else if supported.contains("whpx") {
|
}
|
||||||
"accel=whpx"
|
|
||||||
} else {
|
} else {
|
||||||
"accel=tcg"
|
"accel=tcg"
|
||||||
};
|
};
|
||||||
|
|
|
@ -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