forked from koniifer/ableos
wasm programs are now working
This commit is contained in:
parent
5ba9d28f5d
commit
cddecccb4c
|
@ -2,7 +2,9 @@ mod aalloc;
|
||||||
|
|
||||||
pub const HEAP_START: usize = 0x_4444_4444_0000;
|
pub const HEAP_START: usize = 0x_4444_4444_0000;
|
||||||
/// 131072 bytes
|
/// 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_BASE: usize = 100;
|
||||||
|
|
||||||
pub const HEAP_SIZE: usize = HEAP_BASE * HEAP_MULTIPLIER;
|
pub const HEAP_SIZE: usize = HEAP_BASE * HEAP_MULTIPLIER;
|
||||||
|
|
4
ableos/src/dirty_hacks/mod.rs
Normal file
4
ableos/src/dirty_hacks/mod.rs
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#[no_mangle]
|
||||||
|
extern "C" fn __truncdfsf2(_x: f64) -> f32 {
|
||||||
|
0.0
|
||||||
|
}
|
|
@ -1,7 +1,5 @@
|
||||||
#![allow(clippy::empty_loop)]
|
#![allow(clippy::empty_loop)]
|
||||||
|
|
||||||
pub extern crate externc_libm as libm;
|
|
||||||
|
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
arch::{drivers::graphics::GraphicsBuffer, init, sloop},
|
arch::{drivers::graphics::GraphicsBuffer, init, sloop},
|
||||||
|
@ -43,7 +41,7 @@ pub fn kernel_main() -> ! {
|
||||||
GraphicsBuffer::draw();
|
GraphicsBuffer::draw();
|
||||||
GraphicsBuffer::hide_cursor();
|
GraphicsBuffer::hide_cursor();
|
||||||
GraphicsBuffer::show_cursor();
|
GraphicsBuffer::show_cursor();
|
||||||
// crate::wasm::evaluate();
|
crate::wasm::evaluate();
|
||||||
|
|
||||||
println!("{} v{}", RELEASE_TYPE, KERNEL_VERSION);
|
println!("{} v{}", RELEASE_TYPE, KERNEL_VERSION);
|
||||||
info!("{} v{}", RELEASE_TYPE, KERNEL_VERSION);
|
info!("{} v{}", RELEASE_TYPE, KERNEL_VERSION);
|
||||||
|
|
|
@ -31,6 +31,7 @@ pub mod print;
|
||||||
pub mod log;
|
pub mod log;
|
||||||
|
|
||||||
pub mod allocator;
|
pub mod allocator;
|
||||||
|
pub mod dirty_hacks;
|
||||||
pub mod driver_traits;
|
pub mod driver_traits;
|
||||||
pub mod experiments;
|
pub mod experiments;
|
||||||
pub mod keyboard;
|
pub mod keyboard;
|
||||||
|
@ -38,6 +39,9 @@ pub mod kmain;
|
||||||
pub mod panic;
|
pub mod panic;
|
||||||
pub mod relib;
|
pub mod relib;
|
||||||
pub mod scheduler;
|
pub mod scheduler;
|
||||||
|
pub mod test;
|
||||||
pub mod wasm;
|
pub mod wasm;
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
|
pub extern crate externc_libm as libm;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
pub use ableos::*;
|
pub use ableos::*;
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
|
#[allow(unused_imports)]
|
||||||
use qoi_rs;
|
use qoi_rs;
|
||||||
|
|
|
@ -8,8 +8,6 @@ use {
|
||||||
};
|
};
|
||||||
|
|
||||||
mod wasm_sys;
|
mod wasm_sys;
|
||||||
pub extern crate externc_libm as libm;
|
|
||||||
|
|
||||||
struct HostFunctions;
|
struct HostFunctions;
|
||||||
impl HostFunctions {
|
impl HostFunctions {
|
||||||
fn check_signature(&self, index: usize, signature: &Signature) -> bool {
|
fn check_signature(&self, index: usize, signature: &Signature) -> bool {
|
||||||
|
@ -30,7 +28,7 @@ impl Externals for HostFunctions {
|
||||||
match index.into() {
|
match index.into() {
|
||||||
// Take in one arg discard the rest
|
// Take in one arg discard the rest
|
||||||
SysCall::KILL => {
|
SysCall::KILL => {
|
||||||
println!("Program killed");
|
info!("Program run at runtime called a system call");
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
// Do nothing
|
// Do nothing
|
||||||
|
@ -74,8 +72,7 @@ impl ModuleImportResolver for HostFunctions {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn evaluate() {
|
pub fn evaluate() {
|
||||||
let wasm_binary = // Spacer
|
let wasm_binary = include_bytes!("rust.wasm");
|
||||||
include_bytes!("rust.wasm");
|
|
||||||
|
|
||||||
// Load wasm binary and prepare it for instantiation.
|
// Load wasm binary and prepare it for instantiation.
|
||||||
let module = wasmi::Module::from_buffer(&wasm_binary).expect("failed to load wasm");
|
let module = wasmi::Module::from_buffer(&wasm_binary).expect("failed to load wasm");
|
||||||
|
@ -98,8 +95,5 @@ pub fn evaluate() {
|
||||||
.try_into()
|
.try_into()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
println!(
|
println!("{:?}", result);
|
||||||
"{:?}",
|
|
||||||
result // .unwrap()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![allow(non_camel_case_types)]
|
||||||
|
|
||||||
macro_rules! syscall_enum {
|
macro_rules! syscall_enum {
|
||||||
() => {};
|
() => {};
|
||||||
(@get_last $Variant:ident) => {
|
(@get_last $Variant:ident) => {
|
||||||
|
@ -25,7 +27,6 @@ macro_rules! syscall_enum {
|
||||||
syscall_enum!($($Variant=$Value,)* );
|
syscall_enum!($($Variant=$Value,)* );
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
syscall_enum! {
|
syscall_enum! {
|
||||||
KILL=0, // Provide a PID
|
KILL=0, // Provide a PID
|
||||||
CONSOLE_RESET=1, // Reset the console
|
CONSOLE_RESET=1, // Reset the console
|
||||||
|
|
Loading…
Reference in a new issue