mirror of https://github.com/acidanthera/audk.git
MdeModulePkg/Bds: BDS hotkey shouldn't work on inactive consoles
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com> Reviewed-by: Sunny Wang <sunnywang@intel.com>
This commit is contained in:
parent
b5d89de167
commit
2d15a83017
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
Hotkey library functions.
|
||||
|
||||
Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -440,6 +440,54 @@ BmHotkeyCallback (
|
|||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Return the active Simple Text Input Ex handle array.
|
||||
If the SystemTable.ConsoleInHandle is NULL, the function returns all
|
||||
founded Simple Text Input Ex handles.
|
||||
Otherwise, it just returns the ConsoleInHandle.
|
||||
|
||||
@param Count Return the handle count.
|
||||
|
||||
@retval The active console handles.
|
||||
**/
|
||||
EFI_HANDLE *
|
||||
BmGetActiveConsoleIn (
|
||||
OUT UINTN *Count
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE *Handles;
|
||||
|
||||
if (gST->ConsoleInHandle != NULL) {
|
||||
Status = gBS->OpenProtocol (
|
||||
gST->ConsoleInHandle,
|
||||
&gEfiSimpleTextInputExProtocolGuid,
|
||||
NULL,
|
||||
gImageHandle,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Handles = AllocateCopyPool (sizeof (EFI_HANDLE *), &gST->ConsoleInHandle);
|
||||
*Count = 1;
|
||||
}
|
||||
} else {
|
||||
Status = gBS->LocateHandleBuffer (
|
||||
ByProtocol,
|
||||
&gEfiSimpleTextInputExProtocolGuid,
|
||||
NULL,
|
||||
Count,
|
||||
&Handles
|
||||
);
|
||||
}
|
||||
if (EFI_ERROR (Status)) {
|
||||
Handles = NULL;
|
||||
*Count = 0;
|
||||
}
|
||||
|
||||
return Handles;
|
||||
}
|
||||
|
||||
/**
|
||||
Unregister hotkey notify list.
|
||||
|
||||
|
@ -461,13 +509,7 @@ BmUnregisterHotkeyNotify (
|
|||
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TxtInEx;
|
||||
VOID *NotifyHandle;
|
||||
|
||||
gBS->LocateHandleBuffer (
|
||||
ByProtocol,
|
||||
&gEfiSimpleTextInputExProtocolGuid,
|
||||
NULL,
|
||||
&HandleCount,
|
||||
&Handles
|
||||
);
|
||||
Handles = BmGetActiveConsoleIn (&HandleCount);
|
||||
for (Index = 0; Index < HandleCount; Index++) {
|
||||
Status = gBS->HandleProtocol (Handles[Index], &gEfiSimpleTextInputExProtocolGuid, (VOID **) &TxtInEx);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
@ -485,6 +527,10 @@ BmUnregisterHotkeyNotify (
|
|||
}
|
||||
}
|
||||
|
||||
if (Handles != NULL) {
|
||||
FreePool (Handles);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -636,6 +682,8 @@ BmProcessKeyOption (
|
|||
|
||||
EfiAcquireLock (&mBmHotkeyLock);
|
||||
|
||||
Handles = BmGetActiveConsoleIn (&HandleCount);
|
||||
|
||||
for (Index = 0; Index < KeyShiftStateCount; Index++) {
|
||||
Hotkey = AllocateZeroPool (sizeof (BM_HOTKEY));
|
||||
ASSERT (Hotkey != NULL);
|
||||
|
@ -651,13 +699,6 @@ BmProcessKeyOption (
|
|||
}
|
||||
InsertTailList (&mBmHotkeyList, &Hotkey->Link);
|
||||
|
||||
gBS->LocateHandleBuffer (
|
||||
ByProtocol,
|
||||
&gEfiSimpleTextInputExProtocolGuid,
|
||||
NULL,
|
||||
&HandleCount,
|
||||
&Handles
|
||||
);
|
||||
for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
|
||||
Status = gBS->HandleProtocol (Handles[HandleIndex], &gEfiSimpleTextInputExProtocolGuid, (VOID **) &TxtInEx);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
@ -665,6 +706,9 @@ BmProcessKeyOption (
|
|||
}
|
||||
}
|
||||
|
||||
if (Handles != NULL) {
|
||||
FreePool (Handles);
|
||||
}
|
||||
EfiReleaseLock (&mBmHotkeyLock);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
@ -875,13 +919,20 @@ EfiBootManagerStartHotkeyService (
|
|||
BmProcessKeyOption (mBmContinueKeyOption);
|
||||
}
|
||||
|
||||
EfiCreateProtocolNotifyEvent (
|
||||
&gEfiSimpleTextInputExProtocolGuid,
|
||||
TPL_CALLBACK,
|
||||
BmTxtInExCallback,
|
||||
NULL,
|
||||
&mBmTxtInExRegistration
|
||||
);
|
||||
//
|
||||
// Hook hotkey on every future SimpleTextInputEx instance when
|
||||
// SystemTable.ConsoleInHandle == NULL, which means the console
|
||||
// manager (ConSplitter) is absent.
|
||||
//
|
||||
if (gST->ConsoleInHandle == NULL) {
|
||||
EfiCreateProtocolNotifyEvent (
|
||||
&gEfiSimpleTextInputExProtocolGuid,
|
||||
TPL_CALLBACK,
|
||||
BmTxtInExCallback,
|
||||
NULL,
|
||||
&mBmTxtInExRegistration
|
||||
);
|
||||
}
|
||||
|
||||
Status = EfiCreateEventReadyToBootEx (
|
||||
TPL_CALLBACK,
|
||||
|
@ -891,7 +942,6 @@ EfiBootManagerStartHotkeyService (
|
|||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
|
||||
mBmHotkeyServiceStarted = TRUE;
|
||||
return Status;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue