1
0
Fork 0
forked from koniifer/ableos
ableos-framebuffer/ableos/src/scratchpad.rs

82 lines
1.8 KiB
Rust
Raw Normal View History

2022-02-22 18:15:16 -06:00
use core::arch::asm;
use alloc::string::{String, ToString};
use cpuio::outb;
use crate::{absi::colorify, messaging::ProcessMessage, rhai_shell::rhai_shell};
2022-02-19 08:46:11 -06:00
2022-02-12 03:25:02 -06:00
use {
crate::{
devices::{pci_inner::DeviceClass, Device, DEVICE_TABLE},
proc::PID,
wasm_jumploader::interp,
},
alloc::{format, vec::Vec},
pci::PortOps,
};
2022-02-08 03:01:29 -06:00
/// Experimental scratchpad for testing.
pub fn scratchpad() {
2022-02-12 03:25:02 -06:00
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);
}
2022-02-08 03:01:29 -06:00
2022-02-12 03:25:02 -06:00
let device_table = &mut *DEVICE_TABLE.lock();
2022-02-08 03:01:29 -06:00
2022-02-12 03:25:02 -06:00
for x in dev_list {
let device_name = format!("{:?}-{}", DeviceClass::from_u8(x.id.class), x.id.device_id);
2022-02-08 04:13:53 -06:00
2022-02-18 02:24:10 -06:00
device_table
.devices
.insert(device_name.clone(), Device::Pci(x));
}
2022-02-08 04:13:53 -06:00
2022-02-18 02:24:10 -06:00
/*
for (key, _value) in device_table.devices.iter() {
debug!("{}", key);
}
*/
2022-02-17 04:05:56 -06:00
// interp();
2022-02-21 07:17:16 -06:00
// crate::experiments::absi::colorify();
2022-02-22 18:15:16 -06:00
let message = "Hello, world!";
let xyz = ProcessMessage::new_from_string(PID(123), PID(0), message.to_string());
// print!("{:?}", xyz);
2022-02-18 12:12:07 -06:00
rhai_shell();
2022-02-08 04:13:53 -06:00
}
2022-02-12 03:25:02 -06:00
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);
}
}