/// Memory maps pci bar with specified index to identical location in virtual memory.
/// no_cache determines if we set the `Cache Disable` flag in the page-table-entry.
/// Returns (virtual-pointer, size) if successful, else None (if bar non-existent or IOSpace)
Memory maps pci bar with specified index to identical location in virtual memory.
no_cache determines if we set the `Cache Disable` flag in the page-table-entry.
Returns (virtual-pointer, size) if successful, else None (if bar non-existent or IOSpace)
Memory maps pci bar with specified index to identical location in virtual memory . no_cache determines if we set the ` Cache Disable ` flag in the page - table - entry . Returns ( virtual - pointer size ) if successful else None ( if bar non - existent or IOSpace )
pub fn memory_map_bar(&self, index: u8, no_cache: bool) -> Option<(VirtAddr, usize)> {
		let pci_bar = match self.get_bar(index) {
			Some(PciBar::IO(_)) => {
				warn!("Cannot map IOBar!");
				return None;
			}
			Some(PciBar::Memory(mem_bar)) => mem_bar,
			None => {
				warn!("Memory bar not found!");
				return None;
			}
		};
		debug!(
			"Mapping bar {} at 0x{:x} with length 0x{:x}",
			index, pci_bar.addr, pci_bar.size
		);
		if pci_bar.width != 64 {
			warn!("Currently only mapping of 64 bit bars is supported!");
			return None;
		}
		if !pci_bar.prefetchable {
			warn!("Currently only mapping of prefetchable bars is supported!")
		}
		// Since the bios/bootloader manages the physical address space, the address got from the bar is unique and not overlapping.
		// We therefore do not need to reserve any additional memory in our kernel.
		// Map bar into RW^X virtual memory
		let physical_address = pci_bar.addr;
		let virtual_address = crate::mm::map(
			PhysAddr::from(physical_address),
			pci_bar.size,
			true,
			false,
			no_cache,
		);
		Some((virtual_address, pci_bar.size))
	}
pub fn memory_map_bar ( & self , index : u8 , no_cache : bool ) -> Option < ( VirtAddr , usize ) > { let pci_bar = match self . get_bar ( index ) { Some ( PciBar :: IO ( _ ) ) => { warn ! ( " " ) ; return None ; } Some ( PciBar :: Memory ( mem_bar ) ) => mem_bar , None => { warn ! ( " " ) ; return None ; } } ; debug ! ( " " index pci_bar addr pci_bar size ) ; if pci_bar . width != 64 { warn ! ( " " ) ; return None ; } if ! pci_bar . prefetchable { warn ! ( " " ) } // Since the bios/bootloader manages the physical address space, the address got from the bar is unique and not overlapping. // We therefore do not need to reserve any additional memory in our kernel. // Map bar into RW^X virtual memory let physical_address = pci_bar . addr ; let virtual_address = crate :: mm :: map ( PhysAddr :: from ( physical_address ) , pci_bar . size , true , false , no_cache , ) ; Some ( ( virtual_address , pci_bar . size ) ) }
Memory maps pci bar with specified index to identical location in virtual memory.
Memory maps pci bar with specified index to identical location in virtual memory .
&self
index
u8
no_cache
bool