Claiming a PCI Device from Rust
Before a card can be used, the driver has to switch on its memory decoding so its registers respond at all, and, if the card will move data by itself, mark it as a bus master so it is allowed to write into system memory. The Rust bus type exposes both as methods on the device, with a guard value for enabling so the change is undone when the driver lets go. Skip the first step and every register read returns all ones; skip the second and a transfer started by the card silently never happens. Reading identifying registers from configuration space also happens through this type.
Questions this Concept answers
- Why does the Rust enable call hand back a guard value instead of simply reporting success?
This Concept is waiting for its first lesson!
Before a card can be used, the driver has to switch on its memory decoding so its registers respond at all, and, if the card will move data by itself, mark it as a bus master so it is allowed to write into system memory. The Rust bus type exposes both as methods on the device, with a guard value for enabling so the change is undone when the driver lets go. Skip the first step and every register read returns all ones; skip the second and a transfer started by the card silently never happens. Reading identifying registers from configuration space also happens through this type.
Are you a teacher? Sign in to start contributing.
Sign In