Difference between revisions of "Unit PL050"

From Ultibo.org
Jump to: navigation, search
Line 317: Line 317:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Address'''
+
! Address
 
| The address of the PL050 registers
 
| The address of the PL050 registers
 
|-
 
|-
! '''Name'''
+
! Name
 
| The text description of this device which will show in the device list (Optional)
 
| The text description of this device which will show in the device list (Optional)
 
|-
 
|-
! '''IRQ'''
+
! IRQ
 
| The interrupt number for the PL050
 
| The interrupt number for the PL050
 
|-
 
|-
! '''ClockRate'''
+
! ClockRate
 
| The clock source frequency for the PL050
 
| The clock source frequency for the PL050
 
|-
 
|-
! '''Return'''
+
! Return
 
| Pointer to the new Keyboard device or nil if the Keyboard device could not be created
 
| Pointer to the new Keyboard device or nil if the Keyboard device could not be created
 
|-
 
|-
Line 341: Line 341:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The Keyboard device to destroy
 
| The Keyboard device to destroy
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 356: Line 356:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Address'''
+
! Address
 
| The address of the PL050 registers
 
| The address of the PL050 registers
 
|-
 
|-
! '''Name'''
+
! Name
 
| The text description of this device which will show in the device list (Optional)
 
| The text description of this device which will show in the device list (Optional)
 
|-
 
|-
! '''IRQ'''
+
! IRQ
 
| The interrupt number for the PL050
 
| The interrupt number for the PL050
 
|-
 
|-
! '''ClockRate'''
+
! ClockRate
 
| The clock source frequency for the PL050
 
| The clock source frequency for the PL050
 
|-
 
|-
! '''Return'''
+
! Return
 
| Pointer to the new Mouse device or nil if the Mouse device could not be created
 
| Pointer to the new Mouse device or nil if the Mouse device could not be created
 
|-
 
|-
Line 380: Line 380:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Mouse'''
+
! Mouse
 
| The Mouse device to destroy
 
| The Mouse device to destroy
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 398: Line 398:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| Not intended to be called directly by applications, use KeyboardDeviceControl instead
+
| Not intended to be called directly by applications, use KeyboardDeviceControl instead.
 
|-
 
|-
 
|}
 
|}
Line 410: Line 410:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| Not intended to be called directly by applications
 
| Not intended to be called directly by applications
 
|-
 
|-
Line 422: Line 422:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| Not intended to be called directly by applications
 
| Not intended to be called directly by applications
 
|-
 
|-
Line 437: Line 437:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| Not intended to be called directly by applications, use MouseDeviceControl instead
+
| Not intended to be called directly by applications, use MouseDeviceControl instead.
 
|-
 
|-
 
|}
 
|}
Line 449: Line 449:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| Not intended to be called directly by applications
 
| Not intended to be called directly by applications
 
|-
 
|-
Line 461: Line 461:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| Not intended to be called directly by applications
 
| Not intended to be called directly by applications
 
|-
 
|-
Line 476: Line 476:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Registers'''
+
! Registers
 
| Pointer to the PL050 KMI registers for the device
 
| Pointer to the PL050 KMI registers for the device
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 491: Line 491:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Registers'''
+
! Registers
 
| Pointer to the PL050 KMI registers for the device
 
| Pointer to the PL050 KMI registers for the device
 
|-
 
|-
! '''Value'''
+
! Value
 
| The returned value read from the device
 
| The returned value read from the device
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 509: Line 509:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Registers'''
+
! Registers
 
| Pointer to the PL050 KMI registers for the device
 
| Pointer to the PL050 KMI registers for the device
 
|-
 
|-
! '''Value'''
+
! Value
 
| The data value to write to the device
 
