drivers/pcid: Add pci_daemon function
This handles daemonization and getting the PciFunctionHandle.
This commit is contained in:
@@ -18,11 +18,10 @@ use std::cell::RefCell;
|
||||
pub mod device;
|
||||
|
||||
fn main() {
|
||||
daemon::Daemon::new(daemon);
|
||||
pcid_interface::pci_daemon(daemon);
|
||||
}
|
||||
|
||||
fn daemon(daemon: daemon::Daemon) -> ! {
|
||||
let pcid_handle = PciFunctionHandle::connect_default();
|
||||
fn daemon(daemon: daemon::Daemon, pcid_handle: PciFunctionHandle) -> ! {
|
||||
let pci_config = pcid_handle.config();
|
||||
|
||||
let mut name = pci_config.func.name();
|
||||
|
||||
@@ -23,9 +23,11 @@ QEMU ICH9 8086:293E
|
||||
82801H ICH8 8086:284B
|
||||
*/
|
||||
|
||||
fn daemon(daemon: daemon::Daemon) -> ! {
|
||||
let mut pcid_handle = PciFunctionHandle::connect_default();
|
||||
fn main() {
|
||||
pcid_interface::pci_daemon(daemon);
|
||||
}
|
||||
|
||||
fn daemon(daemon: daemon::Daemon, mut pcid_handle: PciFunctionHandle) -> ! {
|
||||
let pci_config = pcid_handle.config();
|
||||
|
||||
let mut name = pci_config.func.name();
|
||||
@@ -138,7 +140,3 @@ fn daemon(daemon: daemon::Daemon) -> ! {
|
||||
std::process::exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
daemon::Daemon::new(daemon);
|
||||
}
|
||||
|
||||
@@ -13,11 +13,10 @@ mod scheme;
|
||||
// FIXME add a driver-graphics implementation
|
||||
|
||||
fn main() {
|
||||
daemon::Daemon::new(daemon);
|
||||
pcid_interface::pci_daemon(daemon);
|
||||
}
|
||||
|
||||
fn daemon(daemon: daemon::Daemon) -> ! {
|
||||
let mut pcid_handle = PciFunctionHandle::connect_default();
|
||||
fn daemon(daemon: daemon::Daemon, mut pcid_handle: PciFunctionHandle) -> ! {
|
||||
let pci_config = pcid_handle.config();
|
||||
|
||||
let mut name = pci_config.func.name();
|
||||
|
||||
@@ -430,8 +430,23 @@ impl MoveCursor {
|
||||
|
||||
static DEVICE: spin::Once<virtio_core::Device> = spin::Once::new();
|
||||
|
||||
fn deamon(deamon: daemon::Daemon) -> anyhow::Result<()> {
|
||||
let mut pcid_handle = PciFunctionHandle::connect_default();
|
||||
fn main() {
|
||||
pcid_interface::pci_daemon(daemon_runner);
|
||||
}
|
||||
|
||||
fn daemon_runner(daemon: daemon::Daemon, pcid_handle: PciFunctionHandle) -> ! {
|
||||
deamon(daemon, pcid_handle).unwrap();
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
fn deamon(deamon: daemon::Daemon, mut pcid_handle: PciFunctionHandle) -> anyhow::Result<()> {
|
||||
common::setup_logging(
|
||||
"graphics",
|
||||
"pci",
|
||||
"virtio-gpud",
|
||||
common::output_level(),
|
||||
common::file_level(),
|
||||
);
|
||||
|
||||
// Double check that we have the right device.
|
||||
//
|
||||
@@ -542,19 +557,3 @@ fn deamon(deamon: daemon::Daemon) -> anyhow::Result<()> {
|
||||
|
||||
std::process::exit(0);
|
||||
}
|
||||
|
||||
fn daemon_runner(daemon: daemon::Daemon) -> ! {
|
||||
common::setup_logging(
|
||||
"graphics",
|
||||
"pci",
|
||||
"virtio-gpud",
|
||||
common::output_level(),
|
||||
common::file_level(),
|
||||
);
|
||||
deamon(daemon).unwrap();
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
daemon::Daemon::new(daemon_runner);
|
||||
}
|
||||
|
||||
@@ -8,11 +8,10 @@ use pcid_interface::PciFunctionHandle;
|
||||
pub mod device;
|
||||
|
||||
fn main() {
|
||||
daemon::Daemon::new(daemon);
|
||||
pcid_interface::pci_daemon(daemon);
|
||||
}
|
||||
|
||||
fn daemon(daemon: daemon::Daemon) -> ! {
|
||||
let mut pcid_handle = PciFunctionHandle::connect_default();
|
||||
fn daemon(daemon: daemon::Daemon, mut pcid_handle: PciFunctionHandle) -> ! {
|
||||
let pci_config = pcid_handle.config();
|
||||
|
||||
let mut name = pci_config.func.name();
|
||||
|
||||
@@ -10,11 +10,10 @@ pub mod device;
|
||||
mod ixgbe;
|
||||
|
||||
fn main() {
|
||||
daemon::Daemon::new(daemon);
|
||||
pcid_interface::pci_daemon(daemon);
|
||||
}
|
||||
|
||||
fn daemon(daemon: daemon::Daemon) -> ! {
|
||||
let mut pcid_handle = PciFunctionHandle::connect_default();
|
||||
fn daemon(daemon: daemon::Daemon, mut pcid_handle: PciFunctionHandle) -> ! {
|
||||
let pci_config = pcid_handle.config();
|
||||
|
||||
let mut name = pci_config.func.name();
|
||||
|
||||
@@ -35,9 +35,11 @@ fn map_bar(pcid_handle: &mut PciFunctionHandle) -> *mut u8 {
|
||||
panic!("rtl8139d: failed to find BAR");
|
||||
}
|
||||
|
||||
fn daemon(daemon: daemon::Daemon) -> ! {
|
||||
let mut pcid_handle = PciFunctionHandle::connect_default();
|
||||
fn main() {
|
||||
pcid_interface::pci_daemon(daemon);
|
||||
}
|
||||
|
||||
fn daemon(daemon: daemon::Daemon, mut pcid_handle: PciFunctionHandle) -> ! {
|
||||
let pci_config = pcid_handle.config();
|
||||
|
||||
let mut name = pci_config.func.name();
|
||||
@@ -111,7 +113,3 @@ fn daemon(daemon: daemon::Daemon) -> ! {
|
||||
}
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
daemon::Daemon::new(daemon);
|
||||
}
|
||||
|
||||
@@ -35,9 +35,11 @@ fn map_bar(pcid_handle: &mut PciFunctionHandle) -> *mut u8 {
|
||||
panic!("rtl8168d: failed to find BAR");
|
||||
}
|
||||
|
||||
fn daemon(daemon: daemon::Daemon) -> ! {
|
||||
let mut pcid_handle = PciFunctionHandle::connect_default();
|
||||
fn main() {
|
||||
pcid_interface::pci_daemon(daemon);
|
||||
}
|
||||
|
||||
fn daemon(daemon: daemon::Daemon, mut pcid_handle: PciFunctionHandle) -> ! {
|
||||
let pci_config = pcid_handle.config();
|
||||
|
||||
let mut name = pci_config.func.name();
|
||||
@@ -111,7 +113,3 @@ fn daemon(daemon: daemon::Daemon) -> ! {
|
||||
}
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
daemon::Daemon::new(daemon);
|
||||
}
|
||||
|
||||
@@ -26,9 +26,26 @@ pub struct VirtHeader {
|
||||
static_assertions::const_assert_eq!(core::mem::size_of::<VirtHeader>(), 12);
|
||||
|
||||
const MAX_BUFFER_LEN: usize = 65535;
|
||||
fn main() {
|
||||
pcid_interface::pci_daemon(daemon_runner);
|
||||
}
|
||||
|
||||
fn deamon(daemon: daemon::Daemon) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut pcid_handle = PciFunctionHandle::connect_default();
|
||||
fn daemon_runner(daemon: daemon::Daemon, pcid_handle: PciFunctionHandle) -> ! {
|
||||
deamon(daemon, pcid_handle).unwrap();
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
fn deamon(
|
||||
daemon: daemon::Daemon,
|
||||
mut pcid_handle: PciFunctionHandle,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
common::setup_logging(
|
||||
"net",
|
||||
"pci",
|
||||
"virtio-netd",
|
||||
common::output_level(),
|
||||
common::file_level(),
|
||||
);
|
||||
|
||||
// Double check that we have the right device.
|
||||
//
|
||||
@@ -118,19 +135,3 @@ fn deamon(daemon: daemon::Daemon) -> Result<(), Box<dyn std::error::Error>> {
|
||||
scheme.tick()?;
|
||||
}
|
||||
}
|
||||
|
||||
fn daemon_runner(daemon: daemon::Daemon) -> ! {
|
||||
common::setup_logging(
|
||||
"net",
|
||||
"pci",
|
||||
"virtio-netd",
|
||||
common::output_level(),
|
||||
common::file_level(),
|
||||
);
|
||||
deamon(daemon).unwrap();
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
daemon::Daemon::new(daemon_runner);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use std::ptr::NonNull;
|
||||
use std::{env, io};
|
||||
use std::{fmt, process};
|
||||
|
||||
use daemon::Daemon;
|
||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||
|
||||
pub use bar::PciBar;
|
||||
@@ -297,7 +298,7 @@ fn recv<T: DeserializeOwned>(r: &mut File) -> T {
|
||||
}
|
||||
|
||||
impl PciFunctionHandle {
|
||||
pub fn connect_default() -> Self {
|
||||
fn connect_default() -> Self {
|
||||
let channel_fd = match env::var("PCID_CLIENT_CHANNEL") {
|
||||
Ok(channel_fd) => channel_fd,
|
||||
Err(err) => {
|
||||
@@ -471,3 +472,10 @@ impl PciFunctionHandle {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pci_daemon<F: FnOnce(Daemon, PciFunctionHandle) -> !>(f: F) -> ! {
|
||||
Daemon::new(|daemon| {
|
||||
let pcid_handle = PciFunctionHandle::connect_default();
|
||||
f(daemon, pcid_handle)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
//! Interface to `pcid`.
|
||||
|
||||
#![feature(never_type)]
|
||||
|
||||
mod driver_interface;
|
||||
pub use driver_interface::*;
|
||||
|
||||
@@ -14,11 +14,10 @@ use log::{error, info};
|
||||
pub mod ahci;
|
||||
|
||||
fn main() {
|
||||
daemon::Daemon::new(daemon);
|
||||
pcid_interface::pci_daemon(daemon);
|
||||
}
|
||||
|
||||
fn daemon(daemon: daemon::Daemon) -> ! {
|
||||
let mut pcid_handle = PciFunctionHandle::connect_default();
|
||||
fn daemon(daemon: daemon::Daemon, mut pcid_handle: PciFunctionHandle) -> ! {
|
||||
let pci_config = pcid_handle.config();
|
||||
|
||||
let mut name = pci_config.func.name();
|
||||
|
||||
@@ -18,12 +18,10 @@ use crate::ide::{AtaCommand, AtaDisk, Channel};
|
||||
pub mod ide;
|
||||
|
||||
fn main() {
|
||||
daemon::Daemon::new(daemon);
|
||||
pcid_interface::pci_daemon(daemon);
|
||||
}
|
||||
|
||||
fn daemon(daemon: daemon::Daemon) -> ! {
|
||||
let pcid_handle = PciFunctionHandle::connect_default();
|
||||
|
||||
fn daemon(daemon: daemon::Daemon, pcid_handle: PciFunctionHandle) -> ! {
|
||||
let pci_config = pcid_handle.config();
|
||||
|
||||
let mut name = pci_config.func.name();
|
||||
|
||||
@@ -57,10 +57,10 @@ fn time_arm(time_handle: &mut File, secs: i64) -> io::Result<()> {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
daemon::Daemon::new(daemon);
|
||||
pcid_interface::pci_daemon(daemon);
|
||||
}
|
||||
fn daemon(daemon: daemon::Daemon) -> ! {
|
||||
let mut pcid_handle = PciFunctionHandle::connect_default();
|
||||
|
||||
fn daemon(daemon: daemon::Daemon, mut pcid_handle: PciFunctionHandle) -> ! {
|
||||
let pci_config = pcid_handle.config();
|
||||
|
||||
let scheme_name = format!("disk.{}-nvme", pci_config.func.name());
|
||||
|
||||
@@ -30,10 +30,6 @@ pub enum Error {
|
||||
SyscallError(syscall::Error),
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
daemon::Daemon::new(daemon_runner);
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct BlockGeometry {
|
||||
pub cylinders: VolatileCell<u16>,
|
||||
@@ -102,8 +98,23 @@ pub struct BlockVirtRequest {
|
||||
|
||||
const_assert_eq!(core::mem::size_of::<BlockVirtRequest>(), 16);
|
||||
|
||||
fn daemon(daemon: daemon::Daemon) -> anyhow::Result<()> {
|
||||
let mut pcid_handle = PciFunctionHandle::connect_default();
|
||||
fn main() {
|
||||
pcid_interface::pci_daemon(daemon_runner);
|
||||
}
|
||||
|
||||
fn daemon_runner(redox_daemon: daemon::Daemon, pcid_handle: PciFunctionHandle) -> ! {
|
||||
daemon(redox_daemon, pcid_handle).unwrap();
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
fn daemon(daemon: daemon::Daemon, mut pcid_handle: PciFunctionHandle) -> anyhow::Result<()> {
|
||||
common::setup_logging(
|
||||
"disk",
|
||||
"pci",
|
||||
"virtio-blkd",
|
||||
common::output_level(),
|
||||
common::file_level(),
|
||||
);
|
||||
|
||||
// Double check that we have the right device.
|
||||
//
|
||||
@@ -169,15 +180,3 @@ fn daemon(daemon: daemon::Daemon) -> anyhow::Result<()> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn daemon_runner(redox_daemon: daemon::Daemon) -> ! {
|
||||
common::setup_logging(
|
||||
"disk",
|
||||
"pci",
|
||||
"virtio-blkd",
|
||||
common::output_level(),
|
||||
common::file_level(),
|
||||
);
|
||||
daemon(redox_daemon).unwrap();
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
@@ -115,10 +115,6 @@ fn get_int_method(pcid_handle: &mut PciFunctionHandle) -> (Option<File>, Interru
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
daemon::Daemon::new(daemon);
|
||||
}
|
||||
|
||||
//TODO: cleanup CSZ support
|
||||
fn daemon_with_context_size<const N: usize>(
|
||||
daemon: daemon::Daemon,
|
||||
@@ -185,8 +181,11 @@ fn daemon_with_context_size<const N: usize>(
|
||||
}
|
||||
}
|
||||
|
||||
fn daemon(daemon: daemon::Daemon) -> ! {
|
||||
let mut pcid_handle = PciFunctionHandle::connect_default();
|
||||
fn main() {
|
||||
pcid_interface::pci_daemon(daemon);
|
||||
}
|
||||
|
||||
fn daemon(daemon: daemon::Daemon, mut pcid_handle: PciFunctionHandle) -> ! {
|
||||
let address = unsafe { pcid_handle.map_bar(0) }.ptr.as_ptr() as usize;
|
||||
let cap = unsafe { &mut *(address as *mut xhci::CapabilityRegs) };
|
||||
if cap.csz() {
|
||||
|
||||
@@ -191,11 +191,10 @@ impl VboxGuestInfo {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
daemon::Daemon::new(daemon);
|
||||
pcid_interface::pci_daemon(daemon);
|
||||
}
|
||||
|
||||
fn daemon(daemon: daemon::Daemon) -> ! {
|
||||
let mut pcid_handle = PciFunctionHandle::connect_default();
|
||||
fn daemon(daemon: daemon::Daemon, mut pcid_handle: PciFunctionHandle) -> ! {
|
||||
let pci_config = pcid_handle.config();
|
||||
|
||||
let mut name = pci_config.func.name();
|
||||
|
||||
Reference in New Issue
Block a user