test: translate.c File Reference

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

# translate.c File Reference

`#include "ntos.h"`
`#include "haldisp.h"`
`#include <wdmguid.h>`

Go to the source code of this file.

## Defines

#define | FOR_ALL_IN_LIST(Type, Head, Current)
#define | FOR_ALL_IN_ARRAY(_Array, _Size, _Current)
#define | FOR_REST_IN_ARRAY(_Array, _Size, _Current)
#define | HAL_IRQ_TRANSLATOR_VERSION 0

## Functions

NTSTATUS | FstubTranslateResource (IN PVOID Context, IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source, IN RESOURCE_TRANSLATION_DIRECTION Direction, IN ULONG AlternativesCount OPTIONAL, IN IO_RESOURCE_DESCRIPTOR Alternatives[] OPTIONAL, IN PDEVICE_OBJECT PhysicalDeviceObject, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target)
NTSTATUS | FstubTranslateRequirement (IN PVOID Context, IN PIO_RESOURCE_DESCRIPTOR Source, IN PDEVICE_OBJECT PhysicalDeviceObject, OUT PULONG TargetCount, OUT PIO_RESOURCE_DESCRIPTOR *Target)
VOID | FstubTranslatorNull (IN PVOID Context)
NTSTATUS | xHalGetInterruptTranslator (IN INTERFACE_TYPE ParentInterfaceType, IN ULONG ParentBusNumber, IN INTERFACE_TYPE BridgeInterfaceType, IN USHORT Size, IN USHORT Version, OUT PTRANSLATOR_INTERFACE Translator, OUT PULONG BridgeBusNumber)

## Variables

PDEVICE_OBJECT | McaPhysicalBusDevice

## Define Documentation

#define FOR_ALL_IN_ARRAY | ( | _Array,
|  | _Size,
|  | _Current |  | ) |

Value:

    for ( (_Current) = (_Array);                                        \
              (_Current) < (_Array) + (_Size);                              \
              (_Current)++ )

Definition at line 56 of file translate.c.

Referenced by ArbBuildAssignmentOrdering(), ArbDumpArbitrationList(), ArbGetNextAllocationRange(), ArbpBuildAllocationStack(), ArbPruneOrdering(), ArbTestAllocation(), and FstubTranslateResource().

#define FOR_ALL_IN_LIST | ( | Type,
|  | Head,
|  | Current |  | ) |

Value:

    for((Current) = CONTAINING_RECORD((Head)->Flink, Type, ListEntry);  \
           (Head) != &(Current)->ListEntry;                                 \
           (Current) = CONTAINING_RECORD((Current)->ListEntry.Flink,        \
                                         Type,                              \
                                         ListEntry)                         \
           )

Definition at line 46 of file translate.c.

Referenced by ArbBootAllocation(), ArbDumpArbitrationList(), ArbpBuildAllocationStack(), ArbRetestAllocation(), ArbTestAllocation(), RtlCopyRangeList(), RtlInvertRangeList(), RtlMergeRangeLists(), RtlpAddIntersectingRanges(), RtlpAddRange(), RtlpAddToMergedRange(), and RtlpCopyRangeListEntry().

#define FOR_REST_IN_ARRAY | ( | _Array,
|  | _Size,
|  | _Current |  | ) |

Value:

    for ( ;                                                             \
              (_Current) < (_Array) + (_Size);                              \
              (_Current)++ )

Definition at line 64 of file translate.c.

Referenced by ArbpUpdatePriority().

#define HAL_IRQ_TRANSLATOR_VERSION 0

| Definition at line 69 of file translate.c.

## Function Documentation

NTSTATUS FstubTranslateRequirement | ( | IN PVOID | Context,
|  | IN PIO_RESOURCE_DESCRIPTOR | Source,
|  | IN PDEVICE_OBJECT | PhysicalDeviceObject,
|  | OUT PULONG | TargetCount,
|  | OUT PIO_RESOURCE_DESCRIPTOR * | Target
| ) |

Definition at line 291 of file translate.c.

