ReactOS 0.4.15-dev-8191-gbc6c731
translate.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for translate.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID NTAPI FstubTranslatorNull (PVOID Context)
 
NTSTATUS NTAPI FstubTranslateResource (IN OUT PVOID Context OPTIONAL, IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source, IN RESOURCE_TRANSLATION_DIRECTION Direction, IN ULONG AlternativesCount OPTIONAL, IN IO_RESOURCE_DESCRIPTOR Alternatives[], IN PDEVICE_OBJECT PhysicalDeviceObject, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target)
 
NTSTATUS NTAPI FstubTranslateRequirement (IN OUT PVOID Context OPTIONAL, IN PIO_RESOURCE_DESCRIPTOR Source, IN PDEVICE_OBJECT PhysicalDeviceObject, OUT PULONG TargetCount, OUT PIO_RESOURCE_DESCRIPTOR *Target)
 
NTSTATUS NTAPI 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)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file translate.c.

Function Documentation

◆ FstubTranslateRequirement()

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

Definition at line 113 of file translate.c.

118{
119 KIRQL Irql;
121 PAGED_CODE();
122
124
125 /* Allocate output buffer */
127 if (!*Target)
128 {
130 }
131
132 /* Zero & set out count to 1 */
134 *TargetCount = 1;
135
136 /* Translate minimum interrupt vector */
137 (*Target)->u.Interrupt.MinimumVector = HalGetInterruptVector((INTERFACE_TYPE)Context, 0,
138 Source->u.Interrupt.MinimumVector,
139 Source->u.Interrupt.MinimumVector,
140 &Irql, &Affinity);
141
142 /* Translate maximum interrupt vector */
143 (*Target)->u.Interrupt.MaximumVector = HalGetInterruptVector((INTERFACE_TYPE)Context, 0,
144 Source->u.Interrupt.MaximumVector,
145 Source->u.Interrupt.MaximumVector,
146 &Irql, &Affinity);
147
149}
#define PAGED_CODE()
_Out_ PKIRQL Irql
Definition: csq.h:179
ULONG_PTR KAFFINITY
Definition: compat.h:85
NTHALAPI ULONG NTAPI HalGetInterruptVector(INTERFACE_TYPE, ULONG, ULONG, ULONG, PKIRQL, PKAFFINITY)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define PagedPool
Definition: env_spec_w32.h:308
enum _INTERFACE_TYPE INTERFACE_TYPE
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define ASSERT(a)
Definition: mode.c:44
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
#define STATUS_TRANSLATION_COMPLETE
Definition: ntstatus.h:104
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:174

Referenced by xHalGetInterruptTranslator().

◆ FstubTranslateResource()

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

Definition at line 35 of file translate.c.

42{
43 KIRQL Irql;
45 ULONG MinimumVector, Vector, k;
46 PIO_RESOURCE_DESCRIPTOR Alternative;
48 PAGED_CODE();
49
51
52 /* Copy common information */
53 Target->Type = Source->Type;
54 Target->ShareDisposition = Source->ShareDisposition;
55 Target->Flags = Source->Flags;
56
58 {
59 /* Get IRQL, affinity & system vector for the device vector */
60 Target->u.Interrupt.Vector = HalGetInterruptVector((INTERFACE_TYPE)Context, 0,
61 Source->u.Interrupt.Vector,
62 Source->u.Interrupt.Vector,
63 &Irql, &Affinity);
64 Target->u.Interrupt.Level = Irql;
65 Target->u.Interrupt.Affinity = Affinity;
67 }
69 {
70 /* Browse all the resources */
71 for (k = 0; k < AlternativesCount; k++)
72 {
73 Alternative = &(Alternatives[k]);
74
75 ASSERT(Alternative->Type == CmResourceTypeInterrupt);
76
77 /* Try to find the device vector, proceeding by trial & error
78 * We try a vector, and translate it
79 */
80 MinimumVector = Alternative->u.Interrupt.MinimumVector;
81 while (MinimumVector <= Alternative->u.Interrupt.MaximumVector)
82 {
83 /* Translate the vector */
85 MinimumVector,
86 MinimumVector,
87 &Irql, &Affinity);
88
89 /* If the translated vector is matching the given translated vector */
90 if (Vector == Source->u.Interrupt.Vector)
91 {
92 /* We are done, send back device vector */
93 Target->u.Interrupt.Affinity = -1;
94 Target->u.Interrupt.Vector = MinimumVector;
95 Target->u.Interrupt.Level = MinimumVector;
96
97 return STATUS_SUCCESS;
98 }
99
100 MinimumVector++;
101 }
102 }
103 }
104
105 return Status;
106}
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
int k
Definition: mpi.c:3369
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _IO_RESOURCE_DESCRIPTOR::@23::@26 Interrupt
union _IO_RESOURCE_DESCRIPTOR::@23 u
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
WDF_EXTERN_C_START typedef _In_ WDFDEVICE _In_ WDFCONTEXT _In_ WDF_DMA_DIRECTION Direction
@ TranslateChildToParent
Definition: iotypes.h:4665
@ TranslateParentToChild
Definition: iotypes.h:4666

