mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-21 04:46:31 +00:00
mmio buddy新增guard,把映射的职责交由其守卫进行处理,并且守卫被drop的时候自动释放内存 (#346)
* mmio buddy新增guard,把映射的职责交由其守卫进行处理,并且守卫被drop的时候自动释放内存
This commit is contained in:
@ -2,7 +2,10 @@ pub mod x86_64;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub use self::x86_64::*; //公开x86_64架构下的函数,使外界接口统一
|
||||
|
||||
use crate::driver::pci::pci::{BusDeviceFunction, PciAddr, PciError, PciRoot, SegmentGroupNumber};
|
||||
use crate::{
|
||||
driver::pci::pci::{BusDeviceFunction, PciAddr, PciError, PciRoot, SegmentGroupNumber},
|
||||
mm::PhysAddr,
|
||||
};
|
||||
|
||||
/// TraitPciArch Pci架构相关函数,任何架构都应独立实现trait里的函数
|
||||
pub trait TraitPciArch {
|
||||
@ -19,7 +22,7 @@ pub trait TraitPciArch {
|
||||
/// @brief PCI域地址到存储器域地址的转换,x86_64架构为一一对应
|
||||
/// @param address PCI域地址
|
||||
/// @return usize 转换结果
|
||||
fn address_pci_to_physical(pci_address: PciAddr) -> usize;
|
||||
fn address_pci_to_physical(pci_address: PciAddr) -> PhysAddr;
|
||||
/// @brief 获取Segement的root地址,x86_64架构为acpi mcfg表中读取
|
||||
/// @param segement 组id
|
||||
/// @return Result<PciRoot, PciError> 转换结果或出错原因
|
||||
|
@ -7,6 +7,7 @@ use crate::driver::pci::pci::{
|
||||
use crate::include::bindings::bindings::{
|
||||
acpi_get_MCFG, acpi_iter_SDT, acpi_system_description_table_header_t, io_in32, io_out32,
|
||||
};
|
||||
use crate::mm::PhysAddr;
|
||||
|
||||
use core::ffi::c_void;
|
||||
use core::ptr::NonNull;
|
||||
@ -40,8 +41,8 @@ impl TraitPciArch for X86_64PciArch {
|
||||
}
|
||||
}
|
||||
|
||||
fn address_pci_to_physical(pci_address: PciAddr) -> usize {
|
||||
return pci_address.data();
|
||||
fn address_pci_to_physical(pci_address: PciAddr) -> PhysAddr {
|
||||
return PhysAddr::new(pci_address.data());
|
||||
}
|
||||
|
||||
fn ecam_root(segement: SegmentGroupNumber) -> Result<PciRoot, PciError> {
|
||||
@ -61,8 +62,10 @@ impl TraitPciArch for X86_64PciArch {
|
||||
for segmentgroupconfiguration in outcome {
|
||||
if segmentgroupconfiguration.segement_group_number == segement {
|
||||
return Ok(PciRoot {
|
||||
physical_address_base: segmentgroupconfiguration.base_address,
|
||||
mmio_base: None,
|
||||
physical_address_base: PhysAddr::new(
|
||||
segmentgroupconfiguration.base_address as usize,
|
||||
),
|
||||
mmio_guard: None,
|
||||
segement_group_number: segement,
|
||||
bus_begin: segmentgroupconfiguration.bus_begin,
|
||||
bus_end: segmentgroupconfiguration.bus_end,
|
||||
|
Reference in New Issue
Block a user