Add DMAR device definition
This commit is contained in:
parent
2095de83e8
commit
25dc44b348
77
arch/x86_64/src/acpi/dmar/drhd.rs
Normal file
77
arch/x86_64/src/acpi/dmar/drhd.rs
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
#[repr(packed)]
|
||||||
|
pub struct DrhdFault {
|
||||||
|
pub sts: u32,
|
||||||
|
pub ctrl: u32,
|
||||||
|
pub data: u32,
|
||||||
|
pub addr: [u32; 2],
|
||||||
|
_rsv: [u64; 2],
|
||||||
|
pub log: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[repr(packed)]
|
||||||
|
pub struct DrhdProtectedMemory {
|
||||||
|
pub en: u32,
|
||||||
|
pub low_base: u32,
|
||||||
|
pub low_limit: u32,
|
||||||
|
pub high_base: u64,
|
||||||
|
pub high_limit: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[repr(packed)]
|
||||||
|
pub struct DrhdInvalidation {
|
||||||
|
pub queue_head: u64,
|
||||||
|
pub queue_tail: u64,
|
||||||
|
pub queue_addr: u64,
|
||||||
|
_rsv: u32,
|
||||||
|
pub cmpl_sts: u32,
|
||||||
|
pub cmpl_ctrl: u32,
|
||||||
|
pub cmpl_data: u32,
|
||||||
|
pub cmpl_addr: [u32; 2],
|
||||||
|
}
|
||||||
|
|
||||||
|
#[repr(packed)]
|
||||||
|
pub struct DrhdPageRequest {
|
||||||
|
pub queue_head: u64,
|
||||||
|
pub queue_tail: u64,
|
||||||
|
pub queue_addr: u64,
|
||||||
|
_rsv: u32,
|
||||||
|
pub sts: u32,
|
||||||
|
pub ctrl: u32,
|
||||||
|
pub data: u32,
|
||||||
|
pub addr: [u32; 2],
|
||||||
|
}
|
||||||
|
|
||||||
|
#[repr(packed)]
|
||||||
|
pub struct DrhdMtrrVariable {
|
||||||
|
pub base: u64,
|
||||||
|
pub mask: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[repr(packed)]
|
||||||
|
pub struct DrhdMtrr {
|
||||||
|
pub cap: u64,
|
||||||
|
pub def_type: u64,
|
||||||
|
pub fixed: [u64; 11],
|
||||||
|
pub variable: [DrhdMtrrVariable; 10],
|
||||||
|
}
|
||||||
|
|
||||||
|
#[repr(packed)]
|
||||||
|
pub struct Drhd {
|
||||||
|
pub version: u32,
|
||||||
|
_rsv: u32,
|
||||||
|
pub cap: u64,
|
||||||
|
pub ext_cap: u64,
|
||||||
|
pub gl_cmd: u32,
|
||||||
|
pub gl_sts: u32,
|
||||||
|
pub root_table: u64,
|
||||||
|
pub ctx_cmd: u64,
|
||||||
|
_rsv1: u32,
|
||||||
|
pub fault: DrhdFault,
|
||||||
|
_rsv2: u32,
|
||||||
|
pub pm: DrhdProtectedMemory,
|
||||||
|
pub invl: DrhdInvalidation,
|
||||||
|
_rsv3: u64,
|
||||||
|
pub intr_table: u64,
|
||||||
|
pub page_req: DrhdPageRequest,
|
||||||
|
pub mtrr: DrhdMtrr,
|
||||||
|
}
|
|
@ -1,6 +1,11 @@
|
||||||
use core::mem;
|
use core::mem;
|
||||||
|
|
||||||
use super::sdt::Sdt;
|
use super::sdt::Sdt;
|
||||||
|
use self::drhd::Drhd;
|
||||||
|
use memory::Frame;
|
||||||
|
use paging::{entry, ActivePageTable, PhysicalAddress};
|
||||||
|
|
||||||
|
pub mod drhd;
|
||||||
|
|
||||||
/// The DMA Remapping Table
|
/// The DMA Remapping Table
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -52,6 +57,13 @@ pub struct DmarDrhd {
|
||||||
base: u64,
|
base: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl DmarDrhd {
|
||||||
|
pub fn get(&self, active_table: &mut ActivePageTable) -> &'static mut Drhd {
|
||||||
|
active_table.identity_map(Frame::containing_address(PhysicalAddress::new(self.base as usize)), entry::PRESENT | entry::WRITABLE | entry::NO_EXECUTE);
|
||||||
|
unsafe { &mut *(self.base as *mut Drhd) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// DMAR Reserved Memory Region Reporting
|
/// DMAR Reserved Memory Region Reporting
|
||||||
// TODO: Implement iterator on DmarRmrr scope
|
// TODO: Implement iterator on DmarRmrr scope
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
|
@ -9,7 +9,7 @@ use memory::{allocate_frames, Frame};
|
||||||
use paging::{entry, ActivePageTable, Page, PhysicalAddress, VirtualAddress};
|
use paging::{entry, ActivePageTable, Page, PhysicalAddress, VirtualAddress};
|
||||||
use start::{kstart_ap, CPU_COUNT, AP_READY};
|
use start::{kstart_ap, CPU_COUNT, AP_READY};
|
||||||
|
|
||||||
use self::dmar::Dmar;
|
use self::dmar::{Dmar, DmarEntry};
|
||||||
use self::local_apic::LocalApic;
|
use self::local_apic::LocalApic;
|
||||||
use self::madt::{Madt, MadtEntry};
|
use self::madt::{Madt, MadtEntry};
|
||||||
use self::rsdt::Rsdt;
|
use self::rsdt::Rsdt;
|
||||||
|
@ -140,6 +140,19 @@ pub fn init_sdt(sdt: &'static Sdt, active_table: &mut ActivePageTable) {
|
||||||
|
|
||||||
for dmar_entry in dmar.iter() {
|
for dmar_entry in dmar.iter() {
|
||||||
println!(" {:?}", dmar_entry);
|
println!(" {:?}", dmar_entry);
|
||||||
|
match dmar_entry {
|
||||||
|
DmarEntry::Drhd(dmar_drhd) => {
|
||||||
|
let drhd = dmar_drhd.get(active_table);
|
||||||
|
|
||||||
|
println!("VER: {:X}", drhd.version);
|
||||||
|
println!("CAP: {:X}", drhd.cap);
|
||||||
|
println!("EXT_CAP: {:X}", drhd.ext_cap);
|
||||||
|
println!("GCMD: {:X}", drhd.gl_cmd);
|
||||||
|
println!("GSTS: {:X}", drhd.gl_sts);
|
||||||
|
println!("RT: {:X}", drhd.root_table);
|
||||||
|
},
|
||||||
|
_ => ()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
println!(": Unknown");
|
println!(": Unknown");
|
||||||
|
|
|
@ -600,7 +600,6 @@ impl SchemeMut for Tcpd {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn close(&mut self, file: usize) -> Result<usize> {
|
fn close(&mut self, file: usize) -> Result<usize> {
|
||||||
|
|
||||||
let closed = {
|
let closed = {
|
||||||
let mut handle = self.handles.get_mut(&file).ok_or(Error::new(EBADF))?;
|
let mut handle = self.handles.get_mut(&file).ok_or(Error::new(EBADF))?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue