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
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.
19 EFI internal structures for the EFI UNDI driver
32 #include <Guid/EventGroup.h>
33 #include <Protocol/PciIo.h>
34 #include <Protocol/NetworkInterfaceIdentifier.h>
35 #include <Protocol/DevicePath.h>
37 #include <Library/UefiDriverEntryPoint.h>
38 #include <Library/UefiRuntimeLib.h>
39 #include <Library/DebugLib.h>
40 #include <Library/BaseMemoryLib.h>
41 #include <Library/UefiBootServicesTableLib.h>
42 #include <Library/UefiLib.h>
44 #include <IndustryStandard/Pci.h>
49 #define MAX_NIC_INTERFACES 16
51 #define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION_31 0x00010001
52 #define PXE_ROMID_MINORVER_31 0x10
53 #define PXE_STATFLAGS_DB_WRITE_TRUNCATED 0x2000
56 // UNDI_CALL_TABLE.state can have the following values
60 #define MUST_BE_STARTED 1
61 #define MUST_BE_INITIALIZED 2
63 #define UNDI_DEV_SIGNATURE EFI_SIGNATURE_32('u','n','d','i')
64 #define UNDI_DEV_FROM_THIS(a) CR(a, UNDI32_DEV, NIIProtocol, UNDI_DEV_SIGNATURE)
65 #define UNDI_DEV_FROM_NIC(a) CR(a, UNDI32_DEV, NicInfo, UNDI_DEV_SIGNATURE)
69 EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL NIIProtocol
;
70 EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL NIIProtocol_31
;
71 EFI_HANDLE DeviceHandle
;
72 EFI_DEVICE_PATH_PROTOCOL
*Undi32BaseDevPath
;
73 EFI_DEVICE_PATH_PROTOCOL
*Undi32DevPath
;
74 NIC_DATA_INSTANCE NicInfo
;
86 EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL
*InterfacePointer
;
87 EFI_DEVICE_PATH_PROTOCOL
*DevicePathPointer
;
90 typedef struct NII_CONFIG_ENTRY
{
92 UINT32 Reserved
; // padding for alignment
93 struct NII_CONFIG_ENTRY
*NextLink
;
94 NII_ENTRY NiiEntry
[1];
97 typedef VOID (*ptr
)(VOID
);
98 typedef VOID (*bsptr_30
)(UINTN
);
99 typedef VOID (*virtphys_30
)(UINT64
, UINT64
);
100 typedef VOID (*block_30
)(UINT32
);
101 typedef VOID (*mem_io_30
)(UINT8
, UINT8
, UINT64
, UINT64
);
103 typedef VOID (*bsptr
)(UINT64
, UINTN
);
104 typedef VOID (*virtphys
)(UINT64
, UINT64
, UINT64
);
105 typedef VOID (*block
)(UINT64
, UINT32
);
106 typedef VOID (*mem_io
)(UINT64
, UINT8
, UINT8
, UINT64
, UINT64
);
108 typedef VOID (*map_mem
)(UINT64
, UINT64
, UINT32
, UINT32
, UINT64
);
109 typedef VOID (*unmap_mem
)(UINT64
, UINT64
, UINT32
, UINT32
, UINT64
);
110 typedef VOID (*sync_mem
)(UINT64
, UINT64
, UINT32
, UINT32
, UINT64
);
112 extern UNDI_CALL_TABLE api_table
[];
113 extern PXE_SW_UNDI
*pxe
; // !pxe structure
114 extern PXE_SW_UNDI
*pxe_31
; // !pxe structure for 3.1 drivers
115 extern UNDI32_DEV
*UNDI32DeviceList
[MAX_NIC_INTERFACES
];
118 // functions defined in e100b.c
120 UINT8
InByte (NIC_DATA_INSTANCE
*AdapterInfo
, UINT32 Port
);
121 UINT16
InWord (NIC_DATA_INSTANCE
*AdapterInfo
, UINT32 Port
);
122 UINT32
InLong (NIC_DATA_INSTANCE
*AdapterInfo
, UINT32 Port
);
123 VOID
OutByte (NIC_DATA_INSTANCE
*AdapterInfo
, UINT8 Data
, UINT32 Port
);
124 VOID
OutWord (NIC_DATA_INSTANCE
*AdapterInfo
, UINT16 Data
, UINT32 Port
);
125 VOID
OutLong (NIC_DATA_INSTANCE
*AdapterInfo
, UINT32 Data
, UINT32 Port
);
127 UINTN
E100bInit (NIC_DATA_INSTANCE
*AdapterInfo
);
128 UINTN
E100bReset (NIC_DATA_INSTANCE
*AdapterInfo
, INT32 OpFlags
);
129 UINTN
E100bShutdown (NIC_DATA_INSTANCE
*AdapterInfo
);
130 UINTN
E100bTransmit (NIC_DATA_INSTANCE
*AdapterInfo
, UINT64 cpb
, UINT16 opflags
);
131 UINTN
E100bReceive (NIC_DATA_INSTANCE
*AdapterInfo
, UINT64 cpb
, UINT64 db
);
132 UINTN
E100bSetfilter (NIC_DATA_INSTANCE
*AdapterInfo
, UINT16 New_filter
,
133 UINT64 cpb
, UINT32 cpbsize
);
134 UINTN
E100bStatistics(NIC_DATA_INSTANCE
*AdapterInfo
, UINT64 db
, UINT16 dbsize
);
135 UINT8
E100bSetupIAAddr (NIC_DATA_INSTANCE
*AdapterInfo
);
136 UINT8
E100bSetInterruptState (NIC_DATA_INSTANCE
*AdapterInfo
);
138 UINT8
E100bGetEepromAddrLen (NIC_DATA_INSTANCE
*AdapterInfo
);
139 UINT16
E100bReadEeprom (NIC_DATA_INSTANCE
*AdapterInfo
, INT32 Location
, UINT8 address_len
);
140 INT16
E100bReadEepromAndStationAddress (NIC_DATA_INSTANCE
*AdapterInfo
);
143 UINT8
SetupCBlink (NIC_DATA_INSTANCE
*AdapterInfo
);
144 VOID
SetFreeCB (NIC_DATA_INSTANCE
*AdapterInfo
,TxCB
*);
145 TxCB
*GetFreeCB (NIC_DATA_INSTANCE
*AdapterInfo
);
146 UINT16
CheckCBList (NIC_DATA_INSTANCE
*AdapterInfo
);
148 UINT8
SelectiveReset (NIC_DATA_INSTANCE
*AdapterInfo
);
149 UINT16
InitializeChip (NIC_DATA_INSTANCE
*AdapterInfo
);
150 UINT8
SetupReceiveQueues (NIC_DATA_INSTANCE
*AdapterInfo
);
151 VOID
Recycle_RFD (NIC_DATA_INSTANCE
*AdapterInfo
, UINT16
);
152 VOID
XmitWaitForCompletion (NIC_DATA_INSTANCE
*AdapterInfo
);
153 INT8
CommandWaitForCompletion (TxCB
*cmd_ptr
, NIC_DATA_INSTANCE
*AdapterInfo
);
155 BOOLEAN
PhyDetect (NIC_DATA_INSTANCE
*AdapterInfo
);
156 VOID
PhyReset (NIC_DATA_INSTANCE
*AdapterInfo
);
159 IN NIC_DATA_INSTANCE
*AdapterInfo
,
167 IN NIC_DATA_INSTANCE
*AdapterInfo
,
170 IN OUT UINT16
*DataValue
173 BOOLEAN
SetupPhy (NIC_DATA_INSTANCE
*AdapterInfo
);
174 VOID
FindPhySpeedAndDpx (NIC_DATA_INSTANCE
*AdapterInfo
, UINT32 PhyId
);
179 // functions defined in init.c
188 InitializeUNDIDriver (
189 IN EFI_HANDLE ImageHandle
,
190 IN EFI_SYSTEM_TABLE
*SystemTable
194 UNDI_notify_virtual (
208 UndiDriverSupported (
209 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
210 IN EFI_HANDLE Controller
,
211 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
217 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
218 IN EFI_HANDLE Controller
,
219 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
225 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
226 IN EFI_HANDLE Controller
,
227 IN UINTN NumberOfChildren
,
228 IN EFI_HANDLE
*ChildHandleBuffer
233 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevPtr
,
234 IN EFI_DEVICE_PATH_PROTOCOL
*BaseDevPtr
,
235 IN NIC_DATA_INSTANCE
*AdapterInfo
241 IN UINTN MicroSeconds
254 // functions defined in decode.c
259 IN NIC_DATA_INSTANCE
*AdapterInfo
265 IN NIC_DATA_INSTANCE
*AdapterInfo
271 IN NIC_DATA_INSTANCE
*AdapterInfo
277 IN NIC_DATA_INSTANCE
*AdapterInfo
283 IN NIC_DATA_INSTANCE
*AdapterInfo
289 NIC_DATA_INSTANCE
*AdapterInfo
295 IN NIC_DATA_INSTANCE
*AdapterInfo
301 IN NIC_DATA_INSTANCE
*AdapterInfo
307 IN NIC_DATA_INSTANCE
*AdapterInfo
313 IN NIC_DATA_INSTANCE
*AdapterInfo
319 IN NIC_DATA_INSTANCE
*AdapterInfo
325 IN NIC_DATA_INSTANCE
*AdapterInfo
331 IN NIC_DATA_INSTANCE
*AdapterInfo
337 IN NIC_DATA_INSTANCE
*AdapterInfo
343 IN NIC_DATA_INSTANCE
*AdapterInfo
349 IN NIC_DATA_INSTANCE
*AdapterInfo
355 IN NIC_DATA_INSTANCE
*AdapterInfo
361 IN NIC_DATA_INSTANCE
*AdapterInfo
364 VOID
UNDI_APIEntry_new(UINT64
);
365 VOID
UNDI_APIEntry_old(UINT64
);
366 VOID
UNDI_APIEntry_Common(UINT64
);
368 PXE_IPV4
convert_mcip(PXE_MAC_ADDR
*);
369 INT32
validate_mcip (PXE_MAC_ADDR
*MCastAddr
);
371 VOID
PxeStructInit (PXE_SW_UNDI
*PxePtr
, UINTN VersionFlag
);
372 VOID
PxeUpdate (NIC_DATA_INSTANCE
*NicPtr
, PXE_SW_UNDI
*PxePtr
);