Synchronize up to trunk's revision r57689.
[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 #define NDEBUG
13 #include <debug.h>
14
15 /* GLOBALS ********************************************************************/
16
17 PCI_INTERFACE TranslatorInterfaceInterrupt =
18 {
19 &GUID_TRANSLATOR_INTERFACE_STANDARD,
20 sizeof(TRANSLATOR_INTERFACE),
21 0,
22 0,
23 PCI_INTERFACE_FDO,
24 0,
25 PciTrans_Interrupt,
26 tranirq_Constructor,
27 tranirq_Initializer
28 };
29
30 /* FUNCTIONS ******************************************************************/
31
32 NTSTATUS
33 NTAPI
34 tranirq_Initializer(IN PVOID Instance)
35 {
36 /* PnP Interfaces don't get Initialized */
37 ASSERTMSG(FALSE, "PCI tranirq_Initializer, unexpected call.");
38 return STATUS_UNSUCCESSFUL;
39 }
40
41 NTSTATUS
42 NTAPI
43 tranirq_Constructor(IN PVOID DeviceExtension,
44 IN PVOID Instance,
45 IN PVOID InterfaceData,
46 IN USHORT Version,
47 IN USHORT Size,
48 IN PINTERFACE Interface)
49 {
50 PPCI_FDO_EXTENSION FdoExtension = (PPCI_FDO_EXTENSION)DeviceExtension;
51 ULONG BaseBus, ParentBus;
52 INTERFACE_TYPE ParentInterface;
53 ASSERT_FDO(FdoExtension);
54
55 /* Make sure it's the right resource type */
56 if ((ULONG)InterfaceData != CmResourceTypeInterrupt)
57 {
58 /* Fail this invalid request */
59 DPRINT1("PCI - IRQ trans constructor doesn't like %x in InterfaceSpecificData\n",
60 InterfaceData);
61 return STATUS_INVALID_PARAMETER_3;
62 }
63
64 /* Get the bus, and use this as the interface-specific data */
65 BaseBus = FdoExtension->BaseBus;
66 InterfaceData = (PVOID)BaseBus;
67
68 /* Check if this is the root bus */
69 if (PCI_IS_ROOT_FDO(FdoExtension))
70 {
71 /* It is, so there is no parent, and it's connected on the system bus */
72 ParentBus = 0;
73 ParentInterface = Internal;
74 DPRINT1(" Is root FDO\n");
75 }
76 else
77 {
78 /* It's not, so we have to get the root bus' bus number instead */
79 #if 0 // when have PDO commit
80 ParentBus = FdoExtension->PhysicalDeviceObject->DeviceExtension->ParentFdoExtension->BaseBus;
81 ParentInterface = PCIBus;
82 DPRINT1(" Is bridge FDO, parent bus %x, secondary bus %x\n",
83 ParentBus, BaseBus);
84 #endif
85 }
86
87 /* Now call the legacy HAL interface to get the correct translator */
88 return HalGetInterruptTranslator(ParentInterface,
89 ParentBus,
90 PCIBus,
91 sizeof(TRANSLATOR_INTERFACE),
92 0,
93 (PTRANSLATOR_INTERFACE)Interface,
94 (PULONG)&InterfaceData);
95 }
96
97 /* EOF */