From nobody Wed Dec 25 05:45:18 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 151254552097118.900044622511928; Tue, 5 Dec 2017 23:32:00 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 479D120352A9B; Tue, 5 Dec 2017 23:27:25 -0800 (PST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 588B920352A97 for ; Tue, 5 Dec 2017 23:27:23 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Dec 2017 23:31:55 -0800 Received: from jwang36-mobl2.ccr.corp.intel.com ([10.239.192.49]) by fmsmga002.fm.intel.com with ESMTP; 05 Dec 2017 23:31:52 -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=192.55.52.88; helo=mga01.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,367,1508828400"; d="scan'208";a="1252390314" From: Jian J Wang To: edk2-devel@lists.01.org Date: Wed, 6 Dec 2017 15:31:20 +0800 Message-Id: <20171206073120.2248-4-jian.j.wang@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20171206073120.2248-1-jian.j.wang@intel.com> References: <20171206073120.2248-1-jian.j.wang@intel.com> Subject: [edk2] [PATCH 3/3] IntelFrameworkModulePkg/KeyboardDxe: Use macro to enable/disable page 0 X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , 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" Current implementation uses following two methods EnableNullDetection() DisableNullDetection() to enable/disable page 0. These two methods will check PCD PcdNullPointerDetectionPropertyMask to know if the page 0 is disabled or no= t. This is due to the fact that old GCD service doesn't provide paging related attributes of memory block. Since this issue has been fixed, GCD services can be used to determine the paging status of page 0. This is also make it possible to just use a new macro ACCESS_PAGE0_CODE( { } ); to replace above methods to do the same job, which also makes code more readability. Cc: Liming Gao Cc: Michael D Kinney Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang --- .../Csm/BiosThunk/KeyboardDxe/BiosKeyboard.c | 118 ++---------------= ---- .../Csm/BiosThunk/KeyboardDxe/KeyboardDxe.inf | 1 - 2 files changed, 10 insertions(+), 109 deletions(-) diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard= .c b/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.c index ebf03d30c1..c7797acfb8 100644 --- a/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.c +++ b/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/BiosKeyboard.c @@ -1732,98 +1732,6 @@ CheckKeyboardConnect ( } } =20 -/** - Disable NULL pointer detection. -**/ -VOID -DisableNullDetection ( - VOID - ) -{ - EFI_STATUS Status; - EFI_GCD_MEMORY_SPACE_DESCRIPTOR Desc; - - if ((PcdGet8 (PcdNullPointerDetectionPropertyMask) & BIT0) =3D=3D 0) { - return; - } - - // - // Check current capabilities and attributes - // - Status =3D gDS->GetMemorySpaceDescriptor (0, &Desc); - ASSERT_EFI_ERROR (Status); - - // - // Try to add EFI_MEMORY_RP support if necessary - // - if ((Desc.Capabilities & EFI_MEMORY_RP) =3D=3D 0) { - Desc.Capabilities |=3D EFI_MEMORY_RP; - Status =3D gDS->SetMemorySpaceCapabilities (0, EFI_PAGES_TO_SIZE(1), - Desc.Capabilities); - ASSERT_EFI_ERROR (Status); - if (EFI_ERROR (Status)) { - return; - } - } - - // - // Don't bother if EFI_MEMORY_RP is already cleared. - // - if ((Desc.Attributes & EFI_MEMORY_RP) !=3D 0) { - Desc.Attributes &=3D ~EFI_MEMORY_RP; - Status =3D gDS->SetMemorySpaceAttributes (0, EFI_PAGES_TO_SIZE(1), - Desc.Attributes); - ASSERT_EFI_ERROR (Status); - } else { - DEBUG ((DEBUG_WARN, "!!! Page 0 is supposed to be disabled !!!\r\n")); - } -} - -/** - Enable NULL pointer detection. -**/ -VOID -EnableNullDetection ( - VOID - ) -{ - EFI_STATUS Status; - EFI_GCD_MEMORY_SPACE_DESCRIPTOR Desc; - - if ((PcdGet8 (PcdNullPointerDetectionPropertyMask) & BIT0) =3D=3D 0) { - return; - } - - // - // Check current capabilities and attributes - // - Status =3D gDS->GetMemorySpaceDescriptor (0, &Desc); - ASSERT_EFI_ERROR (Status); - - // - // Try to add EFI_MEMORY_RP support if necessary - // - if ((Desc.Capabilities & EFI_MEMORY_RP) =3D=3D 0) { - Desc.Capabilities |=3D EFI_MEMORY_RP; - Status =3D gDS->SetMemorySpaceCapabilities (0, EFI_PAGES_TO_SIZE(1), - Desc.Capabilities); - ASSERT_EFI_ERROR (Status); - if (EFI_ERROR (Status)) { - return; - } - } - - // - // Don't bother if EFI_MEMORY_RP is already set. - // - if ((Desc.Attributes & EFI_MEMORY_RP) =3D=3D 0) { - Desc.Attributes |=3D EFI_MEMORY_RP; - Status =3D gDS->SetMemorySpaceAttributes (0, EFI_PAGES_TO_SIZE(1), - Desc.Attributes); - ASSERT_EFI_ERROR (Status); - } -} - /** Timer event handler: read a series of key stroke from 8042 and put them into memory key buffer.=20 @@ -1931,16 +1839,13 @@ BiosKeyboardTimerHandler ( // 0 Right Shift pressed =20 =20 - // - // Disable NULL pointer detection temporarily - // - DisableNullDetection (); - // // Clear the CTRL and ALT BDA flag // - KbFlag1 =3D *((UINT8 *) (UINTN) 0x417); // read the STATUS FLAGS 1 - KbFlag2 =3D *((UINT8 *) (UINTN) 0x418); // read STATUS FLAGS 2 + ACCESS_PAGE0_CODE ({ + KbFlag1 =3D *((UINT8 *) (UINTN) 0x417); // read the STATUS FLAGS 1 + KbFlag2 =3D *((UINT8 *) (UINTN) 0x418); // read STATUS FLAGS 2 + }); =20 DEBUG_CODE ( { @@ -2008,15 +1913,12 @@ BiosKeyboardTimerHandler ( // // Clear left alt and left ctrl BDA flag // - KbFlag2 &=3D ~(KB_LEFT_ALT_PRESSED | KB_LEFT_CTRL_PRESSED); - *((UINT8 *) (UINTN) 0x418) =3D KbFlag2; - KbFlag1 &=3D ~0x0C; =20 - *((UINT8 *) (UINTN) 0x417) =3D KbFlag1;=20 - - // - // Restore NULL pointer detection - // - EnableNullDetection (); + ACCESS_PAGE0_CODE ({ + KbFlag2 &=3D ~(KB_LEFT_ALT_PRESSED | KB_LEFT_CTRL_PRESSED); + *((UINT8 *) (UINTN) 0x418) =3D KbFlag2; + KbFlag1 &=3D ~0x0C; + *((UINT8 *) (UINTN) 0x417) =3D KbFlag1; + }); =20 // // Output EFI input key and shift/toggle state diff --git a/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/KeyboardDxe.= inf b/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/KeyboardDxe.inf index 596f4ced44..eaaedbfa9c 100644 --- a/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/KeyboardDxe.inf +++ b/IntelFrameworkModulePkg/Csm/BiosThunk/KeyboardDxe/KeyboardDxe.inf @@ -74,7 +74,6 @@ =20 [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdFastPS2Detection ## S= OMETIMES_CONSUMES - gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ## C= ONSUMES =20 [UserExtensions.TianoCore."ExtraFiles"] KeyboardDxeExtra.uni --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel