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