Sync with trunk r63935.
[reactos.git] / drivers / bus / pcix / arb / tr_irq.c
1 /*
2 * PROJECT: ReactOS PCI Bus Driver
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: drivers/bus/pci/intrface/tr_irq.c
5 * PURPOSE: IRQ Translator 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
18 PCI_INTERFACE TranslatorInterfaceInterrupt =
19 {
20 &GUID_TRANSLATOR_INTERFACE_STANDARD,
21 sizeof(TRANSLATOR_INTERFACE),
22 0,
23 0,
24 PCI_INTERFACE_FDO,
25 0,
26 PciTrans_Interrupt,
27 tranirq_Constructor,
28 tranirq_Initializer
29 };
30
31 /* FUNCTIONS ******************************************************************/
32
33 NTSTATUS
34 NTAPI
35 tranirq_Initializer(IN PVOID Instance)
36 {
37 UNREFERENCED_PARAMETER(Instance);
38 /* PnP Interfaces don't get Initialized */
39 ASSERTMSG("PCI tranirq_Initializer, unexpected call.", FALSE);
40 return STATUS_UNSUCCESSFUL;
41 }
42
43 NTSTATUS
44 NTAPI
45 tranirq_Constructor(IN PVOID DeviceExtension,
46 IN PVOID Instance,
47 IN PVOID InterfaceData,
48 IN USHORT Version,
49 IN USHORT Size,
50 IN PINTERFACE Interface)
51 {
52 PPCI_FDO_EXTENSION FdoExtension = (PPCI_FDO_EXTENSION)DeviceExtension;
53 ULONG BaseBus, ParentBus;
54 INTERFACE_TYPE ParentInterface;
55 ASSERT_FDO(FdoExtension);
56
57 UNREFERENCED_PARAMETER(Instance);
58 UNREFERENCED_PARAMETER(Version);
59 UNREFERENCED_PARAMETER(Size);
60
61 /* Make sure it's the right resource type */
62 if ((ULONG)InterfaceData != CmResourceTypeInterrupt)
63 {
64 /* Fail this invalid request */
65 DPRINT1("PCI - IRQ trans constructor doesn't like %p in InterfaceSpecificData\n",
66 InterfaceData);
67 return STATUS_INVALID_PARAMETER_3;
68 }
69
70 /* Get the bus, and use this as the interface-specific data */
71 BaseBus = FdoExtension->BaseBus;
72 InterfaceData = (PVOID)BaseBus;
73
74 /* Check if this is the root bus */
75 if (PCI_IS_ROOT_FDO(FdoExtension))
76 {
77 /* It is, so there is no parent, and it's connected on the system bus */
78 ParentBus = 0;
79 ParentInterface = Internal;
80 DPRINT1(" Is root FDO\n");
81 }
82 else
83 {
84 /* It's not, so we have to get the root bus' bus number instead */
85 #if 0 // when have PDO commit
86 ParentBus = FdoExtension->PhysicalDeviceObject->DeviceExtension->ParentFdoExtension->BaseBus;
87 ParentInterface = PCIBus;
88 DPRINT1(" Is bridge FDO, parent bus %x, secondary bus %x\n",
89 ParentBus, BaseBus);
90 #endif
91 }
92
93 /* Now call the legacy HAL interface to get the correct translator */
94 return HalGetInterruptTranslator(ParentInterface,
95 ParentBus,
96 PCIBus,
97 sizeof(TRANSLATOR_INTERFACE),
98 0,
99 (PTRANSLATOR_INTERFACE)Interface,
100 (PULONG)&InterfaceData);
101 }
102
103 /* EOF */