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