[HAL]
[reactos.git] / reactos / drivers / network / dd / pcnet / pcnet.h
1 /*
2 * ReactOS AMD PCNet Driver
3 *
4 * Copyright (C) 2003 Vizzini <vizzini@plasmic.com>
5 * Copyright (C) 2004 Filip Navara <navaraf@reactos.com>
6 *
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.
11 *
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.
16 *
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.
20 *
21 * REVISIONS:
22 * 01-Sep-2003 vizzini - Created
23 * NOTES:
24 * - this assumes a 32-bit machine, where sizeof(PVOID) = 32 and sizeof(USHORT) = 16
25 * - this assumes 32-bit physical addresses
26 */
27
28 #pragma once
29
30 /* statistics struct */
31 typedef struct _ADAPTER_STATS
32 {
33 ULONG XmtGoodFrames;
34 ULONG XmtRetryErrors;
35 ULONG XmtLossesOfCarrier;
36 ULONG XmtCollisions;
37 ULONG XmtLateCollisions;
38 ULONG XmtExcessiveDefferals;
39 ULONG XmtBufferUnderflows;
40 ULONG XmtBufferErrors;
41 ULONG XmtOneRetry;
42 ULONG XmtMoreThanOneRetry;
43 ULONG RcvGoodFrames;
44 ULONG RcvBufferErrors;
45 ULONG RcvCrcErrors;
46 ULONG RcvOverflowErrors;
47 ULONG RcvFramingErrors;
48 } ADAPTER_STATS, *PADAPTER_STATS;
49
50 /* adapter struct */
51 typedef struct _ADAPTER
52 {
53 NDIS_SPIN_LOCK Lock;
54
55 NDIS_HANDLE MiniportAdapterHandle;
56 ULONG Flags;
57 ULONG InterruptVector;
58 ULONG IoBaseAddress;
59 ULONG_PTR PortOffset;
60 NDIS_MINIPORT_INTERRUPT InterruptObject;
61 NDIS_MEDIA_STATE MediaState;
62 UINT MediaSpeed;
63 BOOLEAN FullDuplex;
64 NDIS_MINIPORT_TIMER MediaDetectionTimer;
65 ULONG CurrentReceiveDescriptorIndex;
66 ULONG CurrentPacketFilter;
67 ULONG CurrentLookaheadSize;
68
69 /* circular indexes to transmit descriptors */
70 ULONG CurrentTransmitStartIndex;
71 ULONG CurrentTransmitEndIndex;
72
73 /* initialization block */
74 ULONG InitializationBlockLength;
75 PINITIALIZATION_BLOCK InitializationBlockVirt;
76 PINITIALIZATION_BLOCK InitializationBlockPhys;
77
78 /* transmit descriptor ring */
79 ULONG TransmitDescriptorRingLength;
80 PTRANSMIT_DESCRIPTOR TransmitDescriptorRingVirt;
81 PTRANSMIT_DESCRIPTOR TransmitDescriptorRingPhys;
82
83 /* transmit buffers */
84 ULONG TransmitBufferLength;
85 PCHAR TransmitBufferPtrVirt;
86 PCHAR TransmitBufferPtrPhys;
87
88 /* receive descriptor ring */
89 ULONG ReceiveDescriptorRingLength;
90 PRECEIVE_DESCRIPTOR ReceiveDescriptorRingVirt;
91 PRECEIVE_DESCRIPTOR ReceiveDescriptorRingPhys;
92
93 /* receive buffers */
94 ULONG ReceiveBufferLength;
95 PCHAR ReceiveBufferPtrVirt;
96 PCHAR ReceiveBufferPtrPhys;
97
98 ADAPTER_STATS Statistics;
99 } ADAPTER, *PADAPTER;
100
101 /* forward declarations */
102 NDIS_STATUS
103 NTAPI
104 MiniportQueryInformation(
105 IN NDIS_HANDLE MiniportAdapterContext,
106 IN NDIS_OID Oid,
107 IN PVOID InformationBuffer,
108 IN ULONG InformationBufferLength,
109 OUT PULONG BytesWritten,
110 OUT PULONG BytesNeeded);
111
112 NDIS_STATUS
113 NTAPI
114 MiniportSetInformation(
115 IN NDIS_HANDLE MiniportAdapterContext,
116 IN NDIS_OID Oid,
117 IN PVOID InformationBuffer,
118 IN ULONG InformationBufferLength,
119 OUT PULONG BytesRead,
120 OUT PULONG BytesNeeded);
121
122 NDIS_STATUS
123 NTAPI
124 MiSetMulticast(
125 PADAPTER Adapter,
126 UCHAR *Addresses,
127 UINT AddressCount);
128
129 NDIS_MEDIA_STATE
130 NTAPI
131 MiGetMediaState(PADAPTER Adapter);
132
133 UINT
134 NTAPI
135 MiGetMediaSpeed(PADAPTER Adapter);
136
137 BOOLEAN
138 NTAPI
139 MiGetMediaDuplex(PADAPTER Adapter);
140
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
147
148 /* flags */
149 #define RESET_IN_PROGRESS 0x1
150
151 /* Maximum number of interrupts handled per call to MiniportHandleInterrupt */
152 #define INTERRUPT_LIMIT 10
153
154 #if DBG
155 #define BREAKPOINT DbgBreakPoint();
156 #else
157 #define BREAKPOINT
158 #endif
159
160 /* memory pool tag */
161 #define PCNET_TAG 'tNcP'