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
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 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
31 /* statistics struct */
32 typedef struct _ADAPTER_STATS
36 ULONG XmtLossesOfCarrier
;
38 ULONG XmtLateCollisions
;
39 ULONG XmtExcessiveDefferals
;
40 ULONG XmtBufferUnderflows
;
41 ULONG XmtBufferErrors
;
43 ULONG XmtMoreThanOneRetry
;
45 ULONG RcvBufferErrors
;
47 ULONG RcvOverflowErrors
;
48 ULONG RcvFramingErrors
;
49 } ADAPTER_STATS
, *PADAPTER_STATS
;
52 typedef struct _ADAPTER
56 NDIS_HANDLE MiniportAdapterHandle
;
58 ULONG InterruptVector
;
61 NDIS_MINIPORT_INTERRUPT InterruptObject
;
62 NDIS_MEDIA_STATE MediaState
;
65 NDIS_MINIPORT_TIMER MediaDetectionTimer
;
66 ULONG CurrentReceiveDescriptorIndex
;
67 ULONG CurrentPacketFilter
;
68 ULONG CurrentLookaheadSize
;
70 /* circular indexes to transmit descriptors */
71 ULONG CurrentTransmitStartIndex
;
72 ULONG CurrentTransmitEndIndex
;
74 /* initialization block */
75 ULONG InitializationBlockLength
;
76 PINITIALIZATION_BLOCK InitializationBlockVirt
;
77 PINITIALIZATION_BLOCK InitializationBlockPhys
;
79 /* transmit descriptor ring */
80 ULONG TransmitDescriptorRingLength
;
81 PTRANSMIT_DESCRIPTOR TransmitDescriptorRingVirt
;
82 PTRANSMIT_DESCRIPTOR TransmitDescriptorRingPhys
;
84 /* transmit buffers */
85 ULONG TransmitBufferLength
;
86 PCHAR TransmitBufferPtrVirt
;
87 PCHAR TransmitBufferPtrPhys
;
89 /* receive descriptor ring */
90 ULONG ReceiveDescriptorRingLength
;
91 PRECEIVE_DESCRIPTOR ReceiveDescriptorRingVirt
;
92 PRECEIVE_DESCRIPTOR ReceiveDescriptorRingPhys
;
95 ULONG ReceiveBufferLength
;
96 PCHAR ReceiveBufferPtrVirt
;
97 PCHAR ReceiveBufferPtrPhys
;
99 ADAPTER_STATS Statistics
;
100 } ADAPTER
, *PADAPTER
;
102 /* forward declarations */
105 MiniportQueryInformation(
106 IN NDIS_HANDLE MiniportAdapterContext
,
108 IN PVOID InformationBuffer
,
109 IN ULONG InformationBufferLength
,
110 OUT PULONG BytesWritten
,
111 OUT PULONG BytesNeeded
);
115 MiniportSetInformation(
116 IN NDIS_HANDLE MiniportAdapterContext
,
118 IN PVOID InformationBuffer
,
119 IN ULONG InformationBufferLength
,
120 OUT PULONG BytesRead
,
121 OUT PULONG BytesNeeded
);
132 MiGetMediaState(PADAPTER Adapter
);
136 MiGetMediaSpeed(PADAPTER Adapter
);
140 MiGetMediaDuplex(PADAPTER Adapter
);
142 /* operational constants */
143 #define NUMBER_OF_BUFFERS 0x20
144 #define LOG_NUMBER_OF_BUFFERS 5 /* log2(NUMBER_OF_BUFFERS) */
145 #define BUFFER_SIZE 0x600
146 #define MAX_MULTICAST_ADDRESSES 32
147 #define MEDIA_DETECTION_INTERVAL 5000
150 #define RESET_IN_PROGRESS 0x1
152 /* Maximum number of interrupts handled per call to MiniportHandleInterrupt */
153 #define INTERRUPT_LIMIT 10
156 #define BREAKPOINT DbgBreakPoint();
161 /* memory pool tag */
162 #define PCNET_TAG 'tNcP'