forked from koniifer/ableos
fix ecah.rs, implement -d, --debuginfo to print debug info in serial (requires recompilation)
This commit is contained in:
parent
8577920d90
commit
c752028c73
|
@ -129,7 +129,7 @@ pub fn handler(vm: &mut Vm) {
|
||||||
};
|
};
|
||||||
msg_vec.remove(0);
|
msg_vec.remove(0);
|
||||||
|
|
||||||
let addr = ((msg_vec[0] as u16) << 8) + msg_vec[1] as u16;
|
let addr = ((msg_vec[0] as u16) << 8) | msg_vec[1] as u16;
|
||||||
msg_vec.remove(0);
|
msg_vec.remove(0);
|
||||||
msg_vec.remove(0);
|
msg_vec.remove(0);
|
||||||
let value = unsafe {
|
let value = unsafe {
|
||||||
|
@ -155,7 +155,7 @@ pub fn handler(vm: &mut Vm) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
msg_vec.remove(0);
|
msg_vec.remove(0);
|
||||||
let addr = ((msg_vec[0] as u16) << 8) + msg_vec[1] as u16;
|
let addr = ((msg_vec[0] as u16) << 8) | msg_vec[1] as u16;
|
||||||
msg_vec.remove(0);
|
msg_vec.remove(0);
|
||||||
msg_vec.remove(0);
|
msg_vec.remove(0);
|
||||||
trace!("Setting address {}", addr);
|
trace!("Setting address {}", addr);
|
||||||
|
@ -164,15 +164,14 @@ pub fn handler(vm: &mut Vm) {
|
||||||
1 => x86_out(addr, msg_vec[0]),
|
1 => x86_out(addr, msg_vec[0]),
|
||||||
2 => x86_out_16(
|
2 => x86_out_16(
|
||||||
addr,
|
addr,
|
||||||
core::mem::transmute::<[u8; 2], u16>(
|
((msg_vec[0] as u16) << 8) | msg_vec[1] as u16,
|
||||||
msg_vec[0..2].try_into().unwrap(),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
4 => x86_out_32(
|
4 => x86_out_32(
|
||||||
addr,
|
addr,
|
||||||
core::mem::transmute::<[u8; 4], u32>(
|
((msg_vec[0] as u32) << 24)
|
||||||
msg_vec[0..4].try_into().unwrap(),
|
| ((msg_vec[1] as u32) << 16)
|
||||||
),
|
| ((msg_vec[2] as u32) << 8)
|
||||||
|
| (msg_vec[3] as u32),
|
||||||
),
|
),
|
||||||
_ => panic!("How?"),
|
_ => panic!("How?"),
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,13 @@ fn main() -> Result<(), Error> {
|
||||||
match args.next().as_deref() {
|
match args.next().as_deref() {
|
||||||
Some("build" | "b") => {
|
Some("build" | "b") => {
|
||||||
let mut release = false;
|
let mut release = false;
|
||||||
|
let mut debuginfo = false;
|
||||||
let mut target = Target::X86_64;
|
let mut target = Target::X86_64;
|
||||||
for arg in args {
|
for arg in args {
|
||||||
if arg == "-r" || arg == "--release" {
|
if arg == "-r" || arg == "--release" {
|
||||||
release = true;
|
release = true;
|
||||||
|
} else if arg == "-d" || arg == "--debuginfo" {
|
||||||
|
debuginfo = true;
|
||||||
} else if arg == "rv64" || arg == "riscv64" || arg == "riscv64-virt" {
|
} else if arg == "rv64" || arg == "riscv64" || arg == "riscv64-virt" {
|
||||||
target = Target::Riscv64Virt;
|
target = Target::Riscv64Virt;
|
||||||
} else if arg == "arm64" || arg == "aarch64" || arg == "aarch64-virt" {
|
} else if arg == "arm64" || arg == "aarch64" || arg == "aarch64-virt" {
|
||||||
|
@ -35,14 +38,17 @@ fn main() -> Result<(), Error> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
build(release, target).change_context(Error::Build)
|
build(release, target, debuginfo).change_context(Error::Build)
|
||||||
}
|
}
|
||||||
Some("run" | "r") => {
|
Some("run" | "r") => {
|
||||||
let mut release = false;
|
let mut release = false;
|
||||||
|
let mut debuginfo = false;
|
||||||
let mut target = Target::X86_64;
|
let mut target = Target::X86_64;
|
||||||
for arg in args {
|
for arg in args {
|
||||||
if arg == "-r" || arg == "--release" {
|
if arg == "-r" || arg == "--release" {
|
||||||
release = true;
|
release = true;
|
||||||
|
} else if arg == "-d" || arg == "--debuginfo" {
|
||||||
|
debuginfo = true;
|
||||||
} else if arg == "rv64" || arg == "riscv64" || arg == "riscv64-virt" {
|
} else if arg == "rv64" || arg == "riscv64" || arg == "riscv64-virt" {
|
||||||
target = Target::Riscv64Virt;
|
target = Target::Riscv64Virt;
|
||||||
} else if arg == "arm64" || arg == "aarch64" || arg == "aarch64-virt" {
|
} else if arg == "arm64" || arg == "aarch64" || arg == "aarch64-virt" {
|
||||||
|
@ -52,7 +58,7 @@ fn main() -> Result<(), Error> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
build(release, target)?;
|
build(release, target, debuginfo)?;
|
||||||
run(release, target)
|
run(release, target)
|
||||||
}
|
}
|
||||||
Some("help" | "h") => {
|
Some("help" | "h") => {
|
||||||
|
@ -270,7 +276,7 @@ fn copy_file_to_img(fpath: &str, fs: &FileSystem<File>) {
|
||||||
.expect("Copy failed");
|
.expect("Copy failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build(release: bool, target: Target) -> Result<(), Error> {
|
fn build(release: bool, target: Target, debuginfo: bool) -> Result<(), Error> {
|
||||||
let fs = get_fs().change_context(Error::Io)?;
|
let fs = get_fs().change_context(Error::Io)?;
|
||||||
let mut com = Command::new("cargo");
|
let mut com = Command::new("cargo");
|
||||||
com.current_dir("kernel");
|
com.current_dir("kernel");
|
||||||
|
@ -278,6 +284,9 @@ fn build(release: bool, target: Target) -> Result<(), Error> {
|
||||||
if release {
|
if release {
|
||||||
com.arg("-r");
|
com.arg("-r");
|
||||||
}
|
}
|
||||||
|
if debuginfo {
|
||||||
|
com.env("RUSTFLAGS", "-Cdebug-assertions=true");
|
||||||
|
}
|
||||||
|
|
||||||
if target == Target::Riscv64Virt {
|
if target == Target::Riscv64Virt {
|
||||||
com.args(["--target", "targets/riscv64-virt-ableos.json"]);
|
com.args(["--target", "targets/riscv64-virt-ableos.json"]);
|
||||||
|
|
Loading…
Reference in a new issue