2 EFI internal structures for the EFI UNDI driver.
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
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 #define MAX_NIC_INTERFACES 16
41 #define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION_31 0x00010001
42 #define PXE_ROMID_MINORVER_31 0x10
43 #define PXE_STATFLAGS_DB_WRITE_TRUNCATED 0x2000
46 // UNDI_CALL_TABLE.state can have the following values
50 #define MUST_BE_STARTED 1
51 #define MUST_BE_INITIALIZED 2
53 #define UNDI_DEV_SIGNATURE SIGNATURE_32('u','n','d','i')
54 #define UNDI_DEV_FROM_THIS(a) CR(a, UNDI32_DEV, NIIProtocol_31, UNDI_DEV_SIGNATURE)
55 #define UNDI_DEV_FROM_NIC(a) CR(a, UNDI32_DEV, NicInfo, UNDI_DEV_SIGNATURE)
59 EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL NIIProtocol_31
;
60 EFI_HANDLE DeviceHandle
;
61 EFI_DEVICE_PATH_PROTOCOL
*Undi32BaseDevPath
;
62 EFI_DEVICE_PATH_PROTOCOL
*Undi32DevPath
;
63 NIC_DATA_INSTANCE NicInfo
;
75 EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL
*InterfacePointer
;
76 EFI_DEVICE_PATH_PROTOCOL
*DevicePathPointer
;
79 typedef struct NII_CONFIG_ENTRY
{
81 UINT32 Reserved
; // padding for alignment
82 struct NII_CONFIG_ENTRY
*NextLink
;
83 NII_ENTRY NiiEntry
[1];
86 typedef VOID (*ptr
)(VOID
);
87 typedef VOID (*bsptr_30
)(UINTN
);
88 typedef VOID (*virtphys_30
)(UINT64
, UINT64
);
89 typedef VOID (*block_30
)(UINT32
);
90 typedef VOID (*mem_io_30
)(UINT8
, UINT8
, UINT64
, UINT64
);
92 typedef VOID (*bsptr
)(UINT64
, UINTN
);
93 typedef VOID (*virtphys
)(UINT64
, UINT64
, UINT64
);
94 typedef VOID (*block
)(UINT64
, UINT32
);
95 typedef VOID (*mem_io
)(UINT64
, UINT8
, UINT8
, UINT64
, UINT64
);
97 typedef VOID (*map_mem
)(UINT64
, UINT64
, UINT32
, UINT32
, UINT64
);
98 typedef VOID (*unmap_mem
)(UINT64
, UINT64
, UINT32
, UINT32
, UINT64
);
99 typedef VOID (*sync_mem
)(UINT64
, UINT64
, UINT32
, UINT32
, UINT64
);
101 extern UNDI_CALL_TABLE api_table
[];
102 extern PXE_SW_UNDI
*pxe_31
; // !pxe structure for 3.1 drivers
103 extern UNDI32_DEV
*UNDI32DeviceList
[MAX_NIC_INTERFACES
];
106 // functions defined in e100b.c
108 UINT8
InByte (NIC_DATA_INSTANCE
*AdapterInfo
, UINT32 Port
);
109 UINT16
InWord (NIC_DATA_INSTANCE
*AdapterInfo
, UINT32 Port
);
110 UINT32
InLong (NIC_DATA_INSTANCE
*AdapterInfo
, UINT32 Port
);
111 VOID
OutByte (NIC_DATA_INSTANCE
*AdapterInfo
, UINT8 Data
, UINT32 Port
);
112 VOID
OutWord (NIC_DATA_INSTANCE
*AdapterInfo
, UINT16 Data
, UINT32 Port
);
113 VOID
OutLong (NIC_DATA_INSTANCE
*AdapterInfo
, UINT32 Data
, UINT32 Port
);
115 UINTN
E100bInit (NIC_DATA_INSTANCE
*AdapterInfo
);
116 UINTN
E100bReset (NIC_DATA_INSTANCE
*AdapterInfo
, INT32 OpFlags
);
117 UINTN
E100bShutdown (NIC_DATA_INSTANCE
*AdapterInfo
);
118 UINTN
E100bTransmit (NIC_DATA_INSTANCE
*AdapterInfo
, UINT64 cpb
, UINT16 opflags
);
119 UINTN
E100bReceive (NIC_DATA_INSTANCE
*AdapterInfo
, UINT64 cpb
, UINT64 db
);
120 UINTN
E100bSetfilter (NIC_DATA_INSTANCE
*AdapterInfo
, UINT16 New_filter
,
121 UINT64 cpb
, UINT32 cpbsize
);
122 UINTN
E100bStatistics(NIC_DATA_INSTANCE
*AdapterInfo
, UINT64 db
, UINT16 dbsize
);
123 UINT8
E100bSetupIAAddr (NIC_DATA_INSTANCE
*AdapterInfo
);
124 UINT8
E100bSetInterruptState (NIC_DATA_INSTANCE
*AdapterInfo
);
126 UINT8
E100bGetEepromAddrLen (NIC_DATA_INSTANCE
*AdapterInfo
);
127 UINT16
E100bReadEeprom (NIC_DATA_INSTANCE
*AdapterInfo
, INT32 Location
, UINT8 address_len
);
128 INT16
E100bReadEepromAndStationAddress (NIC_DATA_INSTANCE
*AdapterInfo
);
131 UINT8
SetupCBlink (NIC_DATA_INSTANCE
*AdapterInfo
);
132 VOID
SetFreeCB (NIC_DATA_INSTANCE
*AdapterInfo
,TxCB
*);
133 TxCB
*GetFreeCB (NIC_DATA_INSTANCE
*AdapterInfo
);
134 UINT16
CheckCBList (NIC_DATA_INSTANCE
*AdapterInfo
);
136 UINT8
SelectiveReset (NIC_DATA_INSTANCE
*AdapterInfo
);
137 UINT16
InitializeChip (NIC_DATA_INSTANCE
*AdapterInfo
);
138 UINT8
SetupReceiveQueues (NIC_DATA_INSTANCE
*AdapterInfo
);
139 VOID
Recycle_RFD (NIC_DATA_INSTANCE
*AdapterInfo
, UINT16
);
140 VOID
XmitWaitForCompletion (NIC_DATA_INSTANCE
*AdapterInfo
);
141 INT8
CommandWaitForCompletion (TxCB
*cmd_ptr
, NIC_DATA_INSTANCE
*AdapterInfo
);
143 BOOLEAN
PhyDetect (NIC_DATA_INSTANCE
*AdapterInfo
);
144 VOID
PhyReset (NIC_DATA_INSTANCE
*AdapterInfo
);
147 IN NIC_DATA_INSTANCE
*AdapterInfo
,
155 IN NIC_DATA_INSTANCE
*AdapterInfo
,
158 IN OUT UINT16
*DataValue
161 BOOLEAN
SetupPhy (NIC_DATA_INSTANCE
*AdapterInfo
);
162 VOID
FindPhySpeedAndDpx (NIC_DATA_INSTANCE
*AdapterInfo
, UINT32 PhyId
);
167 // functions defined in init.c
176 InitializeUNDIDriver (
177 IN EFI_HANDLE ImageHandle
,
178 IN EFI_SYSTEM_TABLE
*SystemTable
182 UNDI_notify_virtual (
196 UndiDriverSupported (
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 EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
213 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
214 IN EFI_HANDLE Controller
,
215 IN UINTN NumberOfChildren
,
216 IN EFI_HANDLE
*ChildHandleBuffer
221 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevPtr
,
222 IN EFI_DEVICE_PATH_PROTOCOL
*BaseDevPtr
,
223 IN NIC_DATA_INSTANCE
*AdapterInfo
229 IN UINTN MicroSeconds
242 // functions defined in decode.c
247 IN NIC_DATA_INSTANCE
*AdapterInfo
253 IN NIC_DATA_INSTANCE
*AdapterInfo
259 IN NIC_DATA_INSTANCE
*AdapterInfo
265 IN NIC_DATA_INSTANCE
*AdapterInfo
271 IN NIC_DATA_INSTANCE
*AdapterInfo
277 NIC_DATA_INSTANCE
*AdapterInfo
283 IN NIC_DATA_INSTANCE
*AdapterInfo
289 IN 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
352 VOID
UNDI_APIEntry_new(UINT64
);
353 VOID
UNDI_APIEntry_Common(UINT64
);
355 PXE_IPV4
convert_mcip(PXE_MAC_ADDR
*);
356 INT32
validate_mcip (PXE_MAC_ADDR
*MCastAddr
);
358 VOID
PxeStructInit (PXE_SW_UNDI
*PxePtr
);
359 VOID
PxeUpdate (NIC_DATA_INSTANCE
*NicPtr
, PXE_SW_UNDI
*PxePtr
);