From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 70D6321AEB0A0 for ; Wed, 26 Jul 2017 02:07:46 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jul 2017 02:09:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,414,1496127600"; d="scan'208";a="1155509545" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga001.jf.intel.com with ESMTP; 26 Jul 2017 02:09:36 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 26 Jul 2017 02:09:35 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.146]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.116]) with mapi id 14.03.0319.002; Wed, 26 Jul 2017 17:09:33 +0800 From: "Gao, Liming" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Kinney, Michael D" Thread-Topic: [PATCH] ShellPkg/map: Recognize CDROM change Thread-Index: AQHTBRpONH72QZR3eE6J53T7fkCVvqJl05KQ Date: Wed, 26 Jul 2017 09:09:32 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14D75C3E0@shsmsx102.ccr.corp.intel.com> References: <20170725074519.240664-1-ruiyu.ni@intel.com> In-Reply-To: <20170725074519.240664-1-ruiyu.ni@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] ShellPkg/map: Recognize CDROM change 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: , X-List-Received-Date: Wed, 26 Jul 2017 09:07:46 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: Ni, Ruiyu >Sent: Tuesday, July 25, 2017 3:45 PM >To: edk2-devel@lists.01.org >Cc: Kinney, Michael D ; Gao, Liming > >Subject: [PATCH] ShellPkg/map: Recognize CDROM change > >The patch adds logic to probe the media change for physical >block devices. So that when media change happens, the BlockIo >is re-installed again. > >It fixes the issue when CDROM is removed UEFI Shell still shows >the BlockIo in the output of "map -r". > >Contributed-under: TianoCore Contribution Agreement 1.0 >Signed-off-by: Ruiyu Ni >Cc: Michael D Kinney >Cc: Liming Gao >--- > ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c | 54 >++++++++++++++++++++++- > 1 file changed, 53 insertions(+), 1 deletion(-) > >diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c >b/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c >index 20eb528fa3..3f5925f507 100644 >--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c >+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c >@@ -1,7 +1,7 @@ > /** @file > Main file for map shell level 2 command. > >- Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
>+ Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
> (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.
> (C) Copyright 2016 Hewlett Packard Enterprise Development LP
> >@@ -980,6 +980,57 @@ STATIC CONST SHELL_PARAM_ITEM MapParamList[] >=3D { > }; > > /** >+ The routine issues dummy read for every physical block device to cause >+ the BlockIo re-installed if media change happened. >+**/ >+VOID >+ProbeForMediaChange ( >+ VOID >+ ) >+{ >+ EFI_STATUS Status; >+ UINTN HandleCount; >+ EFI_HANDLE *Handles; >+ EFI_BLOCK_IO_PROTOCOL *BlockIo; >+ UINTN Index; >+ >+ gBS->LocateHandleBuffer ( >+ ByProtocol, >+ &gEfiBlockIoProtocolGuid, >+ NULL, >+ &HandleCount, >+ &Handles >+ ); >+ // >+ // Probe for media change for every physical block io >+ // >+ for (Index =3D 0; Index < HandleCount; Index++) { >+ Status =3D gBS->HandleProtocol ( >+ Handles[Index], >+ &gEfiBlockIoProtocolGuid, >+ (VOID **) &BlockIo >+ ); >+ if (!EFI_ERROR (Status)) { >+ if (!BlockIo->Media->LogicalPartition) { >+ // >+ // Per spec: >+ // The function (ReadBlocks) must return EFI_NO_MEDIA or >+ // EFI_MEDIA_CHANGED even if LBA, BufferSize, or Buffer are inv= alid so >the caller can probe >+ // for changes in media state. >+ // >+ BlockIo->ReadBlocks ( >+ BlockIo, >+ BlockIo->Media->MediaId, >+ 0, >+ 0, >+ NULL >+ ); >+ } >+ } >+ } >+} >+ >+/** > Function for 'map' command. > > @param[in] ImageHandle Handle to the Image (NULL if Internal). >@@ -1087,6 +1138,7 @@ ShellCommandRunMap ( > || ShellCommandLineGetFlag(Package, L"-u") > || ShellCommandLineGetFlag(Package, L"-t") > ){ >+ ProbeForMediaChange (); > if ( ShellCommandLineGetFlag(Package, L"-r")) { > // > // Do the reset >-- >2.12.2.windows.2