pcid: Don't include source files in two different crates
This confuses rust-analyzer.
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@ use std::ops::Range;
|
||||
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::driver_interface::FullDeviceId;
|
||||
use pcid_interface::FullDeviceId;
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize)]
|
||||
pub struct Config {
|
||||
|
||||
@@ -8,7 +8,6 @@ use log::{error, info};
|
||||
use pci_types::capability::{MultipleMessageSupport, PciCapability};
|
||||
use pci_types::{ConfigRegionAccess, PciAddress};
|
||||
|
||||
use crate::driver_interface;
|
||||
use crate::State;
|
||||
|
||||
pub struct DriverHandler {
|
||||
@@ -21,11 +20,11 @@ pub struct DriverHandler {
|
||||
impl DriverHandler {
|
||||
pub fn spawn(
|
||||
state: Arc<State>,
|
||||
func: driver_interface::PciFunction,
|
||||
func: pcid_interface::PciFunction,
|
||||
capabilities: Vec<PciCapability>,
|
||||
args: &[String],
|
||||
) {
|
||||
let subdriver_args = driver_interface::SubdriverArguments { func };
|
||||
let subdriver_args = pcid_interface::SubdriverArguments { func };
|
||||
|
||||
let mut args = args.iter();
|
||||
if let Some(program) = args.next() {
|
||||
@@ -94,11 +93,12 @@ impl DriverHandler {
|
||||
|
||||
fn respond(
|
||||
&mut self,
|
||||
request: driver_interface::PcidClientRequest,
|
||||
args: &driver_interface::SubdriverArguments,
|
||||
) -> driver_interface::PcidClientResponse {
|
||||
use driver_interface::*;
|
||||
request: pcid_interface::PcidClientRequest,
|
||||
args: &pcid_interface::SubdriverArguments,
|
||||
) -> pcid_interface::PcidClientResponse {
|
||||
use pcid_interface::*;
|
||||
|
||||
#[forbid(non_exhaustive_omitted_patterns)]
|
||||
match request {
|
||||
PcidClientRequest::RequestVendorCapabilities => PcidClientResponse::VendorCapabilities(
|
||||
self.capabilities
|
||||
@@ -320,6 +320,7 @@ impl DriverHandler {
|
||||
);
|
||||
}
|
||||
}
|
||||
_ => unreachable!(),
|
||||
},
|
||||
PcidClientRequest::ReadConfig(offset) => {
|
||||
let value = unsafe { self.state.pcie.read(self.addr, offset) };
|
||||
@@ -331,15 +332,16 @@ impl DriverHandler {
|
||||
}
|
||||
return PcidClientResponse::WriteConfig;
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
fn handle_spawn(
|
||||
mut self,
|
||||
pcid_to_client_write: usize,
|
||||
pcid_from_client_read: usize,
|
||||
args: driver_interface::SubdriverArguments,
|
||||
args: pcid_interface::SubdriverArguments,
|
||||
) {
|
||||
use driver_interface::*;
|
||||
use pcid_interface::*;
|
||||
|
||||
let mut pcid_to_client = unsafe { File::from_raw_fd(pcid_to_client_write as RawFd) };
|
||||
let mut pcid_from_client = unsafe { File::from_raw_fd(pcid_from_client_read as RawFd) };
|
||||
|
||||
@@ -8,7 +8,7 @@ pub struct VendorSpecificCapability {
|
||||
}
|
||||
|
||||
impl VendorSpecificCapability {
|
||||
pub(crate) unsafe fn parse(
|
||||
pub unsafe fn parse(
|
||||
addr: PciCapabilityAddress,
|
||||
access: &dyn ConfigRegionAccess,
|
||||
) -> Self {
|
||||
|
||||
@@ -13,7 +13,7 @@ pub struct FullDeviceId {
|
||||
}
|
||||
|
||||
impl FullDeviceId {
|
||||
pub(crate) fn display(&self) -> String {
|
||||
pub fn display(&self) -> String {
|
||||
let mut string = format!(
|
||||
"{:>04X}:{:>04X} {:>02X}.{:>02X}.{:>02X}.{:>02X} {:?}",
|
||||
self.vendor_id,
|
||||
|
||||
@@ -194,5 +194,5 @@ pub fn allocate_single_interrupt_vector_for_msi(cpu_id: usize) -> (MsiAddrAndDat
|
||||
let msg_data =
|
||||
x86_msix::message_data_edge_triggered(x86_msix::DeliveryMode::Fixed, vector);
|
||||
|
||||
(MsiAddrAndData::new(addr, msg_data), interrupt_handle)
|
||||
(MsiAddrAndData { addr, data: msg_data }, interrupt_handle)
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ pub mod irq_helpers;
|
||||
pub mod msi;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
|
||||
pub struct LegacyInterruptLine(pub(crate) u8);
|
||||
pub struct LegacyInterruptLine(#[doc(hidden)] pub u8);
|
||||
|
||||
impl LegacyInterruptLine {
|
||||
/// Get an IRQ handle for this interrupt line.
|
||||
@@ -257,7 +257,8 @@ pub struct PciFunctionHandle {
|
||||
mapped_bars: [Option<MappedBar>; 6],
|
||||
}
|
||||
|
||||
pub(crate) fn send<W: Write, T: Serialize>(w: &mut W, message: &T) -> Result<()> {
|
||||
#[doc(hidden)]
|
||||
pub fn send<W: Write, T: Serialize>(w: &mut W, message: &T) -> Result<()> {
|
||||
let mut data = Vec::new();
|
||||
bincode::serialize_into(&mut data, message)?;
|
||||
let length_bytes = u64::to_le_bytes(data.len() as u64);
|
||||
@@ -265,7 +266,8 @@ pub(crate) fn send<W: Write, T: Serialize>(w: &mut W, message: &T) -> Result<()>
|
||||
w.write_all(&data)?;
|
||||
Ok(())
|
||||
}
|
||||
pub(crate) fn recv<R: Read, T: DeserializeOwned>(r: &mut R) -> Result<T> {
|
||||
#[doc(hidden)]
|
||||
pub fn recv<R: Read, T: DeserializeOwned>(r: &mut R) -> Result<T> {
|
||||
let mut length_bytes = [0u8; 8];
|
||||
r.read_exact(&mut length_bytes)?;
|
||||
let length = u64::from_le_bytes(length_bytes);
|
||||
|
||||
@@ -11,14 +11,8 @@ use syscall::{Io, Mmio};
|
||||
/// For MSI-X you can have a single [MsiEntry] for each interrupt vector.
|
||||
#[derive(Debug, Default, Serialize, Deserialize)]
|
||||
pub struct MsiAddrAndData {
|
||||
pub(crate) addr: u64,
|
||||
pub(crate) data: u32,
|
||||
}
|
||||
|
||||
impl MsiAddrAndData {
|
||||
pub fn new(addr: u64, data: u32) -> Self {
|
||||
MsiAddrAndData { addr, data }
|
||||
}
|
||||
pub addr: u64,
|
||||
pub data: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
|
||||
+4
-3
@@ -1,3 +1,5 @@
|
||||
#![feature(non_exhaustive_omitted_patterns_lint)]
|
||||
|
||||
use std::fs::{metadata, read_dir, File};
|
||||
use std::io::prelude::*;
|
||||
use std::sync::{Arc, Mutex};
|
||||
@@ -13,12 +15,11 @@ use structopt::StructOpt;
|
||||
|
||||
use crate::cfg_access::Pcie;
|
||||
use crate::config::Config;
|
||||
use crate::driver_interface::{FullDeviceId, LegacyInterruptLine, PciBar};
|
||||
use pcid_interface::{FullDeviceId, LegacyInterruptLine, PciBar};
|
||||
|
||||
mod cfg_access;
|
||||
mod config;
|
||||
mod driver_handler;
|
||||
mod driver_interface;
|
||||
|
||||
#[derive(StructOpt)]
|
||||
#[structopt(about)]
|
||||
@@ -150,7 +151,7 @@ fn handle_parsed_header(
|
||||
capabilities
|
||||
);
|
||||
|
||||
let func = driver_interface::PciFunction {
|
||||
let func = pcid_interface::PciFunction {
|
||||
bars,
|
||||
addr: endpoint_header.header().address(),
|
||||
legacy_interrupt_line: if legacy_interrupt_enabled {
|
||||
|
||||
Reference in New Issue
Block a user