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
;
63 NDIS_MINIPORT_TIMER MediaDetectionTimer
;
64 ULONG CurrentReceiveDescriptorIndex
;
65 ULONG CurrentPacketFilter
;
66 ULONG CurrentLookaheadSize
;
68 /* circular indexes to transmit descriptors */
69 ULONG CurrentTransmitStartIndex
;
70 ULONG CurrentTransmitEndIndex
;
72 /* initialization block */
73 ULONG InitializationBlockLength
;
74 PINITIALIZATION_BLOCK InitializationBlockVirt
;
75 PINITIALIZATION_BLOCK InitializationBlockPhys
;
77 /* transmit descriptor ring */
78 ULONG TransmitDescriptorRingLength
;
79 PTRANSMIT_DESCRIPTOR TransmitDescriptorRingVirt
;
80 PTRANSMIT_DESCRIPTOR TransmitDescriptorRingPhys
;
82 /* transmit buffers */
83 ULONG TransmitBufferLength
;
84 PCHAR TransmitBufferPtrVirt
;
85 PCHAR TransmitBufferPtrPhys
;
87 /* receive descriptor ring */
88 ULONG ReceiveDescriptorRingLength
;
89 PRECEIVE_DESCRIPTOR ReceiveDescriptorRingVirt
;
90 PRECEIVE_DESCRIPTOR ReceiveDescriptorRingPhys
;
93 ULONG ReceiveBufferLength
;
94 PCHAR ReceiveBufferPtrVirt
;
95 PCHAR ReceiveBufferPtrPhys
;
97 ADAPTER_STATS Statistics
;
100 /* forward declarations */
103 MiniportQueryInformation(
104 IN NDIS_HANDLE MiniportAdapterContext
,
106 IN PVOID InformationBuffer
,
107 IN ULONG InformationBufferLength
,
108 OUT PULONG BytesWritten
,
109 OUT PULONG BytesNeeded
);
113 MiniportSetInformation(
114 IN NDIS_HANDLE MiniportAdapterContext
,
116 IN PVOID InformationBuffer
,
117 IN ULONG InformationBufferLength
,
118 OUT PULONG BytesRead
,
119 OUT PULONG BytesNeeded
);
130 MiGetMediaState(PADAPTER Adapter
);
132 /* operational constants */
133 #define NUMBER_OF_BUFFERS 0x20
134 #define LOG_NUMBER_OF_BUFFERS 5 /* log2(NUMBER_OF_BUFFERS) */
135 #define BUFFER_SIZE 0x600
136 #define MAX_MULTICAST_ADDRESSES 32
137 #define MEDIA_DETECTION_INTERVAL 5000
140 #define RESET_IN_PROGRESS 0x1
144 #define PCNET_DbgPrint(_x) \
146 DbgPrint("%s:%d %s: ", __FILE__, __LINE__, __FUNCTION__); \
150 #define PCNET_DbgPrint(_x)
154 #define BREAKPOINT __asm__ ("int $3\n");
159 /* memory pool tag */
160 #define PCNET_TAG 0xbaadf00d