]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/PxeBaseCode.h
1d556685359200fcf750a62b3286a3a50916d3f6
[mirror_edk2.git] / MdePkg / Include / Protocol / PxeBaseCode.h
1 /** @file
2 EFI PXE Base Code Protocol definitions, which is used to access PXE-compatible
3 devices for network access and network booting.
4
5 Copyright (c) 2006 - 2008, Intel Corporation
6 All rights reserved. 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
10
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.
13
14 **/
15 #ifndef __PXE_BASE_CODE_PROTOCOL_H__
16 #define __PXE_BASE_CODE_PROTOCOL_H__
17
18 ///
19 /// PXE Base Code protocol
20 ///
21 #define EFI_PXE_BASE_CODE_PROTOCOL_GUID \
22 { \
23 0x03c4e603, 0xac28, 0x11d3, {0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
24 }
25
26 typedef struct _EFI_PXE_BASE_CODE_PROTOCOL EFI_PXE_BASE_CODE_PROTOCOL;
27
28 ///
29 /// Protocol defined in EFI1.1.
30 ///
31 typedef EFI_PXE_BASE_CODE_PROTOCOL EFI_PXE_BASE_CODE;
32
33 ///
34 /// Default IP TTL and ToS.
35 ///
36 #define DEFAULT_TTL 16
37 #define DEFAULT_ToS 0
38
39 ///
40 /// ICMP error format
41 ///
42 typedef struct {
43 UINT8 Type;
44 UINT8 Code;
45 UINT16 Checksum;
46 union {
47 UINT32 reserved;
48 UINT32 Mtu;
49 UINT32 Pointer;
50 struct {
51 UINT16 Identifier;
52 UINT16 Sequence;
53 } Echo;
54 } u;
55 UINT8 Data[494];
56 } EFI_PXE_BASE_CODE_ICMP_ERROR;
57
58 ///
59 /// TFTP error format
60 ///
61 typedef struct {
62 UINT8 ErrorCode;
63 CHAR8 ErrorString[127];
64 } EFI_PXE_BASE_CODE_TFTP_ERROR;
65
66 ///
67 /// IP Receive Filter definitions
68 ///
69 #define EFI_PXE_BASE_CODE_MAX_IPCNT 8
70
71 ///
72 /// IP Receive Filter structure
73 ///
74 typedef struct {
75 UINT8 Filters;
76 UINT8 IpCnt;
77 UINT16 reserved;
78 EFI_IP_ADDRESS IpList[EFI_PXE_BASE_CODE_MAX_IPCNT];
79 } EFI_PXE_BASE_CODE_IP_FILTER;
80
81 #define EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP 0x0001
82 #define EFI_PXE_BASE_CODE_IP_FILTER_BROADCAST 0x0002
83 #define EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS 0x0004
84 #define EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS_MULTICAST 0x0008
85
86 ///
87 /// ARP cache entries
88 ///
89 typedef struct {
90 EFI_IP_ADDRESS IpAddr;
91 EFI_MAC_ADDRESS MacAddr;
92 } EFI_PXE_BASE_CODE_ARP_ENTRY;
93
94 ///
95 /// ARP route table entries
96 ///
97 typedef struct {
98 EFI_IP_ADDRESS IpAddr;
99 EFI_IP_ADDRESS SubnetMask;
100 EFI_IP_ADDRESS GwAddr;
101 } EFI_PXE_BASE_CODE_ROUTE_ENTRY;
102
103 //
104 // UDP definitions
105 //
106 typedef UINT16 EFI_PXE_BASE_CODE_UDP_PORT;
107
108 #define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP 0x0001
109 #define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT 0x0002
110 #define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_IP 0x0004
111 #define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT 0x0008
112 #define EFI_PXE_BASE_CODE_UDP_OPFLAGS_USE_FILTER 0x0010
113 #define EFI_PXE_BASE_CODE_UDP_OPFLAGS_MAY_FRAGMENT 0x0020
114
115 //
116 // Discover() definitions
117 //
118 #define EFI_PXE_BASE_CODE_BOOT_TYPE_BOOTSTRAP 0
119 #define EFI_PXE_BASE_CODE_BOOT_TYPE_MS_WINNT_RIS 1
120 #define EFI_PXE_BASE_CODE_BOOT_TYPE_INTEL_LCM 2
121 #define EFI_PXE_BASE_CODE_BOOT_TYPE_DOSUNDI 3
122 #define EFI_PXE_BASE_CODE_BOOT_TYPE_NEC_ESMPRO 4
123 #define EFI_PXE_BASE_CODE_BOOT_TYPE_IBM_WSoD 5
124 #define EFI_PXE_BASE_CODE_BOOT_TYPE_IBM_LCCM 6
125 #define EFI_PXE_BASE_CODE_BOOT_TYPE_CA_UNICENTER_TNG 7
126 #define EFI_PXE_BASE_CODE_BOOT_TYPE_HP_OPENVIEW 8
127 #define EFI_PXE_BASE_CODE_BOOT_TYPE_ALTIRIS_9 9
128 #define EFI_PXE_BASE_CODE_BOOT_TYPE_ALTIRIS_10 10
129 #define EFI_PXE_BASE_CODE_BOOT_TYPE_ALTIRIS_11 11
130 #define EFI_PXE_BASE_CODE_BOOT_TYPE_NOT_USED_12 12
131 #define EFI_PXE_BASE_CODE_BOOT_TYPE_REDHAT_INSTALL 13
132 #define EFI_PXE_BASE_CODE_BOOT_TYPE_REDHAT_BOOT 14
133 #define EFI_PXE_BASE_CODE_BOOT_TYPE_REMBO 15
134 #define EFI_PXE_BASE_CODE_BOOT_TYPE_BEOBOOT 16
135 //
136 // 17 through 32767 are reserved
137 // 32768 through 65279 are for vendor use
138 // 65280 through 65534 are reserved
139 //
140 #define EFI_PXE_BASE_CODE_BOOT_TYPE_PXETEST 65535
141
142 #define EFI_PXE_BASE_CODE_BOOT_LAYER_MASK 0x7FFF
143 #define EFI_PXE_BASE_CODE_BOOT_LAYER_INITIAL 0x0000
144
145 ///
146 /// Discover() server list structure.
147 ///
148 typedef struct {
149 UINT16 Type;
150 BOOLEAN AcceptAnyResponse;
151 UINT8 Reserved;
152 EFI_IP_ADDRESS IpAddr;
153 } EFI_PXE_BASE_CODE_SRVLIST;
154
155 ///
156 /// Discover() information override structure.
157 ///
158 typedef struct {
159 BOOLEAN UseMCast;
160 BOOLEAN UseBCast;
161 BOOLEAN UseUCast;
162 BOOLEAN MustUseList;
163 EFI_IP_ADDRESS ServerMCastIp;
164 UINT16 IpCnt;
165 EFI_PXE_BASE_CODE_SRVLIST SrvList[1];
166 } EFI_PXE_BASE_CODE_DISCOVER_INFO;
167
168 ///
169 /// TFTP opcode definitions
170 ///
171 typedef enum {
172 EFI_PXE_BASE_CODE_TFTP_FIRST,
173 EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE,
174 EFI_PXE_BASE_CODE_TFTP_READ_FILE,
175 EFI_PXE_BASE_CODE_TFTP_WRITE_FILE,
176 EFI_PXE_BASE_CODE_TFTP_READ_DIRECTORY,
177 EFI_PXE_BASE_CODE_MTFTP_GET_FILE_SIZE,
178 EFI_PXE_BASE_CODE_MTFTP_READ_FILE,
179 EFI_PXE_BASE_CODE_MTFTP_READ_DIRECTORY,
180 EFI_PXE_BASE_CODE_MTFTP_LAST
181 } EFI_PXE_BASE_CODE_TFTP_OPCODE;
182
183 ///
184 /// MTFTP information. This information is required
185 /// to start or join a multicast TFTP session. It is also required to
186 /// perform the "get file size" and "read directory" operations of MTFTP.
187 ///
188 typedef struct {
189 EFI_IP_ADDRESS MCastIp;
190 EFI_PXE_BASE_CODE_UDP_PORT CPort;
191 EFI_PXE_BASE_CODE_UDP_PORT SPort;
192 UINT16 ListenTimeout;
193 UINT16 TransmitTimeout;
194 } EFI_PXE_BASE_CODE_MTFTP_INFO;
195
196 ///
197 /// DHCPV4 Packet structure
198 ///
199 typedef struct {
200 UINT8 BootpOpcode;
201 UINT8 BootpHwType;
202 UINT8 BootpHwAddrLen;
203 UINT8 BootpGateHops;
204 UINT32 BootpIdent;
205 UINT16 BootpSeconds;
206 UINT16 BootpFlags;
207 UINT8 BootpCiAddr[4];
208 UINT8 BootpYiAddr[4];
209 UINT8 BootpSiAddr[4];
210 UINT8 BootpGiAddr[4];
211 UINT8 BootpHwAddr[16];
212 UINT8 BootpSrvName[64];
213 UINT8 BootpBootFile[128];
214 UINT32 DhcpMagik;
215 UINT8 DhcpOptions[56];
216 } EFI_PXE_BASE_CODE_DHCPV4_PACKET;
217
218 ///
219 /// Packet structure
220 ///
221 typedef union {
222 UINT8 Raw[1472];
223 EFI_PXE_BASE_CODE_DHCPV4_PACKET Dhcpv4;
224 //
225 // EFI_PXE_BASE_CODE_DHCPV6_PACKET Dhcpv6;
226 //
227 } EFI_PXE_BASE_CODE_PACKET;
228
229 //
230 // PXE Base Code Mode structure
231 //
232 #define EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES 8
233 #define EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES 8
234
235 ///
236 /// EFI_PXE_BASE_CODE_MODE
237 /// The data values in this structure are read-only and
238 /// are updated by the code that produces the
239 /// EFI_PXE_BASE_CODE_PROTOCOL functions.
240 ///
241 typedef struct {
242 BOOLEAN Started;
243 BOOLEAN Ipv6Available;
244 BOOLEAN Ipv6Supported;
245 BOOLEAN UsingIpv6;
246 BOOLEAN BisSupported;
247 BOOLEAN BisDetected;
248 BOOLEAN AutoArp;
249 BOOLEAN SendGUID;
250 BOOLEAN DhcpDiscoverValid;
251 BOOLEAN DhcpAckReceived;
252 BOOLEAN ProxyOfferReceived;
253 BOOLEAN PxeDiscoverValid;
254 BOOLEAN PxeReplyReceived;
255 BOOLEAN PxeBisReplyReceived;
256 BOOLEAN IcmpErrorReceived;
257 BOOLEAN TftpErrorReceived;
258 BOOLEAN MakeCallbacks;
259 UINT8 TTL;
260 UINT8 ToS;
261 EFI_IP_ADDRESS StationIp;
262 EFI_IP_ADDRESS SubnetMask;
263 EFI_PXE_BASE_CODE_PACKET DhcpDiscover;
264 EFI_PXE_BASE_CODE_PACKET DhcpAck;
265 EFI_PXE_BASE_CODE_PACKET ProxyOffer;
266 EFI_PXE_BASE_CODE_PACKET PxeDiscover;
267 EFI_PXE_BASE_CODE_PACKET PxeReply;
268 EFI_PXE_BASE_CODE_PACKET PxeBisReply;
269 EFI_PXE_BASE_CODE_IP_FILTER IpFilter;
270 UINT32 ArpCacheEntries;
271 EFI_PXE_BASE_CODE_ARP_ENTRY ArpCache[EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES];
272 UINT32 RouteTableEntries;
273 EFI_PXE_BASE_CODE_ROUTE_ENTRY RouteTable[EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES];
274 EFI_PXE_BASE_CODE_ICMP_ERROR IcmpError;
275 EFI_PXE_BASE_CODE_TFTP_ERROR TftpError;
276 } EFI_PXE_BASE_CODE_MODE;
277
278 //
279 // PXE Base Code Interface Function definitions
280 //
281
282 /**
283 Enables the use of the PXE Base Code Protocol functions.
284
285 This function enables the use of the PXE Base Code Protocol functions. If the
286 Started field of the EFI_PXE_BASE_CODE_MODE structure is already TRUE, then
287 EFI_ALREADY_STARTED will be returned. If UseIpv6 is TRUE, then IPv6 formatted
288 addresses will be used in this session. If UseIpv6 is FALSE, then IPv4 formatted
289 addresses will be used in this session. If UseIpv6 is TRUE, and the Ipv6Supported
290 field of the EFI_PXE_BASE_CODE_MODE structure is FALSE, then EFI_UNSUPPORTED will
291 be returned. If there is not enough memory or other resources to start the PXE
292 Base Code Protocol, then EFI_OUT_OF_RESOURCES will be returned. Otherwise, the
293 PXE Base Code Protocol will be started, and all of the fields of the EFI_PXE_BASE_CODE_MODE
294 structure will be initialized as follows:
295 StartedSet to TRUE.
296 Ipv6SupportedUnchanged.
297 Ipv6AvailableUnchanged.
298 UsingIpv6Set to UseIpv6.
299 BisSupportedUnchanged.
300 BisDetectedUnchanged.
301 AutoArpSet to TRUE.
302 SendGUIDSet to FALSE.
303 TTLSet to DEFAULT_TTL.
304 ToSSet to DEFAULT_ToS.
305 DhcpCompletedSet to FALSE.
306 ProxyOfferReceivedSet to FALSE.
307 StationIpSet to an address of all zeros.
308 SubnetMaskSet to a subnet mask of all zeros.
309 DhcpDiscoverZero-filled.
310 DhcpAckZero-filled.
311 ProxyOfferZero-filled.
312 PxeDiscoverValidSet to FALSE.
313 PxeDiscoverZero-filled.
314 PxeReplyValidSet to FALSE.
315 PxeReplyZero-filled.
316 PxeBisReplyValidSet to FALSE.
317 PxeBisReplyZero-filled.
318 IpFilterSet the Filters field to 0 and the IpCnt field to 0.
319 ArpCacheEntriesSet to 0.
320 ArpCacheZero-filled.
321 RouteTableEntriesSet to 0.
322 RouteTableZero-filled.
323 IcmpErrorReceivedSet to FALSE.
324 IcmpErrorZero-filled.
325 TftpErroReceivedSet to FALSE.
326 TftpErrorZero-filled.
327 MakeCallbacksSet to TRUE if the PXE Base Code Callback Protocol is available.
328 Set to FALSE if the PXE Base Code Callback Protocol is not available.
329
330 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
331 @param UseIpv6 Specifies the type of IP addresses that are to be used during the session
332 that is being started. Set to TRUE for IPv6 addresses, and FALSE for
333 IPv4 addresses.
334
335 @retval EFI_SUCCESS The PXE Base Code Protocol was started.
336 @retval EFI_DEVICE_ERROR The network device encountered an error during this oper
337 @retval EFI_UNSUPPORTED UseIpv6 is TRUE, but the Ipv6Supported field of the
338 EFI_PXE_BASE_CODE_MODE structure is FALSE.
339 @retval EFI_ALREADY_STARTED The PXE Base Code Protocol is already in the started state.
340 @retval EFI_INVALID_PARAMETER The This parameter is NULL or does not point to a valid
341 EFI_PXE_BASE_CODE_PROTOCOL structure.
342 @retval EFI_OUT_OF_RESOURCES Could not allocate enough memory or other resources to start the
343 PXE Base Code Protocol.
344
345 **/
346 typedef
347 EFI_STATUS
348 (EFIAPI *EFI_PXE_BASE_CODE_START)(
349 IN EFI_PXE_BASE_CODE_PROTOCOL *This,
350 IN BOOLEAN UseIpv6
351 );
352
353 /**
354 Disables the use of the PXE Base Code Protocol functions.
355
356 This function stops all activity on the network device. All the resources allocated
357 in Start() are released, the Started field of the EFI_PXE_BASE_CODE_MODE structure is
358 set to FALSE and EFI_SUCCESS is returned. If the Started field of the EFI_PXE_BASE_CODE_MODE
359 structure is already FALSE, then EFI_NOT_STARTED will be returned.
360
361 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
362
363 @retval EFI_SUCCESS The PXE Base Code Protocol was stopped.
364 @retval EFI_NOT_STARTED The PXE Base Code Protocol is already in the stopped state.
365 @retval EFI_INVALID_PARAMETER The This parameter is NULL or does not point to a valid
366 EFI_PXE_BASE_CODE_PROTOCOL structure.
367 @retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
368
369 **/
370 typedef
371 EFI_STATUS
372 (EFIAPI *EFI_PXE_BASE_CODE_STOP)(
373 IN EFI_PXE_BASE_CODE_PROTOCOL *This
374 );
375
376 /**
377 Attempts to complete a DHCPv4 D.O.R.A. (discover / offer / request / acknowledge) or DHCPv6
378 S.A.R.R (solicit / advertise / request / reply) sequence.
379
380 This function attempts to complete the DHCP sequence. If this sequence is completed,
381 then EFI_SUCCESS is returned, and the DhcpCompleted, ProxyOfferReceived, StationIp,
382 SubnetMask, DhcpDiscover, DhcpAck, and ProxyOffer fields of the EFI_PXE_BASE_CODE_MODE
383 structure are filled in.
384 If SortOffers is TRUE, then the cached DHCP offer packets will be sorted before
385 they are tried. If SortOffers is FALSE, then the cached DHCP offer packets will
386 be tried in the order in which they are received. Please see the Preboot Execution
387 Environment (PXE) Specification for additional details on the implementation of DHCP.
388 This function can take at least 31 seconds to timeout and return control to the
389 caller. If the DHCP sequence does not complete, then EFI_TIMEOUT will be returned.
390 If the Callback Protocol does not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE,
391 then the DHCP sequence will be stopped and EFI_ABORTED will be returned.
392
393 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
394 @param SortOffers TRUE if the offers received should be sorted. Set to FALSE to try the
395 offers in the order that they are received.
396
397 @retval EFI_SUCCESS Valid DHCP has completed.
398 @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.
399 @retval EFI_INVALID_PARAMETER The This parameter is NULL or does not point to a valid
400 EFI_PXE_BASE_CODE_PROTOCOL structure.
401 @retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
402 @retval EFI_OUT_OF_RESOURCES Could not allocate enough memory to complete the DHCP Protocol.
403 @retval EFI_ABORTED The callback function aborted the DHCP Protocol.
404 @retval EFI_TIMEOUT The DHCP Protocol timed out.
405 @retval EFI_ICMP_ERROR An ICMP error packet was received during the DHCP session.
406 @retval EFI_NO_RESPONSE Valid PXE offer was not received.
407
408 **/
409 typedef
410 EFI_STATUS
411 (EFIAPI *EFI_PXE_BASE_CODE_DHCP)(
412 IN EFI_PXE_BASE_CODE_PROTOCOL *This,
413 IN BOOLEAN SortOffers
414 );
415
416 /**
417 Attempts to complete the PXE Boot Server and/or boot image discovery sequence.
418
419 This function attempts to complete the PXE Boot Server and/or boot image discovery
420 sequence. If this sequence is completed, then EFI_SUCCESS is returned, and the
421 PxeDiscoverValid, PxeDiscover, PxeReplyReceived, and PxeReply fields of the
422 EFI_PXE_BASE_CODE_MODE structure are filled in. If UseBis is TRUE, then the
423 PxeBisReplyReceived and PxeBisReply fields of the EFI_PXE_BASE_CODE_MODE structure
424 will also be filled in. If UseBis is FALSE, then PxeBisReplyValid will be set to FALSE.
425 In the structure referenced by parameter Info, the PXE Boot Server list, SrvList[],
426 has two uses: It is the Boot Server IP address list used for unicast discovery
427 (if the UseUCast field is TRUE), and it is the list used for Boot Server verification
428 (if the MustUseList field is TRUE). Also, if the MustUseList field in that structure
429 is TRUE and the AcceptAnyResponse field in the SrvList[] array is TRUE, any Boot
430 Server reply of that type will be accepted. If the AcceptAnyResponse field is
431 FALSE, only responses from Boot Servers with matching IP addresses will be accepted.
432 This function can take at least 10 seconds to timeout and return control to the
433 caller. If the Discovery sequence does not complete, then EFI_TIMEOUT will be
434 returned. Please see the Preboot Execution Environment (PXE) Specification for
435 additional details on the implementation of the Discovery sequence.
436 If the Callback Protocol does not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE,
437 then the Discovery sequence is stopped and EFI_ABORTED will be returned.
438
439 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
440 @param Type The type of bootstrap to perform.
441 @param Layer Pointer to the boot server layer number to discover, which must be
442 PXE_BOOT_LAYER_INITIAL when a new server type is being
443 discovered.
444 @param UseBis TRUE if Boot Integrity Services are to be used. FALSE otherwise.
445 @param Info Pointer to a data structure that contains additional information on the
446 type of discovery operation that is to be performed.
447
448 @retval EFI_SUCCESS The Discovery sequence has been completed.
449 @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.
450 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
451 @retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
452 @retval EFI_OUT_OF_RESOURCES Could not allocate enough memory to complete Discovery.
453 @retval EFI_ABORTED The callback function aborted the Discovery sequence.
454 @retval EFI_TIMEOUT The Discovery sequence timed out.
455 @retval EFI_ICMP_ERROR An ICMP error packet was received during the PXE discovery
456 session.
457
458 **/
459 typedef
460 EFI_STATUS
461 (EFIAPI *EFI_PXE_BASE_CODE_DISCOVER)(
462 IN EFI_PXE_BASE_CODE_PROTOCOL *This,
463 IN UINT16 Type,
464 IN UINT16 *Layer,
465 IN BOOLEAN UseBis,
466 IN EFI_PXE_BASE_CODE_DISCOVER_INFO *Info OPTIONAL
467 );
468
469 /**
470 Used to perform TFTP and MTFTP services.
471
472 This function is used to perform TFTP and MTFTP services. This includes the
473 TFTP operations to get the size of a file, read a directory, read a file, and
474 write a file. It also includes the MTFTP operations to get the size of a file,
475 read a directory, and read a file. The type of operation is specified by Operation.
476 If the callback function that is invoked during the TFTP/MTFTP operation does
477 not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, then EFI_ABORTED will
478 be returned.
479 For read operations, the return data will be placed in the buffer specified by
480 BufferPtr. If BufferSize is too small to contain the entire downloaded file,
481 then EFI_BUFFER_TOO_SMALL will be returned and BufferSize will be set to zero
482 or the size of the requested file (the size of the requested file is only returned
483 if the TFTP server supports TFTP options). If BufferSize is large enough for the
484 read operation, then BufferSize will be set to the size of the downloaded file,
485 and EFI_SUCCESS will be returned. Applications using the PxeBc.Mtftp() services
486 should use the get-file-size operations to determine the size of the downloaded
487 file prior to using the read-file operations--especially when downloading large
488 (greater than 64 MB) files--instead of making two calls to the read-file operation.
489 Following this recommendation will save time if the file is larger than expected
490 and the TFTP server does not support TFTP option extensions. Without TFTP option
491 extension support, the client has to download the entire file, counting and discarding
492 the received packets, to determine the file size.
493 For write operations, the data to be sent is in the buffer specified by BufferPtr.
494 BufferSize specifies the number of bytes to send. If the write operation completes
495 successfully, then EFI_SUCCESS will be returned.
496 For TFTP "get file size" operations, the size of the requested file or directory
497 is returned in BufferSize, and EFI_SUCCESS will be returned. If the TFTP server
498 does not support options, the file will be downloaded into a bit bucket and the
499 length of the downloaded file will be returned. For MTFTP "get file size" operations,
500 if the MTFTP server does not support the "get file size" option, EFI_UNSUPPORTED
501 will be returned.
502 This function can take up to 10 seconds to timeout and return control to the caller.
503 If the TFTP sequence does not complete, EFI_TIMEOUT will be returned.
504 If the Callback Protocol does not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE,
505 then the TFTP sequence is stopped and EFI_ABORTED will be returned.
506 The format of the data returned from a TFTP read directory operation is a null-terminated
507 filename followed by a null-terminated information string, of the form
508 "size year-month-day hour:minute:second" (i.e. %d %d-%d-%d %d:%d:%f - note that
509 the seconds field can be a decimal number), where the date and time are UTC. For
510 an MTFTP read directory command, there is additionally a null-terminated multicast
511 IP address preceding the filename of the form %d.%d.%d.%d for IP v4. The final
512 entry is itself null-terminated, so that the final information string is terminated
513 with two null octets.
514
515 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
516 @param Operation The type of operation to perform.
517 @param BufferPtr A pointer to the data buffer.
518 @param Overwrite Only used on write file operations. TRUE if a file on a remote server can
519 be overwritten.
520 @param BufferSize For get-file-size operations, *BufferSize returns the size of the
521 requested file.
522 @param BlockSize The requested block size to be used during a TFTP transfer.
523 @param ServerIp The TFTP / MTFTP server IP address.
524 @param Filename A Null-terminated ASCII string that specifies a directory name or a file
525 name.
526 @param Info Pointer to the MTFTP information.
527 @param DontUseBuffer Set to FALSE for normal TFTP and MTFTP read file operation.
528
529 @retval EFI_SUCCESS The TFTP/MTFTP operation was completed.
530 @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.
531 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
532 @retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
533 @retval EFI_BUFFER_TOO_SMALL The buffer is not large enough to complete the read operation.
534 @retval EFI_ABORTED The callback function aborted the TFTP/MTFTP operation.
535 @retval EFI_TIMEOUT The TFTP/MTFTP operation timed out.
536 @retval EFI_ICMP_ERROR An ICMP error packet was received during the MTFTP session.
537 @retval EFI_TFTP_ERROR A TFTP error packet was received during the MTFTP session.
538
539 **/
540 typedef
541 EFI_STATUS
542 (EFIAPI *EFI_PXE_BASE_CODE_MTFTP)(
543 IN EFI_PXE_BASE_CODE_PROTOCOL *This,
544 IN EFI_PXE_BASE_CODE_TFTP_OPCODE Operation,
545 IN OUT VOID *BufferPtr OPTIONAL,
546 IN BOOLEAN Overwrite,
547 IN OUT UINT64 *BufferSize,
548 IN UINTN *BlockSize OPTIONAL,
549 IN EFI_IP_ADDRESS *ServerIp,
550 IN UINT8 *Filename OPTIONAL,
551 IN EFI_PXE_BASE_CODE_MTFTP_INFO *Info OPTIONAL,
552 IN BOOLEAN DontUseBuffer
553 );
554
555 /**
556 Writes a UDP packet to the network interface.
557
558 This function writes a UDP packet specified by the (optional HeaderPtr and)
559 BufferPtr parameters to the network interface. The UDP header is automatically
560 built by this routine. It uses the parameters OpFlags, DestIp, DestPort, GatewayIp,
561 SrcIp, and SrcPort to build this header. If the packet is successfully built and
562 transmitted through the network interface, then EFI_SUCCESS will be returned.
563 If a timeout occurs during the transmission of the packet, then EFI_TIMEOUT will
564 be returned. If an ICMP error occurs during the transmission of the packet, then
565 the IcmpErrorReceived field is set to TRUE, the IcmpError field is filled in and
566 EFI_ICMP_ERROR will be returned. If the Callback Protocol does not return
567 EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, then EFI_ABORTED will be returned.
568
569 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
570 @param OpFlags The UDP operation flags.
571 @param DestIp The destination IP address.
572 @param DestPort The destination UDP port number.
573 @param GatewayIp The gateway IP address.
574 @param SrcIp The source IP address.
575 @param SrcPort The source UDP port number.
576 @param HeaderSize An optional field which may be set to the length of a header at
577 HeaderPtr to be prefixed to the data at BufferPtr.
578 @param HeaderPtr If HeaderSize is not NULL, a pointer to a header to be prefixed to the
579 data at BufferPtr.
580 @param BufferSize A pointer to the size of the data at BufferPtr.
581 @param BufferPtr A pointer to the data to be written.
582
583 @retval EFI_SUCCESS The UDP Write operation was completed.
584 @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.
585 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
586 @retval EFI_BAD_BUFFER_SIZE The buffer is too long to be transmitted.
587 @retval EFI_ABORTED The callback function aborted the UDP Write operation.
588 @retval EFI_TIMEOUT The UDP Write operation timed out.
589 @retval EFI_ICMP_ERROR An ICMP error packet was received during the UDP write session.
590
591 **/
592 typedef
593 EFI_STATUS
594 (EFIAPI *EFI_PXE_BASE_CODE_UDP_WRITE)(
595 IN EFI_PXE_BASE_CODE_PROTOCOL *This,
596 IN UINT16 OpFlags,
597 IN EFI_IP_ADDRESS *DestIp,
598 IN EFI_PXE_BASE_CODE_UDP_PORT *DestPort,
599 IN EFI_IP_ADDRESS *GatewayIp, OPTIONAL
600 IN EFI_IP_ADDRESS *SrcIp, OPTIONAL
601 IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort, OPTIONAL
602 IN UINTN *HeaderSize, OPTIONAL
603 IN VOID *HeaderPtr, OPTIONAL
604 IN UINTN *BufferSize,
605 IN VOID *BufferPtr
606 );
607
608 /**
609 Reads a UDP packet from the network interface.
610
611 This function reads a UDP packet from a network interface. The data contents
612 are returned in (the optional HeaderPtr and) BufferPtr, and the size of the
613 buffer received is returned in BufferSize . If the input BufferSize is smaller
614 than the UDP packet received (less optional HeaderSize), it will be set to the
615 required size, and EFI_BUFFER_TOO_SMALL will be returned. In this case, the
616 contents of BufferPtr are undefined, and the packet is lost. If a UDP packet is
617 successfully received, then EFI_SUCCESS will be returned, and the information
618 from the UDP header will be returned in DestIp, DestPort, SrcIp, and SrcPort if
619 they are not NULL.
620 Depending on the values of OpFlags and the DestIp, DestPort, SrcIp, and SrcPort
621 input values, different types of UDP packet receive filtering will be performed.
622 The following tables summarize these receive filter operations.
623
624 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
625 @param OpFlags The UDP operation flags.
626 @param DestIp The destination IP address.
627 @param DestPort The destination UDP port number.
628 @param SrcIp The source IP address.
629 @param SrcPort The source UDP port number.
630 @param HeaderSize An optional field which may be set to the length of a header at
631 HeaderPtr to be prefixed to the data at BufferPtr.
632 @param HeaderPtr If HeaderSize is not NULL, a pointer to a header to be prefixed to the
633 data at BufferPtr.
634 @param BufferSize A pointer to the size of the data at BufferPtr.
635 @param BufferPtr A pointer to the data to be read.
636
637 @retval EFI_SUCCESS The UDP Read operation was completed.
638 @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.
639 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
640 @retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
641 @retval EFI_BUFFER_TOO_SMALL The packet is larger than Buffer can hold.
642 @retval EFI_ABORTED The callback function aborted the UDP Read operation.
643 @retval EFI_TIMEOUT The UDP Read operation timed out.
644
645 **/
646 typedef
647 EFI_STATUS
648 (EFIAPI *EFI_PXE_BASE_CODE_UDP_READ)(
649 IN EFI_PXE_BASE_CODE_PROTOCOL *This,
650 IN UINT16 OpFlags,
651 IN OUT EFI_IP_ADDRESS *DestIp, OPTIONAL
652 IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort, OPTIONAL
653 IN OUT EFI_IP_ADDRESS *SrcIp, OPTIONAL
654 IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort, OPTIONAL
655 IN UINTN *HeaderSize, OPTIONAL
656 IN VOID *HeaderPtr, OPTIONAL
657 IN OUT UINTN *BufferSize,
658 IN VOID *BufferPtr
659 );
660
661 /**
662 Updates the IP receive filters of a network device and enables software filtering.
663
664 The NewFilter field is used to modify the network device's current IP receive
665 filter settings and to enable a software filter. This function updates the IpFilter
666 field of the EFI_PXE_BASE_CODE_MODE structure with the contents of NewIpFilter.
667 The software filter is used when the USE_FILTER in OpFlags is set to UdpRead().
668 The current hardware filter remains in effect no matter what the settings of OpFlags
669 are, so that the meaning of ANY_DEST_IP set in OpFlags to UdpRead() is from those
670 packets whose reception is enabled in hardware - physical NIC address (unicast),
671 broadcast address, logical address or addresses (multicast), or all (promiscuous).
672 UdpRead() does not modify the IP filter settings.
673 Dhcp(), Discover(), and Mtftp() set the IP filter, and return with the IP receive
674 filter list emptied and the filter set to EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP.
675 If an application or driver wishes to preserve the IP receive filter settings,
676 it will have to preserve the IP receive filter settings before these calls, and
677 use SetIpFilter() to restore them after the calls. If incompatible filtering is
678 requested (for example, PROMISCUOUS with anything else) or if the device does not
679 support a requested filter setting and it cannot be accommodated in software
680 (for example, PROMISCUOUS not supported), EFI_INVALID_PARAMETER will be returned.
681 The IPlist field is used to enable IPs other than the StationIP. They may be
682 multicast or unicast. If IPcnt is set as well as EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP,
683 then both the StationIP and the IPs from the IPlist will be used.
684
685 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
686 @param NewFilter Pointer to the new set of IP receive filters.
687
688 @retval EFI_SUCCESS The IP receive filter settings were updated.
689 @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.
690 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
691
692 **/
693 typedef
694 EFI_STATUS
695 (EFIAPI *EFI_PXE_BASE_CODE_SET_IP_FILTER)(
696 IN EFI_PXE_BASE_CODE_PROTOCOL *This,
697 IN EFI_PXE_BASE_CODE_IP_FILTER *NewFilter
698 );
699
700 /**
701 Uses the ARP protocol to resolve a MAC address.
702
703 This function uses the ARP protocol to resolve a MAC address. The UsingIpv6 field
704 of the EFI_PXE_BASE_CODE_MODE structure is used to determine if IPv4 or IPv6
705 addresses are being used. The IP address specified by IpAddr is used to resolve
706 a MAC address. If the ARP protocol succeeds in resolving the specified address,
707 then the ArpCacheEntries and ArpCache fields of the EFI_PXE_BASE_CODE_MODE structure
708 are updated, and EFI_SUCCESS is returned. If MacAddr is not NULL, the resolved
709 MAC address is placed there as well.
710 If the PXE Base Code protocol is in the stopped state, then EFI_NOT_STARTED is
711 returned. If the ARP protocol encounters a timeout condition while attempting
712 to resolve an address, then EFI_TIMEOUT is returned. If the Callback Protocol
713 does not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, then EFI_ABORTED is
714 returned.
715
716 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
717 @param IpAddr Pointer to the IP address that is used to resolve a MAC address.
718 @param MacAddr If not NULL, a pointer to the MAC address that was resolved with the
719 ARP protocol.
720
721 @retval EFI_SUCCESS The IP or MAC address was resolved.
722 @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.
723 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
724 @retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
725 @retval EFI_ABORTED The callback function aborted the ARP Protocol.
726 @retval EFI_TIMEOUT The ARP Protocol encountered a timeout condition.
727
728 **/
729 typedef
730 EFI_STATUS
731 (EFIAPI *EFI_PXE_BASE_CODE_ARP)(
732 IN EFI_PXE_BASE_CODE_PROTOCOL *This,
733 IN EFI_IP_ADDRESS *IpAddr,
734 IN EFI_MAC_ADDRESS *MacAddr OPTIONAL
735 );
736
737 /**
738 Updates the parameters that affect the operation of the PXE Base Code Protocol.
739
740 This function sets parameters that affect the operation of the PXE Base Code Protocol.
741 The parameter specified by NewAutoArp is used to control the generation of ARP
742 protocol packets. If NewAutoArp is TRUE, then ARP Protocol packets will be generated
743 as required by the PXE Base Code Protocol. If NewAutoArp is FALSE, then no ARP
744 Protocol packets will be generated. In this case, the only mappings that are
745 available are those stored in the ArpCache of the EFI_PXE_BASE_CODE_MODE structure.
746 If there are not enough mappings in the ArpCache to perform a PXE Base Code Protocol
747 service, then the service will fail. This function updates the AutoArp field of
748 the EFI_PXE_BASE_CODE_MODE structure to NewAutoArp.
749 The SetParameters() call must be invoked after a Callback Protocol is installed
750 to enable the use of callbacks.
751
752 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
753 @param NewAutoArp If not NULL, a pointer to a value that specifies whether to replace the
754 current value of AutoARP.
755 @param NewSendGUID If not NULL, a pointer to a value that specifies whether to replace the
756 current value of SendGUID.
757 @param NewTTL If not NULL, a pointer to be used in place of the current value of TTL,
758 the "time to live" field of the IP header.
759 @param NewToS If not NULL, a pointer to be used in place of the current value of ToS,
760 the "type of service" field of the IP header.
761 @param NewMakeCallback If not NULL, a pointer to a value that specifies whether to replace the
762 current value of the MakeCallback field of the Mode structure.
763
764 @retval EFI_SUCCESS The new parameters values were updated.
765 @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.
766 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
767
768 **/
769 typedef
770 EFI_STATUS
771 (EFIAPI *EFI_PXE_BASE_CODE_SET_PARAMETERS)(
772 IN EFI_PXE_BASE_CODE_PROTOCOL *This,
773 IN BOOLEAN *NewAutoArp, OPTIONAL
774 IN BOOLEAN *NewSendGUID, OPTIONAL
775 IN UINT8 *NewTTL, OPTIONAL
776 IN UINT8 *NewToS, OPTIONAL
777 IN BOOLEAN *NewMakeCallback OPTIONAL
778 );
779
780 /**
781 Updates the station IP address and/or subnet mask values of a network device.
782
783 This function updates the station IP address and/or subnet mask values of a network
784 device.
785 The NewStationIp field is used to modify the network device's current IP address.
786 If NewStationIP is NULL, then the current IP address will not be modified. Otherwise,
787 this function updates the StationIp field of the EFI_PXE_BASE_CODE_MODE structure
788 with NewStationIp.
789 The NewSubnetMask field is used to modify the network device's current subnet
790 mask. If NewSubnetMask is NULL, then the current subnet mask will not be modified.
791 Otherwise, this function updates the SubnetMask field of the EFI_PXE_BASE_CODE_MODE
792 structure with NewSubnetMask.
793
794 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
795 @param NewStationIp Pointer to the new IP address to be used by the network device.
796 @param NewSubnetMask Pointer to the new subnet mask to be used by the network device.
797
798 @retval EFI_SUCCESS The new station IP address and/or subnet mask were updated.
799 @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.
800 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
801
802 **/
803 typedef
804 EFI_STATUS
805 (EFIAPI *EFI_PXE_BASE_CODE_SET_STATION_IP)(
806 IN EFI_PXE_BASE_CODE_PROTOCOL *This,
807 IN EFI_IP_ADDRESS *NewStationIp, OPTIONAL
808 IN EFI_IP_ADDRESS *NewSubnetMask OPTIONAL
809 );
810
811 /**
812 Updates the contents of the cached DHCP and Discover packets.
813
814 The pointers to the new packets are used to update the contents of the cached
815 packets in the EFI_PXE_BASE_CODE_MODE structure.
816
817 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
818 @param NewDhcpDiscoverValid Pointer to a value that will replace the current
819 DhcpDiscoverValid field.
820 @param NewDhcpAckReceived Pointer to a value that will replace the current
821 DhcpAckReceived field.
822 @param NewProxyOfferReceived Pointer to a value that will replace the current
823 ProxyOfferReceived field.
824 @param NewPxeDiscoverValid Pointer to a value that will replace the current
825 ProxyOfferReceived field.
826 @param NewPxeReplyReceived Pointer to a value that will replace the current
827 PxeReplyReceived field.
828 @param NewPxeBisReplyReceived Pointer to a value that will replace the current
829 PxeBisReplyReceived field.
830 @param NewDhcpDiscover Pointer to the new cached DHCP Discover packet contents.
831 @param NewDhcpAck Pointer to the new cached DHCP Ack packet contents.
832 @param NewProxyOffer Pointer to the new cached Proxy Offer packet contents.
833 @param NewPxeDiscover Pointer to the new cached PXE Discover packet contents.
834 @param NewPxeReply Pointer to the new cached PXE Reply packet contents.
835 @param NewPxeBisReply Pointer to the new cached PXE BIS Reply packet contents.
836
837 @retval EFI_SUCCESS The cached packet contents were updated.
838 @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.
839 @retval EFI_INVALID_PARAMETER This is NULL or not point to a valid EFI_PXE_BASE_CODE_PROTOCOL structure.
840
841 **/
842 typedef
843 EFI_STATUS
844 (EFIAPI *EFI_PXE_BASE_CODE_SET_PACKETS)(
845 IN EFI_PXE_BASE_CODE_PROTOCOL *This,
846 BOOLEAN *NewDhcpDiscoverValid, OPTIONAL
847 BOOLEAN *NewDhcpAckReceived, OPTIONAL
848 BOOLEAN *NewProxyOfferReceived, OPTIONAL
849 BOOLEAN *NewPxeDiscoverValid, OPTIONAL
850 BOOLEAN *NewPxeReplyReceived, OPTIONAL
851 BOOLEAN *NewPxeBisReplyReceived, OPTIONAL
852 IN EFI_PXE_BASE_CODE_PACKET *NewDhcpDiscover, OPTIONAL
853 IN EFI_PXE_BASE_CODE_PACKET *NewDhcpAck, OPTIONAL
854 IN EFI_PXE_BASE_CODE_PACKET *NewProxyOffer, OPTIONAL
855 IN EFI_PXE_BASE_CODE_PACKET *NewPxeDiscover, OPTIONAL
856 IN EFI_PXE_BASE_CODE_PACKET *NewPxeReply, OPTIONAL
857 IN EFI_PXE_BASE_CODE_PACKET *NewPxeBisReply OPTIONAL
858 );
859
860 //
861 // PXE Base Code Protocol structure
862 //
863 #define EFI_PXE_BASE_CODE_PROTOCOL_REVISION 0x00010000
864
865 //
866 // Revision defined in EFI1.1
867 //
868 #define EFI_PXE_BASE_CODE_INTERFACE_REVISION EFI_PXE_BASE_CODE_PROTOCOL_REVISION
869
870 ///
871 /// The EFI_PXE_BASE_CODE_PROTOCOL is used to control PXE-compatible devices.
872 /// An EFI_PXE_BASE_CODE_PROTOCOL will be layered on top of an
873 /// EFI_MANAGED_NETWORK_PROTOCOL protocol in order to perform packet level transactions.
874 /// The EFI_PXE_BASE_CODE_PROTOCOL handle also supports the
875 /// EFI_LOAD_FILE_PROTOCOL protocol. This provides a clean way to obtain control from the
876 /// boot manager if the boot path is from the remote device.
877 ///
878 struct _EFI_PXE_BASE_CODE_PROTOCOL {
879 ///
880 /// The revision of the EFI_PXE_BASE_CODE_PROTOCOL. All future revisions must
881 /// be backwards compatible. If a future version is not backwards compatible
882 /// it is not the same GUID.
883 ///
884 UINT64 Revision;
885 EFI_PXE_BASE_CODE_START Start;
886 EFI_PXE_BASE_CODE_STOP Stop;
887 EFI_PXE_BASE_CODE_DHCP Dhcp;
888 EFI_PXE_BASE_CODE_DISCOVER Discover;
889 EFI_PXE_BASE_CODE_MTFTP Mtftp;
890 EFI_PXE_BASE_CODE_UDP_WRITE UdpWrite;
891 EFI_PXE_BASE_CODE_UDP_READ UdpRead;
892 EFI_PXE_BASE_CODE_SET_IP_FILTER SetIpFilter;
893 EFI_PXE_BASE_CODE_ARP Arp;
894 EFI_PXE_BASE_CODE_SET_PARAMETERS SetParameters;
895 EFI_PXE_BASE_CODE_SET_STATION_IP SetStationIp;
896 EFI_PXE_BASE_CODE_SET_PACKETS SetPackets;
897 ///
898 /// Pointer to the EFI_PXE_BASE_CODE_MODE data for this device.
899 ///
900 EFI_PXE_BASE_CODE_MODE *Mode;
901 };
902
903 extern EFI_GUID gEfiPxeBaseCodeProtocolGuid;
904
905 #endif