|
|
@ -2,16 +2,20 @@
|
|
|
|
use rcore_memory::memory_set::handler::Linear;
|
|
|
|
use rcore_memory::memory_set::handler::Linear;
|
|
|
|
use rcore_memory::memory_set::MemoryAttr;
|
|
|
|
use rcore_memory::memory_set::MemoryAttr;
|
|
|
|
use super::*;
|
|
|
|
use super::*;
|
|
|
|
use crate::drivers::bus::pci;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
|
|
pub fn sys_map_pci_device(vendor: usize, product: usize) -> SysResult {
|
|
|
|
pub fn sys_map_pci_device(vendor: usize, product: usize) -> SysResult {
|
|
|
|
|
|
|
|
use crate::drivers::bus::pci;
|
|
|
|
info!(
|
|
|
|
info!(
|
|
|
|
"map_pci_device: vendor: {}, product: {}",
|
|
|
|
"map_pci_device: vendor: {}, product: {}",
|
|
|
|
vendor, product
|
|
|
|
vendor, product
|
|
|
|
);
|
|
|
|
);
|
|
|
|
if let Some(tag) = pci::find_device(vendor as u32, product as u32) {
|
|
|
|
let tag = pci::find_device(vendor as u32, product as u32)
|
|
|
|
|
|
|
|
.ok_or(SysError::ENOENT)?;
|
|
|
|
// Get BAR0 memory
|
|
|
|
// Get BAR0 memory
|
|
|
|
if let Some((base, len)) = unsafe { tag.get_bar_mem(0) } {
|
|
|
|
let (base, len) = unsafe { tag.get_bar_mem(0) }
|
|
|
|
|
|
|
|
.ok_or(SysError::ENOENT)?;
|
|
|
|
|
|
|
|
|
|
|
|
let mut proc = process();
|
|
|
|
let mut proc = process();
|
|
|
|
let virt_addr = proc.memory_set.find_free_area(0, len);
|
|
|
|
let virt_addr = proc.memory_set.find_free_area(0, len);
|
|
|
|
let attr = MemoryAttr::default().user();
|
|
|
|
let attr = MemoryAttr::default().user();
|
|
|
@ -23,10 +27,9 @@ pub fn sys_map_pci_device(vendor: usize, product: usize) -> SysResult {
|
|
|
|
"pci",
|
|
|
|
"pci",
|
|
|
|
);
|
|
|
|
);
|
|
|
|
Ok(virt_addr)
|
|
|
|
Ok(virt_addr)
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
Err(SysError::ENOENT)
|
|
|
|
|
|
|
|
}
|
|
|
|
#[cfg(not(target_arch = "x86_64"))]
|
|
|
|
} else {
|
|
|
|
pub fn sys_map_pci_device(vendor: usize, product: usize) -> SysResult {
|
|
|
|
Err(SysError::ENOENT)
|
|
|
|
Err(SysError::ENOSYS)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|