ReactOS 0.4.17-dev-683-g0dafdc5
arbirq.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: MIT (https://spdx.org/licenses/MIT)
4 * PURPOSE: PnP manager Root IRQ Arbiter
5 * COPYRIGHT: Copyright 2025-2026 Justin Miller <justin.miller@reactos.org>
6 */
7
8/* INCLUDES *****************************************************************/
9
10#include <ntoskrnl.h>
11#define NDEBUG
12#include <debug.h>
13
14/* GLOBALS *******************************************************************/
15
17
18/* FUNCTIONS *****************************************************************/
19
23 _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor,
24 _Out_ PUINT64 OutMinimumAddress,
25 _Out_ PUINT64 OutMaximumAddress,
26 _Out_ PUINT64 OutLength,
27 _Out_ PUINT64 OutAlignment)
28{
29 PAGED_CODE();
30
31 *OutMinimumAddress = IoDescriptor->u.Interrupt.MinimumVector;
32 *OutMaximumAddress = IoDescriptor->u.Interrupt.MaximumVector;
33 *OutLength = 1;
34 *OutAlignment = 1;
35
36 return STATUS_SUCCESS;
37}
38
42 _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor,
45{
46 PAGED_CODE();
47
48 CmDescriptor->Type = CmResourceTypeInterrupt;
49 CmDescriptor->ShareDisposition = IoDescriptor->ShareDisposition;
50 CmDescriptor->Flags = IoDescriptor->Flags;
51
52 CmDescriptor->u.Interrupt.Level = (ULONG)Start;
53 CmDescriptor->u.Interrupt.Vector = (ULONG)Start;
54 CmDescriptor->u.Interrupt.Affinity = (KAFFINITY)-1;
55
56 return STATUS_SUCCESS;
57}
58
64 _Out_ PUINT64 OutLength)
65{
66 PAGED_CODE();
67
68 *Start = CmDescriptor->u.Interrupt.Vector;
69 *OutLength = 1;
70
71 return STATUS_SUCCESS;
72}
73
77 _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
78{
79 PAGED_CODE();
80
81 return (INT32)(IoDescriptor->u.Interrupt.MaximumVector -
82 IoDescriptor->u.Interrupt.MinimumVector + 1);
83}
84
88 _Out_ PIO_RESOURCE_DESCRIPTOR OutIoDescriptor,
89 _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
90{
91 KIRQL Irql;
93
94 PAGED_CODE();
95
96 *OutIoDescriptor = *IoDescriptor;
97
98 if (IoDescriptor->Type != CmResourceTypeInterrupt)
99 return STATUS_SUCCESS;
100
101 OutIoDescriptor->u.Interrupt.MinimumVector =
103 0,
104 IoDescriptor->u.Interrupt.MinimumVector,
105 IoDescriptor->u.Interrupt.MinimumVector,
106 &Irql,
107 &Affinity);
108
109 if (Affinity != 0)
110 {
111 Affinity = 0;
112 OutIoDescriptor->u.Interrupt.MaximumVector =
114 0,
115 IoDescriptor->u.Interrupt.MaximumVector,
116 IoDescriptor->u.Interrupt.MaximumVector,
117 &Irql,
118 &Affinity);
119 }
120
121 if (Affinity == 0)
122 *OutIoDescriptor = *IoDescriptor;
123
124 return STATUS_SUCCESS;
125}
126
148NTAPI
150{
152
153 PAGED_CODE();
154
155 IopRootIrqArbiter.Name = L"RootIRQ";
160
162 NULL,
165 L"Root",
167 if (!NT_SUCCESS(Status))
168 {
169 DPRINT1("IopArbIrqInitialize: Failed with %X\n", Status);
170 }
171
172 return Status;
173}
#define PAGED_CODE()
static _Out_opt_ PULONGLONG Start
COMPILER_DEPENDENT_UINT64 UINT64
Definition: actypes.h:131
ARBITER_INSTANCE IopRootIrqArbiter
Definition: pnpinit.c:24
NTSTATUS NTAPI IopArbIrqPackResource(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _In_ UINT64 Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor)
Definition: arbirq.c:41
INT32 NTAPI IopArbIrqScoreRequirement(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Definition: arbirq.c:76
NTSTATUS NTAPI IopArbIrqUnpackRequirements(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _Out_ PUINT64 OutMinimumAddress, _Out_ PUINT64 OutMaximumAddress, _Out_ PUINT64 OutLength, _Out_ PUINT64 OutAlignment)
Definition: arbirq.c:22
NTSTATUS NTAPI IopArbIrqInitialize(VOID)
Initialize the root IRQ arbiter.
Definition: arbirq.c:149
NTSTATUS NTAPI IopArbIrqTranslateOrdering(_Out_ PIO_RESOURCE_DESCRIPTOR OutIoDescriptor, _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Definition: arbirq.c:87
NTSTATUS NTAPI IopArbIrqUnpackResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor, _Out_ PUINT64 Start, _Out_ PUINT64 OutLength)
Definition: arbirq.c:61
NTSTATUS NTAPI ArbiterLibInitializeInstance(_Inout_ PARBITER_INSTANCE Arbiter, _In_ PDEVICE_OBJECT BusDeviceObject, _In_ CM_RESOURCE_TYPE ResourceType, _In_ PCWSTR ArbiterName, _In_ PCWSTR OrderName, _In_ PARB_TRANSLATE_ORDERING TranslateOrderingFunction)
Definition: arbiter.c:349
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
unsigned __int64 * PUINT64
Definition: basetsd.h:181
_Out_ PKIRQL Irql
Definition: csq.h:179
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
ULONG_PTR KAFFINITY
Definition: compat.h:85
#define L(x)
Definition: resources.c:13
NTHALAPI ULONG NTAPI HalGetInterruptVector(INTERFACE_TYPE, ULONG, ULONG, ULONG, PKIRQL, PKAFFINITY)
UCHAR KIRQL
Definition: env_spec_w32.h:591
Status
Definition: gdiplustypes.h:24
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
@ Isa
Definition: restypes.h:122
#define CmResourceTypeInterrupt
Definition: restypes.h:105
#define STATUS_SUCCESS
Definition: shellext.h:65
PARB_UNPACK_RESOURCE UnpackResource
Definition: arbiter.h:260
PARB_SCORE_REQUIREMENT ScoreRequirement
Definition: arbiter.h:261
PARB_UNPACK_REQUIREMENT UnpackRequirement
Definition: arbiter.h:258
PARB_PACK_RESOURCE PackResource
Definition: arbiter.h:259
int32_t INT32
Definition: typedefs.h:58
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG
Definition: typedefs.h:59
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:174