| The data value to write to the device
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 527: Line 527:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Registers'''
+
! Registers
 
| Pointer to the PL050 KMI registers for the device
 
| Pointer to the PL050 KMI registers for the device
 
|-
 
|-
! '''Command'''
+
! Command
 
| The PS/2 command to send to the device
 
| The PS/2 command to send to the device
 
|-
 
|-
! '''Data'''
+
! Data
 
| Pointer to the data to be sent with the command (Optional)
 
| Pointer to the data to be sent with the command (Optional)
 
|-
 
|-
! '''DataSize'''
+
! DataSize
 
| The size in bytes of the data to be sent
 
| The size in bytes of the data to be sent
 
|-
 
|-
! '''Response'''
+
! Response
 
| Pointer to a buffer to store the response from the device (Optional)
 
| Pointer to a buffer to store the response from the device (Optional)
 
|-
 
|-
! '''ResponseSize'''
+
! ResponseSize
 
| The size in bytes of the response to be received
 
| The size in bytes of the response to be received
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 557: Line 557:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The keyboard device to reset
 
| The keyboard device to reset
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 572: Line 572:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The keyboard device to enable
 
| The keyboard device to enable
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 587: Line 587:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The keyboard device to disable
 
| The keyboard device to disable
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 602: Line 602:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The keyboard device to set the scancode set for
 
| The keyboard device to set the scancode set for
 
|-
 
|-
! '''LEDs'''
+
! LEDs
 
| Type keyboard LED values to set (eg KEYBOARD_LED_CAPSLOCK)
 
| Type keyboard LED values to set (eg KEYBOARD_LED_CAPSLOCK)
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
! '''Note'''
+
! Note
 
| Caller must hold the keyboard lock
 
| Caller must hold the keyboard lock
 
|-
 
|-
Line 623: Line 623:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The keyboard device to set the scancode set for
 
| The keyboard device to set the scancode set for
 
|-
 
|-
! '''Rate'''
+
! Rate
 
| Type typematic repeat rate to set (Milliseconds)
 
| Type typematic repeat rate to set (Milliseconds)
 
|-
 
|-
! '''Delay'''
+
! Delay
 
| The typematic repeat delay to set (Repeat rate intervals before first repeat)
 
| The typematic repeat delay to set (Repeat rate intervals before first repeat)
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
! '''Note'''
+
! Note
 
| Caller must hold the keyboard lock
 
| Caller must hold the keyboard lock
 
|-
 
|-
Line 647: Line 647:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The keyboard device to get the scancode set from
 
| The keyboard device to get the scancode set from
 
|-
 
|-
! '''ScancodeSet'''
+
! ScancodeSet
 
| The returned scancode set value (eg PS2_KEYBOARD_SCANCODE_SET2)
 
| The returned scancode set value (eg PS2_KEYBOARD_SCANCODE_SET2)
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
! '''Note'''
+
! Note
 
| Caller must hold the keyboard lock
 
| Caller must hold the keyboard lock
 
|-
 
|-
Line 668: Line 668:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The keyboard device to set the scancode set for
 
| The keyboard device to set the scancode set for
 
|-
 
|-
! '''ScancodeSet'''
+
! ScancodeSet
 
| The scancode set to set (eg PS2_KEYBOARD_SCANCODE_SET2)
 
| The scancode set to set (eg PS2_KEYBOARD_SCANCODE_SET2)
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
! '''Note'''
+
! Note
 
| Caller must hold the keyboard lock
 
| Caller must hold the keyboard lock
 
|-
 
|-
Line 689: Line 689:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The keyboard device to check for
 
| The keyboard device to check for
 
|-
 
|-
! '''ScanCode'''
+
! ScanCode
 
| The keyboard scan code to check
 
| The keyboard scan code to check
 
|-
 
|-
! '''Note'''
+
! Note
 
| Caller must hold the keyboard lock
 
| Caller must hold the keyboard lock
 
|-
 
|-
Line 707: Line 707:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Keyboard'''
+
! Keyboard
 
| The keyboard device to check for
 
| The keyboard device to check for
 
|-
 
|-
! '''ScanCode'''
+
! ScanCode
 
| The keyboard scan code to check
 
| The keyboard scan code to check
 
|-
 
|-
! '''Note'''
+
! Note
 
| Caller must hold the keyboard lock
 
| Caller must hold the keyboard lock
 
|-
 
|-
Line 725: Line 725:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Mouse'''
+
! Mouse
 
| The mouse device to reset
 
| The mouse device to reset
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
! '''Note'''
+
! Note
 
| Caller must hold the mouse lock
 
| Caller must hold the mouse lock
 
|-
 
|-
Line 743: Line 743:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Mouse'''
+
! Mouse
 
