]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.c
Enhance code to more safely and follow coding style.
[mirror_edk2.git] / ShellPkg / Library / UefiShellInstall1CommandsLib / UefiShellInstall1CommandsLib.c
CommitLineData
75aadf59 1/** @file\r
2 Main file for NULL named library for install1 shell command functions.\r
3\r
2398d9b1 4 Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
75aadf59 5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include "UefiShellInstall1CommandsLib.h"\r
16\r
17STATIC CONST CHAR16 mFileName[] = L"ShellCommands";\r
18EFI_HANDLE gShellInstall1HiiHandle = NULL;\r
75aadf59 19\r
2398d9b1 20/**\r
21 Function to get the filename with help context if HII will not be used.\r
22\r
23 @return The filename with help text in it.\r
24**/\r
75aadf59 25CONST CHAR16*\r
26EFIAPI\r
27ShellCommandGetManFileNameInstall1 (\r
28 VOID\r
29 )\r
30{\r
31 return (mFileName);\r
32}\r
33\r
34/**\r
35 Constructor for the Shell Level 1 Commands library.\r
36\r
37 Install the handlers for level 1 UEFI Shell 2.0 commands.\r
38\r
39 @param ImageHandle the image handle of the process\r
40 @param SystemTable the EFI System Table pointer\r
41\r
42 @retval EFI_SUCCESS the shell command handlers were installed sucessfully\r
43 @retval EFI_UNSUPPORTED the shell level required was not found.\r
44**/\r
45EFI_STATUS\r
46EFIAPI\r
47ShellInstall1CommandsLibConstructor (\r
48 IN EFI_HANDLE ImageHandle,\r
49 IN EFI_SYSTEM_TABLE *SystemTable\r
50 )\r
51{\r
52 //\r
53 // check our bit of the profiles mask\r
54 //\r
55 if ((PcdGet8(PcdShellProfileMask) & BIT2) == 0) {\r
82571fb5 56 return (EFI_SUCCESS);\r
75aadf59 57 }\r
58\r
59 gShellInstall1HiiHandle = HiiAddPackages (&gShellInstall1HiiGuid, gImageHandle, UefiShellInstall1CommandsLibStrings, NULL);\r
60 if (gShellInstall1HiiHandle == NULL) {\r
61 return (EFI_DEVICE_ERROR);\r
62 }\r
63\r
64 //\r
65 // install our shell command handlers that are always installed\r
66 //\r
67 ShellCommandRegisterCommandName(L"bcfg", ShellCommandRunBcfgInstall , ShellCommandGetManFileNameInstall1, 0, L"Install", FALSE, gShellInstall1HiiHandle, STRING_TOKEN(STR_GET_HELP_BCFG));\r
68\r
69 return (EFI_SUCCESS);\r
70}\r
71\r
72/**\r
73 Destructor for the library. free any resources.\r
2398d9b1 74\r
75 @param ImageHandle The image handle of the process.\r
76 @param SystemTable The EFI System Table pointer.\r
75aadf59 77**/\r
78EFI_STATUS\r
79EFIAPI\r
80ShellInstall1CommandsLibDestructor (\r
81 IN EFI_HANDLE ImageHandle,\r
82 IN EFI_SYSTEM_TABLE *SystemTable\r
83 )\r
84{\r
85 if (gShellInstall1HiiHandle != NULL) {\r
86 HiiRemovePackages(gShellInstall1HiiHandle);\r
87 }\r
88 return (EFI_SUCCESS);\r
89}\r