Compare commits

...

3 Commits

Author SHA1 Message Date
Able a59867454d
update to the hello world program 2022-04-24 03:23:23 -05:00
Able 8c45fa4af8
print SYSCALL works 2022-04-19 02:38:59 -05:00
Able 366de40340
updates 2022-04-19 02:15:45 -05:00
6 changed files with 79 additions and 48 deletions

View File

@ -54,7 +54,6 @@ watson = "0.4"
genfs = "0.1.0"
rhai = "1.6.0"
libwasm = {git="https://git.ablecorp.us:443/able/libwasm.git"}
acpi = "4.1.0"
axel = { git = "https://git.ablecorp.us/able/aos_userland" }
versioning = { git = "https://git.ablecorp.us/able/aos_userland" }
@ -134,3 +133,4 @@ volatile = "0.2.6"
x86_64 = "*"
pc-beeper = {git = "https://github.com/AbleOS/pc-beeper"}
vga = "*"
acpi = "4.1.0"

View File

@ -1,6 +1,49 @@
use crate::rhai_shell::shell;
use acpi::AcpiTables;
use core::alloc::Layout;
use crate::rhai_shell::shell;
use acpi::{AcpiTables, PlatformInfo};
/// Experimental scratchpad for testing.
pub fn scratchpad() {
let axel_raw = "kernel{
vals=
time: 123
fn|
print: (None) -> (None);
foo: (None) -> (Num);
}";
let axel = axel::parse(axel_raw.to_string());
for node in axel {
info!("{:?}", node);
}
// acpi();
shell();
}
pub fn pci_fun() {}
pub fn acpi() {
let acpi_handler = AcpiStruct {};
let _table;
unsafe {
_table = AcpiTables::search_for_rsdp_bios(acpi_handler);
}
match _table.unwrap().platform_info().unwrap() {
PlatformInfo {
power_profile,
interrupt_model,
processor_info,
pm_timer,
} => {
info!("{:?}", power_profile);
info!("{:?}", interrupt_model);
// info!("{:?}", processor_info.unwrap());
// info!("{:?}", pm_timer.unwrap());
}
_ => todo!(),
}
}
// TODO: move to a better place
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct AcpiStruct {}
@ -18,30 +61,3 @@ impl acpi::AcpiHandler for AcpiStruct {
todo!("unmap_physical_region");
}
}
/// Experimental scratchpad for testing.
pub fn scratchpad() {
let axel_raw = "kernel{
vals=
time: 123
fn|
print: (None) -> (None);
foo: (None) -> (Num);
}";
let axel = axel::parse(axel_raw.to_string());
for node in axel {
info!("{:?}", node);
}
shell();
}
pub fn pci_fun() {}
pub fn acpi() {
let acpi_handler = AcpiStruct {};
let _table;
unsafe {
_table = AcpiTables::search_for_rsdp_bios(acpi_handler);
}
}

View File

@ -39,6 +39,21 @@ impl StdIO {
}
pub fn read(&mut self) {
todo!();
use crate::devices::DEVICE_TABLE;
let mut dt = DEVICE_TABLE.lock();
let key_device = dt.devices.get_mut(&self.device).unwrap();
match key_device {
Character(dev) => {
let mut buf = String::new();
dev.read_char().map(|c| buf.push(c));
println!("{}", buf);
}
Vterm(vterm) => {
let mut buf = String::new();
vterm.read_char().map(|c| buf.push(c));
println!("{}", buf);
}
}
}
}

View File

@ -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>) = (&[ValueType::I64], None);
PRINT_CHAR => {
let (params, ret_ty): (&[ValueType], Option<ValueType>) = (&[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::<u64>(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",

View File

@ -10,7 +10,7 @@ pub fn interp() {
trace!("Got filesystem");
let file = fs
.open(
b"/home/able/bins/aos_wasm_stress_test.wasm",
b"/home/able/bins/aos_test.wasm",
OpenOptions::new().read(true),
)
.unwrap();
@ -54,6 +54,14 @@ pub fn interp() {
None => debug!("No start function found"),
}
match instance.export_by_name("main") {
Some(_val) => {
trace!("Program main function found");
has_start = true;
}
None => debug!("No main function found"),
}
match (has_driver_entry, has_driver_exit) {
(true, true) => {
trace!("Valid driver entry and exit functions found");

Binary file not shown.