1*f439973dSWarner Losh /** @file 2*f439973dSWarner Losh EFI Multicast Trivial File Transfer Protocol Definition 3*f439973dSWarner Losh 4*f439973dSWarner Losh Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> 5*f439973dSWarner Losh SPDX-License-Identifier: BSD-2-Clause-Patent 6*f439973dSWarner Losh 7*f439973dSWarner Losh @par Revision Reference: 8*f439973dSWarner Losh This Protocol is introduced in UEFI Specification 2.0 9*f439973dSWarner Losh 10*f439973dSWarner Losh **/ 11*f439973dSWarner Losh 12*f439973dSWarner Losh #ifndef __EFI_MTFTP4_PROTOCOL_H__ 13*f439973dSWarner Losh #define __EFI_MTFTP4_PROTOCOL_H__ 14*f439973dSWarner Losh 15*f439973dSWarner Losh #define EFI_MTFTP4_SERVICE_BINDING_PROTOCOL_GUID \ 16*f439973dSWarner Losh { \ 17*f439973dSWarner Losh 0x2FE800BE, 0x8F01, 0x4aa6, {0x94, 0x6B, 0xD7, 0x13, 0x88, 0xE1, 0x83, 0x3F } \ 18*f439973dSWarner Losh } 19*f439973dSWarner Losh 20*f439973dSWarner Losh #define EFI_MTFTP4_PROTOCOL_GUID \ 21*f439973dSWarner Losh { \ 22*f439973dSWarner Losh 0x78247c57, 0x63db, 0x4708, {0x99, 0xc2, 0xa8, 0xb4, 0xa9, 0xa6, 0x1f, 0x6b } \ 23*f439973dSWarner Losh } 24*f439973dSWarner Losh 25*f439973dSWarner Losh typedef struct _EFI_MTFTP4_PROTOCOL EFI_MTFTP4_PROTOCOL; 26*f439973dSWarner Losh typedef struct _EFI_MTFTP4_TOKEN EFI_MTFTP4_TOKEN; 27*f439973dSWarner Losh 28*f439973dSWarner Losh // 29*f439973dSWarner Losh // MTFTP4 packet opcode definition 30*f439973dSWarner Losh // 31*f439973dSWarner Losh #define EFI_MTFTP4_OPCODE_RRQ 1 32*f439973dSWarner Losh #define EFI_MTFTP4_OPCODE_WRQ 2 33*f439973dSWarner Losh #define EFI_MTFTP4_OPCODE_DATA 3 34*f439973dSWarner Losh #define EFI_MTFTP4_OPCODE_ACK 4 35*f439973dSWarner Losh #define EFI_MTFTP4_OPCODE_ERROR 5 36*f439973dSWarner Losh #define EFI_MTFTP4_OPCODE_OACK 6 37*f439973dSWarner Losh #define EFI_MTFTP4_OPCODE_DIR 7 38*f439973dSWarner Losh #define EFI_MTFTP4_OPCODE_DATA8 8 39*f439973dSWarner Losh #define EFI_MTFTP4_OPCODE_ACK8 9 40*f439973dSWarner Losh 41*f439973dSWarner Losh // 42*f439973dSWarner Losh // MTFTP4 error code definition 43*f439973dSWarner Losh // 44*f439973dSWarner Losh #define EFI_MTFTP4_ERRORCODE_NOT_DEFINED 0 45*f439973dSWarner Losh #define EFI_MTFTP4_ERRORCODE_FILE_NOT_FOUND 1 46*f439973dSWarner Losh #define EFI_MTFTP4_ERRORCODE_ACCESS_VIOLATION 2 47*f439973dSWarner Losh #define EFI_MTFTP4_ERRORCODE_DISK_FULL 3 48*f439973dSWarner Losh #define EFI_MTFTP4_ERRORCODE_ILLEGAL_OPERATION 4 49*f439973dSWarner Losh #define EFI_MTFTP4_ERRORCODE_UNKNOWN_TRANSFER_ID 5 50*f439973dSWarner Losh #define EFI_MTFTP4_ERRORCODE_FILE_ALREADY_EXISTS 6 51*f439973dSWarner Losh #define EFI_MTFTP4_ERRORCODE_NO_SUCH_USER 7 52*f439973dSWarner Losh #define EFI_MTFTP4_ERRORCODE_REQUEST_DENIED 8 53*f439973dSWarner Losh 54*f439973dSWarner Losh // 55*f439973dSWarner Losh // MTFTP4 pacekt definitions 56*f439973dSWarner Losh // 57*f439973dSWarner Losh #pragma pack(1) 58*f439973dSWarner Losh 59*f439973dSWarner Losh typedef struct { 60*f439973dSWarner Losh UINT16 OpCode; 61*f439973dSWarner Losh UINT8 Filename[1]; 62*f439973dSWarner Losh } EFI_MTFTP4_REQ_HEADER; 63*f439973dSWarner Losh 64*f439973dSWarner Losh typedef struct { 65*f439973dSWarner Losh UINT16 OpCode; 66*f439973dSWarner Losh UINT8 Data[1]; 67*f439973dSWarner Losh } EFI_MTFTP4_OACK_HEADER; 68*f439973dSWarner Losh 69*f439973dSWarner Losh typedef struct { 70*f439973dSWarner Losh UINT16 OpCode; 71*f439973dSWarner Losh UINT16 Block; 72*f439973dSWarner Losh UINT8 Data[1]; 73*f439973dSWarner Losh } EFI_MTFTP4_DATA_HEADER; 74*f439973dSWarner Losh 75*f439973dSWarner Losh typedef struct { 76*f439973dSWarner Losh UINT16 OpCode; 77*f439973dSWarner Losh UINT16 Block[1]; 78*f439973dSWarner Losh } EFI_MTFTP4_ACK_HEADER; 79*f439973dSWarner Losh 80*f439973dSWarner Losh typedef struct { 81*f439973dSWarner Losh UINT16 OpCode; 82*f439973dSWarner Losh UINT64 Block; 83*f439973dSWarner Losh UINT8 Data[1]; 84*f439973dSWarner Losh } EFI_MTFTP4_DATA8_HEADER; 85*f439973dSWarner Losh 86*f439973dSWarner Losh typedef struct { 87*f439973dSWarner Losh UINT16 OpCode; 88*f439973dSWarner Losh UINT64 Block[1]; 89*f439973dSWarner Losh } EFI_MTFTP4_ACK8_HEADER; 90*f439973dSWarner Losh 91*f439973dSWarner Losh typedef struct { 92*f439973dSWarner Losh UINT16 OpCode; 93*f439973dSWarner Losh UINT16 ErrorCode; 94*f439973dSWarner Losh UINT8 ErrorMessage[1]; 95*f439973dSWarner Losh } EFI_MTFTP4_ERROR_HEADER; 96*f439973dSWarner Losh 97*f439973dSWarner Losh typedef union { 98*f439973dSWarner Losh /// 99*f439973dSWarner Losh /// Type of packets as defined by the MTFTPv4 packet opcodes. 100*f439973dSWarner Losh /// 101*f439973dSWarner Losh UINT16 OpCode; 102*f439973dSWarner Losh /// 103*f439973dSWarner Losh /// Read request packet header. 104*f439973dSWarner Losh /// 105*f439973dSWarner Losh EFI_MTFTP4_REQ_HEADER Rrq; 106*f439973dSWarner Losh /// 107*f439973dSWarner Losh /// Write request packet header. 108*f439973dSWarner Losh /// 109*f439973dSWarner Losh EFI_MTFTP4_REQ_HEADER Wrq; 110*f439973dSWarner Losh /// 111*f439973dSWarner Losh /// Option acknowledge packet header. 112*f439973dSWarner Losh /// 113*f439973dSWarner Losh EFI_MTFTP4_OACK_HEADER Oack; 114*f439973dSWarner Losh /// 115*f439973dSWarner Losh /// Data packet header. 116*f439973dSWarner Losh /// 117*f439973dSWarner Losh EFI_MTFTP4_DATA_HEADER Data; 118*f439973dSWarner Losh /// 119*f439973dSWarner Losh /// Acknowledgement packet header. 120*f439973dSWarner Losh /// 121*f439973dSWarner Losh EFI_MTFTP4_ACK_HEADER Ack; 122*f439973dSWarner Losh /// 123*f439973dSWarner Losh /// Data packet header with big block number. 124*f439973dSWarner Losh /// 125*f439973dSWarner Losh EFI_MTFTP4_DATA8_HEADER Data8; 126*f439973dSWarner Losh /// 127*f439973dSWarner Losh /// Acknowledgement header with big block num. 128*f439973dSWarner Losh /// 129*f439973dSWarner Losh EFI_MTFTP4_ACK8_HEADER Ack8; 130*f439973dSWarner Losh /// 131*f439973dSWarner Losh /// Error packet header. 132*f439973dSWarner Losh /// 133*f439973dSWarner Losh EFI_MTFTP4_ERROR_HEADER Error; 134*f439973dSWarner Losh } EFI_MTFTP4_PACKET; 135*f439973dSWarner Losh 136*f439973dSWarner Losh #pragma pack() 137*f439973dSWarner Losh 138*f439973dSWarner Losh /// 139*f439973dSWarner Losh /// MTFTP4 option definition. 140*f439973dSWarner Losh /// 141*f439973dSWarner Losh typedef struct { 142*f439973dSWarner Losh UINT8 *OptionStr; 143*f439973dSWarner Losh UINT8 *ValueStr; 144*f439973dSWarner Losh } EFI_MTFTP4_OPTION; 145*f439973dSWarner Losh 146*f439973dSWarner Losh typedef struct { 147*f439973dSWarner Losh BOOLEAN UseDefaultSetting; 148*f439973dSWarner Losh EFI_IPv4_ADDRESS StationIp; 149*f439973dSWarner Losh EFI_IPv4_ADDRESS SubnetMask; 150*f439973dSWarner Losh UINT16 LocalPort; 151*f439973dSWarner Losh EFI_IPv4_ADDRESS GatewayIp; 152*f439973dSWarner Losh EFI_IPv4_ADDRESS ServerIp; 153*f439973dSWarner Losh UINT16 InitialServerPort; 154*f439973dSWarner Losh UINT16 TryCount; 155*f439973dSWarner Losh UINT16 TimeoutValue; 156*f439973dSWarner Losh } EFI_MTFTP4_CONFIG_DATA; 157*f439973dSWarner Losh 158*f439973dSWarner Losh typedef struct { 159*f439973dSWarner Losh EFI_MTFTP4_CONFIG_DATA ConfigData; 160*f439973dSWarner Losh UINT8 SupportedOptionCount; 161*f439973dSWarner Losh UINT8 **SupportedOptoins; 162*f439973dSWarner Losh UINT8 UnsupportedOptionCount; 163*f439973dSWarner Losh UINT8 **UnsupportedOptoins; 164*f439973dSWarner Losh } EFI_MTFTP4_MODE_DATA; 165*f439973dSWarner Losh 166*f439973dSWarner Losh typedef struct { 167*f439973dSWarner Losh EFI_IPv4_ADDRESS GatewayIp; 168*f439973dSWarner Losh EFI_IPv4_ADDRESS ServerIp; 169*f439973dSWarner Losh UINT16 ServerPort; 170*f439973dSWarner Losh UINT16 TryCount; 171*f439973dSWarner Losh UINT16 TimeoutValue; 172*f439973dSWarner Losh } EFI_MTFTP4_OVERRIDE_DATA; 173*f439973dSWarner Losh 174*f439973dSWarner Losh // 175*f439973dSWarner Losh // Protocol interfaces definition 176*f439973dSWarner Losh // 177*f439973dSWarner Losh 178*f439973dSWarner Losh /** 179*f439973dSWarner Losh A callback function that is provided by the caller to intercept 180*f439973dSWarner Losh the EFI_MTFTP4_OPCODE_DATA or EFI_MTFTP4_OPCODE_DATA8 packets processed in the 181*f439973dSWarner Losh EFI_MTFTP4_PROTOCOL.ReadFile() function, and alternatively to intercept 182*f439973dSWarner Losh EFI_MTFTP4_OPCODE_OACK or EFI_MTFTP4_OPCODE_ERROR packets during a call to 183*f439973dSWarner Losh EFI_MTFTP4_PROTOCOL.ReadFile(), WriteFile() or ReadDirectory(). 184*f439973dSWarner Losh 185*f439973dSWarner Losh @param This The pointer to the EFI_MTFTP4_PROTOCOL instance. 186*f439973dSWarner Losh @param Token The token that the caller provided in the 187*f439973dSWarner Losh EFI_MTFTP4_PROTOCOL.ReadFile(), WriteFile() 188*f439973dSWarner Losh or ReadDirectory() function. 189*f439973dSWarner Losh @param PacketLen Indicates the length of the packet. 190*f439973dSWarner Losh @param Packet The pointer to an MTFTPv4 packet. 191*f439973dSWarner Losh 192*f439973dSWarner Losh @retval EFI_SUCCESS The operation was successful. 193*f439973dSWarner Losh @retval Others Aborts the transfer process. 194*f439973dSWarner Losh 195*f439973dSWarner Losh **/ 196*f439973dSWarner Losh typedef 197*f439973dSWarner Losh EFI_STATUS 198*f439973dSWarner Losh (EFIAPI *EFI_MTFTP4_CHECK_PACKET)( 199*f439973dSWarner Losh IN EFI_MTFTP4_PROTOCOL *This, 200*f439973dSWarner Losh IN EFI_MTFTP4_TOKEN *Token, 201*f439973dSWarner Losh IN UINT16 PacketLen, 202*f439973dSWarner Losh IN EFI_MTFTP4_PACKET *Paket 203*f439973dSWarner Losh ); 204*f439973dSWarner Losh 205*f439973dSWarner Losh /** 206*f439973dSWarner Losh Timeout callback function. 207*f439973dSWarner Losh 208*f439973dSWarner Losh @param This The pointer to the EFI_MTFTP4_PROTOCOL instance. 209*f439973dSWarner Losh @param Token The token that is provided in the 210*f439973dSWarner Losh EFI_MTFTP4_PROTOCOL.ReadFile() or 211*f439973dSWarner Losh EFI_MTFTP4_PROTOCOL.WriteFile() or 212*f439973dSWarner Losh EFI_MTFTP4_PROTOCOL.ReadDirectory() functions 213*f439973dSWarner Losh by the caller. 214*f439973dSWarner Losh 215*f439973dSWarner Losh @retval EFI_SUCCESS The operation was successful. 216*f439973dSWarner Losh @retval Others Aborts download process. 217*f439973dSWarner Losh 218*f439973dSWarner Losh **/ 219*f439973dSWarner Losh typedef 220*f439973dSWarner Losh EFI_STATUS 221*f439973dSWarner Losh (EFIAPI *EFI_MTFTP4_TIMEOUT_CALLBACK)( 222*f439973dSWarner Losh IN EFI_MTFTP4_PROTOCOL *This, 223*f439973dSWarner Losh IN EFI_MTFTP4_TOKEN *Token 224*f439973dSWarner Losh ); 225*f439973dSWarner Losh 226*f439973dSWarner Losh /** 227*f439973dSWarner Losh A callback function that the caller provides to feed data to the 228*f439973dSWarner Losh EFI_MTFTP4_PROTOCOL.WriteFile() function. 229*f439973dSWarner Losh 230*f439973dSWarner Losh @param This The pointer to the EFI_MTFTP4_PROTOCOL instance. 231*f439973dSWarner Losh @param Token The token provided in the 232*f439973dSWarner Losh EFI_MTFTP4_PROTOCOL.WriteFile() by the caller. 233*f439973dSWarner Losh @param Length Indicates the length of the raw data wanted on input, and the 234*f439973dSWarner Losh length the data available on output. 235*f439973dSWarner Losh @param Buffer The pointer to the buffer where the data is stored. 236*f439973dSWarner Losh 237*f439973dSWarner Losh @retval EFI_SUCCESS The operation was successful. 238*f439973dSWarner Losh @retval Others Aborts session. 239*f439973dSWarner Losh 240*f439973dSWarner Losh **/ 241*f439973dSWarner Losh typedef 242*f439973dSWarner Losh EFI_STATUS 243*f439973dSWarner Losh (EFIAPI *EFI_MTFTP4_PACKET_NEEDED)( 244*f439973dSWarner Losh IN EFI_MTFTP4_PROTOCOL *This, 245*f439973dSWarner Losh IN EFI_MTFTP4_TOKEN *Token, 246*f439973dSWarner Losh IN OUT UINT16 *Length, 247*f439973dSWarner Losh OUT VOID **Buffer 248*f439973dSWarner Losh ); 249*f439973dSWarner Losh 250*f439973dSWarner Losh /** 251*f439973dSWarner Losh Submits an asynchronous interrupt transfer to an interrupt endpoint of a USB device. 252*f439973dSWarner Losh 253*f439973dSWarner Losh @param This The pointer to the EFI_MTFTP4_PROTOCOL instance. 254*f439973dSWarner Losh @param ModeData The pointer to storage for the EFI MTFTPv4 Protocol driver mode data. 255*f439973dSWarner Losh 256*f439973dSWarner Losh @retval EFI_SUCCESS The configuration data was successfully returned. 257*f439973dSWarner Losh @retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated. 258*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER This is NULL or ModeData is NULL. 259*f439973dSWarner Losh 260*f439973dSWarner Losh **/ 261*f439973dSWarner Losh typedef 262*f439973dSWarner Losh EFI_STATUS 263*f439973dSWarner Losh (EFIAPI *EFI_MTFTP4_GET_MODE_DATA)( 264*f439973dSWarner Losh IN EFI_MTFTP4_PROTOCOL *This, 265*f439973dSWarner Losh OUT EFI_MTFTP4_MODE_DATA *ModeData 266*f439973dSWarner Losh ); 267*f439973dSWarner Losh 268*f439973dSWarner Losh /** 269*f439973dSWarner Losh Initializes, changes, or resets the default operational setting for this 270*f439973dSWarner Losh EFI MTFTPv4 Protocol driver instance. 271*f439973dSWarner Losh 272*f439973dSWarner Losh @param This The pointer to the EFI_MTFTP4_PROTOCOL instance. 273*f439973dSWarner Losh @param MtftpConfigData The pointer to the configuration data structure. 274*f439973dSWarner Losh 275*f439973dSWarner Losh @retval EFI_SUCCESS The EFI MTFTPv4 Protocol driver was configured successfully. 276*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER One or more parameters are invalid. 277*f439973dSWarner Losh @retval EFI_ACCESS_DENIED The EFI configuration could not be changed at this time because 278*f439973dSWarner Losh there is one MTFTP background operation in progress. 279*f439973dSWarner Losh @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, 280*f439973dSWarner Losh RARP, etc.) has not finished yet. 281*f439973dSWarner Losh @retval EFI_UNSUPPORTED A configuration protocol (DHCP, BOOTP, RARP, etc.) could not 282*f439973dSWarner Losh be located when clients choose to use the default address 283*f439973dSWarner Losh settings. 284*f439973dSWarner Losh @retval EFI_OUT_OF_RESOURCES The EFI MTFTPv4 Protocol driver instance data could not be 285*f439973dSWarner Losh allocated. 286*f439973dSWarner Losh @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI 287*f439973dSWarner Losh MTFTPv4 Protocol driver instance is not configured. 288*f439973dSWarner Losh 289*f439973dSWarner Losh **/ 290*f439973dSWarner Losh typedef 291*f439973dSWarner Losh EFI_STATUS 292*f439973dSWarner Losh (EFIAPI *EFI_MTFTP4_CONFIGURE)( 293*f439973dSWarner Losh IN EFI_MTFTP4_PROTOCOL *This, 294*f439973dSWarner Losh IN EFI_MTFTP4_CONFIG_DATA *MtftpConfigData OPTIONAL 295*f439973dSWarner Losh ); 296*f439973dSWarner Losh 297*f439973dSWarner Losh /** 298*f439973dSWarner Losh Gets information about a file from an MTFTPv4 server. 299*f439973dSWarner Losh 300*f439973dSWarner Losh @param This The pointer to the EFI_MTFTP4_PROTOCOL instance. 301*f439973dSWarner Losh @param OverrideData Data that is used to override the existing parameters. If NULL, 302*f439973dSWarner Losh the default parameters that were set in the 303*f439973dSWarner Losh EFI_MTFTP4_PROTOCOL.Configure() function are used. 304*f439973dSWarner Losh @param Filename The pointer to null-terminated ASCII file name string. 305*f439973dSWarner Losh @param ModeStr The pointer to null-terminated ASCII mode string. If NULL, "octet" will be used. 306*f439973dSWarner Losh @param OptionCount Number of option/value string pairs in OptionList. 307*f439973dSWarner Losh @param OptionList The pointer to array of option/value string pairs. Ignored if 308*f439973dSWarner Losh OptionCount is zero. 309*f439973dSWarner Losh @param PacketLength The number of bytes in the returned packet. 310*f439973dSWarner Losh @param Packet The pointer to the received packet. This buffer must be freed by 311*f439973dSWarner Losh the caller. 312*f439973dSWarner Losh 313*f439973dSWarner Losh @retval EFI_SUCCESS An MTFTPv4 OACK packet was received and is in the Packet. 314*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: 315*f439973dSWarner Losh - This is NULL. 316*f439973dSWarner Losh - Filename is NULL. 317*f439973dSWarner Losh - OptionCount is not zero and OptionList is NULL. 318*f439973dSWarner Losh - One or more options in OptionList have wrong format. 319*f439973dSWarner Losh - PacketLength is NULL. 320*f439973dSWarner Losh - One or more IPv4 addresses in OverrideData are not valid 321*f439973dSWarner Losh unicast IPv4 addresses if OverrideData is not NULL. 322*f439973dSWarner Losh @retval EFI_UNSUPPORTED One or more options in the OptionList are in the 323*f439973dSWarner Losh unsupported list of structure EFI_MTFTP4_MODE_DATA. 324*f439973dSWarner Losh @retval EFI_NOT_STARTED The EFI MTFTPv4 Protocol driver has not been started. 325*f439973dSWarner Losh @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, 326*f439973dSWarner Losh RARP, etc.) has not finished yet. 327*f439973dSWarner Losh @retval EFI_ACCESS_DENIED The previous operation has not completed yet. 328*f439973dSWarner Losh @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. 329*f439973dSWarner Losh @retval EFI_TFTP_ERROR An MTFTPv4 ERROR packet was received and is in the Packet. 330*f439973dSWarner Losh @retval EFI_NETWORK_UNREACHABLE An ICMP network unreachable error packet was received and the Packet is set to NULL. 331*f439973dSWarner Losh @retval EFI_HOST_UNREACHABLE An ICMP host unreachable error packet was received and the Packet is set to NULL. 332*f439973dSWarner Losh @retval EFI_PROTOCOL_UNREACHABLE An ICMP protocol unreachable error packet was received and the Packet is set to NULL. 333*f439973dSWarner Losh @retval EFI_PORT_UNREACHABLE An ICMP port unreachable error packet was received and the Packet is set to NULL. 334*f439973dSWarner Losh @retval EFI_ICMP_ERROR Some other ICMP ERROR packet was received and is in the Buffer. 335*f439973dSWarner Losh @retval EFI_PROTOCOL_ERROR An unexpected MTFTPv4 packet was received and is in the Packet. 336*f439973dSWarner Losh @retval EFI_TIMEOUT No responses were received from the MTFTPv4 server. 337*f439973dSWarner Losh @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred. 338*f439973dSWarner Losh @retval EFI_NO_MEDIA There was a media error. 339*f439973dSWarner Losh 340*f439973dSWarner Losh **/ 341*f439973dSWarner Losh typedef 342*f439973dSWarner Losh EFI_STATUS 343*f439973dSWarner Losh (EFIAPI *EFI_MTFTP4_GET_INFO)( 344*f439973dSWarner Losh IN EFI_MTFTP4_PROTOCOL *This, 345*f439973dSWarner Losh IN EFI_MTFTP4_OVERRIDE_DATA *OverrideData OPTIONAL, 346*f439973dSWarner Losh IN UINT8 *Filename, 347*f439973dSWarner Losh IN UINT8 *ModeStr OPTIONAL, 348*f439973dSWarner Losh IN UINT8 OptionCount, 349*f439973dSWarner Losh IN EFI_MTFTP4_OPTION *OptionList, 350*f439973dSWarner Losh OUT UINT32 *PacketLength, 351*f439973dSWarner Losh OUT EFI_MTFTP4_PACKET **Packet OPTIONAL 352*f439973dSWarner Losh ); 353*f439973dSWarner Losh 354*f439973dSWarner Losh /** 355*f439973dSWarner Losh Parses the options in an MTFTPv4 OACK packet. 356*f439973dSWarner Losh 357*f439973dSWarner Losh @param This The pointer to the EFI_MTFTP4_PROTOCOL instance. 358*f439973dSWarner Losh @param PacketLen Length of the OACK packet to be parsed. 359*f439973dSWarner Losh @param Packet The pointer to the OACK packet to be parsed. 360*f439973dSWarner Losh @param OptionCount The pointer to the number of options in following OptionList. 361*f439973dSWarner Losh @param OptionList The pointer to EFI_MTFTP4_OPTION storage. Call the EFI Boot 362*f439973dSWarner Losh Service FreePool() to release the OptionList if the options 363*f439973dSWarner Losh in this OptionList are not needed any more. 364*f439973dSWarner Losh 365*f439973dSWarner Losh @retval EFI_SUCCESS The OACK packet was valid and the OptionCount and 366*f439973dSWarner Losh OptionList parameters have been updated. 367*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: 368*f439973dSWarner Losh - PacketLen is 0. 369*f439973dSWarner Losh - Packet is NULL or Packet is not a valid MTFTPv4 packet. 370*f439973dSWarner Losh - OptionCount is NULL. 371*f439973dSWarner Losh @retval EFI_NOT_FOUND No options were found in the OACK packet. 372*f439973dSWarner Losh @retval EFI_OUT_OF_RESOURCES Storage for the OptionList array cannot be allocated. 373*f439973dSWarner Losh @retval EFI_PROTOCOL_ERROR One or more of the option fields is invalid. 374*f439973dSWarner Losh 375*f439973dSWarner Losh **/ 376*f439973dSWarner Losh typedef 377*f439973dSWarner Losh EFI_STATUS 378*f439973dSWarner Losh (EFIAPI *EFI_MTFTP4_PARSE_OPTIONS)( 379*f439973dSWarner Losh IN EFI_MTFTP4_PROTOCOL *This, 380*f439973dSWarner Losh IN UINT32 PacketLen, 381*f439973dSWarner Losh IN EFI_MTFTP4_PACKET *Packet, 382*f439973dSWarner Losh OUT UINT32 *OptionCount, 383*f439973dSWarner Losh OUT EFI_MTFTP4_OPTION **OptionList OPTIONAL 384*f439973dSWarner Losh ); 385*f439973dSWarner Losh 386*f439973dSWarner Losh /** 387*f439973dSWarner Losh Downloads a file from an MTFTPv4 server. 388*f439973dSWarner Losh 389*f439973dSWarner Losh @param This The pointer to the EFI_MTFTP4_PROTOCOL instance. 390*f439973dSWarner Losh @param Token The pointer to the token structure to provide the parameters that are 391*f439973dSWarner Losh used in this operation. 392*f439973dSWarner Losh 393*f439973dSWarner Losh @retval EFI_SUCCESS The data file has been transferred successfully. 394*f439973dSWarner Losh @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. 395*f439973dSWarner Losh @retval EFI_BUFFER_TOO_SMALL BufferSize is not zero but not large enough to hold the 396*f439973dSWarner Losh downloaded data in downloading process. 397*f439973dSWarner Losh @retval EFI_ABORTED Current operation is aborted by user. 398*f439973dSWarner Losh @retval EFI_NETWORK_UNREACHABLE An ICMP network unreachable error packet was received. 399*f439973dSWarner Losh @retval EFI_HOST_UNREACHABLE An ICMP host unreachable error packet was received. 400*f439973dSWarner Losh @retval EFI_PROTOCOL_UNREACHABLE An ICMP protocol unreachable error packet was received. 401*f439973dSWarner Losh @retval EFI_PORT_UNREACHABLE An ICMP port unreachable error packet was received. 402*f439973dSWarner Losh @retval EFI_ICMP_ERROR Some other ICMP ERROR packet was received. 403*f439973dSWarner Losh @retval EFI_TIMEOUT No responses were received from the MTFTPv4 server. 404*f439973dSWarner Losh @retval EFI_TFTP_ERROR An MTFTPv4 ERROR packet was received. 405*f439973dSWarner Losh @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred. 406*f439973dSWarner Losh @retval EFI_NO_MEDIA There was a media error. 407*f439973dSWarner Losh 408*f439973dSWarner Losh **/ 409*f439973dSWarner Losh typedef 410*f439973dSWarner Losh EFI_STATUS 411*f439973dSWarner Losh (EFIAPI *EFI_MTFTP4_READ_FILE)( 412*f439973dSWarner Losh IN EFI_MTFTP4_PROTOCOL *This, 413*f439973dSWarner Losh IN EFI_MTFTP4_TOKEN *Token 414*f439973dSWarner Losh ); 415*f439973dSWarner Losh 416*f439973dSWarner Losh /** 417*f439973dSWarner Losh Sends a file to an MTFTPv4 server. 418*f439973dSWarner Losh 419*f439973dSWarner Losh @param This The pointer to the EFI_MTFTP4_PROTOCOL instance. 420*f439973dSWarner Losh @param Token The pointer to the token structure to provide the parameters that are 421*f439973dSWarner Losh used in this operation. 422*f439973dSWarner Losh 423*f439973dSWarner Losh @retval EFI_SUCCESS The upload session has started. 424*f439973dSWarner Losh @retval EFI_UNSUPPORTED The operation is not supported by this implementation. 425*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER One or more parameters are invalid. 426*f439973dSWarner Losh @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are in 427*f439973dSWarner Losh the unsupported list of structure EFI_MTFTP4_MODE_DATA. 428*f439973dSWarner Losh @retval EFI_NOT_STARTED The EFI MTFTPv4 Protocol driver has not been started. 429*f439973dSWarner Losh @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, 430*f439973dSWarner Losh RARP, etc.) is not finished yet. 431*f439973dSWarner Losh @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv4 session. 432*f439973dSWarner Losh @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. 433*f439973dSWarner Losh @retval EFI_ACCESS_DENIED The previous operation has not completed yet. 434*f439973dSWarner Losh @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred. 435*f439973dSWarner Losh 436*f439973dSWarner Losh **/ 437*f439973dSWarner Losh typedef 438*f439973dSWarner Losh EFI_STATUS 439*f439973dSWarner Losh (EFIAPI *EFI_MTFTP4_WRITE_FILE)( 440*f439973dSWarner Losh IN EFI_MTFTP4_PROTOCOL *This, 441*f439973dSWarner Losh IN EFI_MTFTP4_TOKEN *Token 442*f439973dSWarner Losh ); 443*f439973dSWarner Losh 444*f439973dSWarner Losh /** 445*f439973dSWarner Losh Downloads a data file "directory" from an MTFTPv4 server. May be unsupported in some EFI 446*f439973dSWarner Losh implementations. 447*f439973dSWarner Losh 448*f439973dSWarner Losh @param This The pointer to the EFI_MTFTP4_PROTOCOL instance. 449*f439973dSWarner Losh @param Token The pointer to the token structure to provide the parameters that are 450*f439973dSWarner Losh used in this operation. 451*f439973dSWarner Losh 452*f439973dSWarner Losh @retval EFI_SUCCESS The MTFTPv4 related file "directory" has been downloaded. 453*f439973dSWarner Losh @retval EFI_UNSUPPORTED The operation is not supported by this implementation. 454*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER One or more parameters are invalid. 455*f439973dSWarner Losh @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are in 456*f439973dSWarner Losh the unsupported list of structure EFI_MTFTP4_MODE_DATA. 457*f439973dSWarner Losh @retval EFI_NOT_STARTED The EFI MTFTPv4 Protocol driver has not been started. 458*f439973dSWarner Losh @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, 459*f439973dSWarner Losh RARP, etc.) is not finished yet. 460*f439973dSWarner Losh @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv4 session. 461*f439973dSWarner Losh @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. 462*f439973dSWarner Losh @retval EFI_ACCESS_DENIED The previous operation has not completed yet. 463*f439973dSWarner Losh @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred. 464*f439973dSWarner Losh 465*f439973dSWarner Losh **/ 466*f439973dSWarner Losh typedef 467*f439973dSWarner Losh EFI_STATUS 468*f439973dSWarner Losh (EFIAPI *EFI_MTFTP4_READ_DIRECTORY)( 469*f439973dSWarner Losh IN EFI_MTFTP4_PROTOCOL *This, 470*f439973dSWarner Losh IN EFI_MTFTP4_TOKEN *Token 471*f439973dSWarner Losh ); 472*f439973dSWarner Losh 473*f439973dSWarner Losh /** 474*f439973dSWarner Losh Polls for incoming data packets and processes outgoing data packets. 475*f439973dSWarner Losh 476*f439973dSWarner Losh @param This The pointer to the EFI_MTFTP4_PROTOCOL instance. 477*f439973dSWarner Losh 478*f439973dSWarner Losh @retval EFI_SUCCESS Incoming or outgoing data was processed. 479*f439973dSWarner Losh @retval EFI_NOT_STARTED This EFI MTFTPv4 Protocol instance has not been started. 480*f439973dSWarner Losh @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, 481*f439973dSWarner Losh RARP, etc.) is not finished yet. 482*f439973dSWarner Losh @retval EFI_INVALID_PARAMETER This is NULL. 483*f439973dSWarner Losh @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. 484*f439973dSWarner Losh @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue. 485*f439973dSWarner Losh Consider increasing the polling rate. 486*f439973dSWarner Losh 487*f439973dSWarner Losh **/ 488*f439973dSWarner Losh typedef 489*f439973dSWarner Losh EFI_STATUS 490*f439973dSWarner Losh (EFIAPI *EFI_MTFTP4_POLL)( 491*f439973dSWarner Losh IN EFI_MTFTP4_PROTOCOL *This 492*f439973dSWarner Losh ); 493*f439973dSWarner Losh 494*f439973dSWarner Losh /// 495*f439973dSWarner Losh /// The EFI_MTFTP4_PROTOCOL is designed to be used by UEFI drivers and applications 496*f439973dSWarner Losh /// to transmit and receive data files. The EFI MTFTPv4 Protocol driver uses 497*f439973dSWarner Losh /// the underlying EFI UDPv4 Protocol driver and EFI IPv4 Protocol driver. 498*f439973dSWarner Losh /// 499*f439973dSWarner Losh struct _EFI_MTFTP4_PROTOCOL { 500*f439973dSWarner Losh EFI_MTFTP4_GET_MODE_DATA GetModeData; 501*f439973dSWarner Losh EFI_MTFTP4_CONFIGURE Configure; 502*f439973dSWarner Losh EFI_MTFTP4_GET_INFO GetInfo; 503*f439973dSWarner Losh EFI_MTFTP4_PARSE_OPTIONS ParseOptions; 504*f439973dSWarner Losh EFI_MTFTP4_READ_FILE ReadFile; 505*f439973dSWarner Losh EFI_MTFTP4_WRITE_FILE WriteFile; 506*f439973dSWarner Losh EFI_MTFTP4_READ_DIRECTORY ReadDirectory; 507*f439973dSWarner Losh EFI_MTFTP4_POLL Poll; 508*f439973dSWarner Losh }; 509*f439973dSWarner Losh 510*f439973dSWarner Losh struct _EFI_MTFTP4_TOKEN { 511*f439973dSWarner Losh /// 512*f439973dSWarner Losh /// The status that is returned to the caller at the end of the operation 513*f439973dSWarner Losh /// to indicate whether this operation completed successfully. 514*f439973dSWarner Losh /// 515*f439973dSWarner Losh EFI_STATUS Status; 516*f439973dSWarner Losh /// 517*f439973dSWarner Losh /// The event that will be signaled when the operation completes. If 518*f439973dSWarner Losh /// set to NULL, the corresponding function will wait until the read or 519*f439973dSWarner Losh /// write operation finishes. The type of Event must be 520*f439973dSWarner Losh /// EVT_NOTIFY_SIGNAL. The Task Priority Level (TPL) of 521*f439973dSWarner Losh /// Event must be lower than or equal to TPL_CALLBACK. 522*f439973dSWarner Losh /// 523*f439973dSWarner Losh EFI_EVENT Event; 524*f439973dSWarner Losh /// 525*f439973dSWarner Losh /// If not NULL, the data that will be used to override the existing configure data. 526*f439973dSWarner Losh /// 527*f439973dSWarner Losh EFI_MTFTP4_OVERRIDE_DATA *OverrideData; 528*f439973dSWarner Losh /// 529*f439973dSWarner Losh /// The pointer to the null-terminated ASCII file name string. 530*f439973dSWarner Losh /// 531*f439973dSWarner Losh UINT8 *Filename; 532*f439973dSWarner Losh /// 533*f439973dSWarner Losh /// The pointer to the null-terminated ASCII mode string. If NULL, "octet" is used. 534*f439973dSWarner Losh /// 535*f439973dSWarner Losh UINT8 *ModeStr; 536*f439973dSWarner Losh /// 537*f439973dSWarner Losh /// Number of option/value string pairs. 538*f439973dSWarner Losh /// 539*f439973dSWarner Losh UINT32 OptionCount; 540*f439973dSWarner Losh /// 541*f439973dSWarner Losh /// The pointer to an array of option/value string pairs. Ignored if OptionCount is zero. 542*f439973dSWarner Losh /// 543*f439973dSWarner Losh EFI_MTFTP4_OPTION *OptionList; 544*f439973dSWarner Losh /// 545*f439973dSWarner Losh /// The size of the data buffer. 546*f439973dSWarner Losh /// 547*f439973dSWarner Losh UINT64 BufferSize; 548*f439973dSWarner Losh /// 549*f439973dSWarner Losh /// The pointer to the data buffer. Data that is downloaded from the 550*f439973dSWarner Losh /// MTFTPv4 server is stored here. Data that is uploaded to the 551*f439973dSWarner Losh /// MTFTPv4 server is read from here. Ignored if BufferSize is zero. 552*f439973dSWarner Losh /// 553*f439973dSWarner Losh VOID *Buffer; 554*f439973dSWarner Losh /// 555*f439973dSWarner Losh /// The pointer to the context that will be used by CheckPacket, 556*f439973dSWarner Losh /// TimeoutCallback and PacketNeeded. 557*f439973dSWarner Losh /// 558*f439973dSWarner Losh VOID *Context; 559*f439973dSWarner Losh /// 560*f439973dSWarner Losh /// The pointer to the callback function to check the contents of the received packet. 561*f439973dSWarner Losh /// 562*f439973dSWarner Losh EFI_MTFTP4_CHECK_PACKET CheckPacket; 563*f439973dSWarner Losh /// 564*f439973dSWarner Losh /// The pointer to the function to be called when a timeout occurs. 565*f439973dSWarner Losh /// 566*f439973dSWarner Losh EFI_MTFTP4_TIMEOUT_CALLBACK TimeoutCallback; 567*f439973dSWarner Losh /// 568*f439973dSWarner Losh /// The pointer to the function to provide the needed packet contents. 569*f439973dSWarner Losh /// 570*f439973dSWarner Losh EFI_MTFTP4_PACKET_NEEDED PacketNeeded; 571*f439973dSWarner Losh }; 572*f439973dSWarner Losh 573*f439973dSWarner Losh extern EFI_GUID gEfiMtftp4ServiceBindingProtocolGuid; 574*f439973dSWarner Losh extern EFI_GUID gEfiMtftp4ProtocolGuid; 575*f439973dSWarner Losh 576*f439973dSWarner Losh #endif 577