2 * ReactOS AMD PCNet Driver
4 * Copyright (C) 2003 Vizzini <vizzini@plasmic.com>
5 * Copyright (C) 2004 Filip Navara <navaraf@reactos.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 * 01-Sep-2003 vizzini - Created
24 * - this assumes a 32-bit machine, where sizeof(PVOID) = 32 and sizeof(USHORT) = 16
25 * - this assumes 32-bit physical addresses
30 /* statistics struct */
31 typedef struct _ADAPTER_STATS
35 ULONG XmtLossesOfCarrier
;
37 ULONG XmtLateCollisions
;
38 ULONG XmtExcessiveDefferals
;
39 ULONG XmtBufferUnderflows
;
40 ULONG XmtBufferErrors
;
42 ULONG XmtMoreThanOneRetry
;
44 ULONG RcvBufferErrors
;
46 ULONG RcvOverflowErrors
;
47 ULONG RcvFramingErrors
;
48 } ADAPTER_STATS
, *PADAPTER_STATS
;
51 typedef struct _ADAPTER
55 NDIS_HANDLE MiniportAdapterHandle
;
57 ULONG InterruptVector
;
60 NDIS_MINIPORT_INTERRUPT InterruptObject
;
61 NDIS_MEDIA_STATE MediaState
;
64 NDIS_MINIPORT_TIMER MediaDetectionTimer
;
65 ULONG CurrentReceiveDescriptorIndex
;
66 ULONG CurrentPacketFilter
;
67 ULONG CurrentLookaheadSize
;
69 /* circular indexes to transmit descriptors */
70 ULONG CurrentTransmitStartIndex
;
71 ULONG CurrentTransmitEndIndex
;
73 /* initialization block */
74 ULONG InitializationBlockLength
;
75 PINITIALIZATION_BLOCK InitializationBlockVirt
;
76 PINITIALIZATION_BLOCK InitializationBlockPhys
;
78 /* transmit descriptor ring */
79 ULONG TransmitDescriptorRingLength
;
80 PTRANSMIT_DESCRIPTOR TransmitDescriptorRingVirt
;
81 PTRANSMIT_DESCRIPTOR TransmitDescriptorRingPhys
;
83 /* transmit buffers */
84 ULONG TransmitBufferLength
;
85 PCHAR TransmitBufferPtrVirt
;
86 PCHAR TransmitBufferPtrPhys
;
88 /* receive descriptor ring */
89 ULONG ReceiveDescriptorRingLength
;
90 PRECEIVE_DESCRIPTOR ReceiveDescriptorRingVirt
;
91 PRECEIVE_DESCRIPTOR ReceiveDescriptorRingPhys
;
94 ULONG ReceiveBufferLength
;
95 PCHAR ReceiveBufferPtrVirt
;
96 PCHAR ReceiveBufferPtrPhys
;
98 ADAPTER_STATS Statistics
;
101 /* forward declarations */
104 MiniportQueryInformation(
105 IN NDIS_HANDLE MiniportAdapterContext
,
107 IN PVOID InformationBuffer
,
108 IN ULONG InformationBufferLength
,
109 OUT PULONG BytesWritten
,
110 OUT PULONG BytesNeeded
);
114 MiniportSetInformation(
115 IN NDIS_HANDLE MiniportAdapterContext
,
117 IN PVOID InformationBuffer
,
118 IN ULONG InformationBufferLength
,
119 OUT PULONG BytesRead
,
120 OUT PULONG BytesNeeded
);
131 MiGetMediaState(PADAPTER Adapter
);
135 MiGetMediaSpeed(PADAPTER Adapter
);
139 MiGetMediaDuplex(PADAPTER Adapter
);
141 /* operational constants */
142 #define NUMBER_OF_BUFFERS 0x20
143 #define LOG_NUMBER_OF_BUFFERS 5 /* log2(NUMBER_OF_BUFFERS) */
144 #define BUFFER_SIZE 0x600
145 #define MAX_MULTICAST_ADDRESSES 32
146 #define MEDIA_DETECTION_INTERVAL 5000
149 #define RESET_IN_PROGRESS 0x1
151 /* Maximum number of interrupts handled per call to MiniportHandleInterrupt */
152 #define INTERRUPT_LIMIT 10
155 #define BREAKPOINT DbgBreakPoint();
160 /* memory pool tag */
161 #define PCNET_TAG 'tNcP'