[][src]Struct ps2::Controller

pub struct Controller { /* fields omitted */ }

The PS/2 controller.

Provides the functionality of an Intel 8042 chip. Many computers nowadays don't have PS/2 connectors, but emulate the mouse and keyboard as PS/2 devices through USB. The implementation of this emulation is usually different from manufacturer to manufacturer and cannot always be relied upon to perform correctly. Therefore, if you're writing an operating system, you should disable this legacy support once the USB controller has been initialized.

Implementations

impl Controller[src]

pub const unsafe fn new() -> Self[src]

Create a handle to the PS/2 controller.

Safety

This should usually only be called once. Only one Controller should be able to access the command and data ports at a given time. Ensure that IO ports 0x60 and 0x64 are not accessed by any other code.

pub const fn keyboard(&mut self) -> Keyboard<'_>[src]

Obtain a handle to the keyboard.

pub const fn mouse(&mut self) -> Mouse<'_>[src]

Obtain a handle to the mouse.

pub fn read_status(&mut self) -> ControllerStatusFlags[src]

Read the status register of the controller.

pub fn read_data(&mut self) -> Result<u8, ControllerError>[src]

Read a byte from the data buffer once it is full.

If there is no data available to read within a small timeout, this will return ControllerError::Timeout.

pub fn write_data(&mut self, data: u8) -> Result<(), ControllerError>[src]

Write a byte to the data buffer once it is empty.

pub fn read_internal_ram(
    &mut self,
    byte_number: u8
) -> Result<u8, ControllerError>
[src]

Read a byte from the controller's internal RAM.

The desired byte index must be between 0 and 31. Byte 0 is also known as the configuration byte or command byte.

pub fn write_internal_ram(
    &mut self,
    byte_number: u8,
    data: u8
) -> Result<(), ControllerError>
[src]

Write a byte to the controller's internal RAM.

The desired byte index must be between 0 and 31. Byte 0 is also known as the configuration byte or command byte.

pub fn read_config(&mut self) -> Result<ControllerConfigFlags, ControllerError>[src]

Read the configuration byte (or command byte) of the controller. This is the same as reading byte 0 of the internal RAM.

pub fn write_config(
    &mut self,
    config: ControllerConfigFlags
) -> Result<(), ControllerError>
[src]

Write the configuration byte (or command byte) of the controller. This is the same as writing to byte 0 of the internal RAM.

pub fn disable_mouse(&mut self) -> Result<(), ControllerError>[src]

Disable the mouse. Sets the ControllerConfigFlags::DISABLE_MOUSE flag.

pub fn enable_mouse(&mut self) -> Result<(), ControllerError>[src]

Enable the mouse. Clears the ControllerConfigFlags::DISABLE_MOUSE flag.

pub fn test_mouse(&mut self) -> Result<(), ControllerError>[src]

Perform a self-test on the mouse.

Returns ControllerError::TestFailed if the test fails.

pub fn test_controller(&mut self) -> Result<(), ControllerError>[src]

Perform a self-test on the controller.

Returns ControllerError::TestFailed if the test fails.

pub fn test_keyboard(&mut self) -> Result<(), ControllerError>[src]

Perform a self-test on the keyboard.

Returns ControllerError::TestFailed if the test fails.

pub fn diagnostic_dump(&mut self) -> Result<[u8; 32], ControllerError>[src]

Dump all bytes of the controller's internal RAM.

pub fn disable_keyboard(&mut self) -> Result<(), ControllerError>[src]

Disable the keyboard.

Sets the ControllerConfigFlags::DISABLE_KEYBOARD flag.

pub fn enable_keyboard(&mut self) -> Result<(), ControllerError>[src]

Enable the keyboard.

Clears the ControllerConfigFlags::DISABLE_KEYBOARD flag.

pub fn read_input_port(&mut self) -> Result<InputPortFlags, ControllerError>[src]

Read the state of the controller's input port.

pub fn write_input_low_nibble_to_status(
    &mut self
) -> Result<(), ControllerError>
[src]

Write the low nibble of the controller's input port to the low nibble of the controller status register.

pub fn write_input_high_nibble_to_status(
    &mut self
) -> Result<(), ControllerError>
[src]

Write the high nibble of the controller's input port to the high nibble of the controller status register.

pub fn read_output_port(&mut self) -> Result<OutputPortFlags, ControllerError>[src]

Read the state of the controller's output port.

pub fn write_output_port(
    &mut self,
    output: OutputPortFlags
) -> Result<(), ControllerError>
[src]

Write the state of the controller's output port.

pub fn write_keyboard_buffer(&mut self, data: u8) -> Result<(), ControllerError>[src]

Write a byte to the data buffer as if it were received from the keyboard.

This will trigger an interrupt if interrupts are enabled.

pub fn write_mouse_buffer(&mut self, data: u8) -> Result<(), ControllerError>[src]

Write a byte to the data buffer as if it were received from the mouse.

This will trigger an interrupt if interrupts are enabled.

pub fn write_mouse(&mut self, data: u8) -> Result<(), ControllerError>[src]

Write a byte to the mouse's data buffer.

pub fn read_test_port(&mut self) -> Result<TestPortFlags, ControllerError>[src]

Read the state of the controller's test port.

pub fn pulse_output_low_nibble(
    &mut self,
    data: u8
) -> Result<(), ControllerError>
[src]

Pulse the low nibble of the given byte onto the lower nibble of the controller output port.

Trait Implementations

impl Debug for Controller[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.