diff options
Diffstat (limited to 'payloads/libpayload/drivers')
-rw-r--r-- | payloads/libpayload/drivers/i8042/i8042.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/payloads/libpayload/drivers/i8042/i8042.c b/payloads/libpayload/drivers/i8042/i8042.c index 476139e2ea..a89b9d9717 100644 --- a/payloads/libpayload/drivers/i8042/i8042.c +++ b/payloads/libpayload/drivers/i8042/i8042.c @@ -112,6 +112,19 @@ static u8 fifo_pop(struct fifo *fifo) return ret; } +/** Peek on the head of fifo queue. + * Returns the oldest object on the queue if any. + * In case the queue is empty 0 is returned. + * @fifo: Fifo to use + */ +static u8 fifo_peek(struct fifo *fifo) +{ + if (fifo_is_empty(fifo)) + return 0; + + return fifo->buf[fifo->rx]; +} + /** Destroys a fifo queue. * @fifo: Fifo to use */ @@ -391,6 +404,14 @@ u8 i8042_read_data_ps2(void) } /** + * Returns available keyboard data without advancing the queue. + */ +u8 i8042_peek_data_ps2(void) +{ + return fifo_peek(ps2_fifo); +} + +/** * Returns available mouse data, if any. */ u8 i8042_read_data_aux(void) |