ableos/ableos/src/scratchpad.rs

64 lines
1.5 KiB
Rust

use {
crate::{
devices::{
id::match_vendor,
pci_inner::{DeviceClass, PciIO},
Device, DEVICE_TABLE,
},
rhai_shell::rhai_shell,
},
alloc::{format, vec::Vec},
};
/// 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 vendor_id_name = match_vendor(x.id.vendor_id);
use crate::devices::id::Vendor::*;
match vendor_id_name {
Unknown => {}
Ati => unsafe {
x.cspace_access_method.write32(&PciIO {}, x.loc, 0x0260, 1);
x.cspace_access_method
.write32(&PciIO {}, x.loc, 0x0230, 0x00_ff_0000);
// 0x0260
},
}
let device_name = format!(
"{:?}-{:?}-{}",
vendor_id_name,
DeviceClass::from_u8(x.id.class),
x.id.device_id
);
// println!("{}", device_name);
device_table
.devices
.insert(device_name.clone(), Device::Pci(x));
}
/*
let message = "Hello, world!";
let xyz = ProcessMessage::new_from_string(PID(123), PID(0), message.to_string());
print!("{:?}", xyz);
*/
rhai_shell();
}