ReactOS  0.4.15-dev-5649-gd5999c6
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 STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
enum _INTERFACE_TYPE INTERFACE_TYPE
_Out_ PKIRQL Irql
Definition: csq.h:179
UCHAR KIRQL
Definition: env_spec_w32.h:591
NTHALAPI ULONG NTAPI HalGetInterruptVector(INTERFACE_TYPE, ULONG, ULONG, ULONG, PKIRQL, PKAFFINITY)
#define ASSERT(a)
Definition: mode.c:44
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:170
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
ULONG_PTR KAFFINITY
Definition: compat.h:85
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
#define STATUS_TRANSLATION_COMPLETE
Definition: ntstatus.h:104
#define PAGED_CODE()

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 }
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
enum _INTERFACE_TYPE INTERFACE_TYPE
WDF_EXTERN_C_START typedef _In_ WDFDEVICE _In_ WDFCONTEXT _In_ WDF_DMA_DIRECTION Direction
LONG NTSTATUS
Definition: precomp.h:26
_Out_ PKIRQL Irql
Definition: csq.h:179
UCHAR KIRQL
Definition: env_spec_w32.h:591
NTHALAPI ULONG NTAPI HalGetInterruptVector(INTERFACE_TYPE, ULONG, ULONG, ULONG, PKIRQL, PKAFFINITY)
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:170
struct _IO_RESOURCE_DESCRIPTOR::@1553::@1556 Interrupt
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
union _IO_RESOURCE_DESCRIPTOR::@1553 u
ULONG_PTR KAFFINITY
Definition: compat.h:85
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK _In_ ULONG Vector
Definition: iofuncs.h:800
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
unsigned int ULONG
Definition: retypes.h:1
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_TRANSLATION_COMPLETE
Definition: ntstatus.h:104
int k
Definition: mpi.c:3369
#define PAGED_CODE()

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 }
#define PAGED_CODE()

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  {
172  return STATUS_NOT_IMPLEMENTED;
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 }
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
return STATUS_NOT_IMPLEMENTED
VOID NTAPI FstubTranslatorNull(PVOID Context)
Definition: translate.c:22
#define UlongToPtr(u)
Definition: config.h:106
#define ASSERT(a)
Definition: mode.c:44
#define HAL_IRQ_TRANSLATOR_VERSION
Definition: haltypes.h:287
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:361
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
struct _TRANSLATOR_INTERFACE TRANSLATOR_INTERFACE
#define STATUS_SUCCESS
Definition: shellext.h:65
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
#define PAGED_CODE()