TianoCore EDK2 master
Loading...
Searching...
No Matches
PxeBcImpl.h
Go to the documentation of this file.
1
11#ifndef __EFI_PXEBC_IMPL_H__
12#define __EFI_PXEBC_IMPL_H__
13
14#include <Uefi.h>
15
16#include <Guid/SmBios.h>
20#include <Protocol/Arp.h>
21#include <Protocol/Ip4.h>
22#include <Protocol/Ip4Config2.h>
23#include <Protocol/Ip6.h>
24#include <Protocol/Ip6Config.h>
25#include <Protocol/Udp4.h>
26#include <Protocol/Udp6.h>
27#include <Protocol/Dhcp4.h>
28#include <Protocol/Dhcp6.h>
29#include <Protocol/Dns6.h>
30#include <Protocol/Mtftp4.h>
31#include <Protocol/Mtftp6.h>
33#include <Protocol/LoadFile.h>
38
39#include <Library/DebugLib.h>
45#include <Library/UefiLib.h>
46#include <Library/BaseLib.h>
47#include <Library/NetLib.h>
48#include <Library/DpcLib.h>
50#include <Library/PcdLib.h>
52
56
57#include "PxeBcDriver.h"
58#include "PxeBcDhcp4.h"
59#include "PxeBcDhcp6.h"
60#include "PxeBcMtftp.h"
61#include "PxeBcBoot.h"
62#include "PxeBcSupport.h"
63
64#define PXEBC_DEFAULT_HOPLIMIT 64
65#define PXEBC_DEFAULT_LIFETIME 50000 // 50 ms, unit is microsecond
66#define PXEBC_UDP_TIMEOUT 30000000 // 3 seconds, unit is 100nanosecond
67#define PXEBC_DAD_ADDITIONAL_DELAY 30000000 // 3 seconds
68#define PXEBC_MTFTP_TIMEOUT 4
69#define PXEBC_MTFTP_RETRIES 6
70#define PXEBC_DHCP_RETRIES 4 // refers to mPxeDhcpTimeout, also by PXE2.1 spec.
71#define PXEBC_MENU_MAX_NUM 24
72#define PXEBC_OFFER_MAX_NUM 16
73
74#define PXEBC_CHECK_MEDIA_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20)
75
76#define PXEBC_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('P', 'X', 'E', 'P')
77#define PXEBC_VIRTUAL_NIC_SIGNATURE SIGNATURE_32 ('P', 'X', 'E', 'V')
78#define PXEBC_PRIVATE_DATA_FROM_PXEBC(a) CR (a, PXEBC_PRIVATE_DATA, PxeBc, PXEBC_PRIVATE_DATA_SIGNATURE)
79#define PXEBC_PRIVATE_DATA_FROM_ID(a) CR (a, PXEBC_PRIVATE_DATA, Id, PXEBC_PRIVATE_DATA_SIGNATURE)
80#define PXEBC_VIRTUAL_NIC_FROM_LOADFILE(a) CR (a, PXEBC_VIRTUAL_NIC, LoadFile, PXEBC_VIRTUAL_NIC_SIGNATURE)
81
82#define PXE_ENABLED 0x01
83#define PXE_DISABLED 0x00
84
85typedef union {
89
91 UINT64 Reserved;
92};
93
95 UINT32 Signature;
96 EFI_HANDLE Controller;
98 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
99 PXEBC_PRIVATE_DATA *Private;
100};
101
103 UINT32 Signature;
104 EFI_HANDLE Controller;
105 EFI_HANDLE Image;
106
109
110 PXEBC_VIRTUAL_NIC *Ip4Nic;
111 PXEBC_VIRTUAL_NIC *Ip6Nic;
112
113 EFI_HANDLE ArpChild;
114 EFI_HANDLE Ip4Child;
115 EFI_HANDLE Dhcp4Child;
116 EFI_HANDLE Mtftp4Child;
117 EFI_HANDLE Udp4ReadChild;
118 EFI_HANDLE Udp4WriteChild;
119
120 EFI_ARP_PROTOCOL *Arp;
121 EFI_IP4_PROTOCOL *Ip4;
122 EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
123 EFI_DHCP4_PROTOCOL *Dhcp4;
124 EFI_MTFTP4_PROTOCOL *Mtftp4;
125 EFI_UDP4_PROTOCOL *Udp4Read;
126 EFI_UDP4_PROTOCOL *Udp4Write;
127
128 EFI_HANDLE Ip6Child;
129 EFI_HANDLE Dhcp6Child;
130 EFI_HANDLE Mtftp6Child;
131 EFI_HANDLE Udp6ReadChild;
132 EFI_HANDLE Udp6WriteChild;
133
134 EFI_IP6_PROTOCOL *Ip6;
136 EFI_DHCP6_PROTOCOL *Dhcp6;
137 EFI_MTFTP6_PROTOCOL *Mtftp6;
138 EFI_UDP6_PROTOCOL *Udp6Read;
139 EFI_UDP6_PROTOCOL *Udp6Write;
140 EFI_DNS6_PROTOCOL *Dns6;
141
146 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
147
150 UINT32 Ip6Policy;
151 UINT32 SolicitTimes;
152 UINT64 ElapsedTime;
153
154 EFI_UDP4_CONFIG_DATA Udp4CfgData;
155 EFI_UDP6_CONFIG_DATA Udp6CfgData;
156 EFI_IP4_CONFIG_DATA Ip4CfgData;
157 EFI_IP6_CONFIG_DATA Ip6CfgData;
158
159 EFI_EVENT UdpTimeOutEvent;
160 EFI_EVENT ArpUpdateEvent;
161 EFI_IP4_COMPLETION_TOKEN IcmpToken;
162 EFI_IP6_COMPLETION_TOKEN Icmp6Token;
163
164 BOOLEAN IsAddressOk;
165 BOOLEAN IsOfferSorted;
166 BOOLEAN IsProxyRecved;
167 BOOLEAN IsDoDiscover;
168
169 EFI_IP_ADDRESS TmpStationIp;
170 EFI_IP_ADDRESS StationIp;
171 EFI_IP_ADDRESS SubnetMask;
172 EFI_IP_ADDRESS GatewayIp;
173 EFI_IP_ADDRESS ServerIp;
174 EFI_IPv6_ADDRESS *DnsServer;
175 UINT16 CurSrcPort;
176 UINT32 IaId;
177
178 UINT32 Ip4MaxPacketSize;
179 UINT32 Ip6MaxPacketSize;
180 UINT8 *BootFileName;
181 UINTN BootFileSize;
182 UINTN BlockSize;
183
184 PXEBC_DHCP_PACKET_CACHE ProxyOffer;
187 EFI_DHCP6_PACKET *Dhcp6Request;
188 EFI_DHCP4_PACKET SeedPacket;
189
190 //
191 // OfferIndex records the index of DhcpOffer[] buffer, and OfferCount records the num of each type of offer.
192 //
193 // It supposed that
194 //
195 // OfferNum: 8
196 // OfferBuffer: [ProxyBinl, ProxyBinl, DhcpOnly, ProxyPxe10, DhcpOnly, DhcpPxe10, DhcpBinl, ProxyBinl]
197 // (OfferBuffer is 0-based.)
198 //
199 // And assume that (DhcpPxe10 is the first priority actually.)
200 //
201 // SelectIndex: 2
202 // SelectProxyType: PXEBC_OFFER_TYPE_PROXY_BINL
203 // (SelectIndex is 1-based, and 0 means no one is selected.)
204 //
205 // So it should be
206 //
207 // DhcpOnly DhcpPxe10 DhcpWfm11a DhcpBinl ProxyPxe10 ProxyWfm11a ProxyBinl Bootp
208 // OfferCount: [ 2(n), 1(n), 0(n), 1(n), 1(1), 0(1), 3(n), 1(1)]
209 //
210 // OfferIndex: {[ 2, 5, 0, 6, 3, 0, *0, 0]
211 // [ 4, 0, 0, 0, 0, 0, 1, 0]
212 // [ 0, 0, 0, 0, 0, 0, 7, 0]
213 // ... ]}
214 // (OfferIndex is 0-based.)
215 //
216 //
217 UINT32 SelectIndex;
218 UINT32 SelectProxyType;
219 PXEBC_DHCP_PACKET_CACHE OfferBuffer[PXEBC_OFFER_MAX_NUM];
220 UINT32 OfferNum;
221 UINT32 OfferCount[PxeOfferTypeMax];
222 UINT32 OfferIndex[PxeOfferTypeMax][PXEBC_OFFER_MAX_NUM];
223};
224
225extern EFI_PXE_BASE_CODE_PROTOCOL gPxeBcProtocolTemplate;
226extern EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL gPxeBcCallBackTemplate;
227extern EFI_LOAD_FILE_PROTOCOL gLoadFileProtocolTemplate;
228
229#endif
UINT64 UINTN
EFI_PXE_BASE_CODE_FUNCTION
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33