From 9d1cb9c6409ab5d9a572bbd0ca189c968a14670f Mon Sep 17 00:00:00 2001 From: Able Date: Tue, 19 Apr 2022 02:38:59 -0500 Subject: [PATCH] print SYSCALL works --- ableos/src/wasm_jumploader/host_functions.rs | 24 +++++++------------ userland/root_fs/ext2.img | Bin 4194304 -> 4194304 bytes 2 files changed, 8 insertions(+), 16 deletions(-) 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 87b45adae6ef7d2b35d9a90a50d7bc7499e0a49e..6efcc1ef5dfde0ce3b33070802a310497ba06eac 100644 GIT binary patch delta 1169 zcmdT?%}*0i5a0K9(WQOZ1*(=0?Scgn6-%{J3JO(BAeQ(M5&5bXO3(ww5HCiXteA`@ zTqxVH(UVcaRY;Y_=)sTi<4TP2pk4$cUW_4}OiCdDX&TkI zO)x3LZ4-nUJzFZs4EBb)A8@Nkc%_4c=GZ0)&=Hx5Zre=4CVT3MGe+ultx3|M(N7lj zr;T+nMbf3F+L%(G(3%FRcw~{p$mN67md&*U0O8gg*&moMN#7LW3`kt2`;$8cA z!5!|+PIDqjcP0FuMPtM-Wgph6V#J|qZBnkuYU@9qeu6)x8)usJNV~d}mYo`Q zrOcEq1s}e9#77$m%eLv&%B7pFov(QMnijsUg-KEi)8X=@a)W*sM~A7hj37=SE<#*_ zcm~AROvTqaG-6NY+2t?JQMt@RyhfEzF0)%M44gZE@pRAG@PI%?tA&V!8vU|QHE#K2 z)wr#wZsViu^Y=|tOP3HJ0iy5^s0sPX)g>2rEhvK~3VclgbtSNn3e2Uz=M!;alApk0w@D!0$KpAfDAATa2=oxPyx&a%mK^=v;(dO+yJ-{&;ghS zm=9P0SO~ZYa5JD2Pz5XkEC$>H=mIPOES^%jYzMHNz$$?4 o0_Fx*3Csg*H?TdxyukJXs{-Z&Rt?M#tOi&uuzkSxkF&ak-<`X8`v3p{ delta 1027 zcmZ`&OH30{6n$@I3Il!8K??N4r-kyzf(2?VDxfaFXtX30DM-?Wpe~R^Oblq_5R!|L zL@Co)mm0BdTu7SGjWL?sEn(xIOrbQ4FUUKHmymQa}oR?8mRZuzJGRe?n zB4k4=lmar*90}=KvdsT3j{iRhXxvX;IbY#Hsq*%&*f_`0+Dr& z!RLX9o@ra8ds!*}rui}Im$u%_Uyo6XrVdGsXC*?0Ci)|vxeGe}s`znc=_(V?tOzmc z)y6`O+7W)DH>KCnp@;onN050PZ8PM`8ZkVb>27&<-cN_9q^xRqS2Z%dSL>it2WJv; zGPOpQ#h~u(wP;n6dwX!6eQyK2TLYiPpBfu26Erm}o4!@pBL6@u4PBDf?2lVA7KO6> zPad<23_r6Jn&JGM8lG3fG_8h(#YTk@L2$bXDd9DmNi|J4Ws9}Qedl&~>c-7mr