Dump device BARs in logs
This commit is contained in:
parent
09ace0dfed
commit
96798efb7e
25
src/main.rs
25
src/main.rs
@ -8,7 +8,7 @@ use device_types::{Class, InvalidClass};
|
||||
use pci_rpc::Server;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use spin::Mutex;
|
||||
use x86_64::instructions::port::{Port, PortWriteOnly};
|
||||
use x86_64::{instructions::port::{Port, PortWriteOnly}, registers::control};
|
||||
|
||||
pub mod device_types;
|
||||
|
||||
@ -374,6 +374,29 @@ fn main() {
|
||||
device.common.header_type,
|
||||
)
|
||||
).unwrap();
|
||||
if let &ConfigTypeSpecific::Type0(cfg_type0) = &device.type_specific {
|
||||
let accessor = ConfigAccessor::new(device.bus, device.device, device.function);
|
||||
for (i, &bar) in cfg_type0.bars.iter().enumerate() {
|
||||
if bar == 0x0 {
|
||||
continue;
|
||||
}
|
||||
let bar_idx = (i + 0x4) as u8;
|
||||
accessor.write(bar_idx, 0xFFFF_FFFF);
|
||||
let bar_tmp = accessor.read(bar_idx);
|
||||
let info_bits = if bar & 0x1 == 1 {
|
||||
bar_tmp & !0x3
|
||||
} else {
|
||||
bar_tmp & !0xF
|
||||
};
|
||||
let size = !(info_bits) + 1;
|
||||
accessor.write(bar_idx, bar);
|
||||
if bar & 0x1 == 1 {
|
||||
syslog_client.send_text_message("pci", format!("BAR {}: IO {:#x}, size {:#x}", i, bar & (!0x3), size));
|
||||
} else {
|
||||
syslog_client.send_text_message("pci", format!("BAR {}: MEM {:#x}, size {:#x}", i, bar & (!0xF), size));
|
||||
}
|
||||
}
|
||||
}
|
||||
let driver = config
|
||||
.mappings
|
||||
.iter()
|
||||
|
Loading…
Reference in New Issue
Block a user