VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Mtftp6Dxe/Mtftp6Impl.h@ 48674

最後變更 在這個檔案從48674是 48674,由 vboxsync 提交於 11 年 前

EFI: Export newly imported tinaocore UEFI sources to OSE.

  • 屬性 svn:eol-style 設為 native
檔案大小: 22.8 KB
 
1/** @file
2 Mtftp6 internal data structure and definition declaration.
3
4 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>
5
6 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
16#ifndef __EFI_MTFTP6_IMPL_H__
17#define __EFI_MTFTP6_IMPL_H__
18
19#include <Uefi.h>
20
21#include <Protocol/Udp6.h>
22#include <Protocol/Mtftp6.h>
23#include <Protocol/ServiceBinding.h>
24#include <Protocol/DriverBinding.h>
25
26#include <Library/DebugLib.h>
27#include <Library/UefiDriverEntryPoint.h>
28#include <Library/UefiBootServicesTableLib.h>
29#include <Library/UefiLib.h>
30#include <Library/BaseLib.h>
31#include <Library/NetLib.h>
32
33typedef struct _MTFTP6_SERVICE MTFTP6_SERVICE;
34typedef struct _MTFTP6_INSTANCE MTFTP6_INSTANCE;
35
36#include "Mtftp6Driver.h"
37#include "Mtftp6Option.h"
38#include "Mtftp6Support.h"
39
40#define MTFTP6_SERVICE_SIGNATURE SIGNATURE_32 ('M', 'F', '6', 'S')
41#define MTFTP6_INSTANCE_SIGNATURE SIGNATURE_32 ('M', 'F', '6', 'I')
42
43#define MTFTP6_DEFAULT_SERVER_CMD_PORT 69
44#define MTFTP6_DEFAULT_TIMEOUT 3
45#define MTFTP6_GET_MAPPING_TIMEOUT 3
46#define MTFTP6_DEFAULT_MAX_RETRY 5
47#define MTFTP6_DEFAULT_BLK_SIZE 512
48#define MTFTP6_TICK_PER_SECOND 10000000U
49
50#define MTFTP6_SERVICE_FROM_THIS(a) CR (a, MTFTP6_SERVICE, ServiceBinding, MTFTP6_SERVICE_SIGNATURE)
51#define MTFTP6_INSTANCE_FROM_THIS(a) CR (a, MTFTP6_INSTANCE, Mtftp6, MTFTP6_INSTANCE_SIGNATURE)
52
53extern EFI_MTFTP6_PROTOCOL gMtftp6ProtocolTemplate;
54
55typedef struct _MTFTP6_GETINFO_CONTEXT{
56 EFI_MTFTP6_PACKET **Packet;
57 UINT32 *PacketLen;
58 EFI_STATUS Status;
59} MTFTP6_GETINFO_CONTEXT;
60
61//
62// Control block for MTFTP6 instance, it's per configuration data.
63//
64struct _MTFTP6_INSTANCE {
65 UINT32 Signature;
66 EFI_HANDLE Handle;
67 LIST_ENTRY Link;
68 EFI_MTFTP6_PROTOCOL Mtftp6;
69 MTFTP6_SERVICE *Service;
70 EFI_MTFTP6_CONFIG_DATA *Config;
71
72 EFI_MTFTP6_TOKEN *Token;
73 MTFTP6_EXT_OPTION_INFO ExtInfo;
74
75 UINT16 BlkSize;
76 UINT16 LastBlk;
77 LIST_ENTRY BlkList;
78
79 EFI_IPv6_ADDRESS ServerIp;
80 UINT16 ServerCmdPort;
81 UINT16 ServerDataPort;
82 UDP_IO *UdpIo;
83
84 EFI_IPv6_ADDRESS McastIp;
85 UINT16 McastPort;
86 UDP_IO *McastUdpIo;
87
88 NET_BUF *LastPacket;
89 UINT32 CurRetry;
90 UINT32 MaxRetry;
91 UINT32 PacketToLive;
92 UINT32 Timeout;
93
94 EFI_TPL OldTpl;
95 BOOLEAN IsTransmitted;
96 BOOLEAN IsMaster;
97 BOOLEAN InDestory;
98};
99
100//
101// Control block for MTFTP6 service, it's per Nic handle.
102//
103struct _MTFTP6_SERVICE {
104 UINT32 Signature;
105 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
106 EFI_HANDLE Controller;
107 EFI_HANDLE Image;
108
109 UINT16 ChildrenNum;
110 LIST_ENTRY Children;
111 //
112 // It is used to be as internal calculagraph for all instances.
113 //
114 EFI_EVENT Timer;
115 //
116 // It is used to maintain the parent-child relationship between
117 // mtftp driver and udp driver.
118 //
119 UDP_IO *DummyUdpIo;
120 BOOLEAN InDestory;
121};
122
123/**
124 Returns the current operating mode data for the MTFTP6 instance.
125
126 The GetModeData() function returns the current operating mode and
127 cached data packet for the MTFTP6 instance.
128
129 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.
130 @param[out] ModeData The buffer in which the EFI MTFTPv6 Protocol driver mode
131 data is returned.
132
133 @retval EFI_SUCCESS The configuration data was returned successfully.
134 @retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated.
135 @retval EFI_INVALID_PARAMETER This is NULL, or ModeData is NULL.
136
137**/
138EFI_STATUS
139EFIAPI
140EfiMtftp6GetModeData (
141 IN EFI_MTFTP6_PROTOCOL *This,
142 OUT EFI_MTFTP6_MODE_DATA *ModeData
143 );
144
145/**
146 Initializes, changes, or resets the default operational setting for
147 this EFI MTFTPv6 Protocol driver instance.
148
149 The Configure() function is used to set and change the configuration
150 data for this EFI MTFTPv6 Protocol driver instance. The configuration
151 data can be reset to startup defaults by calling Configure() with
152 MtftpConfigData set to NULL. Whenever the instance is reset, any
153 pending operation is aborted. By changing the EFI MTFTPv6 Protocol
154 driver instance configuration data, the client can connect to
155 different MTFTPv6 servers. The configuration parameters in
156 MtftpConfigData are used as the default parameters in later MTFTPv6
157 operations and can be overridden in later operations.
158
159 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.
160 @param[in] MtftpConfigData Pointer to the configuration data structure.
161
162 @retval EFI_SUCCESS The EFI MTFTPv6 Protocol instance was configured successfully.
163 @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:
164 - This is NULL.
165 - MtftpConfigData.StationIp is neither zero nor one
166 of the configured IP addresses in the underlying IPv6 driver.
167 - MtftpCofigData.ServerIp is not a valid IPv6 unicast address.
168 Note: It does not match the UEFI 2.3 Specification.
169 @retval EFI_ACCESS_DENIED - The configuration could not be changed at this time because there
170 is some MTFTP background operation in progress.
171 - MtftpCofigData.LocalPort is already in use.
172 Note: It does not match the UEFI 2.3 Specification.
173 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
174 address for this instance, but no source address was available for use.
175 @retval EFI_OUT_OF_RESOURCES The EFI MTFTPv6 Protocol driver instance data could not be
176 allocated.
177 Note: It is not defined in the UEFI 2.3 Specification.
178 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI
179 MTFTPv6 Protocol driver instance is not configured.
180 Note: It is not defined in the UEFI 2.3 Specification.
181
182**/
183EFI_STATUS
184EFIAPI
185EfiMtftp6Configure (
186 IN EFI_MTFTP6_PROTOCOL *This,
187 IN EFI_MTFTP6_CONFIG_DATA *MtftpConfigData OPTIONAL
188 );
189
190/**
191 Get the information of the download from the server.
192
193 The GetInfo() function assembles an MTFTPv6 request packet
194 with options, sends it to the MTFTPv6 server, and may return
195 an MTFTPv6 OACK, MTFTPv6 ERROR, or ICMP ERROR packet. Retries
196 occur only if no response packets are received from the MTFTPv6
197 server before the timeout expires.
198
199 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.
200 @param[in] OverrideData Data that is used to override the existing parameters. If NULL, the
201 default parameters that were set in the EFI_MTFTP6_PROTOCOL.Configure()
202 function are used.
203 @param[in] Filename Pointer to null-terminated ASCII file name string.
204 @param[in] ModeStr Pointer to null-terminated ASCII mode string. If NULL, octet will be used
205 @param[in] OptionCount Number of option/value string pairs in OptionList.
206 @param[in] OptionList Pointer to array of option/value string pairs. Ignored if
207 OptionCount is zero.
208 @param[out] PacketLength The number of bytes in the returned packet.
209 @param[out] Packet The pointer to the received packet. This buffer must be freed by
210 the caller.
211
212 @retval EFI_SUCCESS An MTFTPv6 OACK packet was received and is in the Packet.
213 Note: It does not match the UEFI 2.3 Specification.
214 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
215 - This is NULL.
216 - Filename is NULL.
217 - OptionCount is not zero and OptionList is NULL.
218 - One or more options in OptionList have wrong format.
219 - PacketLength is NULL.
220 - OverrideData.ServerIp is not a valid unicast IPv6 address.
221 @retval EFI_UNSUPPORTED One or more options in the OptionList are unsupported by
222 this implementation.
223 @retval EFI_NOT_STARTED The EFI MTFTPv6 Protocol driver has not been started.
224 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
225 address for this instance, but no source address was available for use.
226 @retval EFI_ACCESS_DENIED The previous operation has not completed yet.
227 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
228 @retval EFI_TFTP_ERROR An MTFTPv6 ERROR packet was received and is in the Packet.
229 @retval EFI_NETWORK_UNREACHABLE An ICMP network unreachable error packet was received, and the Packet is set to NULL.
230 Note: It is not defined in the UEFI 2.3 Specification.
231 @retval EFI_HOST_UNREACHABLE An ICMP host unreachable error packet was received, and the Packet is set to NULL.
232 Note: It is not defined in the UEFI 2.3 Specification.
233 @retval EFI_PROTOCOL_UNREACHABLE An ICMP protocol unreachable error packet was received, and the Packet is set to NULL.
234 Note: It is not defined in the UEFI 2.3 Specification.
235 @retval EFI_PORT_UNREACHABLE An ICMP port unreachable error packet was received, and the Packet is set to NULL.
236 @retval EFI_ICMP_ERROR Some other ICMP ERROR packet was received, and the Packet is set to NULL.
237 Note: It does not match the UEFI 2.3 Specification.
238 @retval EFI_PROTOCOL_ERROR An unexpected MTFTPv6 packet was received and is in the Packet.
239 @retval EFI_TIMEOUT No responses were received from the MTFTPv6 server.
240 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
241
242**/
243EFI_STATUS
244EFIAPI
245EfiMtftp6GetInfo (
246 IN EFI_MTFTP6_PROTOCOL *This,
247 IN EFI_MTFTP6_OVERRIDE_DATA *OverrideData OPTIONAL,
248 IN UINT8 *Filename,
249 IN UINT8 *ModeStr OPTIONAL,
250 IN UINT8 OptionCount,
251 IN EFI_MTFTP6_OPTION *OptionList OPTIONAL,
252 OUT UINT32 *PacketLength,
253 OUT EFI_MTFTP6_PACKET **Packet OPTIONAL
254 );
255
256/**
257 Parse the options in an MTFTPv6 OACK packet.
258
259 The ParseOptions() function parses the option fields in an MTFTPv6 OACK
260 packet and returns the number of options that were found, and optionally,
261 a list of pointers to the options in the packet. If one or more of the
262 option fields are not valid, then EFI_PROTOCOL_ERROR is returned and
263 *OptionCount and *OptionList stop at the last valid option.
264
265 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.
266 @param[in] PacketLen Length of the OACK packet to be parsed.
267 @param[in] Packet Pointer to the OACK packet to be parsed.
268 @param[out] OptionCount Pointer to the number of options in the following OptionList.
269 @param[out] OptionList Pointer to EFI_MTFTP6_OPTION storage. Each pointer in the
270 OptionList points to the corresponding MTFTP option buffer
271 in the Packet. Call the EFI Boot Service FreePool() to
272 release the OptionList if the options in this OptionList
273 are not needed any more.
274
275 @retval EFI_SUCCESS The OACK packet was valid and the OptionCount, and
276 OptionList parameters have been updated.
277 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
278 - PacketLen is 0.
279 - Packet is NULL or Packet is not a valid MTFTPv6 packet.
280 - OptionCount is NULL.
281 @retval EFI_NOT_FOUND No options were found in the OACK packet.
282 @retval EFI_OUT_OF_RESOURCES Storage for the OptionList array can not be allocated.
283 @retval EFI_PROTOCOL_ERROR One or more of the option fields is invalid.
284
285**/
286EFI_STATUS
287EFIAPI
288EfiMtftp6ParseOptions (
289 IN EFI_MTFTP6_PROTOCOL *This,
290 IN UINT32 PacketLen,
291 IN EFI_MTFTP6_PACKET *Packet,
292 OUT UINT32 *OptionCount,
293 OUT EFI_MTFTP6_OPTION **OptionList OPTIONAL
294 );
295
296/**
297 Download a file from an MTFTPv6 server.
298
299 The ReadFile() function is used to initialize and start an MTFTPv6 download
300 process and optionally wait for completion. When the download operation
301 completes, whether successfully or not, the Token.Status field is updated
302 by the EFI MTFTPv6 Protocol driver, and then Token.Event is signaled if it
303 is not NULL.
304 Data can be downloaded from the MTFTPv6 server into either of the following
305 locations:
306 - A fixed buffer that is pointed to by Token.Buffer.
307 - A download service function that is pointed to by Token.CheckPacket.
308 If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket
309 will be called first. If the call is successful, the packet will be stored
310 in Token.Buffer.
311
312 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.
313 @param[in] Token Pointer to the token structure to provide the parameters that are
314 used in this operation.
315
316 @retval EFI_SUCCESS The data file has been transferred successfully.
317 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
318 @retval EFI_BUFFER_TOO_SMALL BufferSize is not zero but not large enough to hold the
319 downloaded data in downloading process.
320 Note: It does not match the UEFI 2.3 Specification.
321 @retval EFI_ABORTED Current operation is aborted by user.
322 @retval EFI_NETWORK_UNREACHABLE An ICMP network unreachable error packet was received.
323 Note: It is not defined in the UEFI 2.3 Specification.
324 @retval EFI_HOST_UNREACHABLE An ICMP host unreachable error packet was received.
325 Note: It is not defined in the UEFI 2.3 Specification.
326 @retval EFI_PROTOCOL_UNREACHABLE An ICMP protocol unreachable error packet was received.
327 Note: It is not defined in the UEFI 2.3 Specification.
328 @retval EFI_PORT_UNREACHABLE An ICMP port unreachable error packet was received.
329 Note: It is not defined in the UEFI 2.3 Specification.
330 @retval EFI_ICMP_ERROR An ICMP ERROR packet was received.
331 @retval EFI_TIMEOUT No responses were received from the MTFTPv6 server.
332 @retval EFI_TFTP_ERROR An MTFTPv6 ERROR packet was received.
333 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
334
335**/
336EFI_STATUS
337EFIAPI
338EfiMtftp6ReadFile (
339 IN EFI_MTFTP6_PROTOCOL *This,
340 IN EFI_MTFTP6_TOKEN *Token
341 );
342
343/**
344 Send a file to an MTFTPv6 server.
345
346 The WriteFile() function is used to initialize an uploading operation
347 with the given option list, and optionally, wait for completion. If one
348 or more of the options is not supported by the server, the unsupported
349 options are ignored and a standard TFTP process starts instead. When
350 the upload process completes, whether successfully or not, Token.Event
351 is signaled, and the EFI MTFTPv6 Protocol driver updates Token.Status.
352 The caller can supply the data to be uploaded in the following two modes:
353 - Through the user-provided buffer.
354 - Through a callback function.
355 With the user-provided buffer, the Token.BufferSize field indicates
356 the length of the buffer, and the driver will upload the data in the
357 buffer. With an EFI_MTFTP6_PACKET_NEEDED callback function, the driver
358 will call this callback function to get more data from the user to upload.
359
360 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.
361 @param[in] Token Pointer to the token structure to provide the parameters that are
362 used in this operation.
363
364 @retval EFI_SUCCESS The upload session has started.
365 @retval EFI_UNSUPPORTED The operation is not supported by this implementation.
366 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
367 - This is NULL.
368 - Token is NULL.
369 - Token.Filename is NULL.
370 - Token.OptionCount is not zero and Token.OptionList is NULL.
371 - One or more options in Token.OptionList have wrong format.
372 - Token.Buffer and Token.PacketNeeded are both NULL.
373 - Token.OverrideData.ServerIp is not valid unicast IPv6 addresses.
374 @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are not
375 supported by this implementation.
376 @retval EFI_NOT_STARTED The EFI MTFTPv6 Protocol driver has not been started.
377 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
378 address for this instance, but no source address was available for use.
379 @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv6 session.
380 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
381 @retval EFI_ACCESS_DENIED The previous operation has not completed yet.
382 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
383
384**/
385EFI_STATUS
386EFIAPI
387EfiMtftp6WriteFile (
388 IN EFI_MTFTP6_PROTOCOL *This,
389 IN EFI_MTFTP6_TOKEN *Token
390 );
391
392/**
393 Download a data file directory from an MTFTPv6 server.
394
395 The ReadDirectory() function is used to return a list of files on the
396 MTFTPv6 server that are logically (or operationally) related to
397 Token.Filename. The directory request packet that is sent to the server
398 is built with the option list that was provided by caller, if present.
399 The file information that the server returns is put into either of
400 the following locations:
401 - A fixed buffer that is pointed to by Token.Buffer.
402 - A download service function that is pointed to by Token.CheckPacket.
403 If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket
404 will be called first. If the call is successful, the packet will be stored
405 in Token.Buffer.
406
407 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.
408 @param[in] Token Pointer to the token structure to provide the parameters that are
409 used in this operation.
410
411 @retval EFI_SUCCESS The MTFTPv6 related file "directory" has been downloaded.
412 @retval EFI_UNSUPPORTED The EFI MTFTPv6 Protocol driver does not support this function.
413 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
414 - This is NULL.
415 - Token is NULL.
416 - Token.Filename is NULL.
417 - Token.OptionCount is not zero and Token.OptionList is NULL.
418 - One or more options in Token.OptionList have wrong format.
419 - Token.Buffer and Token.CheckPacket are both NULL.
420 - Token.OverrideData.ServerIp is not valid unicast IPv6 addresses.
421 @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are not
422 supported by this implementation.
423 @retval EFI_NOT_STARTED The EFI MTFTPv6 Protocol driver has not been started.
424 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
425 address for this instance, but no source address was available for use.
426 @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv6 session.
427 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
428 @retval EFI_ACCESS_DENIED The previous operation has not completed yet.
429 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
430
431**/
432EFI_STATUS
433EFIAPI
434EfiMtftp6ReadDirectory (
435 IN EFI_MTFTP6_PROTOCOL *This,
436 IN EFI_MTFTP6_TOKEN *Token
437 );
438
439/**
440 Polls for incoming data packets and processes outgoing data packets.
441
442 The Poll() function can be used by network drivers and applications
443 to increase the rate that data packets are moved between the
444 communications device and the transmit and receive queues.In some
445 systems, the periodic timer event in the managed network driver may
446 not poll the underlying communications device fast enough to transmit
447 and/or receive all data packets without missing incoming packets or
448 dropping outgoing packets. Drivers and applications that are
449 experiencing packet loss should try calling the Poll() function
450 more often.
451
452 @param[in] This The MTFTP6 protocol instance.
453
454
455 @retval EFI_SUCCESS Incoming or outgoing data was processed.
456 @retval EFI_NOT_STARTED This EFI MTFTPv6 Protocol instance has not been started.
457 @retval EFI_INVALID_PARAMETER This is NULL.
458 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
459 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.
460 Consider increasing the polling rate.
461
462**/
463EFI_STATUS
464EFIAPI
465EfiMtftp6Poll (
466 IN EFI_MTFTP6_PROTOCOL *This
467 );
468
469#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette