ReactOS  0.4.14-dev-317-g96040ec
interrupt.c File Reference
#include "videoprt.h"
#include <ndk/halfuncs.h>
#include <debug.h>
Include dependency graph for interrupt.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

BOOLEAN NTAPI IntVideoPortInterruptRoutine (IN struct _KINTERRUPT *Interrupt, IN PVOID ServiceContext)
 
BOOLEAN NTAPI IntVideoPortSetupInterrupt (IN PDEVICE_OBJECT DeviceObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PVIDEO_PORT_CONFIG_INFO ConfigInfo)
 
VP_STATUS NTAPI VideoPortEnableInterrupt (IN PVOID HwDeviceExtension)
 
VP_STATUS NTAPI VideoPortDisableInterrupt (IN PVOID HwDeviceExtension)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 26 of file interrupt.c.

Function Documentation

◆ IntVideoPortInterruptRoutine()

BOOLEAN NTAPI IntVideoPortInterruptRoutine ( IN struct _KINTERRUPT Interrupt,
IN PVOID  ServiceContext 
)

Definition at line 32 of file interrupt.c.

35 {
37 
39 
40  return DeviceExtension->DriverExtension->InitializationData.HwInterrupt(
41  &DeviceExtension->MiniPortDeviceExtension);
42 }
VIDEO_PORT_DRIVER_EXTENSION * DriverExtension
Definition: videoprt.h:100
VIDEO_HW_INITIALIZATION_DATA InitializationData
Definition: videoprt.h:69
smooth NULL
Definition: ftsmooth.c:416
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID ServiceContext
Definition: iofuncs.h:798
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
PVIDEO_HW_INTERRUPT HwInterrupt
Definition: video.h:668

Referenced by IntVideoPortSetupInterrupt().

◆ IntVideoPortSetupInterrupt()

BOOLEAN NTAPI IntVideoPortSetupInterrupt ( IN PDEVICE_OBJECT  DeviceObject,
IN PVIDEO_PORT_DRIVER_EXTENSION  DriverExtension,
IN PVIDEO_PORT_CONFIG_INFO  ConfigInfo 
)

Definition at line 45 of file interrupt.c.

49 {
51  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
52 
54 
55  /*
56  * MSDN documentation for VIDEO_PORT_CONFIG_INFO states: "If a miniport driver's
57  * HwVidFindAdapter function finds that the video adapter does not generate
58  * interrupts or that it cannot determine a valid interrupt vector/level for
59  * the adapter, HwVidFindAdapter should set both BusInterruptVector and
60  * BusInterruptLevel to zero.
61  */
62 
63  if (DriverExtension->InitializationData.HwInterrupt != NULL &&
64  (ConfigInfo->BusInterruptLevel != 0 ||
65  ConfigInfo->BusInterruptVector != 0))
66  {
67  ULONG InterruptVector;
68  KIRQL Irql;
70 
71  InterruptVector = HalGetInterruptVector(
72  ConfigInfo->AdapterInterfaceType,
73  ConfigInfo->SystemIoBusNumber,
74  ConfigInfo->BusInterruptLevel,
75  ConfigInfo->BusInterruptVector,
76  &Irql,
77  &Affinity);
78 
79  if (InterruptVector == 0)
80  {
81  WARN_(VIDEOPRT, "HalGetInterruptVector failed\n");
82  return FALSE;
83  }
84 
85  KeInitializeSpinLock(&DeviceExtension->InterruptSpinLock);
87  &DeviceExtension->InterruptObject,
89  DeviceExtension,
90  &DeviceExtension->InterruptSpinLock,
91  InterruptVector,
92  Irql,
93  Irql,
94  ConfigInfo->InterruptMode,
95  DeviceExtension->InterruptShared,
96  Affinity,
97  FALSE);
98 
99  if (!NT_SUCCESS(Status))
100  {
101  WARN_(VIDEOPRT, "IoConnectInterrupt failed with status 0x%08x\n", Status);
102  return FALSE;
103  }
104  }
105 
106  return TRUE;
107 }
#define TRUE
Definition: types.h:120
NTHALAPI ULONG NTAPI HalGetInterruptVector(INTERFACE_TYPE, ULONG, ULONG, ULONG, PKIRQL, PKAFFINITY)
LONG NTSTATUS
Definition: precomp.h:26
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
_Out_ PKIRQL Irql
Definition: csq.h:179
UCHAR KIRQL
Definition: env_spec_w32.h:591
NTSTATUS NTAPI IoConnectInterrupt(OUT PKINTERRUPT *InterruptObject, IN PKSERVICE_ROUTINE ServiceRoutine, IN PVOID ServiceContext, IN PKSPIN_LOCK SpinLock, IN ULONG Vector, IN KIRQL Irql, IN KIRQL SynchronizeIrql, IN KINTERRUPT_MODE InterruptMode, IN BOOLEAN ShareVector, IN KAFFINITY ProcessorEnableMask, IN BOOLEAN FloatingSave)
Definition: irq.c:22
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN NTAPI IntVideoPortInterruptRoutine(IN struct _KINTERRUPT *Interrupt, IN PVOID ServiceContext)
Definition: interrupt.c:32
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:170
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
ULONG_PTR KAFFINITY
Definition: compat.h:75
unsigned int ULONG
Definition: retypes.h:1
#define WARN_(ch,...)
Definition: debug.h:157