Referenced by xHalGetInterruptTranslator().

◆ FstubTranslatorNull()

VOID NTAPI FstubTranslatorNull ( PVOID  Context)

Definition at line 22 of file translate.c.

23{
24 PAGED_CODE();
25
26 /* Do nothing */
27 return;
28}

Referenced by xHalGetInterruptTranslator().

◆ xHalGetInterruptTranslator()

NTSTATUS NTAPI 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 156 of file translate.c.

163{
164 PAGED_CODE();
165
167 ASSERT(Size >= sizeof(TRANSLATOR_INTERFACE));
168
169 /* Only (E)ISA interfaces are supported */
170 if (BridgeInterfaceType == Internal || BridgeInterfaceType >= MicroChannel)
171 {
173 }
174
175 /* Fill in output struct */
176 Translator->Size = sizeof(TRANSLATOR_INTERFACE);
177 Translator->Version = HAL_IRQ_TRANSLATOR_VERSION;
178 /* In case caller set interface to undefined, faulty it to ISA */
179 Translator->Context = UlongToPtr((BridgeInterfaceType == InterfaceTypeUndefined) ? Isa : BridgeInterfaceType);
180 Translator->InterfaceReference = FstubTranslatorNull;
181 Translator->InterfaceDereference = FstubTranslatorNull;
182 Translator->TranslateResources = FstubTranslateResource;
183 Translator->TranslateResourceRequirements = FstubTranslateRequirement;
184
185 return STATUS_SUCCESS;
186}
#define UlongToPtr(u)
Definition: config.h:106
@ InterfaceTypeUndefined
Definition: hwresource.cpp:136
@ Internal
Definition: hwresource.cpp:137
@ MicroChannel
Definition: hwresource.cpp:140
@ Isa
Definition: hwresource.cpp:138
#define HAL_IRQ_TRANSLATOR_VERSION
Definition: haltypes.h:287
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
NTSTATUS NTAPI FstubTranslateRequirement(IN OUT PVOID Context OPTIONAL, IN PIO_RESOURCE_DESCRIPTOR Source, IN PDEVICE_OBJECT PhysicalDeviceObject, OUT PULONG TargetCount, OUT PIO_RESOURCE_DESCRIPTOR *Target)
Definition: translate.c:113
NTSTATUS NTAPI FstubTranslateResource(IN OUT PVOID Context OPTIONAL, IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source, IN RESOURCE_TRANSLATION_DIRECTION Direction, IN ULONG AlternativesCount OPTIONAL, IN IO_RESOURCE_DESCRIPTOR Alternatives[], IN PDEVICE_OBJECT PhysicalDeviceObject, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target)
Definition: translate.c:35
VOID NTAPI FstubTranslatorNull(PVOID Context)
Definition: translate.c:22
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469
struct _TRANSLATOR_INTERFACE TRANSLATOR_INTERFACE