pcid: Rename PcidServerHandle to PciFunctionHandle

This commit is contained in:
bjorn3
2024-06-15 15:05:42 +02:00
parent 3299a070f2
commit fdb9ea816b
20 changed files with 51 additions and 51 deletions
+2 -2
View File
@@ -14,7 +14,7 @@ use std::usize;
use event::{user_data, EventQueue};
use libredox::flag;
use pcid_interface::{PciBar, PcidServerHandle};
use pcid_interface::{PciBar, PciFunctionHandle};
use redox_log::{OutputBuilder, RedoxLogger};
use syscall::{EventFlags, Packet, SchemeBlockMut};
@@ -66,7 +66,7 @@ fn setup_logging() -> Option<&'static RedoxLogger> {
fn main() {
let mut pcid_handle =
PcidServerHandle::connect_default().expect("ac97d: failed to setup channel to pcid");
PciFunctionHandle::connect_default().expect("ac97d: failed to setup channel to pcid");
let pci_config = pcid_handle
.fetch_config()
.expect("ac97d: failed to fetch config");
+4 -4
View File
@@ -16,7 +16,7 @@ use std::cell::RefCell;
use std::sync::Arc;
use event::{user_data, EventQueue};
use pcid_interface::{MsiSetFeatureInfo, PcidServerHandle, PciFeature, PciFeatureInfo, SetFeatureInfo};
use pcid_interface::{MsiSetFeatureInfo, PciFunctionHandle, PciFeature, PciFeatureInfo, SetFeatureInfo};
#[cfg(target_arch = "x86_64")]
use pcid_interface::irq_helpers::allocate_single_interrupt_vector_for_msi;
use pcid_interface::irq_helpers::read_bsp_apic_id;
@@ -76,7 +76,7 @@ fn setup_logging() -> Option<&'static RedoxLogger> {
}
#[cfg(target_arch = "x86_64")]
fn get_int_method(pcid_handle: &mut PcidServerHandle) -> File {
fn get_int_method(pcid_handle: &mut PciFunctionHandle) -> File {
let pci_config = pcid_handle.fetch_config().expect("ihdad: failed to fetch config");
let all_pci_features = pcid_handle.fetch_all_features().expect("ihdad: failed to fetch pci features");
@@ -121,7 +121,7 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle) -> File {
//TODO: MSI on non-x86_64?
#[cfg(not(target_arch = "x86_64"))]
fn get_int_method(pcid_handle: &mut PcidServerHandle) -> File {
fn get_int_method(pcid_handle: &mut PciFunctionHandle) -> File {
let pci_config = pcid_handle.fetch_config().expect("ihdad: failed to fetch config");
if let Some(irq) = pci_config.func.legacy_interrupt_line {
@@ -135,7 +135,7 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle) -> File {
fn daemon(daemon: redox_daemon::Daemon) -> ! {
let _logger_ref = setup_logging();
let mut pcid_handle = PcidServerHandle::connect_default().expect("ihdad: failed to setup channel to pcid");
let mut pcid_handle = PciFunctionHandle::connect_default().expect("ihdad: failed to setup channel to pcid");
let pci_config = pcid_handle.fetch_config().expect("ihdad: failed to fetch config");
+2 -2
View File
@@ -4,7 +4,7 @@ extern crate syscall;
use std::fs::File;
use std::io::{Read, Write};
use pcid_interface::PcidServerHandle;
use pcid_interface::PciFunctionHandle;
use syscall::call::iopl;
use syscall::data::Packet;
use syscall::scheme::SchemeMut;
@@ -17,7 +17,7 @@ mod scheme;
fn main() {
let mut pcid_handle =
PcidServerHandle::connect_default().expect("bgad: failed to setup channel to pcid");
PciFunctionHandle::connect_default().expect("bgad: failed to setup channel to pcid");
let pci_config = pcid_handle
.fetch_config()
.expect("bgad: failed to fetch config");
+2 -2
View File
@@ -27,7 +27,7 @@ use std::fs::File;
use std::io::{Read, Write};
use std::sync::Arc;
use pcid_interface::PcidServerHandle;
use pcid_interface::PciFunctionHandle;
use syscall::{Packet, SchemeMut};
use virtio_core::transport::{self, Queue};
@@ -409,7 +409,7 @@ fn reinit(control_queue: Arc<Queue>, cursor_queue: Arc<Queue>) -> Result<(), tra
}
fn deamon(deamon: redox_daemon::Daemon) -> anyhow::Result<()> {
let mut pcid_handle = PcidServerHandle::connect_default()?;
let mut pcid_handle = PciFunctionHandle::connect_default()?;
// Double check that we have the right device.
//
+2 -2
View File
@@ -6,14 +6,14 @@ use std::rc::Rc;
use driver_network::NetworkScheme;
use event::{user_data, EventQueue};
use pcid_interface::PcidServerHandle;
use pcid_interface::PciFunctionHandle;
use syscall::EventFlags;
pub mod device;
fn main() {
let mut pcid_handle =
PcidServerHandle::connect_default().expect("e1000d: failed to setup channel to pcid");
PciFunctionHandle::connect_default().expect("e1000d: failed to setup channel to pcid");
let pci_config = pcid_handle
.fetch_config()
.expect("e1000d: failed to fetch config");
+2 -2
View File
@@ -6,7 +6,7 @@ use std::rc::Rc;
use driver_network::NetworkScheme;
use event::{user_data, EventQueue};
use pcid_interface::PcidServerHandle;
use pcid_interface::PciFunctionHandle;
use syscall::EventFlags;
pub mod device;
@@ -15,7 +15,7 @@ mod ixgbe;
fn main() {
let mut pcid_handle =
PcidServerHandle::connect_default().expect("ixgbed: failed to setup channel to pcid");
PciFunctionHandle::connect_default().expect("ixgbed: failed to setup channel to pcid");
let pci_config = pcid_handle
.fetch_config()
.expect("ixgbed: failed to fetch config");
+4 -4
View File
@@ -15,7 +15,7 @@ use pcid_interface::irq_helpers::allocate_single_interrupt_vector_for_msi;
use pcid_interface::irq_helpers::read_bsp_apic_id;
use pcid_interface::msi::{MsixInfo, MsixTableEntry};
use pcid_interface::{
MsiSetFeatureInfo, PciFeature, PciFeatureInfo, PcidServerHandle, SetFeatureInfo,
MsiSetFeatureInfo, PciFeature, PciFeatureInfo, PciFunctionHandle, SetFeatureInfo,
SubdriverArguments,
};
use redox_log::{OutputBuilder, RedoxLogger};
@@ -95,7 +95,7 @@ impl MappedMsixRegs {
}
#[cfg(target_arch = "x86_64")]
fn get_int_method(pcid_handle: &mut PcidServerHandle) -> File {
fn get_int_method(pcid_handle: &mut PciFunctionHandle) -> File {
let pci_config = pcid_handle.fetch_config().expect("rtl8139d: failed to fetch config");
let all_pci_features = pcid_handle.fetch_all_features().expect("rtl8139d: failed to fetch pci features");
@@ -177,7 +177,7 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle) -> File {
//TODO: MSI on non-x86_64?
#[cfg(not(target_arch = "x86_64"))]
fn get_int_method(pcid_handle: &mut PcidServerHandle) -> File {
fn get_int_method(pcid_handle: &mut PciFunctionHandle) -> File {
let pci_config = pcid_handle.fetch_config().expect("rtl8139d: failed to fetch config");
if let Some(irq) = pci_config.func.legacy_interrupt_line {
@@ -209,7 +209,7 @@ fn find_bar(pci_config: &SubdriverArguments) -> Option<(usize, usize)> {
fn daemon(daemon: redox_daemon::Daemon) -> ! {
let _logger_ref = setup_logging();
let mut pcid_handle = PcidServerHandle::connect_default().expect("rtl8139d: failed to setup channel to pcid");
let mut pcid_handle = PciFunctionHandle::connect_default().expect("rtl8139d: failed to setup channel to pcid");
let pci_config = pcid_handle.fetch_config().expect("rtl8139d: failed to fetch config");
+4 -4
View File
@@ -8,7 +8,7 @@ use std::rc::Rc;
use driver_network::NetworkScheme;
use event::{user_data, EventQueue};
use pcid_interface::{MsiSetFeatureInfo, PcidServerHandle, PciFeature, PciFeatureInfo, SetFeatureInfo, SubdriverArguments};
use pcid_interface::{MsiSetFeatureInfo, PciFunctionHandle, PciFeature, PciFeatureInfo, SetFeatureInfo, SubdriverArguments};
#[cfg(target_arch = "x86_64")]
use pcid_interface::irq_helpers::allocate_single_interrupt_vector_for_msi;
use pcid_interface::irq_helpers::read_bsp_apic_id;
@@ -90,7 +90,7 @@ impl MappedMsixRegs {
}
#[cfg(target_arch = "x86_64")]
fn get_int_method(pcid_handle: &mut PcidServerHandle) -> File {
fn get_int_method(pcid_handle: &mut PciFunctionHandle) -> File {
let pci_config = pcid_handle.fetch_config().expect("rtl8168d: failed to fetch config");
let all_pci_features = pcid_handle.fetch_all_features().expect("rtl8168d: failed to fetch pci features");
@@ -172,7 +172,7 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle) -> File {
//TODO: MSI on non-x86_64?
#[cfg(not(target_arch = "x86_64"))]
fn get_int_method(pcid_handle: &mut PcidServerHandle) -> File {
fn get_int_method(pcid_handle: &mut PciFunctionHandle) -> File {
let pci_config = pcid_handle.fetch_config().expect("rtl8168d: failed to fetch config");
if let Some(irq) = pci_config.func.legacy_interrupt_line {
@@ -204,7 +204,7 @@ fn find_bar(pci_config: &SubdriverArguments) -> Option<(usize, usize)> {
fn daemon(daemon: redox_daemon::Daemon) -> ! {
let _logger_ref = setup_logging();
let mut pcid_handle = PcidServerHandle::connect_default().expect("rtl8168d: failed to setup channel to pcid");
let mut pcid_handle = PciFunctionHandle::connect_default().expect("rtl8168d: failed to setup channel to pcid");
let pci_config = pcid_handle.fetch_config().expect("rtl8168d: failed to fetch config");
+2 -2
View File
@@ -5,7 +5,7 @@ use std::io::{Read, Write};
use std::mem;
use driver_network::NetworkScheme;
use pcid_interface::PcidServerHandle;
use pcid_interface::PciFunctionHandle;
use scheme::VirtioNet;
@@ -28,7 +28,7 @@ static_assertions::const_assert_eq!(core::mem::size_of::<VirtHeader>(), 12);
const MAX_BUFFER_LEN: usize = 65535;
fn deamon(daemon: redox_daemon::Daemon) -> Result<(), Box<dyn std::error::Error>> {
let mut pcid_handle = PcidServerHandle::connect_default()?;
let mut pcid_handle = PciFunctionHandle::connect_default()?;
// Double check that we have the right device.
//
+2 -2
View File
@@ -227,7 +227,7 @@ pub enum PcidClientResponse {
// very similar to crossbeam-channel or libstd's mpsc (except the cycle, enqueue and dequeue fields
// are stored in the same buffer as the actual data).
/// A handle from a `pcid` client (e.g. `ahcid`) to `pcid`.
pub struct PcidServerHandle {
pub struct PciFunctionHandle {
pcid_to_client: File,
pcid_from_client: File,
}
@@ -253,7 +253,7 @@ pub(crate) fn recv<R: Read, T: DeserializeOwned>(r: &mut R) -> Result<T> {
Ok(bincode::deserialize_from(&data[..])?)
}
impl PcidServerHandle {
impl PciFunctionHandle {
pub fn connect_default() -> Result<Self> {
let pcid_to_client_fd = env::var("PCID_TO_CLIENT_FD")?.parse::<RawFd>().map_err(PcidClientHandleError::EnvValidityError)?;
let pcid_from_client_fd = env::var("PCID_FROM_CLIENT_FD")?.parse::<RawFd>().map_err(PcidClientHandleError::EnvValidityError)?;
+2 -2
View File
@@ -9,7 +9,7 @@ use std::os::fd::AsRawFd;
use std::usize;
use event::{EventFlags, RawEventQueue};
use pcid_interface::PcidServerHandle;
use pcid_interface::PciFunctionHandle;
use redox_scheme::{RequestKind, Response, SignalBehavior, Socket, V2};
use syscall::error::{Error, ENODEV};
@@ -72,7 +72,7 @@ fn main() {
fn daemon(daemon: redox_daemon::Daemon) -> ! {
let mut pcid_handle =
PcidServerHandle::connect_default().expect("ahcid: failed to setup channel to pcid");
PciFunctionHandle::connect_default().expect("ahcid: failed to setup channel to pcid");
let pci_config = pcid_handle
.fetch_config()
.expect("ahcid: failed to fetch config");
+2 -2
View File
@@ -2,7 +2,7 @@ use driver_block::Disk;
use event::{EventFlags, RawEventQueue};
use libredox::flag;
use log::{error, info};
use pcid_interface::{PciBar, PcidServerHandle};
use pcid_interface::{PciBar, PciFunctionHandle};
use redox_log::{OutputBuilder, RedoxLogger};
use redox_scheme::{RequestKind, Response, SignalBehavior, Socket, V2};
use std::{
@@ -75,7 +75,7 @@ fn main() {
fn daemon(daemon: redox_daemon::Daemon) -> ! {
let mut pcid_handle =
PcidServerHandle::connect_default().expect("ided: failed to setup channel to pcid");
PciFunctionHandle::connect_default().expect("ided: failed to setup channel to pcid");
let pci_config = pcid_handle.fetch_config().expect("ided: failed to fetch config");
+4 -4
View File
@@ -10,7 +10,7 @@ use std::sync::{Arc, Mutex};
use std::{slice, usize};
use libredox::flag;
use pcid_interface::{PciFeature, PciFeatureInfo, PciFunction, PcidServerHandle};
use pcid_interface::{PciFeature, PciFeatureInfo, PciFunction, PciFunctionHandle};
use redox_scheme::{CallRequest, RequestKind, SignalBehavior, Socket, V2};
use syscall::{
Event, Mmio, Packet, Result, SchemeBlockMut,
@@ -58,7 +58,7 @@ pub struct AllocatedBars(pub [Mutex<Option<Bar>>; 6]);
/// structures), and the handles to the interrupts.
#[cfg(target_arch = "x86_64")]
fn get_int_method(
pcid_handle: &mut PcidServerHandle,
pcid_handle: &mut PciFunctionHandle,
function: &PciFunction,
allocated_bars: &AllocatedBars,
) -> Result<(InterruptMethod, InterruptSources)> {
@@ -184,7 +184,7 @@ fn get_int_method(
//TODO: MSI on non-x86_64?
#[cfg(not(target_arch = "x86_64"))]
fn get_int_method(
pcid_handle: &mut PcidServerHandle,
pcid_handle: &mut PciFunctionHandle,
function: &PciFunction,
allocated_bars: &AllocatedBars,
) -> Result<(InterruptMethod, InterruptSources)> {
@@ -246,7 +246,7 @@ fn main() {
}
fn daemon(daemon: redox_daemon::Daemon) -> ! {
let mut pcid_handle =
PcidServerHandle::connect_default().expect("nvmed: failed to setup channel to pcid");
PciFunctionHandle::connect_default().expect("nvmed: failed to setup channel to pcid");
let pci_config = pcid_handle
.fetch_config()
.expect("nvmed: failed to fetch config");
+3 -3
View File
@@ -23,7 +23,7 @@ use self::cq_reactor::NotifReq;
pub use self::queues::{NvmeCmd, NvmeCmdQueue, NvmeComp, NvmeCompQueue};
use pcid_interface::msi::{MsiInfo, MsixInfo, MsixTableEntry};
use pcid_interface::PcidServerHandle;
use pcid_interface::PciFunctionHandle;
#[cfg(target_arch = "aarch64")]
#[inline(always)]
@@ -173,7 +173,7 @@ pub type AtomicCmdId = AtomicU16;
pub struct Nvme {
interrupt_method: Mutex<InterruptMethod>,
pcid_interface: Mutex<PcidServerHandle>,
pcid_interface: Mutex<PciFunctionHandle>,
regs: RwLock<&'static mut NvmeRegs>,
pub(crate) submission_queues: RwLock<BTreeMap<SqId, (Mutex<NvmeCmdQueue>, CqId)>>,
@@ -209,7 +209,7 @@ impl Nvme {
pub fn new(
address: usize,
interrupt_method: InterruptMethod,
pcid_interface: PcidServerHandle,
pcid_interface: PciFunctionHandle,
reactor_sender: Sender<NotifReq>,
) -> Result<Self> {
Ok(Nvme {
+1 -1
View File
@@ -109,7 +109,7 @@ pub struct BlockVirtRequest {
const_assert_eq!(core::mem::size_of::<BlockVirtRequest>(), 16);
fn deamon(deamon: redox_daemon::Daemon) -> anyhow::Result<()> {
let mut pcid_handle = PcidServerHandle::connect_default()?;
let mut pcid_handle = PciFunctionHandle::connect_default()?;
// Double check that we have the right device.
//
+2 -2
View File
@@ -6,7 +6,7 @@ use std::os::unix::io::AsRawFd;
use std::fs::File;
use std::io::{Result, Read, Write};
use pcid_interface::{PciBar, PcidServerHandle};
use pcid_interface::{PciBar, PciFunctionHandle};
use syscall::flag::EventFlags;
use syscall::io::{Io, Mmio, Pio};
@@ -181,7 +181,7 @@ impl VboxGuestInfo {
fn main() {
let mut pcid_handle =
PcidServerHandle::connect_default().expect("vboxd: failed to setup channel to pcid");
PciFunctionHandle::connect_default().expect("vboxd: failed to setup channel to pcid");
let pci_config = pcid_handle
.fetch_config()
.expect("vboxd: failed to fetch config");
+2 -2
View File
@@ -8,7 +8,7 @@ use crate::{probe::MappedMsixRegs, MSIX_PRIMARY_VECTOR};
use pcid_interface::*;
pub fn enable_msix(pcid_handle: &mut PcidServerHandle) -> Result<File, Error> {
pub fn enable_msix(pcid_handle: &mut PciFunctionHandle) -> Result<File, Error> {
let pci_config = pcid_handle.fetch_config()?;
// Extended message signaled interrupts.
@@ -50,7 +50,7 @@ pub fn enable_msix(pcid_handle: &mut PcidServerHandle) -> Result<File, Error> {
pub fn probe_legacy_port_transport(
pci_config: &SubdriverArguments,
pcid_handle: &mut PcidServerHandle,
pcid_handle: &mut PciFunctionHandle,
) -> Result<Device, Error> {
let port = pci_config.func.bars[0].expect_port();
+2 -2
View File
@@ -41,7 +41,7 @@ static_assertions::const_assert_eq!(std::mem::size_of::<MsixTableEntry>(), 16);
pub const MSIX_PRIMARY_VECTOR: u16 = 0;
#[cfg(not(target_arch = "x86_64"))]
fn enable_msix(pcid_handle: &mut PcidServerHandle) -> Result<File, Error> {
fn enable_msix(pcid_handle: &mut PciFunctionHandle) -> Result<File, Error> {
panic!("Msi-X only supported on x86_64");
}
@@ -59,7 +59,7 @@ fn enable_msix(pcid_handle: &mut PcidServerHandle) -> Result<File, Error> {
///
/// ## Panics
/// This function panics if the device is not a virtio device.
pub fn probe_device(pcid_handle: &mut PcidServerHandle) -> Result<Device, Error> {
pub fn probe_device(pcid_handle: &mut PciFunctionHandle) -> Result<Device, Error> {
let pci_config = pcid_handle.fetch_config()?;
assert_eq!(
+4 -4
View File
@@ -12,7 +12,7 @@ use std::sync::{Arc, Mutex};
use std::env;
use libredox::flag;
use pcid_interface::{MsiSetFeatureInfo, PcidServerHandle, PciFeature, PciFeatureInfo, SetFeatureInfo};
use pcid_interface::{MsiSetFeatureInfo, PciFunctionHandle, PciFeature, PciFeatureInfo, SetFeatureInfo};
#[cfg(target_arch = "x86_64")]
use pcid_interface::irq_helpers::allocate_single_interrupt_vector_for_msi;
use pcid_interface::irq_helpers::read_bsp_apic_id;
@@ -85,7 +85,7 @@ fn setup_logging(name: &str) -> Option<&'static RedoxLogger> {
}
#[cfg(target_arch = "x86_64")]
fn get_int_method(pcid_handle: &mut PcidServerHandle, bar0_address: usize) -> (Option<File>, InterruptMethod) {
fn get_int_method(pcid_handle: &mut PciFunctionHandle, bar0_address: usize) -> (Option<File>, InterruptMethod) {
let pci_config = pcid_handle.fetch_config().expect("xhcid: failed to fetch config");
let all_pci_features = pcid_handle.fetch_all_features().expect("xhcid: failed to fetch pci features");
@@ -167,7 +167,7 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle, bar0_address: usize) -> (O
//TODO: MSI on non-x86_64?
#[cfg(not(target_arch = "x86_64"))]
fn get_int_method(pcid_handle: &mut PcidServerHandle, address: usize) -> (Option<File>, InterruptMethod) {
fn get_int_method(pcid_handle: &mut PciFunctionHandle, address: usize) -> (Option<File>, InterruptMethod) {
let pci_config = pcid_handle.fetch_config().expect("xhcid: failed to fetch config");
if let Some(irq) = pci_config.func.legacy_interrupt_line {
@@ -184,7 +184,7 @@ fn main() {
}
fn daemon(daemon: redox_daemon::Daemon) -> ! {
let mut pcid_handle = PcidServerHandle::connect_default().expect("xhcid: failed to setup channel to pcid");
let mut pcid_handle = PciFunctionHandle::connect_default().expect("xhcid: failed to setup channel to pcid");
let pci_config = pcid_handle.fetch_config().expect("xhcid: failed to fetch config");
let mut name = pci_config.func.name();
+3 -3
View File
@@ -22,7 +22,7 @@ use serde::Deserialize;
use crate::usb;
use pcid_interface::msi::{MsixInfo, MsixTableEntry};
use pcid_interface::{PcidServerHandle, PciFeature};
use pcid_interface::{PciFunctionHandle, PciFeature};
mod capability;
mod context;
@@ -198,7 +198,7 @@ pub struct Xhci {
scheme_name: String,
interrupt_method: InterruptMethod,
pcid_handle: Mutex<PcidServerHandle>,
pcid_handle: Mutex<PciFunctionHandle>,
irq_reactor: Mutex<Option<thread::JoinHandle<()>>>,
@@ -258,7 +258,7 @@ impl EndpointState {
}
impl Xhci {
pub fn new(scheme_name: String, address: usize, interrupt_method: InterruptMethod, pcid_handle: PcidServerHandle) -> Result<Xhci> {
pub fn new(scheme_name: String, address: usize, interrupt_method: InterruptMethod, pcid_handle: PciFunctionHandle) -> Result<Xhci> {
let cap = unsafe { &mut *(address as *mut CapabilityRegs) };
debug!("CAP REGS BASE {:X}", address);