diff --git a/ableos/src/wasm_jumploader/host_functions.rs b/ableos/src/wasm_jumploader/host_functions.rs index 81910eb0..04c50550 100644 --- a/ableos/src/wasm_jumploader/host_functions.rs +++ b/ableos/src/wasm_jumploader/host_functions.rs @@ -8,7 +8,7 @@ const ADD_FUNC_INDEX: usize = 0; const GET_TIME_INDEX: usize = 2; const GET_RANDOM_INDEX: usize = 3; const GET_INPUT_INDEX: usize = 4; -const PRINT_CLEVER_HACK: usize = 5; +const PRINT_CHAR: usize = 6; const SEND_SIGNAL_INDEX: usize = 1; pub struct HostExternals; @@ -100,8 +100,8 @@ impl HostExternals { true } - PRINT_CLEVER_HACK => { - let (params, ret_ty): (&[ValueType], Option) = (&[ValueType::I64], None); + PRINT_CHAR => { + let (params, ret_ty): (&[ValueType], Option) = (&[ValueType::I32], None); if params.len() != signature.params().len() { return false; } @@ -178,20 +178,12 @@ impl Externals for HostExternals { Ok(Some(ret)) } - PRINT_CLEVER_HACK => { - // println!("SYSCALL: print clever hack"); - - let combinated = args.nth_checked::(0).unwrap().to_le_bytes(); - - for x in combinated.iter() { - let chr = *x as char; - print!("{}", chr); - } - - println!("\n"); + PRINT_CHAR => { + let chr: u8 = args.nth_checked(0)?; + trace!("SYSCALL: print: {}", chr); + print!("{}", char::from(chr)); Ok(None) } - _ => { error!("Unimplemented function at {}", index); Err(Trap::new(wasmi::TrapKind::Unreachable)) @@ -208,7 +200,7 @@ impl ModuleImportResolver for HostExternals { "get_time" => GET_TIME_INDEX, "get_random" => GET_RANDOM_INDEX, "get_input" => GET_INPUT_INDEX, - "print_clever_hack" => PRINT_CLEVER_HACK, + "print_char" => PRINT_CHAR, _ => { return Err(Error::Instantiation(format!( "Export {} not found", diff --git a/userland/root_fs/ext2.img b/userland/root_fs/ext2.img index 87b45ada..6efcc1ef 100644 Binary files a/userland/root_fs/ext2.img and b/userland/root_fs/ext2.img differ