mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-19 00:46:31 +00:00
把pci驱动的读取acpi mcfg的代码,调整为从新的acpi驱动来读取 (#413)
* 把pci驱动的读取acpi mcfg的代码,调整为从新的acpi驱动来读取
This commit is contained in:
@ -1,17 +1,16 @@
|
||||
use crate::arch::TraitPciArch;
|
||||
use crate::driver::acpi::old::mcfg_find_segment;
|
||||
use crate::driver::acpi::acpi_manager;
|
||||
use crate::driver::pci::pci::{
|
||||
BusDeviceFunction, PciAddr, PciError, PciRoot, SegmentGroupNumber, PORT_PCI_CONFIG_ADDRESS,
|
||||
PORT_PCI_CONFIG_DATA,
|
||||
};
|
||||
use crate::include::bindings::bindings::{
|
||||
acpi_get_MCFG, acpi_iter_SDT, acpi_system_description_table_header_t, io_in32, io_out32,
|
||||
};
|
||||
use crate::include::bindings::bindings::{acpi_get_MCFG, acpi_iter_SDT, io_in32, io_out32};
|
||||
use crate::mm::PhysAddr;
|
||||
|
||||
use acpi::mcfg::Mcfg;
|
||||
use core::ffi::c_void;
|
||||
use core::ptr::NonNull;
|
||||
pub struct X86_64PciArch {}
|
||||
|
||||
pub struct X86_64PciArch;
|
||||
impl TraitPciArch for X86_64PciArch {
|
||||
fn read_config(bus_device_function: &BusDeviceFunction, offset: u8) -> u32 {
|
||||
// 构造pci配置空间地址
|
||||
@ -57,19 +56,22 @@ impl TraitPciArch for X86_64PciArch {
|
||||
}
|
||||
//kdebug!("{}",data);
|
||||
//loop{}
|
||||
let head = NonNull::new(data as *mut acpi_system_description_table_header_t).unwrap();
|
||||
let outcome = unsafe { mcfg_find_segment(head).as_ref() };
|
||||
for segmentgroupconfiguration in outcome {
|
||||
if segmentgroupconfiguration.segement_group_number == segement {
|
||||
return Ok(PciRoot {
|
||||
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,
|
||||
});
|
||||
|
||||
let binding = acpi_manager()
|
||||
.tables()
|
||||
.expect("get acpi_manager table error")
|
||||
.find_table::<Mcfg>();
|
||||
if let Ok(mcfg) = binding {
|
||||
for mcfg_entry in mcfg.entries() {
|
||||
if mcfg_entry.pci_segment_group == segement {
|
||||
return Ok(PciRoot {
|
||||
physical_address_base: PhysAddr::new(mcfg_entry.base_address as usize),
|
||||
mmio_guard: None,
|
||||
segement_group_number: segement,
|
||||
bus_begin: mcfg_entry.bus_number_start,
|
||||
bus_end: mcfg_entry.bus_number_end,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return Err(PciError::SegmentNotFound);
|
||||
|
Reference in New Issue
Block a user