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