pub struct Device<Ctx: DeviceContext = Normal>(/* private fields */);
Expand description
The PCI device representation.
This structure represents the Rust abstraction for a C struct pci_dev
. The implementation
abstracts the usage of an already existing C struct pci_dev
within Rust code that we get
passed from the C side.
§Invariants
A Device
instance represents a valid struct pci_dev
created by the C portion of the
kernel.
Implementations§
Source§impl Device
impl Device
Sourcepub fn revision_id(&self) -> u8
pub fn revision_id(&self) -> u8
Returns the PCI revision ID.
Sourcepub fn subsystem_vendor_id(&self) -> u16
pub fn subsystem_vendor_id(&self) -> u16
Returns the PCI subsystem vendor ID.
Sourcepub fn subsystem_device_id(&self) -> u16
pub fn subsystem_device_id(&self) -> u16
Returns the PCI subsystem device ID.
Sourcepub fn resource_start(&self, bar: u32) -> Result<resource_size_t>
pub fn resource_start(&self, bar: u32) -> Result<resource_size_t>
Returns the start of the given PCI bar resource.
Sourcepub fn resource_len(&self, bar: u32) -> Result<resource_size_t>
pub fn resource_len(&self, bar: u32) -> Result<resource_size_t>
Returns the size of the given PCI bar resource.
Source§impl Device<Bound>
impl Device<Bound>
Sourcepub fn iomap_region_sized<'a, const SIZE: usize>(
&'a self,
bar: u32,
name: &'a CStr,
) -> impl PinInit<Devres<Bar<SIZE>>, Error> + 'a
pub fn iomap_region_sized<'a, const SIZE: usize>( &'a self, bar: u32, name: &'a CStr, ) -> impl PinInit<Devres<Bar<SIZE>>, Error> + 'a
Mapps an entire PCI-BAR after performing a region-request on it. I/O operation bound checks can be performed on compile time for offsets (plus the requested type size) < SIZE.
Sourcepub fn iomap_region<'a>(
&'a self,
bar: u32,
name: &'a CStr,
) -> impl PinInit<Devres<Bar>, Error> + 'a
pub fn iomap_region<'a>( &'a self, bar: u32, name: &'a CStr, ) -> impl PinInit<Devres<Bar>, Error> + 'a
Mapps an entire PCI-BAR after performing a region-request on it.
Sourcepub fn irq_vector(&self, index: u32) -> Result<IrqRequest<'_>>
pub fn irq_vector(&self, index: u32) -> Result<IrqRequest<'_>>
Returns an IrqRequest
for the IRQ vector at the given index, if any.
Sourcepub fn request_irq<'a, T: Handler + 'static>(
&'a self,
index: u32,
flags: Flags,
name: &'static CStr,
handler: impl PinInit<T, Error> + 'a,
) -> Result<impl PinInit<Registration<T>, Error> + 'a>
pub fn request_irq<'a, T: Handler + 'static>( &'a self, index: u32, flags: Flags, name: &'static CStr, handler: impl PinInit<T, Error> + 'a, ) -> Result<impl PinInit<Registration<T>, Error> + 'a>
Returns a kernel::irq::Registration
for the IRQ vector at the given
index.
Sourcepub fn request_threaded_irq<'a, T: ThreadedHandler + 'static>(
&'a self,
index: u32,
flags: Flags,
name: &'static CStr,
handler: impl PinInit<T, Error> + 'a,
) -> Result<impl PinInit<ThreadedRegistration<T>, Error> + 'a>
pub fn request_threaded_irq<'a, T: ThreadedHandler + 'static>( &'a self, index: u32, flags: Flags, name: &'static CStr, handler: impl PinInit<T, Error> + 'a, ) -> Result<impl PinInit<ThreadedRegistration<T>, Error> + 'a>
Returns a kernel::irq::ThreadedRegistration
for the IRQ vector at
the given index.
Source§impl Device<Core>
impl Device<Core>
Sourcepub fn enable_device_mem(&self) -> Result
pub fn enable_device_mem(&self) -> Result
Enable memory resources for this device.
Sourcepub fn set_master(&self)
pub fn set_master(&self)
Enable bus-mastering for this device.
Trait Implementations§
Source§impl AlwaysRefCounted for Device
impl AlwaysRefCounted for Device
Source§impl Deref for Device<CoreInternal>
impl Deref for Device<CoreInternal>
Source§impl Device for Device<Core>
impl Device for Device<Core>
Source§impl From<&Device<CoreInternal>> for ARef<Device>
impl From<&Device<CoreInternal>> for ARef<Device>
Source§fn from(dev: &Device<CoreInternal>) -> Self
fn from(dev: &Device<CoreInternal>) -> Self
impl Send for Device
impl Sync for Device
Auto Trait Implementations§
impl<Ctx = Normal> !Freeze for Device<Ctx>
impl<Ctx = Normal> !RefUnwindSafe for Device<Ctx>
impl<Ctx = Normal> !Send for Device<Ctx>
impl<Ctx = Normal> !Sync for Device<Ctx>
impl<Ctx = Normal> !Unpin for Device<Ctx>
impl<Ctx> UnwindSafe for Device<Ctx>where
Ctx: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> PinInit<T> for T
impl<T> PinInit<T> for T
Source§unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
slot
. Read more