public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] ShellPkg: Add '-nc' flag support in 'disconnect' command
@ 2016-09-22 19:49 Tapan Shah
  2016-09-22 21:21 ` Carsey, Jaben
  0 siblings, 1 reply; 2+ messages in thread
From: Tapan Shah @ 2016-09-22 19:49 UTC (permalink / raw)
  To: edk2-devel; +Cc: jaben.carsey, Tapan Shah

As per ECR 1416, latest UEFI Shell 2.2 specification:
Define a behavior where 'disconnect -r' will disconnect drivers
from all devices but it will reconnect all consoles.
If -nc flag is used (e.g. 'disconnect -r -nc') then disconnect drivers
from all devices and don't reconnect consoles.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Tapan Shah <tapandshah@hpe.com>
---
 .../Library/UefiShellDriver1CommandsLib/Disconnect.c   | 18 +++++++++++++++++-
 .../UefiShellDriver1CommandsLib.uni                    | 14 +++++++++++---
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c
index 9afbf07..e9205a3 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c
@@ -1,6 +1,7 @@
 /** @file
   Main file for Disconnect shell Driver1 function.
 
+  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
   Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials
@@ -17,6 +18,7 @@
 
 STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
   {L"-r", TypeFlag},
+  {L"-nc", TypeFlag},
   {NULL, TypeMax}
   };
 
@@ -132,8 +134,22 @@ ShellCommandRunDisconnect (
         ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDriver1HiiHandle, L"disconnect");  
         ShellStatus = SHELL_INVALID_PARAMETER;
       } else {
-        Status = DisconnectAll();
+         Status = DisconnectAll ();
+         //
+         // Reconnect all consoles if -nc is not provided
+         //
+         if (!ShellCommandLineGetFlag (Package, L"-nc")){
+           ShellConnectFromDevPaths (L"ConInDev");
+           ShellConnectFromDevPaths (L"ConOutDev");
+           ShellConnectFromDevPaths (L"ErrOutDev");
+           ShellConnectFromDevPaths (L"ErrOut");
+           ShellConnectFromDevPaths (L"ConIn");
+           ShellConnectFromDevPaths (L"ConOut");
+         }
       }
+    } else if (ShellCommandLineGetFlag (Package, L"-nc")) {
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDriver1HiiHandle, L"disconnect");  
+      ShellStatus = SHELL_INVALID_PARAMETER;
     } else {
       if (ShellCommandLineGetCount(Package) > 4){
         ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"disconnect");  
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni
index a14469a..c6b8fcd 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni
@@ -1,5 +1,6 @@
 // /**
 //
+// (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
 // (C) Copyright 2012-2015 Hewlett-Packard Development Company, L.P.<BR>
 // Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
 // This program and the accompanying materials
@@ -299,11 +300,14 @@
 "Disconnects one or more drivers from the specified devices. \r\n"
 ".SH SYNOPSIS\r\n"
 " \r\n"
-"DISCONNECT DeviceHandle [DriverHandle [ChildHandle]] [-r] \r\n"
+"DISCONNECT DeviceHandle [DriverHandle [ChildHandle]] \r\n"
+"DISCONNECT [-r] [-nc] \r\n"
 ".SH OPTIONS\r\n"
 " \r\n"
 "NOTES:\r\n"
-"  -r           - Disconnects all drivers from all devices.\r\n"
+"  -r           - Disconnects all drivers from all devices, then reconnect\r\n"
+"                 consoles.\r\n"
+"  -nc          - Do not reconnect the console devices.\r\n"
 "  DeviceHandle - Specifies a device handle (a hexadecimal number). If not specified, then\r\n"
 "                 disconnect DriverHandle.\r\n"
 "  DriverHandle - Specifies a driver handle (a hexadecimal number).\r\n"
@@ -324,9 +328,13 @@
 ".SH EXAMPLES\r\n"
 " \r\n"
 "EXAMPLES:\r\n"
-"  * To disconnect all drivers from all devices:\r\n"
+"  * To disconnect all drivers from all devices, then reconnect console\r\n"
+"    devices:\r\n"
 "    Shell> disconnect -r\r\n"
 " \r\n"
+"  * To disconnect all drivers from all devices, including console devices:\r\n"
+"    Shell> disconnect -r -nc\r\n"
+" \r\n"
 "  * To disconnect all drivers from device 0x28:\r\n"
 "    fs0:\> disconnect 28\r\n"
 " \r\n"
-- 
1.9.5.msysgit.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ShellPkg: Add '-nc' flag support in 'disconnect' command
  2016-09-22 19:49 [PATCH] ShellPkg: Add '-nc' flag support in 'disconnect' command Tapan Shah
@ 2016-09-22 21:21 ` Carsey, Jaben
  0 siblings, 0 replies; 2+ messages in thread
From: Carsey, Jaben @ 2016-09-22 21:21 UTC (permalink / raw)
  To: Tapan Shah, edk2-devel@lists.01.org; +Cc: Carsey, Jaben

Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
And commited.

