diff options
Diffstat (limited to 'MdeModulePkg')
18 files changed, 1416 insertions, 684 deletions
diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf b/MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf index a075c0e1ab..0a50c277c5 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf @@ -62,11 +62,15 @@ gSimpleTextInExNotifyGuid # ALWAYS_CONSUMED
[Protocols]
- gEfiUsbIoProtocolGuid # PROTOCOL ALWAYS_CONSUMED
- gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED
- gEfiSimpleTextInProtocolGuid # PROTOCOL ALWAYS_CONSUMED
- gEfiSimpleTextInputExProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiUsbIoProtocolGuid # PROTOCOL TO_START
+ gEfiDevicePathProtocolGuid # PROTOCOL TO_START
+ gEfiSimpleTextInProtocolGuid # PROTOCOL BY_START
+ gEfiSimpleTextInputExProtocolGuid # PROTOCOL BY_START
+ gEfiHiiDatabaseProtocolGuid # PROTOCOL TO_START
+[FeaturePcd.common]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdDisableDefaultKeyboardLayoutInUsbKbDriver
+
[FixedPcd]
gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValueKeyboardEnable
gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValueKeyboardPresenceDetect
diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/efikey.c b/MdeModulePkg/Bus/Usb/UsbKbDxe/efikey.c index 6ce448642e..50413bd500 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/efikey.c +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/efikey.c @@ -1,6 +1,6 @@ /** @file
-Copyright (c) 2004 - 2007, Intel Corporation
+Copyright (c) 2004 - 2008, Intel Corporation
All rights reserved. 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
@@ -382,6 +382,11 @@ USBKeyboardDriverBindingStart ( goto ErrorExit;
}
+ Status = InitKeyboardLayout (UsbKeyboardDevice);
+ if (EFI_ERROR (Status)) {
+ goto ErrorExit;
+ }
+
Status = gBS->CreateEvent (
EVT_NOTIFY_WAIT,
TPL_NOTIFY,
@@ -650,6 +655,9 @@ USBKeyboardDriverBindingStop ( gBS->CloseEvent (UsbKeyboardDevice->SimpleInputEx.WaitForKeyEx);
KbdFreeNotifyList (&UsbKeyboardDevice->NotifyList);
+ ReleaseKeyboardLayoutResources (UsbKeyboardDevice);
+ gBS->CloseEvent (UsbKeyboardDevice->KeyboardLayoutEvent);
+
if (UsbKeyboardDevice->ControllerNameTable != NULL) {
FreeUnicodeStringTable (UsbKeyboardDevice->ControllerNameTable);
}
diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/efikey.h b/MdeModulePkg/Bus/Usb/UsbKbDxe/efikey.h index bab22a3b88..19443949e9 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/efikey.h +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/efikey.h @@ -1,5 +1,5 @@ /** @file
-Copyright (c) 2004 - 2007, Intel Corporation
+Copyright (c) 2004 - 2008, Intel Corporation
All rights reserved. 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
@@ -27,9 +27,11 @@ Revision History #include <Protocol/SimpleTextIn.h>
#include <Protocol/SimpleTextInEx.h>
-#include <Guid/HotPlugDevice.h>
+#include <Protocol/HiiDatabase.h>
#include <Protocol/UsbIo.h>
#include <Protocol/DevicePath.h>
+#include <Guid/HiiKeyBoardLayout.h>
+#include <Guid/HotPlugDevice.h>
#include <Library/DebugLib.h>
#include <Library/ReportStatusCodeLib.h>
@@ -79,6 +81,27 @@ typedef struct _KEYBOARD_CONSOLE_IN_EX_NOTIFY { EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;
LIST_ENTRY NotifyEntry;
} KEYBOARD_CONSOLE_IN_EX_NOTIFY;
+
+#define USB_NS_KEY_SIGNATURE EFI_SIGNATURE_32 ('u', 'n', 's', 'k')
+
+typedef struct {
+ UINTN Signature;
+ LIST_ENTRY Link;
+
+ //
+ // The number of EFI_NS_KEY_MODIFIER children definitions
+ //
+ UINTN KeyCount;
+
+ //
+ // NsKey[0] : Non-spacing key
+ // NsKey[1] ~ NsKey[KeyCount] : Physical keys
+ //
+ EFI_KEY_DESCRIPTOR *NsKey;
+} USB_NS_KEY;
+
+#define USB_NS_KEY_FORM_FROM_LINK(a) CR (a, USB_NS_KEY, Link, USB_NS_KEY_SIGNATURE)
+
typedef struct {
UINTN Signature;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
@@ -115,12 +138,21 @@ typedef struct { UINT8 RightLogoOn;
UINT8 MenuKeyOn;
UINT8 SysReqOn;
+ UINT8 AltGrOn;
EFI_KEY_STATE KeyState;
//
// Notification function list
//
LIST_ENTRY NotifyList;
+
+ //
+ // Non-spacing key list
+ //
+ LIST_ENTRY NsKeyList;
+ USB_NS_KEY *CurrentNsKey;
+ EFI_KEY_DESCRIPTOR *KeyConvertionTable;
+ EFI_EVENT KeyboardLayoutEvent;
} USB_KB_DEV;
//
@@ -159,7 +191,7 @@ typedef struct { UINT8 Key;
} KB_MODIFIER;
-#define USB_KEYCODE_MAX_MAKE 0x7E
+#define USB_KEYCODE_MAX_MAKE 0x62
#define USBKBD_VALID_KEYCODE(key) ((UINT8) (key) > 3)
diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/keyboard.c b/MdeModulePkg/Bus/Usb/UsbKbDxe/keyboard.c index 87179a4c6b..72fafd9472 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/keyboard.c +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/keyboard.c @@ -1,6 +1,6 @@ /** @file
-Copyright (c) 2004 - 2005, Intel Corporation
+Copyright (c) 2004 - 2008, Intel Corporation
All rights reserved. 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
@@ -24,129 +24,316 @@ Revision History #include "keyboard.h"
#include <Library/UsbLib.h>
+
+//
+// Static English keyboard layout
+// Format:<efi key>, <unicode without shift>, <unicode with shift>, <Modifier>, <AffectedAttribute>
+//
+STATIC
+UINT8 KeyboardLayoutTable[USB_KEYCODE_MAX_MAKE + 8][5] = {
+ {EfiKeyC1, 'a', 'A', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x04
+ {EfiKeyB5, 'b', 'B', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x05
+ {EfiKeyB3, 'c', 'C', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x06
+ {EfiKeyC3, 'd', 'D', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x07
+ {EfiKeyD3, 'e', 'E', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x08
+ {EfiKeyC4, 'f', 'F', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x09
+ {EfiKeyC5, 'g', 'G', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x0A
+ {EfiKeyC6, 'h', 'H', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x0B
+ {EfiKeyD8, 'i', 'I', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x0C
+ {EfiKeyC7, 'j', 'J', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x0D
+ {EfiKeyC8, 'k', 'K', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x0E
+ {EfiKeyC9, 'l', 'L', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x0F
+ {EfiKeyB7, 'm', 'M', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x10
+ {EfiKeyB6, 'n', 'N', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x11
+ {EfiKeyD9, 'o', 'O', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x12
+ {EfiKeyD10, 'p', 'P', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x13
+ {EfiKeyD1, 'q', 'Q', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x14
+ {EfiKeyD4, 'r', 'R', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x15
+ {EfiKeyC2, 's', 'S', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x16
+ {EfiKeyD5, 't', 'T', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x17
+ {EfiKeyD7, 'u', 'U', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x18
+ {EfiKeyB4, 'v', 'V', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x19
+ {EfiKeyD2, 'w', 'W', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x1A
+ {EfiKeyB2, 'x', 'X', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x1B
+ {EfiKeyD6, 'y', 'Y', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x1C
+ {EfiKeyB1, 'z', 'Z', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_CAPS_LOCK}, // 0x1D
+ {EfiKeyE1, '1', '!', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT}, // 0x1E
+ {EfiKeyE2, '2', '@', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT}, // 0x1F
+ {EfiKeyE3, '3', '#', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT}, // 0x20
+ {EfiKeyE4, '4', '$', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT}, // 0x21
+ {EfiKeyE5, '5', '%', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT}, // 0x22
+ {EfiKeyE6, '6', '^', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT}, // 0x23
+ {EfiKeyE7, '7', '&', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT}, // 0x24
+ {EfiKeyE8, '8', '*', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT}, // 0x25
+ {EfiKeyE9, '9', '(', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT}, // 0x26
+ {EfiKeyE10, '0', ')', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT}, // 0x27
+ {EfiKeyEnter, 0x0d, 0x0d, EFI_NULL_MODIFIER, 0}, // 0x28 Enter
+ {EfiKeyEsc, 0x1b, 0x1b, EFI_NULL_MODIFIER, 0}, // 0x29 Esc
+ {EfiKeyBackSpace, 0x08, 0x08, EFI_NULL_MODIFIER, 0}, // 0x2A Backspace
+ {EfiKeyTab, 0x09, 0x09, EFI_NULL_MODIFIER, 0}, // 0x2B Tab
+ {EfiKeySpaceBar, ' ', ' ', EFI_NULL_MODIFIER, 0}, // 0x2C Spacebar
+ {EfiKeyE11, '-', '_', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT}, // 0x2D
+ {EfiKeyE12, '=', '+', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT}, // 0x2E
+ {EfiKeyD11, '[', '{', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT}, // 0x2F
+ {EfiKeyD12, ']', '}', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT}, // 0x30
+ {EfiKeyD13, '\\', '|', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT}, // 0x31
+ {EfiKeyC12, '\\', '|', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT}, // 0x32 Keyboard Non-US # and ~
+ {EfiKeyC10, ';', ':', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT}, // 0x33
+ {EfiKeyC11, '\'', '"', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT}, // 0x34
+ {EfiKeyE0, '`', '~', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT}, // 0x35 Keyboard Grave Accent and Tlide
+ {EfiKeyB8, ',', '<', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT}, // 0x36
+ {EfiKeyB9, '.', '>', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT}, // 0x37
+ {EfiKeyB10, '/', '?', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT}, // 0x38
+ {EfiKeyCapsLock, 0x00, 0x00, EFI_CAPS_LOCK_MODIFIER, 0}, // 0x39 CapsLock
+ {EfiKeyF1, 0x00, 0x00, EFI_FUNCTION_KEY_ONE_MODIFIER, 0}, // 0x3A
+ {EfiKeyF2, 0x00, 0x00, EFI_FUNCTION_KEY_TWO_MODIFIER, 0}, // 0x3B
+ {EfiKeyF3, 0x00, 0x00, EFI_FUNCTION_KEY_THREE_MODIFIER, 0}, // 0x3C
+ {EfiKeyF4, 0x00, 0x00, EFI_FUNCTION_KEY_FOUR_MODIFIER, 0}, // 0x3D
+ {EfiKeyF5, 0x00, 0x00, EFI_FUNCTION_KEY_FIVE_MODIFIER, 0}, // 0x3E
+ {EfiKeyF6, 0x00, 0x00, EFI_FUNCTION_KEY_SIX_MODIFIER, 0}, // 0x3F
+ {EfiKeyF7, 0x00, 0x00, EFI_FUNCTION_KEY_SEVEN_MODIFIER, 0}, // 0x40
+ {EfiKeyF8, 0x00, 0x00, EFI_FUNCTION_KEY_EIGHT_MODIFIER, 0}, // 0x41
+ {EfiKeyF9, 0x00, 0x00, EFI_FUNCTION_KEY_NINE_MODIFIER, 0}, // 0x42
+ {EfiKeyF10, 0x00, 0x00, EFI_FUNCTION_KEY_TEN_MODIFIER, 0}, // 0x43
+ {EfiKeyF11, 0x00, 0x00, EFI_FUNCTION_KEY_ELEVEN_MODIFIER, 0}, // 0x44 F11
+ {EfiKeyF12, 0x00, 0x00, EFI_FUNCTION_KEY_TWELVE_MODIFIER, 0}, // 0x45 F12
+ {EfiKeyPrint, 0x00, 0x00, EFI_PRINT_MODIFIER, 0}, // 0x46 PrintScreen
+ {EfiKeySLck, 0x00, 0x00, EFI_SCROLL_LOCK_MODIFIER, 0}, // 0x47 Scroll Lock
+ {EfiKeyPause, 0x00, 0x00, EFI_PAUSE_MODIFIER, 0}, // 0x48 Pause
+ {EfiKeyIns, 0x00, 0x00, EFI_INSERT_MODIFIER, 0}, // 0x49
+ {EfiKeyHome, 0x00, 0x00, EFI_HOME_MODIFIER, 0}, // 0x4A
+ {EfiKeyPgUp, 0x00, 0x00, EFI_PAGE_UP_MODIFIER, 0}, // 0x4B
+ {EfiKeyDel, 0x00, 0x00, EFI_DELETE_MODIFIER, 0}, // 0x4C
+ {EfiKeyEnd, 0x00, 0x00, EFI_END_MODIFIER, 0}, // 0x4D
+ {EfiKeyPgDn, 0x00, 0x00, EFI_PAGE_DOWN_MODIFIER, 0}, // 0x4E
+ {EfiKeyRightArrow, 0x00, 0x00, EFI_RIGHT_ARROW_MODIFIER, 0}, // 0x4F
+ {EfiKeyLeftArrow, 0x00, 0x00, EFI_LEFT_ARROW_MODIFIER, 0}, // 0x50
+ {EfiKeyDownArrow, 0x00, 0x00, EFI_DOWN_ARROW_MODIFIER, 0}, // 0x51
+ {EfiKeyUpArrow, 0x00, 0x00, EFI_UP_ARROW_MODIFIER, 0}, // 0x52
+ {EfiKeyNLck, 0x00, 0x00, EFI_NUM_LOCK_MODIFIER, 0}, // 0x53 NumLock
+ {EfiKeySlash, '/', '/', EFI_NULL_MODIFIER, 0}, // 0x54
+ {EfiKeyAsterisk, '*', '*', EFI_NULL_MODIFIER, 0}, // 0x55
+ {EfiKeyMinus, '-', '-', EFI_NULL_MODIFIER, 0}, // 0x56
+ {EfiKeyPlus, '+', '+', EFI_NULL_MODIFIER, 0}, // 0x57
+ {EfiKeyEnter, 0x0d, 0x0d, EFI_NULL_MODIFIER, 0}, // 0x58
+ {EfiKeyOne, '1', '1', EFI_END_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK}, // 0x59
+ {EfiKeyTwo, '2', '2', EFI_DOWN_ARROW_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK}, // 0x5A
+ {EfiKeyThree, '3', '3', EFI_PAGE_DOWN_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK}, // 0x5B
+ {EfiKeyFour, '4', '4', EFI_LEFT_ARROW_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK}, // 0x5C
+ {EfiKeyFive, '5', '5', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK}, // 0x5D
+ {EfiKeySix, '6', '6', EFI_RIGHT_ARROW_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK}, // 0x5E
+ {EfiKeySeven, '7', '7', EFI_HOME_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK}, // 0x5F
+ {EfiKeyEight, '8', '8', EFI_UP_ARROW_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK}, // 0x60
+ {EfiKeyNine, '9', '9', EFI_PAGE_UP_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK}, // 0x61
+ {EfiKeyZero, '0', '0', EFI_INSERT_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK}, // 0x62
+ {EfiKeyPeriod, '.', '.', EFI_DELETE_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT | EFI_AFFECTED_BY_NUM_LOCK}, // 0x63
+ {EfiKeyB0, '\\', '|', EFI_NULL_MODIFIER, EFI_AFFECTED_BY_STANDARD_SHIFT}, // 0x64 Keyboard Non-US \ and |
+ {EfiKeyA4, 0x00, 0x00, EFI_NULL_MODIFIER, 0}, // 0x65 Keyboard Application
+
+ {EfiKeyLCtrl, 0, 0, EFI_LEFT_CONTROL_MODIFIER, 0}, // 0xe0
+ {EfiKeyLShift, 0, 0, EFI_LEFT_SHIFT_MODIFIER, 0}, // 0xe1
+ {EfiKeyLAlt, 0, 0, EFI_LEFT_ALT_MODIFIER, 0}, // 0xe2
+ {EfiKeyA0, 0, 0, EFI_NULL_MODIFIER, 0}, // 0xe3
+ {EfiKeyRCtrl, 0, 0, EFI_RIGHT_CONTROL_MODIFIER, 0}, // 0xe4
+ {EfiKeyRShift, 0, 0, EFI_RIGHT_SHIFT_MODIFIER, 0}, // 0xe5
+ {EfiKeyA2, 0, 0, EFI_RIGHT_ALT_MODIFIER, 0}, // 0xe6
+ {EfiKeyA3, 0, 0, EFI_NULL_MODIFIER, 0}, // 0xe7
+};
+
+VOID
+LoadDefaultKeyboardLayout (
+ IN USB_KB_DEV *UsbKeyboardDevice
+ )
+/*++
+
+ Routine Description:
+ Initialize KeyConvertionTable by using default keyboard layout.
+
+ Arguments:
+ UsbKeyboardDevice The USB_KB_DEV instance.
+
+ Returns:
+ None.
+
+--*/
+{
+ UINTN Index;
+ EFI_KEY_DESCRIPTOR *KeyDescriptor;
+
+ //
+ // Construct KeyConvertionTable by default keyboard layout
+ //
+ KeyDescriptor = &UsbKeyboardDevice->KeyConvertionTable[0];
+
+ for (Index = 0; Index < (USB_KEYCODE_MAX_MAKE + 8); Index++) {
+ KeyDescriptor->Key = (EFI_KEY) KeyboardLayoutTable[Index][0];
+ KeyDescriptor->Unicode = KeyboardLayoutTable[Index][1];
+ KeyDescriptor->ShiftedUnicode = KeyboardLayoutTable[Index][2];
+ KeyDescriptor->AltGrUnicode = 0;
+ KeyDescriptor->ShiftedAltGrUnicode = 0;
+ KeyDescriptor->Modifier = KeyboardLayoutTable[Index][3];
+ KeyDescriptor->AffectedAttribute = KeyboardLayoutTable[Index][4];
+
+ KeyDescriptor++;
+ }
+}
+
+//
+// EFI_KEY to USB Scan Code convertion table
+//
+STATIC
+UINT8 UsbScanCodeConvertionTable[] = {
+ 0xe0, // EfiKeyLCtrl
+ 0xe3, // EfiKeyA0
+ 0xe2, // EfiKeyLAlt
+ 0x2c, // EfiKeySpaceBar
+ 0xe6, // EfiKeyA2
+ 0xe7, // EfiKeyA3
+ 0x65, // EfiKeyA4
+ 0xe4, // EfiKeyRCtrl
+ 0x50, // EfiKeyLeftArrow
+ 0x51, // EfiKeyDownArrow
+ 0x4F, // EfiKeyRightArrow
+ 0x62, // EfiKeyZero
+ 0x63, // EfiKeyPeriod
+ 0x28, // EfiKeyEnter
+ 0xe1, // EfiKeyLShift
+ 0x64, // EfiKeyB0
+ 0x1D, // EfiKeyB1
+ 0x1B, // EfiKeyB2
+ 0x06, // EfiKeyB3
+ 0x19, // EfiKeyB4
+ 0x05, // EfiKeyB5
+ 0x11, // EfiKeyB6
+ 0x10, // EfiKeyB7
+ 0x36, // EfiKeyB8
+ 0x37, // EfiKeyB9
+ 0x38, // EfiKeyB10
+ 0xe5, // EfiKeyRShift
+ 0x52, // EfiKeyUpArrow
+ 0x59, // EfiKeyOne
+ 0x5A, // EfiKeyTwo
+ 0x5B, // EfiKeyThree
+ 0x39, // EfiKeyCapsLock
+ 0x04, // EfiKeyC1
+ 0x16, // EfiKeyC2
+ 0x07, // EfiKeyC3
+ 0x09, // EfiKeyC4
+ 0x0A, // EfiKeyC5
+ 0x0B, // EfiKeyC6
+ 0x0D, // EfiKeyC7
+ 0x0E, // EfiKeyC8
+ 0x0F, // EfiKeyC9
+ 0x33, // EfiKeyC10
+ 0x34, // EfiKeyC11
+ 0x32, // EfiKeyC12
+ 0x5C, // EfiKeyFour
+ 0x5D, // EfiKeyFive
+ 0x5E, // EfiKeySix
+ 0x57, // EfiKeyPlus
+ 0x2B, // EfiKeyTab
+ 0x14, // EfiKeyD1
+ 0x1A, // EfiKeyD2
+ 0x08, // EfiKeyD3
+ 0x15, // EfiKeyD4
+ 0x17, // EfiKeyD5
+ 0x1C, // EfiKeyD6
+ 0x18, // EfiKeyD7
+ 0x0C, // EfiKeyD8
+ 0x12, // EfiKeyD9
+ 0x13, // EfiKeyD10
+ 0x2F, // EfiKeyD11
+ 0x30, // EfiKeyD12
+ 0x31, // EfiKeyD13
+ 0x4C, // EfiKeyDel
+ 0x4D, // EfiKeyEnd
+ 0x4E, // EfiKeyPgDn
+ 0x5F, // EfiKeySeven
+ 0x60, // EfiKeyEight
+ 0x61, // EfiKeyNine
+ 0x35, // EfiKeyE0
+ 0x1E, // EfiKeyE1
+ 0x1F, // EfiKeyE2
+ 0x20, // EfiKeyE3
+ 0x21, // EfiKeyE4
+ 0x22, // EfiKeyE5
+ 0x23, // EfiKeyE6
+ 0x24, // EfiKeyE7
+ 0x25, // EfiKeyE8
+ 0x26, // EfiKeyE9
+ 0x27, // EfiKeyE10
+ 0x2D, // EfiKeyE11
+ 0x2E, // EfiKeyE12
+ 0x2A, // EfiKeyBackSpace
+ 0x49, // EfiKeyIns
+ 0x4A, // EfiKeyHome
+ 0x4B, // EfiKeyPgUp
+ 0x53, // EfiKeyNLck
+ 0x54, // EfiKeySlash
+ 0x55, // EfiKeyAsterisk
+ 0x56, // EfiKeyMinus
+ 0x29, // EfiKeyEsc
+ 0x3A, // EfiKeyF1
+ 0x3B, // EfiKeyF2
+ 0x3C, // EfiKeyF3
+ 0x3D, // EfiKeyF4
+ 0x3E, // EfiKeyF5
+ 0x3F, // EfiKeyF6
+ 0x40, // EfiKeyF7
+ 0x41, // EfiKeyF8
+ 0x42, // EfiKeyF9
+ 0x43, // EfiKeyF10
+ 0x44, // EfiKeyF11
+ 0x45, // EfiKeyF12
+ 0x46, // EfiKeyPrint
+ 0x47, // EfiKeySLck
+ 0x48 // EfiKeyPause
+};
+
//
-// USB Key Code to Efi key mapping table
-// Format:<efi scan code>, <unicode without shift>, <unicode with shift>
+// Keyboard Layout Modifier to EFI Scan Code convertion table
//
STATIC
-UINT8 KeyConvertionTable[USB_KEYCODE_MAX_MAKE][3] = {
- { SCAN_NULL, 'a', 'A' }, // 0x04
- { SCAN_NULL, 'b', 'B' }, // 0x05
- { SCAN_NULL, 'c', 'C' }, // 0x06
- { SCAN_NULL, 'd', 'D' }, // 0x07
- { SCAN_NULL, 'e', 'E' }, // 0x08
- { SCAN_NULL, 'f', 'F' }, // 0x09
- { SCAN_NULL, 'g', 'G' }, // 0x0A
- { SCAN_NULL, 'h', 'H' }, // 0x0B
- { SCAN_NULL, 'i', 'I' }, // 0x0C
- { SCAN_NULL, 'j', 'J' }, // 0x0D
- { SCAN_NULL, 'k', 'K' }, // 0x0E
- { SCAN_NULL, 'l', 'L' }, // 0x0F
- { SCAN_NULL, 'm', 'M' }, // 0x10
- { SCAN_NULL, 'n', 'N' }, // 0x11
- { SCAN_NULL, 'o', 'O' }, // 0x12
- { SCAN_NULL, 'p', 'P' }, // 0x13
- { SCAN_NULL, 'q', 'Q' }, // 0x14
- { SCAN_NULL, 'r', 'R' }, // 0x15
- { SCAN_NULL, 's', 'S' }, // 0x16
- { SCAN_NULL, 't', 'T' }, // 0x17
- { SCAN_NULL, 'u', 'U' }, // 0x18
- { SCAN_NULL, 'v', 'V' }, // 0x19
- { SCAN_NULL, 'w', 'W' }, // 0x1A
- { SCAN_NULL, 'x', 'X' }, // 0x1B
- { SCAN_NULL, 'y', 'Y' }, // 0x1C
- { SCAN_NULL, 'z', 'Z' }, // 0x1D
- { SCAN_NULL, '1', '!' }, // 0x1E
- { SCAN_NULL, '2', '@' }, // 0x1F
- { SCAN_NULL, '3', '#' }, // 0x20
- { SCAN_NULL, '4', '$' }, // 0x21
- { SCAN_NULL, '5', '%' }, // 0x22
- { SCAN_NULL, '6', '^' }, // 0x23
- { SCAN_NULL, '7', '&' }, // 0x24
- { SCAN_NULL, '8', '*' }, // 0x25
- { SCAN_NULL, '9', '(' }, // 0x26
- { SCAN_NULL, '0', ')' }, // 0x27
- { SCAN_NULL, 0x0d, 0x0d }, // 0x28 Enter
- { SCAN_ESC, 0x00, 0x00 }, // 0x29 Esc
- { SCAN_NULL, 0x08, 0x08 }, // 0x2A Backspace
- { SCAN_NULL, 0x09, 0x09 }, // 0x2B Tab
- { SCAN_NULL, ' ', ' ' }, // 0x2C Spacebar
- { SCAN_NULL, '-', '_' }, // 0x2D
- { SCAN_NULL, '=', '+' }, // 0x2E
- { SCAN_NULL, '[', '{' }, // 0x2F
- { SCAN_NULL, ']', '}' }, // 0x30
- { SCAN_NULL, '\\', '|' }, // 0x31
- { SCAN_NULL, '\\', '|' }, // 0x32 Keyboard US \ and |
- { SCAN_NULL, ';', ':' }, // 0x33
- { SCAN_NULL, '\'', '"' }, // 0x34
- { SCAN_NULL, '`', '~' }, // 0x35 Keyboard Grave Accent and Tlide
- { SCAN_NULL, ',', '<' }, // 0x36
- { SCAN_NULL, '.', '>' }, // 0x37
- { SCAN_NULL, '/', '?' }, // 0x38
- { SCAN_NULL, 0x00, 0x00 }, // 0x39 CapsLock
- { SCAN_F1, 0x00, 0x00 }, // 0x3A
- { SCAN_F2, 0x00, 0x00 }, // 0x3B
- { SCAN_F3, 0x00, 0x00 }, // 0x3C
- { SCAN_F4, 0x00, 0x00 }, // 0x3D
- { SCAN_F5, 0x00, 0x00 }, // 0x3E
- { SCAN_F6, 0x00, 0x00 }, // 0x3F
- { SCAN_F7, 0x00, 0x00 }, // 0x40
- { SCAN_F8, 0x00, 0x00 }, // 0x41
- { SCAN_F9, 0x00, 0x00 }, // 0x42
- { SCAN_F10, 0x00, 0x00 }, // 0x43
- { SCAN_F11, 0x00, 0x00 }, // 0x44 F11
- { SCAN_F12, 0x00, 0x00 }, // 0x45 F12
- { SCAN_NULL, 0x00, 0x00 }, // 0x46 PrintScreen
- { SCAN_NULL, 0x00, 0x00 }, // 0x47 Scroll Lock
- { SCAN_NULL, 0x00, 0x00 }, // 0x48 Pause
- { SCAN_INSERT, 0x00, 0x00 }, // 0x49
- { SCAN_HOME, 0x00, 0x00 }, // 0x4A
- { SCAN_PAGE_UP, 0x00, 0x00 }, // 0x4B
- { SCAN_DELETE, 0x00, 0x00 }, // 0x4C
- { SCAN_END, 0x00, 0x00 }, // 0x4D
- { SCAN_PAGE_DOWN, 0x00, 0x00 }, // 0x4E
- { SCAN_RIGHT, 0x00, 0x00 }, // 0x4F
- { SCAN_LEFT, 0x00, 0x00 }, // 0x50
- { SCAN_DOWN, 0x00, 0x00 }, // 0x51
- { SCAN_UP, 0x00, 0x00 }, // 0x52
- { SCAN_NULL, 0x00, 0x00 }, // 0x53 NumLock
- { SCAN_NULL, '/', '/' }, // 0x54
- { SCAN_NULL, '*', '*' }, // 0x55
- { SCAN_NULL, '-', '-' }, // 0x56
- { SCAN_NULL, '+', '+' }, // 0x57
- { SCAN_NULL, 0x0d, 0x0d }, // 0x58
- { SCAN_END, '1', '1' }, // 0x59
- { SCAN_DOWN, '2', '2' }, // 0x5A
- { SCAN_PAGE_DOWN, '3', '3' }, // 0x5B
- { SCAN_LEFT, '4', '4' }, // 0x5C
- { SCAN_NULL, '5', '5' }, // 0x5D
- { SCAN_RIGHT, '6', '6' }, // 0x5E
- { SCAN_HOME, '7', '7' }, // 0x5F
- { SCAN_UP, '8', '8' }, // 0x60
- { SCAN_PAGE_UP, '9', '9' }, // 0x61
- { SCAN_INSERT, '0', '0' }, // 0x62
- { SCAN_DELETE, '.', '.' }, // 0x63
- { SCAN_NULL, '\\', '|' }, // 0x64 Keyboard Non-US \ and |
- { SCAN_NULL, 0x00, 0x00 }, // 0x65 Keyboard Application
- { SCAN_NULL, 0x00, 0x00 }, // 0x66 Keyboard Power
- { SCAN_NULL, '=' , '=' }, // 0x67 Keypad =
- { SCAN_F13, 0x00, 0x00 }, // 0x68
- { SCAN_F14, 0x00, 0x00 }, // 0x69
- { SCAN_F15, 0x00, 0x00 }, // 0x6A
- { SCAN_F16, 0x00, 0x00 }, // 0x6B
- { SCAN_F17, 0x00, 0x00 }, // 0x6C
- { SCAN_F18, 0x00, 0x00 }, // 0x6D
- { SCAN_F19, 0x00, 0x00 }, // 0x6E
- { SCAN_F20, 0x00, 0x00 }, // 0x6F
- { SCAN_F21, 0x00, 0x00 }, // 0x70
- { SCAN_F22, 0x00, 0x00 }, // 0x71
- { SCAN_F23, 0x00, 0x00 }, // 0x72
- { SCAN_F24, 0x00, 0x00 }, // 0x73
- { SCAN_MUTE, 0x00, 0x00 }, // 0x7F
- { SCAN_VOLUME_UP, 0x00, 0x00 }, // 0x80
- { SCAN_VOLUME_DOWN, 0x00, 0x00 }, // 0x81
+UINT8 EfiScanCodeConvertionTable[] = {
+ SCAN_NULL, // EFI_NULL_MODIFIER
+ SCAN_NULL, // EFI_LEFT_CONTROL_MODIFIER
+ SCAN_NULL, // EFI_RIGHT_CONTROL_MODIFIER
+ SCAN_NULL, // EFI_LEFT_ALT_MODIFIER
+ SCAN_NULL, // EFI_RIGHT_ALT_MODIFIER
+ SCAN_NULL, // EFI_ALT_GR_MODIFIER
+ SCAN_INSERT, // EFI_INSERT_MODIFIER
+ SCAN_DELETE, // EFI_DELETE_MODIFIER
+ SCAN_PAGE_DOWN, // EFI_PAGE_DOWN_MODIFIER
+ SCAN_PAGE_UP, // EFI_PAGE_UP_MODIFIER
+ SCAN_HOME, // EFI_HOME_MODIFIER
+ SCAN_END, // EFI_END_MODIFIER
+ SCAN_NULL, // EFI_LEFT_SHIFT_MODIFIER
+ SCAN_NULL, // EFI_RIGHT_SHIFT_MODIFIER
+ SCAN_NULL, // EFI_CAPS_LOCK_MODIFIER
+ SCAN_NULL, // EFI_NUM_LOCK_MODIFIER
+ SCAN_LEFT, // EFI_LEFT_ARROW_MODIFIER
+ SCAN_RIGHT, // EFI_RIGHT_ARROW_MODIFIER
+ SCAN_DOWN, // EFI_DOWN_ARROW_MODIFIER
+ SCAN_UP, // EFI_UP_ARROW_MODIFIER
+ SCAN_NULL, // EFI_NS_KEY_MODIFIER
+ SCAN_NULL, // EFI_NS_KEY_DEPENDENCY_MODIFIER
+ SCAN_F1, // EFI_FUNCTION_KEY_ONE_MODIFIER
+ SCAN_F2, // EFI_FUNCTION_KEY_TWO_MODIFIER
+ SCAN_F3, // EFI_FUNCTION_KEY_THREE_MODIFIER
+ SCAN_F4, // EFI_FUNCTION_KEY_FOUR_MODIFIER
+ SCAN_F5, // EFI_FUNCTION_KEY_FIVE_MODIFIER
+ SCAN_F6, // EFI_FUNCTION_KEY_SIX_MODIFIER
+ SCAN_F7, // EFI_FUNCTION_KEY_SEVEN_MODIFIER
+ SCAN_F8, // EFI_FUNCTION_KEY_EIGHT_MODIFIER
+ SCAN_F9, // EFI_FUNCTION_KEY_NINE_MODIFIER
+ SCAN_F10, // EFI_FUNCTION_KEY_TEN_MODIFIER
+ SCAN_F11, // EFI_FUNCTION_KEY_ELEVEN_MODIFIER
+ SCAN_F12, // EFI_FUNCTION_KEY_TWELVE_MODIFIER
};
+EFI_GUID mKeyboardLayoutEventGuid = EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID;
+
+
STATIC KB_MODIFIER KB_Mod[8] = {
{ MOD_CONTROL_L, 0xe0 }, // 11100000
{ MOD_CONTROL_R, 0xe4 }, // 11100100
@@ -200,6 +387,387 @@ IsUSBKeyboard ( }
+EFI_HII_KEYBOARD_LAYOUT *
+GetCurrentKeyboardLayout (
+ VOID
+ )
+/*++
+
+ Routine Description:
+ Get current keyboard layout from HII database.
+
+ Arguments:
+ None.
+
+ Returns:
+ Pointer to EFI_HII_KEYBOARD_LAYOUT.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
+ EFI_HII_KEYBOARD_LAYOUT *KeyboardLayout;
+ UINT16 Length;
+
+ //
+ // Locate Hii database protocol
+ //
+ Status = gBS->LocateProtocol (
+ &gEfiHiiDatabaseProtocolGuid,
+ NULL,
+ (VOID **) &HiiDatabase
+ );
+ if (EFI_ERROR (Status)) {
+ return NULL;
+ }
+
+ //
+ // Get current keyboard layout from HII database
+ //
+ Length = 0;
+ KeyboardLayout = NULL;
+ Status = HiiDatabase->GetKeyboardLayout (
+ HiiDatabase,
+ NULL,
+ &Length,
+ KeyboardLayout
+ );
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ KeyboardLayout = AllocatePool (Length);
+ ASSERT (KeyboardLayout != NULL);
+
+ Status = HiiDatabase->GetKeyboardLayout (
+ HiiDatabase,
+ NULL,
+ &Length,
+ KeyboardLayout
+ );
+ if (EFI_ERROR (Status)) {
+ gBS->FreePool (KeyboardLayout);
+ KeyboardLayout = NULL;
+ }
+ }
+
+ return KeyboardLayout;
+}
+
+EFI_KEY_DESCRIPTOR *
+GetKeyDescriptor (
+ IN USB_KB_DEV *UsbKeyboardDevice,
+ IN UINT8 ScanCode
+ )
+/*++
+
+ Routine Description:
+ Find Key Descriptor in KeyConvertionTable given its scan code.
+
+ Arguments:
+ UsbKeyboardDevice - The USB_KB_DEV instance.
+ ScanCode - USB scan code.
+
+ Returns:
+ The Key descriptor in KeyConvertionTable.
+
+--*/
+{
+ UINT8 Index;
+
+ if (((ScanCode > 0x65) && (ScanCode < 0xe0)) || (ScanCode > 0xe7)) {
+ return NULL;
+ }
+
+ if (ScanCode <= 0x65) {
+ Index = (UINT8) (ScanCode - 4);
+ } else {
+ Index = (UINT8) (ScanCode - 0xe0 + USB_KEYCODE_MAX_MAKE);
+ }
+
+ return &UsbKeyboardDevice->KeyConvertionTable[Index];
+}
+
+USB_NS_KEY *
+FindUsbNsKey (
+ IN USB_KB_DEV *UsbKeyboardDevice,
+ IN EFI_KEY_DESCRIPTOR *KeyDescriptor
+ )
+/*++
+
+ Routine Description:
+ Find Non-Spacing key for given KeyDescriptor.
+
+ Arguments:
+ UsbKeyboardDevice - The USB_KB_DEV instance.
+ KeyDescriptor - Key descriptor.
+
+ Returns:
+ The Non-Spacing key.
+
+--*/
+{
+ LIST_ENTRY *Link;
+ USB_NS_KEY *UsbNsKey;
+
+ Link = GetFirstNode (&UsbKeyboardDevice->NsKeyList);
+ while (!IsNull (&UsbKeyboardDevice->NsKeyList, Link)) {
+ UsbNsKey = USB_NS_KEY_FORM_FROM_LINK (Link);
+
+ if (UsbNsKey->NsKey[0].Key == KeyDescriptor->Key) {
+ return UsbNsKey;
+ }
+
+ Link = GetNextNode (&UsbKeyboardDevice->NsKeyList, Link);
+ }
+
+ return NULL;
+}
+
+EFI_KEY_DESCRIPTOR *
+FindPhysicalKey (
+ IN USB_NS_KEY *UsbNsKey,
+ IN EFI_KEY_DESCRIPTOR *KeyDescriptor
+ )
+/*++
+
+ Routine Description:
+ Find physical key definition for a given Key stroke.
+
+ Arguments:
+ UsbNsKey - The Non-Spacing key information.
+ KeyDescriptor - The key stroke.
+
+ Returns:
+ The physical key definition.
+
+--*/
+{
+ UINTN Index;
+ EFI_KEY_DESCRIPTOR *PhysicalKey;
+
+ PhysicalKey = &UsbNsKey->NsKey[1];
+ for (Index = 0; Index < UsbNsKey->KeyCount; Index++) {
+ if (KeyDescriptor->Key == PhysicalKey->Key) {
+ return PhysicalKey;
+ }
+
+ PhysicalKey++;
+ }
+
+ //
+ // No children definition matched, return original key
+ //
+ return KeyDescriptor;
+}
+
+VOID
+EFIAPI
+SetKeyboardLayoutEvent (
+ EFI_EVENT Event,
+ VOID *Context
+ )
+/*++
+
+ Routine Description:
+ The notification function for SET_KEYBOARD_LAYOUT_EVENT.
+
+ Arguments:
+
+ Returns:
+
+--*/
+{
+ USB_KB_DEV *UsbKeyboardDevice;
+ EFI_HII_KEYBOARD_LAYOUT *KeyboardLayout;
+ EFI_KEY_DESCRIPTOR TempKey;
+ EFI_KEY_DESCRIPTOR *KeyDescriptor;
+ EFI_KEY_DESCRIPTOR *TableEntry;
+ EFI_KEY_DESCRIPTOR *NsKey;
+ USB_NS_KEY *UsbNsKey;
+ UINTN Index;
+ UINTN Index2;
+ UINTN KeyCount;
+ UINT8 ScanCode;
+
+ UsbKeyboardDevice = (USB_KB_DEV *) Context;
+
+ //
+ // Try to get current Keyboard Layout from HII database
+ //
+ KeyboardLayout = GetCurrentKeyboardLayout ();
+ if (KeyboardLayout == NULL) {
+ return;
+ }
+
+ //
+ // Allocate resource for KeyConvertionTable
+ //
+ ReleaseKeyboardLayoutResources (UsbKeyboardDevice);
+ UsbKeyboardDevice->KeyConvertionTable = AllocateZeroPool ((USB_KEYCODE_MAX_MAKE + 8) * sizeof (EFI_KEY_DESCRIPTOR));
+ ASSERT (UsbKeyboardDevice->KeyConvertionTable != NULL);
+
+ KeyDescriptor = (EFI_KEY_DESCRIPTOR *) (((UINT8 *) KeyboardLayout) + sizeof (EFI_HII_KEYBOARD_LAYOUT));
+ for (Index = 0; Index < KeyboardLayout->DescriptorCount; Index++) {
+ //
+ // Copy from HII keyboard layout package binary for alignment
+ //
+ CopyMem (&TempKey, KeyDescriptor, sizeof (EFI_KEY_DESCRIPTOR));
+
+ //
+ // Fill the key into KeyConvertionTable (which use USB Scan Code as index)
+ //
+ ScanCode = UsbScanCodeConvertionTable [(UINT8) (TempKey.Key)];
+ TableEntry = GetKeyDescriptor (UsbKeyboardDevice, ScanCode);
+ CopyMem (TableEntry, KeyDescriptor, sizeof (EFI_KEY_DESCRIPTOR));
+
+ if (TempKey.Modifier == EFI_NS_KEY_MODIFIER) {
+ //
+ // Non-spacing key
+ //
+ UsbNsKey = AllocatePool (sizeof (USB_NS_KEY));
+ ASSERT (UsbNsKey != NULL);
+
+ //
+ // Search for sequential children physical key definitions
+ //
+ KeyCount = 0;
+ NsKey = KeyDescriptor + 1;
+ for (Index2 = Index + 1; Index2 < KeyboardLayout->DescriptorCount; Index2++) {
+ CopyMem (&TempKey, NsKey, sizeof (EFI_KEY_DESCRIPTOR));
+ if (TempKey.Modifier & EFI_NS_KEY_DEPENDENCY_MODIFIER) {
+ KeyCount++;
+ } else {
+ break;
+ }
+ NsKey++;
+ }
+
+ UsbNsKey->Signature = USB_NS_KEY_SIGNATURE;
+ UsbNsKey->KeyCount = KeyCount;
+ UsbNsKey->NsKey = AllocateCopyPool (
+ (KeyCount + 1) * sizeof (EFI_KEY_DESCRIPTOR),
+ KeyDescriptor
+ );
+ InsertTailList (&UsbKeyboardDevice->NsKeyList, &UsbNsKey->Link);
+
+ //
+ // Skip over the child physical keys
+ //
+ Index += KeyCount;
+ KeyDescriptor += KeyCount;
+ }
+
+ KeyDescriptor++;
+ }
+
+ //
+ // There are two EfiKeyEnter, duplicate its Key Descriptor
+ //
+ TableEntry = GetKeyDescriptor (UsbKeyboardDevice, 0x58);
+ KeyDescriptor = GetKeyDescriptor (UsbKeyboardDevice, 0x28);
+ CopyMem (TableEntry, KeyDescriptor, sizeof (EFI_KEY_DESCRIPTOR));
+
+ gBS->FreePool (KeyboardLayout);
+}
+
+VOID
+ReleaseKeyboardLayoutResources (
+ IN USB_KB_DEV *UsbKeyboardDevice
+ )
+/*++
+
+ Routine Description:
+ Destroy resources for Keyboard layout.
+
+ Arguments:
+ UsbKeyboardDevice - The USB_KB_DEV instance.
+
+ Returns:
+ None.
+
+--*/
+{
+ USB_NS_KEY *UsbNsKey;
+ LIST_ENTRY *Link;
+
+ SafeFreePool (UsbKeyboardDevice->KeyConvertionTable);
+ UsbKeyboardDevice->KeyConvertionTable = NULL;
+
+ while (!IsListEmpty (&UsbKeyboardDevice->NsKeyList)) {
+ Link = GetFirstNode (&UsbKeyboardDevice->NsKeyList);
+ UsbNsKey = USB_NS_KEY_FORM_FROM_LINK (Link);
+ RemoveEntryList (&UsbNsKey->Link);
+
+ gBS->FreePool (UsbNsKey->NsKey);
+ gBS->FreePool (UsbNsKey);
+ }
+}
+
+EFI_STATUS
+InitKeyboardLayout (
+ IN USB_KB_DEV *UsbKeyboardDevice
+ )
+/*++
+
+ Routine Description:
+ Initialize USB Keyboard layout.
+
+ Arguments:
+ UsbKeyboardDevice The USB_KB_DEV instance.
+
+ Returns:
+ EFI_SUCCESS - Success
+ Other - Keyboard layout initial failed.
+--*/
+{
+ EFI_HII_KEYBOARD_LAYOUT *KeyboardLayout;
+ EFI_STATUS Status;
+
+ UsbKeyboardDevice->KeyConvertionTable = AllocateZeroPool ((USB_KEYCODE_MAX_MAKE + 8) * sizeof (EFI_KEY_DESCRIPTOR));
+ ASSERT (UsbKeyboardDevice->KeyConvertionTable != NULL);
+
+ InitializeListHead (&UsbKeyboardDevice->NsKeyList);
+ UsbKeyboardDevice->CurrentNsKey = NULL;
+ UsbKeyboardDevice->KeyboardLayoutEvent = NULL;
+
+ //
+ // Register SET_KEYBOARD_LAYOUT_EVENT notification
+ //
+ Status = gBS->CreateEventEx (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ TPL_NOTIFY,
+ SetKeyboardLayoutEvent,
+ UsbKeyboardDevice,
+ &mKeyboardLayoutEventGuid,
+ &UsbKeyboardDevice->KeyboardLayoutEvent
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Try to get current keyboard layout from HII database
+ //
+ KeyboardLayout = GetCurrentKeyboardLayout ();
+ if (KeyboardLayout != NULL) {
+ //
+ // Force to initialize the keyboard layout
+ //
+ gBS->SignalEvent (UsbKeyboardDevice->KeyboardLayoutEvent);
+ } else {
+ if (FeaturePcdGet (PcdDisableDefaultKeyboardLayoutInUsbKbDriver)) {
+ return EFI_NOT_READY;
+ } else {
+
+ //
+ // Fail to get keyboard layout from HII database,
+ // use default keyboard layout
+ //
+ LoadDefaultKeyboardLayout (UsbKeyboardDevice);
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
/**
Initialize USB Keyboard device and all private data structures.
@@ -304,14 +872,18 @@ InitUSBKeyboard ( UsbKeyboardDevice->LeftCtrlOn = 0;
UsbKeyboardDevice->LeftAltOn = 0;
- UsbKeyboardDevice->LeftShiftOn = 0;
- UsbKeyboardDevice->LeftLogoOn = 0;
+ UsbKeyboardDevice->LeftShiftOn = 0;
+ UsbKeyboardDevice->LeftLogoOn = 0;
UsbKeyboardDevice->RightCtrlOn = 0;
UsbKeyboardDevice->RightAltOn = 0;
- UsbKeyboardDevice->RightShiftOn = 0;
- UsbKeyboardDevice->RightLogoOn = 0;
+ UsbKeyboardDevice->RightShiftOn = 0;
+ UsbKeyboardDevice->RightLogoOn = 0;
UsbKeyboardDevice->MenuKeyOn = 0;
- UsbKeyboardDevice->SysReqOn = 0;
+ UsbKeyboardDevice->SysReqOn = 0;
+
+ UsbKeyboardDevice->AltGrOn = 0;
+
+ UsbKeyboardDevice->CurrentNsKey = NULL;
//
// Sync the initial state of lights
@@ -390,6 +962,7 @@ KeyboardHandler ( USB_KEY UsbKey;
UINT8 NewRepeatKey;
UINT32 UsbStatus;
+ EFI_KEY_DESCRIPTOR *KeyDescriptor;
ASSERT (Context);
@@ -573,7 +1146,8 @@ KeyboardHandler ( //
// NumLock pressed or CapsLock pressed
//
- if (CurKeyCodeBuffer[Index] == 0x53 || CurKeyCodeBuffer[Index] == 0x39) {
+ KeyDescriptor = GetKeyDescriptor (UsbKeyboardDevice, CurKeyCodeBuffer[Index]);
+ if (KeyDescriptor->Modifier == EFI_NUM_LOCK_MODIFIER || KeyDescriptor->Modifier == EFI_CAPS_LOCK_MODIFIER) {
UsbKeyboardDevice->RepeatKey = 0;
} else {
NewRepeatKey = CurKeyCodeBuffer[Index];
@@ -602,10 +1176,12 @@ KeyboardHandler ( while (Index != SavedTail) {
RemoveKeyCode (&(UsbKeyboardDevice->KeyboardBuffer), &UsbKey);
- switch (UsbKey.KeyCode) {
+ KeyDescriptor = GetKeyDescriptor (UsbKeyboardDevice, UsbKey.KeyCode);
- case 0xe0:
- case 0xe4:
+ switch (KeyDescriptor->Modifier) {
+
+ case EFI_LEFT_CONTROL_MODIFIER:
+ case EFI_RIGHT_CONTROL_MODIFIER:
if (UsbKey.Down) {
UsbKeyboardDevice->CtrlOn = 1;
} else {
@@ -613,8 +1189,8 @@ KeyboardHandler ( }
break;
- case 0xe2:
- case 0xe6:
+ case EFI_LEFT_ALT_MODIFIER:
+ case EFI_RIGHT_ALT_MODIFIER:
if (UsbKey.Down) {
UsbKeyboardDevice->AltOn = 1;
} else {
@@ -622,11 +1198,18 @@ KeyboardHandler ( }
break;
+ case EFI_ALT_GR_MODIFIER:
+ if (UsbKey.Down) {
+ UsbKeyboardDevice->AltGrOn = 1;
+ } else {
+ UsbKeyboardDevice->AltGrOn = 0;
+ }
+ break;
+
//
// Del Key Code
//
- case 0x4c:
- case 0x63:
+ case EFI_DELETE_MODIFIER:
if (UsbKey.Down) {
if (UsbKeyboardDevice->CtrlOn && UsbKeyboardDevice->AltOn) {
gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);
@@ -688,7 +1271,8 @@ USBParseKey ( OUT UINT8 *KeyChar
)
{
- USB_KEY UsbKey;
+ USB_KEY UsbKey;
+ EFI_KEY_DESCRIPTOR *KeyDescriptor;
*KeyChar = 0;
@@ -698,17 +1282,18 @@ USBParseKey ( //
RemoveKeyCode (&(UsbKeyboardDevice->KeyboardBuffer), &UsbKey);
+ KeyDescriptor = GetKeyDescriptor (UsbKeyboardDevice, UsbKey.KeyCode);
if (!UsbKey.Down) {
- switch (UsbKey.KeyCode) {
+ switch (KeyDescriptor->Modifier) {
//
// CTRL release
//
- case 0xe0:
+ case EFI_LEFT_CONTROL_MODIFIER:
UsbKeyboardDevice->LeftCtrlOn = 0;
UsbKeyboardDevice->CtrlOn = 0;
break;
- case 0xe4:
+ case EFI_RIGHT_CONTROL_MODIFIER:
UsbKeyboardDevice->RightCtrlOn = 0;
UsbKeyboardDevice->CtrlOn = 0;
break;
@@ -716,11 +1301,11 @@ USBParseKey ( //
// Shift release
//
- case 0xe1:
+ case EFI_LEFT_SHIFT_MODIFIER:
UsbKeyboardDevice->LeftShiftOn = 0;
UsbKeyboardDevice->ShiftOn = 0;
break;
- case 0xe5:
+ case EFI_RIGHT_SHIFT_MODIFIER:
UsbKeyboardDevice->RightShiftOn = 0;
UsbKeyboardDevice->ShiftOn = 0;
break;
@@ -728,38 +1313,50 @@ USBParseKey ( //
// Alt release
//
- case 0xe2:
+ case EFI_LEFT_ALT_MODIFIER:
UsbKeyboardDevice->LeftAltOn = 0;
UsbKeyboardDevice->AltOn = 0;
break;
- case 0xe6:
+ case EFI_RIGHT_ALT_MODIFIER:
UsbKeyboardDevice->RightAltOn = 0;
UsbKeyboardDevice->AltOn = 0;
break;
//
- // Logo release
+ // Left Logo release
//
- case 0xe3:
+ case EFI_LEFT_LOGO_MODIFIER:
UsbKeyboardDevice->LeftLogoOn = 0;
break;
- case 0xe7:
+
+ //
+ // Right Logo release
+ //
+ case EFI_RIGHT_LOGO_MODIFIER:
UsbKeyboardDevice->RightLogoOn = 0;
break;
//
- // Menu key (App/Apps) release
+ // Menu key release
//
- case 0x65:
+ case EFI_MENU_MODIFIER:
UsbKeyboardDevice->MenuKeyOn = 0;
break;
//
// SysReq release
//
- case 0x46:
+ case EFI_SYS_REQUEST_MODIFIER:
UsbKeyboardDevice->SysReqOn = 0;
break;
+
+ //
+ // AltGr release
+ //
+ case EFI_ALT_GR_MODIFIER:
+ UsbKeyboardDevice->AltGrOn = 0;
+ break;
+
default:
break;
}
@@ -770,14 +1367,17 @@ USBParseKey ( //
// Analyzes key pressing situation
//
- switch (UsbKey.KeyCode) {
+ switch (KeyDescriptor->Modifier) {
- case 0xe0:
+ //
+ // CTRL press
+ //
+ case EFI_LEFT_CONTROL_MODIFIER:
UsbKeyboardDevice->LeftCtrlOn = 1;
UsbKeyboardDevice->CtrlOn = 1;
- continue;
+ continue;
break;
- case 0xe4:
+ case EFI_RIGHT_CONTROL_MODIFIER:
UsbKeyboardDevice->RightCtrlOn = 1;
UsbKeyboardDevice->CtrlOn = 1;
continue;
@@ -786,13 +1386,13 @@ USBParseKey ( //
// Shift press
//
- case 0xe1:
+ case EFI_LEFT_SHIFT_MODIFIER:
UsbKeyboardDevice->LeftShiftOn = 1;
UsbKeyboardDevice->ShiftOn = 1;
continue;
break;
- case 0xe5:
- UsbKeyboardDevice->RightShiftOn = 1;
+ case EFI_RIGHT_SHIFT_MODIFIER:
+ UsbKeyboardDevice->RightShiftOn = 1;
UsbKeyboardDevice->ShiftOn = 1;
continue;
break;
@@ -800,46 +1400,54 @@ USBParseKey ( //
// Alt press
//
- case 0xe2:
+ case EFI_LEFT_ALT_MODIFIER:
UsbKeyboardDevice->LeftAltOn = 1;
UsbKeyboardDevice->AltOn = 1;
continue;
break;
- case 0xe6:
- UsbKeyboardDevice->RightAltOn = 1;
+ case EFI_RIGHT_ALT_MODIFIER:
+ UsbKeyboardDevice->RightAltOn = 1;
UsbKeyboardDevice->AltOn = 1;
continue;
break;
//
- // Logo press
+ // Left Logo press
//
- case 0xe3:
+ case EFI_LEFT_LOGO_MODIFIER:
UsbKeyboardDevice->LeftLogoOn = 1;
- continue;
break;
- case 0xe7:
+
+ //
+ // Right Logo press
+ //
+ case EFI_RIGHT_LOGO_MODIFIER:
UsbKeyboardDevice->RightLogoOn = 1;
- continue;
break;
//
- // Menu key (App/Apps) press
+ // Menu key press
//
- case 0x65:
+ case EFI_MENU_MODIFIER:
UsbKeyboardDevice->MenuKeyOn = 1;
- continue;
break;
//
// SysReq press
//
- case 0x46:
+ case EFI_SYS_REQUEST_MODIFIER:
UsbKeyboardDevice->SysReqOn = 1;
- continue;
+ continue;
+ break;
+
+ //
+ // AltGr press
+ //
+ case EFI_ALT_GR_MODIFIER:
+ UsbKeyboardDevice->AltGrOn = 1;
break;
- case 0x53:
+ case EFI_NUM_LOCK_MODIFIER:
UsbKeyboardDevice->NumLockOn ^= 1;
//
// Turn on the NumLock light on KB
@@ -848,7 +1456,7 @@ USBParseKey ( continue;
break;
- case 0x39:
+ case EFI_CAPS_LOCK_MODIFIER:
UsbKeyboardDevice->CapsOn ^= 1;
//
// Turn on the CapsLock light on KB
@@ -857,7 +1465,7 @@ USBParseKey ( continue;
break;
- case 0x47:
+ case EFI_SCROLL_LOCK_MODIFIER:
UsbKeyboardDevice->ScrollOn ^= 1;
//
// Turn on the ScrollLock light on KB
@@ -867,22 +1475,17 @@ USBParseKey ( break;
//
- // PrintScreen,Pause,Application,Power
- // keys are not valid EFI key
- //
-
- //
- // PrintScreen/SysRq key and Application key
- // Should be handled by UEFI2.1 compliant code
-
- case 0x48:
- //
- // fall through
- //
- case 0x66:
- //
- // fall through
+ // F11,F12,PrintScreen,Pause/Break
+ // could not be retrieved via SimpleTxtInEx protocol
//
+ case EFI_FUNCTION_KEY_ELEVEN_MODIFIER:
+ case EFI_FUNCTION_KEY_TWELVE_MODIFIER:
+ case EFI_PRINT_MODIFIER:
+ case EFI_PAUSE_MODIFIER:
+ case EFI_BREAK_MODIFIER:
+ //
+ // fall through
+ //
continue;
break;
@@ -893,7 +1496,7 @@ USBParseKey ( //
// When encountered Del Key...
//
- if (UsbKey.KeyCode == 0x4c || UsbKey.KeyCode == 0x63) {
+ if (KeyDescriptor->Modifier == EFI_DELETE_MODIFIER) {
if (UsbKeyboardDevice->CtrlOn && UsbKeyboardDevice->AltOn) {
gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);
}
@@ -904,7 +1507,6 @@ USBParseKey ( }
return EFI_NOT_READY;
-
}
@@ -929,7 +1531,8 @@ USBKeyCodeToEFIScanCode ( OUT EFI_INPUT_KEY *Key
)
{
- UINT8 Index;
+ UINT8 Index;
+ EFI_KEY_DESCRIPTOR *KeyDescriptor;
if (!USBKBD_VALID_KEYCODE (KeyChar)) {
return EFI_NOT_READY;
@@ -944,68 +1547,100 @@ USBKeyCodeToEFIScanCode ( return EFI_NOT_READY;
}
+ KeyDescriptor = GetKeyDescriptor (UsbKeyboardDevice, KeyChar);
+
//
- // Undefined entries from 0x74 to 0x7E
+ // Check for Non-spacing key
//
- if (KeyChar > USB_KEYCODE_MAX_MAKE) {
- Index = (UINT8) (Index - 11);
+ if (KeyDescriptor->Modifier == EFI_NS_KEY_MODIFIER) {
+ UsbKeyboardDevice->CurrentNsKey = FindUsbNsKey (UsbKeyboardDevice, KeyDescriptor);
+ return EFI_NOT_READY;
}
- Key->ScanCode = KeyConvertionTable[Index][0];
+ //
+ // Check whether this keystroke follows a Non-spacing key
+ //
+ if (UsbKeyboardDevice->CurrentNsKey != NULL) {
+ KeyDescriptor = FindPhysicalKey (UsbKeyboardDevice->CurrentNsKey, KeyDescriptor);
+ UsbKeyboardDevice->CurrentNsKey = NULL;
+ }
- if (UsbKeyboardDevice->ShiftOn) {
+ Key->ScanCode = EfiScanCodeConvertionTable[KeyDescriptor->Modifier];
+ Key->UnicodeChar = KeyDescriptor->Unicode;
- Key->UnicodeChar = KeyConvertionTable[Index][2];
- //
- // Need not return associated shift state if a class of printable characters that
- // are normally adjusted by shift modifiers. e.g. Shift Key + 'f' key = 'F'
- //
- if (Key->UnicodeChar >= 'A' && Key->UnicodeChar <= 'Z') {
- UsbKeyboardDevice->LeftShiftOn = 0;
- UsbKeyboardDevice->RightShiftOn = 0;
- }
+ if (KeyDescriptor->AffectedAttribute & EFI_AFFECTED_BY_STANDARD_SHIFT) {
+ if (UsbKeyboardDevice->ShiftOn) {
+ Key->UnicodeChar = KeyDescriptor->ShiftedUnicode;
- } else {
+ //
+ // Need not return associated shift state if a class of printable characters that
+ // are normally adjusted by shift modifiers. e.g. Shift Key + 'f' key = 'F'
+ //
+ if (KeyDescriptor->AffectedAttribute & EFI_AFFECTED_BY_CAPS_LOCK) {
+ UsbKeyboardDevice->LeftShiftOn = 0;
+ UsbKeyboardDevice->RightShiftOn = 0;
+ }
+
+ if (UsbKeyboardDevice->AltGrOn) {
+ Key->UnicodeChar = KeyDescriptor->ShiftedAltGrUnicode;
+ }
+ } else {
+ //
+ // Shift off
+ //
+ Key->UnicodeChar = KeyDescriptor->Unicode;
- Key->UnicodeChar = KeyConvertionTable[Index][1];
+ if (UsbKeyboardDevice->AltGrOn) {
+ Key->UnicodeChar = KeyDescriptor->AltGrUnicode;
+ }
+ }
}
- if (UsbKeyboardDevice->CapsOn) {
+ if (KeyDescriptor->AffectedAttribute & EFI_AFFECTED_BY_CAPS_LOCK) {
+ if (UsbKeyboardDevice->CapsOn) {
- if (Key->UnicodeChar >= 'a' && Key->UnicodeChar <= 'z') {
+ if (Key->UnicodeChar == KeyDescriptor->Unicode) {
- Key->UnicodeChar = KeyConvertionTable[Index][2];
+ Key->UnicodeChar = KeyDescriptor->ShiftedUnicode;
- } else if (Key->UnicodeChar >= 'A' && Key->UnicodeChar <= 'Z') {
+ } else if (Key->UnicodeChar == KeyDescriptor->ShiftedUnicode) {
- Key->UnicodeChar = KeyConvertionTable[Index][1];
+ Key->UnicodeChar = KeyDescriptor->Unicode;
+ }
}
}
+
//
// Translate the CTRL-Alpha characters to their corresponding control value (ctrl-a = 0x0001 through ctrl-Z = 0x001A)
//
if (UsbKeyboardDevice->CtrlOn) {
if (Key->UnicodeChar >= 'a' && Key->UnicodeChar <= 'z') {
- Key->UnicodeChar = (UINT16) (Key->UnicodeChar - 'a' + 1);
+ Key->UnicodeChar = (UINT8) (Key->UnicodeChar - 'a' + 1);
} else if (Key->UnicodeChar >= 'A' && Key->UnicodeChar <= 'Z') {
- Key->UnicodeChar = (UINT16) (Key->UnicodeChar - 'A' + 1);
+ Key->UnicodeChar = (UINT8) (Key->UnicodeChar - 'A' + 1);
}
}
-
-
- if (KeyChar >= 0x59 && KeyChar <= 0x63) {
+
+ if (KeyDescriptor->AffectedAttribute & EFI_AFFECTED_BY_NUM_LOCK) {
if (UsbKeyboardDevice->NumLockOn && !UsbKeyboardDevice->ShiftOn) {
Key->ScanCode = SCAN_NULL;
} else {
-
Key->UnicodeChar = 0x00;
}
}
+ //
+ // Translate Unicode 0x1B (ESC) to EFI Scan Code
+ //
+ if (Key->UnicodeChar == 0x1B && Key->ScanCode == SCAN_NULL) {
+ Key->ScanCode = SCAN_ESC;
+ Key->UnicodeChar = 0x00;
+ }
+
if (Key->UnicodeChar == 0 && Key->ScanCode == SCAN_NULL) {
return EFI_NOT_READY;
}
@@ -1043,7 +1678,7 @@ USBKeyCodeToEFIScanCode ( }
if (UsbKeyboardDevice->SysReqOn == 1) {
UsbKeyboardDevice->KeyState.KeyShiftState |= EFI_SYS_REQ_PRESSED;
- }
+ }
if (UsbKeyboardDevice->ScrollOn == 1) {
UsbKeyboardDevice->KeyState.KeyToggleState |= EFI_SCROLL_LOCK_ACTIVE;
diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/keyboard.h b/MdeModulePkg/Bus/Usb/UsbKbDxe/keyboard.h index 9a8cb0f493..2e7ccf7888 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/keyboard.h +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/keyboard.h @@ -37,6 +37,16 @@ InitUSBKeyboard ( );
EFI_STATUS
+InitKeyboardLayout (
+ IN USB_KB_DEV *UsbKeyboardDevice
+ );
+
+VOID
+ReleaseKeyboardLayoutResources (
+ USB_KB_DEV *UsbKeyboardDevice
+ );
+
+EFI_STATUS
EFIAPI
KeyboardHandler (
IN VOID *Data,
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index ea709c5aa1..8e9bb040dd 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -132,6 +132,8 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdSupportHardwareErrorRecord|FALSE|BOOLEAN|0x00010045
gEfiMdeModulePkgTokenSpaceGuid.PcdUgaConsumeSupport|TRUE|BOOLEAN|0x00010046
gEfiMdeModulePkgTokenSpaceGuid.PcdTurnOffUsbLegacySupport|FALSE|BOOLEAN|0x00010047
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSupportHiiImageProtocol|TRUE|BOOLEAN|0x00010100
+ gEfiMdeModulePkgTokenSpaceGuid.PcdDisableDefaultKeyboardLayoutInUsbKbDriver|FALSE|BOOLEAN|0x00010200
[PcdsFixedAtBuild.common]
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPcdCallBackNumberPerPcdEntry|0x08|UINT32|0x0001000f
diff --git a/MdeModulePkg/Universal/BdsDxe/FrontPage.c b/MdeModulePkg/Universal/BdsDxe/FrontPage.c index 7f3155b2c2..47da390f17 100644 --- a/MdeModulePkg/Universal/BdsDxe/FrontPage.c +++ b/MdeModulePkg/Universal/BdsDxe/FrontPage.c @@ -931,6 +931,8 @@ Returns: //
// Timeout or user press enter to continue
//
+ gST->ConOut->EnableCursor (gST->ConOut, TRUE);
+ gST->ConOut->ClearScreen (gST->ConOut);
goto Exit;
}
}
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c index 3f35ed9005..8decc76102 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c @@ -27,189 +27,6 @@ Revision History #ifndef DISABLE_UNUSED_HII_PROTOCOLS
-STATIC
-CHAR16
-NibbleToHexCharPrivate (
- IN UINT8 Nibble
- )
-/*++
-
- Routine Description:
- Converts the low nibble of a byte to hex unicode character.
-
- Arguments:
- Nibble - lower nibble of a byte.
-
- Returns:
- Hex unicode character between L'0' to L'f'.
-
---*/
-{
- Nibble &= 0x0F;
-
- if (Nibble <= 0x9) {
- return (CHAR16)(Nibble + L'0');
- }
-
- return (CHAR16)(Nibble - 0xA + L'a');
-}
-
-
-/**
- Converts Unicode string to binary buffer.
- The conversion may be partial.
- The first character in the string that is not hex digit stops the conversion.
- At a minimum, any blob of data could be represented as a hex string.
-
- @param Buf Pointer to buffer that receives the data.
- @param Len Length in bytes of the buffer to hold converted
- data. If routine return with EFI_SUCCESS,
- containing length of converted data. If routine
- return with EFI_BUFFER_TOO_SMALL, containg length
- of buffer desired.
- @param Str String to be converted from.
- @param ConvertedStrLen Length of the Hex String consumed.
-
- @retval EFI_SUCCESS Routine Success.
- @retval EFI_BUFFER_TOO_SMALL The buffer is too small to hold converted data.
-
-**/
-STATIC
-EFI_STATUS
-HexStringToBufPrivate (
- IN OUT UINT8 *Buf,
- IN OUT UINTN *Len,
- IN CHAR16 *Str,
- OUT UINTN *ConvertedStrLen OPTIONAL
- )
-{
- UINTN HexCnt;
- UINTN Idx;
- UINTN BufferLength;
- UINT8 Digit;
- UINT8 Byte;
-
- //
- // Find out how many hex characters the string has.
- //
- for (Idx = 0, HexCnt = 0; IsHexDigit (&Digit, Str[Idx]); Idx++, HexCnt++);
-
- if (HexCnt == 0) {
- *Len = 0;
- return EFI_SUCCESS;
- }
- //
- // Two Unicode characters make up 1 buffer byte. Round up.
- //
- BufferLength = (HexCnt + 1) / 2;
-
- //
- // Test if buffer is passed enough.
- //
- if (BufferLength > (*Len)) {
- *Len = BufferLength;
- return EFI_BUFFER_TOO_SMALL;
- }
-
- *Len = BufferLength;
-
- for (Idx = 0; Idx < HexCnt; Idx++) {
-
- IsHexDigit (&Digit, Str[Idx]);
-
- //
- // For odd charaters, write the lower nibble for each buffer byte,
- // and for even characters, the upper nibble.
- //
- if ((Idx & 1) == 0) {
- Byte = (UINT8) (Digit << 4);
- } else {
- Byte = Buf[Idx / 2];
- Byte &= 0xF0;
- Byte = (UINT8) (Byte | Digit);
- }
-
- Buf[Idx / 2] = Byte;
- }
-
- if (ConvertedStrLen != NULL) {
- *ConvertedStrLen = HexCnt;
- }
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Converts binary buffer to Unicode string.
- At a minimum, any blob of data could be represented as a hex string.
-
- @param Str Pointer to the string.
- @param HexStringBufferLength Length in bytes of buffer to hold the hex string.
- Includes tailing '\0' character. If routine return
- with EFI_SUCCESS, containing length of hex string
- buffer. If routine return with
- EFI_BUFFER_TOO_SMALL, containg length of hex
- string buffer desired.
- @param Buf Buffer to be converted from.
- @param Len Length in bytes of the buffer to be converted.
- @param Flag If TRUE, encode the data in the same order as the
- it resides in the Buf. Else encode it in the
- reverse direction.
-
- @retval EFI_SUCCESS Routine success.
- @retval EFI_BUFFER_TOO_SMALL The hex string buffer is too small.
-
-**/
-STATIC
-EFI_STATUS
-BufToHexStringPrivate (
- IN OUT CHAR16 *Str,
- IN OUT UINTN *HexStringBufferLength,
- IN UINT8 *Buf,
- IN UINTN Len,
- IN BOOLEAN Flag
- )
-{
- UINTN Idx;
- UINT8 Byte;
- UINTN StrLen;
-
- //
- // Make sure string is either passed or allocate enough.
- // It takes 2 Unicode characters (4 bytes) to represent 1 byte of the binary buffer.
- // Plus the Unicode termination character.
- //
- StrLen = Len * 2;
- if ((*HexStringBufferLength) < (StrLen + 1) * sizeof (CHAR16)) {
- *HexStringBufferLength = (StrLen + 1) * sizeof (CHAR16);
- return EFI_BUFFER_TOO_SMALL;
- }
-
- *HexStringBufferLength = (StrLen + 1) * sizeof (CHAR16);
-
- //
- // Ends the string.
- //
- Str[StrLen] = 0;
-
- for (Idx = 0; Idx < Len; Idx++) {
-
- Byte = Buf[Idx];
- if (Flag) {
- Str[Idx * 2] = NibbleToHexCharPrivate ((UINT8)(Byte >> 4));
- Str[Idx * 2 + 1] = NibbleToHexCharPrivate (Byte);
- } else {
- Str[StrLen - 1 - Idx * 2] = NibbleToHexCharPrivate (Byte);
- Str[StrLen - 2 - Idx * 2] = NibbleToHexCharPrivate ((UINT8)(Byte >> 4));
- }
- }
-
- return EFI_SUCCESS;
-}
-
-
-
/**
Calculate the number of Unicode characters of the incoming Configuration string,
not including NULL terminator.
@@ -306,7 +123,6 @@ GetDevicePath ( // The data in <PathHdr> is encoded as hex UNICODE %02x bytes in the same order
// as the device path resides in RAM memory.
// Translate the data into binary.
- // Two Unicode characters make up 1 buffer byte.
//
Length /= 2;
*DevicePath = (UINT8 *) AllocateZeroPool (Length);
@@ -315,7 +131,7 @@ GetDevicePath ( return EFI_OUT_OF_RESOURCES;
}
- HexStringToBufPrivate (*DevicePath, &Length, DevicePathString, NULL);
+ HexStringToBuffer (*DevicePath, &Length, DevicePathString);
SafeFreePool (DevicePathString);
@@ -503,12 +319,11 @@ ExportAllStorage ( @param String A constant string which is the prefix of the to be
generated string, e.g. GUID=
@param BufferLen The length of the Buffer in bytes.
- @param Buffer Points to a buffer which will be converted to hex
- string and to be the content of the generated
- string.
- @param Flag If TRUE, convert the buffer data in the same order
- as the it resides in the Buffer. Else convert it
- in the reverse direction.
+ @param Buffer Points to a buffer which will be converted to be the
+ content of the generated string.
+ @param Flag If 1, the buffer contains data for the value of GUID or PATH stored in
+ UINT8 *; if 2, the buffer contains unicode string for the value of NAME;
+ if 3, the buffer contains other data.
@param SubStr Points to the output string. It's caller's
responsibility to free this buffer.
@@ -519,14 +334,15 @@ VOID GenerateSubStr (
IN CONST EFI_STRING String,
IN UINTN BufferLen,
- IN UINT8 *Buffer,
- IN BOOLEAN Flag,
+ IN VOID *Buffer,
+ IN UINT8 Flag,
OUT EFI_STRING *SubStr
)
{
UINTN Length;
EFI_STRING Str;
EFI_STATUS Status;
+ EFI_STRING StringHeader;
ASSERT (String != NULL && SubStr != NULL);
@@ -536,20 +352,33 @@ GenerateSubStr ( return ;
}
- Length = BufferLen * 2 + 1 + StrLen (String) + 1;
+ Length = StrLen (String) + BufferLen * 2 + 1 + 1;
Str = AllocateZeroPool (Length * sizeof (CHAR16));
ASSERT (Str != NULL);
StrCpy (Str, String);
Length = (BufferLen * 2 + 1) * sizeof (CHAR16);
- Status = BufToHexStringPrivate (
- Str + StrLen (String),
- &Length,
- Buffer,
- BufferLen,
- Flag
- );
+ Status = EFI_SUCCESS;
+ StringHeader = Str + StrLen (String);
+
+ switch (Flag) {
+ case 1:
+ Status = BufferToHexString (StringHeader, (UINT8 *) Buffer, BufferLen);
+ break;
+ case 2:
+ Status = UnicodeToConfigString (StringHeader, &Length, (CHAR16 *) Buffer);
+ break;
+ case 3:
+ Status = BufToHexString (StringHeader, &Length, (UINT8 *) Buffer, BufferLen);
+ //
+ // Convert the uppercase to lowercase since <HexAf> is defined in lowercase format.
+ //
+ ToLower (StringHeader);
+ break;
+ default:
+ break;
+ }
ASSERT_EFI_ERROR (Status);
StrCat (Str, L"&");
@@ -1096,7 +925,7 @@ HiiConfigRoutingExportConfig ( if (PathHdr == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- Status = BufToHexStringPrivate (PathHdr, &PathHdrSize, (UINT8 *) DevicePath, Length, TRUE);
+ Status = BufferToHexString (PathHdr, (UINT8 *) DevicePath, Length);
ASSERT_EFI_ERROR (Status);
//
@@ -1104,7 +933,7 @@ HiiConfigRoutingExportConfig ( // It means extract all possible configurations from this specific driver.
//
TmpSize = StrLen (L"GUID=&NAME=&PATH=");
- RequestSize = (TmpSize + sizeof (EFI_GUID) * 2 + StrLen (Storage->Name))
+ RequestSize = (TmpSize + 32 + StrLen (Storage->Name) * 4)
* sizeof (CHAR16) + PathHdrSize;
ConfigRequest = (EFI_STRING) AllocateZeroPool (RequestSize);
if (ConfigRequest == NULL) {
@@ -1115,20 +944,16 @@ HiiConfigRoutingExportConfig ( //
// Add <GuidHdr>
// <GuidHdr> ::= 'GUID='<Guid>
+ // Convert <Guid> in the same order as it resides in RAM memory.
//
StringPtr = ConfigRequest;
StrnCpy (StringPtr, L"GUID=", StrLen (L"GUID="));
StringPtr += StrLen (L"GUID=");
- Status = BufToHexStringPrivate (
- StringPtr,
- &RequestSize,
- (UINT8 *) (&Storage->Guid),
- sizeof (EFI_GUID),
- FALSE
- );
+ Status = BufferToHexString (StringPtr, (UINT8 *) (&Storage->Guid), sizeof (EFI_GUID));
ASSERT_EFI_ERROR (Status);
- StringPtr += RequestSize / 2 - 1;
+
+ StringPtr += 32;
ASSERT (*StringPtr == 0);
*StringPtr = L'&';
StringPtr++;
@@ -1139,8 +964,12 @@ HiiConfigRoutingExportConfig ( //
StrnCpy (StringPtr, L"NAME=", StrLen (L"NAME="));
StringPtr += StrLen (L"NAME=");
- StrnCpy (StringPtr, Storage->Name, StrLen (Storage->Name));
- StringPtr += StrLen (Storage->Name);
+
+ Length = (StrLen (Storage->Name) * 4 + 1) * sizeof (CHAR16);
+ Status = UnicodeToConfigString (StringPtr, &Length, Storage->Name);
+ ASSERT_EFI_ERROR (Status);
+ StringPtr += StrLen (Storage->Name) * 4;
+
*StringPtr = L'&';
StringPtr++;
@@ -1250,7 +1079,7 @@ HiiConfigRoutingExportConfig ( **/
EFI_STATUS
EFIAPI
-HiiConfigRoutingRoutConfig (
+HiiConfigRoutingRouteConfig (
IN CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *This,
IN CONST EFI_STRING Configuration,
OUT EFI_STRING *Progress
@@ -1609,6 +1438,8 @@ HiiBlockToConfig ( Status = BufToHexString (ValueStr, &Length, Value, Width);
ASSERT_EFI_ERROR (Status);
+ ToLower (ValueStr);
+
SafeFreePool (Value);
Value = NULL;
@@ -1955,30 +1786,21 @@ HiiGetAltCfg ( //
// Generate the sub string for later matching.
//
- GenerateSubStr (L"GUID=", sizeof (EFI_GUID), (UINT8 *) Guid, FALSE, &GuidStr);
+ GenerateSubStr (L"GUID=", sizeof (EFI_GUID), (VOID *) Guid, 1, &GuidStr);
GenerateSubStr (
L"PATH=",
GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) DevicePath),
- (UINT8 *) DevicePath,
- TRUE,
+ (VOID *) DevicePath,
+ 1,
&PathStr
);
if (AltCfgId != NULL) {
- GenerateSubStr (L"ALTCFG=", sizeof (UINT16), (UINT8 *) AltCfgId, FALSE, &AltIdStr);
+ GenerateSubStr (L"ALTCFG=", sizeof (UINT16), (VOID *) AltCfgId, 3, &AltIdStr);
}
if (Name != NULL) {
- Length = StrLen (Name);
- Length += StrLen (L"NAME=&") + 1;
- NameStr = AllocateZeroPool (Length * sizeof (CHAR16));
- if (NameStr == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Exit;
- }
- StrCpy (NameStr, L"NAME=");
- StrCat (NameStr, Name);
- StrCat (NameStr, L"&");
+ GenerateSubStr (L"NAME=", StrLen (Name) * sizeof (CHAR16), (VOID *) Name, 2, &NameStr);
} else {
- GenerateSubStr (L"NAME=", 0, NULL, FALSE, &NameStr);
+ GenerateSubStr (L"NAME=", 0, NULL, 2, &NameStr);
}
while (*StringPtr != 0) {
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c index 3ee8b4ca34..b5a5c43b43 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c @@ -1,6 +1,6 @@ /** @file
-Copyright (c) 2007, Intel Corporation
+Copyright (c) 2007 - 2008, Intel Corporation
All rights reserved. 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
@@ -2771,8 +2771,7 @@ HiiNewPackageList ( @retval EFI_SUCCESS The data associated with the Handle was removed
from the HII database.
- @retval EFI_NOT_FOUND The specified PackageList could not be found in
- database.
+ @retval EFI_NOT_FOUND The specified andle is not in database.
@retval EFI_INVALID_PARAMETER The Handle was not valid.
**/
@@ -2790,10 +2789,14 @@ HiiRemovePackageList ( HII_DATABASE_PACKAGE_LIST_INSTANCE *PackageList;
HII_HANDLE *HiiHandle;
- if (This == NULL || !IsHiiHandleValid (Handle)) {
+ if (This == NULL) {
return EFI_INVALID_PARAMETER;
}
+ if (!IsHiiHandleValid (Handle)) {
+ return EFI_NOT_FOUND;
+ }
+
Private = HII_DATABASE_DATABASE_PRIVATE_DATA_FROM_THIS (This);
//
@@ -2879,9 +2882,8 @@ HiiRemovePackageList ( @retval EFI_SUCCESS The HII database was successfully updated.
@retval EFI_OUT_OF_RESOURCES Unable to allocate enough memory for the updated
database.
- @retval EFI_INVALID_PARAMETER Handle or PackageList was NULL.
- @retval EFI_NOT_FOUND The Handle was not valid or could not be found in
- database.
+ @retval EFI_INVALID_PARAMETER PackageList was NULL.
+ @retval EFI_NOT_FOUND The specified Handle is not in database.
**/
EFI_STATUS
@@ -2900,7 +2902,7 @@ HiiUpdatePackageList ( HII_DATABASE_PACKAGE_LIST_INSTANCE *OldPackageList;
EFI_HII_PACKAGE_HEADER PackageHeader;
- if (This == NULL || PackageList == NULL || Handle == NULL) {
+ if (This == NULL || PackageList == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -2993,12 +2995,17 @@ HiiUpdatePackageList ( @param Handle An array of EFI_HII_HANDLE instances returned.
@retval EFI_SUCCESS The matching handles are outputed successfully.
+ HandleBufferLength is updated with the actual length.
@retval EFI_BUFFER_TO_SMALL The HandleBufferLength parameter indicates that
Handle is too small to support the number of
handles. HandleBufferLength is updated with a
value that will enable the data to fit.
@retval EFI_NOT_FOUND No matching handle could not be found in database.
@retval EFI_INVALID_PARAMETER Handle or HandleBufferLength was NULL.
+
+ @retval EFI_INVALID_PARAMETER PackageType is not a EFI_HII_PACKAGE_TYPE_GUID but
+ PackageGuid is not NULL, PackageType is a EFI_HII_
+ PACKAGE_TYPE_GUID but PackageGuid is NULL.
**/
EFI_STATUS
@@ -3350,10 +3357,14 @@ HiiUnregisterPackageNotify ( LIST_ENTRY *Link;
EFI_STATUS Status;
- if (This == NULL || NotificationHandle == NULL) {
+ if (This == NULL) {
return EFI_INVALID_PARAMETER;
}
+ if (NotificationHandle == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
Status = gBS->OpenProtocol (
NotificationHandle,
&mHiiDatabaseNotifyGuid,
@@ -3363,7 +3374,7 @@ HiiUnregisterPackageNotify ( EFI_OPEN_PROTOCOL_TEST_PROTOCOL
);
if (EFI_ERROR (Status)) {
- return EFI_INVALID_PARAMETER;
+ return EFI_NOT_FOUND;
}
Private = HII_DATABASE_DATABASE_PRIVATE_DATA_FROM_THIS (This);
@@ -3474,7 +3485,7 @@ HiiFindKeyboardLayouts ( for (Index = 0; Index < LayoutCount; Index++) {
ResultSize += sizeof (EFI_GUID);
if (ResultSize <= *KeyGuidBufferLength) {
- CopyMem (KeyGuidBuffer + Index, Layout + sizeof (UINT16), sizeof (EFI_GUID));
+ CopyMem (KeyGuidBuffer + (ResultSize / sizeof (EFI_GUID) - 1), Layout + sizeof (UINT16), sizeof (EFI_GUID));
CopyMem (&LayoutLength, Layout, sizeof (UINT16));
Layout = Layout + LayoutLength;
}
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c index f605061981..9e99a12012 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c @@ -905,15 +905,14 @@ GetSystemFont ( /**
- Check whether EFI_FONT_DISPLAY_INFO points to system default font and color.
+ Check whether EFI_FONT_DISPLAY_INFO points to system default font and color or
+ returns the system default according to the optional inputs.
@param Private HII database driver private data.
@param StringInfo Points to the string output information,
including the color and font.
- @param SystemInfo If not NULL, points to system default font and
- color when incoming StringInfo does not match the
- default. Points to NULL if matches. It's
- caller's reponsibility to free this buffer.
+ @param SystemInfo If not NULL, points to system default font and color.
+
@param SystemInfoLen If not NULL, output the length of default system
info.
@@ -933,6 +932,7 @@ IsSystemFontInfo ( EFI_STATUS Status;
EFI_FONT_DISPLAY_INFO *SystemDefault;
UINTN DefaultLen;
+ BOOLEAN Flag;
ASSERT (Private != NULL && Private->Signature == HII_DATABASE_PRIVATE_DATA_SIGNATURE);
@@ -940,28 +940,69 @@ IsSystemFontInfo ( return TRUE;
}
- //
- // Check whether incoming string font and color matches system default.
- //
Status = GetSystemFont (Private, &SystemDefault, &DefaultLen);
ASSERT_EFI_ERROR (Status);
+ //
+ // Record the system default info.
+ //
if (SystemInfo != NULL) {
*SystemInfo = SystemDefault;
- } else {
- SafeFreePool (SystemDefault);
}
if (SystemInfoLen != NULL) {
*SystemInfoLen = DefaultLen;
}
- if (StringInfo == NULL ||
- (StringInfo != NULL && CompareMem (SystemDefault, StringInfo, DefaultLen) == 0)) {
+ if (StringInfo == NULL) {
return TRUE;
}
- return FALSE;
+ Flag = FALSE;
+ //
+ // Check the FontInfoMask to see whether it is retrieving system info.
+ //
+ if ((StringInfo->FontInfoMask & (EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_ANY_FONT)) == 0) {
+ if (StrCmp (StringInfo->FontInfo.FontName, SystemDefault->FontInfo.FontName) != 0) {
+ goto Exit;
+ }
+ }
+ if ((StringInfo->FontInfoMask & (EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_ANY_SIZE)) == 0) {
+ if (StringInfo->FontInfo.FontSize != SystemDefault->FontInfo.FontSize) {
+ goto Exit;
+ }
+ }
+ if ((StringInfo->FontInfoMask & (EFI_FONT_INFO_SYS_STYLE | EFI_FONT_INFO_ANY_STYLE)) == 0) {
+ if (StringInfo->FontInfo.FontStyle != SystemDefault->FontInfo.FontStyle) {
+ goto Exit;
+ }
+ }
+ if ((StringInfo->FontInfoMask & EFI_FONT_INFO_SYS_FORE_COLOR) == 0) {
+ if (CompareMem (
+ &StringInfo->ForegroundColor,
+ &SystemDefault->ForegroundColor,
+ sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
+ ) != 0) {
+ goto Exit;
+ }
+ }
+ if ((StringInfo->FontInfoMask & EFI_FONT_INFO_SYS_BACK_COLOR) == 0) {
+ if (CompareMem (
+ &StringInfo->BackgroundColor,
+ &SystemDefault->BackgroundColor,
+ sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
+ ) != 0) {
+ goto Exit;
+ }
+ }
+
+ Flag = TRUE;
+
+Exit:
+ if (SystemInfo == NULL) {
+ SafeFreePool (SystemDefault);
+ }
+ return Flag;
}
@@ -1400,6 +1441,7 @@ IsLineBreak ( @retval EFI_OUT_OF_RESOURCES Unable to allocate an output buffer for
RowInfoArray or Blt.
@retval EFI_INVALID_PARAMETER The String or Blt was NULL.
+ @retval EFI_INVALID_PARAMETER Flags were invalid combination..
**/
EFI_STATUS
@@ -1470,16 +1512,16 @@ HiiStringToImage ( //
// These two flags require that EFI_HII_OUT_FLAG_CLIP be also set.
//
- if ((Flags & (EFI_HII_OUT_FLAG_CLIP | EFI_HII_OUT_FLAG_CLEAN_X)) == EFI_HII_OUT_FLAG_CLEAN_X) {
+ if ((Flags & (EFI_HII_OUT_FLAG_CLIP | EFI_HII_OUT_FLAG_CLIP_CLEAN_X)) == EFI_HII_OUT_FLAG_CLIP_CLEAN_X) {
return EFI_INVALID_PARAMETER;
}
- if ((Flags & (EFI_HII_OUT_FLAG_CLIP | EFI_HII_OUT_FLAG_CLEAN_Y)) == EFI_HII_OUT_FLAG_CLEAN_Y) {
+ if ((Flags & (EFI_HII_OUT_FLAG_CLIP | EFI_HII_OUT_FLAG_CLIP_CLEAN_Y)) == EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) {
return EFI_INVALID_PARAMETER;
}
//
// This flag cannot be used with EFI_HII_OUT_FLAG_CLEAN_X.
//
- if ((Flags & (EFI_HII_OUT_FLAG_WRAP | EFI_HII_OUT_FLAG_CLEAN_X)) == (EFI_HII_OUT_FLAG_WRAP | EFI_HII_OUT_FLAG_CLEAN_X)) {
+ if ((Flags & (EFI_HII_OUT_FLAG_WRAP | EFI_HII_OUT_FLAG_CLIP_CLEAN_X)) == (EFI_HII_OUT_FLAG_WRAP | EFI_HII_OUT_FLAG_CLIP_CLEAN_X)) {
return EFI_INVALID_PARAMETER;
}
@@ -1633,7 +1675,7 @@ HiiStringToImage ( //
Transparent = (BOOLEAN) ((Flags & EFI_HII_OUT_FLAG_TRANSPARENT) == EFI_HII_OUT_FLAG_TRANSPARENT ? TRUE : FALSE);
- if ((Flags & EFI_HII_OUT_FLAG_CLEAN_Y) == EFI_HII_OUT_FLAG_CLEAN_Y) {
+ if ((Flags & EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) == EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) {
//
// Don't draw at all if there is only one row and
// the row's bottom-most on pixel cannot fit.
@@ -1705,7 +1747,7 @@ HiiStringToImage ( //
if (!LineBreak) {
Flags &= (~ (EFI_HII_OUT_FLAGS) EFI_HII_OUT_FLAG_WRAP);
- Flags |= EFI_HII_OUT_FLAG_CLEAN_X;
+ Flags |= EFI_HII_OUT_FLAG_CLIP_CLEAN_X;
}
}
@@ -1713,7 +1755,7 @@ HiiStringToImage ( // Clip the right-most character if cannot fit when EFI_HII_OUT_FLAG_CLEAN_X is set.
//
if (LineWidth + BltX <= Image->Width ||
- (LineWidth + BltX > Image->Width && (Flags & EFI_HII_OUT_FLAG_CLEAN_X) == 0)) {
+ (LineWidth + BltX > Image->Width && (Flags & EFI_HII_OUT_FLAG_CLIP_CLEAN_X) == 0)) {
//
// Record right-most character in RowInfo even if it is partially displayed.
//
@@ -1749,7 +1791,7 @@ HiiStringToImage ( //
if (RowIndex == MaxRowNum - 1 && Image->Height < LineHeight) {
LineHeight = Image->Height;
- if ((Flags & EFI_HII_OUT_FLAG_CLEAN_Y) == EFI_HII_OUT_FLAG_CLEAN_Y) {
+ if ((Flags & EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) == EFI_HII_OUT_FLAG_CLIP_CLEAN_Y) {
//
// Don't draw at all if the row's bottom-most on pixel cannot fit.
//
@@ -1968,7 +2010,10 @@ Exit: @retval EFI_SUCCESS The string was successfully rendered.
@retval EFI_OUT_OF_RESOURCES Unable to allocate an output buffer for
RowInfoArray or Blt.
- @retval EFI_INVALID_PARAMETER The PackageList was NULL.
+ @retval EFI_INVALID_PARAMETER The Blt or PackageList was NULL.
+ @retval EFI_INVALID_PARAMETER Flags were invalid combination.
+ @retval EFI_NOT_FOUND The specified PackageList is not in the Database or the stringid is not
+ in the specified PackageList.
**/
EFI_STATUS
@@ -1992,6 +2037,10 @@ HiiStringIdToImage ( HII_DATABASE_PRIVATE_DATA *Private;
EFI_STRING String;
UINTN StringSize;
+ UINTN FontLen;
+ EFI_FONT_INFO *StringFontInfo;
+ EFI_FONT_DISPLAY_INFO *NewStringInfo;
+ CHAR8 CurrentLang[RFC_3066_ENTRY_SIZE];
if (This == NULL || PackageList == NULL || Blt == NULL || PackageList == NULL) {
return EFI_INVALID_PARAMETER;
@@ -2001,7 +2050,14 @@ HiiStringIdToImage ( return EFI_NOT_FOUND;
}
- Private = HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This);
+ //
+ // When Language points to NULL, current system language is used.
+ //
+ if (Language != NULL) {
+ AsciiStrCpy (CurrentLang, (CHAR8 *) Language);
+ } else {
+ HiiLibGetCurrentLanguage (CurrentLang);
+ }
//
// Get the string to be displayed.
@@ -2013,14 +2069,18 @@ HiiStringIdToImage ( return EFI_OUT_OF_RESOURCES;
}
+ Private = HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This);
+ StringFontInfo = NULL;
+ NewStringInfo = NULL;
+
Status = Private->HiiString.GetString (
&Private->HiiString,
- Language,
+ CurrentLang,
PackageList,
StringId,
String,
&StringSize,
- NULL
+ &StringFontInfo
);
if (Status == EFI_BUFFER_TOO_SMALL) {
SafeFreePool (String);
@@ -2041,11 +2101,42 @@ HiiStringIdToImage ( }
if (EFI_ERROR (Status)) {
- SafeFreePool (String);
- return Status;
+ goto Exit;
+ }
+
+ //
+ // When StringInfo specifies that string will be output in the system default font and color,
+ // use particular stringfontinfo described in string package instead if exists.
+ // StringFontInfo equals NULL means system default font attaches with the string block.
+ //
+ if (StringFontInfo != NULL && IsSystemFontInfo (Private, (EFI_FONT_DISPLAY_INFO *) StringInfo, NULL, NULL)) {
+ FontLen = sizeof (EFI_FONT_DISPLAY_INFO) - sizeof (CHAR16) + StrSize (StringFontInfo->FontName);
+ NewStringInfo = AllocateZeroPool (FontLen);
+ if (NewStringInfo == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Exit;
+ }
+ NewStringInfo->FontInfoMask = EFI_FONT_INFO_SYS_FORE_COLOR | EFI_FONT_INFO_SYS_BACK_COLOR;
+ NewStringInfo->FontInfo.FontStyle = StringFontInfo->FontStyle;
+ NewStringInfo->FontInfo.FontSize = StringFontInfo->FontSize;
+ StrCpy (NewStringInfo->FontInfo.FontName, StringFontInfo->FontName);
+
+ Status = HiiStringToImage (
+ This,
+ Flags,
+ String,
+ NewStringInfo,
+ Blt,
+ BltX,
+ BltY,
+ RowInfoArray,
+ RowInfoArraySize,
+ ColumnInfoArray
+ );
+ goto Exit;
}
- return HiiStringToImage (
+ Status = HiiStringToImage (
This,
Flags,
String,
@@ -2058,6 +2149,12 @@ HiiStringIdToImage ( ColumnInfoArray
);
+Exit:
+ SafeFreePool (String);
+ SafeFreePool (StringFontInfo);
+ SafeFreePool (NewStringInfo);
+
+ return Status;
}
@@ -2231,7 +2328,9 @@ Exit: returned font handle or points to NULL if there
are no more matching fonts.
@param StringInfoIn Upon entry, points to the font to return
- information about.
+ information about.
+ If NULL, then the information about the system default
+ font will be returned.
@param StringInfoOut Upon return, contains the matching font's
information. If NULL, then no information is
returned. It's caller's responsibility to free
@@ -2242,7 +2341,7 @@ Exit: @retval EFI_SUCCESS Matching font returned successfully.
@retval EFI_NOT_FOUND No matching font was found.
- @retval EFI_INVALID_PARAMETER StringInfoIn is NULL.
+ @retval EFI_INVALID_PARAMETER StringInfoIn->FontInfoMask is an invalid combination.
@retval EFI_OUT_OF_RESOURCES There were insufficient resources to complete the
request.
@@ -2252,7 +2351,7 @@ EFIAPI HiiGetFontInfo (
IN CONST EFI_HII_FONT_PROTOCOL *This,
IN OUT EFI_FONT_HANDLE *FontHandle,
- IN CONST EFI_FONT_DISPLAY_INFO *StringInfoIn,
+ IN CONST EFI_FONT_DISPLAY_INFO *StringInfoIn, OPTIONAL
OUT EFI_FONT_DISPLAY_INFO **StringInfoOut,
IN CONST EFI_STRING String OPTIONAL
)
@@ -2267,51 +2366,71 @@ HiiGetFontInfo ( EFI_STRING StringIn;
EFI_FONT_HANDLE LocalFontHandle;
- if (This == NULL || StringInfoIn == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Check the font information mask to make sure it is valid.
- //
- if (((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_ANY_FONT)) ==
- (EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_ANY_FONT)) ||
- ((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_ANY_SIZE)) ==
- (EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_ANY_SIZE)) ||
- ((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_SYS_STYLE | EFI_FONT_INFO_ANY_STYLE)) ==
- (EFI_FONT_INFO_SYS_STYLE | EFI_FONT_INFO_ANY_STYLE)) ||
- ((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_RESIZE | EFI_FONT_INFO_ANY_SIZE)) ==
- (EFI_FONT_INFO_RESIZE | EFI_FONT_INFO_ANY_SIZE)) ||
- ((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_RESTYLE | EFI_FONT_INFO_ANY_STYLE)) ==
- (EFI_FONT_INFO_RESTYLE | EFI_FONT_INFO_ANY_STYLE))) {
+ if (This == NULL) {
return EFI_INVALID_PARAMETER;
}
FontInfo = NULL;
+ SystemDefault = NULL;
LocalFontHandle = NULL;
if (FontHandle != NULL) {
LocalFontHandle = *FontHandle;
}
+ Private = HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This);
+
+ //
+ // Already searched to the end of the whole list, return directly.
+ //
+ if (LocalFontHandle == &Private->FontInfoList) {
+ LocalFontHandle = NULL;
+ Status = EFI_NOT_FOUND;
+ goto Exit;
+ }
+
//
// Get default system display info, if StringInfoIn points to
// system display info, return it directly.
//
- Private = HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS (This);
-
if (IsSystemFontInfo (Private, (EFI_FONT_DISPLAY_INFO *) StringInfoIn, &SystemDefault, &StringInfoOutLen)) {
- if (StringInfoOut != NULL) {
- *StringInfoOut = AllocateCopyPool (StringInfoOutLen, (EFI_FONT_DISPLAY_INFO *) StringInfoIn);
- if (*StringInfoOut == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- LocalFontHandle = NULL;
- goto Exit;
+ //
+ // System font is the first node. When handle is not NULL, system font can not
+ // be found any more.
+ //
+ if (LocalFontHandle == NULL) {
+ if (StringInfoOut != NULL) {
+ *StringInfoOut = AllocateCopyPool (StringInfoOutLen, SystemDefault);
+ if (*StringInfoOut == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ LocalFontHandle = NULL;
+ goto Exit;
+ }
}
+
+ LocalFontHandle = Private->FontInfoList.ForwardLink;
+ Status = EFI_SUCCESS;
+ goto Exit;
+ } else {
+ LocalFontHandle = NULL;
+ Status = EFI_NOT_FOUND;
+ goto Exit;
}
+ }
- LocalFontHandle = Private->FontInfoList.ForwardLink;
- Status = EFI_SUCCESS;
- goto Exit;
+ //
+ // Check the font information mask to make sure it is valid.
+ //
+ if (((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_ANY_FONT)) ==
+ (EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_ANY_FONT)) ||
+ ((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_ANY_SIZE)) ==
+ (EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_ANY_SIZE)) ||
+ ((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_SYS_STYLE | EFI_FONT_INFO_ANY_STYLE)) ==
+ (EFI_FONT_INFO_SYS_STYLE | EFI_FONT_INFO_ANY_STYLE)) ||
+ ((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_RESIZE | EFI_FONT_INFO_ANY_SIZE)) ==
+ (EFI_FONT_INFO_RESIZE | EFI_FONT_INFO_ANY_SIZE)) ||
+ ((StringInfoIn->FontInfoMask & (EFI_FONT_INFO_RESTYLE | EFI_FONT_INFO_ANY_STYLE)) ==
+ (EFI_FONT_INFO_RESTYLE | EFI_FONT_INFO_ANY_STYLE))) {
+ return EFI_INVALID_PARAMETER;
}
//
@@ -2331,13 +2450,17 @@ HiiGetFontInfo ( if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_SIZE) == EFI_FONT_INFO_SYS_SIZE) {
InfoOut.FontInfo.FontSize = SystemDefault->FontInfo.FontSize;
- } else if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_STYLE) == EFI_FONT_INFO_SYS_STYLE) {
+ }
+ if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_STYLE) == EFI_FONT_INFO_SYS_STYLE) {
InfoOut.FontInfo.FontStyle = SystemDefault->FontInfo.FontStyle;
- } else if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_FORE_COLOR) == EFI_FONT_INFO_SYS_FORE_COLOR) {
+ }
+ if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_FORE_COLOR) == EFI_FONT_INFO_SYS_FORE_COLOR) {
InfoOut.ForegroundColor = SystemDefault->ForegroundColor;
- } else if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_BACK_COLOR) == EFI_FONT_INFO_SYS_BACK_COLOR) {
+ }
+ if ((StringInfoIn->FontInfoMask & EFI_FONT_INFO_SYS_BACK_COLOR) == EFI_FONT_INFO_SYS_BACK_COLOR) {
InfoOut.BackgroundColor = SystemDefault->BackgroundColor;
}
+
FontInfo->FontSize = InfoOut.FontInfo.FontSize;
FontInfo->FontStyle = InfoOut.FontInfo.FontStyle;
@@ -2393,3 +2516,4 @@ Exit: return Status;
}
+
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h index f19813298e..bbd366edec 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h @@ -1,6 +1,6 @@ /** @file
-Copyright (c) 2007, Intel Corporation
+Copyright (c) 2007 - 2008, Intel Corporation
All rights reserved. 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
@@ -47,6 +47,8 @@ Revision History #include <Library/BaseLib.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
+#include <Library/IfrSupportLib.h>
+#include <Library/HiiLib.h>
#define HII_DATABASE_NOTIFY_GUID \
{ \
@@ -495,7 +497,8 @@ FindGlyphBlock ( @retval EFI_SUCCESS The string was successfully rendered.
@retval EFI_OUT_OF_RESOURCES Unable to allocate an output buffer for
RowInfoArray or Blt.
- @retval EFI_INVALID_PARAMETER The String was NULL.
+ @retval EFI_INVALID_PARAMETER The String or Blt.
+ @retval EFI_INVALID_PARAMETER Flags were invalid combination..
**/
EFI_STATUS
@@ -567,7 +570,10 @@ HiiStringToImage ( @retval EFI_SUCCESS The string was successfully rendered.
@retval EFI_OUT_OF_RESOURCES Unable to allocate an output buffer for
RowInfoArray or Blt.
- @retval EFI_INVALID_PARAMETER The String was NULL.
+ @retval EFI_INVALID_PARAMETER The Blt or PackageList was NULL.
+ @retval EFI_INVALID_PARAMETER Flags were invalid combination.
+ @retval EFI_NOT_FOUND The specified PackageList is not in the Database or the stringid is not
+ in the specified PackageList.
**/
EFI_STATUS
@@ -616,7 +622,7 @@ EFIAPI HiiGetGlyph (
IN CONST EFI_HII_FONT_PROTOCOL *This,
IN CHAR16 Char,
- IN CONST EFI_FONT_DISPLAY_INFO *StringInfo,
+ IN CONST EFI_FONT_DISPLAY_INFO *StringInfo, OPTIONAL
OUT EFI_IMAGE_OUTPUT **Blt,
OUT UINTN *Baseline OPTIONAL
)
@@ -635,7 +641,8 @@ HiiGetGlyph ( returned font handle or points to NULL if there
are no more matching fonts.
@param StringInfoIn Upon entry, points to the font to return
- information about.
+ information about. If NULL, then the information about the system default
+ font will be returned.
@param StringInfoOut Upon return, contains the matching font's
information. If NULL, then no information is
returned. It's caller's responsibility to free
@@ -647,9 +654,9 @@ HiiGetGlyph ( @retval EFI_SUCCESS Matching font returned successfully.
@retval EFI_NOT_FOUND No matching font was found.
@retval EFI_INVALID_PARAMETER StringInfoIn is NULL.
+ @retval EFI_INVALID_PARAMETER StringInfoIn->FontInfoMask is an invalid combination.
@retval EFI_OUT_OF_RESOURCES There were insufficient resources to complete the
request.
-
**/
EFI_STATUS
EFIAPI
@@ -706,15 +713,15 @@ HiiNewImage ( @param ImageId The image's id,, which is unique within
PackageList.
@param Image Points to the image.
- @param ImageSize On entry, points to the size of the buffer
- pointed to by Image, in bytes. On return, points
- to the length of the image, in bytes.
@retval EFI_SUCCESS The new image was returned successfully.
@retval EFI_NOT_FOUND The image specified by ImageId is not available.
+ The specified PackageList is not in the database.
@retval EFI_BUFFER_TOO_SMALL The buffer specified by ImageSize is too small to
hold the image.
@retval EFI_INVALID_PARAMETER The Image or ImageSize was NULL.
+ @retval EFI_OUT_OF_RESOURCES The bitmap could not be retrieved because there was not
+ enough memory.
**/
EFI_STATUS
@@ -723,8 +730,7 @@ HiiGetImage ( IN CONST EFI_HII_IMAGE_PROTOCOL *This,
IN EFI_HII_HANDLE PackageList,
IN EFI_IMAGE_ID ImageId,
- OUT EFI_IMAGE_INPUT *Image,
- OUT UINTN *ImageSize
+ OUT EFI_IMAGE_INPUT *Image
)
;
@@ -741,7 +747,7 @@ HiiGetImage ( @retval EFI_SUCCESS The new image was updated successfully.
@retval EFI_NOT_FOUND The image specified by ImageId is not in the
- database.
+ database. The specified PackageList is not in the database.
@retval EFI_INVALID_PARAMETER The Image was NULL.
**/
@@ -821,9 +827,9 @@ HiiDrawImage ( @retval EFI_SUCCESS The image was successfully drawn.
@retval EFI_OUT_OF_RESOURCES Unable to allocate an output buffer for Blt.
- @retval EFI_INVALID_PARAMETER The Image was NULL.
- @retval EFI_NOT_FOUND The specified packagelist could not be found in
- current database.
+ @retval EFI_INVALID_PARAMETER The Blt was NULL.
+ @retval EFI_NOT_FOUND The image specified by ImageId is not in the database.
+ The specified PackageList is not in the database.
**/
EFI_STATUS
@@ -914,7 +920,9 @@ HiiNewString ( @retval EFI_NOT_FOUND The string specified by StringId is not
available.
@retval EFI_NOT_FOUND The string specified by StringId is available but
- not in the specified language.
+ not in the specified language.
+ The specified PackageList is not in the database.
+ @retval EFI_INVALID_LANGUAGE - The string specified by StringId is available but
@retval EFI_BUFFER_TOO_SMALL The buffer specified by StringSize is too small
to hold the string.
@retval EFI_INVALID_PARAMETER The String or Language or StringSize was NULL.
@@ -1029,8 +1037,9 @@ HiiGetLanguages ( too small to hold the returned information.
SecondLanguageSize is updated to hold the size of
the buffer required.
- @retval EFI_NOT_FOUND The language specified by FirstLanguage is not
+ @retval EFI_INVALID_LANGUAGE The language specified by FirstLanguage is not
present in the specified package list.
+ @retval EFI_NOT_FOUND The specified PackageList is not in the Database.
**/
EFI_STATUS
@@ -1091,9 +1100,7 @@ HiiNewPackageList ( @retval EFI_SUCCESS The data associated with the Handle was removed
from the HII database.
- @retval EFI_NOT_FOUND The specified PackageList could not be found in
- database.
- @retval EFI_INVALID_PARAMETER The Handle was not valid.
+ @retval EFI_NOT_FOUND The specified Handle is not in database.
**/
EFI_STATUS
@@ -1119,9 +1126,8 @@ HiiRemovePackageList ( @retval EFI_SUCCESS The HII database was successfully updated.
@retval EFI_OUT_OF_RESOURCES Unable to allocate enough memory for the updated
database.
- @retval EFI_INVALID_PARAMETER Handle or PackageList was NULL.
- @retval EFI_NOT_FOUND The Handle was not valid or could not be found in
- database.
+ @retval EFI_INVALID_PARAMETER PackageList was NULL.
+ @retval EFI_NOT_FOUND The specified Handle is not in database.
**/
EFI_STATUS
@@ -1154,6 +1160,7 @@ HiiUpdatePackageList ( @param Handle An array of EFI_HII_HANDLE instances returned.
@retval EFI_SUCCESS The matching handles are outputed successfully.
+ HandleBufferLength is updated with the actual length.
@retval EFI_BUFFER_TO_SMALL The HandleBufferLength parameter indicates that
Handle is too small to support the number of
handles. HandleBufferLength is updated with a
@@ -1161,6 +1168,10 @@ HiiUpdatePackageList ( @retval EFI_NOT_FOUND No matching handle could not be found in
database.
@retval EFI_INVALID_PARAMETER Handle or HandleBufferLength was NULL.
+ @retval EFI_INVALID_PARAMETER PackageType is not a EFI_HII_PACKAGE_TYPE_GUID but
+ PackageGuid is not NULL, PackageType is a EFI_HII_
+ PACKAGE_TYPE_GUID but PackageGuid is NULL.
+
**/
EFI_STATUS
@@ -1271,7 +1282,8 @@ HiiRegisterPackageNotify ( unregistered.
@retval EFI_SUCCESS Notification is unregistered successfully.
- @retval EFI_INVALID_PARAMETER The Handle is invalid.
+ @retval EFI_NOT_FOUND The incoming notification handle does not exist
+ in current hii database.
**/
EFI_STATUS
@@ -1511,7 +1523,7 @@ HiiConfigRoutingExportConfig ( **/
EFI_STATUS
EFIAPI
-HiiConfigRoutingRoutConfig (
+HiiConfigRoutingRouteConfig (
IN CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *This,
IN CONST EFI_STRING Configuration,
OUT EFI_STRING *Progress
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf index 2bafb25b18..5bdc604700 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf @@ -57,7 +57,8 @@ UefiDriverEntryPoint
BaseMemoryLib
DebugLib
-
+ IfrSupportLib
+ HiiLib
[Protocols]
gEfiConsoleControlProtocolGuid
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c index 6583f6b654..4bba8af1b1 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c @@ -1,6 +1,6 @@ /** @file
-Copyright (c) 2007, Intel Corporation
+Copyright (c) 2007 - 2008, Intel Corporation
All rights reserved. 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
@@ -80,7 +80,7 @@ STATIC HII_DATABASE_PRIVATE_DATA mPrivate = { {
HiiConfigRoutingExtractConfig,
HiiConfigRoutingExportConfig,
- HiiConfigRoutingRoutConfig,
+ HiiConfigRoutingRouteConfig,
HiiBlockToConfig,
HiiConfigToBlock,
HiiGetAltCfg
@@ -104,6 +104,17 @@ STATIC HII_DATABASE_PRIVATE_DATA mPrivate = { NULL
};
+STATIC
+VOID
+EFIAPI
+KeyboardLayoutChangeNullEvent (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ return;
+}
+
EFI_STATUS
EFIAPI
InitializeHiiDatabase (
@@ -161,9 +172,9 @@ Returns: // Create a event with EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID group type.
//
Status = gBS->CreateEventEx (
- 0,
- 0,
- NULL,
+ EFI_EVENT_NOTIFY_SIGNAL,
+ TPL_NOTIFY,
+ KeyboardLayoutChangeNullEvent,
NULL,
&gHiiSetKbdLayoutEventGuid,
&gHiiKeyboardLayoutChanged
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c index 341a50a7e8..6b6a72002d 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c @@ -1,6 +1,6 @@ /** @file
-Copyright (c) 2007, Intel Corporation
+Copyright (c) 2007 - 2008, Intel Corporation
All rights reserved. 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
@@ -610,7 +610,7 @@ HiiNewImage ( UINTN NewBlockSize;
EFI_IMAGE_INPUT *ImageIn;
- if (This == NULL || ImageId == NULL || Image == NULL || PackageList == NULL) {
+ if (This == NULL || ImageId == NULL || Image == NULL || Image->Bitmap == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -798,10 +798,13 @@ HiiNewImage ( length of the image, in bytes.
@retval EFI_SUCCESS The new image was returned successfully.
- @retval EFI_NOT_FOUND The image specified by ImageId is not available.
+ @retval EFI_NOT_FOUND The image specified by ImageId is not in the
+ database. The specified PackageList is not in the database.
@retval EFI_BUFFER_TOO_SMALL The buffer specified by ImageSize is too small to
hold the image.
@retval EFI_INVALID_PARAMETER The Image or ImageSize was NULL.
+ @retval EFI_OUT_OF_RESOURCES The bitmap could not be retrieved because there was not
+ enough memory.
**/
EFI_STATUS
@@ -810,8 +813,7 @@ HiiGetImage ( IN CONST EFI_HII_IMAGE_PROTOCOL *This,
IN EFI_HII_HANDLE PackageList,
IN EFI_IMAGE_ID ImageId,
- OUT EFI_IMAGE_INPUT *Image,
- OUT UINTN *ImageSize
+ OUT EFI_IMAGE_INPUT *Image
)
{
HII_DATABASE_PRIVATE_DATA *Private;
@@ -831,7 +833,7 @@ HiiGetImage ( UINT8 PaletteIndex;
UINT16 PaletteSize;
- if (This == NULL || ImageSize == NULL || Image == NULL || ImageId < 1 || PackageList == NULL) {
+ if (This == NULL || Image == NULL || ImageId < 1) {
return EFI_INVALID_PARAMETER;
}
@@ -897,13 +899,12 @@ HiiGetImage ( // Use the common block code since the definition of these structures is the same.
//
CopyMem (&Iibt1bit, ImageBlock, sizeof (EFI_HII_IIBT_IMAGE_1BIT_BLOCK));
- ImageLength = sizeof (EFI_IMAGE_INPUT) + sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) *
- (Iibt1bit.Bitmap.Width * Iibt1bit.Bitmap.Height - 1);
- if (*ImageSize < ImageLength) {
- *ImageSize = ImageLength;
- return EFI_BUFFER_TOO_SMALL;
+ ImageLength = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) *
+ (Iibt1bit.Bitmap.Width * Iibt1bit.Bitmap.Height);
+ Image->Bitmap = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) AllocateZeroPool (ImageLength);
+ if (Image->Bitmap == NULL) {
+ return EFI_OUT_OF_RESOURCES;
}
- ZeroMem (Image, ImageLength);
if (Flag) {
Image->Flags = EFI_IMAGE_TRANSPARENT;
@@ -956,13 +957,11 @@ HiiGetImage ( ImageBlock + sizeof (EFI_HII_IMAGE_BLOCK) + sizeof (UINT16),
sizeof (UINT16)
);
- ImageLength = sizeof (EFI_IMAGE_INPUT) +
- sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * (Width * Height - 1);
- if (*ImageSize < ImageLength) {
- *ImageSize = ImageLength;
- return EFI_BUFFER_TOO_SMALL;
+ ImageLength = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * (Width * Height);
+ Image->Bitmap = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) AllocateZeroPool (ImageLength);
+ if (Image->Bitmap == NULL) {
+ return EFI_OUT_OF_RESOURCES;
}
- ZeroMem (Image, ImageLength);
if (Flag) {
Image->Flags = EFI_IMAGE_TRANSPARENT;
@@ -999,7 +998,7 @@ HiiGetImage ( @retval EFI_SUCCESS The new image was updated successfully.
@retval EFI_NOT_FOUND The image specified by ImageId is not in the
- database.
+ database. The specified PackageList is not in the database.
@retval EFI_INVALID_PARAMETER The Image was NULL.
**/
@@ -1036,7 +1035,7 @@ HiiSetImage ( UINT32 Part1Size;
UINT32 Part2Size;
- if (This == NULL || Image == NULL || ImageId < 1 || PackageList == NULL) {
+ if (This == NULL || Image == NULL || ImageId < 1 || Image->Bitmap == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -1448,9 +1447,9 @@ HiiDrawImage ( @retval EFI_SUCCESS The image was successfully drawn.
@retval EFI_OUT_OF_RESOURCES Unable to allocate an output buffer for Blt.
- @retval EFI_INVALID_PARAMETER The Image was NULL.
- @retval EFI_NOT_FOUND The specified packagelist could not be found in
- current database.
+ @retval EFI_INVALID_PARAMETER The Blt was NULL.
+ @retval EFI_NOT_FOUND The image specified by ImageId is not in the database.
+ The specified PackageList is not in the database.
**/
EFI_STATUS
@@ -1466,14 +1465,12 @@ HiiDrawImageId ( )
{
EFI_STATUS Status;
- EFI_IMAGE_INPUT ImageTemp;
- EFI_IMAGE_INPUT *Image;
- UINTN ImageSize;
+ EFI_IMAGE_INPUT Image;
//
// Check input parameter.
//
- if (This == NULL || PackageList == NULL || Blt == NULL || PackageList == NULL) {
+ if (This == NULL || Blt == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -1484,24 +1481,16 @@ HiiDrawImageId ( //
// Get the specified Image.
//
- ImageSize = 0;
- Status = HiiGetImage (This, PackageList, ImageId, &ImageTemp, &ImageSize);
- if (Status != EFI_BUFFER_TOO_SMALL) {
+ Status = HiiGetImage (This, PackageList, ImageId, &Image);
+ if (EFI_ERROR (Status)) {
return Status;
}
- Image = (EFI_IMAGE_INPUT *) AllocateZeroPool (ImageSize);
- if (Image == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- Status = HiiGetImage (This, PackageList, ImageId, Image, &ImageSize);
- ASSERT_EFI_ERROR (Status);
-
//
// Draw this image.
//
- Status = HiiDrawImage (This, Flags, Image, Blt, BltX, BltY);
- SafeFreePool (Image);
+ Status = HiiDrawImage (This, Flags, &Image, Blt, BltX, BltY);
+ SafeFreePool (Image.Bitmap);
return Status;
}
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/String.c b/MdeModulePkg/Universal/HiiDatabaseDxe/String.c index 0d830106cd..f6a4cdf02d 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/String.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/String.c @@ -40,6 +40,7 @@ CHAR16 mLanguageWindow[16] = { @param Private Hii database private structure.
@param StringPackage HII string package instance.
+ @param FontId Font identifer, which must be unique within the string package.
@param DuplicateEnable If true, duplicate HII_FONT_INFO which refers to
the same EFI_FONT_INFO is permitted. Otherwise it
is not allowed.
@@ -57,6 +58,7 @@ BOOLEAN ReferFontInfoLocally (
IN HII_DATABASE_PRIVATE_DATA *Private,
IN HII_STRING_PACKAGE_INSTANCE *StringPackage,
+ IN UINT8 FontId,
IN BOOLEAN DuplicateEnable,
IN HII_GLOBAL_FONT_INFO *GlobalFontInfo,
OUT HII_FONT_INFO **LocalFontInfo
@@ -82,11 +84,6 @@ ReferFontInfoLocally ( }
}
}
- //
- // Since string package tool set FontId initially to 0 and increases it
- // progressively by one, StringPackage->FondId always represents an unique
- // and available FontId.
- //
// FontId identifies EFI_FONT_INFO in local string package uniquely.
// GlobalEntry points to a HII_GLOBAL_FONT_INFO which identifies
// EFI_FONT_INFO uniquely in whole hii database.
@@ -95,12 +92,10 @@ ReferFontInfoLocally ( ASSERT (LocalFont != NULL);
LocalFont->Signature = HII_FONT_INFO_SIGNATURE;
- LocalFont->FontId = StringPackage->FontId;
+ LocalFont->FontId = FontId;
LocalFont->GlobalEntry = &GlobalFontInfo->Entry;
InsertTailList (&StringPackage->FontInfoList, &LocalFont->Entry);
- StringPackage->FontId++;
-
*LocalFontInfo = LocalFont;
return FALSE;
}
@@ -183,13 +178,12 @@ GetUnicodeStringTextOrSize ( StringPtr += sizeof (CHAR16);
}
+ if (*BufferSize < StringSize) {
+ *BufferSize = StringSize;
+ return EFI_BUFFER_TOO_SMALL;
+ }
if (StringDest != NULL) {
- if (*BufferSize < StringSize) {
- *BufferSize = StringSize;
- return EFI_BUFFER_TOO_SMALL;
- }
CopyMem (StringDest, StringSrc, StringSize);
- return EFI_SUCCESS;
}
*BufferSize = StringSize;
@@ -292,6 +286,7 @@ FindStringBlock ( UINT16 FontSize;
UINT8 Length8;
EFI_HII_SIBT_EXT2_BLOCK Ext2;
+ UINT8 FontId;
UINT32 Length32;
UINTN StringSize;
CHAR16 Zero;
@@ -486,7 +481,9 @@ FindStringBlock ( // Find the relationship between global font info and the font info of
// this EFI_HII_SIBT_FONT block then backup its information in local package.
//
- BlockHdr += sizeof (EFI_HII_SIBT_EXT2_BLOCK) + sizeof (UINT8);
+ BlockHdr += sizeof (EFI_HII_SIBT_EXT2_BLOCK);
+ CopyMem (&FontId, BlockHdr, sizeof (UINT8));
+ BlockHdr += sizeof (UINT8);
CopyMem (&FontSize, BlockHdr, sizeof (UINT16));
BlockHdr += sizeof (UINT16);
CopyMem (&FontStyle, BlockHdr, sizeof (EFI_HII_FONT_STYLE));
@@ -502,16 +499,21 @@ FindStringBlock ( FontInfo->FontSize = FontSize;
CopyMem (FontInfo->FontName, BlockHdr, StringSize);
+ //
+ // If find the corresponding global font info, save the relationship.
+ // Otherwise ignore this EFI_HII_SIBT_FONT block.
+ //
if (IsFontInfoExisted (Private, FontInfo, NULL, NULL, &GlobalFont)) {
- //
- // If find the corresponding global font info, save the relationship.
- //
- ReferFontInfoLocally (Private, StringPackage, TRUE, GlobalFont, &LocalFont);
+ ReferFontInfoLocally (Private, StringPackage, FontId, TRUE, GlobalFont, &LocalFont);
}
//
- // If can not find, ignore this EFI_HII_SIBT_FONT block.
- //
+ // Since string package tool set FontId initially to 0 and increases it
+ // progressively by one, StringPackage->FondId always represents an unique
+ // and available FontId.
+ //
+ StringPackage->FontId++;
+
SafeFreePool (FontInfo);
}
@@ -647,7 +649,8 @@ GetStringWorker ( }
//
- // Get the string font.
+ // Get the string font. The FontId 0 is the default font for those string blocks which
+ // do not specify a font identifier. If default font is not specified, return NULL.
//
if (StringFontInfo != NULL) {
switch (BlockType) {
@@ -656,10 +659,13 @@ GetStringWorker ( case EFI_HII_SIBT_STRING_UCS2_FONT:
case EFI_HII_SIBT_STRINGS_UCS2_FONT:
FontId = *(StringBlockAddr + sizeof (EFI_HII_STRING_BLOCK));
- return GetStringFontInfo (StringPackage, FontId, StringFontInfo);
break;
default:
- break;
+ FontId = 0;
+ }
+ Status = GetStringFontInfo (StringPackage, FontId, StringFontInfo);
+ if (Status == EFI_NOT_FOUND) {
+ *StringFontInfo = NULL;
}
}
@@ -737,38 +743,48 @@ SetStringWorker ( Referred = FALSE;
//
- // Set the string font according to input font information.
+ // The input StringFontInfo should exist in current database if specified.
//
if (StringFontInfo != NULL) {
- //
- // The input StringFontInfo should exist in current database
- //
if (!IsFontInfoExisted (Private, StringFontInfo, NULL, NULL, &GlobalFont)) {
return EFI_INVALID_PARAMETER;
} else {
- Referred = ReferFontInfoLocally (Private, StringPackage, FALSE, GlobalFont, &LocalFont);
+ Referred = ReferFontInfoLocally (
+ Private,
+ StringPackage,
+ StringPackage->FontId,
+ FALSE,
+ GlobalFont,
+ &LocalFont
+ );
+ if (!Referred) {
+ StringPackage->FontId++;
+ }
}
-
//
- // Update the FontId of the specified string block
+ // Update the FontId of the specified string block to input font info.
//
switch (BlockType) {
- case EFI_HII_SIBT_STRING_SCSU_FONT:
+ case EFI_HII_SIBT_STRING_SCSU_FONT:
case EFI_HII_SIBT_STRINGS_SCSU_FONT:
case EFI_HII_SIBT_STRING_UCS2_FONT:
case EFI_HII_SIBT_STRINGS_UCS2_FONT:
*(StringBlockAddr + sizeof (EFI_HII_STRING_BLOCK)) = LocalFont->FontId;
break;
default:
- return EFI_NOT_FOUND;
+ //
+ // When modify the font info of these blocks, the block type should be updated
+ // to contain font info thus the whole structure should be revised.
+ // It is recommended to use tool to modify the block type not in the code.
+ //
+ return EFI_UNSUPPORTED;
}
-
}
OldBlockSize = StringPackage->StringPkgHdr->Header.Length - StringPackage->StringPkgHdr->HdrSize;
//
- // Set the string text.
+ // Set the string text and font.
//
StringTextPtr = StringBlockAddr + StringTextOffset;
switch (BlockType) {
@@ -1138,7 +1154,7 @@ HiiNewString ( //
Ucs2FontBlockSize = (UINT32) (StrSize (String) + sizeof (EFI_HII_SIBT_STRING_UCS2_FONT_BLOCK) -
sizeof (CHAR16));
- if (ReferFontInfoLocally (Private, StringPackage, FALSE, GlobalFont, &LocalFont)) {
+ if (ReferFontInfoLocally (Private, StringPackage, StringPackage->FontId, FALSE, GlobalFont, &LocalFont)) {
//
// Create a EFI_HII_SIBT_STRING_UCS2_FONT block only.
//
@@ -1229,6 +1245,12 @@ HiiNewString ( StringPackage->StringBlock = StringBlock;
StringPackage->StringPkgHdr->Header.Length += FontBlockSize + Ucs2FontBlockSize;
PackageListNode->PackageListHdr.PackageLength += FontBlockSize + Ucs2FontBlockSize;
+
+ //
+ // Increase the FontId to make it unique since we already add
+ // a EFI_HII_SIBT_FONT block to this string package.
+ //
+ StringPackage->FontId++;
}
}
@@ -1258,7 +1280,9 @@ HiiNewString ( @retval EFI_SUCCESS The string was returned successfully.
@retval EFI_NOT_FOUND The string specified by StringId is not available.
@retval EFI_NOT_FOUND The string specified by StringId is available but
- not in the specified language.
+ not in the specified language.
+ The specified PackageList is not in the database.
+ @retval EFI_INVALID_LANGUAGE - The string specified by StringId is available but
@retval EFI_BUFFER_TOO_SMALL The buffer specified by StringSize is too small to
hold the string.
@retval EFI_INVALID_PARAMETER The String or Language or StringSize was NULL.
@@ -1309,18 +1333,34 @@ HiiGetString ( }
if (PackageListNode != NULL) {
+ //
+ // First search: to match the StringId in the specified language.
+ //
for (Link = PackageListNode->StringPkgHdr.ForwardLink;
Link != &PackageListNode->StringPkgHdr;
Link = Link->ForwardLink
) {
- StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);
- if (R8_EfiLibCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) Language)) {
- Status = GetStringWorker (Private, StringPackage, StringId, String, StringSize, StringFontInfo);
- if (Status != EFI_NOT_FOUND) {
- return Status;
+ StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);
+ if (R8_EfiLibCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) Language)) {
+ Status = GetStringWorker (Private, StringPackage, StringId, String, StringSize, StringFontInfo);
+ if (Status != EFI_NOT_FOUND) {
+ return Status;
+ }
}
}
- }
+ //
+ // Second search: to match the StringId in other available languages if exist.
+ //
+ for (Link = PackageListNode->StringPkgHdr.ForwardLink;
+ Link != &PackageListNode->StringPkgHdr;
+ Link = Link->ForwardLink
+ ) {
+ StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);
+ Status = GetStringWorker (Private, StringPackage, StringId, String, StringSize, StringFontInfo);
+ if (!EFI_ERROR (Status)) {
+ return EFI_INVALID_LANGUAGE;
+ }
+ }
}
return EFI_NOT_FOUND;
@@ -1528,8 +1568,9 @@ HiiGetLanguages ( too small to hold the returned information.
SecondLanguageSize is updated to hold the size of
the buffer required.
- @retval EFI_NOT_FOUND The language specified by FirstLanguage is not
- present in the specified package list.
+ @retval EFI_INVALID_LANGUAGE The language specified by FirstLanguage is not
+ present in the specified package list.
+ @retval EFI_NOT_FOUND The specified PackageList is not in the Database.
**/
EFI_STATUS
@@ -1562,45 +1603,51 @@ HiiGetSecondaryLanguages ( }
Private = HII_STRING_DATABASE_PRIVATE_DATA_FROM_THIS (This);
- Languages = NULL;
- ResultSize = 0;
+ PackageListNode = NULL;
for (Link = Private->DatabaseList.ForwardLink; Link != &Private->DatabaseList; Link = Link->ForwardLink) {
DatabaseRecord = CR (Link, HII_DATABASE_RECORD, DatabaseEntry, HII_DATABASE_RECORD_SIGNATURE);
if (DatabaseRecord->Handle == PackageList) {
PackageListNode = (HII_DATABASE_PACKAGE_LIST_INSTANCE *) (DatabaseRecord->PackageList);
- for (Link1 = PackageListNode->StringPkgHdr.ForwardLink;
- Link1 != &PackageListNode->StringPkgHdr;
- Link1 = Link1->ForwardLink
- ) {
- StringPackage = CR (Link1, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);
- if (R8_EfiLibCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) FirstLanguage)) {
- Languages = StringPackage->StringPkgHdr->Language;
- //
- // Language is a series of ';' terminated strings, first one is primary
- // language and following with other secondary languages or NULL if no
- // secondary languages any more.
- //
- Languages = AsciiStrStr (Languages, ";");
- if (Languages == NULL) {
- break;
- }
- Languages++;
-
- ResultSize = AsciiStrSize (Languages);
- if (ResultSize <= *SecondLanguagesSize) {
- AsciiStrCpy (SecondLanguages, Languages);
- } else {
- *SecondLanguagesSize = ResultSize;
- return EFI_BUFFER_TOO_SMALL;
- }
+ break;
+ }
+ }
+ if (PackageListNode == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ Languages = NULL;
+ ResultSize = 0;
+ for (Link1 = PackageListNode->StringPkgHdr.ForwardLink;
+ Link1 != &PackageListNode->StringPkgHdr;
+ Link1 = Link1->ForwardLink
+ ) {
+ StringPackage = CR (Link1, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);
+ if (R8_EfiLibCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) FirstLanguage)) {
+ Languages = StringPackage->StringPkgHdr->Language;
+ //
+ // Language is a series of ';' terminated strings, first one is primary
+ // language and following with other secondary languages or NULL if no
+ // secondary languages any more.
+ //
+ Languages = AsciiStrStr (Languages, ";");
+ if (Languages == NULL) {
+ break;
+ }
+ Languages++;
- return EFI_SUCCESS;
- }
+ ResultSize = AsciiStrSize (Languages);
+ if (ResultSize <= *SecondLanguagesSize) {
+ AsciiStrCpy (SecondLanguages, Languages);
+ } else {
+ *SecondLanguagesSize = ResultSize;
+ return EFI_BUFFER_TOO_SMALL;
}
+
+ return EFI_SUCCESS;
}
}
- return EFI_NOT_FOUND;
+ return EFI_INVALID_LANGUAGE;
}
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c index c813081454..9108acb473 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c @@ -1,5 +1,5 @@ /** @file -Copyright (c) 2007, Intel Corporation +Copyright (c) 2007 - 2008, Intel Corporation All rights reserved. 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 @@ -1233,11 +1233,11 @@ ParseOpCodes ( // CurrentStatement->Minimum = ((EFI_IFR_STRING *) OpCodeData)->MinSize; CurrentStatement->Maximum = ((EFI_IFR_STRING *) OpCodeData)->MaxSize; - CurrentStatement->StorageWidth = (UINT16)((UINTN) CurrentStatement->Maximum * sizeof (UINT16)); + CurrentStatement->StorageWidth = (UINT16)((UINTN) CurrentStatement->Maximum * sizeof (CHAR16)); CurrentStatement->Flags = ((EFI_IFR_STRING *) OpCodeData)->Flags; CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_STRING; - CurrentStatement->BufferValue = AllocateZeroPool (CurrentStatement->StorageWidth); + CurrentStatement->BufferValue = AllocateZeroPool (CurrentStatement->StorageWidth + sizeof (CHAR16)); InitializeRequestElement (FormSet, CurrentStatement); break; @@ -1252,10 +1252,10 @@ ParseOpCodes ( // CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_PASSWORD *) OpCodeData)->MinSize, sizeof (UINT16)); CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_PASSWORD *) OpCodeData)->MaxSize, sizeof (UINT16)); - CurrentStatement->StorageWidth = (UINT16)((UINTN) CurrentStatement->Maximum * sizeof (UINT16)); + CurrentStatement->StorageWidth = (UINT16)((UINTN) CurrentStatement->Maximum * sizeof (CHAR16)); CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_STRING; - CurrentStatement->BufferValue = AllocateZeroPool (CurrentStatement->StorageWidth); + CurrentStatement->BufferValue = AllocateZeroPool ((CurrentStatement->StorageWidth + sizeof (CHAR16))); InitializeRequestElement (FormSet, CurrentStatement); break; diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c index 820353131f..ff857750ef 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -1,5 +1,5 @@ /** @file -Copyright (c) 2007, Intel Corporation +Copyright (c) 2007 - 2008, Intel Corporation All rights reserved. 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 @@ -1173,7 +1173,11 @@ GetQuestionValue ( } if (IsString) { - StrCpy ((CHAR16 *) Dst, Value); + // + // Convert Config String to Unicode String, e.g "0041004200430044" => "ABCD" + // + Length = StorageWidth + sizeof (CHAR16); + Status = ConfigStringToUnicode ((CHAR16 *) Dst, &Length, Value); } else { Status = HexStringToBuf (Dst, &StorageWidth, Value, NULL); } @@ -1239,7 +1243,11 @@ GetQuestionValue ( // Value = Value + 1; if (!IsBufferStorage && IsString) { - StrCpy ((CHAR16 *) Dst, Value); + // + // Convert Config String to Unicode String, e.g "0041004200430044" => "ABCD" + // + Length = StorageWidth + sizeof (CHAR16); + Status = ConfigStringToUnicode ((CHAR16 *) Dst, &Length, Value); } else { Status = HexStringToBuf (Dst, &StorageWidth, Value, NULL); if (EFI_ERROR (Status)) { @@ -1408,13 +1416,21 @@ SetQuestionValue ( CopyMem (Storage->EditBuffer + Question->VarStoreInfo.VarOffset, Src, StorageWidth); } else { if (IsString) { + // + // Convert Unicode String to Config String, e.g. "ABCD" => "0041004200430044" + // Value = NULL; - NewStringCpy (&Value, (CHAR16 *) Src); - } else { - BufferLen = (StorageWidth * 2 + 1) * sizeof (CHAR16); + BufferLen = ((StrLen ((CHAR16 *) Src) * 4) + 1) * sizeof (CHAR16); Value = AllocateZeroPool (BufferLen); ASSERT (Value != NULL); + Status = UnicodeToConfigString (Value, &BufferLen, (CHAR16 *) Src); + ASSERT_EFI_ERROR (Status); + } else { + BufferLen = StorageWidth * 2 + 1; + Value = AllocateZeroPool (BufferLen * sizeof (CHAR16)); + ASSERT (Value != NULL); BufToHexString (Value, &BufferLen, Src, StorageWidth); + ToLower (Value); } Status = SetValueByName (Storage, Question->VariableName, Value); @@ -1424,7 +1440,7 @@ SetQuestionValue ( if (!Cached) { // // <ConfigResp> ::= <ConfigHdr> + <BlockName> + "&VALUE=" + "<HexCh>StorageWidth * 2" || - // <ConfigHdr> + "&" + <VariableName> + "=" + "<HexCh>StorageWidth * 2" + // <ConfigHdr> + "&" + <VariableName> + "=" + "<string>" // if (IsBufferStorage) { Length = StrLen (Question->BlockName) + 7; @@ -1432,7 +1448,7 @@ SetQuestionValue ( Length = StrLen (Question->VariableName) + 2; } if (!IsBufferStorage && IsString) { - Length += StrLen ((CHAR16 *) Src); + Length += (StrLen ((CHAR16 *) Src) * 4); } else { Length += (StorageWidth * 2); } @@ -1451,10 +1467,16 @@ SetQuestionValue ( Value = ConfigResp + StrLen (ConfigResp); if (!IsBufferStorage && IsString) { - StrCpy (Value, (CHAR16 *) Src); + // + // Convert Unicode String to Config String, e.g. "ABCD" => "0041004200430044" + // + BufferLen = ((StrLen ((CHAR16 *) Src) * 4) + 1) * sizeof (CHAR16); + Status = UnicodeToConfigString (Value, &BufferLen, (CHAR16 *) Src); + ASSERT_EFI_ERROR (Status); } else { - BufferLen = (StorageWidth * 2 + 1) * sizeof (CHAR16); + BufferLen = StorageWidth * 2 + 1; BufToHexString (Value, &BufferLen, Src, StorageWidth); + ToLower (Value); } // diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c index 064a8d9e33..04b9f69303 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c @@ -2299,7 +2299,7 @@ UiDisplayMenu ( Selection->Statement = NULL; break; } - BufferSize = StrLen (StringPtr) / 4; + BufferSize = StrLen (StringPtr) / 2; DevicePath = AllocatePool (BufferSize); HexStringToBuffer ((UINT8 *) DevicePath, &BufferSize, StringPtr); |