References ASSERT, ExAllocatePoolWithTag, HalGetInterruptVector(), PAGED_CODE, and PagedPool.

    00298 {
    00299     ULONG affinity;
    00300     KIRQL irql;
    00301
    00302     PAGED_CODE();
    00303     ASSERT(Source->Type == CmResourceTypeInterrupt);
    00304
    00305     *Target = ExAllocatePoolWithTag(PagedPool,
    00306                                     sizeof(IO_RESOURCE_DESCRIPTOR),
    00307                                     'btsF'
    00308                                     );
    00309
    00310     if (!*Target) {
    00311         return STATUS_INSUFFICIENT_RESOURCES;
    00312     }
    00313
    00314     *TargetCount = 1;
    00315
    00316     //
    00317     // Copy unchanged fields
    00318     //
    00319
    00320     **Target = *Source;
    00321
    00322     (*Target)->u.Interrupt.MinimumVector =
    00323         HalGetInterruptVector(
    00324             (INTERFACE_TYPE)(ULONG_PTR)Context,
    00325             0,     // assume bus 0 ??? BUGBUG ???
    00326             Source->u.Interrupt.MinimumVector,
    00327             Source->u.Interrupt.MinimumVector,
    00328             &irql,
    00329             &affinity
    00330             );
    00331
    00332
    00333     (*Target)->u.Interrupt.MaximumVector =
    00334         HalGetInterruptVector(
    00335             (INTERFACE_TYPE)(ULONG_PTR)Context,
    00336             0,     // assume bus 0 ??? BUGBUG ???
    00337             Source->u.Interrupt.MaximumVector,
    00338             Source->u.Interrupt.MaximumVector,
    00339             &irql,
    00340             &affinity
    00341             );
    00342
    00343
    00344     return STATUS_TRANSLATION_COMPLETE;
    00345 }

NTSTATUS FstubTranslateResource | ( | IN PVOID | Context,
|  | IN PCM_PARTIAL_RESOURCE_DESCRIPTOR | Source,
|  | IN RESOURCE_TRANSLATION_DIRECTION | Direction,
|  | IN ULONG AlternativesCount | OPTIONAL,
|  | IN IO_RESOURCE_DESCRIPTOR Alternatives[] | OPTIONAL,
|  | IN PDEVICE_OBJECT | PhysicalDeviceObject,
|  | OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR | Target
| ) |

Definition at line 192 of file translate.c.

References ASSERT, FOR_ALL_IN_ARRAY, HalGetInterruptVector(), NTSTATUS(), PAGED_CODE, TranslateChildToParent, and TranslateParentToChild.

    00201 {
    00202     NTSTATUS status;
    00203     ULONG affinity, currentVector, translatedVector;
    00204     KIRQL irql;
    00205     PIO_RESOURCE_DESCRIPTOR currentAlternative;
    00206
    00207     PAGED_CODE();
    00208     ASSERT(Source->Type == CmResourceTypeInterrupt);
    00209
    00210     //
    00211     // Copy unchanged fields
    00212     //
    00213
    00214     *Target = *Source;
    00215
    00216     switch (Direction) {
    00217     case TranslateChildToParent:
    00218
    00219         //
    00220         // Perform the translation - The interrupt source is
    00221         // ISA.
    00222         //
    00223
    00224         Target->u.Interrupt.Vector = HalGetInterruptVector(
    00225                                          (INTERFACE_TYPE)(ULONG_PTR)Context,
    00226                                          0,     // assume bus 0 ??? BUGBUG ???
    00227                                          Source->u.Interrupt.Vector,
    00228                                          Source->u.Interrupt.Vector,
    00229                                          &irql,
    00230                                          &affinity
    00231                                          );
    00232
    00233         Target->u.Interrupt.Level = irql;
    00234         Target->u.Interrupt.Affinity = affinity;
    00235
    00236         status = STATUS_TRANSLATION_COMPLETE;
    00237
    00238         break;
    00239
    00240     case TranslateParentToChild:
    00241
    00242         //
    00243         // Translate each alternative and when we match then use the value we
    00244         // just translated
    00245         //
    00246
    00247         FOR_ALL_IN_ARRAY(Alternatives, AlternativesCount, currentAlternative) {
    00248
    00249             ASSERT(currentAlternative->Type == CmResourceTypeInterrupt);
    00250
    00251             currentVector = currentAlternative->u.Interrupt.MinimumVector;
    00252
    00253             while (currentVector <=
    00254                        currentAlternative->u.Interrupt.MaximumVector) {
    00255
    00256                 translatedVector = HalGetInterruptVector((INTERFACE_TYPE)(ULONG_PTR)Context,
    00257                                                          0,// BUGBUG - assume bus 0
    00258                                                          currentVector,
    00259                                                          currentVector,
    00260                                                          &irql,
    00261                                                          &affinity
    00262                                                         );
    00263
    00264
    00265
    00266                 if (translatedVector == Source->u.Interrupt.Vector) {
    00267
    00268                     //
    00269                     // We found our vector - fill in the target and return
    00270                     //
    00271
    00272                     Target->u.Interrupt.Vector = currentVector;
    00273                     Target->u.Interrupt.Level = Target->u.Interrupt.Vector;
    00274                     Target->u.Interrupt.Affinity = 0xFFFFFFFF;
    00275                     return STATUS_SUCCESS;
    00276                 }
    00277
    00278                 currentVector++;
    00279             }
    00280
    00281         }
    00282
    00283         status = STATUS_UNSUCCESSFUL;
    00284
    00285         break;
    00286     }
    00287
    00288     return status;
    00289 }

