ReactOS  0.4.14-dev-55-g2da92ac
routintf.c File Reference
#include <pci.h>
#include <debug.h>
Include dependency graph for routintf.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI routeintrf_Initializer (IN PVOID Instance)
 
NTSTATUS NTAPI routeintrf_Constructor (IN PVOID DeviceExtension, IN PVOID Instance, IN PVOID InterfaceData, IN USHORT Version, IN USHORT Size, IN PINTERFACE Interface)
 
NTSTATUS NTAPI PciCacheLegacyDeviceRouting (IN PDEVICE_OBJECT DeviceObject, IN ULONG BusNumber, IN ULONG SlotNumber, IN UCHAR InterruptLine, IN UCHAR InterruptPin, IN UCHAR BaseClass, IN UCHAR SubClass, IN PDEVICE_OBJECT PhysicalDeviceObject, IN PPCI_PDO_EXTENSION PdoExtension, OUT PDEVICE_OBJECT *pFoundDeviceObject)
 

Variables

PPCI_LEGACY_DEVICE PciLegacyDeviceHead
 
PCI_INTERFACE PciRoutingInterface
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file routintf.c.

Function Documentation

◆ PciCacheLegacyDeviceRouting()

NTSTATUS NTAPI PciCacheLegacyDeviceRouting ( IN PDEVICE_OBJECT  DeviceObject,
IN ULONG  BusNumber,
IN ULONG  SlotNumber,
IN UCHAR  InterruptLine,
IN UCHAR  InterruptPin,
IN UCHAR  BaseClass,
IN UCHAR  SubClass,
IN PDEVICE_OBJECT  PhysicalDeviceObject,
IN PPCI_PDO_EXTENSION  PdoExtension,
OUT PDEVICE_OBJECT pFoundDeviceObject 
)

Definition at line 70 of file routintf.c.

