Skip to content
Snippets Groups Projects
Commit 4f19acb7 authored by FUJITA Tomonori's avatar FUJITA Tomonori Committed by Danilo Krummrich
Browse files

rust: add basic PCI driver abstractions


This commit implements the abstractions necessary to bind a most basic
PCI driver to a PCI device. It also serves as a ground layer for further
PCI functionality.

Specifically, a basic PCI driver has to provide register() and
unregister() methods, a PCI device structure for Rust, and probe() and
remove() callbacks for the C side.

A PCI driver shall be able to register itself for the desired devices,
recognized by their device ID. Another basic necessity is the ability to
store driver data, i.e., through pci_set_drvdata().

In congruency with the C implementation of pci_dev, a Rust PCI device
holds a basic device (device::Device) which is always reference counted
to ensure it cannot disappear as long as there are still users.

Holding a basic device allows for both using interfaces that require a
device, as well as such that demand a pci_dev, which can be obtained
through as_raw(), using the established container_of() macro.

Implement a basic driver model with probe() and remove() callbacks,
implementing the corresponding traits from the 'driver' crate.

Implement PCI device IDs.

Implement pci::Device with basic methods, holding an always reference
counted device::Device.

Signed-off-by: default avatarFUJITA Tomonori <fujita.tomonori@gmail.com>
Co-developed-by: default avatarPhilipp Stanner <pstanner@redhat.com>
Signed-off-by: default avatarPhilipp Stanner <pstanner@redhat.com>
Co-developed-by: default avatarDanilo Krummrich <dakr@redhat.com>
Signed-off-by: default avatarDanilo Krummrich <dakr@redhat.com>
parent 5b8860f9
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment