1 use crate::{
2     driver::pci::pci::{BusDeviceFunction, PciAddr, PciError, PciRoot, SegmentGroupNumber},
3     mm::PhysAddr,
4 };
5 
6 #[cfg(target_arch = "x86_64")]
7 pub mod x86_64;
8 #[cfg(target_arch = "x86_64")]
9 pub use self::x86_64::*; // 公开x86_64架构下的函数,使外界接口统一
10 
11 #[cfg(target_arch = "riscv64")]
12 pub mod riscv64;
13 #[cfg(target_arch = "riscv64")]
14 pub use self::riscv64::*; // 公开riscv64架构下的函数,使外界接口统一
15 
16 pub mod io;
17 
18 /// TraitPciArch Pci架构相关函数,任何架构都应独立实现trait里的函数
19 pub trait TraitPciArch {
20     /// @brief 读取寄存器值,x86_64架构通过读取两个特定io端口实现
21     /// @param bus_device_function 设备的唯一标识符
22     /// @param offset 寄存器偏移值
23     /// @return 读取到的值
read_config(bus_device_function: &BusDeviceFunction, offset: u8) -> u3224     fn read_config(bus_device_function: &BusDeviceFunction, offset: u8) -> u32;
25     /// @brief 写入寄存器值,x86_64架构通过读取两个特定io端口实现
26     /// @param bus_device_function 设备的唯一标识符
27     /// @param offset 寄存器偏移值
28     /// @param data 要写入的值
write_config(bus_device_function: &BusDeviceFunction, offset: u8, data: u32)29     fn write_config(bus_device_function: &BusDeviceFunction, offset: u8, data: u32);
30     /// @brief PCI域地址到存储器域地址的转换,x86_64架构为一一对应
31     /// @param address PCI域地址
32     /// @return usize 转换结果
address_pci_to_physical(pci_address: PciAddr) -> PhysAddr33     fn address_pci_to_physical(pci_address: PciAddr) -> PhysAddr;
34     /// @brief 获取Segement的root地址,x86_64架构为acpi mcfg表中读取
35     /// @param segement 组id
36     /// @return  Result<PciRoot, PciError> 转换结果或出错原因
ecam_root(segement: SegmentGroupNumber) -> Result<PciRoot, PciError>37     fn ecam_root(segement: SegmentGroupNumber) -> Result<PciRoot, PciError>;
38 }
39