2 EFI Multicast Trivial File Tranfer Protocol Definition
4 Copyright (c) 2006, 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.
17 #ifndef __EFI_MTFTP4_PROTOCOL_H__
18 #define __EFI_MTFTP4_PROTOCOL_H__
20 #define EFI_MTFTP4_SERVICE_BINDING_PROTOCOL_GUID \
22 0x2FE800BE, 0x8F01, 0x4aa6, {0x94, 0x6B, 0xD7, 0x13, 0x88, 0xE1, 0x83, 0x3F } \
25 #define EFI_MTFTP4_PROTOCOL_GUID \
27 0x3ad9df29, 0x4501, 0x478d, {0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } \
30 typedef struct _EFI_MTFTP4_PROTOCOL EFI_MTFTP4_PROTOCOL
;
31 typedef struct _EFI_MTFTP4_TOKEN EFI_MTFTP4_TOKEN
;
34 //MTFTP4 packet opcode definition
36 #define EFI_MTFTP4_OPCODE_RRQ 1
37 #define EFI_MTFTP4_OPCODE_WRQ 2
38 #define EFI_MTFTP4_OPCODE_DATA 3
39 #define EFI_MTFTP4_OPCODE_ACK 4
40 #define EFI_MTFTP4_OPCODE_ERROR 5
41 #define EFI_MTFTP4_OPCODE_OACK 6
42 #define EFI_MTFTP4_OPCODE_DIR 7
43 #define EFI_MTFTP4_OPCODE_DATA8 8
44 #define EFI_MTFTP4_OPCODE_ACK8 9
47 // MTFTP4 error code definition
49 #define EFI_MTFTP4_ERRORCODE_NOT_DEFINED 0
50 #define EFI_MTFTP4_ERRORCODE_FILE_NOT_FOUND 1
51 #define EFI_MTFTP4_ERRORCODE_ACCESS_VIOLATION 2
52 #define EFI_MTFTP4_ERRORCODE_DISK_FULL 3
53 #define EFI_MTFTP4_ERRORCODE_ILLEGAL_OPERATION 4
54 #define EFI_MTFTP4_ERRORCODE_UNKNOWN_TRANSFER_ID 5
55 #define EFI_MTFTP4_ERRORCODE_FILE_ALREADY_EXISTS 6
56 #define EFI_MTFTP4_ERRORCODE_NO_SUCH_USER 7
57 #define EFI_MTFTP4_ERRORCODE_REQUEST_DENIED 8
60 // MTFTP4 pacekt definitions
67 } EFI_MTFTP4_REQ_HEADER
;
72 } EFI_MTFTP4_OACK_HEADER
;
78 } EFI_MTFTP4_DATA_HEADER
;
83 } EFI_MTFTP4_ACK_HEADER
;
89 } EFI_MTFTP4_DATA8_HEADER
;
94 } EFI_MTFTP4_ACK8_HEADER
;
99 UINT8 ErrorMessage
[1];
100 } EFI_MTFTP4_ERROR_HEADER
;
104 EFI_MTFTP4_REQ_HEADER Rrq
;
105 EFI_MTFTP4_REQ_HEADER Wrq
;
106 EFI_MTFTP4_OACK_HEADER Oack
;
107 EFI_MTFTP4_DATA_HEADER Data
;
108 EFI_MTFTP4_ACK_HEADER Ack
;
109 EFI_MTFTP4_DATA8_HEADER Data8
;
110 EFI_MTFTP4_ACK8_HEADER Ack8
;
111 EFI_MTFTP4_ERROR_HEADER Error
;
117 // MTFTP4 option definition
126 BOOLEAN UseDefaultSetting
;
127 EFI_IPv4_ADDRESS StationIp
;
128 EFI_IPv4_ADDRESS SubnetMask
;
130 EFI_IPv4_ADDRESS GatewayIp
;
131 EFI_IPv4_ADDRESS ServerIp
;
132 UINT16 InitialServerPort
;
135 } EFI_MTFTP4_CONFIG_DATA
;
139 EFI_MTFTP4_CONFIG_DATA ConfigData
;
140 UINT8 SupportedOptionCount
;
141 UINT8
**SupportedOptoins
;
142 UINT8 UnsupportedOptionCount
;
143 UINT8
**UnsupportedOptoins
;
144 } EFI_MTFTP4_MODE_DATA
;
148 EFI_IPv4_ADDRESS GatewayIp
;
149 EFI_IPv4_ADDRESS ServerIp
;
153 } EFI_MTFTP4_OVERRIDE_DATA
;
156 // Protocol interfaces definition
160 a callback function that is provided by the caller to intercept
161 the EFI_MTFTP4_OPCODE_DATA or EFI_MTFTP4_OPCODE_DATA8 packets processed in the
162 EFI_MTFTP4_PROTOCOL.ReadFile() function, and alternatively to intercept
163 EFI_MTFTP4_OPCODE_OACK or EFI_MTFTP4_OPCODE_ERROR packets during a call to
164 EFI_MTFTP4_PROTOCOL.ReadFile(), WriteFile() or ReadDirectory().
166 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
167 @param Token The token that the caller provided in the
168 EFI_MTFTP4_PROTOCOL.ReadFile(), WriteFile()
169 or ReadDirectory() function.
170 @param PacketLen Indicates the length of the packet.
171 @param Packet Pointer to an MTFTPv4 packet.
173 @retval EFI_SUCCESS Operation sucess
174 @retval Others Abort transfer process
179 (EFIAPI
*EFI_MTFTP4_CHECK_PACKET
)(
180 IN EFI_MTFTP4_PROTOCOL
*This
,
181 IN EFI_MTFTP4_TOKEN
*Token
,
183 IN EFI_MTFTP4_PACKET
*Paket
188 Timeout callback funtion.
190 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
191 @param Token The token that is provided in the
192 EFI_MTFTP4_PROTOCOL.ReadFile() or
193 EFI_MTFTP4_PROTOCOL.WriteFile() or
194 EFI_MTFTP4_PROTOCOL.ReadDirectory() functions
197 @retval EFI_SUCCESS Operation sucess
198 @retval Others Aborts download process.
203 (EFIAPI
*EFI_MTFTP4_TIMEOUT_CALLBACK
)(
204 IN EFI_MTFTP4_PROTOCOL
*This
,
205 IN EFI_MTFTP4_TOKEN
*Token
210 a callback function that the caller provides to feed data to the
211 EFI_MTFTP4_PROTOCOL.WriteFile() function.
213 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
214 @param Token The token provided in the
215 EFI_MTFTP4_PROTOCOL.WriteFile() by the caller.
216 @param Length Indicates the length of the raw data wanted on input, and the
217 length the data available on output.
218 @param Buffer Pointer to the buffer where the data is stored.
220 @retval EFI_SUCCESS Operation sucess
221 @retval Others Aborts session.
226 (EFIAPI
*EFI_MTFTP4_PACKET_NEEDED
)(
227 IN EFI_MTFTP4_PROTOCOL
*This
,
228 IN EFI_MTFTP4_TOKEN
*Token
,
229 IN OUT UINT16
*Length
,
236 Submits an asynchronous interrupt transfer to an interrupt endpoint of a USB device.
238 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
239 @param ModeData Pointer to storage for the EFI MTFTPv4 Protocol driver mode data.
241 @retval EFI_SUCCESS The configuration data was successfully returned.
242 @retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated.
243 @retval EFI_INVALID_PARAMETER This is NULL or ModeData is NULL.
248 (EFIAPI
*EFI_MTFTP4_GET_MODE_DATA
)(
249 IN EFI_MTFTP4_PROTOCOL
*This
,
250 OUT EFI_MTFTP4_MODE_DATA
*ModeData
256 Initializes, changes, or resets the default operational setting for this
257 EFI MTFTPv4 Protocol driver instance.
259 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
260 @param MtftpConfigData Pointer to the configuration data structure.
262 @retval EFI_SUCCESS The EFI MTFTPv4 Protocol driver was configured successfully.
263 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
264 @retval EFI_ACCESS_DENIED The EFI configuration could not be changed at this time because
265 there is one MTFTP background operation in progress.
266 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
267 RARP, etc.) has not finished yet.
268 @retval EFI_UNSUPPORTED A configuration protocol (DHCP, BOOTP, RARP, etc.) could not
269 be located when clients choose to use the default address
271 @retval EFI_OUT_OF_RESOURCES The EFI MTFTPv4 Protocol driver instance data could not be
273 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI
274 MTFTPv4 Protocol driver instance is not configured.
279 (EFIAPI
*EFI_MTFTP4_CONFIGURE
)(
280 IN EFI_MTFTP4_PROTOCOL
*This
,
281 IN EFI_MTFTP4_CONFIG_DATA
*MtftpConfigData OPTIONAL
287 Gets information about a file from an MTFTPv4 server.
289 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
290 @param OverrideData Data that is used to override the existing parameters. If NULL,
291 the default parameters that were set in the
292 EFI_MTFTP4_PROTOCOL.Configure() function are used.
293 @param Filename Pointer to ASCIIZ file name string.
294 @param ModeStr Pointer to ASCIIZ mode string. If NULL, "octet" will be used.
295 @param OptionCount Number of option/value string pairs in OptionList.
296 @param OptionList Pointer to array of option/value string pairs. Ignored if
298 @param PacketLength The number of bytes in the returned packet.
299 @param Packet The pointer to the received packet. This buffer must be freed by
302 @retval EFI_SUCCESS An MTFTPv4 OACK packet was received and is in the Buffer.
303 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
304 @retval EFI_UNSUPPORTED One or more options in the OptionList are in the
305 unsupported list of structure EFI_MTFTP4_MODE_DATA.
306 @retval EFI_NOT_STARTED The EFI MTFTPv4 Protocol driver has not been started.
307 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
308 RARP, etc.) has not finished yet.
309 @retval EFI_ACCESS_DENIED The previous operation has not completed yet.
310 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
311 @retval EFI_TFTP_ERROR An MTFTPv4 ERROR packet was received and is in the buffer.
312 @retval EFI_ICMP_ERROR An ICMP ERROR packet was received and is in the Buffer.
313 @retval EFI_PROTOCOL_ERROR An unexpected MTFTPv4 packet was received and is in the buffer.
314 @retval EFI_TIMEOUT No responses were received from the MTFTPv4 server.
315 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
320 (EFIAPI
*EFI_MTFTP4_GET_INFO
)(
321 IN EFI_MTFTP4_PROTOCOL
*This
,
322 IN EFI_MTFTP4_OVERRIDE_DATA
*OverrideData OPTIONAL
,
324 IN UINT8
*ModeStr OPTIONAL
,
325 IN UINT8 OptionCount
,
326 IN EFI_MTFTP4_OPTION
*OptionList
,
327 OUT UINT32
*PacketLength
,
328 OUT EFI_MTFTP4_PACKET
**Packet OPTIONAL
333 Parses the options in an MTFTPv4 OACK packet.
335 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
336 @param PacketLen Length of the OACK packet to be parsed.
337 @param Packet Pointer to the OACK packet to be parsed.
338 @param OptionCount Pointer to the number of options in following OptionList.
339 @param OptionList Pointer to EFI_MTFTP4_OPTION storage. Call the EFI Boot
340 Service FreePool() to release each option if they are not
343 @retval EFI_SUCCESS The OACK packet was valid and the OptionCount and
344 OptionList parameters have been updated.
345 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
347 - Packet is NULL or Packet is not a valid MTFTPv4 packet.
348 - OptionCount is NULL.
349 @retval EFI_NOT_FOUND No options were found in the OACK packet.
350 @retval EFI_OUT_OF_RESOURCES Storage for the OptionList array cannot be allocated.
351 @retval EFI_PROTOCOL_ERROR One or more of the option fields is invalid.
356 (EFIAPI
*EFI_MTFTP4_PARSE_OPTIONS
)(
357 IN EFI_MTFTP4_PROTOCOL
*This
,
359 IN EFI_MTFTP4_PACKET
*Packet
,
360 OUT UINT32
*OptionCount
,
361 OUT EFI_MTFTP4_OPTION
**OptionList OPTIONAL
367 Downloads a file from an MTFTPv4 server.
369 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
370 @param Token Pointer to the token structure to provide the parameters that are
371 used in this operation.
373 @retval EFI_SUCCESS The data file has been transferred successfully.
374 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
375 @retval EFI_BUFFER_TOO_SMALL BufferSize is not large enough to hold the downloaded data
376 in downloading process.
377 @retval EFI_ABORTED Current operation is aborted by user.
378 @retval EFI_ICMP_ERROR An ICMP ERROR packet was received.
379 @retval EFI_TIMEOUT No responses were received from the MTFTPv4 server.
380 @retval EFI_TFTP_ERROR An MTFTPv4 ERROR packet was received.
381 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
386 (EFIAPI
*EFI_MTFTP4_READ_FILE
)(
387 IN EFI_MTFTP4_PROTOCOL
*This
,
388 IN EFI_MTFTP4_TOKEN
*Token
395 Sends a file to an MTFTPv4 server.
397 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
398 @param Token Pointer to the token structure to provide the parameters that are
399 used in this operation.
401 @retval EFI_SUCCESS The upload session has started.
402 @retval EFI_UNSUPPORTED The operation is not supported by this implementation.
403 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
404 @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are in
405 the unsupported list of structure EFI_MTFTP4_MODE_DATA.
406 @retval EFI_NOT_STARTED The EFI MTFTPv4 Protocol driver has not been started.
407 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
408 RARP, etc.) is not finished yet.
409 @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv4 session.
410 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
411 @retval EFI_ACCESS_DENIED The previous operation has not completed yet.
412 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
417 (EFIAPI
*EFI_MTFTP4_WRITE_FILE
)(
418 IN EFI_MTFTP4_PROTOCOL
*This
,
419 IN EFI_MTFTP4_TOKEN
*Token
425 Downloads a data file "directory" from an MTFTPv4 server. May be unsupported in some EFI
428 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
429 @param Token Pointer to the token structure to provide the parameters that are
430 used in this operation.
432 @retval EFI_SUCCESS The MTFTPv4 related file "directory" has been downloaded.
433 @retval EFI_UNSUPPORTED The operation is not supported by this implementation.
434 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
435 @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are in
436 the unsupported list of structure EFI_MTFTP4_MODE_DATA.
437 @retval EFI_NOT_STARTED The EFI MTFTPv4 Protocol driver has not been started.
438 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
439 RARP, etc.) is not finished yet.
440 @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv4 session.
441 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
442 @retval EFI_ACCESS_DENIED The previous operation has not completed yet.
443 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
448 (EFIAPI
*EFI_MTFTP4_READ_DIRECTORY
)(
449 IN EFI_MTFTP4_PROTOCOL
*This
,
450 IN EFI_MTFTP4_TOKEN
*Token
455 Polls for incoming data packets and processes outgoing data packets.
457 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.
459 @retval EFI_SUCCESS Incoming or outgoing data was processed.
460 @retval EFI_NOT_STARTED This EFI MTFTPv4 Protocol instance has not been started.
461 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,
462 RARP, etc.) is not finished yet.
463 @retval EFI_INVALID_PARAMETER This is NULL.
464 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
465 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.
466 Consider increasing the polling rate.
471 (EFIAPI
*EFI_MTFTP4_POLL
) (
472 IN EFI_MTFTP4_PROTOCOL
*This
477 struct _EFI_MTFTP4_PROTOCOL
{
478 EFI_MTFTP4_GET_MODE_DATA GetModeData
;
479 EFI_MTFTP4_CONFIGURE Configure
;
480 EFI_MTFTP4_GET_INFO GetInfo
;
481 EFI_MTFTP4_PARSE_OPTIONS ParseOptions
;
482 EFI_MTFTP4_READ_FILE ReadFile
;
483 EFI_MTFTP4_WRITE_FILE WriteFile
;
484 EFI_MTFTP4_READ_DIRECTORY ReadDirectory
;
485 EFI_MTFTP4_POLL Poll
;
488 struct _EFI_MTFTP4_TOKEN
{
489 OUT EFI_STATUS Status
;
491 IN EFI_MTFTP4_OVERRIDE_DATA
*OverrideData
;
494 IN UINT32 OptionCount
;
495 IN EFI_MTFTP4_OPTION
*OptionList
;
496 IN OUT UINT64 BufferSize
;
498 IN EFI_MTFTP4_CHECK_PACKET CheckPacket
;
499 IN EFI_MTFTP4_TIMEOUT_CALLBACK TimeoutCallback
;
500 IN EFI_MTFTP4_PACKET_NEEDED PacketNeeded
;
503 extern EFI_GUID gEfiMtftp4ServiceBindingProtocolGuid
;
504 extern EFI_GUID gEfiMtftp4ProtocolGuid
;