EFI_KEY_OPTION definition verified with UEFI spec.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8046 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
gikidy 2009-04-09 07:56:28 +00:00
parent 298530bcaa
commit a9e7937ab0
2 changed files with 36 additions and 15 deletions

View File

@ -101,11 +101,11 @@ RegisterHotkey (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
KeyOptionSize = sizeof (EFI_KEY_OPTION) + GET_KEY_CODE_COUNT (KeyOption->KeyData.PackedValue) * sizeof (EFI_INPUT_KEY); KeyOptionSize = sizeof (EFI_KEY_OPTION) + KeyOption->KeyData.Options.InputKeyCount * sizeof (EFI_INPUT_KEY);
UpdateBootOption = FALSE; UpdateBootOption = FALSE;
// //
// check whether HotKey conflict with keys used by Setup Browser // Check whether HotKey conflict with keys used by Setup Browser
// //
KeyOrder = BdsLibGetVariableAndSize ( KeyOrder = BdsLibGetVariableAndSize (
VAR_KEY_ORDER, VAR_KEY_ORDER,
@ -143,7 +143,7 @@ RegisterHotkey (
} }
if (KeyOption->KeyData.PackedValue == TempOption->KeyData.PackedValue) { if (KeyOption->KeyData.PackedValue == TempOption->KeyData.PackedValue) {
if (GET_KEY_CODE_COUNT (KeyOption->KeyData.PackedValue) == 0 || if (KeyOption->KeyData.Options.InputKeyCount == 0 ||
CompareMem ( CompareMem (
((UINT8 *) TempOption) + sizeof (EFI_KEY_OPTION), ((UINT8 *) TempOption) + sizeof (EFI_KEY_OPTION),
((UINT8 *) KeyOption) + sizeof (EFI_KEY_OPTION), ((UINT8 *) KeyOption) + sizeof (EFI_KEY_OPTION),
@ -348,7 +348,7 @@ HotkeyCallback (
HotkeyData = &Hotkey->KeyData[Hotkey->WaitingKey]; HotkeyData = &Hotkey->KeyData[Hotkey->WaitingKey];
if ((KeyData->Key.ScanCode == HotkeyData->Key.ScanCode) && if ((KeyData->Key.ScanCode == HotkeyData->Key.ScanCode) &&
(KeyData->Key.UnicodeChar == HotkeyData->Key.UnicodeChar) && (KeyData->Key.UnicodeChar == HotkeyData->Key.UnicodeChar) &&
((HotkeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) ? (KeyData->KeyState.KeyShiftState == HotkeyData->KeyState.KeyShiftState) : 1)) { ((HotkeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) ? (KeyData->KeyState.KeyShiftState == HotkeyData->KeyState.KeyShiftState) : TRUE)) {
// //
// Receive an expecting key stroke // Receive an expecting key stroke
// //
@ -538,7 +538,7 @@ HotkeyInsertList (
BDS_HOTKEY_OPTION *HotkeyLeft; BDS_HOTKEY_OPTION *HotkeyLeft;
BDS_HOTKEY_OPTION *HotkeyRight; BDS_HOTKEY_OPTION *HotkeyRight;
UINTN Index; UINTN Index;
UINT32 KeyOptions; EFI_BOOT_KEY_DATA KeyOptions;
UINT32 KeyShiftStateLeft; UINT32 KeyShiftStateLeft;
UINT32 KeyShiftStateRight; UINT32 KeyShiftStateRight;
EFI_INPUT_KEY *InputKey; EFI_INPUT_KEY *InputKey;
@ -552,19 +552,33 @@ HotkeyInsertList (
HotkeyLeft->Signature = BDS_HOTKEY_OPTION_SIGNATURE; HotkeyLeft->Signature = BDS_HOTKEY_OPTION_SIGNATURE;
HotkeyLeft->BootOptionNumber = KeyOption->BootOption; HotkeyLeft->BootOptionNumber = KeyOption->BootOption;
KeyOptions = KeyOption->KeyData.PackedValue; KeyOptions = KeyOption->KeyData;
HotkeyLeft->CodeCount = (UINT8) GET_KEY_CODE_COUNT (KeyOptions); HotkeyLeft->CodeCount = (UINT8) KeyOptions.Options.InputKeyCount;
// //
// Map key shift state from KeyOptions to EFI_KEY_DATA.KeyState // Map key shift state from KeyOptions to EFI_KEY_DATA.KeyState
// //
KeyShiftStateRight = (KeyOptions & EFI_KEY_OPTION_SHIFT) | KeyShiftStateRight = EFI_SHIFT_STATE_VALID;
((KeyOptions & EFI_KEY_OPTION_CONTROL) << 1) | if (KeyOptions.Options.ShiftPressed) {
((KeyOptions & EFI_KEY_OPTION_ALT) << 2) | KeyShiftStateRight |= EFI_RIGHT_SHIFT_PRESSED;
((KeyOptions & EFI_KEY_OPTION_LOGO) << 3) | }
((KeyOptions & (EFI_KEY_OPTION_MENU | EFI_KEY_OPTION_SYSREQ)) << 4) | if (KeyOptions.Options.ControlPressed) {
EFI_SHIFT_STATE_VALID; KeyShiftStateRight |= EFI_RIGHT_CONTROL_PRESSED;
}
if (KeyOptions.Options.AltPressed) {
KeyShiftStateRight |= EFI_RIGHT_ALT_PRESSED;
}
if (KeyOptions.Options.LogoPressed) {
KeyShiftStateRight |= EFI_RIGHT_LOGO_PRESSED;
}
if (KeyOptions.Options.MenuPressed) {
KeyShiftStateRight |= EFI_MENU_KEY_PRESSED;
}
if (KeyOptions.Options.SysReqPressed) {
KeyShiftStateRight |= EFI_SYS_REQ_PRESSED;
}
KeyShiftStateLeft = (KeyShiftStateRight & 0xffffff00) | ((KeyShiftStateRight & 0xff) << 1); KeyShiftStateLeft = (KeyShiftStateRight & 0xffffff00) | ((KeyShiftStateRight & 0xff) << 1);
@ -636,12 +650,14 @@ InitializeHotkeyService (
// //
// Export our capability - EFI_BOOT_OPTION_SUPPORT_KEY and EFI_BOOT_OPTION_SUPPORT_APP // Export our capability - EFI_BOOT_OPTION_SUPPORT_KEY and EFI_BOOT_OPTION_SUPPORT_APP
// with maximum number of key presses of 3
// //
BootOptionSupport = EFI_BOOT_OPTION_SUPPORT_KEY | EFI_BOOT_OPTION_SUPPORT_APP; BootOptionSupport = EFI_BOOT_OPTION_SUPPORT_KEY | EFI_BOOT_OPTION_SUPPORT_APP;
SET_BOOT_OPTION_SUPPORT_KEY_COUNT (BootOptionSupport, 3);
Status = gRT->SetVariable ( Status = gRT->SetVariable (
L"BootOptionSupport", L"BootOptionSupport",
&gEfiGlobalVariableGuid, &gEfiGlobalVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof (UINT32), sizeof (UINT32),
&BootOptionSupport &BootOptionSupport
); );

View File

@ -19,9 +19,14 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "Bds.h" #include "Bds.h"
#include "String.h" #include "String.h"
#define GET_KEY_CODE_COUNT(KeyOptions) (((KeyOptions) & EFI_KEY_CODE_COUNT) >> 8) #define GET_BOOT_OPTION_SUPPORT_KEY_COUNT(a) (((a) & EFI_BOOT_OPTION_SUPPORT_COUNT) >> 8)
#define SET_BOOT_OPTION_SUPPORT_KEY_COUNT(a, c) { \
(a) = ((a) & ~EFI_BOOT_OPTION_SUPPORT_COUNT) | (((c) << 8) & EFI_BOOT_OPTION_SUPPORT_COUNT); \
}
#define BDS_HOTKEY_OPTION_SIGNATURE SIGNATURE_32 ('B', 'd', 'K', 'O') #define BDS_HOTKEY_OPTION_SIGNATURE SIGNATURE_32 ('B', 'd', 'K', 'O')
typedef struct { typedef struct {
UINTN Signature; UINTN Signature;
LIST_ENTRY Link; LIST_ENTRY Link;