From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 D884C823E9 for ; Thu, 22 Dec 2016 18:16:07 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP; 22 Dec 2016 18:16:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,391,1477983600"; d="scan'208";a="1103249528" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga002.fm.intel.com with ESMTP; 22 Dec 2016 18:16:07 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 22 Dec 2016 18:16:07 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.88]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.132]) with mapi id 14.03.0248.002; Fri, 23 Dec 2016 10:16:05 +0800 From: "Fan, Jeff" To: "Zeng, Star" , "edk2-devel@lists.01.org" CC: "Ni, Ruiyu" , "Kinney, Michael D" , "Tian, Feng" , "Zeng, Star" Thread-Topic: [edk2] [PATCH 4/5] IntelFrameworkModulePkg Ps2KbDxe: Execute key notify func at TPL_CALLBACK Thread-Index: AQHSXFmtsSzu6UHsM0udWJmpIgArSaEUzD4A Date: Fri, 23 Dec 2016 02:16:04 +0000 Message-ID: <542CF652F8836A4AB8DBFAAD40ED192A4C50345E@shsmsx102.ccr.corp.intel.com> References: <1482414310-33036-1-git-send-email-star.zeng@intel.com> <1482414310-33036-5-git-send-email-star.zeng@intel.com> In-Reply-To: <1482414310-33036-5-git-send-email-star.zeng@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMGE1Njg1YTItYjIwOS00ZjU4LWE2OWUtYmNmN2Q1NzFkYWMzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6ImMraTl4bWFnWnZCeUhKQ1VWMG85Rnd5STV4TWdkaUFxdW5SK1pSWm11UkE9In0= x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 4/5] IntelFrameworkModulePkg Ps2KbDxe: Execute key notify func at TPL_CALLBACK X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Dec 2016 02:16:07 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jeff Fan -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Star= Zeng Sent: Thursday, December 22, 2016 9:45 PM To: edk2-devel@lists.01.org Cc: Ni, Ruiyu; Kinney, Michael D; Tian, Feng; Fan, Jeff; Zeng, Star Subject: [edk2] [PATCH 4/5] IntelFrameworkModulePkg Ps2KbDxe: Execute key n= otify func at TPL_CALLBACK Current implementation executes key notify function in TimerHandler at TPL_= NOTIFY. The code change is to make key notify function executed at TPL_CALL= BACK to reduce the time occupied at TPL_NOTIFY. The code will signal KeyNotify process event if the key pressed matches any= key registered and insert the KeyData to the EFI Key queue for notify, the= n the KeyNotify process handler will invoke key notify functions at TPL_CAL= LBACK. Cc: Ruiyu Ni Cc: Michael Kinney Cc: Feng Tian Cc: Jeff Fan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng --- .../Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c | 9 +++-- .../Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c | 47 ++++++++++++++++++= +++- .../Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c | 23 ++++++++++- .../Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h | 15 +++++++ 4 files changed, 89 insertions(+), 5 deletions(-) diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c= b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c index 9bde538d10c7..ea0875996753 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 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full text of the license may be found at @@ -1456,7 +1= 456,7 @@ KeyGetchar ( } =20 // - // Invoke notification functions if exist + // Signal KeyNotify process event if this key pressed matches any key re= gistered. // for (Link =3D GetFirstNode (&ConsoleIn->NotifyList); !IsNull (&ConsoleIn= ->NotifyList, Link); Link =3D GetNextNode (&ConsoleIn->NotifyList, Link)) { CurrentNotify =3D CR ( @@ -1466,7 +1466,8 @@ KeyGetchar ( KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE ); if (IsKeyRegistered (&CurrentNotify->KeyData, &KeyData)) { - CurrentNotify->KeyNotificationFn (&KeyData); + PushEfikeyBufTail (&ConsoleIn->EfiKeyQueueForNotify, &KeyData); + gBS->SignalEvent (ConsoleIn->KeyNotifyProcessEvent); } } =20 @@ -1665,6 +1666,8 @@ InitKeyboard ( ConsoleIn->ScancodeQueue.Tail =3D 0; ConsoleIn->EfiKeyQueue.Head =3D 0; ConsoleIn->EfiKeyQueue.Tail =3D 0; + ConsoleIn->EfiKeyQueueForNotify.Head =3D 0; =20 + ConsoleIn->EfiKeyQueueForNotify.Tail =3D 0; =20 // // Reset the status indicators diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c = b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c index 0efeb39e0da4..9803cde50ebf 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 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full text of the license may be found at @@ -681,3 +68= 1,48 @@ Exit: return Status; } =20 +/** + Process key notify. + + @param Event Indicates the event that invoke this funct= ion. + @param Context Indicates the calling context. +**/ +VOID +EFIAPI +KeyNotifyProcessHandler ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + KEYBOARD_CONSOLE_IN_DEV *ConsoleIn; + EFI_KEY_DATA KeyData; + LIST_ENTRY *Link; + LIST_ENTRY *NotifyList; + KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify; + EFI_TPL OldTpl; + + ConsoleIn =3D (KEYBOARD_CONSOLE_IN_DEV *) Context; + + // + // Invoke notification functions. + // + NotifyList =3D &ConsoleIn->NotifyList; + while (!IsEfikeyBufEmpty (&ConsoleIn->EfiKeyQueueForNotify)) { + // + // Enter critical section + // =20 + OldTpl =3D gBS->RaiseTPL (TPL_NOTIFY); + PopEfikeyBufHead (&ConsoleIn->EfiKeyQueueForNotify, &KeyData); + // + // Leave critical section + // + gBS->RestoreTPL (OldTpl); + for (Link =3D GetFirstNode (NotifyList); !IsNull (NotifyList, Link); L= ink =3D GetNextNode (NotifyList, Link)) { + CurrentNotify =3D CR (Link, KEYBOARD_CONSOLE_IN_EX_NOTIFY, NotifyEnt= ry, KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE); + if (IsKeyRegistered (&CurrentNotify->KeyData, &KeyData)) { + CurrentNotify->KeyNotificationFn (&KeyData); + } + } + } +} + diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c b= /IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c index b6a9b70ca95a..ff562b2698d6 100644 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c +++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c @@ -3,7 +3,7 @@ PS/2 Keyboard driver. Routines that interacts with callers, conforming to EFI driver model =20 -Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full text of the license may be found at @@ -306,6 +30= 6,7 @@ KbdControllerDriverStart ( StatusCode =3D EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR; goto ErrorExit; } + =20 // Setup a periodic timer, used for reading keystrokes at a fixed interv= al // Status =3D gBS->CreateEvent ( @@ -332,6 +333,19 @@ KbdControllerDriverStart ( goto ErrorExit; } =20 + Status =3D gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + KeyNotifyProcessHandler, + ConsoleIn, + &ConsoleIn->KeyNotifyProcessEvent + ); + if (EFI_ERROR (Status)) { + Status =3D EFI_OUT_OF_RESOURCES; + StatusCode =3D EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR; + goto ErrorExit; + } + REPORT_STATUS_CODE_WITH_DEVICE_PATH ( EFI_PROGRESS_CODE, EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_PRESENCE_DETECT, @@ -411,6 +425,9 @= @ ErrorExit: if ((ConsoleIn !=3D NULL) && (ConsoleIn->ConInEx.WaitForKeyEx !=3D NULL)= ) { gBS->CloseEvent (ConsoleIn->ConInEx.WaitForKeyEx); } + if ((ConsoleIn !=3D NULL) && (ConsoleIn->KeyNotifyProcessEvent !=3D NULL= )) { + gBS->CloseEvent (ConsoleIn->KeyNotifyProcessEvent); + } KbdFreeNotifyList (&ConsoleIn->NotifyList); if ((ConsoleIn !=3D NULL) && (ConsoleIn->ControllerNameTable !=3D NULL))= { FreeUnicodeStringTable (ConsoleIn->ControllerNameTable); @@ -565,6 +58= 2,10 @@ KbdControllerDriverStop ( gBS->CloseEvent (ConsoleIn->ConInEx.WaitForKeyEx); ConsoleIn->ConInEx.WaitForKeyEx =3D NULL; } + if (ConsoleIn->KeyNotifyProcessEvent !=3D NULL) { + gBS->CloseEvent (ConsoleIn->KeyNotifyProcessEvent); + ConsoleIn->KeyNotifyProcessEvent =3D NULL; } KbdFreeNotifyList (&ConsoleIn->NotifyList); FreeUnicodeStringTable (ConsoleIn->ControllerNameTable); gBS->FreePool (ConsoleIn); diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h b= /IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h index 62d0e78c4d5a..82aa5a64faea 100644 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h +++ b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h @@ -104,6 +104,7 @@ typedef struct { // SCAN_CODE_QUEUE ScancodeQueue; EFI_KEY_QUEUE EfiKeyQueue; + EFI_KEY_QUEUE EfiKeyQueueForNotify; =20 // // Error state @@ -117,6 +118,7 @@ typedef struct { // Notification Function List // LIST_ENTRY NotifyList; + EFI_EVENT KeyNotifyProcessEvent; } KEYBOARD_CONSOLE_IN_DEV; =20 #define KEYBOARD_CONSOLE_IN_DEV_FROM_THIS(a) CR (a, KEYBOARD_CONSOLE_IN_D= EV, ConIn, KEYBOARD_CONSOLE_IN_DEV_SIGNATURE) @@ -268,6 +270,19 @@ KeyGetchar ( ); =20 /** + Process key notify. + + @param Event Indicates the event that invoke this funct= ion. + @param Context Indicates the calling context. +**/ +VOID +EFIAPI +KeyNotifyProcessHandler ( + IN EFI_EVENT Event, + IN VOID *Context + ); + +/** Perform 8042 controller and keyboard Initialization. If ExtendedVerification is TRUE, do additional test for the keyboard interface -- 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel