From nobody Sun May 5 18:48:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 151660863251567.69042057054173; Mon, 22 Jan 2018 00:10:32 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 440162238B59F; Mon, 22 Jan 2018 00:05:04 -0800 (PST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 0AC2D2238B597 for ; Mon, 22 Jan 2018 00:05:02 -0800 (PST) Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jan 2018 00:10:27 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga008.fm.intel.com with ESMTP; 22 Jan 2018 00:10:27 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,395,1511856000"; d="scan'208";a="12170500" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Mon, 22 Jan 2018 16:10:19 +0800 Message-Id: <20180122081024.283496-2-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180122081024.283496-1-ruiyu.ni@intel.com> References: <20180122081024.283496-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 1/6] MdePkg/SimpleTextInEx.h: Fix comments alignment X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Liming Gao --- MdePkg/Include/Protocol/SimpleTextInEx.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/MdePkg/Include/Protocol/SimpleTextInEx.h b/MdePkg/Include/Prot= ocol/SimpleTextInEx.h index 4591bd4779..ffc11c601e 100644 --- a/MdePkg/Include/Protocol/SimpleTextInEx.h +++ b/MdePkg/Include/Protocol/SimpleTextInEx.h @@ -5,7 +5,7 @@ which exposes much more state and modifier information from the input de= vice, also allows one to register a notification for a particular keystroke. =20 - Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -190,13 +190,10 @@ typedef struct { pressed. =20 =20 - @retval EFI_SUCCESS The keystroke information was - returned. - - @retval EFI_NOT_READY There was no keystroke data available. - EFI_DEVICE_ERROR The keystroke - information was not returned due to - hardware errors. + @retval EFI_SUCCESS The keystroke information was returned. + @retval EFI_NOT_READY There was no keystroke data available. + @retval EFI_DEVICE_ERROR The keystroke information was not returned due = to + hardware errors. =20 =20 **/ --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun May 5 18:48:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1516608635016245.03027958450207; Mon, 22 Jan 2018 00:10:35 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9B9602238B5A7; Mon, 22 Jan 2018 00:05:06 -0800 (PST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D044E2232BE18 for ; Mon, 22 Jan 2018 00:05:02 -0800 (PST) Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jan 2018 00:10:28 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga008.fm.intel.com with ESMTP; 22 Jan 2018 00:10:27 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,395,1511856000"; d="scan'208";a="12170503" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Mon, 22 Jan 2018 16:10:20 +0800 Message-Id: <20180122081024.283496-3-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180122081024.283496-1-ruiyu.ni@intel.com> References: <20180122081024.283496-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 2/6] MdeModulePkg/ConSplitter: ReadKeyStrokeEx always return key state X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Today's implementation only return key state when there is key. But when user doesn't press any key, the key state cannot be returned. The patch changes the ReadKeyStrokeEx() to always return the key state even there is no key pressed. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng Cc: Michael D Kinney --- .../Universal/Console/ConSplitterDxe/ConSplitter.c | 164 +++++++++++++++++= +--- .../Universal/Console/ConSplitterDxe/ConSplitter.h | 4 +- 2 files changed, 143 insertions(+), 25 deletions(-) diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c b/= MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c index e70ff6114a..022fca7cbb 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c @@ -16,7 +16,7 @@ never removed. Such design ensures sytem function well during none conso= le device situation. =20 -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
(C) Copyright 2016 Hewlett Packard Enterprise Development LP
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License @@ -67,6 +67,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED TEXT_IN_SPLITTER_PRIVATE_DA= TA mConIn =3D { (LIST_ENTRY *) NULL, (LIST_ENTRY *) NULL }, + (EFI_KEY_DATA *) NULL, + 0, 0, FALSE, =20 @@ -606,6 +608,7 @@ ConSplitterTextInConstructor ( ) { EFI_STATUS Status; + UINTN TextInExListCount; =20 // // Allocate buffer for Simple Text Input device @@ -631,6 +634,19 @@ ConSplitterTextInConstructor ( ); ASSERT_EFI_ERROR (Status); =20 + // + // Allocate buffer for KeyQueue + // + TextInExListCount =3D ConInPrivate->TextInExListCount; + Status =3D ConSplitterGrowBuffer ( + sizeof (EFI_KEY_DATA), + &TextInExListCount, + (VOID **) &ConInPrivate->KeyQueue + ); + if (EFI_ERROR (Status)) { + return EFI_OUT_OF_RESOURCES; + } + // // Allocate buffer for Simple Text Input Ex device // @@ -1968,6 +1984,17 @@ ConSplitterTextInExAddDevice ( return EFI_OUT_OF_RESOURCES; } } + + TextInExListCount =3D Private->TextInExListCount; + Status =3D ConSplitterGrowBuffer ( + sizeof (EFI_KEY_DATA), + &TextInExListCount, + (VOID **) &Private->KeyQueue + ); + if (EFI_ERROR (Status)) { + return EFI_OUT_OF_RESOURCES; + } + Status =3D ConSplitterGrowBuffer ( sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *), &Private->TextInExListCount, @@ -3445,11 +3472,46 @@ ConSplitterTextInReset ( =20 if (!EFI_ERROR (ReturnStatus)) { ToggleStateSyncReInitialization (Private); + // + // Empty the key queue. + // + Private->CurrentNumberOfKeys =3D 0; } =20 return ReturnStatus; } =20 +/** + Dequeue the saved key from internal key queue. + + @param Private Protocol instance pointer. + @param KeyData A pointer to a buffer that is filled in= with the + keystroke state data for the key that w= as + pressed. + @retval EFI_NOT_FOUND Queue is empty. + @retval EFI_SUCCESS First key is dequeued and returned. +**/ +EFI_STATUS +ConSplitterTextInExDequeueKey ( + IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private, + OUT EFI_KEY_DATA *KeyData + ) +{ + if (Private->CurrentNumberOfKeys =3D=3D 0) { + return EFI_NOT_FOUND; + } + // + // Return the first saved key. + // + CopyMem (KeyData, &Private->KeyQueue[0], sizeof (EFI_KEY_DATA)); + Private->CurrentNumberOfKeys--; + CopyMem ( + &Private->KeyQueue[0], + &Private->KeyQueue[1], + Private->CurrentNumberOfKeys * sizeof (EFI_KEY_DATA) + ); + return EFI_SUCCESS; +} =20 /** Reads the next keystroke from the input device. The WaitForKey Event can @@ -3473,7 +3535,13 @@ ConSplitterTextInPrivateReadKeyStroke ( { EFI_STATUS Status; UINTN Index; - EFI_INPUT_KEY CurrentKey; + EFI_KEY_DATA KeyData; + + Status =3D ConSplitterTextInExDequeueKey (Private, &KeyData); + if (!EFI_ERROR (Status)) { + CopyMem (Key, &KeyData.Key, sizeof (EFI_INPUT_KEY)); + return Status; + } =20 Key->UnicodeChar =3D 0; Key->ScanCode =3D SCAN_NULL; @@ -3486,15 +3554,15 @@ ConSplitterTextInPrivateReadKeyStroke ( for (Index =3D 0; Index < Private->CurrentNumberOfConsoles;) { Status =3D Private->TextInList[Index]->ReadKeyStroke ( Private->TextInList[Index], - &CurrentKey + &KeyData.Key ); if (!EFI_ERROR (Status)) { // // If it is not partial keystorke, return the key. Otherwise, contin= ue // to read key from THIS physical console input device. // - if ((CurrentKey.ScanCode !=3D CHAR_NULL) || (CurrentKey.UnicodeChar = !=3D SCAN_NULL)) { - *Key =3D CurrentKey; + if ((KeyData.Key.ScanCode !=3D CHAR_NULL) || (KeyData.Key.UnicodeCha= r !=3D SCAN_NULL)) { + CopyMem (Key, &KeyData.Key, sizeof (EFI_INPUT_KEY)); return Status; } } else { @@ -3681,6 +3749,10 @@ ConSplitterTextInResetEx ( =20 if (!EFI_ERROR (ReturnStatus)) { ToggleStateSyncReInitialization (Private); + // + // Empty the key queue. + // + Private->CurrentNumberOfKeys =3D 0; } =20 return ReturnStatus; @@ -3714,6 +3786,7 @@ ConSplitterTextInReadKeyStrokeEx ( TEXT_IN_SPLITTER_PRIVATE_DATA *Private; EFI_STATUS Status; UINTN Index; + EFI_KEY_STATE KeyState; EFI_KEY_DATA CurrentKeyData; =20 =20 @@ -3725,9 +3798,6 @@ ConSplitterTextInReadKeyStrokeEx ( =20 Private->KeyEventSignalState =3D FALSE; =20 - KeyData->Key.UnicodeChar =3D 0; - KeyData->Key.ScanCode =3D SCAN_NULL; - // // Signal ConnectConIn event on first call in Lazy ConIn mode // @@ -3738,35 +3808,81 @@ ConSplitterTextInReadKeyStrokeEx ( } =20 // - // if no physical console input device exists, return EFI_NOT_READY; - // if any physical console input device has key input, - // return the key and EFI_SUCCESS. + // Return the first saved key. + // + Status =3D ConSplitterTextInExDequeueKey (Private, KeyData); + if (!EFI_ERROR (Status)) { + return Status; + } + ASSERT (Private->CurrentNumberOfKeys =3D=3D 0); + + ZeroMem (&KeyState, sizeof (KeyState)); + + // + // Iterate through all physical consoles to get key state. + // Some physical consoles may return valid key. + // Queue the valid keys. // - for (Index =3D 0; Index < Private->CurrentNumberOfExConsoles;) { + for (Index =3D 0; Index < Private->CurrentNumberOfExConsoles; Index++) { + ZeroMem (&CurrentKeyData, sizeof (EFI_KEY_DATA)); Status =3D Private->TextInExList[Index]->ReadKeyStrokeEx ( - Private->TextInExList[Index], - &CurrentKeyData - ); + Private->TextInExList[Index], + &CurrentKeyData + ); + if (EFI_ERROR (Status) && (Status !=3D EFI_NOT_READY)) { + continue; + } + + // + // Consolidate the key state from all physical consoles. + // + if ((CurrentKeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != =3D 0) { + KeyState.KeyShiftState |=3D CurrentKeyData.KeyState.KeyShiftState; + } + if ((CurrentKeyData.KeyState.KeyToggleState & EFI_TOGGLE_STATE_VALID) = !=3D 0) { + KeyState.KeyToggleState |=3D CurrentKeyData.KeyState.KeyToggleState; + } + if (!EFI_ERROR (Status)) { // // If virtual KeyState has been required to be exposed, or it is not - // partial keystorke, return the key. Otherwise, continue to read key - // from THIS physical console input device. + // partial keystorke, queue the key. + // It's possible that user presses at multiple keyboards at the same= moment, + // Private->KeyQueue[] are the storage to save all the keys. // if ((Private->VirtualKeyStateExported) || (CurrentKeyData.Key.ScanCode !=3D CHAR_NULL) || (CurrentKeyData.Key.UnicodeChar !=3D SCAN_NULL)) { - CopyMem (KeyData, &CurrentKeyData, sizeof (CurrentKeyData)); - return Status; + CopyMem ( + &Private->KeyQueue[Private->CurrentNumberOfKeys], + &CurrentKeyData, + sizeof (EFI_KEY_DATA) + ); + Private->CurrentNumberOfKeys++; } - } else { - // - // Continue to read key from NEXT physical console input device. - // - Index++; } } =20 + // + // Consolidate the key state for all keys in Private->KeyQueue[] + // + for (Index =3D 0; Index < Private->CurrentNumberOfKeys; Index++) { + CopyMem (&Private->KeyQueue[Index].KeyState, &KeyState, sizeof (EFI_KE= Y_STATE)); + } + =20 + // + // Return the first saved key. + // + Status =3D ConSplitterTextInExDequeueKey (Private, KeyData); + if (!EFI_ERROR (Status)) { + return Status; + } + + // + // Always return the key state even there is no key pressed. + // + ZeroMem (&KeyData->Key, sizeof (KeyData->Key)); + CopyMem (&KeyData->KeyState, &KeyState, sizeof (KeyData->KeyState)); return EFI_NOT_READY; } =20 diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h b/= MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h index 9469860bf0..5fde6b0cb4 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h @@ -1,7 +1,7 @@ /** @file Private data structures for the Console Splitter driver =20 -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, 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 @@ -129,6 +129,8 @@ typedef struct { EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL **TextInExList; UINTN TextInExListCount; LIST_ENTRY NotifyList; + EFI_KEY_DATA *KeyQueue; + UINTN CurrentNumberOfKeys; // // It will be initialized and synced between console input devices // for toggle state sync. --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun May 5 18:48:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1516608637969795.0693874134204; Mon, 22 Jan 2018 00:10:37 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0E3832238B5A9; Mon, 22 Jan 2018 00:05:07 -0800 (PST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B85DE2232BE18 for ; Mon, 22 Jan 2018 00:05:03 -0800 (PST) Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jan 2018 00:10:29 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga008.fm.intel.com with ESMTP; 22 Jan 2018 00:10:28 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,395,1511856000"; d="scan'208";a="12170506" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Mon, 22 Jan 2018 16:10:21 +0800 Message-Id: <20180122081024.283496-4-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180122081024.283496-1-ruiyu.ni@intel.com> References: <20180122081024.283496-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 3/6] MdeModulePkg/UsbKb: ReadKeyStrokeEx always return key state X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Today's implementation only return key state when there is key. But when user doesn't press any key, the key state cannot be returned. The patch changes the ReadKeyStrokeEx() to always return the key state even there is no key pressed. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng Cc: Michael D Kinney --- MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c | 4 +- MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c | 107 ++++++++++++++++++---------= ---- MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.h | 14 +++- 3 files changed, 77 insertions(+), 48 deletions(-) diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c b/MdeModulePkg/Bus/Usb/= UsbKbDxe/EfiKey.c index fb2bf3fd81..722350f609 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c @@ -2,7 +2,7 @@ USB Keyboard Driver that manages USB keyboard and produces Simple Text I= nput Protocol and Simple Text Input Ex Protocol. =20 -Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2018, 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 @@ -607,6 +607,8 @@ USBKeyboardReadKeyStrokeWorker ( } =20 if (IsQueueEmpty (&UsbKeyboardDevice->EfiKeyQueue)) { + ZeroMem (&KeyData->Key, sizeof (KeyData->Key)); + InitializeKeyState (UsbKeyboardDevice, &KeyData->KeyState); return EFI_NOT_READY; } =20 diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c b/MdeModulePkg/Bus/Us= b/UsbKbDxe/KeyBoard.c index 91913d4e54..d140311c52 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.c @@ -1,7 +1,7 @@ /** @file Helper functions for USB Keyboard Driver. =20 -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2018, 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 @@ -1484,6 +1484,65 @@ USBParseKey ( return EFI_NOT_READY; } =20 +/** + Initialize the key state. + + @param UsbKeyboardDevice The USB_KB_DEV instance. + @param KeyState A pointer to receive the key state informa= tion. +**/ +VOID +InitializeKeyState ( + IN USB_KB_DEV *UsbKeyboardDevice, + OUT EFI_KEY_STATE *KeyState + ) +{ + KeyState->KeyShiftState =3D EFI_SHIFT_STATE_VALID; + KeyState->KeyToggleState =3D EFI_TOGGLE_STATE_VALID; + + if (UsbKeyboardDevice->LeftCtrlOn) { + KeyState->KeyShiftState |=3D EFI_LEFT_CONTROL_PRESSED; + } + if (UsbKeyboardDevice->RightCtrlOn) { + KeyState->KeyShiftState |=3D EFI_RIGHT_CONTROL_PRESSED; + } + if (UsbKeyboardDevice->LeftAltOn) { + KeyState->KeyShiftState |=3D EFI_LEFT_ALT_PRESSED; + } + if (UsbKeyboardDevice->RightAltOn) { + KeyState->KeyShiftState |=3D EFI_RIGHT_ALT_PRESSED; + } + if (UsbKeyboardDevice->LeftShiftOn) { + KeyState->KeyShiftState |=3D EFI_LEFT_SHIFT_PRESSED; + } + if (UsbKeyboardDevice->RightShiftOn) { + KeyState->KeyShiftState |=3D EFI_RIGHT_SHIFT_PRESSED; + } + if (UsbKeyboardDevice->LeftLogoOn) { + KeyState->KeyShiftState |=3D EFI_LEFT_LOGO_PRESSED; + } + if (UsbKeyboardDevice->RightLogoOn) { + KeyState->KeyShiftState |=3D EFI_RIGHT_LOGO_PRESSED; + } + if (UsbKeyboardDevice->MenuKeyOn) { + KeyState->KeyShiftState |=3D EFI_MENU_KEY_PRESSED; + } + if (UsbKeyboardDevice->SysReqOn) { + KeyState->KeyShiftState |=3D EFI_SYS_REQ_PRESSED; + } + + if (UsbKeyboardDevice->ScrollOn) { + KeyState->KeyToggleState |=3D EFI_SCROLL_LOCK_ACTIVE; + } + if (UsbKeyboardDevice->NumLockOn) { + KeyState->KeyToggleState |=3D EFI_NUM_LOCK_ACTIVE; + } + if (UsbKeyboardDevice->CapsOn) { + KeyState->KeyToggleState |=3D EFI_CAPS_LOCK_ACTIVE; + } + if (UsbKeyboardDevice->IsSupportPartialKey) { + KeyState->KeyToggleState |=3D EFI_KEY_STATE_EXPOSED; + } +} =20 /** Converts USB Keycode ranging from 0x4 to 0x65 to EFI_INPUT_KEY. @@ -1619,52 +1678,8 @@ UsbKeyCodeToEfiInputKey ( // // Save Shift/Toggle state // - KeyData->KeyState.KeyShiftState =3D EFI_SHIFT_STATE_VALID; - KeyData->KeyState.KeyToggleState =3D EFI_TOGGLE_STATE_VALID; + InitializeKeyState (UsbKeyboardDevice, &KeyData->KeyState); =20 - if (UsbKeyboardDevice->LeftCtrlOn) { - KeyData->KeyState.KeyShiftState |=3D EFI_LEFT_CONTROL_PRESSED; - } - if (UsbKeyboardDevice->RightCtrlOn) { - KeyData->KeyState.KeyShiftState |=3D EFI_RIGHT_CONTROL_PRESSED; - } - if (UsbKeyboardDevice->LeftAltOn) { - KeyData->KeyState.KeyShiftState |=3D EFI_LEFT_ALT_PRESSED; - } - if (UsbKeyboardDevice->RightAltOn) { - KeyData->KeyState.KeyShiftState |=3D EFI_RIGHT_ALT_PRESSED; - } - if (UsbKeyboardDevice->LeftShiftOn) { - KeyData->KeyState.KeyShiftState |=3D EFI_LEFT_SHIFT_PRESSED; - } - if (UsbKeyboardDevice->RightShiftOn) { - KeyData->KeyState.KeyShiftState |=3D EFI_RIGHT_SHIFT_PRESSED; - } - if (UsbKeyboardDevice->LeftLogoOn) { - KeyData->KeyState.KeyShiftState |=3D EFI_LEFT_LOGO_PRESSED; - } - if (UsbKeyboardDevice->RightLogoOn) { - KeyData->KeyState.KeyShiftState |=3D EFI_RIGHT_LOGO_PRESSED; - } - if (UsbKeyboardDevice->MenuKeyOn) { - KeyData->KeyState.KeyShiftState |=3D EFI_MENU_KEY_PRESSED; - } - if (UsbKeyboardDevice->SysReqOn) { - KeyData->KeyState.KeyShiftState |=3D EFI_SYS_REQ_PRESSED; - } - - if (UsbKeyboardDevice->ScrollOn) { - KeyData->KeyState.KeyToggleState |=3D EFI_SCROLL_LOCK_ACTIVE; - } - if (UsbKeyboardDevice->NumLockOn) { - KeyData->KeyState.KeyToggleState |=3D EFI_NUM_LOCK_ACTIVE; - } - if (UsbKeyboardDevice->CapsOn) { - KeyData->KeyState.KeyToggleState |=3D EFI_CAPS_LOCK_ACTIVE; - } - if (UsbKeyboardDevice->IsSupportPartialKey) { - KeyData->KeyState.KeyToggleState |=3D EFI_KEY_STATE_EXPOSED; - } // // Signal KeyNotify process event if this key pressed matches any key re= gistered. // diff --git a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.h b/MdeModulePkg/Bus/Us= b/UsbKbDxe/KeyBoard.h index b3eb3e462f..87f2132eac 100644 --- a/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.h +++ b/MdeModulePkg/Bus/Usb/UsbKbDxe/KeyBoard.h @@ -1,7 +1,7 @@ /** @file Function prototype for USB Keyboard Driver. =20 -Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2018, 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 @@ -317,4 +317,16 @@ SetKeyLED ( IN USB_KB_DEV *UsbKeyboardDevice ); =20 +/** + Initialize the key state. + + @param UsbKeyboardDevice The USB_KB_DEV instance. + @param KeyState A pointer to receive the key state informa= tion. +**/ +VOID +InitializeKeyState ( + IN USB_KB_DEV *UsbKeyboardDevice, + OUT EFI_KEY_STATE *KeyState + ); + #endif --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun May 5 18:48:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1516608640597541.8844185010622; Mon, 22 Jan 2018 00:10:40 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6391E2238B5AC; Mon, 22 Jan 2018 00:05:07 -0800 (PST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 987152238B598 for ; Mon, 22 Jan 2018 00:05:04 -0800 (PST) Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jan 2018 00:10:30 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga008.fm.intel.com with ESMTP; 22 Jan 2018 00:10:29 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,395,1511856000"; d="scan'208";a="12170509" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Mon, 22 Jan 2018 16:10:22 +0800 Message-Id: <20180122081024.283496-5-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180122081024.283496-1-ruiyu.ni@intel.com> References: <20180122081024.283496-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 4/6] MdeModulePkg/Ps2Kb: ReadKeyStrokeEx always return key state X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Today's implementation only return key state when there is key. But when user doesn't press any key, the key state cannot be returned. The patch changes the ReadKeyStrokeEx() to always return the key state even there is no key pressed. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng Cc: Michael D Kinney --- .../Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c | 58 ++++++++++++++----= ---- MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c | 6 ++- MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h | 14 +++++- 3 files changed, 54 insertions(+), 24 deletions(-) diff --git a/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c b/MdeModul= ePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c index f92521046f..4def6d9271 100644 --- a/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c +++ b/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c @@ -1,7 +1,7 @@ /** @file Routines that access 8042 keyboard controller =20 -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, 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 @@ -1104,6 +1104,38 @@ UpdateStatusLights ( return Status; } =20 +/** + Initialize the key state. + + @param ConsoleIn The KEYBOARD_CONSOLE_IN_DEV instance. + @param KeyState A pointer to receive the key state information. +**/ +VOID +InitializeKeyState ( + IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn, + OUT EFI_KEY_STATE *KeyState + ) +{ + KeyState->KeyShiftState =3D EFI_SHIFT_STATE_VALID + | (ConsoleIn->LeftCtrl ? EFI_LEFT_CONTROL_PRE= SSED : 0) + | (ConsoleIn->RightCtrl ? EFI_RIGHT_CONTROL_PR= ESSED : 0) + | (ConsoleIn->LeftAlt ? EFI_LEFT_ALT_PRESSED= : 0) + | (ConsoleIn->RightAlt ? EFI_RIGHT_ALT_PRESSE= D : 0) + | (ConsoleIn->LeftShift ? EFI_LEFT_SHIFT_PRESS= ED : 0) + | (ConsoleIn->RightShift ? EFI_RIGHT_SHIFT_PRES= SED : 0) + | (ConsoleIn->LeftLogo ? EFI_LEFT_LOGO_PRESSE= D : 0) + | (ConsoleIn->RightLogo ? EFI_RIGHT_LOGO_PRESS= ED : 0) + | (ConsoleIn->Menu ? EFI_MENU_KEY_PRESSED= : 0) + | (ConsoleIn->SysReq ? EFI_SYS_REQ_PRESSED = : 0) + ; + KeyState->KeyToggleState =3D EFI_TOGGLE_STATE_VALID + | (ConsoleIn->CapsLock ? EFI_CAPS_LOCK_ACTIVE= : 0) + | (ConsoleIn->NumLock ? EFI_NUM_LOCK_ACTIVE = : 0) + | (ConsoleIn->ScrollLock ? EFI_SCROLL_LOCK_ACTI= VE : 0) + | (ConsoleIn->IsSupportPartialKey ? EFI_KEY_STA= TE_EXPOSED : 0) + ; +} + /** Get scancode from scancode buffer and translate into EFI-scancode and un= icode defined by EFI spec. =20 @@ -1316,27 +1348,9 @@ KeyGetchar ( // // Save the Shift/Toggle state // - KeyData.KeyState.KeyShiftState =3D (UINT32) (EFI_SHIFT_STATE_VALID - | (ConsoleIn->LeftCtrl ? EFI_LEFT_CONTR= OL_PRESSED : 0) - | (ConsoleIn->RightCtrl ? EFI_RIGHT_CONT= ROL_PRESSED : 0) - | (ConsoleIn->LeftAlt ? EFI_LEFT_ALT_P= RESSED : 0) - | (ConsoleIn->RightAlt ? EFI_RIGHT_ALT_= PRESSED : 0) - | (ConsoleIn->LeftShift ? EFI_LEFT_SHIFT= _PRESSED : 0) - | (ConsoleIn->RightShift ? EFI_RIGHT_SHIF= T_PRESSED : 0) - | (ConsoleIn->LeftLogo ? EFI_LEFT_LOGO_= PRESSED : 0) - | (ConsoleIn->RightLogo ? EFI_RIGHT_LOGO= _PRESSED : 0) - | (ConsoleIn->Menu ? EFI_MENU_KEY_P= RESSED : 0) - | (ConsoleIn->SysReq ? EFI_SYS_REQ_PR= ESSED : 0) - ); - KeyData.KeyState.KeyToggleState =3D (EFI_KEY_TOGGLE_STATE) (EFI_TOGGLE_S= TATE_VALID - | (ConsoleIn->CapsLock ? EFI_CAPS_LOCK= _ACTIVE : 0) - | (ConsoleIn->NumLock ? EFI_NUM_LOCK_= ACTIVE : 0) - | (ConsoleIn->ScrollLock ? EFI_SCROLL_LO= CK_ACTIVE : 0) - | (ConsoleIn->IsSupportPartialKey ? EFI_= KEY_STATE_EXPOSED : 0) - ); - - KeyData.Key.ScanCode =3D SCAN_NULL; - KeyData.Key.UnicodeChar =3D CHAR_NULL; + InitializeKeyState (ConsoleIn, &KeyData.KeyState); + KeyData.Key.ScanCode =3D SCAN_NULL; + KeyData.Key.UnicodeChar =3D CHAR_NULL; =20 // // Key Pad "/" shares the same scancode as that of "/" except Key Pad "/= " has E0 prefix diff --git a/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c b/MdeModule= Pkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c index 04e3365f9e..5986eca5f3 100644 --- a/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c +++ b/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c @@ -2,7 +2,7 @@ Routines implements SIMPLE_TEXT_IN protocol's interfaces based on 8042 i= nterfaces provided by Ps2KbdCtrller.c. =20 -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, 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 @@ -165,6 +165,10 @@ KeyboardReadKeyStrokeWorker ( Status =3D EFI_DEVICE_ERROR; } else { Status =3D PopEfikeyBufHead (&ConsoleInDev->EfiKeyQueue, KeyData); + if (Status =3D=3D EFI_NOT_READY) { + ZeroMem (&KeyData->Key, sizeof (KeyData->Key)); + InitializeKeyState (ConsoleInDev, &KeyData->KeyState); + } } =20 gBS->RestoreTPL (OldTpl); diff --git a/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h b/MdeModuleP= kg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h index d772a979bf..b6a4f3c6b9 100644 --- a/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h +++ b/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h @@ -1,7 +1,7 @@ /** @file PS/2 keyboard driver header file =20 -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, 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 @@ -566,4 +566,16 @@ IsKeyRegistered ( IN EFI_KEY_DATA *InputData ); =20 +/** + Initialize the key state. + + @param ConsoleIn The KEYBOARD_CONSOLE_IN_DEV instance. + @param KeyState A pointer to receive the key state information. +**/ +VOID +InitializeKeyState ( + IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn, + OUT EFI_KEY_STATE *KeyState + ); + #endif --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun May 5 18:48:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1516608643104473.83396897465684; Mon, 22 Jan 2018 00:10:43 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id BBF6C2238B5A4; Mon, 22 Jan 2018 00:05:09 -0800 (PST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7D9A32238B598 for ; Mon, 22 Jan 2018 00:05:05 -0800 (PST) Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jan 2018 00:10:31 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga008.fm.intel.com with ESMTP; 22 Jan 2018 00:10:30 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,395,1511856000"; d="scan'208";a="12170515" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Mon, 22 Jan 2018 16:10:23 +0800 Message-Id: <20180122081024.283496-6-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180122081024.283496-1-ruiyu.ni@intel.com> References: <20180122081024.283496-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 5/6] IntelFrameworkModule/Ps2Kb: ReadKeyStrokeEx always return key state X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Today's implementation only return key state when there is a key. But when user doesn't press any key, the key state cannot be returned. The patch changes the ReadKeyStrokeEx() to always return the key state even there is no key pressed. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng Cc: Michael D Kinney --- .../Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c | 58 ++++++++++++++----= ---- .../Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c | 6 ++- .../Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h | 14 +++++- 3 files changed, 54 insertions(+), 24 deletions(-) diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c= b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c index b528b89ac4..48d8efd516 100644 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c +++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c @@ -1,7 +1,7 @@ /** @file Routines that access 8042 keyboard controller =20 -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, 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 @@ -1140,6 +1140,38 @@ UpdateStatusLights ( return Status; } =20 +/** + Initialize the key state. + + @param ConsoleIn The KEYBOARD_CONSOLE_IN_DEV instance. + @param KeyState A pointer to receive the key state information. +**/ +VOID +InitializeKeyState ( + IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn, + OUT EFI_KEY_STATE *KeyState + ) +{ + KeyState->KeyShiftState =3D EFI_SHIFT_STATE_VALID + | (ConsoleIn->LeftCtrl ? EFI_LEFT_CONTROL_PRE= SSED : 0) + | (ConsoleIn->RightCtrl ? EFI_RIGHT_CONTROL_PR= ESSED : 0) + | (ConsoleIn->LeftAlt ? EFI_LEFT_ALT_PRESSED= : 0) + | (ConsoleIn->RightAlt ? EFI_RIGHT_ALT_PRESSE= D : 0) + | (ConsoleIn->LeftShift ? EFI_LEFT_SHIFT_PRESS= ED : 0) + | (ConsoleIn->RightShift ? EFI_RIGHT_SHIFT_PRES= SED : 0) + | (ConsoleIn->LeftLogo ? EFI_LEFT_LOGO_PRESSE= D : 0) + | (ConsoleIn->RightLogo ? EFI_RIGHT_LOGO_PRESS= ED : 0) + | (ConsoleIn->Menu ? EFI_MENU_KEY_PRESSED= : 0) + | (ConsoleIn->SysReq ? EFI_SYS_REQ_PRESSED = : 0) + ; + KeyState->KeyToggleState =3D EFI_TOGGLE_STATE_VALID + | (ConsoleIn->CapsLock ? EFI_CAPS_LOCK_ACTIVE= : 0) + | (ConsoleIn->NumLock ? EFI_NUM_LOCK_ACTIVE = : 0) + | (ConsoleIn->ScrollLock ? EFI_SCROLL_LOCK_ACTI= VE : 0) + | (ConsoleIn->IsSupportPartialKey ? EFI_KEY_STA= TE_EXPOSED : 0) + ; +} + /** Get scancode from scancode buffer and translate into EFI-scancode and un= icode defined by EFI spec. =20 @@ -1352,27 +1384,9 @@ KeyGetchar ( // // Save the Shift/Toggle state // - KeyData.KeyState.KeyShiftState =3D (UINT32) (EFI_SHIFT_STATE_VALID - | (ConsoleIn->LeftCtrl ? EFI_LEFT_CONTR= OL_PRESSED : 0) - | (ConsoleIn->RightCtrl ? EFI_RIGHT_CONT= ROL_PRESSED : 0) - | (ConsoleIn->LeftAlt ? EFI_LEFT_ALT_P= RESSED : 0) - | (ConsoleIn->RightAlt ? EFI_RIGHT_ALT_= PRESSED : 0) - | (ConsoleIn->LeftShift ? EFI_LEFT_SHIFT= _PRESSED : 0) - | (ConsoleIn->RightShift ? EFI_RIGHT_SHIF= T_PRESSED : 0) - | (ConsoleIn->LeftLogo ? EFI_LEFT_LOGO_= PRESSED : 0) - | (ConsoleIn->RightLogo ? EFI_RIGHT_LOGO= _PRESSED : 0) - | (ConsoleIn->Menu ? EFI_MENU_KEY_P= RESSED : 0) - | (ConsoleIn->SysReq ? EFI_SYS_REQ_PR= ESSED : 0) - ); - KeyData.KeyState.KeyToggleState =3D (EFI_KEY_TOGGLE_STATE) (EFI_TOGGLE_S= TATE_VALID - | (ConsoleIn->CapsLock ? EFI_CAPS_LOCK= _ACTIVE : 0) - | (ConsoleIn->NumLock ? EFI_NUM_LOCK_= ACTIVE : 0) - | (ConsoleIn->ScrollLock ? EFI_SCROLL_LO= CK_ACTIVE : 0) - | (ConsoleIn->IsSupportPartialKey ? EFI_= KEY_STATE_EXPOSED : 0) - ); - - KeyData.Key.ScanCode =3D SCAN_NULL; - KeyData.Key.UnicodeChar =3D CHAR_NULL; + InitializeKeyState (ConsoleIn, &KeyData.KeyState); + KeyData.Key.ScanCode =3D SCAN_NULL; + KeyData.Key.UnicodeChar =3D CHAR_NULL; =20 // // Key Pad "/" shares the same scancode as that of "/" except Key Pad "/= " has E0 prefix diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c = b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c index 76779553cd..401b0e8c20 100644 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c +++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c @@ -2,7 +2,7 @@ Routines implements SIMPLE_TEXT_IN protocol's interfaces based on 8042 i= nterfaces provided by Ps2KbdCtrller.c. =20 -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, 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 @@ -165,6 +165,10 @@ KeyboardReadKeyStrokeWorker ( Status =3D EFI_DEVICE_ERROR; } else { Status =3D PopEfikeyBufHead (&ConsoleInDev->EfiKeyQueue, KeyData); + if (Status =3D=3D EFI_NOT_READY) { + ZeroMem (&KeyData->Key, sizeof (KeyData->Key)); + InitializeKeyState (ConsoleInDev, &KeyData->KeyState); + } } =20 gBS->RestoreTPL (OldTpl); diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h b= /IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h index 76fb498868..613f176401 100644 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h +++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h @@ -1,7 +1,7 @@ /** @file PS/2 keyboard driver header file =20 -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, 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 @@ -566,4 +566,16 @@ IsKeyRegistered ( IN EFI_KEY_DATA *InputData ); =20 +/** + Initialize the key state. + + @param ConsoleIn The KEYBOARD_CONSOLE_IN_DEV instance. + @param KeyState A pointer to receive the key state information. +**/ +VOID +InitializeKeyState ( + IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn, + OUT EFI_KEY_STATE *KeyState + ); + #endif --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun May 5 18:48:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1516608645737630.2197180624961; Mon, 22 Jan 2018 00:10:45 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 27FE32238B5AF; Mon, 22 Jan 2018 00:05:10 -0800 (PST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5E4472238B598 for ; Mon, 22 Jan 2018 00:05:06 -0800 (PST) Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jan 2018 00:10:32 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by fmsmga008.fm.intel.com with ESMTP; 22 Jan 2018 00:10:31 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,395,1511856000"; d="scan'208";a="12170519" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Mon, 22 Jan 2018 16:10:24 +0800 Message-Id: <20180122081024.283496-7-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180122081024.283496-1-ruiyu.ni@intel.com> References: <20180122081024.283496-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 6/6] IntelFrameworkModule/ThunkKb: ReadKeyStrokeEx always return key state X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Today's implementation only return key state when there is a key. But when user doesn't press any key, the key state cannot be returned. The patch changes the ReadKeyStrokeEx() to always return the key state even there is no key pressed. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng Cc: Michael D Kinney --- .../Csm/BiosThunk/KeyboardDxe/BiosKeyboard.c | 14 ++++++++++= ++-- .../Csm/BiosThunk/KeyboardDxe/BiosKeyboard.h | 5 +++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard= .c b/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.c index ec525891dc..ac8e2364c8 100644 --- a/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.c +++ b/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.c @@ -1,7 +1,7 @@ /** @file ConsoleOut Routines that speak VGA. =20 -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
=20 This program and the accompanying materials are licensed and made available under the terms and conditions @@ -269,7 +269,9 @@ BiosKeyboardDriverBindingStart ( BiosKeyboardPrivate->StatusRegisterAddress =3D KEYBOARD_8042_STATUS= _REGISTER; BiosKeyboardPrivate->CommandRegisterAddress =3D KEYBOARD_8042_COMMAN= D_REGISTER; BiosKeyboardPrivate->ExtendedKeyboard =3D TRUE; - =20 + + BiosKeyboardPrivate->KeyState.KeyShiftState =3D 0; + BiosKeyboardPrivate->KeyState.KeyToggleState =3D 0; BiosKeyboardPrivate->Queue.Front =3D 0; BiosKeyboardPrivate->Queue.Rear =3D 0; BiosKeyboardPrivate->QueueForNotify.Front =3D 0; @@ -978,6 +980,8 @@ KeyboardReadKeyStrokeWorker ( // Status =3D CheckQueue (&BiosKeyboardPrivate->Queue); if (EFI_ERROR (Status)) { + ZeroMem (&KeyData->Key, sizeof (KeyData->Key)); + CopyMem (&KeyData->KeyState, &BiosKeyboardPrivate->KeyState, sizeof (E= FI_KEY_STATE)); gBS->RestoreTPL (OldTpl); return EFI_NOT_READY; } @@ -1986,6 +1990,12 @@ BiosKeyboardTimerHandler ( } =20 Enqueue (&BiosKeyboardPrivate->Queue, &KeyData); + + // + // Save the current key state + // + CopyMem (&BiosKeyboardPrivate->KeyState, &KeyData.KeyState, sizeof (EFI_= KEY_STATE)); + // // Leave critical section and return // diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard= .h b/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.h index c64ec0095e..5300eaa0ab 100644 --- a/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.h +++ b/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.h @@ -1,6 +1,6 @@ /** @file =20 -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
=20 This program and the accompanying materials are licensed and made available under the terms and conditions @@ -220,7 +220,8 @@ typedef struct { UINT16 StatusRegisterAddress; UINT16 CommandRegisterAddress; BOOLEAN ExtendedKeyboard; - =20 + + EFI_KEY_STATE KeyState; // // Buffer storing EFI_KEY_DATA // --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel