ReactOS 0.4.17-dev-1190-g4c812f4
agpintrf.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/intrface/agpintrf.c
5 * PURPOSE: AGP Interface
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9/* INCLUDES *******************************************************************/
10
11#include <pci.h>
12
13#include <ntagp.h>
14
15#define NDEBUG
16#include <debug.h>
17
18/* GLOBALS ********************************************************************/
19
21{
22 &GUID_AGP_TARGET_BUS_INTERFACE_STANDARD,
27 0,
31};
32
33/* FUNCTIONS ******************************************************************/
34
35static
36VOID
40{
42
43 InterlockedIncrement(&PdoExtension->AgpInterfaceReferenceCount);
44 ObReferenceObject(PdoExtension->PhysicalDeviceObject);
45}
46
47static
48VOID
52{
54
55 ObDereferenceObject(PdoExtension->PhysicalDeviceObject);
56 InterlockedDecrement(&PdoExtension->AgpInterfaceReferenceCount);
57}
58
62static
67 _Out_ PPCI_PDO_EXTENSION *HostBridge)
68{
72 PAGED_CODE();
73
76
77 for (Child = FdoExtension->ChildPdoList; Child; Child = Child->Next)
78 {
79 if ((Child->BaseClass != PCI_CLASS_BRIDGE_DEV) ||
80 (Child->SubClass != PCI_SUBCLASS_BR_HOST) ||
81 !Child->TargetAgpCapabilityId)
82 {
83 continue;
84 }
85
86 /* More than one candidate leaves no way to pick the right one */
87 if (Found)
88 {
89 Found = NULL;
91 break;
92 }
93
94 Found = Child;
96 }
97
100
101 *HostBridge = Found;
102 return Status;
103}
104
106NTAPI
108{
110 /* PnP Interfaces don't get Initialized */
111 ASSERTMSG("PCI agpintrf_Initializer, unexpected call.\n", FALSE);
112 return STATUS_UNSUCCESSFUL;
113}
114
116NTAPI
119 IN PVOID InterfaceData,
121 IN USHORT Size,
123{
128
130 UNREFERENCED_PARAMETER(InterfaceData);
132 PAGED_CODE();
133
134 /* Only AGP bridges are supported (which are PCI-to-PCI Bridge Devices) */
135 if ((PdoExtension->BaseClass != PCI_CLASS_BRIDGE_DEV) ||
137 {
138 /* Fail any other PDO */
140 }
141
142 /* Without its own target capability the bridge relies on a host bridge beside it */
144 if (!PdoExtension->TargetAgpCapabilityId)
145 {
146 if (!PCI_IS_ROOT_FDO(PdoExtension->ParentFdoExtension))
148
149 Status = agpintrf_FindHostBridge(PdoExtension->ParentFdoExtension, &Target);
150 if (!NT_SUCCESS(Status))
151 return Status;
152 }
153
155 AgpInterface->Size = sizeof(*AgpInterface);
156 AgpInterface->Version = Version;
157 AgpInterface->Context = Target;
162 AgpInterface->CapabilityID = Target->TargetAgpCapabilityId;
163
164 return STATUS_SUCCESS;
165}
166
167/* EOF */
#define PAGED_CODE()
static VOID NTAPI agpintrf_Dereference(_In_ PVOID Context)
Definition: agpintrf.c:50
NTSTATUS NTAPI agpintrf_Constructor(IN PVOID DeviceExtension, IN PVOID Instance, IN PVOID InterfaceData, IN USHORT Version, IN USHORT Size, IN PINTERFACE Interface)
Definition: agpintrf.c:117
static NTSTATUS NTAPI agpintrf_FindHostBridge(_In_ PPCI_FDO_EXTENSION FdoExtension, _Out_ PPCI_PDO_EXTENSION *HostBridge)
Finds the one host bridge on a root bus that has an AGP capability.
Definition: agpintrf.c:65
static VOID NTAPI agpintrf_Reference(_In_ PVOID Context)
Definition: agpintrf.c:38
NTSTATUS NTAPI agpintrf_Initializer(IN PVOID Instance)
Definition: agpintrf.c:107
PCI_INTERFACE AgpTargetInterface
Definition: agpintrf.c:20
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
LONG NTSTATUS
Definition: precomp.h:26
ULONG NTAPI PciBusInterface_GetBusData(IN PVOID Context, IN ULONG WhichSpace, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: busintrf.c:92
ULONG NTAPI PciBusInterface_SetBusData(IN PVOID Context, IN ULONG WhichSpace, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: busintrf.c:112
return Found
Definition: dirsup.c:1270
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define PCI_INTERFACE_PDO
Definition: pci.h:67
struct _PCI_PDO_EXTENSION * PPCI_PDO_EXTENSION
#define PCI_IS_ROOT_FDO(x)
Definition: pci.h:42
@ PciInterface_AgpTarget
Definition: pci.h:147
@ PdoExtension
Definition: precomp.h:61
@ FdoExtension
Definition: precomp.h:60
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
Status
Definition: gdiplustypes.h:24
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
#define KernelMode
Definition: asm.h:38
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
#define AGP_BUS_INTERFACE_V1
Definition: ntagp.h:31
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_SUCCESS
Definition: shellext.h:65
PINTERFACE_REFERENCE InterfaceReference
Definition: iotypes.h:4536
PGET_SET_DEVICE_DATA GetBusData
Definition: iotypes.h:4539
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: iotypes.h:4537
PGET_SET_DEVICE_DATA SetBusData
Definition: iotypes.h:4538
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
_In_ UCXUSBDEVICE _In_ ULONG Interface
Definition: ucxusbdevice.h:428
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_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 _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:536
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_WMI_INSTANCE_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_opt_ WDFWMIINSTANCE * Instance
Definition: wdfwmi.h:481
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define PCI_SUBCLASS_BR_HOST
Definition: iotypes.h:4177
#define PCI_SUBCLASS_BR_PCI_TO_PCI
Definition: iotypes.h:4181
struct _AGP_TARGET_BUS_INTERFACE_STANDARD * PAGP_TARGET_BUS_INTERFACE_STANDARD
#define PCI_CLASS_BRIDGE_DEV
Definition: iotypes.h:4124
struct _AGP_TARGET_BUS_INTERFACE_STANDARD AGP_TARGET_BUS_INTERFACE_STANDARD
@ Executive
Definition: ketypes.h:467
#define ObDereferenceObject
Definition: obfuncs.h:203
#define ObReferenceObject
Definition: obfuncs.h:204