git: 1fc478fb48e9 - main - bhyve: ps2 implement command 0xf6

From: Warner Losh <imp_at_FreeBSD.org>
Date: Tue, 31 Oct 2023 20:52:42 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=1fc478fb48e9a3ca31f9715164dac47038497a7e

commit 1fc478fb48e9a3ca31f9715164dac47038497a7e
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2023-10-31 20:03:32 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-10-31 20:52:22 +0000

    bhyve: ps2 implement command 0xf6
    
    Implement PS2 Keyboard command 0xf6, which is "SET DEFAULTS". This is
    the same as 0xf5 (DISABLE KEYBOARD), but without disabling the keyboard
    (since that resets all the defaults as a side effect). Normally, we
    clear the fifo when we re-enable the keyboard. However, since this
    leaves the keyboard enabled, clear the fifo as part of this command and
    send an ack.
    
    Linux's keyboard driver sends this command on reboot. Other commands
    enable / reset the kebyoard, so it doesn't matter too much this isn't
    implemented for booting, eg ubuntu.
    
    Sponsored by:           Netflix
    Reviewed by:            corvink, markj
    Differential Revision:  https://reviews.freebsd.org/D42384
---
 usr.sbin/bhyve/amd64/ps2kbd.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/usr.sbin/bhyve/amd64/ps2kbd.c b/usr.sbin/bhyve/amd64/ps2kbd.c
index 6fe36dbc4a55..c9e122b8bbd3 100644
--- a/usr.sbin/bhyve/amd64/ps2kbd.c
+++ b/usr.sbin/bhyve/amd64/ps2kbd.c
@@ -53,6 +53,7 @@
 
 /* keyboard device commands */
 #define	PS2KC_RESET_DEV		0xff
+#define	PS2KC_SET_DEFAULTS	0xf6
 #define	PS2KC_DISABLE		0xf5
 #define	PS2KC_ENABLE		0xf4
 #define	PS2KC_SET_TYPEMATIC	0xf3
@@ -300,6 +301,10 @@ ps2kbd_write(struct ps2kbd_softc *sc, uint8_t val)
 			fifo_put(sc, PS2KC_ACK);
 			fifo_put(sc, PS2KC_BAT_SUCCESS);
 			break;
+		case PS2KC_SET_DEFAULTS:
+			fifo_reset(sc);
+			fifo_put(sc, PS2KC_ACK);
+			break;
 		case PS2KC_DISABLE:
 			sc->enabled = false;
 			fifo_put(sc, PS2KC_ACK);