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