ReactOS  0.4.13-dev-92-gf251225
routintf.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/routinf.c
5  * PURPOSE: Routing Interface
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 
21 {
22  &GUID_INT_ROUTE_INTERFACE_STANDARD,
27  0,
31 };
32 
33 /* FUNCTIONS ******************************************************************/
34 
36 NTAPI
38 {
40  /* PnP Interfaces don't get Initialized */
41  ASSERTMSG("PCI routeintrf_Initializer, unexpected call.\n", FALSE);
42  return STATUS_UNSUCCESSFUL;
43 }
44 
46 NTAPI
51  IN USHORT Size,
53 {
54  UNREFERENCED_PARAMETER(DeviceExtension);
59 
60  /* Only version 1 is supported */
62 
63  /* Not yet implemented */
66 }
67 
69 NTAPI
73  IN UCHAR InterruptLine,
74  IN UCHAR InterruptPin,
75  IN UCHAR BaseClass,
76  IN UCHAR SubClass,
79  OUT PDEVICE_OBJECT *pFoundDeviceObject)
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 }
155 
156 /* EOF */
#define IN
Definition: typedefs.h:38
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:359
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
UCHAR SubClass
Definition: pci.h:529
struct _INT_ROUTE_INTERFACE_STANDARD INT_ROUTE_INTERFACE_STANDARD
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
NTSTATUS NTAPI routeintrf_Initializer(IN PVOID Instance)
Definition: routintf.c:37
LONG NTSTATUS
Definition: precomp.h:26
UCHAR InterruptPin
Definition: pci.h:527
static int Link(const char **args)
Definition: vfdcmd.c:2414
#define PAGED_CODE()
Definition: video.h:57
#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:5100
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
PDEVICE_OBJECT DeviceObject
Definition: pci.h:523
PPCI_PDO_EXTENSION PdoExtension
Definition: pci.h:532
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
_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
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
#define STATUS_NOINTERFACE
Definition: ntstatus.h:798
UCHAR InterruptLine
Definition: pci.h:526
UCHAR BaseClass
Definition: pci.h:528
struct _PCI_LEGACY_DEVICE * Next
Definition: pci.h:522
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#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
unsigned char UCHAR
Definition: xmlstorage.h:181
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
ULONG SlotNumber
Definition: pci.h:525
unsigned short USHORT
Definition: pedump.c:61
IN PVOID Instance
Definition: pci.h:359
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define OUT
Definition: typedefs.h:39
PCI_INTERFACE PciRoutingInterface
Definition: routintf.c:20
unsigned int ULONG
Definition: retypes.h:1
IN PVOID IN PVOID InterfaceData
Definition: pci.h:359
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
return STATUS_SUCCESS
Definition: btrfs.c:2725
PDEVICE_OBJECT PhysicalDeviceObject
Definition: pci.h:530
PPCI_LEGACY_DEVICE PciLegacyDeviceHead
Definition: routintf.c:18
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: routintf.c:70