reactos/drivers/bus/pci
diff -u -r1.5 -r1.6
--- fdo.c 12 Dec 2003 21:54:42 -0000 1.5
+++ fdo.c 12 Mar 2004 19:40:05 -0000 1.6
@@ -1,4 +1,4 @@
-/* $Id: fdo.c,v 1.5 2003/12/12 21:54:42 ekohl Exp $
+/* $Id: fdo.c,v 1.6 2004/03/12 19:40:05 navaraf Exp $
*
* PROJECT: ReactOS PCI bus driver
* FILE: fdo.c
@@ -13,7 +13,7 @@
#include "pcidef.h"
#include "pci.h"
-#define NDEBUG
+//#define NDEBUG
#include <debug.h>
/*** PRIVATE *****************************************************************/
@@ -61,6 +61,7 @@
PLIST_ENTRY CurrentEntry;
PPCI_DEVICE Device;
PCI_SLOT_NUMBER SlotNumber;
+ ULONG BusNumber;
ULONG DeviceNumber;
ULONG FunctionNumber;
ULONG Size;
@@ -82,70 +83,75 @@
DeviceExtension->DeviceListCount = 0;
/* Enumerate devices on the PCI bus */
- SlotNumber.u.AsULONG = 0;
- for (DeviceNumber = 0; DeviceNumber < PCI_MAX_DEVICES; DeviceNumber++)
+ for (BusNumber = 0; BusNumber < 8; BusNumber++)
{
- SlotNumber.u.bits.DeviceNumber = DeviceNumber;
- for (FunctionNumber = 0; FunctionNumber < PCI_MAX_FUNCTION; FunctionNumber++)
+ SlotNumber.u.AsULONG = 0;
+ for (DeviceNumber = 0; DeviceNumber < PCI_MAX_DEVICES; DeviceNumber++)
{
- SlotNumber.u.bits.FunctionNumber = FunctionNumber;
-
- Size= HalGetBusData(PCIConfiguration,
- DeviceExtension->BusNumber,
- SlotNumber.u.AsULONG,
- &PciConfig,
- sizeof(PCI_COMMON_CONFIG));
- DPRINT("Size %lu\n", Size);
- if (Size < sizeof(PCI_COMMON_CONFIG))
+ SlotNumber.u.bits.DeviceNumber = DeviceNumber;
+ for (FunctionNumber = 0; FunctionNumber < PCI_MAX_FUNCTION; FunctionNumber++)
{
- if (FunctionNumber == 0)
- {
- break;
- }
- else
+ SlotNumber.u.bits.FunctionNumber = FunctionNumber;
+
+ Size= HalGetBusData(PCIConfiguration,
+ BusNumber,
+ SlotNumber.u.AsULONG,
+ &PciConfig,
+ sizeof(PCI_COMMON_CONFIG));
+ DPRINT("Size %lu\n", Size);
+ if (Size < sizeof(PCI_COMMON_CONFIG))
{
- continue;
+ if (FunctionNumber == 0)
+ {
+ break;
+ }
+ else
+ {
+ continue;
+ }
}
- }
- DPRINT("Bus %1lu Device %2lu Func %1lu VenID 0x%04hx DevID 0x%04hx\n",
- DeviceExtension->BusNumber,
- DeviceNumber,
- FunctionNumber,
- PciConfig.VendorID,
- PciConfig.DeviceID);
+ DPRINT("Bus %1lu Device %2lu Func %1lu VenID 0x%04hx DevID 0x%04hx\n",
+ BusNumber,
+ DeviceNumber,
+ FunctionNumber,
+ PciConfig.VendorID,
+ PciConfig.DeviceID);
- Status = FdoLocateChildDevice(&Device, DeviceExtension, SlotNumber, &PciConfig);
- if (!NT_SUCCESS(Status))
- {
- Device = (PPCI_DEVICE)ExAllocatePool(PagedPool, sizeof(PCI_DEVICE));
- if (!Device)
+ Status = FdoLocateChildDevice(&Device, DeviceExtension, SlotNumber, &PciConfig);
+ if (!NT_SUCCESS(Status))
{
- /* FIXME: Cleanup resources for already discovered devices */
- return STATUS_INSUFFICIENT_RESOURCES;
+ Device = (PPCI_DEVICE)ExAllocatePool(PagedPool, sizeof(PCI_DEVICE));
+ if (!Device)
+ {
+ /* FIXME: Cleanup resources for already discovered devices */
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ RtlZeroMemory (Device,
+ sizeof(PCI_DEVICE));
+
+ Device->BusNumber = BusNumber;
+
+ RtlCopyMemory (&Device->SlotNumber,
+ &SlotNumber,
+ sizeof(PCI_SLOT_NUMBER));
+
+ RtlCopyMemory (&Device->PciConfig,
+ &PciConfig,
+ sizeof(PCI_COMMON_CONFIG));
+
+ ExInterlockedInsertTailList(
+ &DeviceExtension->DeviceListHead,
+ &Device->ListEntry,
+ &DeviceExtension->DeviceListLock);
}
- RtlZeroMemory (Device,
- sizeof(PCI_DEVICE));
+ /* Don't remove this device */
+ Device->RemovePending = FALSE;
- RtlCopyMemory (&Device->SlotNumber,
- &SlotNumber,
- sizeof(PCI_SLOT_NUMBER));
-
- RtlCopyMemory (&Device->PciConfig,
- &PciConfig,
- sizeof(PCI_COMMON_CONFIG));
-
- ExInterlockedInsertTailList(
- &DeviceExtension->DeviceListHead,
- &Device->ListEntry,
- &DeviceExtension->DeviceListLock);
+ DeviceExtension->DeviceListCount++;
}
-
- /* Don't remove this device */
- Device->RemovePending = FALSE;
-
- DeviceExtension->DeviceListCount++;
}
}
@@ -239,6 +245,10 @@
PdoDeviceExtension->Common.DevicePowerState = PowerDeviceD0;
+ PdoDeviceExtension->Fdo = DeviceObject;
+
+ PdoDeviceExtension->BusNumber = Device->BusNumber;
+
/* FIXME: Get device properties (Hardware IDs, etc.) */
swprintf(
@@ -310,10 +320,6 @@
InitializeListHead(&DeviceExtension->DeviceListHead);
KeInitializeSpinLock(&DeviceExtension->DeviceListLock);
DeviceExtension->DeviceListCount = 0;
-
- /* FIXME: Find a way to get this information */
- DeviceExtension->BusNumber = 0;
-
DeviceExtension->State = dsStarted;
//Irp->IoStatus.Information = 0;
reactos/drivers/bus/pci
diff -u -r1.4 -r1.5
--- pci.h 12 Dec 2003 21:54:42 -0000 1.4
+++ pci.h 12 Mar 2004 19:40:05 -0000 1.5
@@ -1,4 +1,4 @@
-/* $Id: pci.h,v 1.4 2003/12/12 21:54:42 ekohl Exp $ */
+/* $Id: pci.h,v 1.5 2004/03/12 19:40:05 navaraf Exp $ */
#ifndef __PCI_H
#define __PCI_H
@@ -17,7 +17,9 @@
LIST_ENTRY ListEntry;
// Physical Device Object of device
PDEVICE_OBJECT Pdo;
- /* PCI Slot number */
+ // PCI bus number
+ ULONG BusNumber;
+ // PCI slot number
PCI_SLOT_NUMBER SlotNumber;
// PCI configuration data
PCI_COMMON_CONFIG PciConfig;
@@ -52,6 +54,10 @@
{
// Common device data
COMMON_DEVICE_EXTENSION Common;
+ // Functional device object
+ PDEVICE_OBJECT Fdo;
+ // PCI bus number
+ ULONG BusNumber;
// Device ID
UNICODE_STRING DeviceID;
// Instance ID
@@ -71,8 +77,6 @@
{
// Common device data
COMMON_DEVICE_EXTENSION Common;
- // Physical Device Object
- PDEVICE_OBJECT Pdo;
// Current state of the driver
PCI_DEVICE_STATE State;
// Namespace device list
@@ -82,7 +86,7 @@
// Lock for namespace device list
KSPIN_LOCK DeviceListLock;
// PCI bus number
- ULONG BusNumber;
+/* ULONG BusNumber;*/
// Lower device object
PDEVICE_OBJECT Ldo;
} __attribute((packed)) FDO_DEVICE_EXTENSION, *PFDO_DEVICE_EXTENSION;
reactos/drivers/bus/pci
diff -u -r1.2 -r1.3
--- pdo.c 12 Dec 2003 21:54:42 -0000 1.2
+++ pdo.c 12 Mar 2004 19:40:05 -0000 1.3
@@ -1,4 +1,4 @@
-/* $Id: pdo.c,v 1.2 2003/12/12 21:54:42 ekohl Exp $
+/* $Id: pdo.c,v 1.3 2004/03/12 19:40:05 navaraf Exp $
*
* PROJECT: ReactOS PCI bus driver
* FILE: pdo.c
@@ -16,6 +16,8 @@
#define NDEBUG
#include <debug.h>
+DEFINE_GUID(GUID_BUS_TYPE_PCI, 0xc8ebdfb0L, 0xb510, 0x11d0, 0x80, 0xe5, 0x00, 0xa0, 0xc9, 0x25, 0x42, 0xe3);
+
/*** PRIVATE *****************************************************************/
NTSTATUS
@@ -76,6 +78,35 @@
NTSTATUS
+PdoQueryBusInformation(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp,
+ PIO_STACK_LOCATION IrpSp)
+{
+ PPDO_DEVICE_EXTENSION DeviceExtension;
+ PFDO_DEVICE_EXTENSION FdoDeviceExtension;
+ PPNP_BUS_INFORMATION BusInformation;
+
+ DPRINT("Called\n");
+
+ DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+ FdoDeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceExtension->Fdo->DeviceExtension;
+ BusInformation = ExAllocatePool(PagedPool, sizeof(PNP_BUS_INFORMATION));
+ Irp->IoStatus.Information = (ULONG_PTR)BusInformation;
+ if (BusInformation != NULL)
+ {
+ BusInformation->BusTypeGuid = GUID_BUS_TYPE_PCI;
+ BusInformation->LegacyBusType = PCIBus;
+ BusInformation->BusNumber = DeviceExtension->BusNumber;
+
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ return STATUS_SUCCESS;
+}
+
+
+NTSTATUS
PdoSetPower(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
@@ -139,10 +170,13 @@
case IRP_MN_EJECT:
break;
+#endif
case IRP_MN_QUERY_BUS_INFORMATION:
+ Status = PdoQueryBusInformation(DeviceObject, Irp, IrpSp);
break;
+#if 0
case IRP_MN_QUERY_CAPABILITIES:
break;