2 The implementation for the 'tftp' Shell command.
4 Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "UefiShellTftpCommandLib.h"
18 Constant strings and definitions related to the message indicating the amount of
19 progress in the dowloading of a TFTP file.
22 // Frame for the progression slider
23 STATIC CONST CHAR16 mTftpProgressFrame
[] = L
"[ ]";
25 // Number of steps in the progression slider
26 #define TFTP_PROGRESS_SLIDER_STEPS ((sizeof (mTftpProgressFrame) / sizeof (CHAR16)) - 3)
28 // Size in number of characters plus one (final zero) of the message to
29 // indicate the progress of a TFTP download. The format is "[(progress slider:
30 // 40 characters)] (nb of KBytes downloaded so far: 7 characters) Kb". There
31 // are thus the number of characters in mTftpProgressFrame[] plus 11 characters
32 // (2 // spaces, "Kb" and seven characters for the number of KBytes).
33 #define TFTP_PROGRESS_MESSAGE_SIZE ((sizeof (mTftpProgressFrame) / sizeof (CHAR16)) + 12)
35 // String to delete the TFTP progress message to be able to update it :
36 // (TFTP_PROGRESS_MESSAGE_SIZE-1) '\b'
37 STATIC CONST CHAR16 mTftpProgressDelete
[] = L
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
39 STATIC BOOLEAN
StringToUint16 (
40 IN CONST CHAR16
*ValueStr
,
44 STATIC EFI_STATUS
GetNicName (
45 IN EFI_HANDLE ControllerHandle
,
50 STATIC EFI_STATUS
CreateServiceChildAndOpenProtocol (
51 IN EFI_HANDLE ControllerHandle
,
52 IN EFI_GUID
*ServiceBindingProtocolGuid
,
53 IN EFI_GUID
*ProtocolGuid
,
54 OUT EFI_HANDLE
*ChildHandle
,
58 STATIC VOID
CloseProtocolAndDestroyServiceChild (
59 IN EFI_HANDLE ControllerHandle
,
60 IN EFI_GUID
*ServiceBindingProtocolGuid
,
61 IN EFI_GUID
*ProtocolGuid
,
62 IN EFI_HANDLE ChildHandle
65 STATIC EFI_STATUS
GetFileSize (
66 IN EFI_MTFTP4_PROTOCOL
*Mtftp4
,
67 IN CONST CHAR8
*FilePath
,
71 STATIC EFI_STATUS
DownloadFile (
72 IN EFI_MTFTP4_PROTOCOL
*Mtftp4
,
73 IN CONST CHAR16
*FilePath
,
74 IN CONST CHAR8
*AsciiFilePath
,
79 STATIC EFI_STATUS
CheckPacket (
80 IN EFI_MTFTP4_PROTOCOL
*This
,
81 IN EFI_MTFTP4_TOKEN
*Token
,
83 IN EFI_MTFTP4_PACKET
*Packet
86 EFI_MTFTP4_CONFIG_DATA DefaultMtftp4ConfigData
= {
87 TRUE
, // Use default setting
88 { { 0, 0, 0, 0 } }, // StationIp - Not relevant as UseDefaultSetting=TRUE
89 { { 0, 0, 0, 0 } }, // SubnetMask - Not relevant as UseDefaultSetting=TRUE
90 0, // LocalPort - Automatically assigned port number.
91 { { 0, 0, 0, 0 } }, // GatewayIp - Not relevant as UseDefaultSetting=TRUE
92 { { 0, 0, 0, 0 } }, // ServerIp - Not known yet
93 69, // InitialServerPort - Standard TFTP server port
94 6, // TryCount - Max number of retransmissions.
95 4 // TimeoutValue - Retransmission timeout in seconds.
98 STATIC CONST SHELL_PARAM_ITEM ParamList
[] = {
108 Function for 'tftp' command.
110 @param[in] ImageHandle Handle to the Image (NULL if Internal).
111 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
113 @return SHELL_SUCCESS The 'tftp' command completed successfully.
114 @return SHELL_ABORTED The Shell Library initialization failed.
115 @return SHELL_INVALID_PARAMETER At least one of the command's arguments is
117 @return SHELL_OUT_OF_RESOURCES A memory allocation failed.
118 @return SHELL_NOT_FOUND Network Interface Card not found or server
124 ShellCommandRunTftp (
125 IN EFI_HANDLE ImageHandle
,
126 IN EFI_SYSTEM_TABLE
*SystemTable
129 SHELL_STATUS ShellStatus
;
131 LIST_ENTRY
*CheckPackage
;
132 CHAR16
*ProblemParam
;
134 CONST CHAR16
*UserNicName
;
136 CONST CHAR16
*ValueStr
;
137 CONST CHAR16
*RemoteFilePath
;
138 CHAR8
*AsciiRemoteFilePath
;
139 CONST CHAR16
*Walker
;
140 CONST CHAR16
*LocalFilePath
;
141 EFI_MTFTP4_CONFIG_DATA Mtftp4ConfigData
;
145 CHAR16 NicName
[IP4_NIC_NAME_LENGTH
];
146 EFI_HANDLE ControllerHandle
;
147 EFI_HANDLE Mtftp4ChildHandle
;
148 EFI_MTFTP4_PROTOCOL
*Mtftp4
;
151 SHELL_FILE_HANDLE FileHandle
;
153 ShellStatus
= SHELL_INVALID_PARAMETER
;
156 AsciiRemoteFilePath
= NULL
;
160 // Initialize the Shell library (we must be in non-auto-init...)
162 Status
= ShellInitialize ();
163 if (EFI_ERROR (Status
)) {
164 ASSERT_EFI_ERROR (Status
);
165 return SHELL_ABORTED
;
169 // Parse the command line.
171 Status
= ShellCommandLineParse (ParamList
, &CheckPackage
, &ProblemParam
, TRUE
);
172 if (EFI_ERROR (Status
)) {
173 if ((Status
== EFI_VOLUME_CORRUPTED
) &&
174 (ProblemParam
!= NULL
) ) {
176 -1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellTftpHiiHandle
,
177 L
"tftp", ProblemParam
179 FreePool (ProblemParam
);
187 // Check the number of parameters
189 ParamCount
= ShellCommandLineGetCount (CheckPackage
);
190 if (ParamCount
> 4) {
192 -1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_MANY
),
193 gShellTftpHiiHandle
, L
"tftp"
197 if (ParamCount
< 3) {
199 -1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_FEW
),
200 gShellTftpHiiHandle
, L
"tftp"
205 Mtftp4ConfigData
= DefaultMtftp4ConfigData
;
208 // Check the host IPv4 address
210 ValueStr
= ShellCommandLineGetRawValue (CheckPackage
, 1);
211 Status
= NetLibStrToIp4 (ValueStr
, &Mtftp4ConfigData
.ServerIp
);
212 if (EFI_ERROR (Status
)) {
214 -1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV
),
215 gShellTftpHiiHandle
, L
"tftp", ValueStr
220 RemoteFilePath
= ShellCommandLineGetRawValue (CheckPackage
, 2);
221 AsciiRemoteFilePath
= AllocatePool (
222 (StrLen (RemoteFilePath
) + 1) * sizeof (CHAR8
)
224 if (AsciiRemoteFilePath
== NULL
) {
225 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
228 UnicodeStrToAsciiStr (RemoteFilePath
, AsciiRemoteFilePath
);
230 if (ParamCount
== 4) {
231 LocalFilePath
= ShellCommandLineGetRawValue (CheckPackage
, 3);
233 Walker
= RemoteFilePath
+ StrLen (RemoteFilePath
);
234 while ((--Walker
) >= RemoteFilePath
) {
235 if ((*Walker
== L
'\\') ||
236 (*Walker
== L
'/' ) ) {
240 LocalFilePath
= Walker
+ 1;
244 // Get the name of the Network Interface Card to be used if any.
246 UserNicName
= ShellCommandLineGetValue (CheckPackage
, L
"-i");
248 ValueStr
= ShellCommandLineGetValue (CheckPackage
, L
"-l");
249 if (ValueStr
!= NULL
) {
250 if (!StringToUint16 (ValueStr
, &Mtftp4ConfigData
.LocalPort
)) {
255 ValueStr
= ShellCommandLineGetValue (CheckPackage
, L
"-r");
256 if (ValueStr
!= NULL
) {
257 if (!StringToUint16 (ValueStr
, &Mtftp4ConfigData
.InitialServerPort
)) {
262 ValueStr
= ShellCommandLineGetValue (CheckPackage
, L
"-c");
263 if (ValueStr
!= NULL
) {
264 if (!StringToUint16 (ValueStr
, &Mtftp4ConfigData
.TryCount
)) {
269 ValueStr
= ShellCommandLineGetValue (CheckPackage
, L
"-t");
270 if (ValueStr
!= NULL
) {
271 if (!StringToUint16 (ValueStr
, &Mtftp4ConfigData
.TimeoutValue
)) {
274 if (Mtftp4ConfigData
.TimeoutValue
== 0) {
276 -1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV
),
277 gShellTftpHiiHandle
, L
"tftp", ValueStr
284 // Locate all MTFTP4 Service Binding protocols
286 ShellStatus
= SHELL_NOT_FOUND
;
287 Status
= gBS
->LocateHandleBuffer (
289 &gEfiManagedNetworkServiceBindingProtocolGuid
,
294 if (EFI_ERROR (Status
) || (HandleCount
== 0)) {
296 -1, -1, NULL
, STRING_TOKEN (STR_TFTP_ERR_NO_NIC
),
303 (NicNumber
< HandleCount
) && (ShellStatus
!= SHELL_SUCCESS
);
305 ControllerHandle
= Handles
[NicNumber
];
308 Status
= GetNicName (ControllerHandle
, NicNumber
, NicName
);
309 if (EFI_ERROR (Status
)) {
311 -1, -1, NULL
, STRING_TOKEN (STR_TFTP_ERR_NIC_NAME
),
312 gShellTftpHiiHandle
, NicNumber
, Status
317 if (UserNicName
!= NULL
) {
318 if (StrCmp (NicName
, UserNicName
) != 0) {
324 Status
= CreateServiceChildAndOpenProtocol (
326 &gEfiMtftp4ServiceBindingProtocolGuid
,
327 &gEfiMtftp4ProtocolGuid
,
331 if (EFI_ERROR (Status
)) {
333 -1, -1, NULL
, STRING_TOKEN (STR_TFTP_ERR_OPEN_PROTOCOL
),
334 gShellTftpHiiHandle
, NicName
, Status
339 Status
= Mtftp4
->Configure (Mtftp4
, &Mtftp4ConfigData
);
340 if (EFI_ERROR (Status
)) {
342 -1, -1, NULL
, STRING_TOKEN (STR_TFTP_ERR_CONFIGURE
),
343 gShellTftpHiiHandle
, NicName
, Status
348 Status
= GetFileSize (Mtftp4
, AsciiRemoteFilePath
, &FileSize
);
349 if (EFI_ERROR (Status
)) {
351 -1, -1, NULL
, STRING_TOKEN (STR_TFTP_ERR_FILE_SIZE
),
352 gShellTftpHiiHandle
, RemoteFilePath
, NicName
, Status
357 Status
= DownloadFile (Mtftp4
, RemoteFilePath
, AsciiRemoteFilePath
, FileSize
, &Data
);
358 if (EFI_ERROR (Status
)) {
360 -1, -1, NULL
, STRING_TOKEN (STR_TFTP_ERR_DOWNLOAD
),
361 gShellTftpHiiHandle
, RemoteFilePath
, NicName
, Status
366 if (!EFI_ERROR (ShellFileExists (LocalFilePath
))) {
367 ShellDeleteFileByName (LocalFilePath
);
370 Status
= ShellOpenFileByName (
373 EFI_FILE_MODE_CREATE
|
374 EFI_FILE_MODE_WRITE
|
378 if (EFI_ERROR (Status
)) {
380 -1, -1, NULL
, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL
),
381 gShellTftpHiiHandle
, L
"tftp", LocalFilePath
386 Status
= ShellWriteFile (FileHandle
, &FileSize
, Data
);
387 if (!EFI_ERROR (Status
)) {
388 ShellStatus
= SHELL_SUCCESS
;
391 -1, -1, NULL
, STRING_TOKEN (STR_TFTP_ERR_WRITE
),
392 gShellTftpHiiHandle
, LocalFilePath
, Status
395 ShellCloseFile (&FileHandle
);
400 gBS
->FreePages ((EFI_PHYSICAL_ADDRESS
)(UINTN
)Data
, EFI_SIZE_TO_PAGES (FileSize
));
403 CloseProtocolAndDestroyServiceChild (
405 &gEfiMtftp4ServiceBindingProtocolGuid
,
406 &gEfiMtftp4ProtocolGuid
,
411 if ((UserNicName
!= NULL
) && (NicFound
== FALSE
)) {
413 -1, -1, NULL
, STRING_TOKEN (STR_TFTP_ERR_NIC_NOT_FOUND
),
414 gShellTftpHiiHandle
, UserNicName
420 ShellCommandLineFreeVarList (CheckPackage
);
421 if (AsciiRemoteFilePath
!= NULL
) {
422 FreePool (AsciiRemoteFilePath
);
424 if (Handles
!= NULL
) {
432 Check and convert the UINT16 option values of the 'tftp' command
434 @param[in] ValueStr Value as an Unicode encoded string
435 @param[out] Value UINT16 value
437 @return TRUE The value was returned.
438 @return FALSE A parsing error occured.
443 IN CONST CHAR16
*ValueStr
,
449 Val
= ShellStrToUintn (ValueStr
);
450 if (Val
> MAX_UINT16
) {
452 -1, -1, NULL
, STRING_TOKEN (STR_GEN_PARAM_INV
),
453 gShellTftpHiiHandle
, L
"tftp", ValueStr
463 Get the name of the NIC.
465 @param[in] ControllerHandle The network physical device handle.
466 @param[in] NicNumber The network physical device number.
467 @param[out] NicName Address where to store the NIC name.
468 The memory area has to be at least
469 IP4_NIC_NAME_LENGTH bytes wide.
471 @return EFI_SUCCESS The name of the NIC was returned.
472 @return Others The creation of the child for the Managed
473 Network Service failed or the opening of
474 the Managed Network Protocol failed or
475 the operational parameters for the
476 Managed Network Protocol could not be
482 IN EFI_HANDLE ControllerHandle
,
488 EFI_HANDLE MnpHandle
;
489 EFI_MANAGED_NETWORK_PROTOCOL
*Mnp
;
490 EFI_SIMPLE_NETWORK_MODE SnpMode
;
492 Status
= CreateServiceChildAndOpenProtocol (
494 &gEfiManagedNetworkServiceBindingProtocolGuid
,
495 &gEfiManagedNetworkProtocolGuid
,
499 if (EFI_ERROR (Status
)) {
503 Status
= Mnp
->GetModeData (Mnp
, NULL
, &SnpMode
);
504 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_STARTED
)) {
511 SnpMode
.IfType
== NET_IFTYPE_ETHERNET
?
517 Status
= EFI_SUCCESS
;
521 if (MnpHandle
!= NULL
) {
522 CloseProtocolAndDestroyServiceChild (
524 &gEfiManagedNetworkServiceBindingProtocolGuid
,
525 &gEfiManagedNetworkProtocolGuid
,
534 Create a child for the service identified by its service binding protocol GUID
535 and get from the child the interface of the protocol identified by its GUID.
537 @param[in] ControllerHandle Controller handle.
538 @param[in] ServiceBindingProtocolGuid Service binding protocol GUID of the
539 service to be created.
540 @param[in] ProtocolGuid GUID of the protocol to be open.
541 @param[out] ChildHandle Address where the handler of the
542 created child is returned. NULL is
543 returned in case of error.
544 @param[out] Interface Address where a pointer to the
545 protocol interface is returned in
548 @return EFI_SUCCESS The child was created and the protocol opened.
549 @return Others Either the creation of the child or the opening
550 of the protocol failed.
554 CreateServiceChildAndOpenProtocol (
555 IN EFI_HANDLE ControllerHandle
,
556 IN EFI_GUID
*ServiceBindingProtocolGuid
,
557 IN EFI_GUID
*ProtocolGuid
,
558 OUT EFI_HANDLE
*ChildHandle
,
565 Status
= NetLibCreateServiceChild (
568 ServiceBindingProtocolGuid
,
571 if (!EFI_ERROR (Status
)) {
572 Status
= gBS
->OpenProtocol (
578 EFI_OPEN_PROTOCOL_GET_PROTOCOL
580 if (EFI_ERROR (Status
)) {
581 NetLibDestroyServiceChild (
584 ServiceBindingProtocolGuid
,
595 Close the protocol identified by its GUID on the child handle of the service
596 identified by its service binding protocol GUID, then destroy the child
599 @param[in] ControllerHandle Controller handle.
600 @param[in] ServiceBindingProtocolGuid Service binding protocol GUID of the
601 service to be destroyed.
602 @param[in] ProtocolGuid GUID of the protocol to be closed.
603 @param[in] ChildHandle Handle of the child to be destroyed.
608 CloseProtocolAndDestroyServiceChild (
609 IN EFI_HANDLE ControllerHandle
,
610 IN EFI_GUID
*ServiceBindingProtocolGuid
,
611 IN EFI_GUID
*ProtocolGuid
,
612 IN EFI_HANDLE ChildHandle
622 NetLibDestroyServiceChild (
625 ServiceBindingProtocolGuid
,
631 Worker function that gets the size in numbers of bytes of a file from a TFTP
632 server before to download the file.
634 @param[in] Mtftp4 MTFTP4 protocol interface
635 @param[in] FilePath Path of the file, ASCII encoded
636 @param[out] FileSize Address where to store the file size in number of
639 @retval EFI_SUCCESS The size of the file was returned.
640 @retval EFI_UNSUPPORTED The server does not support the "tsize" option.
641 @retval Others Error when retrieving the information from the server
642 (see EFI_MTFTP4_PROTOCOL.GetInfo() status codes)
643 or error when parsing the response of the server.
648 IN EFI_MTFTP4_PROTOCOL
*Mtftp4
,
649 IN CONST CHAR8
*FilePath
,
654 EFI_MTFTP4_OPTION ReqOpt
[1];
655 EFI_MTFTP4_PACKET
*Packet
;
657 EFI_MTFTP4_OPTION
*TableOfOptions
;
658 EFI_MTFTP4_OPTION
*Option
;
662 ReqOpt
[0].OptionStr
= (UINT8
*)"tsize";
665 ReqOpt
[0].ValueStr
= OptBuf
;
667 Status
= Mtftp4
->GetInfo (
678 if (EFI_ERROR (Status
)) {
682 Status
= Mtftp4
->ParseOptions (
689 if (EFI_ERROR (Status
)) {
693 Option
= TableOfOptions
;
694 while (OptCnt
!= 0) {
695 if (AsciiStrnCmp ((CHAR8
*)Option
->OptionStr
, "tsize", 5) == 0) {
696 *FileSize
= AsciiStrDecimalToUintn ((CHAR8
*)Option
->ValueStr
);
702 FreePool (TableOfOptions
);
705 Status
= EFI_UNSUPPORTED
;
714 Worker function that download the data of a file from a TFTP server given
715 the path of the file and its size.
717 @param[in] Mtftp4 MTFTP4 protocol interface
718 @param[in] FilePath Path of the file, Unicode encoded
719 @param[in] AsciiFilePath Path of the file, ASCII encoded
720 @param[in] FileSize Size of the file in number of bytes
721 @param[out] Data Address where to store the address of the buffer
722 where the data of the file were downloaded in
725 @retval EFI_SUCCESS The file was downloaded.
726 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
727 @retval Others The downloading of the file from the server failed
728 (see EFI_MTFTP4_PROTOCOL.ReadFile() status codes).
734 IN EFI_MTFTP4_PROTOCOL
*Mtftp4
,
735 IN CONST CHAR16
*FilePath
,
736 IN CONST CHAR8
*AsciiFilePath
,
742 EFI_PHYSICAL_ADDRESS PagesAddress
;
744 DOWNLOAD_CONTEXT
*TftpContext
;
745 EFI_MTFTP4_TOKEN Mtftp4Token
;
747 // Downloaded file can be large. BS.AllocatePages() is more faster
748 // than AllocatePool() and avoid fragmentation.
749 // The downloaded file could be an EFI application. Marking the
750 // allocated page as EfiBootServicesCode would allow to execute a
751 // potential downloaded EFI application.
752 Status
= gBS
->AllocatePages (
755 EFI_SIZE_TO_PAGES (FileSize
),
758 if (EFI_ERROR (Status
)) {
762 Buffer
= (VOID
*)(UINTN
)PagesAddress
;
763 TftpContext
= AllocatePool (sizeof (DOWNLOAD_CONTEXT
));
764 if (TftpContext
== NULL
) {
765 Status
= EFI_OUT_OF_RESOURCES
;
768 TftpContext
->FileSize
= FileSize
;
769 TftpContext
->DownloadedNbOfBytes
= 0;
770 TftpContext
->LastReportedNbOfBytes
= 0;
772 ZeroMem (&Mtftp4Token
, sizeof (EFI_MTFTP4_TOKEN
));
773 Mtftp4Token
.Filename
= (UINT8
*)AsciiFilePath
;
774 Mtftp4Token
.BufferSize
= FileSize
;
775 Mtftp4Token
.Buffer
= Buffer
;
776 Mtftp4Token
.CheckPacket
= CheckPacket
;
777 Mtftp4Token
.Context
= (VOID
*)TftpContext
;
780 -1, -1, NULL
, STRING_TOKEN (STR_TFTP_DOWNLOADING
),
781 gShellTftpHiiHandle
, FilePath
784 Status
= Mtftp4
->ReadFile (Mtftp4
, &Mtftp4Token
);
786 -1, -1, NULL
, STRING_TOKEN (STR_GEN_CRLF
),
792 if (TftpContext
== NULL
) {
793 FreePool (TftpContext
);
796 if (EFI_ERROR (Status
)) {
797 gBS
->FreePages (PagesAddress
, EFI_SIZE_TO_PAGES (FileSize
));
807 Update the progress of a file download
808 This procedure is called each time a new TFTP packet is received.
810 @param[in] This MTFTP4 protocol interface
811 @param[in] Token Parameters for the download of the file
812 @param[in] PacketLen Length of the packet
813 @param[in] Packet Address of the packet
815 @retval EFI_SUCCESS All packets are accepted.
821 IN EFI_MTFTP4_PROTOCOL
*This
,
822 IN EFI_MTFTP4_TOKEN
*Token
,
824 IN EFI_MTFTP4_PACKET
*Packet
827 DOWNLOAD_CONTEXT
*Context
;
828 CHAR16 Progress
[TFTP_PROGRESS_MESSAGE_SIZE
];
834 if ((NTOHS (Packet
->OpCode
)) != EFI_MTFTP4_OPCODE_DATA
) {
838 Context
= (DOWNLOAD_CONTEXT
*)Token
->Context
;
839 if (Context
->DownloadedNbOfBytes
== 0) {
840 ShellPrintEx (-1, -1, L
"%s 0 Kb", mTftpProgressFrame
);
844 // The data in the packet are prepended with two UINT16 :
845 // . OpCode = EFI_MTFTP4_OPCODE_DATA
846 // . Block = the number of this block of data
848 Context
->DownloadedNbOfBytes
+= PacketLen
- sizeof (Packet
->OpCode
)
849 - sizeof (Packet
->Data
.Block
);
850 NbOfKb
= Context
->DownloadedNbOfBytes
/ 1024;
853 LastStep
= (Context
->LastReportedNbOfBytes
* TFTP_PROGRESS_SLIDER_STEPS
) /
855 Step
= (Context
->DownloadedNbOfBytes
* TFTP_PROGRESS_SLIDER_STEPS
) /
857 if (Step
<= LastStep
) {
861 ShellPrintEx (-1, -1, L
"%s", mTftpProgressDelete
);
863 StrCpy (Progress
, mTftpProgressFrame
);
864 for (Index
= 1; Index
< Step
; Index
++) {
865 Progress
[Index
] = L
'=';
867 Progress
[Step
] = L
'>';
870 Progress
+ (sizeof (mTftpProgressFrame
) / sizeof (CHAR16
)) - 1,
871 sizeof (Progress
) - sizeof (mTftpProgressFrame
),
875 Context
->LastReportedNbOfBytes
= Context
->DownloadedNbOfBytes
;
877 ShellPrintEx (-1, -1, L
"%s", Progress
);