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