mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 17:56:00 +00:00
[PCI]
- Better stub IRP_MJ_POWER handlers. Failing IRP_MN_SET_POWER is illegal! CORE-10117 svn path=/trunk/; revision=69050
This commit is contained in:
parent
813a68a73c
commit
254e6c2c6e
2 changed files with 22 additions and 99 deletions
|
@ -456,33 +456,6 @@ FdoStartDevice(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static NTSTATUS
|
|
||||||
FdoSetPower(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp,
|
|
||||||
PIO_STACK_LOCATION IrpSp)
|
|
||||||
{
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(DeviceObject);
|
|
||||||
UNREFERENCED_PARAMETER(Irp);
|
|
||||||
|
|
||||||
DPRINT("Called\n");
|
|
||||||
|
|
||||||
if (IrpSp->Parameters.Power.Type == DevicePowerState)
|
|
||||||
{
|
|
||||||
/* FIXME: Set device power state for the device */
|
|
||||||
Status = STATUS_UNSUCCESSFUL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Status = STATUS_UNSUCCESSFUL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*** PUBLIC ******************************************************************/
|
/*** PUBLIC ******************************************************************/
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -616,30 +589,16 @@ FdoPowerControl(
|
||||||
* Status
|
* Status
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PIO_STACK_LOCATION IrpSp;
|
PFDO_DEVICE_EXTENSION DeviceExtension;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT("Called\n");
|
DPRINT("Called\n");
|
||||||
|
|
||||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
DeviceExtension = DeviceObject->DeviceExtension;
|
||||||
|
|
||||||
switch (IrpSp->MinorFunction)
|
PoStartNextPowerIrp(Irp);
|
||||||
{
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
case IRP_MN_SET_POWER:
|
Status = PoCallDriver(DeviceExtension->Ldo, Irp);
|
||||||
Status = FdoSetPower(DeviceObject, Irp, IrpSp);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
DPRINT("Unknown IOCTL 0x%X\n", IrpSp->MinorFunction);
|
|
||||||
Status = STATUS_NOT_IMPLEMENTED;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Status != STATUS_PENDING)
|
|
||||||
{
|
|
||||||
Irp->IoStatus.Status = Status;
|
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("Leaving. Status 0x%X\n", Status);
|
DPRINT("Leaving. Status 0x%X\n", Status);
|
||||||
|
|
||||||
|
|
|
@ -202,7 +202,7 @@ PdoReadPciBar(PPDO_DEVICE_EXTENSION DeviceExtension,
|
||||||
{
|
{
|
||||||
ULONG Size;
|
ULONG Size;
|
||||||
ULONG AllOnes;
|
ULONG AllOnes;
|
||||||
|
|
||||||
/* Read the original value */
|
/* Read the original value */
|
||||||
Size = HalGetBusDataByOffset(PCIConfiguration,
|
Size = HalGetBusDataByOffset(PCIConfiguration,
|
||||||
DeviceExtension->PciDevice->BusNumber,
|
DeviceExtension->PciDevice->BusNumber,
|
||||||
|
@ -215,7 +215,7 @@ PdoReadPciBar(PPDO_DEVICE_EXTENSION DeviceExtension,
|
||||||
DPRINT1("Wrong size %lu\n", Size);
|
DPRINT1("Wrong size %lu\n", Size);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write all ones to determine which bits are held to zero */
|
/* Write all ones to determine which bits are held to zero */
|
||||||
AllOnes = MAXULONG;
|
AllOnes = MAXULONG;
|
||||||
Size = HalSetBusDataByOffset(PCIConfiguration,
|
Size = HalSetBusDataByOffset(PCIConfiguration,
|
||||||
|
@ -229,7 +229,7 @@ PdoReadPciBar(PPDO_DEVICE_EXTENSION DeviceExtension,
|
||||||
DPRINT1("Wrong size %lu\n", Size);
|
DPRINT1("Wrong size %lu\n", Size);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the range length */
|
/* Get the range length */
|
||||||
Size = HalGetBusDataByOffset(PCIConfiguration,
|
Size = HalGetBusDataByOffset(PCIConfiguration,
|
||||||
DeviceExtension->PciDevice->BusNumber,
|
DeviceExtension->PciDevice->BusNumber,
|
||||||
|
@ -255,7 +255,7 @@ PdoReadPciBar(PPDO_DEVICE_EXTENSION DeviceExtension,
|
||||||
DPRINT1("Wrong size %lu\n", Size);
|
DPRINT1("Wrong size %lu\n", Size);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,13 +283,13 @@ PdoGetRangeLength(PPDO_DEVICE_EXTENSION DeviceExtension,
|
||||||
ULONGLONG Bar;
|
ULONGLONG Bar;
|
||||||
} NewValue;
|
} NewValue;
|
||||||
ULONG Offset;
|
ULONG Offset;
|
||||||
|
|
||||||
/* Compute the offset of this BAR in PCI config space */
|
/* Compute the offset of this BAR in PCI config space */
|
||||||
Offset = 0x10 + Bar * 4;
|
Offset = 0x10 + Bar * 4;
|
||||||
|
|
||||||
/* Assume this is a 32-bit BAR until we find wrong */
|
/* Assume this is a 32-bit BAR until we find wrong */
|
||||||
*NextBar = Bar + 1;
|
*NextBar = Bar + 1;
|
||||||
|
|
||||||
/* Initialize BAR values to zero */
|
/* Initialize BAR values to zero */
|
||||||
OriginalValue.Bar = 0ULL;
|
OriginalValue.Bar = 0ULL;
|
||||||
NewValue.Bar = 0ULL;
|
NewValue.Bar = 0ULL;
|
||||||
|
@ -301,7 +301,7 @@ PdoGetRangeLength(PPDO_DEVICE_EXTENSION DeviceExtension,
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if this is a memory BAR */
|
/* Check if this is a memory BAR */
|
||||||
if (!(OriginalValue.Bars.Bar0 & PCI_ADDRESS_IO_SPACE))
|
if (!(OriginalValue.Bars.Bar0 & PCI_ADDRESS_IO_SPACE))
|
||||||
{
|
{
|
||||||
|
@ -321,13 +321,13 @@ PdoGetRangeLength(PPDO_DEVICE_EXTENSION DeviceExtension,
|
||||||
*MaximumAddress = 0xFFFFFFFFFFFFFFFFULL;
|
*MaximumAddress = 0xFFFFFFFFFFFFFFFFULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if this is a 64-bit BAR */
|
/* Check if this is a 64-bit BAR */
|
||||||
if ((OriginalValue.Bars.Bar0 & PCI_ADDRESS_MEMORY_TYPE_MASK) == PCI_TYPE_64BIT)
|
if ((OriginalValue.Bars.Bar0 & PCI_ADDRESS_MEMORY_TYPE_MASK) == PCI_TYPE_64BIT)
|
||||||
{
|
{
|
||||||
/* We've now consumed the next BAR too */
|
/* We've now consumed the next BAR too */
|
||||||
*NextBar = Bar + 2;
|
*NextBar = Bar + 2;
|
||||||
|
|
||||||
/* Read the next BAR */
|
/* Read the next BAR */
|
||||||
if (!PdoReadPciBar(DeviceExtension, Offset + 4,
|
if (!PdoReadPciBar(DeviceExtension, Offset + 4,
|
||||||
&OriginalValue.Bars.Bar1,
|
&OriginalValue.Bars.Bar1,
|
||||||
|
@ -354,7 +354,7 @@ PdoGetRangeLength(PPDO_DEVICE_EXTENSION DeviceExtension,
|
||||||
*Flags = 0;
|
*Flags = 0;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
*Base = OriginalValue.Bar & PCI_ADDRESS_MEMORY_ADDRESS_MASK_64;
|
*Base = OriginalValue.Bar & PCI_ADDRESS_MEMORY_ADDRESS_MASK_64;
|
||||||
|
|
||||||
*Length = ~((NewValue.Bar & PCI_ADDRESS_IO_SPACE)
|
*Length = ~((NewValue.Bar & PCI_ADDRESS_IO_SPACE)
|
||||||
|
@ -1490,36 +1490,6 @@ PdoQueryDeviceRelations(
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NTSTATUS
|
|
||||||
PdoSetPower(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp,
|
|
||||||
PIO_STACK_LOCATION IrpSp)
|
|
||||||
{
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(DeviceObject);
|
|
||||||
UNREFERENCED_PARAMETER(Irp);
|
|
||||||
DPRINT("Called\n");
|
|
||||||
|
|
||||||
if (IrpSp->Parameters.Power.Type == DevicePowerState)
|
|
||||||
{
|
|
||||||
Status = STATUS_SUCCESS;
|
|
||||||
|
|
||||||
switch (IrpSp->Parameters.Power.State.SystemState)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
Status = STATUS_UNSUCCESSFUL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Status = STATUS_UNSUCCESSFUL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*** PUBLIC ******************************************************************/
|
/*** PUBLIC ******************************************************************/
|
||||||
|
|
||||||
|
@ -1683,7 +1653,7 @@ PdoPowerControl(
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PIO_STACK_LOCATION IrpSp;
|
PIO_STACK_LOCATION IrpSp;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status = Irp->IoStatus.Status;
|
||||||
|
|
||||||
DPRINT("Called\n");
|
DPRINT("Called\n");
|
||||||
|
|
||||||
|
@ -1691,21 +1661,15 @@ PdoPowerControl(
|
||||||
|
|
||||||
switch (IrpSp->MinorFunction)
|
switch (IrpSp->MinorFunction)
|
||||||
{
|
{
|
||||||
|
case IRP_MN_QUERY_POWER:
|
||||||
case IRP_MN_SET_POWER:
|
case IRP_MN_SET_POWER:
|
||||||
Status = PdoSetPower(DeviceObject, Irp, IrpSp);
|
Status = STATUS_SUCCESS;
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
DPRINT("Unknown IOCTL 0x%X\n", IrpSp->MinorFunction);
|
|
||||||
Status = STATUS_NOT_IMPLEMENTED;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Status != STATUS_PENDING)
|
PoStartNextPowerIrp(Irp);
|
||||||
{
|
Irp->IoStatus.Status = Status;
|
||||||
Irp->IoStatus.Status = Status;
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("Leaving. Status 0x%X\n", Status);
|
DPRINT("Leaving. Status 0x%X\n", Status);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue