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