VOID FstubTranslatorNull | ( | IN PVOID | Context | ) |

Definition at line 348 of file translate.c.

References PAGED_CODE.

    00351 {
    00352     PAGED_CODE();
    00353     return;
    00354 }

NTSTATUS xHalGetInterruptTranslator | ( | IN INTERFACE_TYPE | ParentInterfaceType,
|  | IN ULONG | ParentBusNumber,
|  | IN INTERFACE_TYPE | BridgeInterfaceType,
|  | IN USHORT | Size,
|  | IN USHORT | Version,
|  | OUT PTRANSLATOR_INTERFACE | Translator,
|  | OUT PULONG | BridgeBusNumber
| ) |

Definition at line 107 of file translate.c.

References PAGED_CODE.

    00118                    :
    00119
    00120
    00121 Arguments:
    00122
    00123         ParentInterfaceType - The type of the bus the bridge lives on (normally PCI).
    00124
    00125         ParentBusNumber - The number of the bus the bridge lives on.
    00126
    00127         ParentSlotNumber - The slot number the bridge lives in (where valid).
    00128
    00129         BridgeInterfaceType - The bus type the bridge provides (ie ISA for a PCI-ISA bridge).
    00130
    00131         ResourceType - The resource type we want to translate.
    00132
    00133         Size - The size of the translator buffer.
    00134
    00135         Version - The version of the translator interface requested.
    00136
    00137         Translator - Pointer to the buffer where the translator should be returned
    00138
    00139         BridgeBusNumber - Pointer to where the bus number of the bridge bus should be returned
    00140
    00141 Return Value:
    00142
    00143     Returns the status of this operation.
    00144
    00145 --*/
    00146 {
    00147     PAGED_CODE();
    00148
    00149 #if defined(NO_LEGACY_DRIVERS)
    00150     return STATUS_SUCCESS;
    00151 }
    00152 #else
    00153
    00154     UNREFERENCED_PARAMETER(ParentInterfaceType);
    00155     UNREFERENCED_PARAMETER(ParentBusNumber);
    00156
    00157     ASSERT(Version == HAL_IRQ_TRANSLATOR_VERSION);
    00158     ASSERT(Size >= sizeof (TRANSLATOR_INTERFACE));
    00159
    00160     switch (BridgeInterfaceType) {
    00161     case Eisa:
    00162     case Isa:
    00163     case MicroChannel:
    00164     case InterfaceTypeUndefined:    // special "IDE" cookie
    00165
    00166         //
    00167         // Pass back an interface for an IRQ translator.
    00168         //
    00169         RtlZeroMemory(Translator, sizeof (TRANSLATOR_INTERFACE));
    00170
    00171         Translator->Size = sizeof (TRANSLATOR_INTERFACE);
    00172         Translator->Version = HAL_IRQ_TRANSLATOR_VERSION;
    00173         Translator->InterfaceReference = &FstubTranslatorNull;
    00174         Translator->InterfaceDereference = &FstubTranslatorNull;
    00175         Translator->TranslateResources = &FstubTranslateResource;
    00176         Translator->TranslateResourceRequirements = &FstubTranslateRequirement;
    00177
    00178         if (BridgeInterfaceType == InterfaceTypeUndefined) {
    00179             Translator->Context = (PVOID)Isa;
    00180         } else {
    00181             Translator->Context = (PVOID)BridgeInterfaceType;
    00182         }
    00183
    00184         return STATUS_SUCCESS;
    00185
    00186     default:
    00187         return STATUS_NOT_IMPLEMENTED;
    00188     }
    00189 }

## Variable Documentation

PDEVICE_OBJECT McaPhysicalBusDevice

| Definition at line 96 of file translate.c.