]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Pci/UndiRuntimeDxe/Undi32.h
Fixed potential issues to release resources when error occurs.
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / UndiRuntimeDxe / Undi32.h
1
2 /*++
3
4 Copyright (c) 2006 - 2007, Intel Corporation.
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 Module Name:
14
15 undi32.h
16
17 Abstract:
18
19 EFI internal structures for the EFI UNDI driver
20
21
22
23 Revision History
24
25 --*/
26
27 #ifndef _UNDI_32_H_
28 #define _UNDI_32_H_
29
30 #include <PiDxe.h>
31
32 #include <Guid/EventGroup.h>
33 #include <Protocol/PciIo.h>
34 #include <Protocol/NetworkInterfaceIdentifier.h>
35 #include <Protocol/DevicePath.h>
36
37 #include <Library/UefiDriverEntryPoint.h>
38 #include <Library/UefiRuntimeLib.h>
39 #include <Library/DebugLib.h>
40 #include <Library/BaseMemoryLib.h>
41 #include <Library/UefiBootServicesTableLib.h>
42 #include <Library/UefiLib.h>
43
44 #include <IndustryStandard/Pci.h>
45
46
47 #include "E100b.h"
48
49 #define MAX_NIC_INTERFACES 16
50
51 #define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION_31 0x00010001
52 #define PXE_ROMID_MINORVER_31 0x10
53 #define PXE_STATFLAGS_DB_WRITE_TRUNCATED 0x2000
54
55 //
56 // UNDI_CALL_TABLE.state can have the following values
57 //
58 #define DONT_CHECK -1
59 #define ANY_STATE -1
60 #define MUST_BE_STARTED 1
61 #define MUST_BE_INITIALIZED 2
62
63 #define UNDI_DEV_SIGNATURE EFI_SIGNATURE_32('u','n','d','i')
64 #define UNDI_DEV_FROM_THIS(a) CR(a, UNDI32_DEV, NIIProtocol_31, UNDI_DEV_SIGNATURE)
65 #define UNDI_DEV_FROM_NIC(a) CR(a, UNDI32_DEV, NicInfo, UNDI_DEV_SIGNATURE)
66
67 typedef struct {
68 UINTN Signature;
69 EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL NIIProtocol_31;
70 EFI_HANDLE DeviceHandle;
71 EFI_DEVICE_PATH_PROTOCOL *Undi32BaseDevPath;
72 EFI_DEVICE_PATH_PROTOCOL *Undi32DevPath;
73 NIC_DATA_INSTANCE NicInfo;
74 } UNDI32_DEV;
75
76 typedef struct {
77 UINT16 cpbsize;
78 UINT16 dbsize;
79 UINT16 opflags;
80 UINT16 state;
81 VOID (*api_ptr)();
82 } UNDI_CALL_TABLE;
83
84 typedef struct {
85 EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *InterfacePointer;
86 EFI_DEVICE_PATH_PROTOCOL *DevicePathPointer;
87 } NII_ENTRY;
88
89 typedef struct NII_CONFIG_ENTRY {
90 UINT32 NumEntries;
91 UINT32 Reserved; // padding for alignment
92 struct NII_CONFIG_ENTRY *NextLink;
93 NII_ENTRY NiiEntry[1];
94 } NII_TABLE;
95
96 typedef VOID (*ptr)(VOID);
97 typedef VOID (*bsptr_30)(UINTN);
98 typedef VOID (*virtphys_30)(UINT64, UINT64);
99 typedef VOID (*block_30)(UINT32);
100 typedef VOID (*mem_io_30)(UINT8, UINT8, UINT64, UINT64);
101
102 typedef VOID (*bsptr)(UINT64, UINTN);
103 typedef VOID (*virtphys)(UINT64, UINT64, UINT64);
104 typedef VOID (*block)(UINT64, UINT32);
105 typedef VOID (*mem_io)(UINT64, UINT8, UINT8, UINT64, UINT64);
106
107 typedef VOID (*map_mem)(UINT64, UINT64, UINT32, UINT32, UINT64);
108 typedef VOID (*unmap_mem)(UINT64, UINT64, UINT32, UINT32, UINT64);
109 typedef VOID (*sync_mem)(UINT64, UINT64, UINT32, UINT32, UINT64);
110
111 extern UNDI_CALL_TABLE api_table[];
112 extern PXE_SW_UNDI *pxe_31; // !pxe structure for 3.1 drivers
113 extern UNDI32_DEV *UNDI32DeviceList[MAX_NIC_INTERFACES];
114
115 //
116 // functions defined in e100b.c
117 //
118 UINT8 InByte (NIC_DATA_INSTANCE *AdapterInfo, UINT32 Port);
119 UINT16 InWord (NIC_DATA_INSTANCE *AdapterInfo, UINT32 Port);
120 UINT32 InLong (NIC_DATA_INSTANCE *AdapterInfo, UINT32 Port);
121 VOID OutByte (NIC_DATA_INSTANCE *AdapterInfo, UINT8 Data, UINT32 Port);
122 VOID OutWord (NIC_DATA_INSTANCE *AdapterInfo, UINT16 Data, UINT32 Port);
123 VOID OutLong (NIC_DATA_INSTANCE *AdapterInfo, UINT32 Data, UINT32 Port);
124
125 UINTN E100bInit (NIC_DATA_INSTANCE *AdapterInfo);
126 UINTN E100bReset (NIC_DATA_INSTANCE *AdapterInfo, INT32 OpFlags);
127 UINTN E100bShutdown (NIC_DATA_INSTANCE *AdapterInfo);
128 UINTN E100bTransmit (NIC_DATA_INSTANCE *AdapterInfo, UINT64 cpb, UINT16 opflags);
129 UINTN E100bReceive (NIC_DATA_INSTANCE *AdapterInfo, UINT64 cpb, UINT64 db);
130 UINTN E100bSetfilter (NIC_DATA_INSTANCE *AdapterInfo, UINT16 New_filter,
131 UINT64 cpb, UINT32 cpbsize);
132 UINTN E100bStatistics(NIC_DATA_INSTANCE *AdapterInfo, UINT64 db, UINT16 dbsize);
133 UINT8 E100bSetupIAAddr (NIC_DATA_INSTANCE *AdapterInfo);
134 UINT8 E100bSetInterruptState (NIC_DATA_INSTANCE *AdapterInfo);
135
136 UINT8 E100bGetEepromAddrLen (NIC_DATA_INSTANCE *AdapterInfo);
137 UINT16 E100bReadEeprom (NIC_DATA_INSTANCE *AdapterInfo, INT32 Location, UINT8 address_len);
138 INT16 E100bReadEepromAndStationAddress (NIC_DATA_INSTANCE *AdapterInfo);
139
140 UINT16 next(UINT16);
141 UINT8 SetupCBlink (NIC_DATA_INSTANCE *AdapterInfo);
142 VOID SetFreeCB (NIC_DATA_INSTANCE *AdapterInfo,TxCB *);
143 TxCB *GetFreeCB (NIC_DATA_INSTANCE *AdapterInfo);
144 UINT16 CheckCBList (NIC_DATA_INSTANCE *AdapterInfo);
145
146 UINT8 SelectiveReset (NIC_DATA_INSTANCE *AdapterInfo);
147 UINT16 InitializeChip (NIC_DATA_INSTANCE *AdapterInfo);
148 UINT8 SetupReceiveQueues (NIC_DATA_INSTANCE *AdapterInfo);
149 VOID Recycle_RFD (NIC_DATA_INSTANCE *AdapterInfo, UINT16);
150 VOID XmitWaitForCompletion (NIC_DATA_INSTANCE *AdapterInfo);
151 INT8 CommandWaitForCompletion (TxCB *cmd_ptr, NIC_DATA_INSTANCE *AdapterInfo);
152
153 BOOLEAN PhyDetect (NIC_DATA_INSTANCE *AdapterInfo);
154 VOID PhyReset (NIC_DATA_INSTANCE *AdapterInfo);
155 VOID
156 MdiWrite (
157 IN NIC_DATA_INSTANCE *AdapterInfo,
158 IN UINT8 RegAddress,
159 IN UINT8 PhyAddress,
160 IN UINT16 DataValue
161 );
162
163 VOID
164 MdiRead(
165 IN NIC_DATA_INSTANCE *AdapterInfo,
166 IN UINT8 RegAddress,
167 IN UINT8 PhyAddress,
168 IN OUT UINT16 *DataValue
169 );
170
171 BOOLEAN SetupPhy (NIC_DATA_INSTANCE *AdapterInfo);
172 VOID FindPhySpeedAndDpx (NIC_DATA_INSTANCE *AdapterInfo, UINT32 PhyId);
173
174
175
176 //
177 // functions defined in init.c
178 //
179 EFI_STATUS
180 InstallConfigTable (
181 IN VOID
182 );
183
184 EFI_STATUS
185 EFIAPI
186 InitializeUNDIDriver (
187 IN EFI_HANDLE ImageHandle,
188 IN EFI_SYSTEM_TABLE *SystemTable
189 );
190
191 VOID
192 UNDI_notify_virtual (
193 EFI_EVENT event,
194 VOID *context
195 );
196
197 VOID
198 EFIAPI
199 UndiNotifyExitBs (
200 EFI_EVENT Event,
201 VOID *Context
202 );
203
204 EFI_STATUS
205 EFIAPI
206 UndiDriverSupported (
207 IN EFI_DRIVER_BINDING_PROTOCOL *This,
208 IN EFI_HANDLE Controller,
209 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
210 );
211
212 EFI_STATUS
213 EFIAPI
214 UndiDriverStart (
215 IN EFI_DRIVER_BINDING_PROTOCOL *This,
216 IN EFI_HANDLE Controller,
217 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
218 );
219
220 EFI_STATUS
221 EFIAPI
222 UndiDriverStop (
223 IN EFI_DRIVER_BINDING_PROTOCOL *This,
224 IN EFI_HANDLE Controller,
225 IN UINTN NumberOfChildren,
226 IN EFI_HANDLE *ChildHandleBuffer
227 );
228
229 EFI_STATUS
230 AppendMac2DevPath (
231 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevPtr,
232 IN EFI_DEVICE_PATH_PROTOCOL *BaseDevPtr,
233 IN NIC_DATA_INSTANCE *AdapterInfo
234 );
235
236 VOID
237 TmpDelay (
238 IN UINT64 UnqId,
239 IN UINTN MicroSeconds
240 );
241
242 VOID
243 TmpMemIo (
244 IN UINT64 UnqId,
245 IN UINT8 ReadWrite,
246 IN UINT8 Len,
247 IN UINT64 Port,
248 IN UINT64 BufAddr
249 );
250
251 //
252 // functions defined in decode.c
253 //
254 VOID
255 UNDI_GetState (
256 IN PXE_CDB *CdbPtr,
257 IN NIC_DATA_INSTANCE *AdapterInfo
258 );
259
260 VOID
261 UNDI_Start (
262 IN PXE_CDB *CdbPtr,
263 IN NIC_DATA_INSTANCE *AdapterInfo
264 );
265
266 VOID
267 UNDI_Stop (
268 IN PXE_CDB *CdbPtr,
269 IN NIC_DATA_INSTANCE *AdapterInfo
270 );
271
272 VOID
273 UNDI_GetInitInfo (
274 IN PXE_CDB *CdbPtr,
275 IN NIC_DATA_INSTANCE *AdapterInfo
276 );
277
278 VOID
279 UNDI_GetConfigInfo (
280 IN PXE_CDB *CdbPtr,
281 IN NIC_DATA_INSTANCE *AdapterInfo
282 );
283
284 VOID
285 UNDI_Initialize (
286 IN PXE_CDB *CdbPtr,
287 NIC_DATA_INSTANCE *AdapterInfo
288 );
289
290 VOID
291 UNDI_Reset (
292 IN PXE_CDB *CdbPtr,
293 IN NIC_DATA_INSTANCE *AdapterInfo
294 );
295
296 VOID
297 UNDI_Shutdown (
298 IN PXE_CDB *CdbPtr,
299 IN NIC_DATA_INSTANCE *AdapterInfo
300 );
301
302 VOID
303 UNDI_Interrupt (
304 IN PXE_CDB *CdbPtr,
305 IN NIC_DATA_INSTANCE *AdapterInfo
306 );
307
308 VOID
309 UNDI_RecFilter (
310 IN PXE_CDB *CdbPtr,
311 IN NIC_DATA_INSTANCE *AdapterInfo
312 );
313
314 VOID
315 UNDI_StnAddr (
316 IN PXE_CDB *CdbPtr,
317 IN NIC_DATA_INSTANCE *AdapterInfo
318 );
319
320 VOID
321 UNDI_Statistics (
322 IN PXE_CDB *CdbPtr,
323 IN NIC_DATA_INSTANCE *AdapterInfo
324 );
325
326 VOID
327 UNDI_ip2mac (
328 IN PXE_CDB *CdbPtr,
329 IN NIC_DATA_INSTANCE *AdapterInfo
330 );
331
332 VOID
333 UNDI_NVData (
334 IN PXE_CDB *CdbPtr,
335 IN NIC_DATA_INSTANCE *AdapterInfo
336 );
337
338 VOID
339 UNDI_Status (
340 IN PXE_CDB *CdbPtr,
341 IN NIC_DATA_INSTANCE *AdapterInfo
342 );
343
344 VOID
345 UNDI_FillHeader (
346 IN PXE_CDB *CdbPtr,
347 IN NIC_DATA_INSTANCE *AdapterInfo
348 );
349
350 VOID
351 UNDI_Transmit (
352 IN PXE_CDB *CdbPtr,
353 IN NIC_DATA_INSTANCE *AdapterInfo
354 );
355
356 VOID
357 UNDI_Receive (
358 IN PXE_CDB *CdbPtr,
359 IN NIC_DATA_INSTANCE *AdapterInfo
360 );
361
362 VOID UNDI_APIEntry_new(UINT64);
363 VOID UNDI_APIEntry_Common(UINT64);
364
365 PXE_IPV4 convert_mcip(PXE_MAC_ADDR *);
366 INT32 validate_mcip (PXE_MAC_ADDR *MCastAddr);
367
368 VOID PxeStructInit (PXE_SW_UNDI *PxePtr);
369 VOID PxeUpdate (NIC_DATA_INSTANCE *NicPtr, PXE_SW_UNDI *PxePtr);
370
371 #endif