Merge remote-tracking branch 'origin/master' into svga_driver

This commit is contained in:
koniifer 2024-08-31 23:40:25 +01:00
commit d8bba8f0af
2 changed files with 19 additions and 11 deletions

View file

@ -129,7 +129,7 @@ pub fn handler(vm: &mut Vm) {
};
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);
let value = unsafe {
@ -155,7 +155,7 @@ pub fn handler(vm: &mut Vm) {
}
};
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);
trace!("Setting address {}", addr);
@ -164,15 +164,14 @@ pub fn handler(vm: &mut Vm) {
1 => x86_out(addr, msg_vec[0]),
2 => x86_out_16(
addr,
core::mem::transmute::<[u8; 2], u16>(
msg_vec[0..2].try_into().unwrap(),
),
((msg_vec[0] as u16) << 8) | msg_vec[1] as u16,
),
4 => x86_out_32(
addr,
core::mem::transmute::<[u8; 4], u32>(
msg_vec[0..4].try_into().unwrap(),
),
((msg_vec[0] as u32) << 24)
| ((msg_vec[1] as u32) << 16)
| ((msg_vec[2] as u32) << 8)
| (msg_vec[3] as u32),
),
_ => panic!("How?"),
}

View file

@ -22,10 +22,13 @@ fn main() -> Result<(), Error> {
match args.next().as_deref() {
Some("build" | "b") => {
let mut release = false;
let mut debuginfo = false;
let mut target = Target::X86_64;
for arg in args {
if arg == "-r" || arg == "--release" {
release = true;
} else if arg == "-d" || arg == "--debuginfo" {
debuginfo = true;
} else if arg == "rv64" || arg == "riscv64" || arg == "riscv64-virt" {
target = Target::Riscv64Virt;
} 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") => {
let mut release = false;
let mut debuginfo = false;
let mut target = Target::X86_64;
for arg in args {
if arg == "-r" || arg == "--release" {
release = true;
} else if arg == "-d" || arg == "--debuginfo" {
debuginfo = true;
} else if arg == "rv64" || arg == "riscv64" || arg == "riscv64-virt" {
target = Target::Riscv64Virt;
} 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)
}
Some("help" | "h") => {
@ -270,7 +276,7 @@ fn copy_file_to_img(fpath: &str, fs: &FileSystem<File>) {
.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 mut com = Command::new("cargo");
com.current_dir("kernel");
@ -278,6 +284,9 @@ fn build(release: bool, target: Target) -> Result<(), Error> {
if release {
com.arg("-r");
}
if debuginfo {
com.env("RUSTFLAGS", "-Cdebug-assertions=true");
}
if target == Target::Riscv64Virt {
com.args(["--target", "targets/riscv64-virt-ableos.json"]);