2 This EFI_PXE_BASE_CODE_PROTOCOL and EFI_LOAD_FILE_PROTOCOL.
3 interfaces declaration.
5 Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
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.
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.
17 #ifndef __EFI_PXEBC_IMPL_H__
18 #define __EFI_PXEBC_IMPL_H__
22 #include <Guid/SmBios.h>
23 #include <IndustryStandard/SmBios.h>
24 #include <Protocol/NetworkInterfaceIdentifier.h>
25 #include <Protocol/Arp.h>
26 #include <Protocol/Ip4.h>
27 #include <Protocol/Ip4Config2.h>
28 #include <Protocol/Ip6.h>
29 #include <Protocol/Ip6Config.h>
30 #include <Protocol/Udp4.h>
31 #include <Protocol/Udp6.h>
32 #include <Protocol/Dhcp4.h>
33 #include <Protocol/Dhcp6.h>
34 #include <Protocol/Mtftp4.h>
35 #include <Protocol/Mtftp6.h>
36 #include <Protocol/PxeBaseCode.h>
37 #include <Protocol/LoadFile.h>
38 #include <Protocol/PxeBaseCodeCallBack.h>
39 #include <Protocol/ServiceBinding.h>
40 #include <Protocol/DriverBinding.h>
41 #include <Protocol/AdapterInformation.h>
43 #include <Library/DebugLib.h>
44 #include <Library/BaseMemoryLib.h>
45 #include <Library/MemoryAllocationLib.h>
46 #include <Library/UefiDriverEntryPoint.h>
47 #include <Library/UefiBootServicesTableLib.h>
48 #include <Library/UefiRuntimeServicesTableLib.h>
49 #include <Library/UefiLib.h>
50 #include <Library/BaseLib.h>
51 #include <Library/NetLib.h>
52 #include <Library/DpcLib.h>
53 #include <Library/DevicePathLib.h>
54 #include <Library/PcdLib.h>
56 typedef struct _PXEBC_PRIVATE_DATA PXEBC_PRIVATE_DATA
;
57 typedef struct _PXEBC_PRIVATE_PROTOCOL PXEBC_PRIVATE_PROTOCOL
;
58 typedef struct _PXEBC_VIRTUAL_NIC PXEBC_VIRTUAL_NIC
;
60 #include "PxeBcDriver.h"
61 #include "PxeBcDhcp4.h"
62 #include "PxeBcDhcp6.h"
63 #include "PxeBcMtftp.h"
64 #include "PxeBcBoot.h"
65 #include "PxeBcSupport.h"
67 #define PXEBC_DEFAULT_HOPLIMIT 64
68 #define PXEBC_DEFAULT_LIFETIME 50000 // 50 ms, unit is microsecond
69 #define PXEBC_UDP_TIMEOUT 30000000 // 3 seconds, unit is 100nanosecond
70 #define PXEBC_DAD_ADDITIONAL_DELAY 30000000 // 3 seconds
71 #define PXEBC_MTFTP_TIMEOUT 4
72 #define PXEBC_MTFTP_RETRIES 6
73 #define PXEBC_DHCP_RETRIES 4 // refers to mPxeDhcpTimeout, also by PXE2.1 spec.
74 #define PXEBC_MENU_MAX_NUM 24
75 #define PXEBC_OFFER_MAX_NUM 16
77 #define PXEBC_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('P', 'X', 'E', 'P')
78 #define PXEBC_VIRTUAL_NIC_SIGNATURE SIGNATURE_32 ('P', 'X', 'E', 'V')
79 #define PXEBC_PRIVATE_DATA_FROM_PXEBC(a) CR (a, PXEBC_PRIVATE_DATA, PxeBc, PXEBC_PRIVATE_DATA_SIGNATURE)
80 #define PXEBC_PRIVATE_DATA_FROM_ID(a) CR (a, PXEBC_PRIVATE_DATA, Id, PXEBC_PRIVATE_DATA_SIGNATURE)
81 #define PXEBC_VIRTUAL_NIC_FROM_LOADFILE(a) CR (a, PXEBC_VIRTUAL_NIC, LoadFile, PXEBC_VIRTUAL_NIC_SIGNATURE)
84 PXEBC_DHCP4_PACKET_CACHE Dhcp4
;
85 PXEBC_DHCP6_PACKET_CACHE Dhcp6
;
86 } PXEBC_DHCP_PACKET_CACHE
;
88 struct _PXEBC_PRIVATE_PROTOCOL
{
92 struct _PXEBC_VIRTUAL_NIC
{
94 EFI_HANDLE Controller
;
95 EFI_LOAD_FILE_PROTOCOL LoadFile
;
96 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
97 PXEBC_PRIVATE_DATA
*Private
;
100 struct _PXEBC_PRIVATE_DATA
{
102 EFI_HANDLE Controller
;
105 PXEBC_PRIVATE_PROTOCOL Id
;
106 EFI_SIMPLE_NETWORK_PROTOCOL
*Snp
;
108 PXEBC_VIRTUAL_NIC
*Ip4Nic
;
109 PXEBC_VIRTUAL_NIC
*Ip6Nic
;
113 EFI_HANDLE Dhcp4Child
;
114 EFI_HANDLE Mtftp4Child
;
115 EFI_HANDLE Udp4ReadChild
;
116 EFI_HANDLE Udp4WriteChild
;
118 EFI_ARP_PROTOCOL
*Arp
;
119 EFI_IP4_PROTOCOL
*Ip4
;
120 EFI_IP4_CONFIG2_PROTOCOL
*Ip4Config2
;
121 EFI_DHCP4_PROTOCOL
*Dhcp4
;
122 EFI_MTFTP4_PROTOCOL
*Mtftp4
;
123 EFI_UDP4_PROTOCOL
*Udp4Read
;
124 EFI_UDP4_PROTOCOL
*Udp4Write
;
127 EFI_HANDLE Dhcp6Child
;
128 EFI_HANDLE Mtftp6Child
;
129 EFI_HANDLE Udp6ReadChild
;
130 EFI_HANDLE Udp6WriteChild
;
132 EFI_IP6_PROTOCOL
*Ip6
;
133 EFI_IP6_CONFIG_PROTOCOL
*Ip6Cfg
;
134 EFI_DHCP6_PROTOCOL
*Dhcp6
;
135 EFI_MTFTP6_PROTOCOL
*Mtftp6
;
136 EFI_UDP6_PROTOCOL
*Udp6Read
;
137 EFI_UDP6_PROTOCOL
*Udp6Write
;
139 EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL
*Nii
;
140 EFI_PXE_BASE_CODE_PROTOCOL PxeBc
;
141 EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL LoadFileCallback
;
142 EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL
*PxeBcCallback
;
143 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
145 EFI_PXE_BASE_CODE_MODE Mode
;
146 EFI_PXE_BASE_CODE_FUNCTION Function
;
151 EFI_UDP4_CONFIG_DATA Udp4CfgData
;
152 EFI_UDP6_CONFIG_DATA Udp6CfgData
;
153 EFI_IP4_CONFIG_DATA Ip4CfgData
;
154 EFI_IP6_CONFIG_DATA Ip6CfgData
;
156 EFI_EVENT UdpTimeOutEvent
;
157 EFI_EVENT ArpUpdateEvent
;
158 EFI_IP4_COMPLETION_TOKEN IcmpToken
;
159 EFI_IP6_COMPLETION_TOKEN Icmp6Token
;
162 BOOLEAN IsOfferSorted
;
163 BOOLEAN IsProxyRecved
;
164 BOOLEAN IsDoDiscover
;
166 EFI_IP_ADDRESS TmpStationIp
;
167 EFI_IP_ADDRESS StationIp
;
168 EFI_IP_ADDRESS SubnetMask
;
169 EFI_IP_ADDRESS GatewayIp
;
170 EFI_IP_ADDRESS ServerIp
;
174 UINT32 Ip4MaxPacketSize
;
175 UINT32 Ip6MaxPacketSize
;
180 PXEBC_DHCP_PACKET_CACHE ProxyOffer
;
181 PXEBC_DHCP_PACKET_CACHE DhcpAck
;
182 PXEBC_DHCP_PACKET_CACHE PxeReply
;
183 EFI_DHCP6_PACKET
*Dhcp6Request
;
184 EFI_DHCP4_PACKET SeedPacket
;
187 // OfferIndex records the index of DhcpOffer[] buffer, and OfferCount records the num of each type of offer.
192 // OfferBuffer: [ProxyBinl, ProxyBinl, DhcpOnly, ProxyPxe10, DhcpOnly, DhcpPxe10, DhcpBinl, ProxyBinl]
193 // (OfferBuffer is 0-based.)
195 // And assume that (DhcpPxe10 is the first priority actually.)
198 // SelectProxyType: PXEBC_OFFER_TYPE_PROXY_BINL
199 // (SelectIndex is 1-based, and 0 means no one is selected.)
203 // DhcpOnly DhcpPxe10 DhcpWfm11a DhcpBinl ProxyPxe10 ProxyWfm11a ProxyBinl Bootp
204 // OfferCount: [ 2(n), 1(n), 0(n), 1(n), 1(1), 0(1), 3(n), 1(1)]
206 // OfferIndex: {[ 2, 5, 0, 6, 3, 0, *0, 0]
207 // [ 4, 0, 0, 0, 0, 0, 1, 0]
208 // [ 0, 0, 0, 0, 0, 0, 7, 0]
210 // (OfferIndex is 0-based.)
214 UINT32 SelectProxyType
;
215 PXEBC_DHCP_PACKET_CACHE OfferBuffer
[PXEBC_OFFER_MAX_NUM
];
217 UINT32 OfferCount
[PxeOfferTypeMax
];
218 UINT32 OfferIndex
[PxeOfferTypeMax
][PXEBC_OFFER_MAX_NUM
];
221 extern EFI_PXE_BASE_CODE_PROTOCOL gPxeBcProtocolTemplate
;
222 extern EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL gPxeBcCallBackTemplate
;
223 extern EFI_LOAD_FILE_PROTOCOL gLoadFileProtocolTemplate
;