ReactOS 0.4.17-dev-812-ged4f258
ar_busno.c File Reference
#include <pci.h>
#include <debug.h>
Include dependency graph for ar_busno.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI arbusno_UnpackRequirement (_In_ PIO_RESOURCE_DESCRIPTOR Descriptor, _Out_ PULONGLONG Minimum, _Out_ PULONGLONG Maximum, _Out_ PULONGLONG Length, _Out_ PULONGLONG Alignment)
 
NTSTATUS NTAPI arbusno_PackResource (_In_ PIO_RESOURCE_DESCRIPTOR Descriptor, _In_ ULONGLONG Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Resource)
 
NTSTATUS NTAPI arbusno_UnpackResource (_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Resource, _Out_ PULONGLONG Start, _Out_ PULONGLONG Length)
 
INT32 NTAPI arbusno_ScoreRequirement (_In_ PIO_RESOURCE_DESCRIPTOR Descriptor)
 
NTSTATUS NTAPI arbusno_Initializer (IN PVOID Instance)
 
NTSTATUS NTAPI arbusno_Constructor (IN PVOID DeviceExtension, IN PVOID PciInterface, IN PVOID InterfaceData, IN USHORT Version, IN USHORT Size, IN PINTERFACE Interface)
 

Variables

PCI_INTERFACE ArbiterInterfaceBusNumber
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file ar_busno.c.

Function Documentation

◆ arbusno_Constructor()

NTSTATUS NTAPI arbusno_Constructor ( IN PVOID  DeviceExtension,
IN PVOID  PciInterface,
IN PVOID  InterfaceData,
IN USHORT  Version,
IN USHORT  Size,
IN PINTERFACE  Interface 
)

Definition at line 143 of file ar_busno.c.

149{
151 PAGED_CODE();
152
153 UNREFERENCED_PARAMETER(PciInterface);
156
157 /* This one only arbitrates bus numbers */
158 if ((ULONG_PTR)InterfaceData != CmResourceTypeBusNumber)
159 {
161 }
162
163 /* Hand out the instance that was built for this bus */
167}
#define PAGED_CODE()
NTSTATUS NTAPI PciArbiterConstructor(_In_ PPCI_FDO_EXTENSION FdoExtension, _In_ PCI_SIGNATURE ArbiterType, _Out_ PARBITER_INTERFACE Interface)
Definition: arb_comn.c:48
struct _PCI_FDO_EXTENSION * PPCI_FDO_EXTENSION
@ PciArb_BusNumber
Definition: pci.h:104
@ FdoExtension
Definition: precomp.h:48
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
#define STATUS_INVALID_PARAMETER_5
Definition: ntstatus.h:573
#define CmResourceTypeBusNumber
Definition: restypes.h:109
uint32_t ULONG_PTR
Definition: typedefs.h:65
_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
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469

◆ arbusno_Initializer()

NTSTATUS NTAPI arbusno_Initializer ( IN PVOID  Instance)

Definition at line 110 of file ar_busno.c.

111{
115
116 PAGED_CODE();
117
118 RtlZeroMemory(&Arbiter->CommonInstance, sizeof(Arbiter->CommonInstance));
119
120 FdoExtension = Arbiter->BusFdoExtension;
121
126
128 FdoExtension->FunctionalDeviceObject,
130 Arbiter->InstanceName,
131 L"Pci",
132 NULL);
133 if (!NT_SUCCESS(Status))
134 {
135 DPRINT1("arbusno_Initializer: init arbiter return %X\n", Status);
136 }
137
138 return Status;
139}
NTSTATUS NTAPI arbusno_PackResource(_In_ PIO_RESOURCE_DESCRIPTOR Descriptor, _In_ ULONGLONG Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Resource)
Definition: ar_busno.c:54
INT32 NTAPI arbusno_ScoreRequirement(_In_ PIO_RESOURCE_DESCRIPTOR Descriptor)
Definition: ar_busno.c:85
NTSTATUS NTAPI arbusno_UnpackRequirement(_In_ PIO_RESOURCE_DESCRIPTOR Descriptor, _Out_ PULONGLONG Minimum, _Out_ PULONGLONG Maximum, _Out_ PULONGLONG Length, _Out_ PULONGLONG Alignment)
Definition: ar_busno.c:35
NTSTATUS NTAPI arbusno_UnpackResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Resource, _Out_ PULONGLONG Start, _Out_ PULONGLONG Length)
Definition: ar_busno.c:71
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
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#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
PPCI_FDO_EXTENSION BusFdoExtension
Definition: pci.h:411
WCHAR InstanceName[24]
Definition: pci.h:412
ARBITER_INSTANCE CommonInstance
Definition: pci.h:413
PARB_UNPACK_RESOURCE UnpackResource
Definition: arbiter.h:312
PARB_SCORE_REQUIREMENT ScoreRequirement
Definition: arbiter.h:313
PARB_UNPACK_REQUIREMENT UnpackRequirement
Definition: arbiter.h:310
PARB_PACK_RESOURCE PackResource
Definition: arbiter.h:311
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_WMI_INSTANCE_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_opt_ WDFWMIINSTANCE * Instance
Definition: wdfwmi.h:481

