]> git.proxmox.com Git - mirror_edk2.git/blob - Nt32Pkg/SnpNt32Dxe/SnpNt32.h
UefiCpuPkg: Remove double \r
[mirror_edk2.git] / Nt32Pkg / SnpNt32Dxe / SnpNt32.h
1 /** @file
2
3 Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
5
6 Module Name:
7
8 SnpNt32.h
9
10 Abstract:
11
12 -**/
13
14 #ifndef _SNP_NT32_H_
15 #define _SNP_NT32_H_
16
17 #include <Uefi.h>
18
19 #include <Protocol/SimpleNetwork.h>
20 #include <Protocol/DevicePath.h>
21 #include <Protocol/WinNtThunk.h>
22
23 #include <Library/BaseLib.h>
24 #include <Library/DebugLib.h>
25 #include <Library/BaseMemoryLib.h>
26 #include <Library/UefiBootServicesTableLib.h>
27 #include <Library/UefiLib.h>
28 #include <Library/DevicePathLib.h>
29 #include <Library/NetLib.h>
30 #include <Library/MemoryAllocationLib.h>
31
32 typedef struct _SNPNT32_GLOBAL_DATA SNPNT32_GLOBAL_DATA;
33 typedef struct _SNPNT32_INSTANCE_DATA SNPNT32_INSTANCE_DATA;
34
35 #define NETWORK_LIBRARY_NAME_U L"SnpNt32Io.dll"
36
37 #define NETWORK_LIBRARY_INITIALIZE "SnpInitialize"
38 #define NETWORK_LIBRARY_FINALIZE "SnpFinalize"
39 #define NETWORK_LIBRARY_SET_RCV_FILTER "SnpSetReceiveFilter"
40 #define NETWORK_LIBRARY_RECEIVE "SnpReceive"
41 #define NETWORK_LIBRARY_TRANSMIT "SnpTransmit"
42
43 #pragma pack(1)
44 typedef struct _NT_NET_INTERFACE_INFO {
45 UINT32 InterfaceIndex;
46 EFI_MAC_ADDRESS MacAddr;
47 } NT_NET_INTERFACE_INFO;
48 #pragma pack()
49
50 #define NET_ETHER_HEADER_SIZE 14
51
52 #define MAX_INTERFACE_INFO_NUMBER 16
53 #define MAX_FILE_NAME_LENGTH 280
54
55 #define SNP_MAX_TX_BUFFER_NUM 65536
56 #define SNP_TX_BUFFER_INCREASEMENT 32
57
58
59
60
61 //
62 // Functions in Net Library
63 //
64 typedef
65 INT32
66 (*NT_NET_INITIALIZE) (
67 IN OUT UINT32 *InterfaceCount,
68 IN OUT NT_NET_INTERFACE_INFO * InterfaceInfoBuffer
69 );
70
71 typedef
72 INT32
73 (*NT_NET_FINALIZE) (
74 VOID
75 );
76
77 typedef
78 INT32
79 (*NT_NET_SET_RECEIVE_FILTER) (
80 IN UINT32 Index,
81 IN UINT32 EnableFilter,
82 IN UINT32 MCastFilterCnt,
83 IN EFI_MAC_ADDRESS * MCastFilter
84 );
85
86 typedef
87 INT32
88 (*NT_NET_RECEIVE) (
89 IN UINT32 Index,
90 IN OUT UINT32 *BufferSize,
91 OUT VOID *Buffer
92 );
93
94 typedef
95 INT32
96 (*NT_NET_TRANSMIT) (
97 IN UINT32 Index,
98 IN UINT32 HeaderSize,
99 IN UINT32 BufferSize,
100 IN VOID *Buffer,
101 IN EFI_MAC_ADDRESS * SrcAddr,
102 IN EFI_MAC_ADDRESS * DestAddr,
103 IN UINT16 *Protocol
104 );
105
106 typedef struct _NT_NET_UTILITY_TABLE {
107 NT_NET_INITIALIZE Initialize;
108 NT_NET_FINALIZE Finalize;
109 NT_NET_SET_RECEIVE_FILTER SetReceiveFilter;
110 NT_NET_RECEIVE Receive;
111 NT_NET_TRANSMIT Transmit;
112 } NT_NET_UTILITY_TABLE;
113
114 //
115 // Private functions
116 //
117 typedef
118 EFI_STATUS
119 (*SNPNT32_INITIALIZE_GLOBAL_DATA) (
120 IN SNPNT32_GLOBAL_DATA * This
121 );
122
123 typedef
124 EFI_STATUS
125 (*SNPNT32_INITIALIZE_INSTANCE_DATA) (
126 IN SNPNT32_GLOBAL_DATA * This,
127 IN SNPNT32_INSTANCE_DATA * Instance
128 );
129
130 typedef
131 EFI_STATUS
132 (*SNPNT32_CLOSE_INSTANCE) (
133 IN SNPNT32_GLOBAL_DATA * This,
134 IN SNPNT32_INSTANCE_DATA * Instance
135 );
136
137 //
138 // Global data for this driver
139 //
140 #define SNP_NT32_DRIVER_SIGNATURE SIGNATURE_32 ('W', 'S', 'N', 'P')
141
142 struct _SNPNT32_GLOBAL_DATA {
143 UINT32 Signature;
144
145 //
146 // List for all the fake SNP instance
147 //
148 LIST_ENTRY InstanceList;
149
150 EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk;
151 HMODULE NetworkLibraryHandle;
152
153 NT_NET_UTILITY_TABLE NtNetUtilityTable;
154
155 EFI_LOCK Lock;
156
157 //
158 // Private functions
159 //
160 SNPNT32_INITIALIZE_GLOBAL_DATA InitializeGlobalData;
161 SNPNT32_INITIALIZE_INSTANCE_DATA InitializeInstanceData;
162 SNPNT32_CLOSE_INSTANCE CloseInstance;
163 };
164
165 //
166 // Instance data for each fake SNP instance
167 //
168 #define SNP_NT32_INSTANCE_SIGNATURE SIGNATURE_32 ('w', 'S', 'N', 'P')
169
170 struct _SNPNT32_INSTANCE_DATA {
171 UINT32 Signature;
172
173 //
174 // List entry use for linking with other instance
175 //
176 LIST_ENTRY Entry;
177
178 //
179 // Array of the recycled transmit buffer address.
180 //
181 UINT64 *RecycledTxBuf;
182
183 //
184 // Current number of recycled buffer pointers in RecycledTxBuf.
185 //
186 UINT32 RecycledTxBufCount;
187
188 //
189 // The maximum number of recycled buffer pointers in RecycledTxBuf.
190 //
191 UINT32 MaxRecycledTxBuf;
192
193 SNPNT32_GLOBAL_DATA *GlobalData;
194
195 EFI_HANDLE DeviceHandle;
196 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
197
198 EFI_SIMPLE_NETWORK_PROTOCOL Snp;
199 EFI_SIMPLE_NETWORK_MODE Mode;
200
201 NT_NET_INTERFACE_INFO InterfaceInfo;
202
203 //
204 // Private functions
205 //
206 };
207
208 #define SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS(a) \
209 CR ( \
210 a, \
211 SNPNT32_INSTANCE_DATA, \
212 Snp, \
213 SNP_NT32_INSTANCE_SIGNATURE \
214 )
215
216 extern EFI_DRIVER_BINDING_PROTOCOL gSnpNt32DriverBinding;
217 extern EFI_COMPONENT_NAME_PROTOCOL gSnpNt32DriverComponentName;
218 extern EFI_COMPONENT_NAME2_PROTOCOL gSnpNt32DriverComponentName2;
219
220 /**
221 Test to see if this driver supports ControllerHandle. This service
222 is called by the EFI boot service ConnectController(). In
223 order to make drivers as small as possible, there are a few calling
224 restrictions for this service. ConnectController() must
225 follow these calling restrictions. If any other agent wishes to call
226 Supported() it must also follow these calling restrictions.
227
228 @param This Protocol instance pointer.
229 @param ControllerHandle Handle of device to test
230 @param RemainingDevicePath Optional parameter use to pick a specific child
231 device to start.
232
233 @retval EFI_SUCCESS This driver supports this device
234 @retval EFI_UNSUPPORTED This driver does not support this device
235
236 **/
237 EFI_STATUS
238 EFIAPI
239 SnpNt32DriverBindingSupported (
240 IN EFI_DRIVER_BINDING_PROTOCOL * This,
241 IN EFI_HANDLE ControllerHandle,
242 IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
243 );
244
245 /**
246 Start this driver on ControllerHandle. This service is called by the
247 EFI boot service ConnectController(). In order to make
248 drivers as small as possible, there are a few calling restrictions for
249 this service. ConnectController() must follow these
250 calling restrictions. If any other agent wishes to call Start() it
251 must also follow these calling restrictions.
252
253 @param This Protocol instance pointer.
254 @param ControllerHandle Handle of device to bind driver to
255 @param RemainingDevicePath Optional parameter use to pick a specific child
256 device to start.
257
258 @retval EFI_SUCCESS Always succeeds.
259
260 **/
261 EFI_STATUS
262 EFIAPI
263 SnpNt32DriverBindingStart (
264 IN EFI_DRIVER_BINDING_PROTOCOL * This,
265 IN EFI_HANDLE ControllerHandle,
266 IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
267 );
268
269 /**
270 Stop this driver on ControllerHandle. This service is called by the
271 EFI boot service DisconnectController(). In order to
272 make drivers as small as possible, there are a few calling
273 restrictions for this service. DisconnectController()
274 must follow these calling restrictions. If any other agent wishes
275 to call Stop() it must also follow these calling restrictions.
276
277 @param This Protocol instance pointer.
278 @param ControllerHandle Handle of device to stop driver on
279 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
280 children is zero stop the entire bus driver.
281 @param ChildHandleBuffer List of Child Handles to Stop.
282
283 @retval EFI_SUCCESS Always succeeds.
284
285 **/
286 EFI_STATUS
287 EFIAPI
288 SnpNt32DriverBindingStop (
289 IN EFI_DRIVER_BINDING_PROTOCOL *This,
290 IN EFI_HANDLE ControllerHandle,
291 IN UINTN NumberOfChildren,
292 IN EFI_HANDLE *ChildHandleBuffer
293 );
294
295 /**
296 Initialize the driver's global data.
297
298 @param This Pointer to the global context data.
299
300 @retval EFI_SUCCESS The global data is initialized.
301 @retval EFI_NOT_FOUND The required DLL is not found.
302 @retval EFI_DEVICE_ERROR Error initialize network utility library.
303 @retval EFI_OUT_OF_RESOURCES Out of resource.
304 @retval other Other errors.
305
306 **/
307 EFI_STATUS
308 SnpNt32InitializeGlobalData (
309 IN OUT SNPNT32_GLOBAL_DATA *This
310 );
311
312 /**
313 Initialize the snpnt32 driver instance.
314
315 @param This Pointer to the SnpNt32 global data.
316 @param Instance Pointer to the instance context data.
317
318 @retval EFI_SUCCESS The driver instance is initialized.
319 @retval other Initialization errors.
320
321 **/
322 EFI_STATUS
323 SnpNt32InitializeInstanceData (
324 IN SNPNT32_GLOBAL_DATA *This,
325 IN OUT SNPNT32_INSTANCE_DATA *Instance
326 );
327
328 /**
329 Close the SnpNt32 driver instance.
330
331 @param This Pointer to the SnpNt32 global data.
332 @param Instance Pointer to the instance context data.
333
334 @retval EFI_SUCCESS The instance is closed.
335
336 **/
337 EFI_STATUS
338 SnpNt32CloseInstance (
339 IN SNPNT32_GLOBAL_DATA *This,
340 IN OUT SNPNT32_INSTANCE_DATA *Instance
341 );
342
343 #endif