The hotkey callback in BDS module should defer loading the boot option until the TPL drops to TPL_APPLICATION after the keyboard driver is enhanced to call hotkey callback in timer handler whose TPL is higher than TPL_APPLICATION.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11573 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
niruiyu 2011-04-20 08:51:18 +00:00
parent a176509a7f
commit d394581d11
3 changed files with 79 additions and 63 deletions

View File

@ -1,7 +1,7 @@
/** @file
FrontPage routines to handle the callbacks and browser calls
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2004 - 2011, 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
@ -15,6 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "Bds.h"
#include "FrontPage.h"
#include "Language.h"
#include "Hotkey.h"
EFI_GUID mFrontPageGuid = FRONT_PAGE_FORMSET_GUID;
@ -971,8 +972,10 @@ PlatformBdsEnterFrontPage (
gConnectAllHappened = TRUE;
}
HotkeyBoot ();
if (TimeoutDefault != 0xffff) {
Status = ShowProgress (TimeoutDefault);
HotkeyBoot ();
//
// Ensure screen is clear when switch Console from Graphics mode to Text mode

View File

@ -2,7 +2,7 @@
Provides a way for 3rd party applications to register themselves for launch by the
Boot Manager based on hot key
Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2007 - 2011, 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
@ -17,7 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
LIST_ENTRY mHotkeyList = INITIALIZE_LIST_HEAD_VARIABLE (mHotkeyList);
BOOLEAN mHotkeyCallbackPending = FALSE;
BDS_COMMON_OPTION *mHotkeyBootOption = NULL;
EFI_EVENT mHotkeyEvent;
VOID *mHotkeyRegistration;
@ -300,6 +300,50 @@ UnregisterHotkey (
return Status;
}
/**
Try to boot the boot option triggered by hotkey.
**/
VOID
HotkeyBoot (
VOID
)
{
EFI_STATUS Status;
UINTN ExitDataSize;
CHAR16 *ExitData;
if (mHotkeyBootOption != NULL) {
BdsLibConnectDevicePath (mHotkeyBootOption->DevicePath);
//
// Clear the screen before launch this BootOption
//
gST->ConOut->Reset (gST->ConOut, FALSE);
Status = BdsLibBootViaBootOption (mHotkeyBootOption, mHotkeyBootOption->DevicePath, &ExitDataSize, &ExitData);
if (EFI_ERROR (Status)) {
//
// Call platform action to indicate the boot fail
//
mHotkeyBootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_FAILED));
PlatformBdsBootFail (mHotkeyBootOption, Status, ExitData, ExitDataSize);
} else {
//
// Call platform action to indicate the boot success
//
mHotkeyBootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_SUCCEEDED));
PlatformBdsBootSuccess (mHotkeyBootOption);
}
FreePool (mHotkeyBootOption->Description);
FreePool (mHotkeyBootOption->DevicePath);
FreePool (mHotkeyBootOption->LoadOptions);
FreePool (mHotkeyBootOption);
mHotkeyBootOption = NULL;
}
}
/**
This is the common notification function for HotKeys, it will be registered
@ -322,24 +366,22 @@ HotkeyCallback (
LIST_ENTRY *Link;
BDS_HOTKEY_OPTION *Hotkey;
UINT16 Buffer[10];
BDS_COMMON_OPTION *BootOption;
UINTN ExitDataSize;
CHAR16 *ExitData;
EFI_STATUS Status;
EFI_KEY_DATA *HotkeyData;
if (mHotkeyCallbackPending) {
if (mHotkeyBootOption != NULL) {
//
// When responsing to a Hotkey, ignore sequential hotkey stroke until
// the current Boot#### load option returned
// Do not process sequential hotkey stroke until the current boot option returns
//
return EFI_SUCCESS;
}
Status = EFI_SUCCESS;
Link = GetFirstNode (&mHotkeyList);
while (!IsNull (&mHotkeyList, Link)) {
for ( Link = GetFirstNode (&mHotkeyList)
; !IsNull (&mHotkeyList, Link)
; Link = GetNextNode (&mHotkeyList, Link)
) {
HotkeyCatched = FALSE;
Hotkey = BDS_HOTKEY_OPTION_FROM_LINK (Link);
@ -350,11 +392,10 @@ HotkeyCallback (
HotkeyData = &Hotkey->KeyData[Hotkey->WaitingKey];
if ((KeyData->Key.ScanCode == HotkeyData->Key.ScanCode) &&
(KeyData->Key.UnicodeChar == HotkeyData->Key.UnicodeChar) &&
(((HotkeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) ? (KeyData->KeyState.KeyShiftState == HotkeyData->KeyState.KeyShiftState) : TRUE)) {
//
// Receive an expecting key stroke
//
if (Hotkey->CodeCount > 1) {
(((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) ?
(KeyData->KeyState.KeyShiftState == HotkeyData->KeyState.KeyShiftState) : TRUE
)
) {
//
// For hotkey of key combination, transit to next waiting state
//
@ -366,12 +407,6 @@ HotkeyCallback (
//
HotkeyCatched = TRUE;
}
} else {
//
// For hotkey of single key stroke
//
HotkeyCatched = TRUE;
}
} else {
//
// Receive an unexpected key stroke, reset to initial waiting state
@ -391,38 +426,8 @@ HotkeyCallback (
InitializeListHead (&BootLists);
UnicodeSPrint (Buffer, sizeof (Buffer), L"Boot%04x", Hotkey->BootOptionNumber);
BootOption = BdsLibVariableToOption (&BootLists, Buffer);
if (BootOption == NULL) {
return EFI_NOT_FOUND;
mHotkeyBootOption = BdsLibVariableToOption (&BootLists, Buffer);
}
BootOption->BootCurrent = Hotkey->BootOptionNumber;
BdsLibConnectDevicePath (BootOption->DevicePath);
//
// Clear the screen before launch this BootOption
//
gST->ConOut->Reset (gST->ConOut, FALSE);
mHotkeyCallbackPending = TRUE;
Status = BdsLibBootViaBootOption (BootOption, BootOption->DevicePath, &ExitDataSize, &ExitData);
mHotkeyCallbackPending = FALSE;
if (EFI_ERROR (Status)) {
//
// Call platform action to indicate the boot fail
//
BootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_FAILED));
PlatformBdsBootFail (BootOption, Status, ExitData, ExitDataSize);
} else {
//
// Call platform action to indicate the boot success
//
BootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_SUCCEEDED));
PlatformBdsBootSuccess (BootOption);
}
}
Link = GetNextNode (&mHotkeyList, Link);
}
return Status;

View File

@ -2,7 +2,7 @@
Provides a way for 3rd party applications to register themselves for launch by the
Boot Manager based on hot key
Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2007 - 2011, 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
@ -92,4 +92,12 @@ InitializeHotkeyService (
VOID
);
/**
Try to boot the boot option triggered by hotkey.
**/
VOID
HotkeyBoot (
VOID
);
#endif