◆ arbusno_PackResource()

NTSTATUS NTAPI arbusno_PackResource ( _In_ PIO_RESOURCE_DESCRIPTOR  Descriptor,
_In_ ULONGLONG  Start,
_Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR  Resource 
)

Definition at line 54 of file ar_busno.c.

57{
58 /* Turn the run of bus numbers the engine settled on into a resource */
60
62 Resource->Flags = Descriptor->Flags;
63 Resource->ShareDisposition = Descriptor->ShareDisposition;
64 Resource->u.BusNumber.Start = (ULONG)Start;
65 Resource->u.BusNumber.Length = Descriptor->u.BusNumber.Length;
66 return STATUS_SUCCESS;
67}
static _Out_opt_ PULONGLONG Start
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE Resource
Definition: cdprocs.h:843
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342

Referenced by arbusno_Initializer().

◆ arbusno_ScoreRequirement()

INT32 NTAPI arbusno_ScoreRequirement ( _In_ PIO_RESOURCE_DESCRIPTOR  Descriptor)

Definition at line 85 of file ar_busno.c.

86{
87 ULONGLONG Minimum, Maximum, Length, Alignment;
88
89 /* A requirement this arbiter cannot read is treated as unsatisfiable */
91 &Minimum,
92 &Maximum,
93 &Length,
94 &Alignment)) ||
95 (Maximum < Minimum))
96 {
97 return -1;
98 }
99
100 /*
101 * The score is how many places the run could go, so that the engine places
102 * the most constrained requirements first.
103 */
104 if ((Maximum - Minimum) >= MAXLONG) return MAXLONG;
105 return (INT32)(Maximum - Minimum + 1);
106}
union Alignment_ Alignment
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
int32_t INT32
Definition: typedefs.h:58
uint64_t ULONGLONG
Definition: typedefs.h:67
#define MAXLONG
Definition: umtypes.h:116

Referenced by arbusno_Initializer().

◆ arbusno_UnpackRequirement()

NTSTATUS NTAPI arbusno_UnpackRequirement ( _In_ PIO_RESOURCE_DESCRIPTOR  Descriptor,
_Out_ PULONGLONG  Minimum,
_Out_ PULONGLONG  Maximum,
_Out_ PULONGLONG  Length,
_Out_ PULONGLONG  Alignment 
)

Definition at line 35 of file ar_busno.c.

40{
41 /* This arbiter is only ever handed bus number descriptors */
43
44 /* Bus numbers are counted, not addressed, so they are always unit-aligned */
45 *Minimum = Descriptor->u.BusNumber.MinBusNumber;
46 *Maximum = Descriptor->u.BusNumber.MaxBusNumber;
47 *Length = Descriptor->u.BusNumber.Length;
48 *Alignment = 1;
49 return STATUS_SUCCESS;
50}

Referenced by arbusno_Initializer(), and arbusno_ScoreRequirement().

◆ arbusno_UnpackResource()

NTSTATUS NTAPI arbusno_UnpackResource ( _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR  Resource,
_Out_ PULONGLONG  Start,
_Out_ PULONGLONG  Length 
)

Definition at line 71 of file ar_busno.c.

74{
75 /* Read a previously packed run of bus numbers back out */
77
78 *Start = Resource->u.BusNumber.Start;
79 *Length = Resource->u.BusNumber.Length;
80 return STATUS_SUCCESS;
81}

Referenced by arbusno_Initializer().

Variable Documentation

◆ ArbiterInterfaceBusNumber

PCI_INTERFACE ArbiterInterfaceBusNumber
Initial value:
=
{
&GUID_ARBITER_INTERFACE_STANDARD,
0,
0,
0,
}
NTSTATUS NTAPI arbusno_Constructor(IN PVOID DeviceExtension, IN PVOID PciInterface, IN PVOID InterfaceData, IN USHORT Version, IN USHORT Size, IN PINTERFACE Interface)
Definition: ar_busno.c:143
NTSTATUS NTAPI arbusno_Initializer(IN PVOID Instance)
Definition: ar_busno.c:110
#define PCI_INTERFACE_FDO
Definition: pci.h:58
struct _ARBITER_INTERFACE ARBITER_INTERFACE

Definition at line 18 of file ar_busno.c.