1 | /** @file
|
---|
2 | This EFI_PXE_BASE_CODE_PROTOCOL and EFI_LOAD_FILE_PROTOCOL.
|
---|
3 | interfaces declaration.
|
---|
4 |
|
---|
5 | Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
|
---|
6 |
|
---|
7 | This program and the accompanying materials
|
---|
8 | are licensed and made available under the terms and conditions of the BSD License
|
---|
9 | which accompanies this distribution. The full text of the license may be found at
|
---|
10 | http://opensource.org/licenses/bsd-license.php.
|
---|
11 |
|
---|
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
---|
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
---|
14 |
|
---|
15 | **/
|
---|
16 |
|
---|
17 | #ifndef __EFI_PXEBC_IMPL_H__
|
---|
18 | #define __EFI_PXEBC_IMPL_H__
|
---|
19 |
|
---|
20 | #include <Uefi.h>
|
---|
21 |
|
---|
22 | #include <Guid/SmBios.h>
|
---|
23 | #include <IndustryStandard/SmBios.h>
|
---|
24 | #include <IndustryStandard/Dhcp.h>
|
---|
25 | #include <Protocol/NetworkInterfaceIdentifier.h>
|
---|
26 | #include <Protocol/Arp.h>
|
---|
27 | #include <Protocol/Ip4.h>
|
---|
28 | #include <Protocol/Ip4Config2.h>
|
---|
29 | #include <Protocol/Ip6.h>
|
---|
30 | #include <Protocol/Ip6Config.h>
|
---|
31 | #include <Protocol/Udp4.h>
|
---|
32 | #include <Protocol/Udp6.h>
|
---|
33 | #include <Protocol/Dhcp4.h>
|
---|
34 | #include <Protocol/Dhcp6.h>
|
---|
35 | #include <Protocol/Dns6.h>
|
---|
36 | #include <Protocol/Mtftp4.h>
|
---|
37 | #include <Protocol/Mtftp6.h>
|
---|
38 | #include <Protocol/PxeBaseCode.h>
|
---|
39 | #include <Protocol/LoadFile.h>
|
---|
40 | #include <Protocol/PxeBaseCodeCallBack.h>
|
---|
41 | #include <Protocol/ServiceBinding.h>
|
---|
42 | #include <Protocol/DriverBinding.h>
|
---|
43 | #include <Protocol/AdapterInformation.h>
|
---|
44 |
|
---|
45 | #include <Library/DebugLib.h>
|
---|
46 | #include <Library/BaseMemoryLib.h>
|
---|
47 | #include <Library/MemoryAllocationLib.h>
|
---|
48 | #include <Library/UefiDriverEntryPoint.h>
|
---|
49 | #include <Library/UefiBootServicesTableLib.h>
|
---|
50 | #include <Library/UefiRuntimeServicesTableLib.h>
|
---|
51 | #include <Library/UefiLib.h>
|
---|
52 | #include <Library/BaseLib.h>
|
---|
53 | #include <Library/NetLib.h>
|
---|
54 | #include <Library/DpcLib.h>
|
---|
55 | #include <Library/DevicePathLib.h>
|
---|
56 | #include <Library/PcdLib.h>
|
---|
57 |
|
---|
58 | typedef struct _PXEBC_PRIVATE_DATA PXEBC_PRIVATE_DATA;
|
---|
59 | typedef struct _PXEBC_PRIVATE_PROTOCOL PXEBC_PRIVATE_PROTOCOL;
|
---|
60 | typedef struct _PXEBC_VIRTUAL_NIC PXEBC_VIRTUAL_NIC;
|
---|
61 |
|
---|
62 | #include "PxeBcDriver.h"
|
---|
63 | #include "PxeBcDhcp4.h"
|
---|
64 | #include "PxeBcDhcp6.h"
|
---|
65 | #include "PxeBcMtftp.h"
|
---|
66 | #include "PxeBcBoot.h"
|
---|
67 | #include "PxeBcSupport.h"
|
---|
68 |
|
---|
69 | #define PXEBC_DEFAULT_HOPLIMIT 64
|
---|
70 | #define PXEBC_DEFAULT_LIFETIME 50000 // 50 ms, unit is microsecond
|
---|
71 | #define PXEBC_UDP_TIMEOUT 30000000 // 3 seconds, unit is 100nanosecond
|
---|
72 | #define PXEBC_DAD_ADDITIONAL_DELAY 30000000 // 3 seconds
|
---|
73 | #define PXEBC_MTFTP_TIMEOUT 4
|
---|
74 | #define PXEBC_MTFTP_RETRIES 6
|
---|
75 | #define PXEBC_DHCP_RETRIES 4 // refers to mPxeDhcpTimeout, also by PXE2.1 spec.
|
---|
76 | #define PXEBC_MENU_MAX_NUM 24
|
---|
77 | #define PXEBC_OFFER_MAX_NUM 16
|
---|
78 |
|
---|
79 | #define PXEBC_CHECK_MEDIA_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20)
|
---|
80 |
|
---|
81 | #define PXEBC_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('P', 'X', 'E', 'P')
|
---|
82 | #define PXEBC_VIRTUAL_NIC_SIGNATURE SIGNATURE_32 ('P', 'X', 'E', 'V')
|
---|
83 | #define PXEBC_PRIVATE_DATA_FROM_PXEBC(a) CR (a, PXEBC_PRIVATE_DATA, PxeBc, PXEBC_PRIVATE_DATA_SIGNATURE)
|
---|
84 | #define PXEBC_PRIVATE_DATA_FROM_ID(a) CR (a, PXEBC_PRIVATE_DATA, Id, PXEBC_PRIVATE_DATA_SIGNATURE)
|
---|
85 | #define PXEBC_VIRTUAL_NIC_FROM_LOADFILE(a) CR (a, PXEBC_VIRTUAL_NIC, LoadFile, PXEBC_VIRTUAL_NIC_SIGNATURE)
|
---|
86 |
|
---|
87 | typedef union {
|
---|
88 | PXEBC_DHCP4_PACKET_CACHE Dhcp4;
|
---|
89 | PXEBC_DHCP6_PACKET_CACHE Dhcp6;
|
---|
90 | } PXEBC_DHCP_PACKET_CACHE;
|
---|
91 |
|
---|
92 | struct _PXEBC_PRIVATE_PROTOCOL {
|
---|
93 | UINT64 Reserved;
|
---|
94 | };
|
---|
95 |
|
---|
96 | struct _PXEBC_VIRTUAL_NIC {
|
---|
97 | UINT32 Signature;
|
---|
98 | EFI_HANDLE Controller;
|
---|
99 | EFI_LOAD_FILE_PROTOCOL LoadFile;
|
---|
100 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
---|
101 | PXEBC_PRIVATE_DATA *Private;
|
---|
102 | };
|
---|
103 |
|
---|
104 | struct _PXEBC_PRIVATE_DATA {
|
---|
105 | UINT32 Signature;
|
---|
106 | EFI_HANDLE Controller;
|
---|
107 | EFI_HANDLE Image;
|
---|
108 |
|
---|
109 | PXEBC_PRIVATE_PROTOCOL Id;
|
---|
110 | EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
|
---|
111 |
|
---|
112 | PXEBC_VIRTUAL_NIC *Ip4Nic;
|
---|
113 | PXEBC_VIRTUAL_NIC *Ip6Nic;
|
---|
114 |
|
---|
115 | EFI_HANDLE ArpChild;
|
---|
116 | EFI_HANDLE Ip4Child;
|
---|
117 | EFI_HANDLE Dhcp4Child;
|
---|
118 | EFI_HANDLE Mtftp4Child;
|
---|
119 | EFI_HANDLE Udp4ReadChild;
|
---|
120 | EFI_HANDLE Udp4WriteChild;
|
---|
121 |
|
---|
122 | EFI_ARP_PROTOCOL *Arp;
|
---|
123 | EFI_IP4_PROTOCOL *Ip4;
|
---|
124 | EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
|
---|
125 | EFI_DHCP4_PROTOCOL *Dhcp4;
|
---|
126 | EFI_MTFTP4_PROTOCOL *Mtftp4;
|
---|
127 | EFI_UDP4_PROTOCOL *Udp4Read;
|
---|
128 | EFI_UDP4_PROTOCOL *Udp4Write;
|
---|
129 |
|
---|
130 | EFI_HANDLE Ip6Child;
|
---|
131 | EFI_HANDLE Dhcp6Child;
|
---|
132 | EFI_HANDLE Mtftp6Child;
|
---|
133 | EFI_HANDLE Udp6ReadChild;
|
---|
134 | EFI_HANDLE Udp6WriteChild;
|
---|
135 |
|
---|
136 | EFI_IP6_PROTOCOL *Ip6;
|
---|
137 | EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg;
|
---|
138 | EFI_DHCP6_PROTOCOL *Dhcp6;
|
---|
139 | EFI_MTFTP6_PROTOCOL *Mtftp6;
|
---|
140 | EFI_UDP6_PROTOCOL *Udp6Read;
|
---|
141 | EFI_UDP6_PROTOCOL *Udp6Write;
|
---|
142 | EFI_DNS6_PROTOCOL *Dns6;
|
---|
143 |
|
---|
144 | EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii;
|
---|
145 | EFI_PXE_BASE_CODE_PROTOCOL PxeBc;
|
---|
146 | EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL LoadFileCallback;
|
---|
147 | EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *PxeBcCallback;
|
---|
148 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
---|
149 |
|
---|
150 | EFI_PXE_BASE_CODE_MODE Mode;
|
---|
151 | EFI_PXE_BASE_CODE_FUNCTION Function;
|
---|
152 | UINT32 Ip6Policy;
|
---|
153 | UINT32 SolicitTimes;
|
---|
154 | UINT64 ElapsedTime;
|
---|
155 |
|
---|
156 | EFI_UDP4_CONFIG_DATA Udp4CfgData;
|
---|
157 | EFI_UDP6_CONFIG_DATA Udp6CfgData;
|
---|
158 | EFI_IP4_CONFIG_DATA Ip4CfgData;
|
---|
159 | EFI_IP6_CONFIG_DATA Ip6CfgData;
|
---|
160 |
|
---|
161 | EFI_EVENT UdpTimeOutEvent;
|
---|
162 | EFI_EVENT ArpUpdateEvent;
|
---|
163 | EFI_IP4_COMPLETION_TOKEN IcmpToken;
|
---|
164 | EFI_IP6_COMPLETION_TOKEN Icmp6Token;
|
---|
165 |
|
---|
166 | BOOLEAN IsAddressOk;
|
---|
167 | BOOLEAN IsOfferSorted;
|
---|
168 | BOOLEAN IsProxyRecved;
|
---|
169 | BOOLEAN IsDoDiscover;
|
---|
170 |
|
---|
171 | EFI_IP_ADDRESS TmpStationIp;
|
---|
172 | EFI_IP_ADDRESS StationIp;
|
---|
173 | EFI_IP_ADDRESS SubnetMask;
|
---|
174 | EFI_IP_ADDRESS GatewayIp;
|
---|
175 | EFI_IP_ADDRESS ServerIp;
|
---|
176 | EFI_IPv6_ADDRESS *DnsServer;
|
---|
177 | UINT16 CurSrcPort;
|
---|
178 | UINT32 IaId;
|
---|
179 |
|
---|
180 | UINT32 Ip4MaxPacketSize;
|
---|
181 | UINT32 Ip6MaxPacketSize;
|
---|
182 | UINT8 *BootFileName;
|
---|
183 | UINTN BootFileSize;
|
---|
184 | UINTN BlockSize;
|
---|
185 |
|
---|
186 | PXEBC_DHCP_PACKET_CACHE ProxyOffer;
|
---|
187 | PXEBC_DHCP_PACKET_CACHE DhcpAck;
|
---|
188 | PXEBC_DHCP_PACKET_CACHE PxeReply;
|
---|
189 | EFI_DHCP6_PACKET *Dhcp6Request;
|
---|
190 | EFI_DHCP4_PACKET SeedPacket;
|
---|
191 |
|
---|
192 | //
|
---|
193 | // OfferIndex records the index of DhcpOffer[] buffer, and OfferCount records the num of each type of offer.
|
---|
194 | //
|
---|
195 | // It supposed that
|
---|
196 | //
|
---|
197 | // OfferNum: 8
|
---|
198 | // OfferBuffer: [ProxyBinl, ProxyBinl, DhcpOnly, ProxyPxe10, DhcpOnly, DhcpPxe10, DhcpBinl, ProxyBinl]
|
---|
199 | // (OfferBuffer is 0-based.)
|
---|
200 | //
|
---|
201 | // And assume that (DhcpPxe10 is the first priority actually.)
|
---|
202 | //
|
---|
203 | // SelectIndex: 2
|
---|
204 | // SelectProxyType: PXEBC_OFFER_TYPE_PROXY_BINL
|
---|
205 | // (SelectIndex is 1-based, and 0 means no one is selected.)
|
---|
206 | //
|
---|
207 | // So it should be
|
---|
208 | //
|
---|
209 | // DhcpOnly DhcpPxe10 DhcpWfm11a DhcpBinl ProxyPxe10 ProxyWfm11a ProxyBinl Bootp
|
---|
210 | // OfferCount: [ 2(n), 1(n), 0(n), 1(n), 1(1), 0(1), 3(n), 1(1)]
|
---|
211 | //
|
---|
212 | // OfferIndex: {[ 2, 5, 0, 6, 3, 0, *0, 0]
|
---|
213 | // [ 4, 0, 0, 0, 0, 0, 1, 0]
|
---|
214 | // [ 0, 0, 0, 0, 0, 0, 7, 0]
|
---|
215 | // ... ]}
|
---|
216 | // (OfferIndex is 0-based.)
|
---|
217 | //
|
---|
218 | //
|
---|
219 | UINT32 SelectIndex;
|
---|
220 | UINT32 SelectProxyType;
|
---|
221 | PXEBC_DHCP_PACKET_CACHE OfferBuffer[PXEBC_OFFER_MAX_NUM];
|
---|
222 | UINT32 OfferNum;
|
---|
223 | UINT32 OfferCount[PxeOfferTypeMax];
|
---|
224 | UINT32 OfferIndex[PxeOfferTypeMax][PXEBC_OFFER_MAX_NUM];
|
---|
225 | };
|
---|
226 |
|
---|
227 | extern EFI_PXE_BASE_CODE_PROTOCOL gPxeBcProtocolTemplate;
|
---|
228 | extern EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL gPxeBcCallBackTemplate;
|
---|
229 | extern EFI_LOAD_FILE_PROTOCOL gLoadFileProtocolTemplate;
|
---|
230 |
|
---|
231 | #endif
|
---|