fix: map virtio GPU BAR from pcid handoff
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -4,7 +4,7 @@ use std::sync::Mutex;
|
||||
|
||||
use log::{info, warn};
|
||||
use redox_driver_sys::memory::MmioRegion;
|
||||
use redox_driver_sys::pci::{PciBarInfo, PciDevice, PciDeviceInfo};
|
||||
use redox_driver_sys::pci::{PciBarInfo, PciDeviceInfo};
|
||||
|
||||
use crate::driver::{DriverError, DriverEvent, GpuDriver, Result};
|
||||
use crate::drivers::interrupt::InterruptHandle;
|
||||
@@ -32,10 +32,14 @@ fn find_fb_bar(info: &PciDeviceInfo) -> Result<PciBarInfo> {
|
||||
.ok_or_else(|| DriverError::Pci("VirtIO GPU has no valid framebuffer BAR".into()))
|
||||
}
|
||||
|
||||
fn map_bar(device: &mut PciDevice, bar: &PciBarInfo, name: &str) -> Result<MmioRegion> {
|
||||
device
|
||||
.map_bar(bar.index, bar.addr, bar.size as usize)
|
||||
.map_err(|e| DriverError::Mmio(format!("failed to map {name}: {e}")))
|
||||
fn map_bar(bar: &PciBarInfo, name: &str) -> Result<MmioRegion> {
|
||||
MmioRegion::map(
|
||||
bar.addr,
|
||||
bar.size as usize,
|
||||
redox_driver_sys::memory::CacheType::DeviceMemory,
|
||||
redox_driver_sys::memory::MmioProt::READ_WRITE,
|
||||
)
|
||||
.map_err(|e| DriverError::Mmio(format!("failed to map {name}: {e}")))
|
||||
}
|
||||
|
||||
impl VirtioDriver {
|
||||
@@ -48,10 +52,7 @@ impl VirtioDriver {
|
||||
}
|
||||
|
||||
let fb_bar = find_fb_bar(&info)?;
|
||||
let mut device = PciDevice::open_location(&info.location)
|
||||
.map_err(|e| DriverError::Pci(format!("open PCI: {e}")))?;
|
||||
let _mmio = map_bar(&mut device, &fb_bar, "VirtIO FB BAR")?;
|
||||
drop(device);
|
||||
let _mmio = map_bar(&fb_bar, "VirtIO FB BAR")?;
|
||||
|
||||
info!(
|
||||
"redox-drm: VirtIO GPU at {}: {} MiB BAR at {:#x}",
|
||||
|
||||
Reference in New Issue
Block a user