ReactOS 0.4.15-dev-8135-g1bc6c90
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 */
20VOID
23{
24 PAGED_CODE();
25
26 /* Do nothing */
27 return;
28}
29
30/*
31 * @implemented
32 */
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 */
112NTAPI
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 */
155NTAPI
157 IN ULONG ParentBusNumber,
158 IN INTERFACE_TYPE BridgeInterfaceType,
159 IN USHORT Size,
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 {
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 PAGED_CODE()
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
_Out_ PKIRQL Irql
Definition: csq.h:179
ULONG_PTR KAFFINITY
Definition: compat.h:85
#define UlongToPtr(u)
Definition: config.h:106
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
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
@ InterfaceTypeUndefined
Definition: hwresource.cpp:136
@ Internal
Definition: hwresource.cpp:137
@ MicroChannel
Definition: hwresource.cpp:140
@ Isa
Definition: hwresource.cpp:138
enum _INTERFACE_TYPE INTERFACE_TYPE
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define ASSERT(a)
Definition: mode.c:44
int k
Definition: mpi.c:3369
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
#define HAL_IRQ_TRANSLATOR_VERSION
Definition: haltypes.h:287
#define STATUS_TRANSLATION_COMPLETE
Definition: ntstatus.h:104
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_SUCCESS
Definition: shellext.h:65
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
struct _IO_RESOURCE_DESCRIPTOR::@23::@26 Interrupt
union _IO_RESOURCE_DESCRIPTOR::@23 u
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 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
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
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
WDF_EXTERN_C_START typedef _In_ WDFDEVICE _In_ WDFCONTEXT _In_ WDF_DMA_DIRECTION Direction
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:174
@ TranslateChildToParent
Definition: iotypes.h:4665
@ TranslateParentToChild
Definition: iotypes.h:4666
enum _RESOURCE_TRANSLATION_DIRECTION RESOURCE_TRANSLATION_DIRECTION
struct _TRANSLATOR_INTERFACE TRANSLATOR_INTERFACE