Struct vm_superio::i8042::I8042Device
source · [−]pub struct I8042Device<T: Trigger> { /* private fields */ }
Expand description
An i8042 PS/2 controller that emulates just enough to shutdown the machine.
A Trigger
object is used for notifying the VMM
about the CPU reset event.
Example
struct EventFdTrigger(EventFd);
impl Trigger for EventFdTrigger {
type E = Error;
fn trigger(&self) -> Result<()> {
self.write(1)
}
}
impl Deref for EventFdTrigger {
type Target = EventFd;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl EventFdTrigger {
pub fn new(flag: i32) -> Self {
EventFdTrigger(EventFd::new(flag).unwrap())
}
}
let reset_evt = EventFdTrigger::new(libc::EFD_NONBLOCK);
let mut i8042 = I8042Device::new(reset_evt);
// Check read/write operations.
assert_eq!(i8042.read(0), 0);
i8042.write(4, 0xFE).unwrap();
Implementations
sourceimpl<T: Trigger> I8042Device<T>
impl<T: Trigger> I8042Device<T>
sourcepub fn new(reset_evt: T) -> I8042Device<T>
pub fn new(reset_evt: T) -> I8042Device<T>
Constructs an i8042 device that will signal the given event when the guest requests it.
Arguments
reset_evt
- A Trigger object that will be used to notify the driver about the reset event.
Example
You can see an example of how to use this function in the
Example
section from I8042Device
.
sourcepub fn read(&mut self, _offset: u8) -> u8
pub fn read(&mut self, _offset: u8) -> u8
Handles a read request from the driver at _offset
offset from the
base I/O address.
Returns the read value, which at this moment is 0x00, since we’re not interested in an i8042 operation other than CPU reset.
Arguments
_offset
- The offset that will be added to the base address for writing to a specific register.
Example
You can see an example of how to use this function in the
Example
section from I8042Device
.
sourcepub fn write(&mut self, offset: u8, value: u8) -> Result<(), T::E>
pub fn write(&mut self, offset: u8, value: u8) -> Result<(), T::E>
Handles a write request from the driver at offset
offset from the
base I/O address.
Arguments
offset
- The offset that will be added to the base address for writing to a specific register.value
- The byte that should be written.
Example
You can see an example of how to use this function in the
Example
section from I8042Device
.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for I8042Device<T> where
T: RefUnwindSafe,
impl<T> Send for I8042Device<T> where
T: Send,
impl<T> Sync for I8042Device<T> where
T: Sync,
impl<T> Unpin for I8042Device<T> where
T: Unpin,
impl<T> UnwindSafe for I8042Device<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more