1 | /** @file
|
---|
2 | Main file for NULL named library for level 3 shell command functions.
|
---|
3 |
|
---|
4 | (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
|
---|
5 | Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>
|
---|
6 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
7 |
|
---|
8 | **/
|
---|
9 | #include "UefiShellLevel3CommandsLib.h"
|
---|
10 |
|
---|
11 | CONST CHAR16 gShellLevel3FileName[] = L"ShellCommands";
|
---|
12 | EFI_HII_HANDLE gShellLevel3HiiHandle = NULL;
|
---|
13 |
|
---|
14 | /**
|
---|
15 | return the filename to get help from is not using HII.
|
---|
16 |
|
---|
17 | @retval The filename.
|
---|
18 | **/
|
---|
19 | CONST CHAR16*
|
---|
20 | EFIAPI
|
---|
21 | ShellCommandGetManFileNameLevel3 (
|
---|
22 | VOID
|
---|
23 | )
|
---|
24 | {
|
---|
25 | return (gShellLevel3FileName);
|
---|
26 | }
|
---|
27 |
|
---|
28 | /**
|
---|
29 | Constructor for the Shell Level 3 Commands library.
|
---|
30 |
|
---|
31 | Install the handlers for level 3 UEFI Shell 2.0 commands.
|
---|
32 |
|
---|
33 | @param ImageHandle the image handle of the process
|
---|
34 | @param SystemTable the EFI System Table pointer
|
---|
35 |
|
---|
36 | @retval EFI_SUCCESS the shell command handlers were installed sucessfully
|
---|
37 | @retval EFI_UNSUPPORTED the shell level required was not found.
|
---|
38 | **/
|
---|
39 | EFI_STATUS
|
---|
40 | EFIAPI
|
---|
41 | ShellLevel3CommandsLibConstructor (
|
---|
42 | IN EFI_HANDLE ImageHandle,
|
---|
43 | IN EFI_SYSTEM_TABLE *SystemTable
|
---|
44 | )
|
---|
45 | {
|
---|
46 | gShellLevel3HiiHandle = NULL;
|
---|
47 | //
|
---|
48 | // if shell level is less than 3 do nothing
|
---|
49 | //
|
---|
50 | if (PcdGet8(PcdShellSupportLevel) < 3) {
|
---|
51 | return (EFI_SUCCESS);
|
---|
52 | }
|
---|
53 |
|
---|
54 | gShellLevel3HiiHandle = HiiAddPackages (&gShellLevel3HiiGuid, gImageHandle, UefiShellLevel3CommandsLibStrings, NULL);
|
---|
55 | if (gShellLevel3HiiHandle == NULL) {
|
---|
56 | return (EFI_DEVICE_ERROR);
|
---|
57 | }
|
---|
58 | //
|
---|
59 | // install our shell command handlers that are always installed
|
---|
60 | //
|
---|
61 | // Note: that Time, Timezone, and Date are part of level 2 library
|
---|
62 | //
|
---|
63 | ShellCommandRegisterCommandName(L"type", ShellCommandRunType , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_TYPE));
|
---|
64 | ShellCommandRegisterCommandName(L"touch", ShellCommandRunTouch , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_TOUCH));
|
---|
65 | ShellCommandRegisterCommandName(L"ver", ShellCommandRunVer , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_VER));
|
---|
66 | ShellCommandRegisterCommandName(L"alias", ShellCommandRunAlias , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_ALIAS));
|
---|
67 | ShellCommandRegisterCommandName(L"cls", ShellCommandRunCls , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_CLS));
|
---|
68 | ShellCommandRegisterCommandName(L"echo", ShellCommandRunEcho , ShellCommandGetManFileNameLevel3, 3, L"", FALSE, gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_ECHO));
|
---|
69 | ShellCommandRegisterCommandName(L"pause", ShellCommandRunPause , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_PAUSE));
|
---|
70 | ShellCommandRegisterCommandName(L"getmtc", ShellCommandRunGetMtc , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_GETMTC));
|
---|
71 | ShellCommandRegisterCommandName(L"help", ShellCommandRunHelp , ShellCommandGetManFileNameLevel3, 3, L"", TRUE , gShellLevel3HiiHandle, STRING_TOKEN(STR_GET_HELP_HELP));
|
---|
72 |
|
---|
73 | ShellCommandRegisterAlias(L"type", L"cat");
|
---|
74 |
|
---|
75 | return (EFI_SUCCESS);
|
---|
76 | }
|
---|
77 |
|
---|
78 | /**
|
---|
79 | Destructor for the library. free any resources.
|
---|
80 |
|
---|
81 | @param ImageHandle The image handle of the process.
|
---|
82 | @param SystemTable The EFI System Table pointer.
|
---|
83 | **/
|
---|
84 | EFI_STATUS
|
---|
85 | EFIAPI
|
---|
86 | ShellLevel3CommandsLibDestructor (
|
---|
87 | IN EFI_HANDLE ImageHandle,
|
---|
88 | IN EFI_SYSTEM_TABLE *SystemTable
|
---|
89 | )
|
---|
90 | {
|
---|
91 | if (gShellLevel3HiiHandle != NULL) {
|
---|
92 | HiiRemovePackages(gShellLevel3HiiHandle);
|
---|
93 | }
|
---|
94 | return (EFI_SUCCESS);
|
---|
95 | }
|
---|