3 Copyright (c) 2007 - 2008, Intel Corporation.<BR>
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
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.
14 #ifndef __EFI_PXEBC_IMPL_H__
15 #define __EFI_PXEBC_IMPL_H__
18 typedef struct _PXEBC_PRIVATE_DATA PXEBC_PRIVATE_DATA
;
22 #include <Guid/SmBios.h>
23 #include <IndustryStandard/SmBios.h>
24 #include <Protocol/Dhcp4.h>
25 #include <Protocol/PxeBaseCode.h>
26 #include <Protocol/Mtftp4.h>
27 #include <Protocol/Udp4.h>
28 #include <Protocol/LoadFile.h>
29 #include <Protocol/NetworkInterfaceIdentifier.h>
30 #include <Protocol/PxeBaseCodeCallBack.h>
31 #include <Protocol/Arp.h>
32 #include <Protocol/Ip4.h>
34 #include <Library/DebugLib.h>
35 #include <Library/BaseMemoryLib.h>
36 #include <Library/MemoryAllocationLib.h>
37 #include <Library/UefiDriverEntryPoint.h>
38 #include <Library/UefiBootServicesTableLib.h>
39 #include <Library/UefiLib.h>
40 #include <Library/BaseLib.h>
41 #include <Library/NetLib.h>
43 #include "PxeBcDriver.h"
45 #include "PxeBcDhcp.h"
46 #include "PxeBcMtftp.h"
47 #include "PxeBcSupport.h"
49 #define PXEBC_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('P', 'X', 'E', 'P')
50 #define PXEBC_MTFTP_TIMEOUT 4
51 #define PXEBC_MTFTP_RETRIES 6
53 struct _PXEBC_PRIVATE_DATA
{
55 EFI_HANDLE Controller
;
58 EFI_HANDLE Dhcp4Child
;
60 EFI_HANDLE Mtftp4Child
;
61 EFI_HANDLE Udp4ReadChild
;
62 EFI_HANDLE Udp4WriteChild
;
64 EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL
*Nii
;
66 EFI_PXE_BASE_CODE_PROTOCOL PxeBc
;
67 EFI_LOAD_FILE_PROTOCOL LoadFile
;
68 EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL LoadFileCallback
;
69 EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL
*PxeBcCallback
;
70 EFI_ARP_PROTOCOL
*Arp
;
71 EFI_DHCP4_PROTOCOL
*Dhcp4
;
72 EFI_IP4_PROTOCOL
*Ip4
;
73 EFI_IP4_CONFIG_DATA Ip4ConfigData
;
74 EFI_MTFTP4_PROTOCOL
*Mtftp4
;
75 EFI_UDP4_PROTOCOL
*Udp4Read
;
76 EFI_UDP4_PROTOCOL
*Udp4Write
;
77 UINT16 CurrentUdpSrcPort
;
78 EFI_UDP4_CONFIG_DATA Udp4CfgData
;
81 EFI_PXE_BASE_CODE_MODE Mode
;
82 EFI_PXE_BASE_CODE_FUNCTION Function
;
86 EFI_IP_ADDRESS StationIp
;
87 EFI_IP_ADDRESS SubnetMask
;
88 EFI_IP_ADDRESS GatewayIp
;
89 EFI_IP_ADDRESS ServerIp
;
94 UINT8 OptionBuffer
[PXEBC_DHCP4_MAX_OPTION_SIZE
];
95 EFI_DHCP4_PACKET SeedPacket
;
100 BOOLEAN GotProxyOffer
;
102 UINT32 SelectedOffer
;
103 UINT32 ProxyOfferType
;
106 // Cached packets as complements of pxe mode data
108 PXEBC_CACHED_DHCP4_PACKET ProxyOffer
;
109 PXEBC_CACHED_DHCP4_PACKET Dhcp4Ack
;
110 PXEBC_CACHED_DHCP4_PACKET PxeReply
;
111 PXEBC_CACHED_DHCP4_PACKET Dhcp4Offers
[PXEBC_MAX_OFFER_NUM
];
114 // Arrays for different types of offers:
115 // ServerCount records the count of the servers we got the offers,
116 // OfferIndex records the index of the offer sent by the server indexed by ServerCount.
118 UINT32 ServerCount
[DHCP4_PACKET_TYPE_MAX
];
119 UINT32 OfferIndex
[DHCP4_PACKET_TYPE_MAX
][PXEBC_MAX_OFFER_NUM
];
121 UINT32 ProxyIndex
[DHCP4_PACKET_TYPE_MAX
];
122 UINT32 BinlIndex
[PXEBC_MAX_OFFER_NUM
];
124 EFI_EVENT GetArpCacheEvent
;
126 // token and event used to get ICMP error data from IP
128 EFI_IP4_COMPLETION_TOKEN IcmpErrorRcvToken
;
131 #define PXEBC_PRIVATE_DATA_FROM_PXEBC(a) CR (a, PXEBC_PRIVATE_DATA, PxeBc, PXEBC_PRIVATE_DATA_SIGNATURE)
133 #define PXEBC_PRIVATE_DATA_FROM_LOADFILE(a) CR (a, PXEBC_PRIVATE_DATA, LoadFile, PXEBC_PRIVATE_DATA_SIGNATURE)
135 #define PXEBC_PRIVATE_DATA_FROM_PXEBCCALLBACK(a) CR (a, PXEBC_PRIVATE_DATA, PxeBcCallback, PXEBC_PRIVATE_DATA_SIGNATURE)
137 extern EFI_PXE_BASE_CODE_PROTOCOL mPxeBcProtocolTemplate
;
138 extern EFI_LOAD_FILE_PROTOCOL mLoadFileProtocolTemplate
;
141 Causes the driver to load a specified file.
143 @param This Protocol instance pointer.
144 @param FilePath The device specific path of the file to load.
145 @param BootPolicy If TRUE, indicates that the request originates from the
146 boot manager is attempting to load FilePath as a boot
147 selection. If FALSE, then FilePath must match as exact file
149 @param BufferSize On input the size of Buffer in bytes. On output with a return
150 code of EFI_SUCCESS, the amount of data transferred to
151 Buffer. On output with a return code of EFI_BUFFER_TOO_SMALL,
152 the size of Buffer required to retrieve the requested file.
153 @param Buffer The memory buffer to transfer the file to. IF Buffer is NULL,
154 then no the size of the requested file is returned in
157 @retval EFI_SUCCESS The file was loaded.
158 @retval EFI_UNSUPPORTED The device does not support the provided BootPolicy
159 @retval EFI_INVALID_PARAMETER FilePath is not a valid device path, or
161 @retval EFI_NO_MEDIA No medium was present to load the file.
162 @retval EFI_DEVICE_ERROR The file was not loaded due to a device error.
163 @retval EFI_NO_RESPONSE The remote system did not respond.
164 @retval EFI_NOT_FOUND The file was not found.
165 @retval EFI_ABORTED The file load process was manually cancelled.
171 IN EFI_LOAD_FILE_PROTOCOL
* This
,
172 IN EFI_DEVICE_PATH_PROTOCOL
* FilePath
,
173 IN BOOLEAN BootPolicy
,
174 IN OUT UINTN
*BufferSize
,
175 IN VOID
*Buffer OPTIONAL