OvmfPkg/PlatformBootManagerLib: add USB keyboard to ConIn
authorLaszlo Ersek <lersek@redhat.com>
Sun, 15 Apr 2018 20:34:47 +0000 (22:34 +0200)
committerLaszlo Ersek <lersek@redhat.com>
Mon, 16 Apr 2018 19:45:25 +0000 (21:45 +0200)
PlatformInitializeConsole() (called by PlatformBootManagerBeforeConsole())
adds elements of "gPlatformConsole" to ConIn / ConOut / ErrOut (as
requested per element) if at boot at least one of ConIn and ConOut doesn't
exist. This typically applies to new VMs, and VMs with freshly recreated
varstores.

Add a USB keyboard wildcard to ConIn via "gPlatformConsole", so that we
not only bind the PS/2 keyboard. (The PS/2 keyboard is added in
PrepareLpcBridgeDevicePath()). Explicitly connecting the USB keyboard is
necessary after commit 245c643cc8b7.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c

index 82f294577ecf41f50458432d6e220381a8f710ad..a50cd7bcaf903f19fc6b53a74092e2301f745f6d 100644 (file)
@@ -27,6 +27,16 @@ typedef struct {
 } VENDOR_UART_DEVICE_PATH;\r
 #pragma pack()\r
 \r
+//\r
+// USB Keyboard Device Path structure\r
+//\r
+#pragma pack (1)\r
+typedef struct {\r
+  USB_CLASS_DEVICE_PATH    Keyboard;\r
+  EFI_DEVICE_PATH_PROTOCOL End;\r
+} USB_KEYBOARD_DEVICE_PATH;\r
+#pragma pack ()\r
+\r
 ACPI_HID_DEVICE_PATH       gPnpPs2KeyboardDeviceNode  = gPnpPs2Keyboard;\r
 ACPI_HID_DEVICE_PATH       gPnp16550ComPortDeviceNode = gPnp16550ComPort;\r
 UART_DEVICE_PATH           gUartDeviceNode            = gUart;\r
@@ -71,6 +81,24 @@ VENDOR_UART_DEVICE_PATH gDebugAgentUartDevicePath = {
   gEndEntire\r
 };\r
 \r
+STATIC USB_KEYBOARD_DEVICE_PATH gUsbKeyboardDevicePath = {\r
+  {\r
+    {\r
+      MESSAGING_DEVICE_PATH,\r
+      MSG_USB_CLASS_DP,\r
+      {\r
+        (UINT8)sizeof (USB_CLASS_DEVICE_PATH),\r
+        (UINT8)(sizeof (USB_CLASS_DEVICE_PATH) >> 8)\r
+      }\r
+    },\r
+    0xFFFF, // VendorId: any\r
+    0xFFFF, // ProductId: any\r
+    3,      // DeviceClass: HID\r
+    1,      // DeviceSubClass: boot\r
+    1       // DeviceProtocol: keyboard\r
+  },\r
+  gEndEntire\r
+};\r
 \r
 //\r
 // Predefined platform default console device path\r
@@ -80,6 +108,10 @@ PLATFORM_CONSOLE_CONNECT_ENTRY   gPlatformConsole[] = {
     (EFI_DEVICE_PATH_PROTOCOL *) &gDebugAgentUartDevicePath,\r
     (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)\r
   },\r
+  {\r
+    (EFI_DEVICE_PATH_PROTOCOL *)&gUsbKeyboardDevicePath,\r
+    CONSOLE_IN\r
+  },\r
   {\r
     NULL,\r
     0\r