ReactOS 0.4.17-dev-923-g4c9a150
legacypcirqarb.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS HAL
3 * LICENSE: MIT (https://spdx.org/licenses/MIT)
4 * PURPOSE: Legacy HAL IRQ Arbiter
5 * COPYRIGHT: Copyright 2026 Justin Miller <justin.miller@reactos.org>
6 */
7
8#include <hal.h>
9#include <arbiter.h>
10
12
13static
14CODE_SEG("PAGE")
18 _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor,
19 _Out_ PUINT64 OutMinimumAddress,
20 _Out_ PUINT64 OutMaximumAddress,
21 _Out_ PUINT64 OutLength,
22 _Out_ PUINT64 OutAlignment)
23{
24 PAGED_CODE();
25
26 ASSERT(IoDescriptor->Type == CmResourceTypeInterrupt);
27
28 *OutMinimumAddress = (UINT64)IoDescriptor->u.Interrupt.MinimumVector;
29 *OutMaximumAddress = (UINT64)IoDescriptor->u.Interrupt.MaximumVector;
30 *OutLength = 1;
31 *OutAlignment = 1;
32 return STATUS_SUCCESS;
33}
34
35static
36CODE_SEG("PAGE")
40 _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor,
43{
44 PAGED_CODE();
45
46 ASSERT(IoDescriptor->Type == CmResourceTypeInterrupt);
47
48 /* Our vectors live in a ULONG, and the PIR table never goes past 15 anyway. */
49 if (Start > MAXULONG)
51
52 CmDescriptor->Type = CmResourceTypeInterrupt;
53 CmDescriptor->ShareDisposition = IoDescriptor->ShareDisposition;
54 CmDescriptor->Flags = IoDescriptor->Flags;
55 CmDescriptor->u.Interrupt.Level = (ULONG)Start;
56 CmDescriptor->u.Interrupt.Vector = (ULONG)Start;
57 CmDescriptor->u.Interrupt.Affinity = (KAFFINITY)-1;
58 return STATUS_SUCCESS;
59}
60
61static
62CODE_SEG("PAGE")
68 _Out_ PUINT64 OutLength)
69{
70 PAGED_CODE();
71
72 ASSERT(CmDescriptor->Type == CmResourceTypeInterrupt);
73
74 *Start = CmDescriptor->u.Interrupt.Vector;
75 *OutLength = 1;
76 return STATUS_SUCCESS;
77}
78
79static
80CODE_SEG("PAGE")
84 _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
85{
86 INT32 ScoreReg;
87
88 PAGED_CODE();
89
90 ASSERT(IoDescriptor->Type == CmResourceTypeInterrupt);
91
92 ScoreReg = (INT32)(IoDescriptor->u.Interrupt.MaximumVector - IoDescriptor->u.Interrupt.MinimumVector + 1);
93
94 return (ScoreReg < 0) ? MAXLONG : ScoreReg;
95}
96
97static
98VOID
101{
102 NOTHING;
103}
104
105static
106VOID
107NTAPI
109{
110 NOTHING;
111}
112
120CODE_SEG("PAGE")
122NTAPI
124 _In_ PDEVICE_OBJECT BusFdo)
125{
127
128 PAGED_CODE();
129
134
135 /*
136 * TODO: Later we'll override more when we implement PIR.
137 * The most important piece for now here is the clamp.
138 * This will let us boot for now, preserving orignal reactos behavior.
139 * (Plug and Pray)
140 */
141
143 BusFdo,
145 L"HalIRQ",
146 L"Root",
147 NULL);
148 if (!NT_SUCCESS(Status))
149 {
150 return Status;
151 }
152
153 /* Lock to the 0-15 the PIR table only understands. */
158
159 return Status;
160}
161
180CODE_SEG("PAGE")
182NTAPI
187{
188 PARBITER_INTERFACE ArbiterInterface = Interface;
189
190 PAGED_CODE();
191
192 *Length = sizeof(*ArbiterInterface);
193 if (Size < sizeof(*ArbiterInterface))
195
196 ArbiterInterface->Size = sizeof(*ArbiterInterface);
197 ArbiterInterface->Version = 1;
198 ArbiterInterface->Context = &LegacyPCArbiter;
199 ArbiterInterface->ArbiterHandler = ArbiterLibHandler;
200 ArbiterInterface->Flags = 0;
201
204
205 return STATUS_SUCCESS;
206}
#define PAGED_CODE()
#define CODE_SEG(...)
static _Out_opt_ PULONGLONG Start
COMPILER_DEPENDENT_UINT64 UINT64
Definition: actypes.h:131
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:69
#define ARBITER_MAXIMUM_ADDRESS
Definition: arbiter.h:13
NTSTATUS NTAPI ArbiterLibHandler(_In_ PVOID Context, _In_ ARBITER_ACTION Action, _Inout_ PARBITER_PARAMETERS Parameters)
The single ARBITER_ACTION dispatcher every exported ARBITER_INTERFACE points its ArbiterHandler at; C...
Definition: handler.c:164
LONG NTSTATUS
Definition: precomp.h:26
unsigned __int64 * PUINT64
Definition: basetsd.h:181
#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
Status
Definition: gdiplustypes.h:24
#define PIC_CASCADE_IRQ
Definition: halhw.h:156
#define NOTHING
Definition: input_list.c:10
static NTSTATUS NTAPI HalpLegacyPCArbUnpackRequirement(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _Out_ PUINT64 OutMinimumAddress, _Out_ PUINT64 OutMaximumAddress, _Out_ PUINT64 OutLength, _Out_ PUINT64 OutAlignment)
static VOID NTAPI HalpLegacyPCArbDereference(PVOID Context)
static INT32 NTAPI HalpLegacyPCArbScoreRequirement(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
NTSTATUS NTAPI HalpLegacyPCQueryArbInterface(_Out_writes_bytes_(Size) PVOID Interface, _In_ ULONG Size, _Out_ PULONG Length)
Query the legacy PC Arbiter.
static NTSTATUS NTAPI HalpLegacyPCArbUnpackResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor, _Out_ PUINT64 Start, _Out_ PUINT64 OutLength)
static VOID NTAPI HalpLegacyPCArbReference(PVOID Context)
static NTSTATUS NTAPI HalpLegacyPCArbPackResource(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _In_ UINT64 Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor)
NTSTATUS NTAPI HalpLegacyPCCreateArbiter(_In_ PDEVICE_OBJECT BusFdo)
Initialize the legacy PC arbiter that uses PIR for PIC IRQ assignments.
static ARBITER_INSTANCE LegacyPCArbiter
#define ASSERT(a)
Definition: mode.c:44
NTSYSAPI NTSTATUS NTAPI RtlAddRange(_Inout_ PRTL_RANGE_LIST RangeList, _In_ ULONGLONG Start, _In_ ULONGLONG End, _In_ UCHAR Attributes, _In_ ULONG Flags, _In_opt_ PVOID UserData, _In_opt_ PVOID Owner)
#define RTL_RANGE_LIST_ADD_IF_CONFLICT
Definition: rtltypes.h:81
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define _Out_writes_bytes_(s)
Definition: no_sal2.h:178
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define CmResourceTypeInterrupt
Definition: restypes.h:105
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
_In_ PVOID Context
Definition: storport.h:2269
PARB_UNPACK_RESOURCE UnpackResource
Definition: arbiter.h:312
PARB_SCORE_REQUIREMENT ScoreRequirement
Definition: arbiter.h:313
PRTL_RANGE_LIST Allocation
Definition: arbiter.h:302
PARB_UNPACK_REQUIREMENT UnpackRequirement
Definition: arbiter.h:310
PARB_PACK_RESOURCE PackResource
Definition: arbiter.h:311
PINTERFACE_REFERENCE InterfaceReference
Definition: iotypes.h:4661
PARBITER_HANDLER ArbiterHandler
Definition: iotypes.h:4663
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: iotypes.h:4662
#define MAXULONG
Definition: typedefs.h:251
int32_t INT32
Definition: typedefs.h:58
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define MAXLONG
Definition: umtypes.h:116
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465