| The mouse device to enable
 
| The mouse device to enable
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
! '''Note'''
+
! Note
 
| Caller must hold the mouse lock
 
| Caller must hold the mouse lock
 
|-
 
|-
Line 761: Line 761:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Mouse'''
+
! Mouse
 
| The mouse device to disable
 
| The mouse device to disable
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
! '''Note'''
+
! Note
 
| Caller must hold the mouse lock
 
| Caller must hold the mouse lock
 
|-
 
|-
Line 779: Line 779:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Mouse'''
+
! Mouse
 
| The mouse device to set the rate for
 
| The mouse device to set the rate for
 
|-
 
|-
! '''Rate'''
+
! Rate
 
| The sample rate to set (samples per second)
 
| The sample rate to set (samples per second)
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
! '''Note'''
+
! Note
 
| Caller must hold the mouse lock
 
| Caller must hold the mouse lock
 
|-
 
|-

Revision as of 04:51, 24 April 2018

Return to Unit Reference


Description


ARM PrimeCell PL050 PS2 Keyboard/Mouse Interface Driver unit

The PL050 is an Advanced Microcontroller Bus Architecture (AMBA) compliant peripheral that implements a PS/2 compatible Keyboard and Mouse interface. This driver supports all of the standard functionality of the PL050 KMI controller including both Keyboard and Mouse devices as well as setting LEDs, repeat rate, repeat delay and sample rate values.

The driver uses interrupt transfers for receiving keyboard and mouse inputs but uses only polling mode for transmitting data to the keyboard or mouse device. This driver has only been tested with the QEMU Versatile PB emulation of the PL050 device and has not been confirmed to work with real hardware.

Notes:

- Currently QEMU only supports Scancode set 2 so scancode sets 1 and 3 are not implemented.

- On Windows, QEMU appears to send invalid scancodes for Print Screen and Pause/Break keys.

- On Windows, QEMU does not differentiate between the cursor keys (Up, Down, Left, Right, Home, End, PgUp, PgDown) and the numeric keypad keys so each of these will always return their numeric keypad equivalent. This means that to use the cursor keys you need to turn off Number Lock otherwise they are interpreted as number keys instead.

Constants



[Expand]
PL050 specific constants PL050_*


[Expand]
PL050 control register PL050_CR_*


[Expand]
PL050 status register PL050_STAT_*


[Expand]
PL050 interrupt register PL050_IIR_*


Type definitions



PL050 KMI registers

[Expand]

PPL050KMIRegisters = ^TPL050KMIRegisters;

TPL050KMIRegisters = record

PL050 keyboard scancode

[Expand]

PPL050KeyboardScancode = ^TPL050KeyboardScancode;

TPL050KeyboardScancode = record

PL050 keyboard

[Expand]

PPL050Keyboard = ^TPL050Keyboard;

TPL050Keyboard = record

PL050 mouse packet

[Expand]

PPL050MousePacket = ^TPL050MousePacket;

TPL050MousePacket = record

PL050 mouse

[Expand]

PPL050Mouse = ^TPL050Mouse;

TPL050Mouse = record


Public variables


None defined

Function declarations



PL050 functions

[Expand]
function PL050KeyboardCreate(Address:LongWord; const Name:String; IRQ,ClockRate:LongWord):PKeyboardDevice;
Description: Create, register and attach a new PL050 Keyboard device which can be accessed using the keyboard API


[Expand]
function PL050KeyboardDestroy(Keyboard:PKeyboardDevice):LongWord;
Description: Detach, deregister and destroy a PL050 Keyboard device created by this driver


[Expand]
function PL050MouseCreate(Address:LongWord; const Name:String; IRQ,ClockRate:LongWord):PMouseDevice;
Description: Create, register and attach a new PL050 Mouse device which can be accessed using the mouse API


[Expand]
function PL050MouseDestroy(Mouse:PMouseDevice):LongWord;
Description: Detach, deregister and destroy a PL050 Mouse device created by this driver


PL050 keyboard functions

[Expand]
function PL050KeyboardControl(Keyboard:PKeyboardDevice; Request:Integer; Argument1:LongWord; var Argument2:LongWord):LongWord;
Description: Implementation of KeyboardDeviceControl API for PL050 Keyboard


