Allow reading PCI header through pcid socket

This commit is contained in:
Jeremy Soller
2022-09-07 12:15:41 -06:00
parent 3ed83c74cf
commit e2a8255547
4 changed files with 20 additions and 4 deletions
+10 -1
View File
@@ -7,7 +7,7 @@ use std::os::unix::io::{FromRawFd, RawFd};
use serde::{Serialize, Deserialize, de::DeserializeOwned};
use thiserror::Error;
pub use crate::pci::PciBar;
pub use crate::pci::{PciBar, PciHeader};
pub use crate::pci::msi;
pub mod irq_helpers;
@@ -169,6 +169,7 @@ pub enum SetFeatureInfo {
#[non_exhaustive]
pub enum PcidClientRequest {
RequestConfig,
RequestHeader,
RequestFeatures,
EnableFeature(PciFeature),
FeatureStatus(PciFeature),
@@ -187,6 +188,7 @@ pub enum PcidServerResponseError {
#[non_exhaustive]
pub enum PcidClientResponse {
Config(SubdriverArguments),
Header(PciHeader),
AllFeatures(Vec<(PciFeature, FeatureStatus)>),
FeatureEnabled(PciFeature),
FeatureStatus(PciFeature, FeatureStatus),
@@ -252,6 +254,13 @@ impl PcidServerHandle {
other => Err(PcidClientHandleError::InvalidResponse(other)),
}
}
pub fn fetch_header(&mut self) -> Result<PciHeader> {
self.send(&PcidClientRequest::RequestHeader)?;
match self.recv()? {
PcidClientResponse::Header(a) => Ok(a),
other => Err(PcidClientHandleError::InvalidResponse(other)),
}
}
pub fn fetch_all_features(&mut self) -> Result<Vec<(PciFeature, FeatureStatus)>> {
self.send(&PcidClientRequest::RequestFeatures)?;
match self.recv()? {