00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
#include "iop.h"
00023
#pragma hdrstop
00024
00025
00026
00027
00028
00029
00030 #define MAX_ULONGLONG ((ULONGLONG) -1)
00031
00032
00033
00034
00035
00036
NTSTATUS
00037
IopBusNumberInitialize(
00038 VOID
00039 );
00040
00041
NTSTATUS
00042
IopBusNumberUnpackRequirement(
00043 IN PIO_RESOURCE_DESCRIPTOR Descriptor,
00044 OUT PULONGLONG Minimum,
00045 OUT PULONGLONG Maximum,
00046 OUT PULONG Length,
00047 OUT PULONG Alignment
00048 );
00049
00050
NTSTATUS
00051
IopBusNumberPackResource(
00052 IN PIO_RESOURCE_DESCRIPTOR Requirement,
00053 IN ULONGLONG Start,
00054 OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor
00055 );
00056
00057 LONG
00058
IopBusNumberScoreRequirement(
00059 IN PIO_RESOURCE_DESCRIPTOR Descriptor
00060 );
00061
00062
NTSTATUS
00063
IopBusNumberUnpackResource(
00064 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor,
00065 OUT PULONGLONG Start,
00066 OUT PULONG Length
00067 );
00068
00069
00070
00071
00072
00073
00074
#ifdef ALLOC_PRAGMA
00075
00076
#pragma alloc_text(PAGE, IopBusNumberInitialize)
00077
#pragma alloc_text(PAGE, IopBusNumberUnpackRequirement)
00078
#pragma alloc_text(PAGE, IopBusNumberPackResource)
00079
#pragma alloc_text(PAGE, IopBusNumberScoreRequirement)
00080
#pragma alloc_text(PAGE, IopBusNumberUnpackResource)
00081
00082
#endif // ALLOC_PRAGMA
00083
00084
00085
00086
00087
00088
NTSTATUS
00089 IopBusNumberInitialize(
00090 VOID
00091 )
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109 {
00110
NTSTATUS status;
00111
00112
IopRootBusNumberArbiter.
UnpackRequirement =
IopBusNumberUnpackRequirement;
00113
IopRootBusNumberArbiter.
PackResource =
IopBusNumberPackResource;
00114
IopRootBusNumberArbiter.
UnpackResource =
IopBusNumberUnpackResource;
00115
IopRootBusNumberArbiter.
ScoreRequirement =
IopBusNumberScoreRequirement;
00116
00117 status =
ArbInitializeArbiterInstance(&
IopRootBusNumberArbiter,
00118
NULL,
00119 CmResourceTypeBusNumber,
00120
L"RootBusNumber",
00121
L"Root",
00122
NULL
00123 );
00124
if (
NT_SUCCESS(status)) {
00125
00126
00127
00128
00129
RtlAddRange(
IopRootBusNumberArbiter.
Allocation,
00130 (ULONGLONG) 0x100,
00131 (ULONGLONG) -1,
00132 0,
00133 0,
00134
NULL,
00135
NULL
00136 );
00137
00138 }
00139
00140
return status;
00141 }
00142
00143
00144
00145
00146
00147
NTSTATUS
00148 IopBusNumberUnpackRequirement(
00149 IN PIO_RESOURCE_DESCRIPTOR Descriptor,
00150 OUT PULONGLONG Minimum,
00151 OUT PULONGLONG Maximum,
00152 OUT PULONG Length,
00153 OUT PULONG Alignment
00154 )
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182 {
00183
ASSERT(Descriptor);
00184
ASSERT(Descriptor->Type == CmResourceTypeBusNumber);
00185
00186
ARB_PRINT(2,
00187 (
"Unpacking BusNumber requirement %p => 0x%I64x-0x%I64x\n",
00188 Descriptor,
00189 (ULONGLONG) Descriptor->u.BusNumber.MinBusNumber,
00190 (ULONGLONG) Descriptor->u.BusNumber.MaxBusNumber
00191 ));
00192
00193 *Minimum = (ULONGLONG) Descriptor->u.BusNumber.MinBusNumber;
00194 *Maximum = (ULONGLONG) Descriptor->u.BusNumber.MaxBusNumber;
00195 *Length = Descriptor->u.BusNumber.Length;
00196 *Alignment = 1;
00197
00198
return STATUS_SUCCESS;
00199
00200 }
00201
00202 LONG
00203 IopBusNumberScoreRequirement(
00204 IN PIO_RESOURCE_DESCRIPTOR Descriptor
00205 )
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226 {
00227 LONG score;
00228
00229
ASSERT(Descriptor);
00230
ASSERT(Descriptor->Type == CmResourceTypeBusNumber);
00231
00232 score = (Descriptor->u.BusNumber.MaxBusNumber -
00233 Descriptor->u.BusNumber.MinBusNumber) /
00234 Descriptor->u.BusNumber.Length;
00235
00236
ARB_PRINT(2,
00237 (
"Scoring BusNumber resource %p => %i\n",
00238 Descriptor,
00239 score
00240 ));
00241
00242
return score;
00243 }
00244
00245
NTSTATUS
00246 IopBusNumberPackResource(
00247 IN PIO_RESOURCE_DESCRIPTOR Requirement,
00248 IN ULONGLONG Start,
00249 OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor
00250 )
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272 {
00273
ASSERT(Descriptor);
00274
ASSERT(
Start < ((ULONG)-1));
00275
ASSERT(Requirement);
00276
ASSERT(Requirement->Type == CmResourceTypeBusNumber);
00277
00278
ARB_PRINT(2,
00279 (
"Packing BusNumber resource %p => 0x%I64x\n",
00280 Descriptor,
00281
Start
00282 ));
00283
00284 Descriptor->Type = CmResourceTypeBusNumber;
00285 Descriptor->ShareDisposition = Requirement->ShareDisposition;
00286 Descriptor->Flags = Requirement->Flags;
00287 Descriptor->u.BusNumber.Start = (ULONG)
Start;
00288 Descriptor->u.BusNumber.Length = Requirement->u.BusNumber.Length;
00289
00290
return STATUS_SUCCESS;
00291 }
00292
00293
NTSTATUS
00294 IopBusNumberUnpackResource(
00295 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor,
00296 OUT PULONGLONG Start,
00297 OUT PULONG Length
00298 )
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320 {
00321
ASSERT(Descriptor);
00322
ASSERT(
Start);
00323
ASSERT(Length);
00324
ASSERT(Descriptor->Type == CmResourceTypeBusNumber);
00325
00326 *
Start = (ULONGLONG) Descriptor->u.BusNumber.Start;
00327 *Length = Descriptor->u.BusNumber.Length;
00328
00329
ARB_PRINT(2,
00330 (
"Unpacking BusNumber resource %p => 0x%I64x\n",
00331 Descriptor,
00332 *
Start
00333 ));
00334
00335
return STATUS_SUCCESS;
00336
00337 }
00338