wasm programs are now working

This commit is contained in:
Able 2021-12-24 08:04:07 -06:00
parent 5ba9d28f5d
commit cddecccb4c
8 changed files with 19 additions and 14 deletions

View file

@ -2,7 +2,9 @@ mod aalloc;
pub const HEAP_START: usize = 0x_4444_4444_0000;
/// 131072 bytes
pub const HEAP_MULTIPLIER: usize = 1024;
// pub const HEAP_MULTIPLIER: usize = 1024;
pub const HEAP_MULTIPLIER: usize = 100000;
pub const HEAP_BASE: usize = 100;
pub const HEAP_SIZE: usize = HEAP_BASE * HEAP_MULTIPLIER;

View file

@ -0,0 +1,4 @@
#[no_mangle]
extern "C" fn __truncdfsf2(_x: f64) -> f32 {
0.0
}

View file

@ -1,7 +1,5 @@
#![allow(clippy::empty_loop)]
pub extern crate externc_libm as libm;
use {
crate::{
arch::{drivers::graphics::GraphicsBuffer, init, sloop},
@ -43,7 +41,7 @@ pub fn kernel_main() -> ! {
GraphicsBuffer::draw();
GraphicsBuffer::hide_cursor();
GraphicsBuffer::show_cursor();
// crate::wasm::evaluate();
crate::wasm::evaluate();
println!("{} v{}", RELEASE_TYPE, KERNEL_VERSION);
info!("{} v{}", RELEASE_TYPE, KERNEL_VERSION);

View file

@ -31,6 +31,7 @@ pub mod print;
pub mod log;
pub mod allocator;
pub mod dirty_hacks;
pub mod driver_traits;
pub mod experiments;
pub mod keyboard;
@ -38,6 +39,9 @@ pub mod kmain;
pub mod panic;
pub mod relib;
pub mod scheduler;
pub mod test;
pub mod wasm;
extern crate alloc;
pub extern crate externc_libm as libm;

View file

@ -1,3 +1,4 @@
#![no_std]
#![no_main]
pub use ableos::*;

View file

@ -1 +1,2 @@
#[allow(unused_imports)]
use qoi_rs;

View file

@ -8,8 +8,6 @@ use {
};
mod wasm_sys;
pub extern crate externc_libm as libm;
struct HostFunctions;
impl HostFunctions {
fn check_signature(&self, index: usize, signature: &Signature) -> bool {
@ -30,7 +28,7 @@ impl Externals for HostFunctions {
match index.into() {
// Take in one arg discard the rest
SysCall::KILL => {
println!("Program killed");
info!("Program run at runtime called a system call");
Ok(None)
}
// Do nothing
@ -74,8 +72,7 @@ impl ModuleImportResolver for HostFunctions {
}
pub fn evaluate() {
let wasm_binary = // Spacer
include_bytes!("rust.wasm");
let wasm_binary = include_bytes!("rust.wasm");
// Load wasm binary and prepare it for instantiation.
let module = wasmi::Module::from_buffer(&wasm_binary).expect("failed to load wasm");
@ -98,8 +95,5 @@ pub fn evaluate() {
.try_into()
.unwrap();
println!(
"{:?}",
result // .unwrap()
);
println!("{:?}", result);
}

View file

@ -1,3 +1,5 @@
#![allow(non_camel_case_types)]
macro_rules! syscall_enum {
() => {};
(@get_last $Variant:ident) => {
@ -25,7 +27,6 @@ macro_rules! syscall_enum {
syscall_enum!($($Variant=$Value,)* );
};
}
syscall_enum! {
KILL=0, // Provide a PID
CONSOLE_RESET=1, // Reset the console