ReactOS 0.4.17-dev-683-g0dafdc5
arbdma.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 DMA 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.Dma.MinimumChannel;
32 *OutMaximumAddress = IoDescriptor->u.Dma.MaximumChannel;
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 = CmResourceTypeDma;
49 CmDescriptor->ShareDisposition = IoDescriptor->ShareDisposition;
50 CmDescriptor->Flags = IoDescriptor->Flags;
51
52 /*
53 * TODO: this is only version gated temporarily,
54 * we need this for USB3 eventually, I marked it for now.
55 */
56#if (NTDDI_VERSION >= NTDDI_WIN8)
57 if (IoDescriptor->Flags & CM_RESOURCE_DMA_V3)
58 {
59 CmDescriptor->u.DmaV3.Channel = IoDescriptor->u.DmaV3.Channel;
60 CmDescriptor->u.DmaV3.RequestLine = IoDescriptor->u.DmaV3.RequestLine;
61 CmDescriptor->u.DmaV3.TransferWidth = (UCHAR)IoDescriptor->u.DmaV3.TransferWidth;
62 return STATUS_SUCCESS;
63 }
64#endif
65
66 CmDescriptor->u.Dma.Channel = (ULONG)Start;
67 CmDescriptor->u.Dma.Port = 0;
68
69 return STATUS_SUCCESS;
70}
71
77 _Out_ PUINT64 OutLength)
78{
79 PAGED_CODE();
80
81 *Start = CmDescriptor->u.Dma.Channel;
82 *OutLength = 1;
83
84 return STATUS_SUCCESS;
85}
86
90 _In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
91{
92 PAGED_CODE();
93 return (INT32)(IoDescriptor->u.Dma.MaximumChannel - IoDescriptor->u.Dma.MinimumChannel);
94}
95
105NTAPI
107{
109
110 PAGED_CODE();
111 IopRootDmaArbiter.Name = L"RootDma";
116
118 NULL,
121 L"Root",
122 NULL);
123 if (!NT_SUCCESS(Status))
124 {
125 DPRINT1("IopArbDmaInitialize: Failed with %X", Status);
126 }
127
128 return Status;
129}
#define PAGED_CODE()
static _Out_opt_ PULONGLONG Start
COMPILER_DEPENDENT_UINT64 UINT64
Definition: actypes.h:131
NTSTATUS NTAPI IopArbDmaInitialize(VOID)
Initialize the RootDmaArbiter.
Definition: arbdma.c:106
INT32 NTAPI IopArbDmaScoreRequirement(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Definition: arbdma.c:89
NTSTATUS NTAPI IopArbDmaPackResource(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _In_ UINT64 Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor)
Definition: arbdma.c:41
NTSTATUS NTAPI IopArbDmaUnpackResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor, _Out_ PUINT64 Start, _Out_ PUINT64 OutLength)
Definition: arbdma.c:74
NTSTATUS NTAPI IopArbDmaUnpackRequirements(_In_ PIO_RESOURCE_DESCRIPTOR IoDescriptor, _Out_ PUINT64 OutMinimumAddress, _Out_ PUINT64 OutMaximumAddress, _Out_ PUINT64 OutLength, _Out_ PUINT64 OutAlignment)
Definition: arbdma.c:22
ARBITER_INSTANCE IopRootDmaArbiter
Definition: pnpinit.c:25
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
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define L(x)
Definition: resources.c:13
Status
Definition: gdiplustypes.h:24
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define CmResourceTypeDma
Definition: restypes.h:107
#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
unsigned char UCHAR
Definition: typedefs.h:53
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define CM_RESOURCE_DMA_V3
Definition: cmtypes.h:300