From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=zhichao.gao@intel.com; receiver=edk2-devel@lists.01.org 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 8CDF6211F1E0A for ; Mon, 1 Apr 2019 22:49:59 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Apr 2019 22:49:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,298,1549958400"; d="scan'208";a="139225816" Received: from gaozhic-mobl.ccr.corp.intel.com ([10.239.196.135]) by orsmga003.jf.intel.com with ESMTP; 01 Apr 2019 22:49:57 -0700 From: Zhichao Gao To: edk2-devel@lists.01.org Cc: Bret Barkelew , Jian J Wang , Ray Ni , Star Zeng , Liming Gao , Sean Brogan , Michael Turner Date: Tue, 2 Apr 2019 13:49:45 +0800 Message-Id: <20190402054945.9712-3-zhichao.gao@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20190402054945.9712-1-zhichao.gao@intel.com> References: <20190402054945.9712-1-zhichao.gao@intel.com> Subject: [PATCH 2/2] MdeModulePkg/BdsDxe: Use a pcd to set OS indications bit X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2019 05:49:59 -0000 From: Bret Barkelew REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1678 Use the pcd PcdPlatformRecoverySupport to control whether to set the PlatformRecovery#### variable and whether to set the EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY bit of variable "OsIndicationsSupported". Cc: Jian J Wang Cc: Ray Ni Cc: Star Zeng Cc: Liming Gao Cc: Sean Brogan Cc: Michael Turner Cc: Bret Barkelew Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhichao Gao --- MdeModulePkg/Universal/BdsDxe/BdsDxe.inf | 1 + MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 74 +++++++++++++----------- 2 files changed, 41 insertions(+), 34 deletions(-) diff --git a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf index 82eb8aafc6..9caabbce7f 100644 --- a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf +++ b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf @@ -101,6 +101,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable ## SOMETIMES_CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdPlatformRecoverySupport ## CONSUMES [Depex] TRUE diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c index 8946d79ab2..ade77adb7d 100644 --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c @@ -552,10 +552,14 @@ BdsFormalizeOSIndicationVariable ( // Status = EfiBootManagerGetBootManagerMenu (&BootManagerMenu); if (Status != EFI_NOT_FOUND) { - OsIndicationSupport = EFI_OS_INDICATIONS_BOOT_TO_FW_UI | EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY; + OsIndicationSupport = EFI_OS_INDICATIONS_BOOT_TO_FW_UI; EfiBootManagerFreeLoadOption (&BootManagerMenu); } else { - OsIndicationSupport = EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY; + OsIndicationSupport = 0; + } + + if (PcdGetBool (PcdPlatformRecoverySupport)) { + OsIndicationSupport |= EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY; } Status = gRT->SetVariable ( @@ -769,41 +773,43 @@ BdsEntry ( // InitializeLanguage (TRUE); - // - // System firmware must include a PlatformRecovery#### variable specifying - // a short-form File Path Media Device Path containing the platform default - // file path for removable media - // - FilePath = FileDevicePath (NULL, EFI_REMOVABLE_MEDIA_FILE_NAME); - Status = EfiBootManagerInitializeLoadOption ( - &LoadOption, - LoadOptionNumberUnassigned, - LoadOptionTypePlatformRecovery, - LOAD_OPTION_ACTIVE, - L"Default PlatformRecovery", - FilePath, - NULL, - 0 - ); - ASSERT_EFI_ERROR (Status); - LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadOptionTypePlatformRecovery); - if (EfiBootManagerFindLoadOption (&LoadOption, LoadOptions, LoadOptionCount) == -1) { - for (Index = 0; Index < LoadOptionCount; Index++) { - // - // The PlatformRecovery#### options are sorted by OptionNumber. - // Find the the smallest unused number as the new OptionNumber. - // - if (LoadOptions[Index].OptionNumber != Index) { - break; + if (PcdGetBool (PcdPlatformRecoverySupport)) { + // + // System firmware must include a PlatformRecovery#### variable specifying + // a short-form File Path Media Device Path containing the platform default + // file path for removable media + // + FilePath = FileDevicePath (NULL, EFI_REMOVABLE_MEDIA_FILE_NAME); + Status = EfiBootManagerInitializeLoadOption ( + &LoadOption, + LoadOptionNumberUnassigned, + LoadOptionTypePlatformRecovery, + LOAD_OPTION_ACTIVE, + L"Default PlatformRecovery", + FilePath, + NULL, + 0 + ); + ASSERT_EFI_ERROR (Status); + LoadOptions = EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadOptionTypePlatformRecovery); + if (EfiBootManagerFindLoadOption (&LoadOption, LoadOptions, LoadOptionCount) == -1) { + for (Index = 0; Index < LoadOptionCount; Index++) { + // + // The PlatformRecovery#### options are sorted by OptionNumber. + // Find the the smallest unused number as the new OptionNumber. + // + if (LoadOptions[Index].OptionNumber != Index) { + break; + } } + LoadOption.OptionNumber = Index; + Status = EfiBootManagerLoadOptionToVariable (&LoadOption); + ASSERT_EFI_ERROR (Status); } - LoadOption.OptionNumber = Index; - Status = EfiBootManagerLoadOptionToVariable (&LoadOption); - ASSERT_EFI_ERROR (Status); + EfiBootManagerFreeLoadOption (&LoadOption); + FreePool (FilePath); + EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount); } - EfiBootManagerFreeLoadOption (&LoadOption); - FreePool (FilePath); - EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount); // // Report Status Code to indicate connecting drivers will happen -- 2.21.0.windows.1