pub struct KeyboardController {
output: [u8; 8],
output_len: u8,
input: [u8; 32],
input_len: u8,
last_command: u8,
data_reads: u32,
reply_reads: u32,
scancode_reads: u32,
output_port_write: bool,
controller_data: bool,
}Expand description
Minimal 8042 state with a small controller-to-host output queue.
Fields§
§output: [u8; 8]Bytes waiting for the host on the data port (controller replies).
output_len: u8Number of valid bytes in output (at the front).
input: [u8; 32]Scancodes typed by the host and not read by the guest yet.
input_len: u8Number of valid scancodes in input (at the front).
last_command: u8Last command written to port 0x64.
data_reads: u32Number of data-port reads the guest performed (diagnostics only).
A guest that queues scancodes but never reads 0x60 is the difference
between “the interrupt never arrived” and “the handler read the port”.
reply_reads: u32Reads of 0x60 answered from the controller reply queue (diagnostics).
scancode_reads: u32Reads of 0x60 answered from the host scancode queue (diagnostics).
output_port_write: boolNext data-port write goes to the controller output port, not the
keyboard (set by command 0xD1).
controller_data: boolNext data-port write is a controller parameter (config/aux), not a keyboard command, so it must not produce a keyboard ACK.
Implementations§
Source§impl KeyboardController
impl KeyboardController
Sourcepub fn push_scancode(&mut self, code: u8) -> bool
pub fn push_scancode(&mut self, code: u8) -> bool
Queues one set-1 scancode as if the PS/2 keyboard sent it.
Returns false when the queue is full: the caller keeps the remaining
bytes and retries after the guest has read some.
Sourcepub const fn has_scancode(&self) -> bool
pub const fn has_scancode(&self) -> bool
True while the guest has not read every queued scancode.
Sourcepub const fn pending_scancodes(&self) -> u8
pub const fn pending_scancodes(&self) -> u8
Number of scancodes waiting to be read by the guest.
Sourcepub const fn data_reads(&self) -> u32
pub const fn data_reads(&self) -> u32
Number of data-port reads observed so far (diagnostics only).
Sourcepub const fn reply_reads(&self) -> u32
pub const fn reply_reads(&self) -> u32
Reads of 0x60 answered from the controller reply queue.
Sourcepub const fn scancode_reads(&self) -> u32
pub const fn scancode_reads(&self) -> u32
Reads of 0x60 answered from the host scancode queue.
Sourcepub const fn last_command(&self) -> u8
pub const fn last_command(&self) -> u8
Last command written to the status port (diagnostics).
Sourcefn write_data(&mut self, value: u8)
fn write_data(&mut self, value: u8)
Handles a data-port write (keyboard command or parameter).
Sourcefn write_command(&mut self, value: u8)
fn write_command(&mut self, value: u8)
Handles a status-port write (controller command).
Sourcefn pop_input_front(&mut self)
fn pop_input_front(&mut self)
Drops the front scancode of the input queue.
Trait Implementations§
Source§impl Clone for KeyboardController
impl Clone for KeyboardController
impl Copy for KeyboardController
Source§impl Debug for KeyboardController
impl Debug for KeyboardController
Source§impl Default for KeyboardController
impl Default for KeyboardController
impl Eq for KeyboardController
Source§impl PartialEq for KeyboardController
impl PartialEq for KeyboardController
impl StructuralPartialEq for KeyboardController
Auto Trait Implementations§
impl Forget for KeyboardController
impl Freeze for KeyboardController
impl Move for KeyboardController
impl RefUnwindSafe for KeyboardController
impl Send for KeyboardController
impl Sync for KeyboardController
impl Unpin for KeyboardController
impl UnsafeUnpin for KeyboardController
impl UnwindSafe for KeyboardController
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more