Ultibo API
C/C++ API for Ultibo Core
Loading...
Searching...
No Matches
pl050.h
Go to the documentation of this file.
1/*
2 * This file is part of the Ultibo project, https://ultibo.org/
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2026 Garry Wood <garry@softoz.com.au>
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26#ifndef _ULTIBO_PL050_H
27#define _ULTIBO_PL050_H
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include "ultibo/keyboard.h"
34#include "ultibo/mouse.h"
35#include "ultibo/ps2.h"
36
38#define PL050_KEYBOARD_DESCRIPTION "ARM PrimeCell PL050 PS2 Keyboard"
39#define PL050_MOUSE_DESCRIPTION "ARM PrimeCell PL050 PS2 Mouse"
40
41#define PL050_KEYBOARD_SCANCODE_COUNT 256
42#define PL050_MOUSE_PACKET_COUNT 256
43
44#define PL050_KEYBOARD_CLOCK_RATE 8000000
45#define PL050_MOUSE_CLOCK_RATE 8000000
46
47#define PL050_KEYBOARD_SHIFTSTATE_MASK KEYBOARD_LEFT_CTRL | KEYBOARD_LEFT_SHIFT | KEYBOARD_LEFT_ALT | KEYBOARD_RIGHT_CTRL | KEYBOARD_RIGHT_SHIFT | KEYBOARD_RIGHT_ALT
48
50#define PL050_CR_TYPE (1 << 5)
51#define PL050_CR_RXINTREN (1 << 4)
52#define PL050_CR_TXINTREN (1 << 3)
53#define PL050_CR_EN (1 << 2)
54#define PL050_CR_FDL (1 << 1)
55#define PL050_CR_FCL (1 << 0)
56
58#define PL050_STAT_TXEMPTY (1 << 6)
59#define PL050_STAT_TXBUSY (1 << 5)
60#define PL050_STAT_RXFULL (1 << 4)
61#define PL050_STAT_RXBUSY (1 << 3)
62#define PL050_STAT_RXPARITY (1 << 2)
63#define PL050_STAT_IC (1 << 1)
64#define PL050_STAT_ID (1 << 0)
65
67#define PL050_IIR_TXINTR (1 << 1)
68#define PL050_IIR_RXINTR (1 << 0)
69
74{
75 uint32_t cr;
76 uint32_t stat;
77 uint32_t data;
78 uint32_t clkdiv;
79 uint32_t iir;
80};
81
82
84
93
94
96{
97 // Keyboard Properties
99 // PL050 Properties
100 uint32_t irq;
102 uint8_t scancodeset;
104 uint32_t scancodestart;
105 uint32_t scancodecount;
106 uint16_t lastcode;
107 uint32_t shiftstate;
108 // Statistics Properties
109 uint32_t discardcount;
110 uint32_t interruptcount;
111};
112
113
115
123
124
126{
127 // Mouse Properties
129 // PL050 Properties
130 uint32_t irq;
133 uint32_t packetstart;
134 uint32_t packetcount;
135 // Statistics Properties
136 uint32_t discardcount;
137 uint32_t interruptcount;
138};
139
141
150KEYBOARD_DEVICE * STDCALL pl050_keyboard_create(size_t address, char *name, uint32_t irq, uint32_t clockrate);
151
158
167MOUSE_DEVICE * STDCALL pl050_mouse_create(size_t address, char *name, uint32_t irq, uint32_t clockrate);
168
175
176#ifdef __cplusplus
177}
178#endif
179
180#endif // _ULTIBO_PL050_H
#define STDCALL
Definition globaltypes.h:45
struct _KEYBOARD_DEVICE KEYBOARD_DEVICE
Definition keyboard.h:203
struct _MOUSE_DEVICE MOUSE_DEVICE
Definition mouse.h:193
struct _PL050_MOUSE PL050_MOUSE
Definition pl050.h:114
struct _PL050_KMI_REGISTERS PL050_KMI_REGISTERS
Definition pl050.h:72
MOUSE_DEVICE *STDCALL pl050_mouse_create(size_t address, char *name, uint32_t irq, uint32_t clockrate)
Create, register and attach a new PL050 Mouse device which can be accessed using the mouse API.
#define PL050_KEYBOARD_SCANCODE_COUNT
Number of keyboard scancode buffers for receive.
Definition pl050.h:41
uint32_t STDCALL pl050_keyboard_destroy(KEYBOARD_DEVICE *keyboard)
Detach, deregister and destroy a PL050 Keyboard device created by this driver.
struct _PL050_KEYBOARD_SCANCODE PL050_KEYBOARD_SCANCODE
Definition pl050.h:85
uint32_t STDCALL pl050_mouse_destroy(MOUSE_DEVICE *mouse)
Detach, deregister and destroy a PL050 Mouse device created by this driver.
#define PL050_MOUSE_PACKET_COUNT
Number of mouse packet buffers for receive.
Definition pl050.h:42
KEYBOARD_DEVICE *STDCALL pl050_keyboard_create(size_t address, char *name, uint32_t irq, uint32_t clockrate)
Create, register and attach a new PL050 Keyboard device which can be accessed using the keyboard API.
struct _PL050_KEYBOARD PL050_KEYBOARD
Definition pl050.h:83
struct _PL050_MOUSE_PACKET PL050_MOUSE_PACKET
Definition pl050.h:116
struct _PS2_KEYBOARD_SCANCODE PS2_KEYBOARD_SCANCODE
Definition ps2.h:169
Definition pl050.h:87
PL050_KEYBOARD * keyboard
Definition pl050.h:88
uint32_t count
Definition pl050.h:89
PS2_KEYBOARD_SCANCODE scancode
Definition pl050.h:91
int32_t index
Definition pl050.h:90
Definition pl050.h:96
uint32_t discardcount
Number of received bytes discarded (due to no buffer or other reasons).
Definition pl050.h:109
uint32_t irq
Definition pl050.h:100
PL050_KEYBOARD_SCANCODE scancodedata[PL050_KEYBOARD_SCANCODE_COUNT]
Buffers for scancode receiving.
Definition pl050.h:103
PL050_KMI_REGISTERS * registers
Device registers.
Definition pl050.h:101
uint32_t scancodestart
The scancode buffer to use for the next receive.
Definition pl050.h:104
uint8_t scancodeset
The currently selected scancode set.
Definition pl050.h:102
uint16_t lastcode
The scan code of the last key pressed.
Definition pl050.h:106
uint32_t interruptcount
Number of interrupt requests received by the device.
Definition pl050.h:110
uint32_t scancodecount
The number of scancode buffers that are in use.
Definition pl050.h:105
uint32_t shiftstate
The modifier flags of the current shift state.
Definition pl050.h:107
KEYBOARD_DEVICE keyboard
Definition pl050.h:98
Definition pl050.h:74
uint32_t iir
Interrupt status register.
Definition pl050.h:79
uint32_t data
Received data (read)/ Data to be transmitted (write).
Definition pl050.h:77
uint32_t clkdiv
Clock divisor register.
Definition pl050.h:78
uint32_t stat
Status register.
Definition pl050.h:76
uint32_t cr
Control register.
Definition pl050.h:75
Definition pl050.h:118
PL050_MOUSE * mouse
Definition pl050.h:119
PL050_MOUSE_PACKET packet
Definition pl050.h:121
uint32_t count
Definition pl050.h:120
Definition pl050.h:126
PL050_MOUSE_PACKET packetdata[PL050_MOUSE_PACKET_COUNT]
Buffers for mouse packet receiving.
Definition pl050.h:132
uint32_t discardcount
Number of received bytes discarded (due to no buffer or other reasons).
Definition pl050.h:136
uint32_t irq
Definition pl050.h:130
PL050_KMI_REGISTERS * registers
Device registers.
Definition pl050.h:131
uint32_t interruptcount
Number of interrupt requests received by the device.
Definition pl050.h:137
MOUSE_DEVICE mouse
Definition pl050.h:128
uint32_t packetstart
The mouse packet buffer to use for the next receive.
Definition pl050.h:133
uint32_t packetcount
The number of mouse packet buffers that are in use.
Definition pl050.h:134