ReactOS  0.4.14-dev-376-gaedba84
translate.c
Go to the documentation of this file.
1 /*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/fstub/translate.c
5 * PURPOSE: Interrupt Translator Routines
6 * PROGRAMMERS: Pierre Schweitzer (pierre.schweitzer@reactos.org)
7 */
8 
9 /* INCLUDES ******************************************************************/
10 
11 #include <ntoskrnl.h>
12 #define NDEBUG
13 #include <debug.h>
14 
15 /* PRIVATE FUNCTIONS *********************************************************/
16 
17 /*
18  * @implemented
19  */
20 VOID
21 NTAPI
23 {
24  PAGED_CODE();
25 
26  /* Do nothing */
27  return;
28 }
29 
30 /*
31  * @implemented
32  */
34 NTAPI
38  IN ULONG AlternativesCount OPTIONAL,
39  IN IO_RESOURCE_DESCRIPTOR Alternatives[],
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 }
107 
108 /*
109  * @implemented
110  */
111 NTSTATUS
112 NTAPI
116  OUT PULONG TargetCount,
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 }
150 
151 /*
152  * @implemented
153  */
154 NTSTATUS
155 NTAPI
157  IN ULONG ParentBusNumber,
158  IN INTERFACE_TYPE BridgeInterfaceType,
159  IN USHORT Size,
160  IN USHORT Version,
161  OUT PTRANSLATOR_INTERFACE Translator,
162  OUT PULONG BridgeBusNumber)
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 }
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
#define IN
Definition: typedefs.h:38
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:359
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
enum _INTERFACE_TYPE INTERFACE_TYPE
NTHALAPI ULONG NTAPI HalGetInterruptVector(INTERFACE_TYPE, ULONG, ULONG, ULONG, PKIRQL, PKAFFINITY)
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
LONG NTSTATUS
Definition: precomp.h:26
union _IO_RESOURCE_DESCRIPTOR::@1987 u
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1122
_Out_ PKIRQL Irql
Definition: csq.h:179
struct _IO_RESOURCE_DESCRIPTOR::@1987::@1990 Interrupt
#define PAGED_CODE()
Definition: video.h:57
UCHAR KIRQL
Definition: env_spec_w32.h:591
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
VOID NTAPI FstubTranslatorNull(PVOID Context)
Definition: translate.c:22
#define UlongToPtr(u)
Definition: config.h:106
#define HAL_IRQ_TRANSLATOR_VERSION
Definition: haltypes.h:276
_Inout_ PSIZE_T _In_opt_ PMDLX _In_ MM_ROTATE_DIRECTION Direction
Definition: mmfuncs.h:773
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:170
_Must_inspect_result_ typedef _In_ ULONG _In_ BOOLEAN Target
Definition: iotypes.h:1068
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
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
Status
Definition: gdiplustypes.h:24
struct _TRANSLATOR_INTERFACE TRANSLATOR_INTERFACE
unsigned short USHORT
Definition: pedump.c:61
ULONG_PTR KAFFINITY
Definition: compat.h:75
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK _In_ ULONG Vector
Definition: iofuncs.h:798
unsigned int * PULONG
Definition: retypes.h:1
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
enum _RESOURCE_TRANSLATION_DIRECTION RESOURCE_TRANSLATION_DIRECTION
#define OUT
Definition: typedefs.h:39
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: translate.c:156
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
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 STATUS_TRANSLATION_COMPLETE
Definition: ntstatus.h:104
return STATUS_SUCCESS
Definition: btrfs.c:2938
int k
Definition: mpi.c:3369
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68