use { crate::{ devices::{pci_inner::DeviceClass, Device, DEVICE_TABLE}, proc::PID, wasm_jumploader::interp, }, alloc::{format, vec::Vec}, pci::PortOps, }; /// Experimental scratchpad for testing. pub fn scratchpad() { let mut dev_list = Vec::new(); let bus_scan; unsafe { bus_scan = pci::scan_bus(&PciIO {}, pci::CSpaceAccessMethod::IO); } for dev in bus_scan { dev_list.push(dev); } let device_table = &mut *DEVICE_TABLE.lock(); for x in dev_list { let device_name = format!("{:?}-{}", DeviceClass::from_u8(x.id.class), x.id.device_id); device_table.devices.insert(device_name, Device::Pci(x)); } for (key, _value) in device_table.devices.iter() { debug!("{}", key); } // interp(); rhai_shell(); } 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, }, } } } */ pub fn rhai_shell() { let mut engine = rhai::Engine::new(); let ret = engine.eval::("1 + 2"); match ret { Ok(x) => println!("{}", x), Err(e) => println!("{}", e), } loop {} } lazy_static::lazy_static!( pub static ref KEYBUFF: spin::Mutex> = spin::Mutex::new( Vec::new()) ; ); use alloc::string::String; use crate::arch::sloop;