]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.c
ShellPkg/ShellLib: Constructor doesn't depend on ShellParameters
[mirror_edk2.git] / ShellPkg / Library / UefiShellTftpCommandLib / UefiShellTftpCommandLib.c
CommitLineData
68074260
RC
1/** @file\r
2 Main file for NULL named library for 'tftp' Shell command functions.\r
3\r
4 Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved. <BR>\r
5 Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>\r
6\r
7 This program and the accompanying materials\r
8 are licensed and made available under the terms and conditions of the BSD License\r
9 which accompanies this distribution. The full text of the license may be found at\r
10 http://opensource.org/licenses/bsd-license.php\r
11\r
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16#include "UefiShellTftpCommandLib.h"\r
17\r
18CONST CHAR16 gShellTftpFileName[] = L"ShellCommand";\r
19EFI_HANDLE gShellTftpHiiHandle = NULL;\r
20\r
21/**\r
22 Return the file name of the help text file if not using HII.\r
23\r
24 @return The string pointer to the file name.\r
25**/\r
26CONST CHAR16*\r
27EFIAPI\r
28ShellCommandGetManFileNameTftp (\r
29 VOID\r
30 )\r
31{\r
32 return gShellTftpFileName;\r
33}\r
34\r
35/**\r
36 Constructor for the Shell Tftp Command library.\r
37\r
38 Install the handlers for Tftp UEFI Shell command.\r
39\r
40 @param ImageHandle The image handle of the process.\r
41 @param SystemTable The EFI System Table pointer.\r
42\r
43 @retval EFI_SUCCESS The Shell command handlers were installed sucessfully.\r
44 @retval EFI_UNSUPPORTED The Shell level required was not found.\r
45**/\r
46EFI_STATUS\r
47EFIAPI\r
48ShellTftpCommandLibConstructor (\r
49 IN EFI_HANDLE ImageHandle,\r
50 IN EFI_SYSTEM_TABLE *SystemTable\r
51 )\r
52{\r
53 gShellTftpHiiHandle = NULL;\r
54\r
55 //\r
56 // check our bit of the profiles mask\r
57 //\r
58 if ((PcdGet8 (PcdShellProfileMask) & BIT3) == 0) {\r
59 return EFI_SUCCESS;\r
60 }\r
61\r
62 gShellTftpHiiHandle = HiiAddPackages (\r
63 &gShellTftpHiiGuid, gImageHandle,\r
64 UefiShellTftpCommandLibStrings, NULL\r
65 );\r
66 if (gShellTftpHiiHandle == NULL) {\r
67 return EFI_DEVICE_ERROR;\r
68 }\r
69 //\r
70 // Install our Shell command handler\r
71 //\r
72 ShellCommandRegisterCommandName (\r
73 L"tftp", ShellCommandRunTftp, ShellCommandGetManFileNameTftp, 0,\r
74 L"tftp", TRUE , gShellTftpHiiHandle, STRING_TOKEN (STR_GET_HELP_TFTP)\r
75 );\r
76\r
77 return EFI_SUCCESS;\r
78}\r
79\r
80/**\r
81 Destructor for the library. free any resources.\r
82\r
83 @param ImageHandle The image handle of the process.\r
84 @param SystemTable The EFI System Table pointer.\r
85**/\r
86EFI_STATUS\r
87EFIAPI\r
88ShellTftpCommandLibDestructor (\r
89 IN EFI_HANDLE ImageHandle,\r
90 IN EFI_SYSTEM_TABLE *SystemTable\r
91 )\r
92{\r
93 if (gShellTftpHiiHandle != NULL) {\r
94 HiiRemovePackages (gShellTftpHiiHandle);\r
95 }\r
96 return EFI_SUCCESS;\r
97}\r