Skip to main content

BusSchemeServer

Struct BusSchemeServer 

Source
pub struct BusSchemeServer {
    drivers: Vec<(String, Box<dyn BusDriver>)>,
    port_handle: u64,
    handles: BTreeMap<u64, OpenHandle>,
    next_id: u64,
    pci_cache: Vec<PciDeviceInfo>,
    find_cache: BTreeMap<(u16, u16), Vec<u8>>,
    name_to_idx: BTreeMap<String, usize>,
}

Fields§

§drivers: Vec<(String, Box<dyn BusDriver>)>§port_handle: u64§handles: BTreeMap<u64, OpenHandle>§next_id: u64§pci_cache: Vec<PciDeviceInfo>§find_cache: BTreeMap<(u16, u16), Vec<u8>>

Rendered pci/find/<vid>/<did> results, keyed by (vendor, device).

Each read of a find file used to re-run the pci_enum syscall and re-render the whole listing; sequential reads of a long result were O(reads × devices). The cache is invalidated on every rescan so results stay coherent with pci/inventory.

§name_to_idx: BTreeMap<String, usize>

Driver-name → index into drivers, built once at construction.

Path resolution is O(log n) instead of a linear scan over all driver names on every open/existence check : significant with the 100–1000 drivers this server is expected to host.

Implementations§

Source§

impl BusSchemeServer

Source

pub fn new(drivers: Vec<(String, Box<dyn BusDriver>)>, port_handle: u64) -> Self

Creates a new instance.

Source

pub fn refresh_pci_cache(&mut self) -> Result<usize, ()>

Performs the refresh pci cache operation.

Returns Ok(count) with the number of devices found, or Err(()) if the underlying pci_enum syscall failed (cache remains unchanged).

Source

fn ok_reply(sender: u64) -> IpcMessage

Source

fn err_reply(sender: u64, code: usize) -> IpcMessage

Source

fn alloc_id(&mut self) -> Option<u64>

Source

fn count_handles_of(&self, sender: u64) -> usize

Count open handles belonging to sender.

Source

fn resolve_driver_path<'a>(&self, path: &'a str) -> Option<(usize, &'a str)>

Split a normalised path into a driver index + sub-path, or detect PCI / root.

Source

fn is_pci_path(path: &str) -> bool

Source

fn path_exists(&self, path: &str) -> bool

Source

fn parse_reg_offset(path: &str) -> Option<usize>

Source

fn parse_hex_usize(s: &str) -> Option<usize>

Parse an unsigned hex value, rejecting inputs from_str_radix would otherwise accept:

  • sign prefixes ("+1f", "-1f"),
  • repeated 0x prefixes ("0x0x10", previously stripped in a loop).
Source

fn parse_hex_u8(s: &str) -> Option<u8>

Source

fn parse_hex_u16(s: &str) -> Option<u16>

Source

fn parse_firewall_id(sub_path: &str) -> Option<u32>

Parses the peripheral id of a firewall/<grant|release>/<id> path.

Source

fn handle_open(&mut self, sender: u64, payload: &[u8]) -> IpcMessage

Source

fn handle_read(&mut self, sender: u64, payload: &[u8]) -> IpcMessage

Source

fn generate_read_content(&mut self, kind: &HandleKind, offset: usize) -> Vec<u8> ⓘ

Source

fn read_pci_content(&mut self, path: &str) -> Vec<u8> ⓘ

Source

fn read_driver_content( &self, driver: &Box<dyn BusDriver>, name: &str, sub_path: &str, ) -> Vec<u8> ⓘ

Source

fn handle_write(&mut self, sender: u64, payload: &[u8]) -> IpcMessage

Source

fn handle_close(&mut self, sender: u64, payload: &[u8]) -> IpcMessage

Source

fn handle_readdir(&self, sender: u64, payload: &[u8]) -> IpcMessage

Source

pub fn dispatch( &mut self, msg_type: u32, sender: u64, payload: &[u8], ) -> IpcMessage

Dispatches one request and returns the reply message.

Public so that the scheme contract can be exercised by host-side integration tests without a live kernel IPC transport.

Source

pub fn serve(&mut self) -> !

Performs the serve operation.

Source

fn normalize_path(path: &str) -> Option<String>

Normalise a client-supplied path for the /bus namespace:

  • collapses repeated /,
  • drops . segments,
  • resolves .. lexically (returns None if it escapes the root).

The root is the empty string. Without this, a path such as pci/../<driver>/reg/x could bypass naive prefix matching if sub-tree resolution ever becomes recursive.

Source

fn parse_pci_bdf(s: &str) -> Option<PciAddress>

Source

fn parse_cfg_path(path: &str) -> Option<(PciAddress, u8, u8)>

Source

fn parse_find_path(path: &str) -> Option<(u16, u16)>

Source

fn render_inventory(&self) -> Vec<u8> ⓘ

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.