wasm programs are now working

master
Able 2021-12-24 08:04:07 -06:00
parent e9fb5806c9
commit 72bdffdbf5
No known key found for this signature in database
GPG Key ID: 2BB8F62388A6A225
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