[HAL] Add Xbox Hardware Abstraction Layer
[reactos.git] / hal / halx86 / legacy / bus / pcibus.c
index de10dbd..93ed9cb 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * PROJECT:         ReactOS HAL
  * LICENSE:         GPL - See COPYING in the top level directory
- * FILE:            hal/halx86/generic/bus/pcibus.c
+ * FILE:            hal/halx86/legacy/bus/pcibus.c
  * PURPOSE:         PCI Bus Support (Configuration Space, Resource Allocation)
  * PROGRAMMERS:     Alex Ionescu (alex.ionescu@reactos.org)
  */
 #define NDEBUG
 #include <debug.h>
 
+#if defined(ALLOC_PRAGMA) && !defined(_MINIHAL_)
+#pragma alloc_text(INIT, HalpInitializePciStubs)
+#pragma alloc_text(INIT, HalpQueryPciRegistryInfo)
+#pragma alloc_text(INIT, HalpRegisterPciDebuggingDeviceInfo)
+#pragma alloc_text(INIT, HalpReleasePciDeviceForDebugging)
+#pragma alloc_text(INIT, HalpSetupPciDeviceForDebugging)
+#endif
+
 /* GLOBALS *******************************************************************/
 
 extern BOOLEAN HalpPciLockSettings;
@@ -360,12 +368,12 @@ HalpGetPCIData(IN PBUS_HANDLER BusHandler,
      * video card, so it appears to be present on 1:0:0 - 1:31:0.
      * We hack around these problems by indicating "device not present" for devices
      * 0:0:1, 0:0:2, 1:1:0, 1:2:0, 1:3:0, ...., 1:31:0 */
-    if ((0 == BusHandler->BusNumber && 0 == Slot.u.bits.DeviceNumber &&
-         (1 == Slot.u.bits.FunctionNumber || 2 == Slot.u.bits.FunctionNumber)) ||
-        (1 == BusHandler->BusNumber && 0 != Slot.u.bits.DeviceNumber))
+    if ((BusHandler->BusNumber == 0 && Slot.u.bits.DeviceNumber == 0 &&
+        (Slot.u.bits.FunctionNumber == 1 || Slot.u.bits.FunctionNumber == 2)) ||
+        (BusHandler->BusNumber == 1 && Slot.u.bits.DeviceNumber != 0))
     {
-        DPRINT("Blacklisted PCI slot\n");
-        if (0 == Offset && sizeof(USHORT) <= Length)
+        DPRINT("Blacklisted PCI slot (%d:%d:%d)\n", BusHandler->BusNumber, Slot.u.bits.DeviceNumber, Slot.u.bits.FunctionNumber);
+        if (Offset == 0 && Length >= sizeof(USHORT))
         {
             *(PUSHORT)Buffer = PCI_INVALID_VENDORID;
             return sizeof(USHORT);
@@ -452,11 +460,11 @@ HalpSetPCIData(IN PBUS_HANDLER BusHandler,
      * video card, so it appears to be present on 1:0:0 - 1:31:0.
      * We hack around these problems by indicating "device not present" for devices
      * 0:0:1, 0:0:2, 1:1:0, 1:2:0, 1:3:0, ...., 1:31:0 */
-    if ((0 == BusHandler->BusNumber && 0 == Slot.u.bits.DeviceNumber &&
-         (1 == Slot.u.bits.FunctionNumber || 2 == Slot.u.bits.FunctionNumber)) ||
-        (1 == BusHandler->BusNumber && 0 != Slot.u.bits.DeviceNumber))
+    if ((BusHandler->BusNumber == 0 && Slot.u.bits.DeviceNumber == 0 &&
+        (Slot.u.bits.FunctionNumber == 1 || Slot.u.bits.FunctionNumber == 2)) ||
+        (BusHandler->BusNumber == 1 && Slot.u.bits.DeviceNumber != 0))
     {
-        DPRINT1("Trying to set data on blacklisted PCI slot\n");
+        DPRINT1("Trying to set data on blacklisted PCI slot (%d:%d:%d)\n", BusHandler->BusNumber, Slot.u.bits.DeviceNumber, Slot.u.bits.FunctionNumber);
         return 0;
     }
 #endif
@@ -600,9 +608,9 @@ HalpGetISAFixedPCIIrq(IN PBUS_HANDLER BusHandler,
     return STATUS_SUCCESS;
 }
 
+INIT_FUNCTION
 NTSTATUS
 NTAPI
-INIT_FUNCTION
 HalpSetupPciDeviceForDebugging(IN PVOID LoaderBlock,
                                IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice)
 {
@@ -610,18 +618,18 @@ HalpSetupPciDeviceForDebugging(IN PVOID LoaderBlock,
     return STATUS_NOT_IMPLEMENTED;
 }
 
+INIT_FUNCTION
 NTSTATUS
 NTAPI
-INIT_FUNCTION
 HalpReleasePciDeviceForDebugging(IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice)
 {
     DPRINT1("Unimplemented!\n");
     return STATUS_NOT_IMPLEMENTED;
 }
 
+INIT_FUNCTION
 VOID
 NTAPI
-INIT_FUNCTION
 HalpRegisterPciDebuggingDeviceInfo(VOID)
 {
     BOOLEAN Found = FALSE;
@@ -854,9 +862,9 @@ HaliPciInterfaceReadConfig(IN PBUS_HANDLER RootBusHandler,
     return Length;
 }
 
+INIT_FUNCTION
 PPCI_REGISTRY_INFO_INTERNAL
 NTAPI
-INIT_FUNCTION
 HalpQueryPciRegistryInfo(VOID)
 {
 #ifndef _MINIHAL_
@@ -1087,9 +1095,9 @@ HalpQueryPciRegistryInfo(VOID)
 #endif
 }
 
+INIT_FUNCTION
 VOID
 NTAPI
-INIT_FUNCTION
 HalpInitializePciStubs(VOID)
 {
     PPCI_REGISTRY_INFO_INTERNAL PciRegistryInfo;