forked from AbleOS/ableos
print SYSCALL works
This commit is contained in:
parent
9e836f8098
commit
9d1cb9c640
|
@ -8,7 +8,7 @@ const ADD_FUNC_INDEX: usize = 0;
|
||||||
const GET_TIME_INDEX: usize = 2;
|
const GET_TIME_INDEX: usize = 2;
|
||||||
const GET_RANDOM_INDEX: usize = 3;
|
const GET_RANDOM_INDEX: usize = 3;
|
||||||
const GET_INPUT_INDEX: usize = 4;
|
const GET_INPUT_INDEX: usize = 4;
|
||||||
const PRINT_CLEVER_HACK: usize = 5;
|
const PRINT_CHAR: usize = 6;
|
||||||
const SEND_SIGNAL_INDEX: usize = 1;
|
const SEND_SIGNAL_INDEX: usize = 1;
|
||||||
|
|
||||||
pub struct HostExternals;
|
pub struct HostExternals;
|
||||||
|
@ -100,8 +100,8 @@ impl HostExternals {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
PRINT_CLEVER_HACK => {
|
PRINT_CHAR => {
|
||||||
let (params, ret_ty): (&[ValueType], Option<ValueType>) = (&[ValueType::I64], None);
|
let (params, ret_ty): (&[ValueType], Option<ValueType>) = (&[ValueType::I32], None);
|
||||||
if params.len() != signature.params().len() {
|
if params.len() != signature.params().len() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -178,20 +178,12 @@ impl Externals for HostExternals {
|
||||||
Ok(Some(ret))
|
Ok(Some(ret))
|
||||||
}
|
}
|
||||||
|
|
||||||
PRINT_CLEVER_HACK => {
|
PRINT_CHAR => {
|
||||||
// println!("SYSCALL: print clever hack");
|
let chr: u8 = args.nth_checked(0)?;
|
||||||
|
trace!("SYSCALL: print: {}", chr);
|
||||||
let combinated = args.nth_checked::<u64>(0).unwrap().to_le_bytes();
|
print!("{}", char::from(chr));
|
||||||
|
|
||||||
for x in combinated.iter() {
|
|
||||||
let chr = *x as char;
|
|
||||||
print!("{}", chr);
|
|
||||||
}
|
|
||||||
|
|
||||||
println!("\n");
|
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
error!("Unimplemented function at {}", index);
|
error!("Unimplemented function at {}", index);
|
||||||
Err(Trap::new(wasmi::TrapKind::Unreachable))
|
Err(Trap::new(wasmi::TrapKind::Unreachable))
|
||||||
|
@ -208,7 +200,7 @@ impl ModuleImportResolver for HostExternals {
|
||||||
"get_time" => GET_TIME_INDEX,
|
"get_time" => GET_TIME_INDEX,
|
||||||
"get_random" => GET_RANDOM_INDEX,
|
"get_random" => GET_RANDOM_INDEX,
|
||||||
"get_input" => GET_INPUT_INDEX,
|
"get_input" => GET_INPUT_INDEX,
|
||||||
"print_clever_hack" => PRINT_CLEVER_HACK,
|
"print_char" => PRINT_CHAR,
|
||||||
_ => {
|
_ => {
|
||||||
return Err(Error::Instantiation(format!(
|
return Err(Error::Instantiation(format!(
|
||||||
"Export {} not found",
|
"Export {} not found",
|
||||||
|
|
Binary file not shown.
Loading…
Reference in a new issue