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