[Expand]
procedure PL050KeyboardInterruptHandler(Keyboard:PKeyboardDevice);
Description: Interrupt handler for the PL050 keyboard device


[Expand]
procedure PL050KeyboardWorker(Scancode:PPL050KeyboardScancode);
Description: Worker function for the PL050 keyboard device, called on a worker thread when a recognized scancode is received by the interrupt handler


PL050 mouse functions

[Expand]
function PL050MouseControl(Mouse:PMouseDevice; Request:Integer; Argument1:LongWord; var Argument2:LongWord):LongWord;
Description: Implementation of MouseDeviceControl API for PL050 Mouse


[Expand]
procedure PL050MouseInterruptHandler(Mouse:PMouseDevice);
Description: Interrupt handler for the PL050 mouse device


[Expand]
procedure PL050MouseWorker(Packet:PPL050MousePacket);
Description: Worker function for the PL050 mouse device, called on a worker thread when a new mouse packet is received by the interrupt handler


PL050 helper functions

[Expand]
function PL050KMIClear(Registers:PPL050KMIRegisters):LongWord;
Description: Clear the read buffer on a PL050 KMI device


[Expand]
function PL050KMIRead(Registers:PPL050KMIRegisters; var Value:Byte):LongWord;
Description: Read one byte of data from a PL050 KMI device


[Expand]
function PL050KMIWrite(Registers:PPL050KMIRegisters; Value:Byte):LongWord;
Description: Write one byte of data to a PL050 KMI device


[Expand]
function PL050KMICommand(Registers:PPL050KMIRegisters; Command:Byte; Data:PByte; DataSize:LongWord; Response:PByte; ResponseSize:LongWord):LongWord;
Description: Send a PS/2 command and data to a PL050 KMI device and wait for the required response


[Expand]
function PL050KMIKeyboardReset(Keyboard:PPL050Keyboard):LongWord;
Description: Reset a PL050 keyboard device


[Expand]
function PL050KMIKeyboardEnable(Keyboard:PPL050Keyboard):LongWord;
Description: Enable a PL050 keyboard device


[Expand]
function PL050KMIKeyboardDisable(Keyboard:PPL050Keyboard):LongWord;
Description: Disable a PL050 keyboard device


[Expand]
function PL050KMIKeyboardSetLEDs(Keyboard:PPL050Keyboard; LEDs:LongWord):LongWord;
Description: Set the keyboard LEDs for a PL050 keyboard device


[Expand]
function PL050KMIKeyboardSetTypematic(Keyboard:PPL050Keyboard; Rate,Delay:LongWord):LongWord;
Description: Set the typematic rate and delay for a PL050 keyboard device


[Expand]
function PL050KMIKeyboardGetScancodeSet(Keyboard:PPL050Keyboard; var ScancodeSet:Byte):LongWord;
Description: Get the current scancode set from a PL050 keyboard device


[Expand]
function PL050KMIKeyboardSetScancodeSet(Keyboard:PPL050Keyboard; ScancodeSet:Byte):LongWord;
Description: Set the scancode set for a PL050 keyboard device


[Expand]
function PL050KMIKeyboardCheckPressed(Keyboard:PPL050Keyboard; ScanCode:Word):Boolean;
Description: Check if the passed scan code has been pressed (True if not previously pressed)


[Expand]
function PL050KMIKeyboardCheckRepeated(Keyboard:PPL050Keyboard; ScanCode:Word):Boolean;
Description: Check if the passed scan code was the last key pressed and if the repeat delay has expired


[Expand]
function PL050KMIMouseReset(Mouse:PPL050Mouse):LongWord;
Description: Reset a PL050 mouse device


[Expand]
function PL050KMIMouseEnable(Mouse:PPL050Mouse):LongWord;
Description: Enable a PL050 mouse device


[Expand]
function PL050KMIMouseDisable(Mouse:PPL050Mouse):LongWord;
Description: Disable a PL050 mouse device


[Expand]
function PL050KMIMouseSetSampleRate(Mouse:PPL050Mouse; Rate:Byte):LongWord;
Description: Set the sample rate on a PL050 mouse device


Return to Unit Reference