// 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
\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
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