2 EFI Multicast Trivial File Tranfer Protocol Definition
4 Copyright (c) 2006 - 2008, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef __EFI_MTFTP4_PROTOCOL_H__
16 #define __EFI_MTFTP4_PROTOCOL_H__
18 #define EFI_MTFTP4_SERVICE_BINDING_PROTOCOL_GUID \
20 0x2FE800BE, 0x8F01, 0x4aa6, {0x94, 0x6B, 0xD7, 0x13, 0x88, 0xE1, 0x83, 0x3F } \
23 #define EFI_MTFTP4_PROTOCOL_GUID \
25 0x78247c57, 0x63db, 0x4708, {0x99, 0xc2, 0xa8, 0xb4, 0xa9, 0xa6, 0x1f, 0x6b } \
28 typedef struct _EFI_MTFTP4_PROTOCOL EFI_MTFTP4_PROTOCOL
;
29 typedef struct _EFI_MTFTP4_TOKEN EFI_MTFTP4_TOKEN
;
32 //MTFTP4 packet opcode definition
34 #define EFI_MTFTP4_OPCODE_RRQ 1
35 #define EFI_MTFTP4_OPCODE_WRQ 2
36 #define EFI_MTFTP4_OPCODE_DATA 3
37 #define EFI_MTFTP4_OPCODE_ACK 4
38 #define EFI_MTFTP4_OPCODE_ERROR 5
39 #define EFI_MTFTP4_OPCODE_OACK 6
40 #define EFI_MTFTP4_OPCODE_DIR 7
41 #define EFI_MTFTP4_OPCODE_DATA8 8
42 #define EFI_MTFTP4_OPCODE_ACK8 9
45 // MTFTP4 error code definition
47 #define EFI_MTFTP4_ERRORCODE_NOT_DEFINED 0
48 #define EFI_MTFTP4_ERRORCODE_FILE_NOT_FOUND 1
49 #define EFI_MTFTP4_ERRORCODE_ACCESS_VIOLATION 2
50 #define EFI_MTFTP4_ERRORCODE_DISK_FULL 3
51 #define EFI_MTFTP4_ERRORCODE_ILLEGAL_OPERATION 4
52 #define EFI_MTFTP4_ERRORCODE_UNKNOWN_TRANSFER_ID 5
53 #define EFI_MTFTP4_ERRORCODE_FILE_ALREADY_EXISTS 6
54 #define EFI_MTFTP4_ERRORCODE_NO_SUCH_USER 7
55 #define EFI_MTFTP4_ERRORCODE_REQUEST_DENIED 8
58 // MTFTP4 pacekt definitions
65 } EFI_MTFTP4_REQ_HEADER
;
70 } EFI_MTFTP4_OACK_HEADER
;
76 } EFI_MTFTP4_DATA_HEADER
;
81 } EFI_MTFTP4_ACK_HEADER
;
87 } EFI_MTFTP4_DATA8_HEADER
;
92 } EFI_MTFTP4_ACK8_HEADER
;
97 UINT8 ErrorMessage
[1];
98 } EFI_MTFTP4_ERROR_HEADER
;
102 EFI_MTFTP4_REQ_HEADER Rrq
;
103 EFI_MTFTP4_REQ_HEADER Wrq
;
104 EFI_MTFTP4_OACK_HEADER Oack
;
105 EFI_MTFTP4_DATA_HEADER Data
;
106 EFI_MTFTP4_ACK_HEADER Ack
;
107 EFI_MTFTP4_DATA8_HEADER Data8
;
108 EFI_MTFTP4_ACK8_HEADER Ack8
;
109 EFI_MTFTP4_ERROR_HEADER Error
;
115 /// MTFTP4 option definition
124 BOOLEAN UseDefaultSetting
;
125 EFI_IPv4_ADDRESS StationIp
;
126 EFI_IPv4_ADDRESS SubnetMask
;
128 EFI_IPv4_ADDRESS GatewayIp
;
129 EFI_IPv4_ADDRESS ServerIp
;
130 UINT16 InitialServerPort
;
133 } EFI_MTFTP4_CONFIG_DATA
;
137 EFI_MTFTP4_CONFIG_DATA ConfigData
;
138 UINT8 SupportedOptionCount
;
139 UINT8
**SupportedOptoins
;
140 UINT8 UnsupportedOptionCount
;
141 UINT8
**UnsupportedOptoins
;
142 } EFI_MTFTP4_MODE_DATA
;
146 EFI_IPv4_ADDRESS GatewayIp
;
147 EFI_IPv4_ADDRESS ServerIp
;
151 } EFI_MTFTP4_OVERRIDE_DATA
;
154 // Protocol interfaces definition
158 a callback function that is provided by the caller to intercept
159 the EFI_MTFTP4_OPCODE_DATA or EFI_MTFTP4_OPCODE_DATA8 packets processed in the
160 EFI_MTFTP4_PROTOCOL.ReadFile() function, and alternatively to intercept
161 EFI_MTFTP4_OPCODE_OACK or EFI_MTFTP4_OPCODE_ERROR packets during a call to
162 EFI_MTFTP4_PROTOCOL.ReadFile(), WriteFile() or ReadDirectory().
164 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
165 @param Token The token that the caller provided in the
166 EFI_MTFTP4_PROTOCOL.ReadFile(), WriteFile()
167 or ReadDirectory() function.
168 @param PacketLen Indicates the length of the packet.
169 @param Packet Pointer to an MTFTPv4 packet.
171 @retval EFI_SUCCESS Operation sucess
172 @retval Others Abort transfer process
177 (EFIAPI
*EFI_MTFTP4_CHECK_PACKET
)(
178 IN EFI_MTFTP4_PROTOCOL
*This
,
179 IN EFI_MTFTP4_TOKEN
*Token
,
181 IN EFI_MTFTP4_PACKET
*Paket
185 Timeout callback funtion.
187 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
188 @param Token The token that is provided in the
189 EFI_MTFTP4_PROTOCOL.ReadFile() or
190 EFI_MTFTP4_PROTOCOL.WriteFile() or
191 EFI_MTFTP4_PROTOCOL.ReadDirectory() functions
194 @retval EFI_SUCCESS Operation sucess
195 @retval Others Aborts download process.
200 (EFIAPI
*EFI_MTFTP4_TIMEOUT_CALLBACK
)(
201 IN EFI_MTFTP4_PROTOCOL
*This
,
202 IN EFI_MTFTP4_TOKEN
*Token
206 a callback function that the caller provides to feed data to the
207 EFI_MTFTP4_PROTOCOL.WriteFile() function.
209 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
210 @param Token The token provided in the
211 EFI_MTFTP4_PROTOCOL.WriteFile() by the caller.
212 @param Length Indicates the length of the raw data wanted on input, and the
213 length the data available on output.
214 @param Buffer Pointer to the buffer where the data is stored.
216 @retval EFI_SUCCESS Operation sucess
217 @retval Others Aborts session.
222 (EFIAPI
*EFI_MTFTP4_PACKET_NEEDED
)(
223 IN EFI_MTFTP4_PROTOCOL
*This
,
224 IN EFI_MTFTP4_TOKEN
*Token
,
225 IN OUT UINT16
*Length
,
231 Submits an asynchronous interrupt transfer to an interrupt endpoint of a USB device.
233 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
234 @param ModeData Pointer to storage for the EFI MTFTPv4 Protocol driver mode data.
236 @retval EFI_SUCCESS The configuration data was successfully returned.
237 @retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated.
238 @retval EFI_INVALID_PARAMETER This is NULL or ModeData is NULL.
243 (EFIAPI
*EFI_MTFTP4_GET_MODE_DATA
)(
244 IN EFI_MTFTP4_PROTOCOL
*This
,
245 OUT EFI_MTFTP4_MODE_DATA
*ModeData
250 Initializes, changes, or resets the default operational setting for this
251 EFI MTFTPv4 Protocol driver instance.
253 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
254 @param MtftpConfigData Pointer to the configuration data structure.
256 @retval EFI_SUCCESS The EFI MTFTPv4 Protocol driver was configured successfully.
257 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
258 @retval EFI_ACCESS_DENIED The EFI configuration could not be changed at this time because
259 there is one MTFTP background operation in progress.
260 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
261 RARP, etc.) has not finished yet.
262 @retval EFI_UNSUPPORTED A configuration protocol (DHCP, BOOTP, RARP, etc.) could not
263 be located when clients choose to use the default address
265 @retval EFI_OUT_OF_RESOURCES The EFI MTFTPv4 Protocol driver instance data could not be
267 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI
268 MTFTPv4 Protocol driver instance is not configured.
273 (EFIAPI
*EFI_MTFTP4_CONFIGURE
)(
274 IN EFI_MTFTP4_PROTOCOL
*This
,
275 IN EFI_MTFTP4_CONFIG_DATA
*MtftpConfigData OPTIONAL
280 Gets information about a file from an MTFTPv4 server.
282 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
283 @param OverrideData Data that is used to override the existing parameters. If NULL,
284 the default parameters that were set in the
285 EFI_MTFTP4_PROTOCOL.Configure() function are used.
286 @param Filename Pointer to ASCIIZ file name string.
287 @param ModeStr Pointer to ASCIIZ mode string. If NULL, "octet" will be used.
288 @param OptionCount Number of option/value string pairs in OptionList.
289 @param OptionList Pointer to array of option/value string pairs. Ignored if
291 @param PacketLength The number of bytes in the returned packet.
292 @param Packet The pointer to the received packet. This buffer must be freed by
295 @retval EFI_SUCCESS An MTFTPv4 OACK packet was received and is in the Buffer.
296 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
297 @retval EFI_UNSUPPORTED One or more options in the OptionList are in the
298 unsupported list of structure EFI_MTFTP4_MODE_DATA.
299 @retval EFI_NOT_STARTED The EFI MTFTPv4 Protocol driver has not been started.
300 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
301 RARP, etc.) has not finished yet.
302 @retval EFI_ACCESS_DENIED The previous operation has not completed yet.
303 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
304 @retval EFI_TFTP_ERROR An MTFTPv4 ERROR packet was received and is in the buffer.
305 @retval EFI_ICMP_ERROR An ICMP ERROR packet was received and is in the Buffer.
306 @retval EFI_PROTOCOL_ERROR An unexpected MTFTPv4 packet was received and is in the buffer.
307 @retval EFI_TIMEOUT No responses were received from the MTFTPv4 server.
308 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
313 (EFIAPI
*EFI_MTFTP4_GET_INFO
)(
314 IN EFI_MTFTP4_PROTOCOL
*This
,
315 IN EFI_MTFTP4_OVERRIDE_DATA
*OverrideData OPTIONAL
,
317 IN UINT8
*ModeStr OPTIONAL
,
318 IN UINT8 OptionCount
,
319 IN EFI_MTFTP4_OPTION
*OptionList
,
320 OUT UINT32
*PacketLength
,
321 OUT EFI_MTFTP4_PACKET
**Packet OPTIONAL
325 Parses the options in an MTFTPv4 OACK packet.
327 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
328 @param PacketLen Length of the OACK packet to be parsed.
329 @param Packet Pointer to the OACK packet to be parsed.
330 @param OptionCount Pointer to the number of options in following OptionList.
331 @param OptionList Pointer to EFI_MTFTP4_OPTION storage. Call the EFI Boot
332 Service FreePool() to release each option if they are not
335 @retval EFI_SUCCESS The OACK packet was valid and the OptionCount and
336 OptionList parameters have been updated.
337 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
339 - Packet is NULL or Packet is not a valid MTFTPv4 packet.
340 - OptionCount is NULL.
341 @retval EFI_NOT_FOUND No options were found in the OACK packet.
342 @retval EFI_OUT_OF_RESOURCES Storage for the OptionList array cannot be allocated.
343 @retval EFI_PROTOCOL_ERROR One or more of the option fields is invalid.
348 (EFIAPI
*EFI_MTFTP4_PARSE_OPTIONS
)(
349 IN EFI_MTFTP4_PROTOCOL
*This
,
351 IN EFI_MTFTP4_PACKET
*Packet
,
352 OUT UINT32
*OptionCount
,
353 OUT EFI_MTFTP4_OPTION
**OptionList OPTIONAL
358 Downloads a file from an MTFTPv4 server.
360 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
361 @param Token Pointer to the token structure to provide the parameters that are
362 used in this operation.
364 @retval EFI_SUCCESS The data file has been transferred successfully.
365 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
366 @retval EFI_BUFFER_TOO_SMALL BufferSize is not large enough to hold the downloaded data
367 in downloading process.
368 @retval EFI_ABORTED Current operation is aborted by user.
369 @retval EFI_ICMP_ERROR An ICMP ERROR packet was received.
370 @retval EFI_TIMEOUT No responses were received from the MTFTPv4 server.
371 @retval EFI_TFTP_ERROR An MTFTPv4 ERROR packet was received.
372 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
377 (EFIAPI
*EFI_MTFTP4_READ_FILE
)(
378 IN EFI_MTFTP4_PROTOCOL
*This
,
379 IN EFI_MTFTP4_TOKEN
*Token
385 Sends a file to an MTFTPv4 server.
387 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
388 @param Token Pointer to the token structure to provide the parameters that are
389 used in this operation.
391 @retval EFI_SUCCESS The upload session has started.
392 @retval EFI_UNSUPPORTED The operation is not supported by this implementation.
393 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
394 @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are in
395 the unsupported list of structure EFI_MTFTP4_MODE_DATA.
396 @retval EFI_NOT_STARTED The EFI MTFTPv4 Protocol driver has not been started.
397 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
398 RARP, etc.) is not finished yet.
399 @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv4 session.
400 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
401 @retval EFI_ACCESS_DENIED The previous operation has not completed yet.
402 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
407 (EFIAPI
*EFI_MTFTP4_WRITE_FILE
)(
408 IN EFI_MTFTP4_PROTOCOL
*This
,
409 IN EFI_MTFTP4_TOKEN
*Token
414 Downloads a data file "directory" from an MTFTPv4 server. May be unsupported in some EFI
417 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
418 @param Token Pointer to the token structure to provide the parameters that are
419 used in this operation.
421 @retval EFI_SUCCESS The MTFTPv4 related file "directory" has been downloaded.
422 @retval EFI_UNSUPPORTED The operation is not supported by this implementation.
423 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
424 @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are in
425 the unsupported list of structure EFI_MTFTP4_MODE_DATA.
426 @retval EFI_NOT_STARTED The EFI MTFTPv4 Protocol driver has not been started.
427 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
428 RARP, etc.) is not finished yet.
429 @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv4 session.
430 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
431 @retval EFI_ACCESS_DENIED The previous operation has not completed yet.
432 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
437 (EFIAPI
*EFI_MTFTP4_READ_DIRECTORY
)(
438 IN EFI_MTFTP4_PROTOCOL
*This
,
439 IN EFI_MTFTP4_TOKEN
*Token
443 Polls for incoming data packets and processes outgoing data packets.
445 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
447 @retval EFI_SUCCESS Incoming or outgoing data was processed.
448 @retval EFI_NOT_STARTED This EFI MTFTPv4 Protocol instance has not been started.
449 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
450 RARP, etc.) is not finished yet.
451 @retval EFI_INVALID_PARAMETER This is NULL.
452 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
453 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.
454 Consider increasing the polling rate.
459 (EFIAPI
*EFI_MTFTP4_POLL
)(
460 IN EFI_MTFTP4_PROTOCOL
*This
464 /// The EFI_MTFTP4_PROTOCOL is designed to be used by UEFI drivers and applications
465 /// to transmit and receive data files. The EFI MTFTPv4 Protocol driver uses
466 /// the underlying EFI UDPv4 Protocol driver and EFI IPv4 Protocol driver.
468 struct _EFI_MTFTP4_PROTOCOL
{
469 EFI_MTFTP4_GET_MODE_DATA GetModeData
;
470 EFI_MTFTP4_CONFIGURE Configure
;
471 EFI_MTFTP4_GET_INFO GetInfo
;
472 EFI_MTFTP4_PARSE_OPTIONS ParseOptions
;
473 EFI_MTFTP4_READ_FILE ReadFile
;
474 EFI_MTFTP4_WRITE_FILE WriteFile
;
475 EFI_MTFTP4_READ_DIRECTORY ReadDirectory
;
476 EFI_MTFTP4_POLL Poll
;
479 struct _EFI_MTFTP4_TOKEN
{
482 EFI_MTFTP4_OVERRIDE_DATA
*OverrideData
;
486 EFI_MTFTP4_OPTION
*OptionList
;
487 OUT UINT64 BufferSize
;
489 EFI_MTFTP4_CHECK_PACKET CheckPacket
;
490 EFI_MTFTP4_TIMEOUT_CALLBACK TimeoutCallback
;
491 EFI_MTFTP4_PACKET_NEEDED PacketNeeded
;
494 extern EFI_GUID gEfiMtftp4ServiceBindingProtocolGuid
;
495 extern EFI_GUID gEfiMtftp4ProtocolGuid
;