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