MdeModulePkg UsbKbDxe: Execute key notify func at TPL_CALLBACK

Current implementation executes key notify function in TimerHandler
at TPL_NOTIFY. The code change is to make key notify function
executed at TPL_CALLBACK to reduce the time occupied at TPL_NOTIFY.

The code will signal KeyNotify process event if the key pressed
matches any key registered and insert the KeyData to the EFI Key
queue for notify, then the KeyNotify process handler will invoke
key notify functions at TPL_CALLBACK.

Cc: Ruiyu Ni <Ruiyu.ni@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <Ruiyu.ni@intel.com>
This commit is contained in:
Star Zeng
2016-12-16 17:16:22 +08:00
parent cf88579c10
commit 4ae46dbacd
3 changed files with 92 additions and 5 deletions

View File

@@ -820,6 +820,7 @@ InitUSBKeyboard (
InitQueue (&UsbKeyboardDevice->UsbKeyQueue, sizeof (USB_KEY));
InitQueue (&UsbKeyboardDevice->EfiKeyQueue, sizeof (EFI_KEY_DATA));
InitQueue (&UsbKeyboardDevice->EfiKeyQueueForNotify, sizeof (EFI_KEY_DATA));
//
// Use the config out of the descriptor
@@ -1665,20 +1666,25 @@ UsbKeyCodeToEfiInputKey (
KeyData->KeyState.KeyToggleState |= EFI_KEY_STATE_EXPOSED;
}
//
// Invoke notification functions if the key is registered.
// Signal KeyNotify process event if this key pressed matches any key registered.
//
NotifyList = &UsbKeyboardDevice->NotifyList;
for (Link = GetFirstNode (NotifyList); !IsNull (NotifyList, Link); Link = GetNextNode (NotifyList, Link)) {
CurrentNotify = CR (Link, KEYBOARD_CONSOLE_IN_EX_NOTIFY, NotifyEntry, USB_KB_CONSOLE_IN_EX_NOTIFY_SIGNATURE);
if (IsKeyRegistered (&CurrentNotify->KeyData, KeyData)) {
CurrentNotify->KeyNotificationFn (KeyData);
//
// The key notification function needs to run at TPL_CALLBACK
// while current TPL is TPL_NOTIFY. It will be invoked in
// KeyNotifyProcessHandler() which runs at TPL_CALLBACK.
//
Enqueue (&UsbKeyboardDevice->EfiKeyQueueForNotify, KeyData, sizeof (*KeyData));
gBS->SignalEvent (UsbKeyboardDevice->KeyNotifyProcessEvent);
}
}
return EFI_SUCCESS;
}
/**
Create the queue.