> -----Original Message-----
> From: Tapan Shah [mailto:tapandshah@hpe.com]
> Sent: Thursday, September 22, 2016 12:49 PM
> To: edk2-devel@lists.01.org
> Cc: Carsey, Jaben <jaben.carsey@intel.com>; Tapan Shah
> <tapandshah@hpe.com>
> Subject: [PATCH] ShellPkg: Add '-nc' flag support in 'disconnect' command
> Importance: High
> 
> As per ECR 1416, latest UEFI Shell 2.2 specification:
> Define a behavior where 'disconnect -r' will disconnect drivers
> from all devices but it will reconnect all consoles.
> If -nc flag is used (e.g. 'disconnect -r -nc') then disconnect drivers
> from all devices and don't reconnect consoles.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Tapan Shah <tapandshah@hpe.com>
> ---
>  .../Library/UefiShellDriver1CommandsLib/Disconnect.c   | 18
> +++++++++++++++++-
>  .../UefiShellDriver1CommandsLib.uni                    | 14 +++++++++++---
>  2 files changed, 28 insertions(+), 4 deletions(-)
> 
> diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c
> b/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c
> index 9afbf07..e9205a3 100644
> --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c
> +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c
> @@ -1,6 +1,7 @@
>  /** @file
>    Main file for Disconnect shell Driver1 function.
> 
> +  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
>    (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
>    Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
>    This program and the accompanying materials
> @@ -17,6 +18,7 @@
> 
>  STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
>    {L"-r", TypeFlag},
> +  {L"-nc", TypeFlag},
>    {NULL, TypeMax}
>    };
> 
> @@ -132,8 +134,22 @@ ShellCommandRunDisconnect (
>          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW),
> gShellDriver1HiiHandle, L"disconnect");
>          ShellStatus = SHELL_INVALID_PARAMETER;
>        } else {
> -        Status = DisconnectAll();
> +         Status = DisconnectAll ();
> +         //
> +         // Reconnect all consoles if -nc is not provided
> +         //
> +         if (!ShellCommandLineGetFlag (Package, L"-nc")){
> +           ShellConnectFromDevPaths (L"ConInDev");
> +           ShellConnectFromDevPaths (L"ConOutDev");
> +           ShellConnectFromDevPaths (L"ErrOutDev");
> +           ShellConnectFromDevPaths (L"ErrOut");
> +           ShellConnectFromDevPaths (L"ConIn");
> +           ShellConnectFromDevPaths (L"ConOut");
> +         }
>        }
> +    } else if (ShellCommandLineGetFlag (Package, L"-nc")) {
> +      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW),
> gShellDriver1HiiHandle, L"disconnect");
> +      ShellStatus = SHELL_INVALID_PARAMETER;
>      } else {
>        if (ShellCommandLineGetCount(Package) > 4){
>          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY),
> gShellDriver1HiiHandle, L"disconnect");
> diff --git
> a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Command
> sLib.uni
> b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Comman
> dsLib.uni
> index a14469a..c6b8fcd 100644
> ---
> a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Command
> sLib.uni
> +++
> b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Comman
> dsLib.uni
> @@ -1,5 +1,6 @@
>  // /**
>  //
> +// (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
>  // (C) Copyright 2012-2015 Hewlett-Packard Development Company,
> L.P.<BR>
>  // Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
>  // This program and the accompanying materials
> @@ -299,11 +300,14 @@
>  "Disconnects one or more drivers from the specified devices. \r\n"
>  ".SH SYNOPSIS\r\n"
>  " \r\n"
> -"DISCONNECT DeviceHandle [DriverHandle [ChildHandle]] [-r] \r\n"
> +"DISCONNECT DeviceHandle [DriverHandle [ChildHandle]] \r\n"
> +"DISCONNECT [-r] [-nc] \r\n"
>  ".SH OPTIONS\r\n"
>  " \r\n"
>  "NOTES:\r\n"
> -"  -r           - Disconnects all drivers from all devices.\r\n"
> +"  -r           - Disconnects all drivers from all devices, then reconnect\r\n"
> +"                 consoles.\r\n"
> +"  -nc          - Do not reconnect the console devices.\r\n"
>  "  DeviceHandle - Specifies a device handle (a hexadecimal number). If not
> specified, then\r\n"
>  "                 disconnect DriverHandle.\r\n"
>  "  DriverHandle - Specifies a driver handle (a hexadecimal number).\r\n"
> @@ -324,9 +328,13 @@
>  ".SH EXAMPLES\r\n"
>  " \r\n"
>  "EXAMPLES:\r\n"
> -"  * To disconnect all drivers from all devices:\r\n"
> +"  * To disconnect all drivers from all devices, then reconnect console\r\n"
> +"    devices:\r\n"
>  "    Shell> disconnect -r\r\n"
>  " \r\n"
> +"  * To disconnect all drivers from all devices, including console devices:\r\n"
> +"    Shell> disconnect -r -nc\r\n"
> +" \r\n"
>  "  * To disconnect all drivers from device 0x28:\r\n"
>  "    fs0:\> disconnect 28\r\n"
>  " \r\n"
> --
> 1.9.5.msysgit.0



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-09-22 21:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-22 19:49 [PATCH] ShellPkg: Add '-nc' flag support in 'disconnect' command Tapan Shah
2016-09-22 21:21 ` Carsey, Jaben

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox