summaryrefslogtreecommitdiff
path: root/IntelFrameworkModulePkg/Bus
diff options
context:
space:
mode:
authorli-elvin <li-elvin@6f19259b-4bc3-4df7-8a09-765794883524>2012-10-11 07:01:22 +0000
committerli-elvin <li-elvin@6f19259b-4bc3-4df7-8a09-765794883524>2012-10-11 07:01:22 +0000
commit4ccfd30544d1da8f3b5a02293f1feca702dde90a (patch)
tree7aaaec115373661fd287ed317287428b1348c737 /IntelFrameworkModulePkg/Bus
parente8c758dc9252adaefa0d13c5702e32e0402d18e8 (diff)
downloadedk2-platforms-4ccfd30544d1da8f3b5a02293f1feca702dde90a.tar.xz
Add PcdFastPS2Detection to improve PS2 keyboard driver start performance.
Signed-off-by: Li Elvin <elvin.li@intel.com> Reviewed-by: Yao Jiewen<jiewen.yao@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13820 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'IntelFrameworkModulePkg/Bus')
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c192
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c20
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf3
3 files changed, 115 insertions, 100 deletions
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c
index 4ad80c17c1..05b62f6a8c 100644
--- a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c
+++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c
@@ -1519,16 +1519,18 @@ InitKeyboard (
// Perform a read to cleanup the Status Register's
// output buffer full bits within MAX TRY times
//
- while (!EFI_ERROR (Status) && TryTime < KEYBOARD_MAX_TRY) {
- Status = KeyboardRead (ConsoleIn, &CommandByte);
- TryTime ++;
- }
- //
- // Exceed the max try times. The device may be error.
- //
- if (TryTime == KEYBOARD_MAX_TRY) {
- Status = EFI_DEVICE_ERROR;
- goto Done;
+ if ((KeyReadStatusRegister (ConsoleIn) & KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA)) {
+ while (!EFI_ERROR (Status) && TryTime < KEYBOARD_MAX_TRY) {
+ Status = KeyboardRead (ConsoleIn, &CommandByte);
+ TryTime ++;
+ }
+ //
+ // Exceed the max try times. The device may be error.
+ //
+ if (TryTime == KEYBOARD_MAX_TRY) {
+ Status = EFI_DEVICE_ERROR;
+ goto Done;
+ }
}
//
// We should disable mouse interface during the initialization process
@@ -1543,34 +1545,37 @@ InitKeyboard (
// time initialization
//
if ((KeyReadStatusRegister (ConsoleIn) & KEYBOARD_STATUS_REGISTER_SYSTEM_FLAG) != 0) {
- //
- // 8042 controller is already setup (by myself or by mouse driver):
- // See whether mouse interface is already enabled
- // which determines whether we should enable it later
- //
- //
- // Read the command byte of 8042 controller
- //
- Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_READ);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"\n\r");
- goto Done;
- }
-
- Status = KeyboardRead (ConsoleIn, &CommandByte);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"\n\r");
- goto Done;
- }
- //
- // Test the mouse enabling bit
- //
- if ((CommandByte & 0x20) != 0) {
- mEnableMouseInterface = FALSE;
+ if (!PcdGetBool (PcdFastPS2Detection)) {
+ //
+ // 8042 controller is already setup (by myself or by mouse driver):
+ // See whether mouse interface is already enabled
+ // which determines whether we should enable it later
+ //
+ //
+ // Read the command byte of 8042 controller
+ //
+ Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_READ);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"\n\r");
+ goto Done;
+ }
+
+ Status = KeyboardRead (ConsoleIn, &CommandByte);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"\n\r");
+ goto Done;
+ }
+ //
+ // Test the mouse enabling bit
+ //
+ if ((CommandByte & 0x20) != 0) {
+ mEnableMouseInterface = FALSE;
+ } else {
+ mEnableMouseInterface = TRUE;
+ }
} else {
- mEnableMouseInterface = TRUE;
- }
-
+ mEnableMouseInterface = FALSE;
+ }
} else {
//
// 8042 controller is not setup yet:
@@ -1580,36 +1585,38 @@ InitKeyboard (
//
// Disable keyboard and mouse interfaces
//
- Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_DISABLE_KEYBOARD_INTERFACE);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"\n\r");
- goto Done;
- }
-
- Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_DISABLE_MOUSE_INTERFACE);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"\n\r");
- goto Done;
- }
-
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_PC_SELF_TEST,
- ConsoleIn->DevicePath
- );
- //
- // 8042 Controller Self Test
- //
- Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_CONTROLLER_SELF_TEST);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"8042 controller command write error!\n\r");
- goto Done;
- }
-
- Status = KeyboardWaitForValue (ConsoleIn, 0x55);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"8042 controller self test failed!\n\r");
- goto Done;
+ if (!PcdGetBool (PcdFastPS2Detection)) {
+ Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_DISABLE_KEYBOARD_INTERFACE);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"\n\r");
+ goto Done;
+ }
+
+ Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_DISABLE_MOUSE_INTERFACE);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"\n\r");
+ goto Done;
+ }
+
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (
+ EFI_PROGRESS_CODE,
+ EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_PC_SELF_TEST,
+ ConsoleIn->DevicePath
+ );
+ //
+ // 8042 Controller Self Test
+ //
+ Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_CONTROLLER_SELF_TEST);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"8042 controller command write error!\n\r");
+ goto Done;
+ }
+
+ Status = KeyboardWaitForValue (ConsoleIn, 0x55);
+ if (EFI_ERROR (Status)) {
+ KeyboardError (ConsoleIn, L"8042 controller self test failed!\n\r");
+ goto Done;
+ }
}
//
// Don't enable mouse interface later
@@ -1865,34 +1872,37 @@ CheckKeyboardConnect (
EFI_STATUS Status;
UINTN WaitForValueTimeOutBcakup;
- Status = EFI_SUCCESS;
//
// enable keyboard itself and wait for its ack
// If can't receive ack, Keyboard should not be connected.
//
- Status = KeyboardWrite (
- ConsoleIn,
- KEYBOARD_KBEN
- );
-
- if (EFI_ERROR (Status)) {
- return FALSE;
- }
- //
- // wait for 1s
- //
- WaitForValueTimeOutBcakup = mWaitForValueTimeOut;
- mWaitForValueTimeOut = KEYBOARD_WAITFORVALUE_TIMEOUT;
- Status = KeyboardWaitForValue (
- ConsoleIn,
- KEYBOARD_CMDECHO_ACK
- );
- mWaitForValueTimeOut = WaitForValueTimeOutBcakup;
-
- if (EFI_ERROR (Status)) {
- return FALSE;
+ if (!PcdGetBool (PcdFastPS2Detection)) {
+ Status = KeyboardWrite (
+ ConsoleIn,
+ KEYBOARD_KBEN
+ );
+
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+ //
+ // wait for 1s
+ //
+ WaitForValueTimeOutBcakup = mWaitForValueTimeOut;
+ mWaitForValueTimeOut = KEYBOARD_WAITFORVALUE_TIMEOUT;
+ Status = KeyboardWaitForValue (
+ ConsoleIn,
+ KEYBOARD_CMDECHO_ACK
+ );
+ mWaitForValueTimeOut = WaitForValueTimeOutBcakup;
+
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+
+ return TRUE;
+ } else {
+ return TRUE;
}
-
- return TRUE;
}
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c
index c73cf93613..4f87990876 100644
--- a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c
+++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c
@@ -263,15 +263,17 @@ KbdControllerDriverStart (
//
// Return code is ignored on purpose.
//
- KeyboardRead (ConsoleIn, &Data);
- if ((KeyReadStatusRegister (ConsoleIn) & (KBC_PARE | KBC_TIM)) == (KBC_PARE | KBC_TIM)) {
- //
- // If nobody decodes KBC I/O port, it will read back as 0xFF.
- // Check the Time-Out and Parity bit to see if it has an active KBC in system
- //
- Status = EFI_DEVICE_ERROR;
- StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_NOT_DETECTED;
- goto ErrorExit;
+ if (!PcdGetBool (PcdFastPS2Detection)) {
+ KeyboardRead (ConsoleIn, &Data);
+ if ((KeyReadStatusRegister (ConsoleIn) & (KBC_PARE | KBC_TIM)) == (KBC_PARE | KBC_TIM)) {
+ //
+ // If nobody decodes KBC I/O port, it will read back as 0xFF.
+ // Check the Time-Out and Parity bit to see if it has an active KBC in system
+ //
+ Status = EFI_DEVICE_ERROR;
+ StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_NOT_DETECTED;
+ goto ErrorExit;
+ }
}
//
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf
index 61fd036c3c..f2cc8b0061 100644
--- a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf
+++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf
@@ -68,6 +68,9 @@
[FeaturePcd]
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPs2KbdExtendedVerification
+[Pcd]
+ gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdFastPS2Detection
+
# [Event]
# ##
# # Event will be signaled for WaitForKey event.