1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
|
/*++
Copyright (c) 1992 Microsoft Corporation
Module Name:
ltreg.c
Abstract:
This module contains helper routines for reading configuration
information from the registry.
Author:
Nikhil Kamkolkar (nikhilk@microsoft.com)
Stephen Hou (stephh@microsoft.com)
Revision History:
19 Jun 1992 Initial Version (dch@pacvax.pacersoft.com)
Notes: Tab stop: 4
--*/
#define LTREG_H_LOCALS
#include "ltmain.h"
#include "ltreg.h"
// Define file id for errorlogging
#define FILENUM LTREG
UINT
LtRegGetBusNumber(
IN NDIS_HANDLE ConfigHandle
)
/*++
Routine Description:
This routine determines the bus number the card is installed on
Arguments:
ConfigHandle : The handle to the configuration database
Return Value:
Returns the bus number the card is on. If we do not find the
relevant information in the database, then 0 is returned.
--*/
{
NDIS_STATUS Status;
PNDIS_CONFIGURATION_PARAMETER Parameter;
UINT BusNumber = 0;
NDIS_STRING Keyword = LT_REG_KEY_BUS_NUMBER_STRING;
NdisReadConfiguration(
&Status,
&Parameter,
ConfigHandle,
&Keyword,
NdisParameterInteger);
if (Status == NDIS_STATUS_SUCCESS)
{
BusNumber = (UINT)Parameter->ParameterData.IntegerData;
}
return(BusNumber);
}
NDIS_STATUS
LtRegGetBusType(
IN NDIS_HANDLE ConfigHandle,
OUT PNDIS_INTERFACE_TYPE BusType
)
/*++
Routine Description:
This routine determines the type of bus the card is installed on
Arguments:
ConfigHandle : The handle to the configuration database
BusType : On return, the bus type is stored here
Return Value:
NDIS_STATUS_SUCCESS : if successfully read from the config database
NDIS_STATUS_FAILURE : if unable to find the information in the config
database
--*/
{
NDIS_STATUS Status;
PNDIS_CONFIGURATION_PARAMETER Parameter;
NDIS_STRING Keyword = LT_REG_KEY_BUS_TYPE_STRING;
NdisReadConfiguration(
&Status,
&Parameter,
ConfigHandle,
&Keyword,
NdisParameterInteger);
if (Status == NDIS_STATUS_SUCCESS)
{
*BusType = (UINT)Parameter->ParameterData.IntegerData;
}
return(Status);
}
UCHAR
LtRegGetNodeId(
IN NDIS_HANDLE ConfigHandle
)
/*++
Routine Description:
This routine determines the last NodeId used by the card.
Arguments:
ConfigHandle : The handle to the configuration database
Return Value:
Returns the last valid NodeId used by the card. If we find that
the value stored in the configuration info is not valid, then the
suggested NodeId is returned.
--*/
{
NDIS_STATUS Status;
PNDIS_CONFIGURATION_PARAMETER Parameter;
NDIS_STRING Keyword = LT_REG_KEY_NODE_ID_STRING;
UCHAR NodeId = 0;
NdisReadConfiguration(
&Status,
&Parameter,
ConfigHandle,
&Keyword,
NdisParameterInteger);
if (Status == NDIS_STATUS_SUCCESS)
{
NodeId = (UCHAR)Parameter->ParameterData.IntegerData;
if ((NodeId < LT_NODE_ID_MIN) || (NodeId > LT_NODE_ID_MAX))
{
NodeId = 0;
}
}
return(NodeId);
}
NDIS_STATUS
LtRegGetIoBaseAddr(
OUT PUINT IoBaseAddress,
IN NDIS_HANDLE NdisConfigHandle,
IN NDIS_HANDLE ConfigHandle,
IN NDIS_INTERFACE_TYPE BusType
)
/*++
Routine Description:
This routine determines the port addresses used to communicate
with the card.
Arguments:
IoBaseAddress : On return, the I/O port address is stored here
ConfigHandle : The handle to the configuration database
SlotNumber : For MCA machines, the indicates the slot the card is in
BusType : The type of bus the card is located on
Return Value:
NDIS_STATUS_SUCCESS : if successful
NDIS_STATUS_ADAPTER_NOT_FOUND : if running on a MCA machine and
the adapter cannot be located
NDIS_STATUS_BAD_CHARACTERISTICS : if the I/O base is not within
the legal range
--*/
{
NDIS_MCA_POS_DATA McaData;
NDIS_STATUS Status;
PNDIS_CONFIGURATION_PARAMETER Parameter;
NDIS_STRING Keyword = LT_REG_KEY_IO_BASE_ADDRESS_STRING;
UINT SlotNumber = 0;
// If BusType is NdisInterfaceMca, then we read the MCA POS info to
// get our parameters. Otherwise, we just read the registry.
if (BusType == NdisInterfaceMca)
{
NdisReadMcaPosInformation(
&Status,
NdisConfigHandle,
&SlotNumber,
&McaData);
// *IoBaseAddress = (UINT)(McaData.PosData2 | (McaData.PosData3 << 8));
*IoBaseAddress = LT_DECODE_ADDR_FROM_POSDATA(McaData);
DBGPRINT(DBG_COMP_REGISTRY, DBG_LEVEL_FATAL,
("LtRegGetIoBaseAddr: Base %lx. %lx.%lx.%lx.%lx, Id - %lx\n",
*IoBaseAddress, McaData.PosData1, McaData.PosData2,
McaData.PosData3, McaData.PosData4, McaData.AdapterId));
if ((Status != NDIS_STATUS_SUCCESS) || (McaData.AdapterId != LT_MCA_POS_ID))
{
Status = NDIS_STATUS_ADAPTER_NOT_FOUND;
}
}
else
{
NdisReadConfiguration(
&Status,
&Parameter,
ConfigHandle,
&Keyword,
NdisParameterHexInteger);
if (Status == NDIS_STATUS_SUCCESS)
{
*IoBaseAddress = (UINT)Parameter->ParameterData.IntegerData;
}
}
if ((Status == NDIS_STATUS_SUCCESS) &&
((*IoBaseAddress < LT_IO_BASE_ADDRESS_MIN) ||
(*IoBaseAddress > LT_IO_BASE_ADDRESS_MAX)))
{
DBGPRINT(DBG_COMP_REGISTRY, DBG_LEVEL_FATAL,
("LtRegGetIoBaseAddr: invalid value found for %s\n", LT_REG_KEY_IO_BASE_ADDRESS));
Status = NDIS_STATUS_BAD_CHARACTERISTICS;
}
return(Status);
}
|