Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

pnpdma.c

Go to the documentation of this file.
00001 00002 /*++ 00003 00004 Copyright (c) 1997 Microsoft Corporation 00005 00006 Module Name: 00007 00008 pnpirq.c 00009 00010 Abstract: 00011 00012 Root DMA arbiter 00013 00014 Author: 00015 00016 Andy Thornton (andrewth) 04/17/97 00017 00018 Revision History: 00019 00020 --*/ 00021 00022 #include "iop.h" 00023 #pragma hdrstop 00024 00025 // 00026 // Constants 00027 // 00028 00029 00030 #define MAX_ULONGLONG ((ULONGLONG) -1) 00031 00032 // 00033 // Prototypes 00034 // 00035 00036 NTSTATUS 00037 IopDmaInitialize( 00038 VOID 00039 ); 00040 00041 NTSTATUS 00042 IopDmaUnpackRequirement( 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 IopDmaPackResource( 00052 IN PIO_RESOURCE_DESCRIPTOR Requirement, 00053 IN ULONGLONG Start, 00054 OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor 00055 ); 00056 00057 LONG 00058 IopDmaScoreRequirement( 00059 IN PIO_RESOURCE_DESCRIPTOR Descriptor 00060 ); 00061 00062 NTSTATUS 00063 IopDmaUnpackResource( 00064 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, 00065 OUT PULONGLONG Start, 00066 OUT PULONG Length 00067 ); 00068 00069 00070 BOOLEAN 00071 IopDmaOverrideConflict( 00072 IN PARBITER_INSTANCE Arbiter, 00073 IN PARBITER_ALLOCATION_STATE State 00074 ); 00075 00076 // 00077 // Make everything pageable 00078 // 00079 00080 #ifdef ALLOC_PRAGMA 00081 00082 #pragma alloc_text(PAGE, IopDmaInitialize) 00083 #pragma alloc_text(PAGE, IopDmaUnpackRequirement) 00084 #pragma alloc_text(PAGE, IopDmaPackResource) 00085 #pragma alloc_text(PAGE, IopDmaScoreRequirement) 00086 #pragma alloc_text(PAGE, IopDmaUnpackResource) 00087 #pragma alloc_text(PAGE, IopDmaOverrideConflict) 00088 #endif // ALLOC_PRAGMA 00089 00090 // 00091 // Implementation 00092 // 00093 00094 NTSTATUS 00095 IopDmaInitialize( 00096 VOID 00097 ) 00098 00099 /*++ 00100 00101 Routine Description: 00102 00103 This routine initializes the arbiter 00104 00105 Parameters: 00106 00107 None 00108 00109 Return Value: 00110 00111 None 00112 00113 --*/ 00114 00115 { 00116 00117 IopRootDmaArbiter.UnpackRequirement = IopDmaUnpackRequirement; 00118 IopRootDmaArbiter.PackResource = IopDmaPackResource; 00119 IopRootDmaArbiter.UnpackResource = IopDmaUnpackResource; 00120 IopRootDmaArbiter.ScoreRequirement = IopDmaScoreRequirement; 00121 IopRootDmaArbiter.OverrideConflict = IopDmaOverrideConflict; 00122 00123 return ArbInitializeArbiterInstance(&IopRootDmaArbiter, 00124 NULL, 00125 CmResourceTypeDma, 00126 L"RootDMA", 00127 L"Root", 00128 NULL // no translation of DMA 00129 ); 00130 } 00131 00132 // 00133 // Arbiter callbacks 00134 // 00135 00136 NTSTATUS 00137 IopDmaUnpackRequirement( 00138 IN PIO_RESOURCE_DESCRIPTOR Descriptor, 00139 OUT PULONGLONG Minimum, 00140 OUT PULONGLONG Maximum, 00141 OUT PULONG Length, 00142 OUT PULONG Alignment 00143 ) 00144 00145 /*++ 00146 00147 Routine Description: 00148 00149 This routine unpacks an resource requirement descriptor. 00150 00151 Arguments: 00152 00153 Descriptor - The descriptor describing the requirement to unpack. 00154 00155 Minimum - Pointer to where the minimum acceptable start value should be 00156 unpacked to. 00157 00158 Maximum - Pointer to where the maximum acceptable end value should be 00159 unpacked to. 00160 00161 Length - Pointer to where the required length should be unpacked to. 00162 00163 Minimum - Pointer to where the required alignment should be unpacked to. 00164 00165 Return Value: 00166 00167 Returns the status of this operation. 00168 00169 --*/ 00170 00171 { 00172 ASSERT(Descriptor); 00173 ASSERT(Descriptor->Type == CmResourceTypeDma); 00174 00175 ARB_PRINT(2, 00176 ("Unpacking DMA requirement %p => 0x%I64x-0x%I64x\n", 00177 Descriptor, 00178 (ULONGLONG) Descriptor->u.Dma.MinimumChannel, 00179 (ULONGLONG) Descriptor->u.Dma.MaximumChannel 00180 )); 00181 00182 *Minimum = (ULONGLONG) Descriptor->u.Dma.MinimumChannel; 00183 *Maximum = (ULONGLONG) Descriptor->u.Dma.MaximumChannel; 00184 *Length = 1; 00185 *Alignment = 1; 00186 00187 return STATUS_SUCCESS; 00188 00189 } 00190 00191 LONG 00192 IopDmaScoreRequirement( 00193 IN PIO_RESOURCE_DESCRIPTOR Descriptor 00194 ) 00195 00196 /*++ 00197 00198 Routine Description: 00199 00200 This routine scores a requirement based on how flexible it is. The least 00201 flexible devices are scored the least and so when the arbitration list is 00202 sorted we try to allocate their resources first. 00203 00204 Arguments: 00205 00206 Descriptor - The descriptor describing the requirement to score. 00207 00208 00209 Return Value: 00210 00211 The score. 00212 00213 --*/ 00214 00215 { 00216 LONG score; 00217 00218 ASSERT(Descriptor); 00219 ASSERT(Descriptor->Type == CmResourceTypeDma); 00220 00221 score = Descriptor->u.Dma.MaximumChannel - Descriptor->u.Dma.MinimumChannel; 00222 00223 ARB_PRINT(2, 00224 ("Scoring DMA resource %p => %i\n", 00225 Descriptor, 00226 score 00227 )); 00228 00229 return score; 00230 } 00231 00232 NTSTATUS 00233 IopDmaPackResource( 00234 IN PIO_RESOURCE_DESCRIPTOR Requirement, 00235 IN ULONGLONG Start, 00236 OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor 00237 ) 00238 00239 /*++ 00240 00241 Routine Description: 00242 00243 This routine packs an resource descriptor. 00244 00245 Arguments: 00246 00247 Requirement - The requirement from which this resource was chosen. 00248 00249 Start - The start value of the resource. 00250 00251 Descriptor - Pointer to the descriptor to pack into. 00252 00253 Return Value: 00254 00255 Returns the status of this operation. 00256 00257 --*/ 00258 00259 { 00260 ASSERT(Descriptor); 00261 ASSERT(Start < ((ULONG)-1)); 00262 ASSERT(Requirement); 00263 ASSERT(Requirement->Type == CmResourceTypeDma); 00264 00265 ARB_PRINT(2, 00266 ("Packing DMA resource %p => 0x%I64x\n", 00267 Descriptor, 00268 Start 00269 )); 00270 00271 Descriptor->Type = CmResourceTypeDma; 00272 Descriptor->ShareDisposition = Requirement->ShareDisposition; 00273 Descriptor->Flags = Requirement->Flags; // BUGBUG - is this correct? 00274 Descriptor->u.Dma.Channel = (ULONG) Start; 00275 Descriptor->u.Dma.Port = 0; 00276 00277 return STATUS_SUCCESS; 00278 } 00279 00280 NTSTATUS 00281 IopDmaUnpackResource( 00282 IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, 00283 OUT PULONGLONG Start, 00284 OUT PULONG Length 00285 ) 00286 00287 /*++ 00288 00289 Routine Description: 00290 00291 This routine unpacks an resource descriptor. 00292 00293 Arguments: 00294 00295 Descriptor - The descriptor describing the resource to unpack. 00296 00297 Start - Pointer to where the start value should be unpacked to. 00298 00299 Length - Pointer to where the length value should be unpacked to. 00300 00301 Return Value: 00302 00303 Returns the status of this operation. 00304 00305 --*/ 00306 00307 { 00308 00309 *Start = Descriptor->u.Dma.Channel; 00310 *Length = 1; 00311 00312 ARB_PRINT(2, 00313 ("Unpacking DMA resource %p => 0x%I64x\n", 00314 Descriptor, 00315 *Start 00316 )); 00317 00318 return STATUS_SUCCESS; 00319 00320 } 00321 00322 00323 BOOLEAN 00324 IopDmaOverrideConflict( 00325 IN PARBITER_INSTANCE Arbiter, 00326 IN PARBITER_ALLOCATION_STATE State 00327 ) 00328 00329 /*++ 00330 00331 Routine Description: 00332 00333 Just say no. 00334 00335 Arguments: 00336 00337 Arbiter - The instance data of the arbiter who was called. 00338 00339 State - The state of the current arbitration. 00340 00341 Return Value: 00342 00343 TRUE if the conflict is allowable, false otherwise 00344 00345 --*/ 00346 00347 { 00348 PAGED_CODE(); 00349 00350 return FALSE; 00351 } 00352

Generated on Sat May 15 19:41:16 2004 for test by doxygen 1.3.7