1
0
Fork 0
forked from AbleOS/ableos
ableos_time/ableos/src/scratchpad.rs

64 lines
1.5 KiB
Rust
Raw Normal View History

2022-02-12 03:25:02 -06:00
use {
crate::{
2022-02-28 06:48:56 -06:00
devices::{
id::match_vendor,
pci_inner::{DeviceClass, PciIO},
Device, DEVICE_TABLE,
},
rhai_shell::rhai_shell,
2022-02-12 03:25:02 -06:00
},
alloc::{format, vec::Vec},
};
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 {
2022-02-28 06:48:56 -06:00
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);
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
/*
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());
2022-02-28 06:48:56 -06:00
print!("{:?}", xyz);
*/
2022-02-12 03:25:02 -06:00
2022-02-28 06:48:56 -06:00
rhai_shell();
2022-02-12 03:25:02 -06:00
}