From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: ray.ni@intel.com) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by groups.io with SMTP; Sat, 04 May 2019 20:22:44 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 May 2019 20:22:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,431,1549958400"; d="scan'208";a="148349244" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga003.jf.intel.com with ESMTP; 04 May 2019 20:22:44 -0700 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sat, 4 May 2019 20:22:42 -0700 Received: from shsmsx107.ccr.corp.intel.com (10.239.4.96) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sat, 4 May 2019 20:22:43 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.33]) by SHSMSX107.ccr.corp.intel.com ([169.254.9.7]) with mapi id 14.03.0415.000; Sun, 5 May 2019 11:22:40 +0800 From: "Ni, Ray" To: "devel@edk2.groups.io" , "Liu, Zhiguang" CC: "Justen, Jordan L" , Andrew Fish Subject: Re: [edk2-devel] [PATCH 2/2] EmulatorPkg: Save the modified order after rebooting Thread-Topic: [edk2-devel] [PATCH 2/2] EmulatorPkg: Save the modified order after rebooting Thread-Index: AQHU/kv/3GtcRY9tS0S8ME3q8LMs6qZb5yXA Date: Sun, 5 May 2019 03:22:40 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C125ED9@SHSMSX104.ccr.corp.intel.com> References: <20190429052443.2908-1-zhiguang.liu@intel.com> <20190429052443.2908-3-zhiguang.liu@intel.com> In-Reply-To: <20190429052443.2908-3-zhiguang.liu@intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: ray.ni@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Zhiguang, You could avoid using memory mapped FV device path (guided FV device path) by adding FvNameGuid to EmulatorPkg.fdf file under [FV.RvRecovery] section= . [FV.FvRecovery] FvNameGuid =3D 6D99E806-3D38-42c2-A095-5F4300BFD7DC Thanks, Ray > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of > Zhiguang Liu > Sent: Monday, April 29, 2019 1:25 PM > To: devel@edk2.groups.io > Cc: Justen, Jordan L ; Andrew Fish > ; Ni, Ray > Subject: [edk2-devel] [PATCH 2/2] EmulatorPkg: Save the modified order > after rebooting >=20 > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D1650 >=20 > The reason why boot order changed is that everytime Emulator > restarts, the memory mapped address will change. > This patch correct the device path to the right one. >=20 > Signed-off-by: Zhiguang Liu >=20 > Cc: Jordan Justen > Cc: Andrew Fish > Cc: Ray Ni > --- > EmulatorPkg/Library/PlatformBmLib/PlatformBm.c | 62 > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > ++-- > 1 file changed, 60 insertions(+), 2 deletions(-) >=20 > diff --git a/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c > b/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c > index 191ce58cfb..28329e4f52 100644 > --- a/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c > +++ b/EmulatorPkg/Library/PlatformBmLib/PlatformBm.c > @@ -332,6 +332,63 @@ PlatformBdsRegisterStaticBootOptions ( > PrintXY (10, 50, &White, &Black, L"Enter to boot directly."); > } >=20 > +/** > + Change the device path of the boot options to the correct one. > + and return whether it is the first time to start up emulator since la= st build. > + @param FirstBoot Return 1 if it is the first time to start up emu= lator since > last build. > +**/ > +VOID > +EFIAPI > +PlatformBootManagerChangeDevicePath ( > + OUT UINTN *FirstBoot > + ) > +{ > + UINTN BootOptionCount; > + EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; > + UINTN Index,LastIndex; > + UINTN Flag=3D0; > + *FirstBoot=3D1; > + BootOptions =3D EfiBootManagerGetLoadOptions (&BootOptionCount, > LoadOptionTypeBoot); > + for (Index =3D 0; Index < BootOptionCount; Index++) > + { > + if ((!StrCmp(L"UEFI Enter Setup", BootOptions[Index].Description)) = || > + (!StrCmp(L"UEFI BootManagerMenuApp", > BootOptions[Index].Description)) || > + (!StrCmp(L"UEFI Shell", BootOptions[Index].Description))) > + { > + EFI_DEVICE_PATH_PROTOCOL *mypath; > + EFI_DEVICE_PATH_PROTOCOL *mynextnode; > + EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; > + gBS->HandleProtocol( > + gImageHandle, > + &gEfiLoadedImageProtocolGuid, > + (VOID **)&LoadedImage); > + mynextnode =3D NextDevicePathNode(BootOptions[Index].FilePath); > + mypath =3D DevicePathFromHandle(LoadedImage->DeviceHandle); > + while (!IsDevicePathEndType(mynextnode)) > + { > + mypath =3D AppendDevicePathNode( > + mypath, > + mynextnode); > + mynextnode =3D NextDevicePathNode(mynextnode); > + } > + BootOptions[Index].FilePath =3D DuplicateDevicePath(mypath); > + FreePool(mypath); > + EfiBootManagerLoadOptionToVariable(&BootOptions[Index]); > + if(!StrCmp(L"UEFI Enter Setup", BootOptions[Index].Description)){ > + if (Flag!=3D0){ > + > EfiBootManagerDeleteLoadOptionVariable(BootOptions[LastIndex].OptionN > umber, LoadOptionTypeBoot); > + } > + Flag++; > + LastIndex=3DIndex; > + } > + if(!StrCmp(L"UEFI Shell", BootOptions[Index].Description)){ > + *FirstBoot=3D0; > + } > + > + } > + } > +} > + > /** > Do the platform specific action after the console is connected. >=20 > @@ -348,7 +405,7 @@ PlatformBootManagerAfterConsole ( > VOID > ) > { > - > + UINTN FirstBoot=3D1; > // > // Go the different platform policy with different boot mode > // Notes: this part code can be change with the table policy > @@ -374,9 +431,10 @@ PlatformBootManagerAfterConsole ( > case BOOT_WITH_DEFAULT_SETTINGS: > default: > PlatformBdsDiagnostics (IGNORE, TRUE); > - PlatformBdsRegisterStaticBootOptions (); > + PlatformBootManagerChangeDevicePath(&FirstBoot); > PlatformBdsConnectSequence (); > EfiBootManagerRefreshAllBootOption (); > + PlatformBdsRegisterStaticBootOptions (); > break; > } > } > -- > 2.21.0.windows.1 >=20 >=20 >=20