]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.h
NetworkPkg: Remove some clarification from IScsiDxe.inf
[mirror_edk2.git] / MdeModulePkg / Universal / Network / UefiPxeBcDxe / PxeBcImpl.h
1 /** @file
2
3 Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
4 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 **/
13
14 #ifndef __EFI_PXEBC_IMPL_H__
15 #define __EFI_PXEBC_IMPL_H__
16
17
18 typedef struct _PXEBC_PRIVATE_DATA PXEBC_PRIVATE_DATA;
19
20 #include <Uefi.h>
21
22 #include <Guid/SmBios.h>
23 #include <IndustryStandard/SmBios.h>
24 #include <IndustryStandard/Dhcp.h>
25 #include <Protocol/Dhcp4.h>
26 #include <Protocol/PxeBaseCode.h>
27 #include <Protocol/Mtftp4.h>
28 #include <Protocol/Udp4.h>
29 #include <Protocol/LoadFile.h>
30 #include <Protocol/NetworkInterfaceIdentifier.h>
31 #include <Protocol/PxeBaseCodeCallBack.h>
32 #include <Protocol/Arp.h>
33 #include <Protocol/Ip4.h>
34 #include <Protocol/Ip4Config2.h>
35
36 #include <Library/DebugLib.h>
37 #include <Library/DevicePathLib.h>
38 #include <Library/BaseMemoryLib.h>
39 #include <Library/MemoryAllocationLib.h>
40 #include <Library/UefiDriverEntryPoint.h>
41 #include <Library/UefiBootServicesTableLib.h>
42 #include <Library/UefiLib.h>
43 #include <Library/BaseLib.h>
44 #include <Library/NetLib.h>
45 #include <Library/DpcLib.h>
46 #include <Library/PcdLib.h>
47
48 #include "PxeBcDriver.h"
49 #include "PxeBcDhcp.h"
50 #include "PxeBcMtftp.h"
51 #include "PxeBcSupport.h"
52
53 #define PXEBC_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('P', 'X', 'E', 'P')
54 #define PXEBC_MTFTP_TIMEOUT 4
55 #define PXEBC_MTFTP_RETRIES 6
56 #define PXEBC_DEFAULT_UDP_OVERHEAD_SIZE 8
57 #define PXEBC_DEFAULT_TFTP_OVERHEAD_SIZE 4
58 #define PXEBC_DEFAULT_PACKET_SIZE 1480
59 #define PXEBC_DEFAULT_LIFETIME 50000 // 50ms, unit is microsecond
60 #define PXEBC_CHECK_MEDIA_WAITING_TIME EFI_TIMER_PERIOD_SECONDS(20)
61
62 struct _PXEBC_PRIVATE_DATA {
63 UINT32 Signature;
64 EFI_HANDLE Controller;
65 EFI_HANDLE Image;
66 EFI_HANDLE ArpChild;
67 EFI_HANDLE Dhcp4Child;
68 EFI_HANDLE Ip4Child;
69 EFI_HANDLE Mtftp4Child;
70 EFI_HANDLE Udp4ReadChild;
71 EFI_HANDLE Udp4WriteChild;
72
73 EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii;
74
75 EFI_PXE_BASE_CODE_PROTOCOL PxeBc;
76 EFI_LOAD_FILE_PROTOCOL LoadFile;
77 EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL LoadFileCallback;
78 EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *PxeBcCallback;
79 EFI_ARP_PROTOCOL *Arp;
80 EFI_DHCP4_PROTOCOL *Dhcp4;
81 EFI_IP4_PROTOCOL *Ip4;
82 EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
83 EFI_IP4_CONFIG_DATA Ip4ConfigData;
84 EFI_MTFTP4_PROTOCOL *Mtftp4;
85 EFI_UDP4_PROTOCOL *Udp4Read;
86 EFI_UDP4_PROTOCOL *Udp4Write;
87 UINT16 CurrentUdpSrcPort;
88 EFI_UDP4_CONFIG_DATA Udp4CfgData;
89
90
91 EFI_PXE_BASE_CODE_MODE Mode;
92 EFI_PXE_BASE_CODE_FUNCTION Function;
93
94 CHAR8 *BootFileName;
95
96 EFI_IP_ADDRESS StationIp;
97 EFI_IP_ADDRESS SubnetMask;
98 EFI_IP_ADDRESS GatewayIp;
99 EFI_IP_ADDRESS ServerIp;
100 BOOLEAN AddressIsOk;
101 UINT32 Ip4MaxPacketSize;
102 UINTN BlockSize;
103 UINTN FileSize;
104
105 UINT8 OptionBuffer[PXEBC_DHCP4_MAX_OPTION_SIZE];
106 EFI_DHCP4_PACKET SeedPacket;
107 EFI_MAC_ADDRESS Mac;
108 UINT8 MacLen;
109
110 BOOLEAN SortOffers;
111 BOOLEAN GotProxyOffer;
112 UINT32 NumOffers;
113 UINT32 SelectedOffer;
114 UINT32 ProxyOfferType;
115
116 //
117 // Cached packets as complements of pxe mode data
118 //
119 PXEBC_CACHED_DHCP4_PACKET ProxyOffer;
120 PXEBC_CACHED_DHCP4_PACKET Dhcp4Ack;
121 PXEBC_CACHED_DHCP4_PACKET PxeReply;
122 PXEBC_CACHED_DHCP4_PACKET Dhcp4Offers[PXEBC_MAX_OFFER_NUM];
123
124 //
125 // Arrays for different types of offers:
126 // ServerCount records the count of the servers we got the offers,
127 // OfferIndex records the index of the offer sent by the server indexed by ServerCount.
128 //
129 UINT32 ServerCount[DHCP4_PACKET_TYPE_MAX];
130 UINT32 OfferIndex[DHCP4_PACKET_TYPE_MAX][PXEBC_MAX_OFFER_NUM];
131 UINT32 BootpIndex;
132 UINT32 ProxyIndex[DHCP4_PACKET_TYPE_MAX];
133 UINT32 BinlIndex[PXEBC_MAX_OFFER_NUM];
134
135 EFI_EVENT GetArpCacheEvent;
136 //
137 // token and event used to get ICMP error data from IP
138 //
139 EFI_IP4_COMPLETION_TOKEN IcmpErrorRcvToken;
140 };
141
142 #define PXEBC_PRIVATE_DATA_FROM_PXEBC(a) CR (a, PXEBC_PRIVATE_DATA, PxeBc, PXEBC_PRIVATE_DATA_SIGNATURE)
143
144 #define PXEBC_PRIVATE_DATA_FROM_LOADFILE(a) CR (a, PXEBC_PRIVATE_DATA, LoadFile, PXEBC_PRIVATE_DATA_SIGNATURE)
145
146 #define PXEBC_PRIVATE_DATA_FROM_PXEBCCALLBACK(a) CR (a, PXEBC_PRIVATE_DATA, PxeBcCallback, PXEBC_PRIVATE_DATA_SIGNATURE)
147
148 extern EFI_PXE_BASE_CODE_PROTOCOL mPxeBcProtocolTemplate;
149 extern EFI_LOAD_FILE_PROTOCOL mLoadFileProtocolTemplate;
150
151 /**
152 Causes the driver to load a specified file.
153
154 @param This Protocol instance pointer.
155 @param FilePath The device specific path of the file to load.
156 @param BootPolicy If TRUE, indicates that the request originates from the
157 boot manager is attempting to load FilePath as a boot
158 selection. If FALSE, then FilePath must match as exact file
159 to be loaded.
160 @param BufferSize On input the size of Buffer in bytes. On output with a return
161 code of EFI_SUCCESS, the amount of data transferred to
162 Buffer. On output with a return code of EFI_BUFFER_TOO_SMALL,
163 the size of Buffer required to retrieve the requested file.
164 @param Buffer The memory buffer to transfer the file to. IF Buffer is NULL,
165 then no the size of the requested file is returned in
166 BufferSize.
167
168 @retval EFI_SUCCESS The file was loaded.
169 @retval EFI_UNSUPPORTED The device does not support the provided BootPolicy
170 @retval EFI_INVALID_PARAMETER FilePath is not a valid device path, or
171 BufferSize is NULL.
172 @retval EFI_NO_MEDIA No medium was present to load the file.
173 @retval EFI_DEVICE_ERROR The file was not loaded due to a device error.
174 @retval EFI_NO_RESPONSE The remote system did not respond.
175 @retval EFI_NOT_FOUND The file was not found.
176 @retval EFI_ABORTED The file load process was manually cancelled.
177
178 **/
179 EFI_STATUS
180 EFIAPI
181 EfiPxeLoadFile (
182 IN EFI_LOAD_FILE_PROTOCOL * This,
183 IN EFI_DEVICE_PATH_PROTOCOL * FilePath,
184 IN BOOLEAN BootPolicy,
185 IN OUT UINTN *BufferSize,
186 IN VOID *Buffer OPTIONAL
187 );
188
189 #endif