]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/PxeBcDxe/Bc.h
1. Add EFI LOADED IMAGE DEVICE PATH Protocol in LoadImage() service, per UEFI 2.1b.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / PxeBcDxe / Bc.h
1 /** @file
2
3 Copyright (c) 2004 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13 bc.h
14
15 Abstract:
16
17
18 **/
19
20 #ifndef _BC_H
21 #define _BC_H
22
23 #include <PiDxe.h>
24
25 #include <Guid/SmBios.h>
26 #include <IndustryStandard/Smbios.h>
27 #include <Protocol/Bis.h>
28 #include <Protocol/PxeBaseCode.h>
29 #include <Protocol/PxeBaseCodeCallBack.h>
30 #include <Protocol/NetworkInterfaceIdentifier.h>
31 #include <Protocol/SimpleNetwork.h>
32 #include <Protocol/LoadFile.h>
33 #include <Protocol/DevicePath.h>
34 #include <Protocol/Tcp.h>
35
36 #include <Library/DebugLib.h>
37 #include <Library/BaseMemoryLib.h>
38 #include <Library/MemoryAllocationLib.h>
39 #include <Library/UefiDriverEntryPoint.h>
40 #include <Library/UefiBootServicesTableLib.h>
41 #include <Library/BaseLib.h>
42 #include <Library/UefiLib.h>
43
44 #define CALLBACK_INTERVAL 100 // ten times a second
45 #define FILTER_BITS (EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP | \
46 EFI_PXE_BASE_CODE_IP_FILTER_BROADCAST | \
47 EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS | \
48 EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS_MULTICAST \
49 )
50
51 #define WAIT_TX_TIMEOUT 1000
52
53 #define SUPPORT_IPV6 0
54
55 #define PXE_BASECODE_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('p', 'x', 'e', 'd')
56
57 //
58 // Determine the classes of IPv4 address
59 //
60 #define IS_CLASSA_IPADDR(x) ((((EFI_IP_ADDRESS*)x)->v4.Addr[0] & 0x80) == 0x00)
61 #define IS_CLASSB_IPADDR(x) ((((EFI_IP_ADDRESS*)x)->v4.Addr[0] & 0xc0) == 0x80)
62 #define IS_CLASSC_IPADDR(x) ((((EFI_IP_ADDRESS*)x)->v4.Addr[0] & 0xe0) == 0xc0)
63 #define IS_INADDR_UNICAST(x) ((IS_CLASSA_IPADDR(x) || IS_CLASSB_IPADDR(x) || IS_CLASSC_IPADDR(x)) && (((EFI_IP_ADDRESS*)x)->Addr[0] != 0) )
64
65 //
66 // Definitions for internet group management protocol version 2 message
67 // structure
68 // Per RFC 2236, November 1997
69 //
70 #pragma pack(1)
71
72 typedef struct {
73 UINT8 Type;
74 UINT8 MaxRespTime; // in tenths of a second
75 UINT16 Checksum; // ones complement of ones complement sum of
76 // 16 bit words of message
77 UINT32 GroupAddress; // for general query, all systems group,
78 // for group specific, the group
79 } IGMPV2_MESSAGE;
80
81 #define IGMP_TYPE_QUERY 0x11
82 #define IGMP_TYPE_REPORT 0x16
83 #define IGMP_TYPE_V1REPORT 0x12
84 #define IGMP_TYPE_LEAVE_GROUP 0x17
85
86 #define IGMP_DEFAULT_MAX_RESPONSE_TIME 10 // 10 second default
87 #pragma pack()
88
89 #define MAX_MCAST_GROUPS 8 // most we allow ourselves to join at once
90 #define MAX_OFFERS 16
91
92 typedef struct {
93 UINTN Signature;
94 EFI_LOCK Lock;
95 BOOLEAN ShowErrorMessages;
96 EFI_TCP_PROTOCOL Tcp;
97 EFI_PXE_BASE_CODE_PROTOCOL EfiBc;
98 EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *CallbackProtocolPtr;
99 EFI_HANDLE Handle;
100
101 EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *NiiPtr;
102 EFI_SIMPLE_NETWORK_PROTOCOL *SimpleNetwork;
103 UINT8 *TransmitBufferPtr;
104 UINT8 *ReceiveBufferPtr;
105 EFI_PXE_BASE_CODE_FUNCTION Function;
106
107 UINTN OldestArpEntry;
108 UINTN MCastGroupCount;
109 EFI_EVENT Igmpv1TimeoutEvent;
110 BOOLEAN UseIgmpv1Reporting;
111 EFI_EVENT IgmpGroupEvent[MAX_MCAST_GROUPS];
112 UINT16 RandomPort;
113
114 #if SUPPORT_IPV6
115 //
116 // TBD
117 //
118 #else
119 UINT32 MCastGroup[MAX_MCAST_GROUPS];
120 #endif
121
122 BOOLEAN GoodStationIp;
123 BOOLEAN DidTransmit;
124 UINTN IpLength;
125 VOID *DhcpPacketBuffer;
126 UINTN FileSize;
127 VOID *BootServerReceiveBuffer;
128 EFI_IP_ADDRESS ServerIp;
129
130 //
131 // work area
132 // for dhcp
133 //
134 VOID *ReceiveBuffers;
135 VOID *TransmitBuffer;
136 UINTN NumOffersReceived;
137 UINT16 TotalSeconds;
138
139 //
140 // arrays for different types of offers
141 //
142 UINT8 ServerCount[4];
143 UINT8 OfferCount[4][MAX_OFFERS];
144 UINT8 GotBootp;
145 UINT8 GotProxy[4];
146 UINT8 BinlProxies[MAX_OFFERS];
147
148 UINT8 *ArpBuffer;
149 UINT8 *TftpAckBuffer;
150 UINT8 *TftpErrorBuffer;
151 IGMPV2_MESSAGE IgmpMessage;
152 BOOLEAN BigBlkNumFlag;
153 UINT8 Timeout;
154 UINT16 RandomSeed;
155 } PXE_BASECODE_DEVICE;
156
157 //
158 // type index
159 //
160 #define DHCP_ONLY_IX 0
161 #define PXE10_IX 1
162 #define WfM11a_IX 2
163 #define BINL_IX 3
164
165 #define PXE_RND_PORT_LOW 2070
166
167 //
168 //
169 //
170 #define LOADFILE_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('p', 'x', 'e', 'l')
171
172 typedef struct {
173 UINTN Signature;
174 EFI_LOCK Lock;
175 EFI_LOAD_FILE_PROTOCOL LoadFile;
176 PXE_BASECODE_DEVICE *Private;
177 } LOADFILE_DEVICE;
178
179 #define EFI_BASE_CODE_DEV_FROM_THIS(a) CR (a, PXE_BASECODE_DEVICE, efi_bc, PXE_BASECODE_DEVICE_SIGNATURE);
180
181 #define EFI_BASE_CODE_DEV_FROM_TCP(a) CR (a, PXE_BASECODE_DEVICE, Tcp, PXE_BASECODE_DEVICE_SIGNATURE);
182
183 #define EFI_LOAD_FILE_DEV_FROM_THIS(a) CR (a, LOADFILE_DEVICE, LoadFile, LOADFILE_DEVICE_SIGNATURE)
184
185 EFI_BIS_PROTOCOL *
186 PxebcBisStart (
187 PXE_BASECODE_DEVICE *Private,
188 BIS_APPLICATION_HANDLE *BisAppHandle,
189 EFI_BIS_DATA **BisDataSigInfo
190 )
191 ;
192
193 VOID
194 PxebcBisStop (
195 EFI_BIS_PROTOCOL *Bis,
196 BIS_APPLICATION_HANDLE BisAppHandle,
197 EFI_BIS_DATA *BisDataSigInfo
198 )
199 ;
200
201 BOOLEAN
202 PxebcBisVerify (
203 PXE_BASECODE_DEVICE *Private,
204 VOID *FileBuffer,
205 UINTN FileBufferLength,
206 VOID *CredentialBuffer,
207 UINTN CredentialBufferLength
208 )
209 ;
210
211 BOOLEAN
212 PxebcBisDetect (
213 PXE_BASECODE_DEVICE *Private
214 )
215 ;
216
217 //
218 // Global Variables
219 //
220 extern EFI_COMPONENT_NAME_PROTOCOL gPxeBcComponentName;
221 extern EFI_COMPONENT_NAME2_PROTOCOL gPxeBcComponentName2;
222
223 //
224 // //////////////////////////////////////////////////////////
225 //
226 // prototypes
227 //
228
229 /**
230 Initialize the base code drivers and install the driver binding
231
232 Standard EFI Image Entry
233
234 @retval EFI_SUCCESS This driver was successfully bound
235
236 **/
237 EFI_STATUS
238 EFIAPI
239 InitializeBCDriver (
240 IN EFI_HANDLE ImageHandle,
241 IN EFI_SYSTEM_TABLE *SystemTable
242 )
243 ;
244
245 EFI_STATUS
246 EFIAPI
247 BcStart (
248 IN EFI_PXE_BASE_CODE_PROTOCOL *This,
249 IN BOOLEAN UseIpv6
250 )
251 ;
252
253 EFI_STATUS
254 EFIAPI
255 BcStop (
256 IN EFI_PXE_BASE_CODE_PROTOCOL *This
257 )
258 ;
259
260 EFI_STATUS
261 EFIAPI
262 BcDhcp (
263 IN EFI_PXE_BASE_CODE_PROTOCOL *This,
264 IN BOOLEAN SortOffers
265 )
266 ;
267
268 EFI_STATUS
269 EFIAPI
270 BcDiscover (
271 IN EFI_PXE_BASE_CODE_PROTOCOL * This,
272 IN UINT16 Type,
273 IN UINT16 *Layer,
274 IN BOOLEAN UseBis,
275 IN EFI_PXE_BASE_CODE_DISCOVER_INFO * Info OPTIONAL
276 )
277 ;
278
279 EFI_STATUS
280 EFIAPI
281 BcMtftp (
282 IN EFI_PXE_BASE_CODE_PROTOCOL * This,
283 IN EFI_PXE_BASE_CODE_TFTP_OPCODE Operation,
284 IN OUT VOID *BufferPtr,
285 IN BOOLEAN Overwrite,
286 IN OUT UINT64 *BufferSize,
287 IN UINTN *BlockSize OPTIONAL,
288 IN EFI_IP_ADDRESS * ServerIp,
289 IN UINT8 *Filename,
290 IN EFI_PXE_BASE_CODE_MTFTP_INFO * Info OPTIONAL,
291 IN BOOLEAN DontUseBuffer
292 )
293 ;
294
295 EFI_STATUS
296 EFIAPI
297 BcUdpWrite (
298 IN EFI_PXE_BASE_CODE_PROTOCOL *This,
299 IN UINT16 OpFlags,
300 IN EFI_IP_ADDRESS *DestIp,
301 IN EFI_PXE_BASE_CODE_UDP_PORT *DestPort,
302 IN EFI_IP_ADDRESS *GatewayIp, OPTIONAL
303 IN EFI_IP_ADDRESS *SrcIp, OPTIONAL
304 IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort, OPTIONAL
305 IN UINTN *HeaderSize, OPTIONAL
306 IN VOID *HeaderPtr, OPTIONAL
307 IN UINTN *BufferSize,
308 IN VOID *BufferPtr
309 )
310 ;
311
312 EFI_STATUS
313 EFIAPI
314 BcUdpRead (
315 IN EFI_PXE_BASE_CODE_PROTOCOL *This,
316 IN UINT16 OpFlags,
317 IN OUT EFI_IP_ADDRESS *DestIp, OPTIONAL
318 IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort, OPTIONAL
319 IN OUT EFI_IP_ADDRESS *SrcIp, OPTIONAL
320 IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort, OPTIONAL
321 IN UINTN *HeaderSize, OPTIONAL
322 IN VOID *HeaderPtr, OPTIONAL
323 IN OUT UINTN *BufferSize,
324 IN VOID *BufferPtr
325 )
326 ;
327
328 EFI_STATUS
329 EFIAPI
330 BcTcpWrite (
331 IN EFI_PXE_BASE_CODE_PROTOCOL *This,
332 IN UINT16 OpFlags,
333 IN UINT16 *UrgentPointer,
334 IN UINT32 *SequenceNumber,
335 IN UINT32 *AckNumber,
336 IN UINT16 *HlenResCode,
337 IN UINT16 *Window,
338 IN EFI_IP_ADDRESS *DestIp,
339 IN EFI_PXE_BASE_CODE_TCP_PORT *DestPort,
340 IN EFI_IP_ADDRESS *GatewayIp, OPTIONAL
341 IN EFI_IP_ADDRESS *SrcIp, OPTIONAL
342 IN OUT EFI_PXE_BASE_CODE_TCP_PORT *SrcPort, OPTIONAL
343 IN UINTN *HeaderSize, OPTIONAL
344 IN VOID *HeaderPtr, OPTIONAL
345 IN UINTN *BufferSize,
346 IN VOID *BufferPtr
347 )
348 ;
349
350 EFI_STATUS
351 EFIAPI
352 BcTcpRead (
353 IN EFI_PXE_BASE_CODE_PROTOCOL *This,
354 IN UINT16 OpFlags,
355 IN OUT EFI_IP_ADDRESS *DestIp, OPTIONAL
356 IN OUT EFI_PXE_BASE_CODE_TCP_PORT *DestPort, OPTIONAL
357 IN OUT EFI_IP_ADDRESS *SrcIp, OPTIONAL
358 IN OUT EFI_PXE_BASE_CODE_TCP_PORT *SrcPort, OPTIONAL
359 IN UINTN *HeaderSize, OPTIONAL
360 IN VOID *HeaderPtr, OPTIONAL
361 IN OUT UINTN *BufferSize,
362 IN VOID *BufferPtr
363 )
364 ;
365
366 EFI_STATUS
367 EFIAPI
368 BcArp (
369 IN EFI_PXE_BASE_CODE_PROTOCOL * This,
370 IN EFI_IP_ADDRESS * IpAddr,
371 IN EFI_MAC_ADDRESS * MacAddr OPTIONAL
372 )
373 ;
374
375 EFI_STATUS
376 EFIAPI
377 BcIpFilter (
378 IN EFI_PXE_BASE_CODE_PROTOCOL *This,
379 IN EFI_PXE_BASE_CODE_IP_FILTER *NewFilter
380 )
381 ;
382
383 EFI_STATUS
384 EFIAPI
385 BcSetParameters (
386 IN EFI_PXE_BASE_CODE_PROTOCOL * This,
387 IN BOOLEAN *NewAutoArp, OPTIONAL
388 IN BOOLEAN *NewSendGUID, OPTIONAL
389 IN UINT8 *NewTTL, OPTIONAL
390 IN UINT8 *NewToS, OPTIONAL
391 IN BOOLEAN *NewMakeCallback OPTIONAL
392 )
393 ;
394
395 EFI_STATUS
396 EFIAPI
397 BcSetStationIP (
398 IN EFI_PXE_BASE_CODE_PROTOCOL * This,
399 IN EFI_IP_ADDRESS * NewStationIp, OPTIONAL
400 IN EFI_IP_ADDRESS * NewSubnetMask OPTIONAL
401 )
402 ;
403
404 EFI_STATUS
405 EFIAPI
406 BcSetPackets (
407 IN EFI_PXE_BASE_CODE_PROTOCOL * This,
408 BOOLEAN *NewDhcpDiscoverValid, OPTIONAL
409 BOOLEAN *NewDhcpAckReceived, OPTIONAL
410 BOOLEAN *NewProxyOfferReceived, OPTIONAL
411 BOOLEAN *NewPxeDiscoverValid, OPTIONAL
412 BOOLEAN *NewPxeReplyReceived, OPTIONAL
413 BOOLEAN *NewPxeBisReplyReceived, OPTIONAL
414 IN EFI_PXE_BASE_CODE_PACKET * NewDhcpDiscover, OPTIONAL
415 IN EFI_PXE_BASE_CODE_PACKET * NewDhcpAck, OPTIONAL
416 IN EFI_PXE_BASE_CODE_PACKET * NewProxyOffer, OPTIONAL
417 IN EFI_PXE_BASE_CODE_PACKET * NewPxeDiscover, OPTIONAL
418 IN EFI_PXE_BASE_CODE_PACKET * NewPxeReply, OPTIONAL
419 IN EFI_PXE_BASE_CODE_PACKET * NewPxeBisReply OPTIONAL
420 )
421 ;
422
423 EFI_STATUS
424 EFIAPI
425 LoadFile (
426 IN EFI_LOAD_FILE_PROTOCOL *This,
427 IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
428 IN BOOLEAN BootPolicy,
429 IN OUT UINTN *BufferSize,
430 IN VOID *Buffer
431 )
432 ;
433
434 EFI_STATUS
435 PxeBcLibGetSmbiosSystemGuidAndSerialNumber (
436 IN EFI_GUID *SystemGuid,
437 OUT CHAR8 **SystemSerialNumber
438 )
439 ;
440
441 #include "ip.h"
442 #include "dhcp.h"
443 #include "tftp.h"
444
445 #endif /* _BC_H */
446
447 /* EOF - bc.h */