1 use crate::driver::pci::pci::SegmentGroupNumber;
2 use crate::include::bindings::bindings::acpi_system_description_table_header_t;
3 use core::ptr::{slice_from_raw_parts_mut, NonNull};
4 // MCFG表中的Segement配置部分,开始位置为44+16*n
5 #[repr(C, packed)]
6 pub struct Segement_Configuration_Space {
7     pub base_address: u64,
8     pub segement_group_number: SegmentGroupNumber,
9     pub bus_begin: u8,
10     pub bus_end: u8,
11     pub reverse: u32,
12 }
13 
14 /// @brief 获取Segement_Configuration_Space的数量并返回对应数量的Segement_Configuration_Space的切片指针
15 /// @param head acpi_system_description_table_header_t的指针
16 /// @return NonNull<[Segement_Configuration_Space]>
mcfg_find_segment( head: NonNull<acpi_system_description_table_header_t>, ) -> NonNull<[Segement_Configuration_Space]>17 pub fn mcfg_find_segment(
18     head: NonNull<acpi_system_description_table_header_t>,
19 ) -> NonNull<[Segement_Configuration_Space]> {
20     let table_length = unsafe { (*head.as_ptr()).Length };
21     let number_of_segments = ((table_length - 44) / 16) as u16;
22     NonNull::new(slice_from_raw_parts_mut(
23         (head.as_ptr() as usize + 44) as *mut _,
24         number_of_segments as usize,
25     ))
26     .unwrap()
27 }
28