4
1
mirror of https://github.com/DragonOS-Community/DragonOS.git synced 2025-06-20 01:46:31 +00:00

把pci驱动的读取acpi mcfg的代码,调整为从新的acpi驱动来读取 (#413)

* 把pci驱动的读取acpi mcfg的代码,调整为从新的acpi驱动来读取
This commit is contained in:
yuyi2439
2023-11-01 21:11:55 +08:00
committed by GitHub
parent 971462be94
commit 8b3d1688da
4 changed files with 22 additions and 49 deletions
kernel/src
arch
x86_64
driver

@ -21,7 +21,6 @@ extern crate acpi;
pub mod bus;
mod c_adapter;
pub mod glue;
pub mod old;
pub mod pmtmr;
mod sysfs;

@ -1,27 +0,0 @@
use crate::driver::pci::pci::SegmentGroupNumber;
use crate::include::bindings::bindings::acpi_system_description_table_header_t;
use core::ptr::{slice_from_raw_parts_mut, NonNull};
// MCFG表中的Segement配置部分开始位置为44+16*n
#[repr(C, packed)]
pub struct SegementConfigurationSpace {
pub base_address: u64,
pub segement_group_number: SegmentGroupNumber,
pub bus_begin: u8,
pub bus_end: u8,
pub reverse: u32,
}
/// @brief 获取Segement_Configuration_Space的数量并返回对应数量的Segement_Configuration_Space的切片指针
/// @param head acpi_system_description_table_header_t的指针
/// @return NonNull<[Segement_Configuration_Space]>
pub fn mcfg_find_segment(
head: NonNull<acpi_system_description_table_header_t>,
) -> NonNull<[SegementConfigurationSpace]> {
let table_length = unsafe { (*head.as_ptr()).Length };
let number_of_segments = ((table_length - 44) / 16) as u16;
NonNull::new(slice_from_raw_parts_mut(
(head.as_ptr() as usize + 44) as *mut _,
number_of_segments as usize,
))
.unwrap()
}

@ -15,8 +15,7 @@ use crate::{
kobject::{KObjType, KObject, KObjectState},
},
virtio::virtio_impl::HalImpl,
},
kdebug, kerror, kinfo,
}, kerror, kinfo,
libs::spinlock::SpinLock,
net::{generate_iface_id, NET_DRIVERS},
syscall::SystemError,