ReactOS 0.4.15-dev-7906-g1b85a5f
interrupt.c
Go to the documentation of this file.
1/*
2 * VideoPort driver
3 *
4 * Copyright (C) 2002, 2003, 2004 ReactOS Team
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 */
21
22#include "videoprt.h"
23
24#include <ndk/halfuncs.h>
25
26#define NDEBUG
27#include <debug.h>
28
29/* PRIVATE FUNCTIONS **********************************************************/
30
33 IN struct _KINTERRUPT *Interrupt,
35{
37
39
40 return DeviceExtension->DriverExtension->InitializationData.HwInterrupt(
41 &DeviceExtension->MiniPortDeviceExtension);
42}
43
48 IN PVIDEO_PORT_CONFIG_INFO ConfigInfo)
49{
51 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
52
53 DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
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,
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}
108
109/* PUBLIC FUNCTIONS ***********************************************************/
110
111/*
112 * @implemented
113 */
115NTAPI
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 */
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? */
146#endif
147}
148
149/*
150 * @implemented
151 */
153NTAPI
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 */
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? */
176#endif
177}
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define UNIMPLEMENTED
Definition: debug.h:115
_Out_ PKIRQL Irql
Definition: csq.h:179
#define NO_ERROR
Definition: dderror.h:5
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG_PTR KAFFINITY
Definition: compat.h:85
NTHALAPI ULONG NTAPI HalGetInterruptVector(INTERFACE_TYPE, ULONG, ULONG, ULONG, PKIRQL, PKAFFINITY)
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
Status
Definition: gdiplustypes.h:25
BOOLEAN NTAPI HalEnableSystemInterrupt(IN ULONG Vector, IN KIRQL Irql, IN KINTERRUPT_MODE InterruptMode)
Definition: pic.c:295
VOID NTAPI HalDisableSystemInterrupt(IN ULONG Vector, IN KIRQL Irql)
Definition: pic.c:309
if(dx< 0)
Definition: linetemp.h:194
#define ASSERT(a)
Definition: mode.c:44
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
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
LONG VP_STATUS
Definition: video.h:153
#define WARN_(ch,...)
Definition: debug.h:157
PVIDEO_HW_INTERRUPT HwInterrupt
Definition: video.h:676
VIDEO_PORT_DRIVER_EXTENSION * DriverExtension
Definition: videoprt.h:103
CHAR POINTER_ALIGNMENT MiniPortDeviceExtension[1]
Definition: videoprt.h:113
VIDEO_HW_INITIALIZATION_DATA InitializationData
Definition: videoprt.h:72
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define VIDEO_PORT_GET_DEVICE_EXTENSION(MiniportExtension)
Definition: videoprt.h:140
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFINTERRUPT * Interrupt
Definition: wdfinterrupt.h:379
VP_STATUS NTAPI VideoPortEnableInterrupt(IN PVOID HwDeviceExtension)
Definition: interrupt.c:116
BOOLEAN NTAPI IntVideoPortSetupInterrupt(IN PDEVICE_OBJECT DeviceObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PVIDEO_PORT_CONFIG_INFO ConfigInfo)
Definition: interrupt.c:45
VP_STATUS NTAPI VideoPortDisableInterrupt(IN PVOID HwDeviceExtension)
Definition: interrupt.c:154
BOOLEAN NTAPI IntVideoPortInterruptRoutine(IN struct _KINTERRUPT *Interrupt, IN PVOID ServiceContext)
Definition: interrupt.c:32
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:174
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID ServiceContext
Definition: iofuncs.h:801