Trait pci_driver::regions::structured::PciBitFieldWriteable
source · [−]pub trait PciBitFieldWriteable: PciBitFieldReadable {
const WRITE_MASK: Self::Type;
fn write(&self, value: Self::Type) -> Result<()>;
}Expand description
A PCI register of type that is a bit field and may be written.
Required Associated Constants
sourceconst WRITE_MASK: Self::Type
const WRITE_MASK: Self::Type
Write mask for the register.
One wants to alter the value of only some bits of the register. However, the register may only be read/written in its entirety. Further, some of the bits in the register may need to be written with the value 0 in order not to change their actual state in the device. This write mask has those bits set to 0, and the others set to 1. Thus, to alter the value of only some bits of the register, this must be done:
- Read the register into
x; - Apply the write mask to
x, i.e.,let y = x & WRITE_MASK; - Modify
yas needed; - Write the resulting value into the register.
Of course, you most likely can just use the member functions that this type provides to manipulate individual parts of the register, but sometimes you may need to do these steps by yourself, e.g., to atomically alter several parts of the register at once.