PFDO_DEVICE_EXTENSION FdoDeviceExtension;
PPNP_BUS_INFORMATION BusInformation;
+ UNREFERENCED_PARAMETER(IrpSp);
DPRINT("Called\n");
DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
PDEVICE_CAPABILITIES DeviceCapabilities;
ULONG DeviceNumber, FunctionNumber;
+ UNREFERENCED_PARAMETER(Irp);
DPRINT("Called\n");
DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
DeviceCapabilities->UniqueID = FALSE;
DeviceCapabilities->Address = ((DeviceNumber << 16) & 0xFFFF0000) + (FunctionNumber & 0xFFFF);
- DeviceCapabilities->UINumber = (ULONG)-1; /* FIXME */
+ DeviceCapabilities->UINumber = MAXULONG; /* FIXME */
return STATUS_SUCCESS;
}
*Base = BaseValue;
/* Set magic value */
- NewValue = (ULONG)-1;
+ NewValue = MAXULONG;
Size= HalSetBusDataByOffset(PCIConfiguration,
DeviceExtension->PciDevice->BusNumber,
DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
ULONG Length;
ULONG Flags;
+ UNREFERENCED_PARAMETER(IrpSp);
DPRINT("PdoQueryResourceRequirements() called\n");
DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
}
/* Calculate the resource list size */
- ListSize = FIELD_OFFSET(IO_RESOURCE_REQUIREMENTS_LIST, List->Descriptors)
+ ListSize = FIELD_OFFSET(IO_RESOURCE_REQUIREMENTS_LIST, List[0].Descriptors)
+ ResCount * sizeof(IO_RESOURCE_DESCRIPTOR);
DPRINT("ListSize %lu (0x%lx)\n", ListSize, ListSize);
RtlZeroMemory(ResourceList, ListSize);
ResourceList->ListSize = ListSize;
ResourceList->InterfaceType = PCIBus;
- ResourceList->BusNumber = 0;
- ResourceList->SlotNumber = 0;
+ ResourceList->BusNumber = DeviceExtension->PciDevice->BusNumber;
+ ResourceList->SlotNumber = DeviceExtension->PciDevice->SlotNumber.u.AsULONG;
ResourceList->AlternativeLists = 1;
ResourceList->List[0].Version = 1;
DPRINT("PdoQueryResources() called\n");
+ UNREFERENCED_PARAMETER(IrpSp);
DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
/* Get PCI configuration space */
}
/* Calculate the resource list size */
- ListSize = FIELD_OFFSET(CM_RESOURCE_LIST, List->PartialResourceList.PartialDescriptors)
+ ListSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors)
+ ResCount * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
/* Allocate the resource list */
RtlZeroMemory(ResourceList, ListSize);
ResourceList->Count = 1;
ResourceList->List[0].InterfaceType = PCIBus;
- ResourceList->List[0].BusNumber = 0;
+ ResourceList->List[0].BusNumber = DeviceExtension->PciDevice->BusNumber;
PartialList = &ResourceList->List[0].PartialResourceList;
PartialList->Version = 1;
Descriptor->ShareDisposition = CmResourceShareShared;
Descriptor->Flags = CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE;
Descriptor->u.Interrupt.Level = PciConfig.u.type0.InterruptLine;
- Descriptor->u.Interrupt.Vector = 0;
+ Descriptor->u.Interrupt.Vector = PciConfig.u.type0.InterruptLine;
Descriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
}
}
{
NTSTATUS Status;
+ UNREFERENCED_PARAMETER(Irp);
if (RtlCompareMemory(IrpSp->Parameters.QueryInterface.InterfaceType,
&GUID_BUS_INTERFACE_STANDARD, sizeof(GUID)) == sizeof(GUID))
{
return Status;
}
+static NTSTATUS
+PdoStartDevice(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp,
+ PIO_STACK_LOCATION IrpSp)
+{
+ PCM_RESOURCE_LIST RawResList = IrpSp->Parameters.StartDevice.AllocatedResources;
+ PCM_FULL_RESOURCE_DESCRIPTOR RawFullDesc;
+ PCM_PARTIAL_RESOURCE_DESCRIPTOR RawPartialDesc;
+ ULONG i, ii;
+ PPDO_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
+ UCHAR Irq;
+
+ if (!RawResList)
+ return STATUS_SUCCESS;
+
+ /* TODO: Assign the other resources we get to the card */
+
+ for (i = 0; i < RawResList->Count; i++)
+ {
+ RawFullDesc = &RawResList->List[i];
+
+ for (ii = 0; ii < RawFullDesc->PartialResourceList.Count; ii++)
+ {
+ RawPartialDesc = &RawFullDesc->PartialResourceList.PartialDescriptors[ii];
+
+ if (RawPartialDesc->Type == CmResourceTypeInterrupt)
+ {
+ DPRINT1("Assigning IRQ %x to PCI device (%x, %x)\n",
+ RawPartialDesc->u.Interrupt.Vector,
+ DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
+ DeviceExtension->PciDevice->BusNumber);
+
+ Irq = (UCHAR)RawPartialDesc->u.Interrupt.Vector;
+ HalSetBusDataByOffset(PCIConfiguration,
+ DeviceExtension->PciDevice->BusNumber,
+ DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
+ &Irq,
+ 0x3c /* PCI_INTERRUPT_LINE */,
+ sizeof(UCHAR));
+ }
+ }
+ }
+
+ return STATUS_SUCCESS;
+}
static NTSTATUS
PdoReadConfig(
return STATUS_SUCCESS;
}
+static NTSTATUS
+PdoQueryDeviceRelations(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp,
+ PIO_STACK_LOCATION IrpSp)
+{
+ PDEVICE_RELATIONS DeviceRelations;
+
+ /* We only support TargetDeviceRelation for child PDOs */
+ if (IrpSp->Parameters.QueryDeviceRelations.Type != TargetDeviceRelation)
+ return Irp->IoStatus.Status;
+
+ /* We can do this because we only return 1 PDO for TargetDeviceRelation */
+ DeviceRelations = ExAllocatePool(PagedPool, sizeof(*DeviceRelations));
+ if (!DeviceRelations)
+ return STATUS_INSUFFICIENT_RESOURCES;
+
+ DeviceRelations->Count = 1;
+ DeviceRelations->Objects[0] = DeviceObject;
+
+ /* The PnP manager will remove this when it is done with the PDO */
+ ObReferenceObject(DeviceObject);
+
+ Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
+
+ return STATUS_SUCCESS;
+}
static NTSTATUS
PdoSetPower(
PPDO_DEVICE_EXTENSION DeviceExtension;
NTSTATUS Status;
+ UNREFERENCED_PARAMETER(Irp);
DPRINT("Called\n");
DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
IrpSp = IoGetCurrentIrpStackLocation(Irp);
switch (IrpSp->MinorFunction) {
-#if 0
+
case IRP_MN_DEVICE_USAGE_NOTIFICATION:
+ DPRINT("Unimplemented IRP_MN_DEVICE_USAGE_NOTIFICATION received\n");
break;
case IRP_MN_EJECT:
+ DPRINT("Unimplemented IRP_MN_EJECT received\n");
break;
-#endif
case IRP_MN_QUERY_BUS_INFORMATION:
Status = PdoQueryBusInformation(DeviceObject, Irp, IrpSp);
Status = PdoQueryCapabilities(DeviceObject, Irp, IrpSp);
break;
-#if 0
case IRP_MN_QUERY_DEVICE_RELATIONS:
- /* FIXME: Possibly handle for RemovalRelations */
+ Status = PdoQueryDeviceRelations(DeviceObject, Irp, IrpSp);
break;
-#endif
case IRP_MN_QUERY_DEVICE_TEXT:
DPRINT("IRP_MN_QUERY_DEVICE_TEXT received\n");
Status = PdoQueryId(DeviceObject, Irp, IrpSp);
break;
-#if 0
case IRP_MN_QUERY_PNP_DEVICE_STATE:
+ DPRINT("Unimplemented IRP_MN_QUERY_ID received\n");
break;
-#endif
case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
DPRINT("IRP_MN_QUERY_RESOURCE_REQUIREMENTS received\n");
Status = PdoQueryResources(DeviceObject, Irp, IrpSp);
break;
-#if 0
case IRP_MN_SET_LOCK:
+ DPRINT("Unimplemented IRP_MN_SET_LOCK received\n");
break;
-#endif
case IRP_MN_START_DEVICE:
+ Status = PdoStartDevice(DeviceObject, Irp, IrpSp);
+ break;
+
case IRP_MN_QUERY_STOP_DEVICE:
case IRP_MN_CANCEL_STOP_DEVICE:
case IRP_MN_STOP_DEVICE: