]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Library/UefiShellDriver1CommandsLib/Reconnect.c
ShellPkg/UefiShellLib: clarify workaround for unfixable EdkShell bug
[mirror_edk2.git] / ShellPkg / Library / UefiShellDriver1CommandsLib / Reconnect.c
1 /** @file
2 Main file for Reconnect shell Driver1 function.
3
4 Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
5 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
6 (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 **/
10
11 #include "UefiShellDriver1CommandsLib.h"
12
13 STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
14 {L"-r", TypeFlag},
15 {NULL, TypeMax}
16 };
17
18 /**
19 Connect all the possible console devices.
20
21 **/
22 VOID
23 ConnectAllConsoles (
24 VOID
25 )
26 {
27 ShellConnectFromDevPaths(L"ConInDev");
28 ShellConnectFromDevPaths(L"ConOutDev");
29 ShellConnectFromDevPaths(L"ErrOutDev");
30
31 ShellConnectFromDevPaths(L"ErrOut");
32 ShellConnectFromDevPaths(L"ConIn");
33 ShellConnectFromDevPaths(L"ConOut");
34 }
35
36
37 /**
38 Function for 'reconnect' command.
39
40 @param[in] ImageHandle Handle to the Image (NULL if Internal).
41 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
42 **/
43 SHELL_STATUS
44 EFIAPI
45 ShellCommandRunReconnect (
46 IN EFI_HANDLE ImageHandle,
47 IN EFI_SYSTEM_TABLE *SystemTable
48 )
49 {
50 SHELL_STATUS ShellStatus;
51 LIST_ENTRY *Package;
52 CHAR16 *ProblemParam;
53 EFI_STATUS Status;
54
55 gInReconnect = TRUE;
56 ShellStatus = SHELL_SUCCESS;
57
58 //
59 // initialize the shell lib (we must be in non-auto-init...)
60 //
61 Status = ShellInitialize();
62 ASSERT_EFI_ERROR(Status);
63
64 Status = CommandInit();
65 ASSERT_EFI_ERROR(Status);
66
67 //
68 // parse the command line
69 //
70 Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
71 if (EFI_ERROR(Status)) {
72 if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
73 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, L"reconnect", ProblemParam);
74 FreePool(ProblemParam);
75 ShellStatus = SHELL_INVALID_PARAMETER;
76 } else {
77 ASSERT(FALSE);
78 }
79 } else {
80 ShellStatus = ShellCommandRunDisconnect(ImageHandle, SystemTable);
81 if (ShellStatus == SHELL_SUCCESS) {
82 if (ShellCommandLineGetFlag(Package, L"-r")) {
83 ConnectAllConsoles();
84 }
85 ShellStatus = ShellCommandRunConnect(ImageHandle, SystemTable);
86 }
87 }
88
89 gInReconnect = FALSE;
90
91 return (ShellStatus);
92 }
93