Referenced by IntVideoPortFindAdapter().

◆ VideoPortDisableInterrupt()

VP_STATUS NTAPI VideoPortDisableInterrupt ( IN PVOID  HwDeviceExtension)

Definition at line 154 of file interrupt.c.

155 {
156 #ifndef _M_AMD64
157  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
158 
159  /* Get the device extension */
160  DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
161 
162  /* Fail if the driver didn't register an ISR */
163  if (!DeviceExtension->DriverExtension->InitializationData.HwInterrupt)
164  {
165  /* No ISR, no interrupts */
166  return ERROR_INVALID_FUNCTION;
167  }
168 
169  /* Disable the interrupt and return */
170  HalDisableSystemInterrupt(DeviceExtension->InterruptVector, 0);
171  return NO_ERROR;
172 #else
173  /* FIXME: Function still present? If so what to use instead of HalDisableSystemInterrupt? */
175  return ERROR_INVALID_FUNCTION;
176 #endif
177 }
VIDEO_PORT_DRIVER_EXTENSION * DriverExtension
Definition: videoprt.h:100
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
VIDEO_HW_INITIALIZATION_DATA InitializationData
Definition: videoprt.h:69
#define VIDEO_PORT_GET_DEVICE_EXTENSION(MiniportExtension)
Definition: videoprt.h:133
#define NO_ERROR
Definition: dderror.h:5
VOID NTAPI HalDisableSystemInterrupt(IN ULONG Vector, IN KIRQL Irql)
Definition: pic.c:309
PVIDEO_HW_INTERRUPT HwInterrupt
Definition: video.h:668
#define UNIMPLEMENTED
Definition: debug.h:114

◆ VideoPortEnableInterrupt()

VP_STATUS NTAPI VideoPortEnableInterrupt ( IN PVOID  HwDeviceExtension)

Definition at line 116 of file interrupt.c.

117 {
118 #ifndef _M_AMD64
119  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
120  BOOLEAN InterruptValid;
121 
122  /* Get the device extension */
123  DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
124 
125  /* Fail if the driver didn't register an ISR */
126  if (!DeviceExtension->DriverExtension->InitializationData.HwInterrupt)
127  {
128  /* No ISR, no interrupts */
129  return ERROR_INVALID_FUNCTION;
130  }
131 
132  /* Re-enable the interrupt and return */
133  InterruptValid = HalEnableSystemInterrupt(DeviceExtension->InterruptVector,
134  0,
135  DeviceExtension->InterruptLevel);
136 
137  /* Make sure the interrupt was valid */
138  ASSERT(InterruptValid == TRUE);
139 
140  /* Return to caller */
141  return NO_ERROR;
142 #else
143  /* FIXME: Function still present? If so what to use instead of HalEnableSystemInterrupt? */
145  return ERROR_INVALID_FUNCTION;
146 #endif
147 }
BOOLEAN NTAPI HalEnableSystemInterrupt(IN ULONG Vector, IN KIRQL Irql, IN KINTERRUPT_MODE InterruptMode)
Definition: pic.c:295
#define TRUE
Definition: types.h:120
VIDEO_PORT_DRIVER_EXTENSION * DriverExtension
Definition: videoprt.h:100
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
VIDEO_HW_INITIALIZATION_DATA InitializationData
Definition: videoprt.h:69
#define VIDEO_PORT_GET_DEVICE_EXTENSION(MiniportExtension)
Definition: videoprt.h:133
#define NO_ERROR
Definition: dderror.h:5
unsigned char BOOLEAN
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
PVIDEO_HW_INTERRUPT HwInterrupt
Definition: video.h:668
#define UNIMPLEMENTED
Definition: debug.h:114