2 EFI internal structures for the EFI UNDI driver.
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
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.
20 #include <Guid/EventGroup.h>
21 #include <Protocol/PciIo.h>
22 #include <Protocol/NetworkInterfaceIdentifier.h>
23 #include <Protocol/DevicePath.h>
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>
34 #include <IndustryStandard/Pci.h>
39 extern EFI_DRIVER_BINDING_PROTOCOL gUndiDriverBinding
;
40 extern EFI_COMPONENT_NAME_PROTOCOL gUndiComponentName
;
41 extern EFI_COMPONENT_NAME2_PROTOCOL gUndiComponentName2
;
43 #define MAX_NIC_INTERFACES 16
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
50 // UNDI_CALL_TABLE.state can have the following values
54 #define MUST_BE_STARTED 1
55 #define MUST_BE_INITIALIZED 2
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)
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
;
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
);
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
);
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
);
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
];
98 // functions defined in e100b.c
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
);
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
);
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
);
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
);
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
);
135 BOOLEAN
PhyDetect (NIC_DATA_INSTANCE
*AdapterInfo
);
136 VOID
PhyReset (NIC_DATA_INSTANCE
*AdapterInfo
);
139 IN NIC_DATA_INSTANCE
*AdapterInfo
,
147 IN NIC_DATA_INSTANCE
*AdapterInfo
,
150 IN OUT UINT16
*DataValue
153 BOOLEAN
SetupPhy (NIC_DATA_INSTANCE
*AdapterInfo
);
154 VOID
FindPhySpeedAndDpx (NIC_DATA_INSTANCE
*AdapterInfo
, UINT32 PhyId
);
159 // functions defined in init.c
168 InitializeUNDIDriver (
169 IN EFI_HANDLE ImageHandle
,
170 IN EFI_SYSTEM_TABLE
*SystemTable
174 UNDI_notify_virtual (
188 UndiDriverSupported (
189 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
190 IN EFI_HANDLE Controller
,
191 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
197 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
198 IN EFI_HANDLE Controller
,
199 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
205 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
206 IN EFI_HANDLE Controller
,
207 IN UINTN NumberOfChildren
,
208 IN EFI_HANDLE
*ChildHandleBuffer
213 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevPtr
,
214 IN EFI_DEVICE_PATH_PROTOCOL
*BaseDevPtr
,
215 IN NIC_DATA_INSTANCE
*AdapterInfo
221 IN UINTN MicroSeconds
234 // functions defined in decode.c
239 IN NIC_DATA_INSTANCE
*AdapterInfo
245 IN NIC_DATA_INSTANCE
*AdapterInfo
251 IN NIC_DATA_INSTANCE
*AdapterInfo
257 IN NIC_DATA_INSTANCE
*AdapterInfo
263 IN NIC_DATA_INSTANCE
*AdapterInfo
269 NIC_DATA_INSTANCE
*AdapterInfo
275 IN NIC_DATA_INSTANCE
*AdapterInfo
281 IN NIC_DATA_INSTANCE
*AdapterInfo
287 IN NIC_DATA_INSTANCE
*AdapterInfo
293 IN NIC_DATA_INSTANCE
*AdapterInfo
299 IN NIC_DATA_INSTANCE
*AdapterInfo
305 IN NIC_DATA_INSTANCE
*AdapterInfo
311 IN NIC_DATA_INSTANCE
*AdapterInfo
317 IN NIC_DATA_INSTANCE
*AdapterInfo
323 IN NIC_DATA_INSTANCE
*AdapterInfo
329 IN NIC_DATA_INSTANCE
*AdapterInfo
335 IN NIC_DATA_INSTANCE
*AdapterInfo
341 IN NIC_DATA_INSTANCE
*AdapterInfo
344 VOID
UNDI_APIEntry_new(UINT64
);
345 VOID
UNDI_APIEntry_Common(UINT64
);
347 PXE_IPV4
convert_mcip(PXE_MAC_ADDR
*);
348 INT32
validate_mcip (PXE_MAC_ADDR
*MCastAddr
);
350 VOID
PxeStructInit (PXE_SW_UNDI
*PxePtr
);
351 VOID
PxeUpdate (NIC_DATA_INSTANCE
*NicPtr
, PXE_SW_UNDI
*PxePtr
);