2 EFI Multicast Trivial File Tranfer Protocol Definition
4 Copyright (c) 2006 - 2009, 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.
13 @par Revision Reference:
14 This Protocol is introduced in UEFI Specification 2.0
18 #ifndef __EFI_MTFTP4_PROTOCOL_H__
19 #define __EFI_MTFTP4_PROTOCOL_H__
21 #define EFI_MTFTP4_SERVICE_BINDING_PROTOCOL_GUID \
23 0x2FE800BE, 0x8F01, 0x4aa6, {0x94, 0x6B, 0xD7, 0x13, 0x88, 0xE1, 0x83, 0x3F } \
26 #define EFI_MTFTP4_PROTOCOL_GUID \
28 0x78247c57, 0x63db, 0x4708, {0x99, 0xc2, 0xa8, 0xb4, 0xa9, 0xa6, 0x1f, 0x6b } \
31 typedef struct _EFI_MTFTP4_PROTOCOL EFI_MTFTP4_PROTOCOL
;
32 typedef struct _EFI_MTFTP4_TOKEN EFI_MTFTP4_TOKEN
;
35 //MTFTP4 packet opcode definition
37 #define EFI_MTFTP4_OPCODE_RRQ 1
38 #define EFI_MTFTP4_OPCODE_WRQ 2
39 #define EFI_MTFTP4_OPCODE_DATA 3
40 #define EFI_MTFTP4_OPCODE_ACK 4
41 #define EFI_MTFTP4_OPCODE_ERROR 5
42 #define EFI_MTFTP4_OPCODE_OACK 6
43 #define EFI_MTFTP4_OPCODE_DIR 7
44 #define EFI_MTFTP4_OPCODE_DATA8 8
45 #define EFI_MTFTP4_OPCODE_ACK8 9
48 // MTFTP4 error code definition
50 #define EFI_MTFTP4_ERRORCODE_NOT_DEFINED 0
51 #define EFI_MTFTP4_ERRORCODE_FILE_NOT_FOUND 1
52 #define EFI_MTFTP4_ERRORCODE_ACCESS_VIOLATION 2
53 #define EFI_MTFTP4_ERRORCODE_DISK_FULL 3
54 #define EFI_MTFTP4_ERRORCODE_ILLEGAL_OPERATION 4
55 #define EFI_MTFTP4_ERRORCODE_UNKNOWN_TRANSFER_ID 5
56 #define EFI_MTFTP4_ERRORCODE_FILE_ALREADY_EXISTS 6
57 #define EFI_MTFTP4_ERRORCODE_NO_SUCH_USER 7
58 #define EFI_MTFTP4_ERRORCODE_REQUEST_DENIED 8
61 // MTFTP4 pacekt definitions
68 } EFI_MTFTP4_REQ_HEADER
;
73 } EFI_MTFTP4_OACK_HEADER
;
79 } EFI_MTFTP4_DATA_HEADER
;
84 } EFI_MTFTP4_ACK_HEADER
;
90 } EFI_MTFTP4_DATA8_HEADER
;
95 } EFI_MTFTP4_ACK8_HEADER
;
100 UINT8 ErrorMessage
[1];
101 } EFI_MTFTP4_ERROR_HEADER
;
105 /// Type of packets as defined by the MTFTPv4 packet opcodes.
109 /// Read request packet header.
111 EFI_MTFTP4_REQ_HEADER Rrq
;
113 /// Write request packet header.
115 EFI_MTFTP4_REQ_HEADER Wrq
;
117 /// Option acknowledge packet header.
119 EFI_MTFTP4_OACK_HEADER Oack
;
121 /// Data packet header.
123 EFI_MTFTP4_DATA_HEADER Data
;
125 /// Acknowledgement packet header.
127 EFI_MTFTP4_ACK_HEADER Ack
;
129 /// Data packet header with big block number.
131 EFI_MTFTP4_DATA8_HEADER Data8
;
133 /// Acknowledgement header with big block num.
135 EFI_MTFTP4_ACK8_HEADER Ack8
;
137 /// Error packet header.
139 EFI_MTFTP4_ERROR_HEADER Error
;
145 /// MTFTP4 option definition
154 BOOLEAN UseDefaultSetting
;
155 EFI_IPv4_ADDRESS StationIp
;
156 EFI_IPv4_ADDRESS SubnetMask
;
158 EFI_IPv4_ADDRESS GatewayIp
;
159 EFI_IPv4_ADDRESS ServerIp
;
160 UINT16 InitialServerPort
;
163 } EFI_MTFTP4_CONFIG_DATA
;
167 EFI_MTFTP4_CONFIG_DATA ConfigData
;
168 UINT8 SupportedOptionCount
;
169 UINT8
**SupportedOptoins
;
170 UINT8 UnsupportedOptionCount
;
171 UINT8
**UnsupportedOptoins
;
172 } EFI_MTFTP4_MODE_DATA
;
176 EFI_IPv4_ADDRESS GatewayIp
;
177 EFI_IPv4_ADDRESS ServerIp
;
181 } EFI_MTFTP4_OVERRIDE_DATA
;
184 // Protocol interfaces definition
188 A callback function that is provided by the caller to intercept
189 the EFI_MTFTP4_OPCODE_DATA or EFI_MTFTP4_OPCODE_DATA8 packets processed in the
190 EFI_MTFTP4_PROTOCOL.ReadFile() function, and alternatively to intercept
191 EFI_MTFTP4_OPCODE_OACK or EFI_MTFTP4_OPCODE_ERROR packets during a call to
192 EFI_MTFTP4_PROTOCOL.ReadFile(), WriteFile() or ReadDirectory().
194 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
195 @param Token The token that the caller provided in the
196 EFI_MTFTP4_PROTOCOL.ReadFile(), WriteFile()
197 or ReadDirectory() function.
198 @param PacketLen Indicates the length of the packet.
199 @param Packet Pointer to an MTFTPv4 packet.
201 @retval EFI_SUCCESS Operation sucess
202 @retval Others Abort transfer process
207 (EFIAPI
*EFI_MTFTP4_CHECK_PACKET
)(
208 IN EFI_MTFTP4_PROTOCOL
*This
,
209 IN EFI_MTFTP4_TOKEN
*Token
,
211 IN EFI_MTFTP4_PACKET
*Paket
215 Timeout callback funtion.
217 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
218 @param Token The token that is provided in the
219 EFI_MTFTP4_PROTOCOL.ReadFile() or
220 EFI_MTFTP4_PROTOCOL.WriteFile() or
221 EFI_MTFTP4_PROTOCOL.ReadDirectory() functions
224 @retval EFI_SUCCESS Operation sucess
225 @retval Others Aborts download process.
230 (EFIAPI
*EFI_MTFTP4_TIMEOUT_CALLBACK
)(
231 IN EFI_MTFTP4_PROTOCOL
*This
,
232 IN EFI_MTFTP4_TOKEN
*Token
236 A callback function that the caller provides to feed data to the
237 EFI_MTFTP4_PROTOCOL.WriteFile() function.
239 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
240 @param Token The token provided in the
241 EFI_MTFTP4_PROTOCOL.WriteFile() by the caller.
242 @param Length Indicates the length of the raw data wanted on input, and the
243 length the data available on output.
244 @param Buffer Pointer to the buffer where the data is stored.
246 @retval EFI_SUCCESS Operation sucess
247 @retval Others Aborts session.
252 (EFIAPI
*EFI_MTFTP4_PACKET_NEEDED
)(
253 IN EFI_MTFTP4_PROTOCOL
*This
,
254 IN EFI_MTFTP4_TOKEN
*Token
,
255 IN OUT UINT16
*Length
,
261 Submits an asynchronous interrupt transfer to an interrupt endpoint of a USB device.
263 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
264 @param ModeData Pointer to storage for the EFI MTFTPv4 Protocol driver mode data.
266 @retval EFI_SUCCESS The configuration data was successfully returned.
267 @retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated.
268 @retval EFI_INVALID_PARAMETER This is NULL or ModeData is NULL.
273 (EFIAPI
*EFI_MTFTP4_GET_MODE_DATA
)(
274 IN EFI_MTFTP4_PROTOCOL
*This
,
275 OUT EFI_MTFTP4_MODE_DATA
*ModeData
280 Initializes, changes, or resets the default operational setting for this
281 EFI MTFTPv4 Protocol driver instance.
283 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
284 @param MtftpConfigData Pointer to the configuration data structure.
286 @retval EFI_SUCCESS The EFI MTFTPv4 Protocol driver was configured successfully.
287 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
288 @retval EFI_ACCESS_DENIED The EFI configuration could not be changed at this time because
289 there is one MTFTP background operation in progress.
290 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
291 RARP, etc.) has not finished yet.
292 @retval EFI_UNSUPPORTED A configuration protocol (DHCP, BOOTP, RARP, etc.) could not
293 be located when clients choose to use the default address
295 @retval EFI_OUT_OF_RESOURCES The EFI MTFTPv4 Protocol driver instance data could not be
297 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI
298 MTFTPv4 Protocol driver instance is not configured.
303 (EFIAPI
*EFI_MTFTP4_CONFIGURE
)(
304 IN EFI_MTFTP4_PROTOCOL
*This
,
305 IN EFI_MTFTP4_CONFIG_DATA
*MtftpConfigData OPTIONAL
310 Gets information about a file from an MTFTPv4 server.
312 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
313 @param OverrideData Data that is used to override the existing parameters. If NULL,
314 the default parameters that were set in the
315 EFI_MTFTP4_PROTOCOL.Configure() function are used.
316 @param Filename Pointer to ASCIIZ file name string.
317 @param ModeStr Pointer to ASCIIZ mode string. If NULL, "octet" will be used.
318 @param OptionCount Number of option/value string pairs in OptionList.
319 @param OptionList Pointer to array of option/value string pairs. Ignored if
321 @param PacketLength The number of bytes in the returned packet.
322 @param Packet The pointer to the received packet. This buffer must be freed by
325 @retval EFI_SUCCESS An MTFTPv4 OACK packet was received and is in the Buffer.
326 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
327 @retval EFI_UNSUPPORTED One or more options in the OptionList are in the
328 unsupported list of structure EFI_MTFTP4_MODE_DATA.
329 @retval EFI_NOT_STARTED The EFI MTFTPv4 Protocol driver has not been started.
330 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
331 RARP, etc.) has not finished yet.
332 @retval EFI_ACCESS_DENIED The previous operation has not completed yet.
333 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
334 @retval EFI_TFTP_ERROR An MTFTPv4 ERROR packet was received and is in the buffer.
335 @retval EFI_ICMP_ERROR An ICMP ERROR packet was received and is in the Buffer.
336 @retval EFI_PROTOCOL_ERROR An unexpected MTFTPv4 packet was received and is in the buffer.
337 @retval EFI_TIMEOUT No responses were received from the MTFTPv4 server.
338 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
343 (EFIAPI
*EFI_MTFTP4_GET_INFO
)(
344 IN EFI_MTFTP4_PROTOCOL
*This
,
345 IN EFI_MTFTP4_OVERRIDE_DATA
*OverrideData OPTIONAL
,
347 IN UINT8
*ModeStr OPTIONAL
,
348 IN UINT8 OptionCount
,
349 IN EFI_MTFTP4_OPTION
*OptionList
,
350 OUT UINT32
*PacketLength
,
351 OUT EFI_MTFTP4_PACKET
**Packet OPTIONAL
355 Parses the options in an MTFTPv4 OACK packet.
357 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
358 @param PacketLen Length of the OACK packet to be parsed.
359 @param Packet Pointer to the OACK packet to be parsed.
360 @param OptionCount Pointer to the number of options in following OptionList.
361 @param OptionList Pointer to EFI_MTFTP4_OPTION storage. Call the EFI Boot
362 Service FreePool() to release the OptionList if the options
363 in this OptionList are not needed any more.
365 @retval EFI_SUCCESS The OACK packet was valid and the OptionCount and
366 OptionList parameters have been updated.
367 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
369 - Packet is NULL or Packet is not a valid MTFTPv4 packet.
370 - OptionCount is NULL.
371 @retval EFI_NOT_FOUND No options were found in the OACK packet.
372 @retval EFI_OUT_OF_RESOURCES Storage for the OptionList array cannot be allocated.
373 @retval EFI_PROTOCOL_ERROR One or more of the option fields is invalid.
378 (EFIAPI
*EFI_MTFTP4_PARSE_OPTIONS
)(
379 IN EFI_MTFTP4_PROTOCOL
*This
,
381 IN EFI_MTFTP4_PACKET
*Packet
,
382 OUT UINT32
*OptionCount
,
383 OUT EFI_MTFTP4_OPTION
**OptionList OPTIONAL
388 Downloads a file from an MTFTPv4 server.
390 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
391 @param Token Pointer to the token structure to provide the parameters that are
392 used in this operation.
394 @retval EFI_SUCCESS The data file has been transferred successfully.
395 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
396 @retval EFI_BUFFER_TOO_SMALL BufferSize is not large enough to hold the downloaded data
397 in downloading process.
398 @retval EFI_ABORTED Current operation is aborted by user.
399 @retval EFI_ICMP_ERROR An ICMP ERROR packet was received.
400 @retval EFI_TIMEOUT No responses were received from the MTFTPv4 server.
401 @retval EFI_TFTP_ERROR An MTFTPv4 ERROR packet was received.
402 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
407 (EFIAPI
*EFI_MTFTP4_READ_FILE
)(
408 IN EFI_MTFTP4_PROTOCOL
*This
,
409 IN EFI_MTFTP4_TOKEN
*Token
415 Sends a file to an MTFTPv4 server.
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 upload session has started.
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_WRITE_FILE
)(
438 IN EFI_MTFTP4_PROTOCOL
*This
,
439 IN EFI_MTFTP4_TOKEN
*Token
444 Downloads a data file "directory" from an MTFTPv4 server. May be unsupported in some EFI
447 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
448 @param Token Pointer to the token structure to provide the parameters that are
449 used in this operation.
451 @retval EFI_SUCCESS The MTFTPv4 related file "directory" has been downloaded.
452 @retval EFI_UNSUPPORTED The operation is not supported by this implementation.
453 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
454 @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are in
455 the unsupported list of structure EFI_MTFTP4_MODE_DATA.
456 @retval EFI_NOT_STARTED The EFI MTFTPv4 Protocol driver has not been started.
457 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
458 RARP, etc.) is not finished yet.
459 @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv4 session.
460 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
461 @retval EFI_ACCESS_DENIED The previous operation has not completed yet.
462 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
467 (EFIAPI
*EFI_MTFTP4_READ_DIRECTORY
)(
468 IN EFI_MTFTP4_PROTOCOL
*This
,
469 IN EFI_MTFTP4_TOKEN
*Token
473 Polls for incoming data packets and processes outgoing data packets.
475 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
477 @retval EFI_SUCCESS Incoming or outgoing data was processed.
478 @retval EFI_NOT_STARTED This EFI MTFTPv4 Protocol instance has not been started.
479 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
480 RARP, etc.) is not finished yet.
481 @retval EFI_INVALID_PARAMETER This is NULL.
482 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
483 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.
484 Consider increasing the polling rate.
489 (EFIAPI
*EFI_MTFTP4_POLL
)(
490 IN EFI_MTFTP4_PROTOCOL
*This
494 /// The EFI_MTFTP4_PROTOCOL is designed to be used by UEFI drivers and applications
495 /// to transmit and receive data files. The EFI MTFTPv4 Protocol driver uses
496 /// the underlying EFI UDPv4 Protocol driver and EFI IPv4 Protocol driver.
498 struct _EFI_MTFTP4_PROTOCOL
{
499 EFI_MTFTP4_GET_MODE_DATA GetModeData
;
500 EFI_MTFTP4_CONFIGURE Configure
;
501 EFI_MTFTP4_GET_INFO GetInfo
;
502 EFI_MTFTP4_PARSE_OPTIONS ParseOptions
;
503 EFI_MTFTP4_READ_FILE ReadFile
;
504 EFI_MTFTP4_WRITE_FILE WriteFile
;
505 EFI_MTFTP4_READ_DIRECTORY ReadDirectory
;
506 EFI_MTFTP4_POLL Poll
;
509 struct _EFI_MTFTP4_TOKEN
{
511 /// The status that is returned to the caller at the end of the operation
512 /// to indicate whether this operation completed successfully.
516 /// The event that will be signaled when the operation completes. If
517 /// set to NULL, the corresponding function will wait until the read or
518 /// write operation finishes. The type of Event must be
519 /// EVT_NOTIFY_SIGNAL. The Task Priority Level (TPL) of
520 /// Event must be lower than or equal to TPL_CALLBACK.
524 /// If not NULL, the data that will be used to override the existing configure data.
526 EFI_MTFTP4_OVERRIDE_DATA
*OverrideData
;
528 /// Pointer to the ASCIIZ file name string.
532 /// Pointer to the ASCIIZ mode string. If NULL, "octet" is used.
536 /// Number of option/value string pairs.
540 /// Pointer to an array of option/value string pairs. Ignored if OptionCount is zero.
542 EFI_MTFTP4_OPTION
*OptionList
;
544 /// Size of the data buffer.
548 /// Pointer to the data buffer. Data that is downloaded from the
549 /// MTFTPv4 server is stored here. Data that is uploaded to the
550 /// MTFTPv4 server is read from here. Ignored if BufferSize is zero.
554 /// Pointer to the context that will be used by CheckPacket,
555 /// TimeoutCallback and PacketNeeded.
559 /// Pointer to the callback function to check the contents of the received packet.
561 EFI_MTFTP4_CHECK_PACKET CheckPacket
;
563 /// Pointer to the function to be called when a timeout occurs.
565 EFI_MTFTP4_TIMEOUT_CALLBACK TimeoutCallback
;
567 /// Pointer to the function to provide the needed packet contents.
569 EFI_MTFTP4_PACKET_NEEDED PacketNeeded
;
572 extern EFI_GUID gEfiMtftp4ServiceBindingProtocolGuid
;
573 extern EFI_GUID gEfiMtftp4ProtocolGuid
;