test: pnpdma.c File Reference

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

# pnpdma.c File Reference

`#include "iop.h"`

Go to the source code of this file.

## Defines

#define | MAX_ULONGLONG ((ULONGLONG) -1)

## Functions

NTSTATUS | IopDmaInitialize (VOID)
NTSTATUS | IopDmaUnpackRequirement (IN PIO_RESOURCE_DESCRIPTOR Descriptor, OUT PULONGLONG Minimum, OUT PULONGLONG Maximum, OUT PULONG Length, OUT PULONG Alignment)
NTSTATUS | IopDmaPackResource (IN PIO_RESOURCE_DESCRIPTOR Requirement, IN ULONGLONG Start, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor)
LONG | IopDmaScoreRequirement (IN PIO_RESOURCE_DESCRIPTOR Descriptor)
NTSTATUS | IopDmaUnpackResource (IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, OUT PULONGLONG Start, OUT PULONG Length)
BOOLEAN | IopDmaOverrideConflict (IN PARBITER_INSTANCE Arbiter, IN PARBITER_ALLOCATION_STATE State)

## Define Documentation

#define MAX_ULONGLONG ((ULONGLONG) -1)

| Definition at line 30 of file pnpdma.c.

## Function Documentation

NTSTATUS IopDmaInitialize | ( | VOID |  | ) |

Definition at line 95 of file pnpdma.c.

References ArbInitializeArbiterInstance(), IopDmaOverrideConflict(), IopDmaPackResource(), IopDmaScoreRequirement(), IopDmaUnpackRequirement(), IopDmaUnpackResource(), IopRootDmaArbiter, L, NULL, _ARBITER_INSTANCE::OverrideConflict, _ARBITER_INSTANCE::PackResource, _ARBITER_INSTANCE::ScoreRequirement, _ARBITER_INSTANCE::UnpackRequirement, and _ARBITER_INSTANCE::UnpackResource.

    00101                    :
    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 }

BOOLEAN IopDmaOverrideConflict | ( | IN PARBITER_INSTANCE | Arbiter,
|  | IN PARBITER_ALLOCATION_STATE | State
| ) |

Definition at line 324 of file pnpdma.c.

References FALSE, and PAGED_CODE.

Referenced by IopDmaInitialize().

    00331                    :
    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 }

NTSTATUS IopDmaPackResource | ( | IN PIO_RESOURCE_DESCRIPTOR | Requirement,
|  | IN ULONGLONG | Start,
|  | OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR | Descriptor
| ) |

Definition at line 233 of file pnpdma.c.

References ARB_PRINT, ASSERT, and Start.

Referenced by IopDmaInitialize().

    00241                    :
    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 }

LONG IopDmaScoreRequirement | ( | IN PIO_RESOURCE_DESCRIPTOR | Descriptor | ) |

Definition at line 192 of file pnpdma.c.

References ARB_PRINT, and ASSERT.

Referenced by IopDmaInitialize().

    00198                    :
    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 }

NTSTATUS IopDmaUnpackRequirement | ( | IN PIO_RESOURCE_DESCRIPTOR | Descriptor,
|  | OUT PULONGLONG | Minimum,
|  | OUT PULONGLONG | Maximum,
|  | OUT PULONG | Length,
|  | OUT PULONG | Alignment
| ) |

Definition at line 137 of file pnpdma.c.

References ARB_PRINT, and ASSERT.

Referenced by IopDmaInitialize().

    00147                    :
    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 }

NTSTATUS IopDmaUnpackResource | ( | IN PCM_PARTIAL_RESOURCE_DESCRIPTOR | Descriptor,
|  | OUT PULONGLONG | Start,
|  | OUT PULONG | Length
| ) |

Definition at line 281 of file pnpdma.c.

References ARB_PRINT, and Start.

Referenced by IopDmaInitialize().

    00289                    :
    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 }