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

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.

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.

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.