From 195192db8a89d43fca8fb0aadb767e207d42d930 Mon Sep 17 00:00:00 2001 From: able Date: Wed, 13 Dec 2023 04:21:32 -0600 Subject: [PATCH] compiling on arm works again --- kernel/src/holeybytes/ecah.rs | 22 ++++++++++--------- sysdata/limine.cfg | 2 +- sysdata/test-programs/hblib/std.rhai | 1 - .../limine_framebuffer_driver.rhai | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/kernel/src/holeybytes/ecah.rs b/kernel/src/holeybytes/ecah.rs index 7f3be72..e11aa75 100644 --- a/kernel/src/holeybytes/ecah.rs +++ b/kernel/src/holeybytes/ecah.rs @@ -109,8 +109,17 @@ pub fn handler(vm: &mut Vm) { info!("Recieve {:?} from Buffer({})", msg, r2); } 5 => { - let r2 = vm.registers[2].cast::(); - vm.registers[3] = hbvm::value::Value( unsafe { x86_in(r2 as u16) } as u64); + #[cfg(target_arch = "x86_64")] + { + let r2 = vm.registers[2].cast::(); + unsafe fn x86_in(address: u16) -> u32 { + x86_64::instructions::port::Port::new(address).read() + } + unsafe fn x86_out(address: u16, value: u32) { + x86_64::instructions::port::Port::new(address).write(value); + } + vm.registers[3] = hbvm::value::Value(unsafe { x86_in(r2 as u16) } as u64); + } } // 5 _ => { @@ -119,13 +128,6 @@ pub fn handler(vm: &mut Vm) { } } -unsafe fn x86_in(address: u16) -> u32{ - x86_64::instructions::port::Port::new(address).read() -} -unsafe fn x86_out(address: u16, value: u32){ - x86_64::instructions::port::Port::new(address).write(value); -} - fn log_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogError> { // let message_length = 8 + 8 + 8; // log::info!("Mem Addr 0x{:x?} length {}", mem_addr, length); @@ -139,7 +141,7 @@ fn log_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogE } let log_level = msg_vec.pop().unwrap(); match String::from_utf8(msg_vec) { - Ok (strr) => { + Ok(strr) => { // use LogLevel::*; let ll = match log_level { 0 | 48 => error!("{}", strr), diff --git a/sysdata/limine.cfg b/sysdata/limine.cfg index 65f7457..1e6458c 100644 --- a/sysdata/limine.cfg +++ b/sysdata/limine.cfg @@ -28,7 +28,7 @@ TERM_BACKDROP=008080 MODULE_CMDLINE="" MODULE_PATH=boot:///keyboard_driver.hbf - MODULE_CMDLINE="" + MODULE_CMDLINE="arch=${ARCH}" MODULE_PATH=boot:///vfs_test.hbf MODULE_CMDLINE="" diff --git a/sysdata/test-programs/hblib/std.rhai b/sysdata/test-programs/hblib/std.rhai index 4c16d52..6aa63c4 100644 --- a/sysdata/test-programs/hblib/std.rhai +++ b/sysdata/test-programs/hblib/std.rhai @@ -29,7 +29,6 @@ fn ipc_make_bound_buffer(length) { private fn log(log_level, string){ // This is NOT the final format let str = data::str(string + log_level); - // 1 byte for the log level // 8 bytes for the length to the message // 8 bytes for the pointer to the string diff --git a/sysdata/test-programs/limine_framebuffer_driver.rhai b/sysdata/test-programs/limine_framebuffer_driver.rhai index 7b1a6f5..de642eb 100644 --- a/sysdata/test-programs/limine_framebuffer_driver.rhai +++ b/sysdata/test-programs/limine_framebuffer_driver.rhai @@ -72,7 +72,7 @@ fn clear() { } // Define main -fn main(){ +fn main() { // Log the arguments { cp(r3, r1);