ReactOS 0.4.17-dev-806-gffa4164
ar_busno.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS PCI Bus Driver
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: drivers/bus/pci/arb/ar_busno.c
5 * PURPOSE: Bus Number Arbitration
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9/* INCLUDES *******************************************************************/
10
11#include <pci.h>
12
13#define NDEBUG
14#include <debug.h>
15
16/* GLOBALS ********************************************************************/
17
19{
20 &GUID_ARBITER_INTERFACE_STANDARD,
21 sizeof(ARBITER_INTERFACE),
22 0,
23 0,
25 0,
29};
30
31/* FUNCTIONS ******************************************************************/
32
36 _Out_ PULONGLONG Minimum,
37 _Out_ PULONGLONG Maximum,
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}
51
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}
68
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}
82
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}
107
109NTAPI
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}
140
142NTAPI
144 IN PVOID PciInterface,
145 IN PVOID InterfaceData,
147 IN USHORT Size,
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}
168
169/* EOF */
#define PAGED_CODE()
static _Out_opt_ PULONGLONG Start
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_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_UnpackRequirement(_In_ PIO_RESOURCE_DESCRIPTOR Descriptor, _Out_ PULONGLONG Minimum, _Out_ PULONGLONG Maximum, _Out_ PULONGLONG Length, _Out_ PULONGLONG Alignment)
Definition: ar_busno.c:35
PCI_INTERFACE ArbiterInterfaceBusNumber
Definition: ar_busno.c:18
NTSTATUS NTAPI arbusno_UnpackResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Resource, _Out_ PULONGLONG Start, _Out_ PULONGLONG Length)
Definition: ar_busno.c:71
NTSTATUS NTAPI arbusno_Initializer(IN PVOID Instance)
Definition: ar_busno.c:110
NTSTATUS NTAPI PciArbiterConstructor(_In_ PPCI_FDO_EXTENSION FdoExtension, _In_ PCI_SIGNATURE ArbiterType, _Out_ PARBITER_INTERFACE Interface)
Definition: arb_comn.c:48
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
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE Resource
Definition: cdprocs.h:843
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define L(x)
Definition: resources.c:13
#define PCI_INTERFACE_FDO
Definition: pci.h:58
struct _PCI_FDO_EXTENSION * PPCI_FDO_EXTENSION
@ PciArb_BusNumber
Definition: pci.h:104
@ FdoExtension
Definition: precomp.h:48
union Alignment_ Alignment
Status
Definition: gdiplustypes.h:24
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
__GNU_EXTENSION typedef unsigned __int64 * PULONGLONG
Definition: ntbasedef.h:395
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define STATUS_INVALID_PARAMETER_5
Definition: ntstatus.h:573
unsigned short USHORT
Definition: pedump.c:61
#define CmResourceTypeBusNumber
Definition: restypes.h:109
#define STATUS_SUCCESS
Definition: shellext.h:65
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
int32_t INT32
Definition: typedefs.h:58
#define NTAPI
Definition: typedefs.h:36
uint64_t ULONGLONG
Definition: typedefs.h:67
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
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
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_WMI_INSTANCE_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_opt_ WDFWMIINSTANCE * Instance
Definition: wdfwmi.h:481
struct _ARBITER_INTERFACE ARBITER_INTERFACE