]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.c
add support to easily remove profiles and shell levels. the libraries will not do...
[mirror_edk2.git] / ShellPkg / Library / UefiShellInstall1CommandsLib / UefiShellInstall1CommandsLib.c
1 /** @file
2 Main file for NULL named library for install1 shell command functions.
3
4 Copyright (c) 2010 - 2011, 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 "UefiShellInstall1CommandsLib.h"
16
17 STATIC CONST CHAR16 mFileName[] = L"ShellCommands";
18 EFI_HANDLE gShellInstall1HiiHandle = NULL;
19 CONST EFI_GUID gShellInstall1HiiGuid = \
20 { \
21 0x7d574d54, 0xd364, 0x4d4a, { 0x95, 0xe3, 0x49, 0x45, 0xdb, 0x7a, 0xd3, 0xee } \
22 };
23
24 /**
25 Function to get the filename with help context if HII will not be used.
26
27 @return The filename with help text in it.
28 **/
29 CONST CHAR16*
30 EFIAPI
31 ShellCommandGetManFileNameInstall1 (
32 VOID
33 )
34 {
35 return (mFileName);
36 }
37
38 /**
39 Constructor for the Shell Level 1 Commands library.
40
41 Install the handlers for level 1 UEFI Shell 2.0 commands.
42
43 @param ImageHandle the image handle of the process
44 @param SystemTable the EFI System Table pointer
45
46 @retval EFI_SUCCESS the shell command handlers were installed sucessfully
47 @retval EFI_UNSUPPORTED the shell level required was not found.
48 **/
49 EFI_STATUS
50 EFIAPI
51 ShellInstall1CommandsLibConstructor (
52 IN EFI_HANDLE ImageHandle,
53 IN EFI_SYSTEM_TABLE *SystemTable
54 )
55 {
56 //
57 // check our bit of the profiles mask
58 //
59 if ((PcdGet8(PcdShellProfileMask) & BIT2) == 0) {
60 return (EFI_SUCCESS);
61 }
62
63 gShellInstall1HiiHandle = HiiAddPackages (&gShellInstall1HiiGuid, gImageHandle, UefiShellInstall1CommandsLibStrings, NULL);
64 if (gShellInstall1HiiHandle == NULL) {
65 return (EFI_DEVICE_ERROR);
66 }
67
68 //
69 // install our shell command handlers that are always installed
70 //
71 ShellCommandRegisterCommandName(L"bcfg", ShellCommandRunBcfgInstall , ShellCommandGetManFileNameInstall1, 0, L"Install", FALSE, gShellInstall1HiiHandle, STRING_TOKEN(STR_GET_HELP_BCFG));
72
73 return (EFI_SUCCESS);
74 }
75
76 /**
77 Destructor for the library. free any resources.
78
79 @param ImageHandle The image handle of the process.
80 @param SystemTable The EFI System Table pointer.
81 **/
82 EFI_STATUS
83 EFIAPI
84 ShellInstall1CommandsLibDestructor (
85 IN EFI_HANDLE ImageHandle,
86 IN EFI_SYSTEM_TABLE *SystemTable
87 )
88 {
89 if (gShellInstall1HiiHandle != NULL) {
90 HiiRemovePackages(gShellInstall1HiiHandle);
91 }
92 return (EFI_SUCCESS);
93 }