mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-18 03:56:42 +00:00
Rename some IOMMU functions
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
65a95cf6b7
commit
c2626da757
@ -77,7 +77,7 @@ pub(super) fn init() {
|
|||||||
let mut iommu_regs = IOMMU_REGS.get().unwrap().lock();
|
let mut iommu_regs = IOMMU_REGS.get().unwrap().lock();
|
||||||
|
|
||||||
// Check if interrupt remapping is supported
|
// Check if interrupt remapping is supported
|
||||||
let extend_cap = iommu_regs.extended_capability();
|
let extend_cap = iommu_regs.read_extended_capability();
|
||||||
if !extend_cap.flags().contains(ExtendedCapabilityFlags::IR) {
|
if !extend_cap.flags().contains(ExtendedCapabilityFlags::IR) {
|
||||||
warn!("[IOMMU] Interrupt remapping not supported");
|
warn!("[IOMMU] Interrupt remapping not supported");
|
||||||
return;
|
return;
|
||||||
|
@ -13,7 +13,7 @@ pub mod queue;
|
|||||||
pub(super) fn init() {
|
pub(super) fn init() {
|
||||||
let mut iommu_regs = IOMMU_REGS.get().unwrap().lock();
|
let mut iommu_regs = IOMMU_REGS.get().unwrap().lock();
|
||||||
if !iommu_regs
|
if !iommu_regs
|
||||||
.extended_capability()
|
.read_extended_capability()
|
||||||
.flags()
|
.flags()
|
||||||
.contains(ExtendedCapabilityFlags::QI)
|
.contains(ExtendedCapabilityFlags::QI)
|
||||||
{
|
{
|
||||||
|
@ -83,7 +83,7 @@ pub struct IommuRegisters {
|
|||||||
impl IommuRegisters {
|
impl IommuRegisters {
|
||||||
/// Version of IOMMU
|
/// Version of IOMMU
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn version(&self) -> IommuVersion {
|
pub fn read_version(&self) -> IommuVersion {
|
||||||
let version = self.version.read();
|
let version = self.version.read();
|
||||||
IommuVersion {
|
IommuVersion {
|
||||||
major: version.get_bits(4..8) as u8,
|
major: version.get_bits(4..8) as u8,
|
||||||
@ -92,17 +92,17 @@ impl IommuRegisters {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Capability of IOMMU
|
/// Capability of IOMMU
|
||||||
pub fn capability(&self) -> Capability {
|
pub fn read_capability(&self) -> Capability {
|
||||||
Capability::new(self.capability.read())
|
Capability::new(self.capability.read())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extended Capability of IOMMU
|
/// Extended Capability of IOMMU
|
||||||
pub fn extended_capability(&self) -> ExtendedCapability {
|
pub fn read_extended_capability(&self) -> ExtendedCapability {
|
||||||
ExtendedCapability::new(self.extended_capability.read())
|
ExtendedCapability::new(self.extended_capability.read())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Global Status of IOMMU
|
/// Global Status of IOMMU
|
||||||
pub fn global_status(&self) -> GlobalStatus {
|
pub fn read_global_status(&self) -> GlobalStatus {
|
||||||
GlobalStatus::from_bits_truncate(self.global_status.read())
|
GlobalStatus::from_bits_truncate(self.global_status.read())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,30 +115,30 @@ impl IommuRegisters {
|
|||||||
self.root_table_address
|
self.root_table_address
|
||||||
.write(root_table.lock().root_paddr() as u64);
|
.write(root_table.lock().root_paddr() as u64);
|
||||||
self.write_global_command(GlobalCommand::SRTP, true);
|
self.write_global_command(GlobalCommand::SRTP, true);
|
||||||
while !self.global_status().contains(GlobalStatus::RTPS) {}
|
while !self.read_global_status().contains(GlobalStatus::RTPS) {}
|
||||||
|
|
||||||
// Enable DMA remapping
|
// Enable DMA remapping
|
||||||
self.write_global_command(GlobalCommand::TE, true);
|
self.write_global_command(GlobalCommand::TE, true);
|
||||||
while !self.global_status().contains(GlobalStatus::TES) {}
|
while !self.read_global_status().contains(GlobalStatus::TES) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Enable Interrupt Remapping with IntRemappingTable
|
/// Enable Interrupt Remapping with IntRemappingTable
|
||||||
pub(super) fn enable_interrupt_remapping(&mut self, table: &'static IntRemappingTable) {
|
pub(super) fn enable_interrupt_remapping(&mut self, table: &'static IntRemappingTable) {
|
||||||
assert!(self
|
assert!(self
|
||||||
.extended_capability()
|
.read_extended_capability()
|
||||||
.flags()
|
.flags()
|
||||||
.contains(ExtendedCapabilityFlags::IR));
|
.contains(ExtendedCapabilityFlags::IR));
|
||||||
// Set interrupt remapping table address
|
// Set interrupt remapping table address
|
||||||
self.interrupt_remapping_table_addr.write(table.encode());
|
self.interrupt_remapping_table_addr.write(table.encode());
|
||||||
self.write_global_command(GlobalCommand::SIRTP, true);
|
self.write_global_command(GlobalCommand::SIRTP, true);
|
||||||
while !self.global_status().contains(GlobalStatus::IRTPS) {}
|
while !self.read_global_status().contains(GlobalStatus::IRTPS) {}
|
||||||
|
|
||||||
// Enable Interrupt Remapping
|
// Enable Interrupt Remapping
|
||||||
self.write_global_command(GlobalCommand::IRE, true);
|
self.write_global_command(GlobalCommand::IRE, true);
|
||||||
while !self.global_status().contains(GlobalStatus::IRES) {}
|
while !self.read_global_status().contains(GlobalStatus::IRES) {}
|
||||||
|
|
||||||
// Invalidate interrupt cache
|
// Invalidate interrupt cache
|
||||||
if self.global_status().contains(GlobalStatus::QIES) {
|
if self.read_global_status().contains(GlobalStatus::QIES) {
|
||||||
let mut queue = QUEUE.get().unwrap().lock();
|
let mut queue = QUEUE.get().unwrap().lock();
|
||||||
|
|
||||||
// Construct global invalidation of interrupt cache and invalidation wait.
|
// Construct global invalidation of interrupt cache and invalidation wait.
|
||||||
@ -158,15 +158,15 @@ impl IommuRegisters {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Disable Compatibility format interrupts
|
// Disable Compatibility format interrupts
|
||||||
if self.global_status().contains(GlobalStatus::CFIS) {
|
if self.read_global_status().contains(GlobalStatus::CFIS) {
|
||||||
self.write_global_command(GlobalCommand::CFI, false);
|
self.write_global_command(GlobalCommand::CFI, false);
|
||||||
while self.global_status().contains(GlobalStatus::CFIS) {}
|
while self.read_global_status().contains(GlobalStatus::CFIS) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn enable_queued_invalidation(&mut self, queue: &Queue) {
|
pub(super) fn enable_queued_invalidation(&mut self, queue: &Queue) {
|
||||||
assert!(self
|
assert!(self
|
||||||
.extended_capability()
|
.read_extended_capability()
|
||||||
.flags()
|
.flags()
|
||||||
.contains(ExtendedCapabilityFlags::QI));
|
.contains(ExtendedCapabilityFlags::QI));
|
||||||
self.invalidate.queue_tail.write(0);
|
self.invalidate.queue_tail.write(0);
|
||||||
@ -204,7 +204,7 @@ impl IommuRegisters {
|
|||||||
|
|
||||||
// Enable Queued invalidation
|
// Enable Queued invalidation
|
||||||
self.write_global_command(GlobalCommand::QIE, true);
|
self.write_global_command(GlobalCommand::QIE, true);
|
||||||
while !self.global_status().contains(GlobalStatus::QIES) {}
|
while !self.read_global_status().contains(GlobalStatus::QIES) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn global_invalidation(&mut self) {
|
fn global_invalidation(&mut self) {
|
||||||
@ -282,10 +282,10 @@ impl IommuRegisters {
|
|||||||
};
|
};
|
||||||
|
|
||||||
debug!("IOMMU registers:{:#x?}", iommu_regs);
|
debug!("IOMMU registers:{:#x?}", iommu_regs);
|
||||||
debug!("IOMMU capability:{:#x?}", iommu_regs.capability());
|
debug!("IOMMU capability:{:#x?}", iommu_regs.read_capability());
|
||||||
debug!(
|
debug!(
|
||||||
"IOMMU extend capability:{:#x?}",
|
"IOMMU extend capability:{:#x?}",
|
||||||
iommu_regs.extended_capability()
|
iommu_regs.read_extended_capability()
|
||||||
);
|
);
|
||||||
|
|
||||||
Some(iommu_regs)
|
Some(iommu_regs)
|
||||||
|
Reference in New Issue
Block a user