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