minor changes
This commit is contained in:
parent
75cfb18c77
commit
b21c53fa82
|
@ -1,6 +1,3 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
target = "./json_targets/x86_64-ableos.json"
|
target = "./json_targets/x86_64-ableos.json"
|
||||||
|
|
||||||
|
@ -8,7 +5,6 @@ target = "./json_targets/x86_64-ableos.json"
|
||||||
build-std = ["core", "compiler_builtins", "alloc"]
|
build-std = ["core", "compiler_builtins", "alloc"]
|
||||||
build-std-features = ["compiler-builtins-mem"]
|
build-std-features = ["compiler-builtins-mem"]
|
||||||
|
|
||||||
|
|
||||||
[target.'cfg(target_arch = "x86_64")']
|
[target.'cfg(target_arch = "x86_64")']
|
||||||
rustflags = ["-C", "target-feature=+rdrnd"]
|
rustflags = ["-C", "target-feature=+rdrnd"]
|
||||||
runner = "bootimage runner"
|
runner = "bootimage runner"
|
||||||
|
|
21
ableos/Cargo.lock
generated
21
ableos/Cargo.lock
generated
|
@ -36,10 +36,12 @@ dependencies = [
|
||||||
"genfs",
|
"genfs",
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
"libwasm",
|
||||||
"linked_list_allocator",
|
"linked_list_allocator",
|
||||||
"lliw",
|
"lliw",
|
||||||
"log",
|
"log",
|
||||||
"pc-beeper",
|
"pc-beeper",
|
||||||
|
"pci",
|
||||||
"pic8259",
|
"pic8259",
|
||||||
"picorand",
|
"picorand",
|
||||||
"pretty-hex",
|
"pretty-hex",
|
||||||
|
@ -50,7 +52,6 @@ dependencies = [
|
||||||
"shadeable",
|
"shadeable",
|
||||||
"smoltcp",
|
"smoltcp",
|
||||||
"spin 0.5.2",
|
"spin 0.5.2",
|
||||||
"tinypci",
|
|
||||||
"uart_16550",
|
"uart_16550",
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
"vga",
|
"vga",
|
||||||
|
@ -276,6 +277,11 @@ version = "0.2.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "33a33a362ce288760ec6a508b94caaec573ae7d3bbbd91b87aa0bad4456839db"
|
checksum = "33a33a362ce288760ec6a508b94caaec573ae7d3bbbd91b87aa0bad4456839db"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libwasm"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://git.ablecorp.us/able/libwasm.git#a89b8fc701ba0196cc9cca9989d9beb93d02a317"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "linked_list_allocator"
|
name = "linked_list_allocator"
|
||||||
version = "0.9.1"
|
version = "0.9.1"
|
||||||
|
@ -387,6 +393,14 @@ dependencies = [
|
||||||
"x86_64",
|
"x86_64",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pci"
|
||||||
|
version = "0.0.1"
|
||||||
|
source = "git+https://gitlab.com/robigalia/pci#4e2fddc61825568b1d14d09fdc669389e6c43f02"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pic8259"
|
name = "pic8259"
|
||||||
version = "0.10.2"
|
version = "0.10.2"
|
||||||
|
@ -669,11 +683,6 @@ dependencies = [
|
||||||
"crunchy",
|
"crunchy",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tinypci"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "git+https://github.com/trashbyte/tinypci.git#5e1bc4cf7ae4edb8d524a5e7e71a1ace9c4850fc"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ttf-parser"
|
name = "ttf-parser"
|
||||||
version = "0.14.0"
|
version = "0.14.0"
|
||||||
|
|
|
@ -12,16 +12,20 @@ run-args = [
|
||||||
"-cpu",
|
"-cpu",
|
||||||
"Broadwell-v3",
|
"Broadwell-v3",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"-serial",
|
"-serial",
|
||||||
"stdio",
|
"stdio",
|
||||||
"-smp",
|
"-smp",
|
||||||
"cores=2",
|
"cores=2",
|
||||||
|
|
||||||
"-vga",
|
|
||||||
"qxl",
|
|
||||||
# An example gpu used with ableOS
|
# An example gpu used with ableOS
|
||||||
# "-device",
|
"-device",
|
||||||
# "virtio-gpu",
|
"virtio-gpu",
|
||||||
|
|
||||||
# An example disk used with ableOS
|
# An example disk used with ableOS
|
||||||
"-device",
|
"-device",
|
||||||
|
@ -49,9 +53,6 @@ lliw = "0.2.0"
|
||||||
spin = "0.5.2"
|
spin = "0.5.2"
|
||||||
vga = "*"
|
vga = "*"
|
||||||
log = "*"
|
log = "*"
|
||||||
# tinypci = "0.1.0"
|
|
||||||
|
|
||||||
tinypci = { git = "https://github.com/trashbyte/tinypci.git", default-features = false }
|
|
||||||
|
|
||||||
pretty-hex = "0.2.1"
|
pretty-hex = "0.2.1"
|
||||||
unicode-width = "0.1.7"
|
unicode-width = "0.1.7"
|
||||||
|
@ -63,10 +64,17 @@ genfs = "0.1.0"
|
||||||
pc-beeper = {git = "https://github.com/AbleOS/pc-beeper"}
|
pc-beeper = {git = "https://github.com/AbleOS/pc-beeper"}
|
||||||
|
|
||||||
|
|
||||||
|
pci = {git="https://gitlab.com/robigalia/pci"}
|
||||||
|
libwasm = {git="https://git.ablecorp.us:443/able/libwasm.git"}
|
||||||
acpi = "4.1.0"
|
acpi = "4.1.0"
|
||||||
|
|
||||||
|
|
||||||
|
# [dependencies.ockam]
|
||||||
|
# version = "0.46.0"
|
||||||
|
# no-default-features = false
|
||||||
|
# features = ["alloc"]
|
||||||
|
|
||||||
|
|
||||||
[dependencies.rdrand]
|
[dependencies.rdrand]
|
||||||
version = "0.8.1"
|
version = "0.8.1"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
wgpu
|
|
||||||
|
|
||||||
write using wgpu and compiles to native/web
|
|
|
@ -1,9 +0,0 @@
|
||||||
Don't keep piling on API shit
|
|
||||||
Good docs are a must!!!!!!!!!!!!
|
|
||||||
No Bloat
|
|
||||||
One thing One Way
|
|
||||||
Bloat makes M!nt sad
|
|
||||||
Have rust-like strings only
|
|
||||||
|
|
||||||
# Don't
|
|
||||||
memory gun
|
|
|
@ -1 +0,0 @@
|
||||||
start custom unicode at E100
|
|
|
@ -1,3 +0,0 @@
|
||||||
user
|
|
||||||
> execute
|
|
||||||
> file system
|
|
|
@ -1,17 +0,0 @@
|
||||||
|
|
||||||
VGA
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pcie
|
|
||||||
gpu
|
|
||||||
amd
|
|
||||||
ati
|
|
||||||
set_red
|
|
||||||
ssd
|
|
|
@ -2,6 +2,8 @@ use alloc::string::String;
|
||||||
|
|
||||||
use crate::character_device::CharacterDevice;
|
use crate::character_device::CharacterDevice;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
|
||||||
pub struct DevNull;
|
pub struct DevNull;
|
||||||
|
|
||||||
impl CharacterDevice for DevNull {
|
impl CharacterDevice for DevNull {
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::character_device::CharacterDevice;
|
use crate::character_device::CharacterDevice;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct DevUnicode {
|
pub struct DevUnicode {
|
||||||
pub next_write_char: char,
|
pub next_write_char: char,
|
||||||
pub next_read_char: char,
|
pub next_read_char: char,
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::character_device::CharacterDevice;
|
use crate::character_device::CharacterDevice;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct DevZero;
|
pub struct DevZero;
|
||||||
|
|
||||||
impl CharacterDevice for DevZero {
|
impl CharacterDevice for DevZero {
|
3
ableos/src/devices/character_devs/mod.rs
Normal file
3
ableos/src/devices/character_devs/mod.rs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
pub mod dev_null;
|
||||||
|
pub mod dev_unicode;
|
||||||
|
pub mod dev_zero;
|
|
@ -1,19 +1,20 @@
|
||||||
|
pub mod character_devs;
|
||||||
|
pub mod pci_inner;
|
||||||
|
|
||||||
use alloc::{
|
use alloc::{
|
||||||
boxed::Box,
|
boxed::Box,
|
||||||
string::{String, ToString},
|
string::{String, ToString},
|
||||||
};
|
};
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
|
use pci::PCIDevice;
|
||||||
|
|
||||||
use crate::character_device::CharacterDevice;
|
use crate::character_device::CharacterDevice;
|
||||||
|
|
||||||
pub mod dev_null;
|
|
||||||
pub mod dev_unicode;
|
|
||||||
pub mod dev_zero;
|
|
||||||
|
|
||||||
// FIXME: This is a hack to hold a device.
|
// FIXME: This is a hack to hold a device.
|
||||||
|
// #[derive(Debug)]
|
||||||
pub enum Device {
|
pub enum Device {
|
||||||
CharacterDevice(Box<dyn CharacterDevice>),
|
Character(Box<dyn CharacterDevice>),
|
||||||
// BlockDevice,
|
Pci(PCIDevice),
|
||||||
}
|
}
|
||||||
unsafe impl Sync for Device {}
|
unsafe impl Sync for Device {}
|
||||||
unsafe impl Send for Device {}
|
unsafe impl Send for Device {}
|
||||||
|
@ -21,16 +22,25 @@ unsafe impl Send for Device {}
|
||||||
pub struct DeviceTable {
|
pub struct DeviceTable {
|
||||||
pub devices: HashMap<String, Device>,
|
pub devices: HashMap<String, Device>,
|
||||||
}
|
}
|
||||||
use self::dev_null::DevNull;
|
use self::character_devs::{dev_null::DevNull, dev_unicode::DevUnicode, dev_zero::DevZero};
|
||||||
pub use self::Device::*;
|
pub use self::Device::*;
|
||||||
impl DeviceTable {
|
impl DeviceTable {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let mut table: HashMap<String, Device> = HashMap::new();
|
let mut table: HashMap<String, Device> = HashMap::new();
|
||||||
table.insert("null".to_string(), CharacterDevice(Box::new(DevNull)));
|
table.insert("null".to_string(), Character(Box::new(DevNull)));
|
||||||
|
table.insert("zero".to_string(), Character(Box::new(DevZero)));
|
||||||
|
table.insert(
|
||||||
|
"unicode".to_string(),
|
||||||
|
Character(Box::new(DevUnicode {
|
||||||
|
next_write_char: 0x00 as char,
|
||||||
|
next_read_char: 0x00 as char,
|
||||||
|
})),
|
||||||
|
);
|
||||||
DeviceTable { devices: table }
|
DeviceTable { devices: table }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static::lazy_static!(
|
lazy_static::lazy_static!(
|
||||||
static ref DEVICE_TABLE: DeviceTable = DeviceTable::new();
|
pub static ref DEVICE_TABLE: spin::Mutex<DeviceTable> =
|
||||||
|
spin::Mutex::new(DeviceTable::new());
|
||||||
);
|
);
|
||||||
|
|
56
ableos/src/devices/pci_inner.rs
Normal file
56
ableos/src/devices/pci_inner.rs
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
//! map the DeviceClass via <https://pci-ids.ucw.cz/read/PD>
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
pub enum DeviceClass {
|
||||||
|
UnclassifiedDevice = 0,
|
||||||
|
MassStorageController = 0x01,
|
||||||
|
NetworkController = 0x02,
|
||||||
|
DisplayController = 0x03,
|
||||||
|
MultimediaController = 0x04,
|
||||||
|
MemoryController = 0x05,
|
||||||
|
BridgeDevice = 0x06,
|
||||||
|
|
||||||
|
CommunicationController = 0x07,
|
||||||
|
GenericSystemPeripheral = 0x08,
|
||||||
|
InputDevice = 0x09,
|
||||||
|
DockingStation = 0x0a,
|
||||||
|
Processor = 0x0b,
|
||||||
|
SerialBusController = 0x0c,
|
||||||
|
WirelessController = 0x0d,
|
||||||
|
IntelligentController = 0x0e,
|
||||||
|
SatelliteCommunicationController = 0x0f,
|
||||||
|
EncryptionController = 0x10,
|
||||||
|
SignalProcessingController = 0x11,
|
||||||
|
|
||||||
|
// 14
|
||||||
|
// 15
|
||||||
|
// 16
|
||||||
|
Coprocessor = 40,
|
||||||
|
// 64
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DeviceClass {
|
||||||
|
pub fn from_u8(val: u8) -> DeviceClass {
|
||||||
|
match val {
|
||||||
|
0x00 => DeviceClass::UnclassifiedDevice,
|
||||||
|
0x01 => DeviceClass::MassStorageController,
|
||||||
|
0x02 => DeviceClass::NetworkController,
|
||||||
|
0x03 => DeviceClass::DisplayController,
|
||||||
|
0x04 => DeviceClass::MultimediaController,
|
||||||
|
0x05 => DeviceClass::MemoryController,
|
||||||
|
0x06 => DeviceClass::BridgeDevice,
|
||||||
|
0x07 => DeviceClass::CommunicationController,
|
||||||
|
0x08 => DeviceClass::GenericSystemPeripheral,
|
||||||
|
0x09 => DeviceClass::InputDevice,
|
||||||
|
0x0a => DeviceClass::DockingStation,
|
||||||
|
0x0b => DeviceClass::Processor,
|
||||||
|
0x0c => DeviceClass::SerialBusController,
|
||||||
|
0x0d => DeviceClass::WirelessController,
|
||||||
|
0x0e => DeviceClass::IntelligentController,
|
||||||
|
0x0f => DeviceClass::SatelliteCommunicationController,
|
||||||
|
0x10 => DeviceClass::EncryptionController,
|
||||||
|
0x11 => DeviceClass::SignalProcessingController,
|
||||||
|
0x40 => DeviceClass::Coprocessor,
|
||||||
|
_ => DeviceClass::UnclassifiedDevice,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -32,6 +32,7 @@ pub mod arch;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod print;
|
pub mod print;
|
||||||
|
pub mod devices;
|
||||||
pub mod wasm_jumploader;
|
pub mod wasm_jumploader;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -89,9 +90,9 @@ pub use alias_table::*;
|
||||||
|
|
||||||
pub mod tests;
|
pub mod tests;
|
||||||
pub use tests::*;
|
pub use tests::*;
|
||||||
pub mod syscalls;
|
/*pub mod syscalls;
|
||||||
pub use syscalls::*;
|
pub use syscalls::*;
|
||||||
|
*/
|
||||||
pub mod scratchpad;
|
pub mod scratchpad;
|
||||||
pub use scratchpad::*;
|
pub use scratchpad::*;
|
||||||
pub mod filesystem;
|
pub mod filesystem;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
//! The scheduler is also responsible for choosing the priority of a process.
|
//! The scheduler is also responsible for choosing the priority of a process.
|
||||||
//! The scheduler is responsible for choosing which process to execute next.
|
//! The scheduler is responsible for choosing which process to execute next.
|
||||||
|
|
||||||
use alloc::vec::Vec;
|
use alloc::{string::ToString, vec::Vec};
|
||||||
|
|
||||||
pub mod capabilities;
|
pub mod capabilities;
|
||||||
pub mod proc;
|
pub mod proc;
|
||||||
|
@ -120,6 +120,7 @@ impl Scheduler {
|
||||||
password: generate_process_pass(),
|
password: generate_process_pass(),
|
||||||
capabilities: Capabilities::empty(),
|
capabilities: Capabilities::empty(),
|
||||||
priority,
|
priority,
|
||||||
|
working_dir: "todo!()".to_string(),
|
||||||
};
|
};
|
||||||
// self.free_pid.0 += 1;
|
// self.free_pid.0 += 1;
|
||||||
// self.list.push(process);
|
// self.list.push(process);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use alloc::vec::Vec;
|
use alloc::{string::ToString, vec::Vec};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
capabilities::Capabilities,
|
capabilities::Capabilities,
|
||||||
|
@ -70,6 +70,7 @@ impl Scheduler {
|
||||||
password: generate_process_pass(),
|
password: generate_process_pass(),
|
||||||
priority,
|
priority,
|
||||||
capabilities: Capabilities::empty(),
|
capabilities: Capabilities::empty(),
|
||||||
|
working_dir: "todo!()".to_string(),
|
||||||
};
|
};
|
||||||
self.free_pid.0 += 1;
|
self.free_pid.0 += 1;
|
||||||
process
|
process
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
//! Process definition and general utilities surrounding them
|
//! Process definition and general utilities surrounding them
|
||||||
|
|
||||||
|
use alloc::string::String;
|
||||||
|
|
||||||
use super::{capabilities::Capabilities, Priority};
|
use super::{capabilities::Capabilities, Priority};
|
||||||
|
|
||||||
/// Process Identification
|
/// Process Identification
|
||||||
|
@ -15,11 +17,13 @@ pub struct Process {
|
||||||
|
|
||||||
/// Process password
|
/// Process password
|
||||||
pub password: u128,
|
pub password: u128,
|
||||||
|
|
||||||
///
|
///
|
||||||
pub capabilities: Capabilities,
|
pub capabilities: Capabilities,
|
||||||
/// A process's priority
|
/// A process's priority
|
||||||
pub priority: Priority,
|
pub priority: Priority,
|
||||||
|
|
||||||
|
///
|
||||||
|
pub working_dir: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Process {}
|
impl Process {}
|
||||||
|
|
|
@ -1,27 +1,88 @@
|
||||||
use alloc::{string::String, vec::Vec};
|
use {
|
||||||
use genfs::{Fs, OpenOptions};
|
crate::{
|
||||||
|
devices::{pci_inner::DeviceClass, Device, DEVICE_TABLE},
|
||||||
use crate::{filesystem::FILE_SYSTEM, wasm_jumploader::interp};
|
proc::PID,
|
||||||
|
wasm_jumploader::interp,
|
||||||
|
},
|
||||||
|
alloc::{format, vec::Vec},
|
||||||
|
pci::PortOps,
|
||||||
|
};
|
||||||
|
|
||||||
/// Experimental scratchpad for testing.
|
/// Experimental scratchpad for testing.
|
||||||
pub fn scratchpad() {
|
pub fn scratchpad() {
|
||||||
let fs = &*FILE_SYSTEM.lock();
|
let mut dev_list = Vec::new();
|
||||||
let file = fs
|
let bus_scan;
|
||||||
.open(b"/home/able/kernel.md", OpenOptions::new().read(true))
|
unsafe {
|
||||||
.unwrap();
|
bus_scan = pci::scan_bus(&PciIO {}, pci::CSpaceAccessMethod::IO);
|
||||||
|
}
|
||||||
|
for dev in bus_scan {
|
||||||
|
dev_list.push(dev);
|
||||||
|
}
|
||||||
|
|
||||||
let mut file_bytes = Vec::new();
|
let device_table = &mut *DEVICE_TABLE.lock();
|
||||||
file.read_to_end(&mut file_bytes).unwrap();
|
|
||||||
|
|
||||||
let string = String::from_utf8_lossy(&file_bytes);
|
for x in dev_list {
|
||||||
|
let device_name = format!("{:?}-{}", DeviceClass::from_u8(x.id.class), x.id.device_id);
|
||||||
|
|
||||||
print!("{}", string);
|
device_table.devices.insert(device_name, Device::Pci(x));
|
||||||
|
}
|
||||||
|
|
||||||
let pci_list = tinypci::brute_force_scan();
|
for (key, _value) in device_table.devices.iter() {
|
||||||
|
debug!("{}", key);
|
||||||
for pci in pci_list {
|
|
||||||
info!("{}", pci);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interp();
|
interp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct PciIO {}
|
||||||
|
|
||||||
|
impl PortOps for PciIO {
|
||||||
|
unsafe fn read8(&self, port: u16) -> u8 {
|
||||||
|
cpuio::inb(port as u16)
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn read16(&self, port: u16) -> u16 {
|
||||||
|
cpuio::inw(port as u16)
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn read32(&self, port: u16) -> u32 {
|
||||||
|
cpuio::inl(port as u16)
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn write8(&self, port: u16, val: u8) {
|
||||||
|
cpuio::outb(val, port as u16);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn write16(&self, port: u16, val: u16) {
|
||||||
|
cpuio::outw(val, port as u16);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn write32(&self, port: u16, val: u32) {
|
||||||
|
cpuio::outl(val, port as u16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// An experimental process message format
|
||||||
|
pub struct ProcessMessage {
|
||||||
|
pub to_pid: PID,
|
||||||
|
pub from_pid: PID,
|
||||||
|
pub message: [u8; 2048],
|
||||||
|
|
||||||
|
pub sender_time: SecondsTime,
|
||||||
|
}
|
||||||
|
//
|
||||||
|
use libwasm::syscalls::time_calls::SecondsTime;
|
||||||
|
|
||||||
|
impl ProcessMessage {
|
||||||
|
pub fn new(to_pid: PID, from_pid: PID, message: [u8; 2048]) -> Self {
|
||||||
|
ProcessMessage {
|
||||||
|
to_pid,
|
||||||
|
from_pid,
|
||||||
|
message,
|
||||||
|
sender_time: SecondsTime {
|
||||||
|
seconds: 0,
|
||||||
|
milliseconds: 0,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
//! File system related system calls.
|
|
||||||
|
|
||||||
/// Temporary representation of a file path
|
|
||||||
pub type Path = *const u8;
|
|
||||||
|
|
||||||
/// Remove a Directory from the filesystem
|
|
||||||
///
|
|
||||||
/// # Arguments
|
|
||||||
/// * `full_path` - The full path of the directory to remove
|
|
||||||
/// * `force` - Whether to remove the directory even if it is not empty
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn remove_directory(path: Path, force_delete: bool) {
|
|
||||||
unimplemented!();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a new directory at the given path
|
|
||||||
///
|
|
||||||
/// # Arguments
|
|
||||||
/// * `full_path` - The full path of the directory to create
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn create_directory(path: Path) -> FSReturns {
|
|
||||||
unimplemented!();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[repr(C)]
|
|
||||||
/// A return used by the file related system calls
|
|
||||||
pub enum FSReturns {
|
|
||||||
/// The system call was successful
|
|
||||||
Ok,
|
|
||||||
|
|
||||||
/// The directory can not be created
|
|
||||||
DirectoryCouldNotBeCreated,
|
|
||||||
/// The directory could not be removed
|
|
||||||
DirectoryCouldNotBeRemoved,
|
|
||||||
///
|
|
||||||
FileCouldNotBeCreated,
|
|
||||||
///
|
|
||||||
FileCouldNotBeRemoved,
|
|
||||||
/// The file could not be opened
|
|
||||||
FileCouldNotBeOpened,
|
|
||||||
///
|
|
||||||
FileCouldNotBeClosed,
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
#![deny(missing_docs)]
|
|
||||||
//! The module of syscalls.
|
|
||||||
|
|
||||||
use crate::proc::PID;
|
|
||||||
|
|
||||||
pub mod file_calls;
|
|
||||||
pub mod time_calls;
|
|
||||||
|
|
||||||
#[repr(C)]
|
|
||||||
/// Signals that can be sent to a process
|
|
||||||
pub enum Signals {
|
|
||||||
/// Terminate the process
|
|
||||||
Terminate,
|
|
||||||
/// Shutdown the process and allow it to shutdown cleanly
|
|
||||||
Quit,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Send a signal to a process
|
|
||||||
///
|
|
||||||
/// # Arguments
|
|
||||||
///
|
|
||||||
/// * `pid` - The PID of the process to send the signal to
|
|
||||||
/// * `signal` - The signal to send
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn send_signal(pid: PID, signal: Signals) {
|
|
||||||
unimplemented!("send_signal");
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
//! Time related system calls.
|
|
||||||
|
|
||||||
use core::panic;
|
|
||||||
|
|
||||||
/// Seconds and milliseconds since the Unix epoch.
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct SecondsTime {
|
|
||||||
seconds: u64,
|
|
||||||
milliseconds: u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Sleep the calling process for the given number of milliseconds
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn sleep(time: SecondsTime) {
|
|
||||||
panic!("sleep is not implemented yet");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
/// Get the current time in seconds, milliseconds
|
|
||||||
pub extern "C" fn get_time() -> SecondsTime {
|
|
||||||
panic!("get_time not implemented");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
/// Set the current time in seconds, milliseconds
|
|
||||||
pub extern "C" fn set_time(time: SecondsTime) {
|
|
||||||
panic!("set_time not implemented");
|
|
||||||
}
|
|
|
@ -4,9 +4,7 @@ use wasmi::{
|
||||||
Signature, Trap, ValueType,
|
Signature, Trap, ValueType,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct HostExternals {
|
pub struct HostExternals {}
|
||||||
// counter: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
const ADD_FUNC_INDEX: usize = 0;
|
const ADD_FUNC_INDEX: usize = 0;
|
||||||
|
|
||||||
|
@ -21,7 +19,7 @@ impl Externals for HostExternals {
|
||||||
let a: u32 = args.nth_checked(0)?;
|
let a: u32 = args.nth_checked(0)?;
|
||||||
let b: u32 = args.nth_checked(1)?;
|
let b: u32 = args.nth_checked(1)?;
|
||||||
let result = a + b;
|
let result = a + b;
|
||||||
|
println!("SYSCALL: {} + {} = {}", a, b, result);
|
||||||
Ok(Some(RuntimeValue::I32(result as i32)))
|
Ok(Some(RuntimeValue::I32(result as i32)))
|
||||||
}
|
}
|
||||||
_ => panic!("Unimplemented function at {}", index),
|
_ => panic!("Unimplemented function at {}", index),
|
||||||
|
|
|
@ -5,21 +5,22 @@ extern crate wasmi;
|
||||||
|
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
use genfs::{Fs, OpenOptions};
|
use genfs::{Fs, OpenOptions};
|
||||||
use wasmi::{ImportsBuilder, ModuleInstance, NopExternals};
|
use wasmi::{ImportsBuilder, ModuleInstance};
|
||||||
|
|
||||||
use crate::{filesystem::FILE_SYSTEM, wasm_jumploader::host_functions::HostExternals};
|
use crate::{filesystem::FILE_SYSTEM, wasm_jumploader::host_functions::HostExternals};
|
||||||
|
|
||||||
pub fn interp() {
|
pub fn interp() {
|
||||||
|
info!("Interpreting...");
|
||||||
let fs = &*FILE_SYSTEM.lock();
|
let fs = &*FILE_SYSTEM.lock();
|
||||||
|
info!("Got filesystem");
|
||||||
let file = fs
|
let file = fs
|
||||||
.open(b"/home/able/test.wasm", OpenOptions::new().read(true))
|
.open(b"/home/able/bins/test.wasm", OpenOptions::new().read(true))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let mut wasm_binary = Vec::new();
|
let mut wasm_binary = Vec::new();
|
||||||
|
|
||||||
let ret = file.read_to_end(&mut wasm_binary).unwrap();
|
let ret = file.read_to_end(&mut wasm_binary).unwrap();
|
||||||
|
info!("Binary size {}", ret);
|
||||||
// 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");
|
||||||
|
|
||||||
|
@ -35,5 +36,5 @@ pub fn interp() {
|
||||||
.invoke_export("start", &[], &mut HostExternals {})
|
.invoke_export("start", &[], &mut HostExternals {})
|
||||||
.expect("failed to execute export");
|
.expect("failed to execute export");
|
||||||
|
|
||||||
info!("collected wasm return value: {:?}", ret);
|
println!("collected wasm return value: {:?}", ret);
|
||||||
}
|
}
|
||||||
|
|
8
userland/aos_wasm_stress_test/Cargo.lock
generated
8
userland/aos_wasm_stress_test/Cargo.lock
generated
|
@ -5,3 +5,11 @@ version = 3
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aos_wasm_stress_test"
|
name = "aos_wasm_stress_test"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"libwasm",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libwasm"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://git.ablecorp.us/able/libwasm.git#502187e8734b54df3c6cae2baf2315539a3ec49b"
|
||||||
|
|
|
@ -6,3 +6,4 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
libwasm = {git="https://git.ablecorp.us:443/able/libwasm.git"}
|
|
@ -2,21 +2,11 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![deny(improper_ctypes)]
|
#![deny(improper_ctypes)]
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
mod libwasm;
|
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
fn start() -> i32 {
|
fn start() -> i32 {
|
||||||
let ret = unsafe { add(1, 2) };
|
let ret = unsafe { add(1, 2) };
|
||||||
|
|
||||||
info!(b"hello");
|
|
||||||
|
|
||||||
ret as i32
|
ret as i32
|
||||||
}
|
}
|
||||||
|
|
||||||
use core::panic::PanicInfo;
|
use libwasm::syscalls::add;
|
||||||
|
|
||||||
#[panic_handler]
|
|
||||||
fn panic(_info: &PanicInfo) -> ! {
|
|
||||||
loop {}
|
|
||||||
}
|
|
||||||
|
|
Binary file not shown.
Loading…
Reference in a new issue