xref: /DragonOS/kernel/src/arch/riscv64/pci/mod.rs (revision 731bc2b32d7b37298883d7a15b6dca659b436ee4)
1 use system_error::SystemError;
2 use unified_init::macros::unified_init;
3 
4 use crate::{
5     arch::TraitPciArch,
6     driver::{
7         open_firmware::fdt::open_firmware_fdt_driver,
8         pci::pci::{pci_init, BusDeviceFunction, PciAddr},
9     },
10     init::initcall::INITCALL_SUBSYS,
11     mm::PhysAddr,
12 };
13 
14 use self::pci_host_ecam::pci_host_ecam_driver_init;
15 
16 mod pci_host_ecam;
17 
18 pub struct RiscV64PciArch;
19 impl TraitPciArch for RiscV64PciArch {
read_config(_bus_device_function: &BusDeviceFunction, _offset: u8) -> u3220     fn read_config(_bus_device_function: &BusDeviceFunction, _offset: u8) -> u32 {
21         unimplemented!("RiscV64PciArch::read_config")
22     }
23 
write_config(_bus_device_function: &BusDeviceFunction, _offset: u8, _data: u32)24     fn write_config(_bus_device_function: &BusDeviceFunction, _offset: u8, _data: u32) {
25         unimplemented!("RiscV64pci_root_0().write_config")
26     }
27 
address_pci_to_physical(pci_address: PciAddr) -> crate::mm::PhysAddr28     fn address_pci_to_physical(pci_address: PciAddr) -> crate::mm::PhysAddr {
29         return PhysAddr::new(pci_address.data());
30     }
31 }
32 
33 #[unified_init(INITCALL_SUBSYS)]
riscv_pci_init() -> Result<(), SystemError>34 fn riscv_pci_init() -> Result<(), SystemError> {
35     let fdt = open_firmware_fdt_driver().fdt_ref()?;
36 
37     pci_host_ecam_driver_init(&fdt)?;
38     pci_init();
39 
40     return Ok(());
41 }
42