]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Library/UefiShellDriver1CommandsLib/Reconnect.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[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 Function for 'reconnect' command.
38
39 @param[in] ImageHandle Handle to the Image (NULL if Internal).
40 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
41 **/
42 SHELL_STATUS
43 EFIAPI
44 ShellCommandRunReconnect (
45 IN EFI_HANDLE ImageHandle,
46 IN EFI_SYSTEM_TABLE *SystemTable
47 )
48 {
49 SHELL_STATUS ShellStatus;
50 LIST_ENTRY *Package;
51 CHAR16 *ProblemParam;
52 EFI_STATUS Status;
53
54 gInReconnect = TRUE;
55 ShellStatus = SHELL_SUCCESS;
56
57 //
58 // initialize the shell lib (we must be in non-auto-init...)
59 //
60 Status = ShellInitialize ();
61 ASSERT_EFI_ERROR (Status);
62
63 Status = CommandInit ();
64 ASSERT_EFI_ERROR (Status);
65
66 //
67 // parse the command line
68 //
69 Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
70 if (EFI_ERROR (Status)) {
71 if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
72 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, L"reconnect", ProblemParam);
73 FreePool (ProblemParam);
74 ShellStatus = SHELL_INVALID_PARAMETER;
75 } else {
76 ASSERT (FALSE);
77 }
78 } else {
79 ShellStatus = ShellCommandRunDisconnect (ImageHandle, SystemTable);
80 if (ShellStatus == SHELL_SUCCESS) {
81 if (ShellCommandLineGetFlag (Package, L"-r")) {
82 ConnectAllConsoles ();
83 }
84
85 ShellStatus = ShellCommandRunConnect (ImageHandle, SystemTable);
86 }
87 }
88
89 gInReconnect = FALSE;
90
91 return (ShellStatus);
92 }