80 {
82  PPCI_LEGACY_DEVICE LegacyDevice;
83  PDEVICE_OBJECT FoundDeviceObject;
84  PAGED_CODE();
85 
86  /* Scan current registered devices */
87  LegacyDevice = PciLegacyDeviceHead;
89  while (LegacyDevice)
90  {
91  /* Find a match */
92  if ((BusNumber == LegacyDevice->BusNumber) &&
93  (SlotNumber == LegacyDevice->SlotNumber))
94  {
95  /* We already know about this routing */
96  break;
97  }
98 
99  /* We know about device already, but for a different location */
100  if (LegacyDevice->DeviceObject == DeviceObject)
101  {
102  /* Free the existing structure, move to the next one */
103  *Link = LegacyDevice->Next;
104  ExFreePoolWithTag(LegacyDevice, 0);
105  LegacyDevice = *Link;
106  }
107  else
108  {
109  /* Keep going */
110  Link = &LegacyDevice->Next;
111  LegacyDevice = LegacyDevice->Next;
112  }
113  }
114 
115  /* Did we find a match? */
116  if (!LegacyDevice)
117  {
118  /* Allocate a new cache structure */
119  LegacyDevice = ExAllocatePoolWithTag(PagedPool,
120  sizeof(PCI_LEGACY_DEVICE),
121  'PciR');
122  if (!LegacyDevice) return STATUS_INSUFFICIENT_RESOURCES;
123 
124  /* Save all the data in it */
125  RtlZeroMemory(LegacyDevice, sizeof(PCI_LEGACY_DEVICE));
126  LegacyDevice->BusNumber = BusNumber;
127  LegacyDevice->SlotNumber = SlotNumber;
128  LegacyDevice->InterruptLine = InterruptLine;
129  LegacyDevice->InterruptPin = InterruptPin;
130  LegacyDevice->BaseClass = BaseClass;
131  LegacyDevice->SubClass = SubClass;
133  LegacyDevice->DeviceObject = DeviceObject;
134  LegacyDevice->PdoExtension = PdoExtension;
135 
136  /* Link it in the list */
137  LegacyDevice->Next = PciLegacyDeviceHead;
138  PciLegacyDeviceHead = LegacyDevice;
139  }
140 
141  /* Check if we found, or created, a matching caching structure */
142  FoundDeviceObject = LegacyDevice->DeviceObject;
143  if (FoundDeviceObject == DeviceObject)
144  {
145  /* Return the device object and success */
146  if (pFoundDeviceObject) *pFoundDeviceObject = DeviceObject;
147  return STATUS_SUCCESS;
148  }
149 
150  /* Otherwise, this is a new device object for this location */
151  LegacyDevice->DeviceObject = DeviceObject;
152  if (pFoundDeviceObject) *pFoundDeviceObject = FoundDeviceObject;
153  return STATUS_SUCCESS;
154 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
UCHAR SubClass
Definition: pci.h:529
UCHAR InterruptPin
Definition: pci.h:527
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1114
static int Link(const char **args)
Definition: vfdcmd.c:2414
#define PAGED_CODE()
Definition: video.h:57
PDEVICE_OBJECT DeviceObject
Definition: pci.h:523
PPCI_PDO_EXTENSION PdoExtension
Definition: pci.h:532
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:156
ULONG BusNumber
Definition: pci.h:524
UCHAR InterruptLine
Definition: pci.h:526
UCHAR BaseClass
Definition: pci.h:528
struct _PCI_LEGACY_DEVICE * Next
Definition: pci.h:522
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG _In_ ULONG SlotNumber
Definition: halfuncs.h:156
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
ULONG SlotNumber
Definition: pci.h:525
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
return STATUS_SUCCESS
Definition: btrfs.c:2966
PDEVICE_OBJECT PhysicalDeviceObject
Definition: pci.h:530
PPCI_LEGACY_DEVICE PciLegacyDeviceHead
Definition: routintf.c:18

Referenced by PciAssignSlotResources().

◆ routeintrf_Constructor()

NTSTATUS NTAPI routeintrf_Constructor ( IN PVOID  DeviceExtension,
IN PVOID  Instance,
IN PVOID  InterfaceData,
IN USHORT  Version,
IN USHORT  Size,
IN PINTERFACE  Interface 
)

Definition at line 47 of file routintf.c.

53 {
54  UNREFERENCED_PARAMETER(DeviceExtension);
59 
60  /* Only version 1 is supported */
62 
63  /* Not yet implemented */
66 }
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:359
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define PCI_INT_ROUTE_INTRF_STANDARD_VER
Definition: iotypes.h:5101
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
#define STATUS_NOINTERFACE
Definition: ntstatus.h:798
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
IN PVOID Instance
Definition: pci.h:359
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
IN PVOID IN PVOID InterfaceData
Definition: pci.h:359

◆ routeintrf_Initializer()

NTSTATUS NTAPI routeintrf_Initializer ( IN PVOID  Instance)

Definition at line 37 of file routintf.c.

38 {
40  /* PnP Interfaces don't get Initialized */
41  ASSERTMSG("PCI routeintrf_Initializer, unexpected call.\n", FALSE);
42  return STATUS_UNSUCCESSFUL;
43 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
IN PVOID Instance
Definition: pci.h:359

Variable Documentation

◆ PciLegacyDeviceHead

PPCI_LEGACY_DEVICE PciLegacyDeviceHead

Definition at line 18 of file routintf.c.

Referenced by PciCacheLegacyDeviceRouting().

◆ PciRoutingInterface

PCI_INTERFACE PciRoutingInterface
Initial value:
=
{
&GUID_INT_ROUTE_INTERFACE_STANDARD,
0,
}
struct _INT_ROUTE_INTERFACE_STANDARD INT_ROUTE_INTERFACE_STANDARD
NTSTATUS NTAPI routeintrf_Initializer(IN PVOID Instance)
Definition: routintf.c:37
#define PCI_INTERFACE_FDO
Definition: pci.h:56
NTSTATUS NTAPI routeintrf_Constructor(IN PVOID DeviceExtension, IN PVOID Instance, IN PVOID InterfaceData, IN USHORT Version, IN USHORT Size, IN PINTERFACE Interface)
Definition: routintf.c:47
#define PCI_INT_ROUTE_INTRF_STANDARD_VER
Definition: iotypes.h:5101

Definition at line 20 of file routintf.c.