]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Library/UefiShellDriver1CommandsLib/Reconnect.c
ShellPkg: Connect all the consoles in "reconnect -r".
[mirror_edk2.git] / ShellPkg / Library / UefiShellDriver1CommandsLib / Reconnect.c
1 /** @file
2 Main file for Reconnect shell Driver1 function.
3
4 Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include "UefiShellDriver1CommandsLib.h"
16
17 STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
18 {L"-r", TypeFlag},
19 {NULL, TypeMax}
20 };
21
22 /**
23 Connect all the possible console devices.
24
25 **/
26 VOID
27 ConnectAllConsoles (
28 VOID
29 )
30 {
31 ShellConnectFromDevPaths(L"ConInDev");
32 ShellConnectFromDevPaths(L"ConOutDev");
33 ShellConnectFromDevPaths(L"ErrOutDev");
34
35 ShellConnectFromDevPaths(L"ErrOut");
36 ShellConnectFromDevPaths(L"ConIn");
37 ShellConnectFromDevPaths(L"ConOut");
38 }
39
40
41 /**
42 Function for 'reconnect' command.
43
44 @param[in] ImageHandle Handle to the Image (NULL if Internal).
45 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
46 **/
47 SHELL_STATUS
48 EFIAPI
49 ShellCommandRunReconnect (
50 IN EFI_HANDLE ImageHandle,
51 IN EFI_SYSTEM_TABLE *SystemTable
52 )
53 {
54 SHELL_STATUS ShellStatus;
55 LIST_ENTRY *Package;
56 CHAR16 *ProblemParam;
57 EFI_STATUS Status;
58
59 gInReconnect = TRUE;
60 ShellStatus = SHELL_SUCCESS;
61
62 //
63 // initialize the shell lib (we must be in non-auto-init...)
64 //
65 Status = ShellInitialize();
66 ASSERT_EFI_ERROR(Status);
67
68 Status = CommandInit();
69 ASSERT_EFI_ERROR(Status);
70
71 //
72 // parse the command line
73 //
74 Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
75 if (EFI_ERROR(Status)) {
76 if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
77 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, ProblemParam);
78 FreePool(ProblemParam);
79 ShellStatus = SHELL_INVALID_PARAMETER;
80 } else {
81 ASSERT(FALSE);
82 }
83 } else {
84 ShellStatus = ShellCommandRunDisconnect(ImageHandle, SystemTable);
85 if (ShellStatus == SHELL_SUCCESS) {
86 if (ShellCommandLineGetFlag(Package, L"-r")) {
87 ConnectAllConsoles();
88 }
89 ShellStatus = ShellCommandRunConnect(ImageHandle, SystemTable);
90 }
91 }
92
93 gInReconnect = FALSE;
94
95 return (ShellStatus);
96 }
97