ReactOS 0.4.15-dev-8332-ga943bb4
irq.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for irq.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

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)
 
VOID NTAPI IoDisconnectInterrupt (PKINTERRUPT InterruptObject)
 
NTSTATUS IopConnectInterruptExFullySpecific (_Inout_ PIO_CONNECT_INTERRUPT_PARAMETERS Parameters)
 
NTSTATUS NTAPI IoConnectInterruptEx (_Inout_ PIO_CONNECT_INTERRUPT_PARAMETERS Parameters)
 
VOID NTAPI IoDisconnectInterruptEx (_In_ PIO_DISCONNECT_INTERRUPT_PARAMETERS Parameters)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file irq.c.

Function Documentation

◆ IoConnectInterrupt()

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 at line 23 of file irq.c.

34{
36 PKINTERRUPT InterruptUsed;
37 PIO_INTERRUPT IoInterrupt;
38 BOOLEAN FirstRun;
39 CCHAR Count = 0;
41
42 PAGED_CODE();
43
44 /* Assume failure */
46
47 /* Get the affinity */
49 while (Affinity)
50 {
51 /* Increase count */
52 if (Affinity & 1) Count++;
53 Affinity >>= 1;
54 }
55
56 /* Make sure we have a valid CPU count */
58
59 /* Allocate the array of I/O interrupts */
60 IoInterrupt = ExAllocatePoolZero(NonPagedPool,
61 (Count - 1) * sizeof(KINTERRUPT) +
62 sizeof(IO_INTERRUPT),
64 if (!IoInterrupt) return STATUS_INSUFFICIENT_RESOURCES;
65
66 /* Use the structure's spinlock, if none was provided */
67 if (!SpinLock)
68 {
69 SpinLock = &IoInterrupt->SpinLock;
71 }
72
73 /* We first start with a built-in interrupt inside the I/O structure */
74 Interrupt = (PKINTERRUPT)(IoInterrupt + 1);
75 FirstRun = TRUE;
76
77 /* Now create all the interrupts */
79 for (Count = 0; Affinity; Count++, Affinity >>= 1)
80 {
81 /* Check if it's enabled for this CPU */
82 if (!(Affinity & 1))
83 continue;
84
85 /* Check which one we will use */
86 InterruptUsed = FirstRun ? &IoInterrupt->FirstInterrupt : Interrupt;
87
88 /* Initialize it */
89 KeInitializeInterrupt(InterruptUsed,
93 Vector,
94 Irql,
98 Count,
100
101 /* Connect it */
102 if (!KeConnectInterrupt(InterruptUsed))
103 {
104 /* Check how far we got */
105 if (FirstRun)
106 {
107 /* We failed early so just free this */
108 ExFreePoolWithTag(IoInterrupt, TAG_KINTERRUPT);
109 }
110 else
111 {
112 /* Far enough, so disconnect everything */
114 }
115
116 /* And fail */
118 }
119
120 /* Now we've used up our First Run */
121 if (FirstRun)
122 {
123 FirstRun = FALSE;
124 }
125 else
126 {
127 /* Move on to the next one */
128 IoInterrupt->Interrupt[(UCHAR)Count] = Interrupt++;
129 }
130 }
131
132 /* Return success */
133 *InterruptObject = &IoInterrupt->FirstInterrupt;
134 return STATUS_SUCCESS;
135}
#define PAGED_CODE()
unsigned char BOOLEAN
_Out_ PKIRQL Irql
Definition: csq.h:179
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
ULONG_PTR KAFFINITY
Definition: compat.h:85
#define NonPagedPool
Definition: env_spec_w32.h:307
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
@ InterruptObject
Definition: ketypes.h:428
int Count
Definition: noreturn.cpp:7
struct _KINTERRUPT * PKINTERRUPT
Definition: nt_native.h:32
KAFFINITY KeActiveProcessors
Definition: krnlinit.c:23
VOID NTAPI IoDisconnectInterrupt(PKINTERRUPT InterruptObject)
Definition: irq.c:142
BOOLEAN NTAPI KeConnectInterrupt(IN PKINTERRUPT Interrupt)
Definition: interrupt.c:81
VOID NTAPI KeInitializeInterrupt(IN PKINTERRUPT Interrupt, 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 CHAR ProcessorNumber, IN BOOLEAN FloatingSave)
Definition: interrupt.c:29
#define STATUS_SUCCESS
Definition: shellext.h:65
KSPIN_LOCK SpinLock
Definition: io.h:325
PKINTERRUPT Interrupt[MAXIMUM_PROCESSORS]
Definition: io.h:324
KINTERRUPT FirstInterrupt
Definition: io.h:323
#define TAG_KINTERRUPT
Definition: tag.h:88
char CCHAR
Definition: typedefs.h:51
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFINTERRUPT * Interrupt
Definition: wdfinterrupt.h:379
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:228
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:174
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK _In_ ULONG _In_ KIRQL _In_ KIRQL _In_ KINTERRUPT_MODE _In_ BOOLEAN _In_ KAFFINITY ProcessorEnableMask
Definition: iofuncs.h:808
_In_ PKSERVICE_ROUTINE ServiceRoutine
Definition: iofuncs.h:800
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK _In_ ULONG _In_ KIRQL _In_ KIRQL _In_ KINTERRUPT_MODE InterruptMode
Definition: iofuncs.h:806
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK _In_ ULONG _In_ KIRQL _In_ KIRQL SynchronizeIrql
Definition: iofuncs.h:805
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK _In_ ULONG _In_ KIRQL _In_ KIRQL _In_ KINTERRUPT_MODE _In_ BOOLEAN _In_ KAFFINITY _In_ BOOLEAN FloatingSave
Definition: iofuncs.h:809
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK _In_ ULONG _In_ KIRQL _In_ KIRQL _In_ KINTERRUPT_MODE _In_ BOOLEAN ShareVector
Definition: iofuncs.h:807
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID ServiceContext
Definition: iofuncs.h:801
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by AcpiOsInstallInterruptHandler(), AddControllers(), EnableIrq(), FdoCallHWInitialize(), HDA_FDOStartDevice(), i8042ConnectKeyboardInterrupt(), i8042ConnectMouseInterrupt(), InPortStartDevice(), IntVideoPortSetupInterrupt(), IopConnectInterruptExFullySpecific(), LegacyAttachInterrupt(), NdisMRegisterInterrupt(), PortFdoConnectInterrupt(), sb16_play(), SerialPnpStartDevice(), StreamClassStartDevice(), TestConnectInterrupt(), UniataConnectIntr2(), and USBPORT_StartDevice().

◆ IoConnectInterruptEx()

NTSTATUS NTAPI IoConnectInterruptEx ( _Inout_ PIO_CONNECT_INTERRUPT_PARAMETERS  Parameters)

Definition at line 198 of file irq.c.

200{
201 PAGED_CODE();
202
203 switch (Parameters->Version)
204 {
208 //TODO: We don't do anything for the group type
211 DPRINT1("FIXME: Message based interrupts are UNIMPLEMENTED\n");
212 break;
214 DPRINT1("FIXME: Line based interrupts are UNIMPLEMENTED\n");
215 break;
216 }
217
218 return STATUS_SUCCESS;
219}
#define DPRINT1
Definition: precomp.h:8
NTSTATUS IopConnectInterruptExFullySpecific(_Inout_ PIO_CONNECT_INTERRUPT_PARAMETERS Parameters)
Definition: irq.c:173
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869
#define CONNECT_FULLY_SPECIFIED_GROUP
#define CONNECT_LINE_BASED
#define CONNECT_FULLY_SPECIFIED
#define CONNECT_MESSAGE_BASED

◆ IoDisconnectInterrupt()

VOID NTAPI IoDisconnectInterrupt ( PKINTERRUPT  InterruptObject)

Definition at line 142 of file irq.c.

143{
144 PIO_INTERRUPT IoInterrupt;
145 ULONG i;
146
147 PAGED_CODE();
148
149 /* Get the I/O interrupt */
152 FirstInterrupt);
153
154 /* Disconnect the first one */
156
157 /* Now disconnect the others */
158 for (i = 0; i < KeNumberProcessors; i++)
159 {
160 /* Make sure one was registered */
161 if (!IoInterrupt->Interrupt[i])
162 continue;
163
164 /* Disconnect it */
165 KeDisconnectInterrupt(IoInterrupt->Interrupt[i]);
166 }
167
168 /* Free the I/O interrupt */
169 ExFreePoolWithTag(IoInterrupt, TAG_KINTERRUPT);
170}
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 const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
CCHAR KeNumberProcessors
Definition: krnlinit.c:35
BOOLEAN NTAPI KeDisconnectInterrupt(IN PKINTERRUPT Interrupt)
Definition: interrupt.c:165
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59

Referenced by AcpiOsRemoveInterruptHandler(), AddControllers(), FdoRemoveAdapter(), HDA_FDORemoveDevice(), i8042ConnectMouseInterrupt(), InPortRemoveDevice(), IntVideoPortFindAdapter(), IoConnectInterrupt(), IoDisconnectInterruptEx(), NdisMDeregisterInterrupt(), StreamClassReleaseResources(), UniataDisconnectIntr2(), Unload(), and USBPORT_StartDevice().

◆ IoDisconnectInterruptEx()

VOID NTAPI IoDisconnectInterruptEx ( _In_ PIO_DISCONNECT_INTERRUPT_PARAMETERS  Parameters)

Definition at line 223 of file irq.c.

225{
226 PAGED_CODE();
227
228 //FIXME: This eventually will need to handle more cases
229 if (Parameters->ConnectionContext.InterruptObject)
230 IoDisconnectInterrupt(Parameters->ConnectionContext.InterruptObject);
231}

◆ IopConnectInterruptExFullySpecific()

NTSTATUS IopConnectInterruptExFullySpecific ( _Inout_ PIO_CONNECT_INTERRUPT_PARAMETERS  Parameters)

Definition at line 173 of file irq.c.

175{
177
178 PAGED_CODE();
179
180 /* Fallback to standard IoConnectInterrupt */
181 Status = IoConnectInterrupt(Parameters->FullySpecified.InterruptObject,
182 Parameters->FullySpecified.ServiceRoutine,
183 Parameters->FullySpecified.ServiceContext,
184 Parameters->FullySpecified.SpinLock,
185 Parameters->FullySpecified.Vector,
186 Parameters->FullySpecified.Irql,
187 Parameters->FullySpecified.SynchronizeIrql,
188 Parameters->FullySpecified.InterruptMode,
189 Parameters->FullySpecified.ShareVector,
190 Parameters->FullySpecified.ProcessorEnableMask,
191 Parameters->FullySpecified.FloatingSave);
192 DPRINT("IopConnectInterruptEx_FullySpecific: has failed with status %X", Status);
193 return Status;
194}
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: gdiplustypes.h:25
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:23
#define DPRINT
Definition: sndvol32.h:73

Referenced by IoConnectInterruptEx().