]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.c
Enhance Ps2Mouse and Ps2Keyboard driver and fix for random hangs in System waiting...
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / Ps2MouseDxe / Ps2Mouse.c
index 32b527c72c4820d9c0561f98d50a95f0d91205f4..084c3244aebae38329055742c717f6d7f5ad4e60 100644 (file)
@@ -228,6 +228,18 @@ PS2MouseDriverStart (
   // Initialize keyboard controller if necessary\r
   //\r
   IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);\r
+  //\r
+  // Fix for random hangs in System waiting for the Key if no KBC is present in BIOS.\r
+  //\r
+  if ((Data & (KBC_PARE | KBC_TIM)) == (KBC_PARE | KBC_TIM)) {\r
+    //\r
+    // If nobody decodes KBC I/O port, it will read back as 0xFF.\r
+    // Check the Time-Out and Parity bit to see if it has an active KBC in system\r
+    //\r
+    Status     = EFI_DEVICE_ERROR;\r
+    StatusCode = EFI_PERIPHERAL_MOUSE | EFI_P_EC_NOT_DETECTED;\r
+    goto ErrorExit;\r
+  } \r
   if ((Data & KBC_SYSF) != KBC_SYSF) {\r
     Status = KbcSelfTest (IsaIo);\r
     if (EFI_ERROR (Status)) {\r
@@ -329,7 +341,9 @@ PS2MouseDriverStart (
 \r
 ErrorExit:\r
 \r
-  KbcDisableAux (IsaIo);\r
+  if (Status != EFI_DEVICE_ERROR) {\r
+    KbcDisableAux (IsaIo);\r
+  }\r
 \r
   if (StatusCode != 0) {\r
     REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
@@ -350,13 +364,16 @@ ErrorExit:
   if ((MouseDev != NULL) && (MouseDev->ControllerNameTable != NULL)) {\r
     FreeUnicodeStringTable (MouseDev->ControllerNameTable);\r
   }\r
-  //\r
-  // Since there will be no timer handler for mouse input any more,\r
-  // exhaust input data just in case there is still mouse data left\r
-  //\r
-  EmptyStatus = EFI_SUCCESS;\r
-  while (!EFI_ERROR (EmptyStatus)) {\r
-    EmptyStatus = In8042Data (IsaIo, &Data);\r
+  \r
+  if (Status != EFI_DEVICE_ERROR) {\r
+    //\r
+    // Since there will be no timer handler for mouse input any more,\r
+    // exhaust input data just in case there is still mouse data left\r
+    //\r
+    EmptyStatus = EFI_SUCCESS;\r
+    while (!EFI_ERROR (EmptyStatus)) {\r
+      EmptyStatus = In8042Data (IsaIo, &Data);\r
+    }\r
   }\r
 \r
   if (MouseDev != NULL) {\r