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