git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1459 6f19259b...
[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 //
98 // functions defined in e100b.c
99 //
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);
106
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);
117
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);
121
122 UINT16 next(UINT16);
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);
127
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);
134
135 BOOLEAN PhyDetect (NIC_DATA_INSTANCE *AdapterInfo);
136 VOID PhyReset (NIC_DATA_INSTANCE *AdapterInfo);
137 VOID
138 MdiWrite (
139 IN NIC_DATA_INSTANCE *AdapterInfo,
140 IN UINT8 RegAddress,
141 IN UINT8 PhyAddress,
142 IN UINT16 DataValue
143 );
144
145 VOID
146 MdiRead(
147 IN NIC_DATA_INSTANCE *AdapterInfo,
148 IN UINT8 RegAddress,
149 IN UINT8 PhyAddress,
150 IN OUT UINT16 *DataValue
151 );
152
153 BOOLEAN SetupPhy (NIC_DATA_INSTANCE *AdapterInfo);
154 VOID FindPhySpeedAndDpx (NIC_DATA_INSTANCE *AdapterInfo, UINT32 PhyId);
155
156
157
158 //
159 // functions defined in init.c
160 //
161 VOID
162 TmpDelay (
163 IN UINT64 UnqId,
164 IN UINTN MicroSeconds
165 );
166
167 VOID
168 TmpMemIo (
169 IN UINT64 UnqId,
170 IN UINT8 ReadWrite,
171 IN UINT8 Len,
172 IN UINT64 Port,
173 IN UINT64 BufAddr
174 );
175
176 //
177 // functions defined in decode.c
178 //
179 VOID UNDI_GetState();
180 VOID UNDI_Start();
181 VOID UNDI_Stop();
182 VOID UNDI_GetInitInfo();
183 VOID UNDI_GetConfigInfo();
184 VOID UNDI_Initialize();
185 VOID UNDI_Reset();
186 VOID UNDI_Shutdown();
187 VOID UNDI_Interrupt();
188 VOID UNDI_RecFilter();
189 VOID UNDI_StnAddr();
190 VOID UNDI_Statistics();
191 VOID UNDI_ip2mac();
192 VOID UNDI_NVData();
193 VOID UNDI_Status();
194 VOID UNDI_FillHeader();
195 VOID UNDI_Transmit();
196 VOID UNDI_Receive();
197
198 VOID UNDI_APIEntry_new(UINT64);
199 VOID UNDI_APIEntry_old(UINT64);
200 VOID UNDI_APIEntry_Common(UINT64);
201
202 PXE_IPV4 convert_mcip(PXE_MAC_ADDR *);
203 INT32 validate_mcip (PXE_MAC_ADDR *MCastAddr);
204
205 VOID PxeStructInit (PXE_SW_UNDI *PxePtr, UINTN VersionFlag);
206 VOID PxeUpdate (NIC_DATA_INSTANCE *NicPtr, PXE_SW_UNDI *PxePtr);
207
208 #endif