summaryrefslogtreecommitdiffstats
path: root/ShellPkg
diff options
context:
space:
mode:
Diffstat (limited to 'ShellPkg')
-rw-r--r--[-rwxr-xr-x]ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c (renamed from ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c)92
-rw-r--r--ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.h (renamed from ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.h)40
-rw-r--r--ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.uni (renamed from ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.uni)0
-rw-r--r--ShellPkg/DynamicCommand/TftpDynamicCommand/TftpApp.c54
-rw-r--r--ShellPkg/DynamicCommand/TftpDynamicCommand/TftpApp.inf (renamed from ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.inf)34
-rw-r--r--ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.c131
-rw-r--r--ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf64
-rw-r--r--ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.c97
-rw-r--r--ShellPkg/ShellPkg.dsc11
9 files changed, 368 insertions, 155 deletions
diff --git a/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c
index fbde3bfe60..8569c966dd 100755..100644
--- a/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c
+++ b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c
@@ -2,7 +2,7 @@
The implementation for the 'tftp' Shell command.
Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>
- Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved. <BR>
+ Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved. <BR>
(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
This program and the accompanying materials
@@ -14,9 +14,10 @@
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
-#include "UefiShellTftpCommandLib.h"
+#include "Tftp.h"
#define IP4_CONFIG2_INTERFACE_INFO_NAME_LENGTH 32
+EFI_HANDLE mTftpHiiHandle;
/*
Constant strings and definitions related to the message indicating the amount of
@@ -256,8 +257,7 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
**/
SHELL_STATUS
-EFIAPI
-ShellCommandRunTftp (
+RunTftp (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
@@ -315,7 +315,7 @@ ShellCommandRunTftp (
if ((Status == EFI_VOLUME_CORRUPTED) &&
(ProblemParam != NULL) ) {
ShellPrintHiiEx (
- -1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellTftpHiiHandle,
+ -1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), mTftpHiiHandle,
L"tftp", ProblemParam
);
FreePool (ProblemParam);
@@ -332,14 +332,14 @@ ShellCommandRunTftp (
if (ParamCount > 4) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY),
- gShellTftpHiiHandle, L"tftp"
+ mTftpHiiHandle, L"tftp"
);
goto Error;
}
if (ParamCount < 3) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW),
- gShellTftpHiiHandle, L"tftp"
+ mTftpHiiHandle, L"tftp"
);
goto Error;
}
@@ -354,7 +354,7 @@ ShellCommandRunTftp (
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
- gShellTftpHiiHandle, L"tftp", ValueStr
+ mTftpHiiHandle, L"tftp", ValueStr
);
goto Error;
}
@@ -416,7 +416,7 @@ ShellCommandRunTftp (
if (Mtftp4ConfigData.TimeoutValue == 0) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
- gShellTftpHiiHandle, L"tftp", ValueStr
+ mTftpHiiHandle, L"tftp", ValueStr
);
goto Error;
}
@@ -430,7 +430,7 @@ ShellCommandRunTftp (
if (BlockSize < MTFTP_MIN_BLKSIZE || BlockSize > MTFTP_MAX_BLKSIZE) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
- gShellTftpHiiHandle, L"tftp", ValueStr
+ mTftpHiiHandle, L"tftp", ValueStr
);
goto Error;
}
@@ -450,7 +450,7 @@ ShellCommandRunTftp (
if (EFI_ERROR (Status) || (HandleCount == 0)) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_NO_NIC),
- gShellTftpHiiHandle
+ mTftpHiiHandle
);
goto Error;
}
@@ -465,7 +465,7 @@ ShellCommandRunTftp (
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_NIC_NAME),
- gShellTftpHiiHandle, NicNumber, Status
+ mTftpHiiHandle, NicNumber, Status
);
continue;
}
@@ -487,7 +487,7 @@ ShellCommandRunTftp (
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_OPEN_PROTOCOL),
- gShellTftpHiiHandle, NicName, Status
+ mTftpHiiHandle, NicName, Status
);
continue;
}
@@ -496,7 +496,7 @@ ShellCommandRunTftp (
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_CONFIGURE),
- gShellTftpHiiHandle, NicName, Status
+ mTftpHiiHandle, NicName, Status
);
goto NextHandle;
}
@@ -505,7 +505,7 @@ ShellCommandRunTftp (
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_FILE_SIZE),
- gShellTftpHiiHandle, RemoteFilePath, NicName, Status
+ mTftpHiiHandle, RemoteFilePath, NicName, Status
);
goto NextHandle;
}
@@ -514,7 +514,7 @@ ShellCommandRunTftp (
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_DOWNLOAD),
- gShellTftpHiiHandle, RemoteFilePath, NicName, Status
+ mTftpHiiHandle, RemoteFilePath, NicName, Status
);
goto NextHandle;
}
@@ -534,7 +534,7 @@ ShellCommandRunTftp (
if (EFI_ERROR (Status)) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL),
- gShellTftpHiiHandle, L"tftp", LocalFilePath
+ mTftpHiiHandle, L"tftp", LocalFilePath
);
goto NextHandle;
}
@@ -546,7 +546,7 @@ ShellCommandRunTftp (
} else {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_WRITE),
- gShellTftpHiiHandle, LocalFilePath, Status
+ mTftpHiiHandle, LocalFilePath, Status
);
}
ShellCloseFile (&FileHandle);
@@ -568,7 +568,7 @@ ShellCommandRunTftp (
if ((UserNicName != NULL) && (!NicFound)) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_ERR_NIC_NOT_FOUND),
- gShellTftpHiiHandle, UserNicName
+ mTftpHiiHandle, UserNicName
);
}
@@ -607,7 +607,7 @@ StringToUint16 (
if (Val > MAX_UINT16) {
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),
- gShellTftpHiiHandle, L"tftp", ValueStr
+ mTftpHiiHandle, L"tftp", ValueStr
);
return FALSE;
}
@@ -948,13 +948,13 @@ DownloadFile (
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_TFTP_DOWNLOADING),
- gShellTftpHiiHandle, FilePath
+ mTftpHiiHandle, FilePath
);
Status = Mtftp4->ReadFile (Mtftp4, &Mtftp4Token);
ShellPrintHiiEx (
-1, -1, NULL, STRING_TOKEN (STR_GEN_CRLF),
- gShellTftpHiiHandle
+ mTftpHiiHandle
);
Error :
@@ -1052,3 +1052,51 @@ CheckPacket (
return EFI_SUCCESS;
}
+
+/**
+ Retrive HII package list from ImageHandle and publish to HII database.
+
+ @param ImageHandle The image handle of the process.
+
+ @return HII handle.
+**/
+EFI_HANDLE
+InitializeHiiPackage (
+ EFI_HANDLE ImageHandle
+ )
+{
+ EFI_STATUS Status;
+ EFI_HII_PACKAGE_LIST_HEADER *PackageList;
+ EFI_HANDLE HiiHandle;
+
+ //
+ // Retrieve HII package list from ImageHandle
+ //
+ Status = gBS->OpenProtocol (
+ ImageHandle,
+ &gEfiHiiPackageListProtocolGuid,
+ (VOID **)&PackageList,
+ ImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ return NULL;
+ }
+
+ //
+ // Publish HII package list to HII Database.
+ //
+ Status = gHiiDatabase->NewPackageList (
+ gHiiDatabase,
+ PackageList,
+ NULL,
+ &HiiHandle
+ );
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ return NULL;
+ }
+ return HiiHandle;
+}
diff --git a/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.h b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.h
index 6767f95166..9963eab3eb 100644
--- a/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.h
+++ b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.h
@@ -1,7 +1,7 @@
/** @file
- header file for NULL named library for 'tftp' Shell command functions.
+ Header file for 'tftp' command functions.
- Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved. <BR>
+ Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved. <BR>
Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>
This program and the accompanying materials
@@ -14,13 +14,12 @@
**/
-#ifndef _UEFI_SHELL_TFTP_COMMAND_LIB_H_
-#define _UEFI_SHELL_TFTP_COMMAND_LIB_H_
+#ifndef _TFTP_H_
+#define _TFTP_H_
#include <Uefi.h>
-#include <Guid/ShellLibHiiGuid.h>
-
+#include <Protocol/HiiPackageList.h>
#include <Protocol/ServiceBinding.h>
#include <Protocol/Mtftp4.h>
@@ -28,7 +27,6 @@
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
-#include <Library/ShellCommandLib.h>
#include <Library/ShellLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
@@ -36,8 +34,9 @@
#include <Library/HiiLib.h>
#include <Library/NetLib.h>
#include <Library/PrintLib.h>
+#include <Library/UefiHiiServicesLib.h>
-extern EFI_HANDLE gShellTftpHiiHandle;
+extern EFI_HANDLE mTftpHiiHandle;
typedef struct {
UINTN FileSize;
@@ -48,14 +47,29 @@ typedef struct {
/**
Function for 'tftp' command.
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
+ @param[in] ImageHandle The image handle.
+ @param[in] SystemTable The system table.
+
+ @retval SHELL_SUCCESS Command completed successfully.
+ @retval SHELL_INVALID_PARAMETER Command usage error.
+ @retval SHELL_ABORTED The user aborts the operation.
+ @retval value Unknown error.
**/
SHELL_STATUS
-EFIAPI
-ShellCommandRunTftp (
+RunTftp (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
-#endif /* _UEFI_SHELL_TFTP_COMMAND_LIB_H_ */
+/**
+ Retrive HII package list from ImageHandle and publish to HII database.
+
+ @param ImageHandle The image handle of the process.
+
+ @return HII handle.
+**/
+EFI_HANDLE
+InitializeHiiPackage (
+ EFI_HANDLE ImageHandle
+ );
+#endif // _TFTP_H_
diff --git a/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.uni b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.uni
index 4f4447d67a..4f4447d67a 100644
--- a/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.uni
+++ b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.uni
diff --git a/ShellPkg/DynamicCommand/TftpDynamicCommand/TftpApp.c b/ShellPkg/DynamicCommand/TftpDynamicCommand/TftpApp.c
new file mode 100644
index 0000000000..23f2bf7d9b
--- /dev/null
+++ b/ShellPkg/DynamicCommand/TftpDynamicCommand/TftpApp.c
@@ -0,0 +1,54 @@
+/** @file
+ Entrypoint of "tftp" shell standalone application.
+
+ Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved. <BR>
+ Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+#include "Tftp.h"
+
+//
+// String token ID of help message text.
+// Shell supports to find help message in the resource section of an application image if
+// .MAN file is not found. This global variable is added to make build tool recognizes
+// that the help string is consumed by user and then build tool will add the string into
+// the resource section. Thus the application can use '-?' option to show help message in
+// Shell.
+//
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (STR_GET_HELP_TFTP);
+
+/**
+ Entry point of Tftp standalone application.
+
+ @param ImageHandle The image handle of the process.
+ @param SystemTable The EFI System Table pointer.
+
+ @retval EFI_SUCCESS Tftp command is executed sucessfully.
+ @retval EFI_ABORTED HII package was failed to initialize.
+ @retval others Other errors when executing tftp command.
+**/
+EFI_STATUS
+EFIAPI
+TftpAppInitialize (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ mTftpHiiHandle = InitializeHiiPackage (ImageHandle);
+ if (mTftpHiiHandle == NULL) {
+ return EFI_ABORTED;
+ }
+
+ Status = (EFI_STATUS)RunTftp (ImageHandle, SystemTable);
+ HiiRemovePackages (mTftpHiiHandle);
+ return Status;
+}
diff --git a/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.inf b/ShellPkg/DynamicCommand/TftpDynamicCommand/TftpApp.inf
index 96db258920..185bd4557a 100644
--- a/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.inf
+++ b/ShellPkg/DynamicCommand/TftpDynamicCommand/TftpApp.inf
@@ -1,7 +1,7 @@
## @file
-# Provides Shell 'tftp' command functions
+# Provides Shell 'tftp' standalone application.
#
-# Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved. <BR>
+# Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved. <BR>
# Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>
#
# This program and the accompanying materials
@@ -16,19 +16,21 @@
[Defines]
INF_VERSION = 0x00010006
- BASE_NAME = UefiShellTftpCommandLib
- FILE_GUID = D2B61A25-9835-4E5D-906A-15615E1FF668
+ BASE_NAME = tftp
+ FILE_GUID = 8DC58D0D-67F5-4B97-9DFC-E442BB9A5648
MODULE_TYPE = UEFI_APPLICATION
VERSION_STRING = 1.0
- LIBRARY_CLASS = NULL|UEFI_APPLICATION UEFI_DRIVER
- CONSTRUCTOR = ShellTftpCommandLibConstructor
- DESTRUCTOR = ShellTftpCommandLibDestructor
+ ENTRY_POINT = TftpAppInitialize
+#
+# This flag specifies whether HII resource section is generated into PE image.
+#
+ UEFI_HII_RESOURCE_SECTION = TRUE
[Sources.common]
- UefiShellTftpCommandLib.uni
- UefiShellTftpCommandLib.c
- UefiShellTftpCommandLib.h
+ Tftp.uni
+ Tftp.h
Tftp.c
+ TftpApp.c
[Packages]
MdePkg/MdePkg.dec
@@ -40,22 +42,18 @@
BaseLib
BaseMemoryLib
DebugLib
- ShellCommandLib
ShellLib
UefiLib
UefiRuntimeServicesTableLib
UefiBootServicesTableLib
- PcdLib
+ UefiApplicationEntryPoint
+ UefiHiiServicesLib
HiiLib
FileHandleLib
NetLib
-[Pcd]
- gEfiShellPkgTokenSpaceGuid.PcdShellProfileMask ## CONSUMES
-
[Protocols]
gEfiManagedNetworkServiceBindingProtocolGuid ## CONSUMES
gEfiMtftp4ServiceBindingProtocolGuid ## CONSUMES
-
-[Guids]
- gShellTftpHiiGuid ## CONSUMES ## HII
+ gEfiMtftp4ProtocolGuid ## CONSUMES
+ gEfiHiiPackageListProtocolGuid ## CONSUMES
diff --git a/ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.c b/ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.c
new file mode 100644
index 0000000000..928ef08468
--- /dev/null
+++ b/ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.c
@@ -0,0 +1,131 @@
+/** @file
+ Produce "tftp" shell dynamic command.
+
+ Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved. <BR>
+ Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+#include "Tftp.h"
+#include <Protocol/ShellDynamicCommand.h>
+
+/**
+ This is the shell command handler function pointer callback type. This
+ function handles the command when it is invoked in the shell.
+
+ @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.
+ @param[in] SystemTable The pointer to the system table.
+ @param[in] ShellParameters The parameters associated with the command.
+ @param[in] Shell The instance of the shell protocol used in the context
+ of processing this command.
+
+ @return EFI_SUCCESS the operation was sucessful
+ @return other the operation failed.
+**/
+SHELL_STATUS
+EFIAPI
+TftpCommandHandler (
+ IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
+ IN EFI_SYSTEM_TABLE *SystemTable,
+ IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
+ IN EFI_SHELL_PROTOCOL *Shell
+ )
+{
+ gEfiShellParametersProtocol = ShellParameters;
+ return RunTftp (gImageHandle, SystemTable);
+}
+
+/**
+ This is the command help handler function pointer callback type. This
+ function is responsible for displaying help information for the associated
+ command.
+
+ @param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.
+ @param[in] Language The pointer to the language string to use.
+
+ @return string Pool allocated help string, must be freed by caller
+**/
+CHAR16 *
+EFIAPI
+TftpCommandGetHelp (
+ IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,
+ IN CONST CHAR8 *Language
+ )
+{
+ return HiiGetString (mTftpHiiHandle, STRING_TOKEN (STR_GET_HELP_TFTP), Language);
+}
+
+EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mTftpDynamicCommand = {
+ L"tftp",
+ TftpCommandHandler,
+ TftpCommandGetHelp
+};
+
+/**
+ Entry point of Tftp Dynamic Command.
+
+ Produce the DynamicCommand protocol to handle "tftp" command.
+
+ @param ImageHandle The image handle of the process.
+ @param SystemTable The EFI System Table pointer.
+
+ @retval EFI_SUCCESS Tftp command is executed sucessfully.
+ @retval EFI_ABORTED HII package was failed to initialize.
+ @retval others Other errors when executing tftp command.
+**/
+EFI_STATUS
+EFIAPI
+TftpCommandInitialize (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ mTftpHiiHandle = InitializeHiiPackage (ImageHandle);
+ if (mTftpHiiHandle == NULL) {
+ return EFI_ABORTED;
+ }
+
+ Status = gBS->InstallProtocolInterface (
+ &ImageHandle,
+ &gEfiShellDynamicCommandProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &mTftpDynamicCommand
+ );
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+}
+
+/**
+ Tftp driver unload handler.
+
+ @param ImageHandle The image handle of the process.
+
+ @retval EFI_SUCCESS The image is unloaded.
+ @retval Others Failed to unload the image.
+**/
+EFI_STATUS
+EFIAPI
+TftpUnload (
+ IN EFI_HANDLE ImageHandle
+)
+{
+ EFI_STATUS Status;
+ Status = gBS->UninstallProtocolInterface (
+ ImageHandle,
+ &gEfiShellDynamicCommandProtocolGuid,
+ &mTftpDynamicCommand
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ HiiRemovePackages (mTftpHiiHandle);
+ return EFI_SUCCESS;
+}
diff --git a/ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf b/ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf
new file mode 100644
index 0000000000..85d04b77dc
--- /dev/null
+++ b/ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf
@@ -0,0 +1,64 @@
+## @file
+# Provides Shell 'tftp' dynamic command.
+#
+# Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved. <BR>
+# Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = tftpDynamicCommand
+ FILE_GUID = A487A478-51EF-48AA-8794-7BEE2A0562F1
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = TftpCommandInitialize
+ UNLOAD_IMAGE = TftpUnload
+#
+# This flag specifies whether HII resource section is generated into PE image.
+#
+ UEFI_HII_RESOURCE_SECTION = TRUE
+
+[Sources.common]
+ Tftp.uni
+ Tftp.h
+ Tftp.c
+ TftpDynamicCommand.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ ShellPkg/ShellPkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+ MemoryAllocationLib
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ ShellLib
+ UefiLib
+ UefiRuntimeServicesTableLib
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+ UefiHiiServicesLib
+ HiiLib
+ FileHandleLib
+ NetLib
+
+[Protocols]
+ gEfiManagedNetworkServiceBindingProtocolGuid ## CONSUMES
+ gEfiMtftp4ServiceBindingProtocolGuid ## CONSUMES
+ gEfiMtftp4ProtocolGuid ## CONSUMES
+ gEfiHiiPackageListProtocolGuid ## CONSUMES
+ gEfiShellDynamicCommandProtocolGuid ## PRODUCES
+
+[DEPEX]
+ TRUE
diff --git a/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.c b/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.c
deleted file mode 100644
index 22c81b8d2a..0000000000
--- a/ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/** @file
- Main file for NULL named library for 'tftp' Shell command functions.
-
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved. <BR>
- Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>
-
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-#include "UefiShellTftpCommandLib.h"
-
-CONST CHAR16 gShellTftpFileName[] = L"ShellCommand";
-EFI_HANDLE gShellTftpHiiHandle = NULL;
-
-/**
- Return the file name of the help text file if not using HII.
-
- @return The string pointer to the file name.
-**/
-CONST CHAR16*
-EFIAPI
-ShellCommandGetManFileNameTftp (
- VOID
- )
-{
- return gShellTftpFileName;
-}
-
-/**
- Constructor for the Shell Tftp Command library.
-
- Install the handlers for Tftp UEFI Shell command.
-
- @param ImageHandle The image handle of the process.
- @param SystemTable The EFI System Table pointer.
-
- @retval EFI_SUCCESS The Shell command handlers were installed sucessfully.
- @retval EFI_UNSUPPORTED The Shell level required was not found.
-**/
-EFI_STATUS
-EFIAPI
-ShellTftpCommandLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- gShellTftpHiiHandle = NULL;
-
- //
- // check our bit of the profiles mask
- //
- if ((PcdGet8 (PcdShellProfileMask) & BIT3) == 0) {
- return EFI_SUCCESS;
- }
-
- gShellTftpHiiHandle = HiiAddPackages (
- &gShellTftpHiiGuid, gImageHandle,
- UefiShellTftpCommandLibStrings, NULL
- );
- if (gShellTftpHiiHandle == NULL) {
- return EFI_DEVICE_ERROR;
- }
- //
- // Install our Shell command handler
- //
- ShellCommandRegisterCommandName (
- L"tftp", ShellCommandRunTftp, ShellCommandGetManFileNameTftp, 0,
- L"tftp", TRUE , gShellTftpHiiHandle, STRING_TOKEN (STR_GET_HELP_TFTP)
- );
-
- return EFI_SUCCESS;
-}
-
-/**
- Destructor for the library. free any resources.
-
- @param ImageHandle The image handle of the process.
- @param SystemTable The EFI System Table pointer.
-**/
-EFI_STATUS
-EFIAPI
-ShellTftpCommandLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- if (gShellTftpHiiHandle != NULL) {
- HiiRemovePackages (gShellTftpHiiHandle);
- }
- return EFI_SUCCESS;
-}
diff --git a/ShellPkg/ShellPkg.dsc b/ShellPkg/ShellPkg.dsc
index ed6ac4356d..8fc20709f4 100644
--- a/ShellPkg/ShellPkg.dsc
+++ b/ShellPkg/ShellPkg.dsc
@@ -25,6 +25,7 @@
[LibraryClasses.common]
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
+ UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathProtocol.inf
!if $(TARGET) == RELEASE
@@ -79,7 +80,6 @@
[PcdsFixedAtBuild]
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xFF
- gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|16000
!ifdef $(NO_SHELL_PROFILES)
gEfiShellPkgTokenSpaceGuid.PcdShellProfileMask|0x00
@@ -103,7 +103,6 @@
ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf
ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf
ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.inf
- ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.inf
ShellPkg/Library/UefiDpLib/UefiDpLib.inf {
<LibraryClasses>
@@ -112,6 +111,8 @@
}
ShellPkg/Application/Shell/Shell.inf {
+ <PcdsFixedAtBuild>
+ gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
<LibraryClasses>
NULL|ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf
NULL|ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf
@@ -125,11 +126,11 @@
!ifdef $(INCLUDE_DP)
NULL|ShellPkg/Library/UefiDpLib/UefiDpLib.inf
!endif #$(INCLUDE_DP)
-!ifdef $(INCLUDE_TFTP_COMMAND)
- NULL|ShellPkg/Library/UefiShellTftpCommandLib/UefiShellTftpCommandLib.inf
-!endif #$(INCLUDE_TFTP_COMMAND)
!endif #$(NO_SHELL_PROFILES)
}
+ ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf
+ ShellPkg/DynamicCommand/TftpDynamicCommand/TftpApp.inf
+
[BuildOptions]
*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES