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