From: "Gao, Liming" <liming.gao@intel.com>
To: "Ni, Ruiyu" <ruiyu.ni@intel.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Kinney, Michael D" <michael.d.kinney@intel.com>
Subject: Re: [PATCH] ShellPkg/map: Recognize CDROM change
Date: Wed, 26 Jul 2017 09:09:32 +0000 [thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14D75C3E0@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <20170725074519.240664-1-ruiyu.ni@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
>-----Original Message-----
>From: Ni, Ruiyu
>Sent: Tuesday, July 25, 2017 3:45 PM
>To: edk2-devel@lists.01.org
>Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming
><liming.gao@intel.com>
>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 <ruiyu.ni@intel.com>
>Cc: Michael D Kinney <michael.d.kinney@intel.com>
>Cc: Liming Gao <liming.gao@intel.com>
>---
> 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.<BR>
>+ Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
> (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
> (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
>
>@@ -980,6 +980,57 @@ STATIC CONST SHELL_PARAM_ITEM MapParamList[]
>= {
> };
>
> /**
>+ 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 = 0; Index < HandleCount; Index++) {
>+ Status = 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 invalid 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
prev parent reply other threads:[~2017-07-26 9:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-25 7:45 [PATCH] ShellPkg/map: Recognize CDROM change Ruiyu Ni
2017-07-26 9:09 ` Gao, Liming [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A89E2EF3DFEDB4C8BFDE51014F606A14D75C3E0@shsmsx102.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox