- Merge aicom-network-fixes up to r36740
[reactos.git] / reactos / drivers / network / dd / ne2000 / include / ne2000.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Novell Eagle 2000 driver
4 * FILE: include/ne2000.h
5 * PURPOSE: NE2000 driver definitions
6 */
7 #ifndef __NE2000_H
8 #define __NE2000_H
9
10 #define NDIS_MINIPORT_DRIVER 1
11 #define NDIS_LEGACY_MINIPORT 1
12 #define NDIS51_MINIPORT 1
13 #include <ndis.h>
14 #include <8390.h>
15 #include <debug.h>
16
17 /* Define NOCARD to test NDIS without a card */
18 //#define NOCARD
19
20 /* NE2000 sepcific constants */
21 #define NIC_DATA 0x10 /* Data register */
22 #define NIC_RESET 0x1F /* Reset register */
23
24
25 /* Global constants */
26
27 #define DRIVER_NDIS_MAJOR_VERSION 3
28 #define DRIVER_NDIS_MINOR_VERSION 0
29
30 #define DRIVER_DEFAULT_IO_BASE_ADDRESS 0x280 /* bochs default */
31 #define DRIVER_DEFAULT_INTERRUPT_NUMBER 9 /* bochs default */
32 #define DRIVER_DEFAULT_INTERRUPT_SHARED FALSE
33 #define DRIVER_DEFAULT_INTERRUPT_MODE NdisInterruptLatched
34
35 #define DRIVER_MAX_MULTICAST_LIST_SIZE 8
36
37 #define DRIVER_VENDOR_DESCRIPTION "Novell Eagle 2000 Adapter."
38 #define DRIVER_VENDOR_DRIVER_VERSION 0x0100 /* 1.0 */
39
40 #define DRIVER_FRAME_SIZE 1514 /* Size of an ethernet frame */
41 #define DRIVER_HEADER_SIZE 14 /* Size of an ethernet header */
42 #define DRIVER_LENGTH_OF_ADDRESS 6 /* Size of an ethernet address */
43
44 /* Maximum lookahead buffer size */
45 #define DRIVER_MAXIMUM_LOOKAHEAD (252 - DRIVER_HEADER_SIZE)
46
47 /* Size of a block in a buffer ring */
48 #define DRIVER_BLOCK_SIZE 256
49
50
51 /* Default number of transmit buffers */
52 #define DRIVER_DEFAULT_TX_BUFFER_COUNT 12
53 #define BUFFERS_PER_TX_BUF 1
54
55 /* Interrupt Mask Register value */
56 #define DRIVER_INTERRUPT_MASK IMR_ALLE - IMR_RDCE
57
58
59
60 /* Global structures */
61
62 typedef struct _MINIPORT_RESERVED
63 {
64 PNDIS_PACKET Next;
65 } MINIPORT_RESERVED, *PMINIPORT_RESERVED;
66
67 #define RESERVED(Packet) ((PMINIPORT_RESERVED)((Packet)->MiniportReserved))
68
69 typedef UCHAR DRIVER_HARDWARE_ADDRESS[DRIVER_LENGTH_OF_ADDRESS];
70
71 /* Information about an adapter */
72 typedef struct _NIC_ADAPTER
73 {
74 /* Entry on global adapter list */
75 LIST_ENTRY ListEntry;
76 /* Adapter handle */
77 NDIS_HANDLE MiniportAdapterHandle;
78 /* NDIS interrupt object */
79 NDIS_MINIPORT_INTERRUPT Interrupt;
80
81 /* I/O base address and interrupt number of adapter */
82 ULONG IoBaseAddress;
83 ULONG InterruptLevel;
84 ULONG InterruptVector;
85 BOOLEAN InterruptShared;
86 KINTERRUPT_MODE InterruptMode;
87
88 /* Mapped address of the I/O base port */
89 PUCHAR IOBase;
90
91 /* TRUE if the NIC can transfer in word mode */
92 BOOLEAN WordMode;
93
94 /* Base address and size of the onboard memory window */
95 PUCHAR RamBase;
96 UINT RamSize;
97
98 /* Station Address PROM (SAPROM) */
99 UCHAR SAPROM[16];
100
101 /* Onboard ethernet address from the manufacturer */
102 DRIVER_HARDWARE_ADDRESS PermanentAddress;
103
104 /* Ethernet address currently in use */
105 DRIVER_HARDWARE_ADDRESS StationAddress;
106
107 /* Maximum number of multicast addresses this adapter supports */
108 ULONG MaxMulticastListSize;
109
110 /* List of multicast addresses in use */
111 DRIVER_HARDWARE_ADDRESS Addresses[DRIVER_MAX_MULTICAST_LIST_SIZE];
112
113 /* Current multicast address mask */
114 UCHAR MulticastAddressMask[8];
115
116 /* Masked interrupts (IMR value) */
117 ULONG InterruptMask;
118
119 /* Interrupts that have occurred */
120 UCHAR InterruptStatus;
121
122 /* Current packet filter */
123 ULONG PacketFilter;
124
125 /* Lookahead buffer */
126 UINT LookaheadSize;
127 UCHAR Lookahead[DRIVER_MAXIMUM_LOOKAHEAD + DRIVER_HEADER_SIZE];
128
129 /* Receive buffer ring */
130 UINT PageStart;
131 UINT PageStop;
132 UINT CurrentPage;
133 UINT NextPacket;
134
135 /* TRUE if there was a buffer overflow */
136 BOOLEAN BufferOverflow;
137
138 /* TRUE if an error occurred during reception of a packet */
139 BOOLEAN ReceiveError;
140
141 /* TRUE if an error occurred during transmission of a packet */
142 BOOLEAN TransmitError;
143
144 /* TRUE if a transmit interrupt is pending */
145 BOOLEAN TransmitPending;
146
147 /* Received packet header */
148 PACKET_HEADER PacketHeader;
149
150 /* Offset in onboard RAM of received packet */
151 ULONG PacketOffset;
152
153 /* TRUE if receive indications are done and should be completed */
154 BOOLEAN DoneIndicating;
155
156 /* Transmit buffers */
157 UINT TXStart; /* Start block of transmit buffer ring */
158 UINT TXCount; /* Number of blocks in transmit buffer ring */
159 UINT TXFree; /* Number of free transmit buffers */
160 UINT TXNext; /* Next buffer to use */
161 /* Length of packet. 0 means buffer is unused */
162 UINT TXSize[DRIVER_DEFAULT_TX_BUFFER_COUNT];
163 INT TXCurrent; /* Current buffer beeing transmitted. -1 means none */
164
165 /* Head of transmit queue */
166 PNDIS_PACKET TXQueueHead;
167 /* Tail of transmit queue */
168 PNDIS_PACKET TXQueueTail;
169
170 /* Statistics */
171 ULONG FrameAlignmentErrors;
172 ULONG CrcErrors;
173 ULONG MissedPackets;
174
175 /* Flags used for driver cleanup */
176 BOOLEAN IOPortRangeRegistered;
177 BOOLEAN InterruptRegistered;
178 BOOLEAN ShutdownHandlerRegistered;
179 } NIC_ADAPTER, *PNIC_ADAPTER;
180
181 /* Global driver information */
182 typedef struct _DRIVER_INFORMATION
183 {
184 NDIS_HANDLE NdisWrapperHandle; /* Returned from NdisInitializeWrapper */
185 NDIS_HANDLE NdisMacHandle; /* Returned from NdisRegisterMac */
186 LIST_ENTRY AdapterListHead; /* Adapters this driver control */
187 } DRIVER_INFORMATION, *PDRIVER_INFORMATION;
188
189
190
191 /* Global variable */
192
193 extern DRIVER_INFORMATION DriverInfo;
194 extern NDIS_PHYSICAL_ADDRESS HighestAcceptableMax;
195
196
197
198 /* Prototypes */
199
200 BOOLEAN NICCheck(
201 PNIC_ADAPTER Adapter);
202
203 NDIS_STATUS NICInitialize(
204 PNIC_ADAPTER Adapter);
205
206 NDIS_STATUS NICSetup(
207 PNIC_ADAPTER Adapter);
208
209 NDIS_STATUS NICStart(
210 PNIC_ADAPTER Adapter);
211
212 NDIS_STATUS NICStop(
213 PNIC_ADAPTER Adapter);
214
215 NDIS_STATUS NICReset(
216 PNIC_ADAPTER Adapter);
217
218 VOID NICUpdateCounters(
219 PNIC_ADAPTER Adapter);
220
221 VOID NICReadDataAlign(
222 PNIC_ADAPTER Adapter,
223 PUSHORT Target,
224 ULONG Source,
225 USHORT Length);
226
227 VOID NICWriteDataAlign(
228 PNIC_ADAPTER Adapter,
229 ULONG Target,
230 PUSHORT Source,
231 USHORT Length);
232
233 VOID NICReadData(
234 PNIC_ADAPTER Adapter,
235 PUCHAR Target,
236 ULONG Source,
237 USHORT Length);
238
239 VOID NICWriteData(
240 PNIC_ADAPTER Adapter,
241 ULONG Target,
242 PUCHAR Source,
243 USHORT Length);
244
245 VOID NICTransmit(
246 PNIC_ADAPTER Adapter);
247
248 #endif /* __NE2000_H */
249
250 /* EOF */