]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/UefiPxeBcDxe/PxeBcSupport.h
UefiCpuPkg/PiSmmCpuDxeSmm: patch "gSmiCr3" with PatchInstructionX86()
[mirror_edk2.git] / NetworkPkg / UefiPxeBcDxe / PxeBcSupport.h
CommitLineData
a3bcde70
HT
1/** @file\r
2 Support functions declaration for UefiPxeBc Driver.\r
3\r
f8e13a24 4 Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
a3bcde70
HT
5\r
6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php.\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#ifndef __EFI_PXEBC_SUPPORT_H__\r
17#define __EFI_PXEBC_SUPPORT_H__\r
18\r
19\r
20#define ICMP_DEST_UNREACHABLE 3\r
21#define ICMP_SOURCE_QUENCH 4\r
22#define ICMP_REDIRECT 5\r
23#define ICMP_ECHO_REQUEST 8\r
24#define ICMP_TIME_EXCEEDED 11\r
25#define ICMP_PARAMETER_PROBLEM 12\r
26\r
27\r
a3bcde70
HT
28\r
29/**\r
30 Flush the previous configration using the new station Ip address.\r
31\r
32 @param[in] Private Pointer to PxeBc private data.\r
33 @param[in] StationIp Pointer to the station Ip address.\r
34 @param[in] SubnetMask Pointer to the subnet mask address for v4.\r
35\r
36 @retval EFI_SUCCESS Successfully flushed the previous config.\r
37 @retval Others Failed to flush using the new station Ip.\r
38\r
39**/\r
40EFI_STATUS\r
0e7f6f50 41PxeBcFlushStationIp (\r
a3bcde70 42 PXEBC_PRIVATE_DATA *Private,\r
f8e13a24 43 EFI_IP_ADDRESS *StationIp, OPTIONAL\r
a3bcde70
HT
44 EFI_IP_ADDRESS *SubnetMask OPTIONAL\r
45 );\r
46\r
47\r
48/**\r
49 Notify callback function when an event is triggered.\r
50\r
51 @param[in] Event The triggered event.\r
52 @param[in] Context The opaque parameter to the function.\r
53\r
54**/\r
55VOID\r
56EFIAPI\r
57PxeBcCommonNotify (\r
58 IN EFI_EVENT Event,\r
59 IN VOID *Context\r
60 );\r
61\r
62\r
63/**\r
64 Perform arp resolution from the arp cache in PxeBcMode.\r
65\r
66 @param Mode Pointer to EFI_PXE_BASE_CODE_MODE.\r
67 @param Ip4Addr The Ip4 address for resolution.\r
68 @param MacAddress The resoluted MAC address if the resolution is successful.\r
69 The value is undefined if resolution fails.\r
70\r
71 @retval TRUE Found a matched entry.\r
72 @retval FALSE Did not find a matched entry.\r
73\r
74**/\r
75BOOLEAN\r
76PxeBcCheckArpCache (\r
77 IN EFI_PXE_BASE_CODE_MODE *Mode,\r
78 IN EFI_IPv4_ADDRESS *Ip4Addr,\r
79 OUT EFI_MAC_ADDRESS *MacAddress\r
80 );\r
81\r
82\r
83/**\r
84 Update arp cache periodically.\r
85\r
86 @param Event Pointer to EFI_PXE_BC_PROTOCOL.\r
87 @param Context Context of the timer event.\r
88\r
89**/\r
90VOID\r
91EFIAPI\r
92PxeBcArpCacheUpdate (\r
93 IN EFI_EVENT Event,\r
94 IN VOID *Context\r
95 );\r
96\r
97\r
98/**\r
99 xxx\r
100\r
101 @param Event The event signaled.\r
102 @param Context The context passed in by the event notifier.\r
103\r
104**/\r
105VOID\r
106EFIAPI\r
107PxeBcIcmpErrorUpdate (\r
108 IN EFI_EVENT Event,\r
109 IN VOID *Context\r
110 );\r
111\r
112\r
113/**\r
114 xxx\r
115\r
116 @param Event The event signaled.\r
117 @param Context The context passed in by the event notifier.\r
118\r
119**/\r
120VOID\r
121EFIAPI\r
122PxeBcIcmp6ErrorUpdate (\r
123 IN EFI_EVENT Event,\r
124 IN VOID *Context\r
125 );\r
126\r
127\r
128/**\r
129 This function is to configure a UDPv4 instance for UdpWrite.\r
130\r
6f2f4116
FS
131 @param[in] Udp4 The pointer to EFI_UDP4_PROTOCOL.\r
132 @param[in] StationIp The pointer to the station address.\r
133 @param[in] SubnetMask The pointer to the subnet mask.\r
134 @param[in] Gateway The pointer to the gateway address.\r
135 @param[in, out] SrcPort The pointer to the source port.\r
136 @param[in] DoNotFragment If TRUE, fragment is not enabled.\r
137 Otherwise, fragment is enabled.\r
e895641b 138 @param[in] Ttl The time to live field of the IP header. \r
6f2f4116 139 @param[in] ToS The type of service field of the IP header.\r
a3bcde70
HT
140\r
141 @retval EFI_SUCCESS Successfully configured this instance.\r
142 @retval Others Failed to configure this instance.\r
143\r
144**/\r
145EFI_STATUS\r
146PxeBcConfigUdp4Write (\r
147 IN EFI_UDP4_PROTOCOL *Udp4,\r
148 IN EFI_IPv4_ADDRESS *StationIp,\r
149 IN EFI_IPv4_ADDRESS *SubnetMask,\r
150 IN EFI_IPv4_ADDRESS *Gateway,\r
151 IN OUT UINT16 *SrcPort,\r
6f2f4116 152 IN BOOLEAN DoNotFragment,\r
e895641b 153 IN UINT8 Ttl,\r
6f2f4116 154 IN UINT8 ToS\r
a3bcde70
HT
155 );\r
156\r
157\r
158/**\r
159 This function is to configure a UDPv6 instance for UdpWrite.\r
160\r
161 @param[in] Udp6 Pointer to EFI_UDP6_PROTOCOL.\r
162 @param[in] StationIp Pointer to the station address.\r
163 @param[in, out] SrcPort Pointer to the source port.\r
164\r
165 @retval EFI_SUCCESS Successfuly configured this instance.\r
166 @retval Others Failed to configure this instance.\r
167\r
168**/\r
169EFI_STATUS\r
170PxeBcConfigUdp6Write (\r
171 IN EFI_UDP6_PROTOCOL *Udp6,\r
172 IN EFI_IPv6_ADDRESS *StationIp,\r
173 IN OUT UINT16 *SrcPort\r
174 );\r
175\r
176/**\r
177 This function is to configure a UDPv4 instance for UdpWrite.\r
178\r
179 @param[in] Udp4 Pointer to EFI_UDP4_PROTOCOL.\r
180 @param[in] Session Pointer to the UDP4 session data.\r
181 @param[in] TimeoutEvent The event for timeout.\r
182 @param[in] Gateway Pointer to the gateway address.\r
183 @param[in] HeaderSize An optional field which may be set to the length of a header\r
184 at HeaderPtr to be prefixed to the data at BufferPtr.\r
185 @param[in] HeaderPtr If HeaderSize is not NULL, a pointer to a header to be\r
186 prefixed to the data at BufferPtr.\r
187 @param[in] BufferSize A pointer to the size of the data at BufferPtr.\r
188 @param[in] BufferPtr A pointer to the data to be written.\r
189\r
190 @retval EFI_SUCCESS Successfully sent out data with Udp4Write.\r
191 @retval Others Failed to send out data.\r
192\r
193**/\r
194EFI_STATUS\r
195PxeBcUdp4Write (\r
196 IN EFI_UDP4_PROTOCOL *Udp4,\r
197 IN EFI_UDP4_SESSION_DATA *Session,\r
198 IN EFI_EVENT TimeoutEvent,\r
199 IN EFI_IPv4_ADDRESS *Gateway OPTIONAL,\r
200 IN UINTN *HeaderSize OPTIONAL,\r
201 IN VOID *HeaderPtr OPTIONAL,\r
202 IN UINTN *BufferSize,\r
203 IN VOID *BufferPtr\r
204 );\r
205\r
206\r
207/**\r
208 This function is to configure a UDPv6 instance for UdpWrite.\r
209\r
210 @param[in] Udp6 Pointer to EFI_UDP6_PROTOCOL.\r
211 @param[in] Session Pointer to the UDP6 session data.\r
212 @param[in] TimeoutEvent The event for timeout.\r
213 @param[in] HeaderSize An optional field which may be set to the length of a header\r
214 at HeaderPtr to be prefixed to the data at BufferPtr.\r
215 @param[in] HeaderPtr If HeaderSize is not NULL, a pointer to a header to be\r
216 prefixed to the data at BufferPtr.\r
217 @param[in] BufferSize A pointer to the size of the data at BufferPtr.\r
218 @param[in] BufferPtr A pointer to the data to be written.\r
219\r
220 @retval EFI_SUCCESS Successfully to send out data with Udp6Write.\r
221 @retval Others Failed to send out data.\r
222\r
223**/\r
224EFI_STATUS\r
225PxeBcUdp6Write (\r
226 IN EFI_UDP6_PROTOCOL *Udp6,\r
227 IN EFI_UDP6_SESSION_DATA *Session,\r
228 IN EFI_EVENT TimeoutEvent,\r
229 IN UINTN *HeaderSize OPTIONAL,\r
230 IN VOID *HeaderPtr OPTIONAL,\r
231 IN UINTN *BufferSize,\r
232 IN VOID *BufferPtr\r
233 );\r
234\r
235\r
236/**\r
237 Check the received packet with the Ip filter.\r
238\r
239 @param[in] Mode Pointer to mode data of PxeBc.\r
240 @param[in] Session Pointer to the current UDPv4 session.\r
241 @param[in] OpFlags Operation flag for UdpRead/UdpWrite.\r
242\r
243 @retval TRUE Succesfully passed the Ip filter.\r
244 @retval FALSE Failed to pass the Ip filter.\r
245\r
246**/\r
247BOOLEAN\r
248PxeBcCheckByIpFilter (\r
249 IN EFI_PXE_BASE_CODE_MODE *Mode,\r
250 IN VOID *Session,\r
251 IN UINT16 OpFlags\r
252 );\r
253\r
254\r
255/**\r
256 Filter the received packet with the destination Ip.\r
257\r
258 @param[in] Mode Pointer to mode data of PxeBc.\r
259 @param[in] Session Pointer to the current UDPv4 session.\r
260 @param[in, out] DestIp Pointer to the dest Ip address.\r
261 @param[in] OpFlags Operation flag for UdpRead/UdpWrite.\r
262\r
263 @retval TRUE Succesfully passed the IPv4 filter.\r
264 @retval FALSE Failed to pass the IPv4 filter.\r
265\r
266**/\r
267BOOLEAN\r
268PxeBcCheckByDestIp (\r
269 IN EFI_PXE_BASE_CODE_MODE *Mode,\r
270 IN VOID *Session,\r
271 IN OUT EFI_IP_ADDRESS *DestIp,\r
272 IN UINT16 OpFlags\r
273 );\r
274\r
275\r
276/**\r
277 Check the received packet with the destination port.\r
278\r
76389e18 279 @param[in] Mode Pointer to mode data of PxeBc.\r
a3bcde70
HT
280 @param[in] Session Pointer to the current UDPv4 session.\r
281 @param[in, out] DestPort Pointer to the destination port.\r
282 @param[in] OpFlags Operation flag for UdpRead/UdpWrite.\r
283\r
284 @retval TRUE Succesfully passed the IPv4 filter.\r
285 @retval FALSE Failed to pass the IPv4 filter.\r
286\r
287**/\r
288BOOLEAN\r
289PxeBcCheckByDestPort (\r
290 IN EFI_PXE_BASE_CODE_MODE *Mode,\r
291 IN VOID *Session,\r
292 IN OUT UINT16 *DestPort,\r
293 IN UINT16 OpFlags\r
294 );\r
295\r
296\r
297/**\r
298 Filter the received packet with the source Ip.\r
299\r
300 @param[in] Mode Pointer to mode data of PxeBc.\r
301 @param[in] Session Pointer to the current UDPv4 session.\r
302 @param[in, out] SrcIp Pointer to the source Ip address.\r
303 @param[in] OpFlags Operation flag for UdpRead/UdpWrite.\r
304\r
305 @retval TRUE Succesfully passed the IPv4 filter.\r
306 @retval FALSE Failed to pass the IPv4 filter.\r
307\r
308**/\r
309BOOLEAN\r
310PxeBcFilterBySrcIp (\r
311 IN EFI_PXE_BASE_CODE_MODE *Mode,\r
312 IN VOID *Session,\r
313 IN OUT EFI_IP_ADDRESS *SrcIp,\r
314 IN UINT16 OpFlags\r
315 );\r
316\r
317\r
318/**\r
319 Filter the received packet with the source port.\r
320\r
321 @param[in] Mode Pointer to mode data of PxeBc.\r
322 @param[in] Session Pointer to the current UDPv4 session.\r
323 @param[in, out] SrcPort Pointer to the source port.\r
324 @param[in] OpFlags Operation flag for UdpRead/UdpWrite.\r
325\r
326 @retval TRUE Succesfully passed the IPv4 filter.\r
327 @retval FALSE Failed to pass the IPv4 filter.\r
328\r
329**/\r
330BOOLEAN\r
331PxeBcFilterBySrcPort (\r
332 IN EFI_PXE_BASE_CODE_MODE *Mode,\r
333 IN VOID *Session,\r
334 IN OUT UINT16 *SrcPort,\r
335 IN UINT16 OpFlags\r
336 );\r
337\r
338\r
339/**\r
340 This function is to receive packet with Udp4Read.\r
341\r
342 @param[in] Udp4 Pointer to EFI_UDP4_PROTOCOL.\r
343 @param[in] Token Pointer to EFI_UDP4_COMPLETION_TOKEN.\r
344 @param[in] Mode Pointer to EFI_PXE_BASE_CODE_MODE.\r
345 @param[in] TimeoutEvent The event for timeout.\r
346 @param[in] OpFlags The UDP operation flags.\r
347 @param[in] IsDone Pointer to IsDone flag.\r
348 @param[out] IsMatched Pointer to IsMatched flag.\r
349 @param[in, out] DestIp Pointer to destination address.\r
350 @param[in, out] DestPort Pointer to destination port.\r
351 @param[in, out] SrcIp Pointer to source address.\r
352 @param[in, out] SrcPort Pointer to source port.\r
353\r
354 @retval EFI_SUCCESS Successfully read data with Udp4.\r
355 @retval Others Failed to send out data.\r
356\r
357**/\r
358EFI_STATUS\r
359PxeBcUdp4Read (\r
360 IN EFI_UDP4_PROTOCOL *Udp4,\r
361 IN EFI_UDP4_COMPLETION_TOKEN *Token,\r
362 IN EFI_PXE_BASE_CODE_MODE *Mode,\r
363 IN EFI_EVENT TimeoutEvent,\r
364 IN UINT16 OpFlags,\r
365 IN BOOLEAN *IsDone,\r
366 OUT BOOLEAN *IsMatched,\r
367 IN OUT EFI_IP_ADDRESS *DestIp OPTIONAL,\r
368 IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort OPTIONAL,\r
369 IN OUT EFI_IP_ADDRESS *SrcIp OPTIONAL,\r
370 IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort OPTIONAL\r
371 );\r
372\r
373\r
374/**\r
375 This function is to receive packet with Udp6Read.\r
376\r
377 @param[in] Udp6 Pointer to EFI_UDP6_PROTOCOL.\r
378 @param[in] Token Pointer to EFI_UDP6_COMPLETION_TOKEN.\r
379 @param[in] Mode Pointer to EFI_PXE_BASE_CODE_MODE.\r
380 @param[in] TimeoutEvent The event for timeout.\r
381 @param[in] OpFlags The UDP operation flags.\r
382 @param[in] IsDone Pointer to IsDone flag.\r
383 @param[out] IsMatched Pointer to IsMatched flag.\r
384 @param[in, out] DestIp Pointer to destination address.\r
385 @param[in, out] DestPort Pointer to destination port.\r
386 @param[in, out] SrcIp Pointer to source address.\r
387 @param[in, out] SrcPort Pointer to source port.\r
388\r
389 @retval EFI_SUCCESS Successfully read data with Udp6.\r
390 @retval Others Failed to send out data.\r
391\r
392**/\r
393EFI_STATUS\r
394PxeBcUdp6Read (\r
395 IN EFI_UDP6_PROTOCOL *Udp6,\r
396 IN EFI_UDP6_COMPLETION_TOKEN *Token,\r
397 IN EFI_PXE_BASE_CODE_MODE *Mode,\r
398 IN EFI_EVENT TimeoutEvent,\r
399 IN UINT16 OpFlags,\r
400 IN BOOLEAN *IsDone,\r
401 OUT BOOLEAN *IsMatched,\r
402 IN OUT EFI_IP_ADDRESS *DestIp OPTIONAL,\r
403 IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort OPTIONAL,\r
404 IN OUT EFI_IP_ADDRESS *SrcIp OPTIONAL,\r
405 IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort OPTIONAL\r
406 );\r
407\r
408\r
409/**\r
410 This function is to display the IPv4 address.\r
411\r
412 @param[in] Ip Pointer to the IPv4 address.\r
413\r
414**/\r
415VOID\r
416PxeBcShowIp4Addr (\r
417 IN EFI_IPv4_ADDRESS *Ip\r
418 );\r
419\r
420\r
421/**\r
422 This function is to display the IPv6 address.\r
423\r
424 @param[in] Ip Pointer to the IPv6 address.\r
425\r
426**/\r
427VOID\r
428PxeBcShowIp6Addr (\r
429 IN EFI_IPv6_ADDRESS *Ip\r
430 );\r
431\r
432\r
433/**\r
434 This function is to convert UINTN to ASCII string with required format.\r
435\r
436 @param[in] Number Numeric value to be converted.\r
437 @param[in] Buffer Pointer to the buffer for ASCII string.\r
438 @param[in] Length Length of the required format.\r
439\r
440**/\r
441VOID\r
442PxeBcUintnToAscDecWithFormat (\r
443 IN UINTN Number,\r
444 IN UINT8 *Buffer,\r
445 IN INTN Length\r
446 );\r
447\r
448\r
449/**\r
450 This function is to convert a UINTN to a ASCII string, and return the\r
451 actual length of the buffer.\r
452\r
453 @param[in] Number Numeric value to be converted.\r
454 @param[in] Buffer Pointer to the buffer for ASCII string.\r
c960bdc2
ZL
455 @param[in] BufferSize The maxsize of the buffer.\r
456 \r
a3bcde70
HT
457 @return Length The actual length of the ASCII string.\r
458\r
459**/\r
460UINTN\r
461PxeBcUintnToAscDec (\r
462 IN UINTN Number,\r
c960bdc2
ZL
463 IN UINT8 *Buffer,\r
464 IN UINTN BufferSize\r
a3bcde70
HT
465 );\r
466\r
467/**\r
468 This function is to convert unicode hex number to a UINT8.\r
469\r
470 @param[out] Digit The converted UINT8 for output.\r
471 @param[in] Char The unicode hex number to be converted.\r
472\r
473 @retval EFI_SUCCESS Successfully converted the unicode hex.\r
474 @retval EFI_INVALID_PARAMETER Failed to convert the unicode hex.\r
475\r
476**/\r
477EFI_STATUS\r
478PxeBcUniHexToUint8 (\r
479 OUT UINT8 *Digit,\r
480 IN CHAR16 Char\r
481 );\r
482\r
129b8b09 483/**\r
f43b7a54 484 Calculate the elapsed time.\r
129b8b09 485\r
486 @param[in] Private The pointer to PXE private data\r
487\r
488**/\r
489VOID\r
490CalcElapsedTime (\r
491 IN PXEBC_PRIVATE_DATA *Private\r
492 );\r
493\r
216f7970 494/**\r
495 Get the Nic handle using any child handle in the IPv4 stack.\r
496\r
497 @param[in] ControllerHandle Pointer to child handle over IPv4.\r
498\r
499 @return NicHandle The pointer to the Nic handle.\r
500\r
501**/\r
502EFI_HANDLE\r
503PxeBcGetNicByIp4Children (\r
504 IN EFI_HANDLE ControllerHandle\r
505 );\r
506\r
507/**\r
508 Get the Nic handle using any child handle in the IPv6 stack.\r
509\r
510 @param[in] ControllerHandle Pointer to child handle over IPv6.\r
511\r
512 @return NicHandle The pointer to the Nic handle.\r
513\r
514**/\r
515EFI_HANDLE\r
516PxeBcGetNicByIp6Children (\r
517 IN EFI_HANDLE ControllerHandle\r
518 );\r
a3bcde70 519#endif\r