drivers: start building virtio-gpu

Signed-off-by: Anhad Singh <andypython@protonmail.com>
This commit is contained in:
Anhad Singh
2023-06-29 16:37:59 +10:00
parent a720cf6f44
commit 4bbda21f0b
7 changed files with 66 additions and 1 deletions
Generated
+10
View File
@@ -1948,6 +1948,16 @@ dependencies = [
"thiserror",
]
[[package]]
name = "virtio-gpud"
version = "0.1.0"
dependencies = [
"log",
"pcid",
"redox-daemon",
"virtio-core",
]
[[package]]
name = "virtio-netd"
version = "0.1.0"
+1
View File
@@ -25,6 +25,7 @@ members = [
"virtio-blkd",
"virtio-netd",
"virtio-gpud",
"virtio-core",
]
+1 -1
View File
@@ -24,7 +24,7 @@ These are the currently implemented devices/hardware interfaces.
- usbctl - USB control (incomplete).
- usbhidd - USB HID (incomplete).
- usbscsid - USB SCSI (incomplete).
- virtio-* - VirtIO (incomplete) (`virtio-blk`, `virtio-net`).
- virtio-* - VirtIO (incomplete) (`virtio-blk`, `virtio-net`, `virtio-gpu`).
## Contributing to Drivers
+9
View File
@@ -41,3 +41,12 @@ vendor = 6900
device = 4096
command = ["virtio-netd"]
use_channel = true
[[drivers]]
name = "virtio-gpu"
class = 3
subclass = 0
vendor = 6900
device = 4176
command = ["virtio-gpud"]
use_channel = true
+4
View File
@@ -64,6 +64,10 @@ pub const fn align(val: usize, align: usize) -> usize {
(val + align) & !align
}
pub const fn align_down(addr: usize) -> usize {
addr & !(syscall::PAGE_SIZE - 1)
}
#[cfg(target_os = "redox")]
pub fn setup_logging(level: log::LevelFilter, name: &str) {
use redox_log::{OutputBuilder, RedoxLogger};
+13
View File
@@ -0,0 +1,13 @@
[package]
name = "virtio-gpud"
version = "0.1.0"
edition = "2021"
authors = ["Anhad Singh <andypython@protonmail.com>"]
[dependencies]
log = "0.4"
virtio-core = { path = "../virtio-core" }
pcid = { path = "../pcid" }
redox-daemon = "0.1"
+28
View File
@@ -0,0 +1,28 @@
use pcid_interface::PcidServerHandle;
use virtio_core::transport::Error;
fn deamon(deamon: redox_daemon::Daemon) -> Result<(), Error> {
let mut pcid_handle = PcidServerHandle::connect_default()?;
// Double check that we have the right device.
//
// 0x1050 - virtio-gpu
let pci_config = pcid_handle.fetch_config()?;
assert_eq!(pci_config.func.devid, 0x1050);
log::info!("virtio-gpu: initiating startup sequence :^)");
let device = virtio_core::probe_device(&mut pcid_handle)?;
loop {}
}
fn daemon_runner(redox_daemon: redox_daemon::Daemon) -> ! {
deamon(redox_daemon).unwrap();
unreachable!();
}
pub fn main() {
#[cfg(target_os = "redox")]
virtio_core::utils::setup_logging(log::LevelFilter::Trace, "virtio-gpud");
redox_daemon::Daemon::new(daemon_runner).expect("virtio-core: failed to daemonize");
}