[FORMATTING]

Fix indentation. No code changes!

svn path=/trunk/; revision=61084
This commit is contained in:
Eric Kohl 2013-11-23 18:36:05 +00:00
parent 41ccb2555a
commit e5769b0d38
4 changed files with 181 additions and 174 deletions

View file

@ -16,12 +16,12 @@ NTAPI
PcmciaFdoPlugPlay(PPCMCIA_FDO_EXTENSION FdoExt, PcmciaFdoPlugPlay(PPCMCIA_FDO_EXTENSION FdoExt,
PIRP Irp) PIRP Irp)
{ {
UNREFERENCED_PARAMETER(FdoExt); UNREFERENCED_PARAMETER(FdoExt);
UNIMPLEMENTED; UNIMPLEMENTED;
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_NOT_SUPPORTED; return STATUS_NOT_SUPPORTED;
} }

View file

@ -20,16 +20,16 @@ NTAPI
PcmciaCreateClose(PDEVICE_OBJECT DeviceObject, PcmciaCreateClose(PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
{ {
UNREFERENCED_PARAMETER(DeviceObject); UNREFERENCED_PARAMETER(DeviceObject);
Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
DPRINT("PCMCIA: Create/Close\n"); DPRINT("PCMCIA: Create/Close\n");
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
DRIVER_DISPATCH PcmciaDeviceControl; DRIVER_DISPATCH PcmciaDeviceControl;
@ -39,27 +39,27 @@ NTAPI
PcmciaDeviceControl(PDEVICE_OBJECT DeviceObject, PcmciaDeviceControl(PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
{ {
PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp); PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
NTSTATUS Status; NTSTATUS Status;
UNREFERENCED_PARAMETER(DeviceObject); UNREFERENCED_PARAMETER(DeviceObject);
DPRINT("PCMCIA: DeviceIoControl\n"); DPRINT("PCMCIA: DeviceIoControl\n");
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
switch (IrpSp->Parameters.DeviceIoControl.IoControlCode) switch (IrpSp->Parameters.DeviceIoControl.IoControlCode)
{ {
default: default:
DPRINT1("PCMCIA: Unknown ioctl code: %x\n", IrpSp->Parameters.DeviceIoControl.IoControlCode); DPRINT1("PCMCIA: Unknown ioctl code: %x\n", IrpSp->Parameters.DeviceIoControl.IoControlCode);
Status = STATUS_NOT_SUPPORTED; Status = STATUS_NOT_SUPPORTED;
} }
Irp->IoStatus.Status = Status; Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status; return Status;
} }
DRIVER_UNLOAD PcmciaUnload; DRIVER_UNLOAD PcmciaUnload;
@ -68,8 +68,8 @@ VOID
NTAPI NTAPI
PcmciaUnload(PDRIVER_OBJECT DriverObject) PcmciaUnload(PDRIVER_OBJECT DriverObject)
{ {
UNREFERENCED_PARAMETER(DriverObject); UNREFERENCED_PARAMETER(DriverObject);
DPRINT("PCMCIA: Unload\n"); DPRINT("PCMCIA: Unload\n");
} }
DRIVER_DISPATCH PcmciaPlugPlay; DRIVER_DISPATCH PcmciaPlugPlay;
@ -79,19 +79,19 @@ NTAPI
PcmciaPlugPlay(PDEVICE_OBJECT DeviceObject, PcmciaPlugPlay(PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
{ {
PPCMCIA_COMMON_EXTENSION Common = DeviceObject->DeviceExtension; PPCMCIA_COMMON_EXTENSION Common = DeviceObject->DeviceExtension;
DPRINT("PCMCIA: PnP\n"); DPRINT("PCMCIA: PnP\n");
if (Common->IsFDO) if (Common->IsFDO)
{ {
return PcmciaFdoPlugPlay((PPCMCIA_FDO_EXTENSION)Common, return PcmciaFdoPlugPlay((PPCMCIA_FDO_EXTENSION)Common,
Irp); Irp);
} }
else else
{ {
return PcmciaPdoPlugPlay((PPCMCIA_PDO_EXTENSION)Common, return PcmciaPdoPlugPlay((PPCMCIA_PDO_EXTENSION)Common,
Irp); Irp);
} }
} }
DRIVER_DISPATCH PcmciaPower; DRIVER_DISPATCH PcmciaPower;
@ -101,78 +101,80 @@ NTAPI
PcmciaPower(PDEVICE_OBJECT DeviceObject, PcmciaPower(PDEVICE_OBJECT DeviceObject,
PIRP Irp) PIRP Irp)
{ {
PPCMCIA_COMMON_EXTENSION Common = DeviceObject->DeviceExtension; PPCMCIA_COMMON_EXTENSION Common = DeviceObject->DeviceExtension;
PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp); PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
NTSTATUS Status; NTSTATUS Status;
switch (IrpSp->MinorFunction) switch (IrpSp->MinorFunction)
{ {
case IRP_MN_QUERY_POWER: case IRP_MN_QUERY_POWER:
/* I don't see any reason that we should care */ /* I don't see any reason that we should care */
DPRINT("PCMCIA: IRP_MN_QUERY_POWER\n"); DPRINT("PCMCIA: IRP_MN_QUERY_POWER\n");
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
break; break;
case IRP_MN_POWER_SEQUENCE: case IRP_MN_POWER_SEQUENCE:
DPRINT("PCMCIA: IRP_MN_POWER_SEQUENCE\n"); DPRINT("PCMCIA: IRP_MN_POWER_SEQUENCE\n");
RtlCopyMemory(IrpSp->Parameters.PowerSequence.PowerSequence, RtlCopyMemory(IrpSp->Parameters.PowerSequence.PowerSequence,
&Common->PowerSequence, &Common->PowerSequence,
sizeof(POWER_SEQUENCE)); sizeof(POWER_SEQUENCE));
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
break; break;
case IRP_MN_WAIT_WAKE: case IRP_MN_WAIT_WAKE:
/* Not really sure about this */ /* Not really sure about this */
DPRINT("PCMCIA: IRP_MN_WAIT_WAKE\n"); DPRINT("PCMCIA: IRP_MN_WAIT_WAKE\n");
Status = STATUS_NOT_SUPPORTED; Status = STATUS_NOT_SUPPORTED;
break; break;
case IRP_MN_SET_POWER: case IRP_MN_SET_POWER:
DPRINT("PCMCIA: IRP_MN_SET_POWER\n"); DPRINT("PCMCIA: IRP_MN_SET_POWER\n");
if (IrpSp->Parameters.Power.Type == SystemPowerState) if (IrpSp->Parameters.Power.Type == SystemPowerState)
{ {
Common->SystemPowerState = IrpSp->Parameters.Power.State.SystemState; Common->SystemPowerState = IrpSp->Parameters.Power.State.SystemState;
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
} }
else else
{ {
Common->DevicePowerState = IrpSp->Parameters.Power.State.DeviceState; Common->DevicePowerState = IrpSp->Parameters.Power.State.DeviceState;
/* Update the POWER_SEQUENCE struct */ /* Update the POWER_SEQUENCE struct */
if (Common->DevicePowerState <= PowerDeviceD1) if (Common->DevicePowerState <= PowerDeviceD1)
Common->PowerSequence.SequenceD1++; Common->PowerSequence.SequenceD1++;
if (Common->DevicePowerState <= PowerDeviceD2) if (Common->DevicePowerState <= PowerDeviceD2)
Common->PowerSequence.SequenceD2++; Common->PowerSequence.SequenceD2++;
if (Common->DevicePowerState <= PowerDeviceD3) if (Common->DevicePowerState <= PowerDeviceD3)
Common->PowerSequence.SequenceD3++; Common->PowerSequence.SequenceD3++;
/* Start the underlying device if we are handling this for a PDO */ /* Start the underlying device if we are handling this for a PDO */
if (!Common->IsFDO) if (!Common->IsFDO)
Status = PcmciaPdoSetPowerState((PPCMCIA_PDO_EXTENSION)Common); Status = PcmciaPdoSetPowerState((PPCMCIA_PDO_EXTENSION)Common);
else else
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
} }
/* Report that we changed state to the Power Manager */ /* Report that we changed state to the Power Manager */
PoSetPowerState(DeviceObject, IrpSp->Parameters.Power.Type, IrpSp->Parameters.Power.State); PoSetPowerState(DeviceObject,
break; IrpSp->Parameters.Power.Type,
IrpSp->Parameters.Power.State);
break;
default: default:
DPRINT1("PCMCIA: Invalid MN code in MJ_POWER handler %x\n", IrpSp->MinorFunction); DPRINT1("PCMCIA: Invalid MN code in MJ_POWER handler %x\n", IrpSp->MinorFunction);
ASSERT(FALSE); ASSERT(FALSE);
Status = STATUS_INVALID_DEVICE_REQUEST; Status = STATUS_INVALID_DEVICE_REQUEST;
break; break;
} }
Irp->IoStatus.Status = Status; Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status; return Status;
} }
DRIVER_ADD_DEVICE PcmciaAddDevice; DRIVER_ADD_DEVICE PcmciaAddDevice;
@ -182,38 +184,39 @@ NTAPI
PcmciaAddDevice(PDRIVER_OBJECT DriverObject, PcmciaAddDevice(PDRIVER_OBJECT DriverObject,
PDEVICE_OBJECT PhysicalDeviceObject) PDEVICE_OBJECT PhysicalDeviceObject)
{ {
PPCMCIA_FDO_EXTENSION FdoExt; PPCMCIA_FDO_EXTENSION FdoExt;
PDEVICE_OBJECT Fdo; PDEVICE_OBJECT Fdo;
NTSTATUS Status; NTSTATUS Status;
DPRINT("PCMCIA: AddDevice\n"); DPRINT("PCMCIA: AddDevice\n");
Status = IoCreateDevice(DriverObject, Status = IoCreateDevice(DriverObject,
sizeof(*FdoExt), sizeof(*FdoExt),
NULL, NULL,
FILE_DEVICE_BUS_EXTENDER, FILE_DEVICE_BUS_EXTENDER,
FILE_DEVICE_SECURE_OPEN, FILE_DEVICE_SECURE_OPEN,
FALSE, FALSE,
&Fdo); &Fdo);
if (!NT_SUCCESS(Status)) return Status; if (!NT_SUCCESS(Status))
return Status;
FdoExt = Fdo->DeviceExtension; FdoExt = Fdo->DeviceExtension;
RtlZeroMemory(FdoExt, sizeof(*FdoExt)); RtlZeroMemory(FdoExt, sizeof(*FdoExt));
InitializeListHead(&FdoExt->ChildDeviceList); InitializeListHead(&FdoExt->ChildDeviceList);
KeInitializeSpinLock(&FdoExt->Lock); KeInitializeSpinLock(&FdoExt->Lock);
FdoExt->Common.Self = Fdo; FdoExt->Common.Self = Fdo;
FdoExt->Common.IsFDO = TRUE; FdoExt->Common.IsFDO = TRUE;
FdoExt->Common.State = dsStopped; FdoExt->Common.State = dsStopped;
FdoExt->Ldo = IoAttachDeviceToDeviceStack(Fdo, FdoExt->Ldo = IoAttachDeviceToDeviceStack(Fdo,
PhysicalDeviceObject); PhysicalDeviceObject);
Fdo->Flags &= ~DO_DEVICE_INITIALIZING; Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
NTSTATUS NTSTATUS
@ -221,41 +224,41 @@ NTAPI
DriverEntry(PDRIVER_OBJECT DriverObject, DriverEntry(PDRIVER_OBJECT DriverObject,
PUNICODE_STRING RegistryPath) PUNICODE_STRING RegistryPath)
{ {
RTL_QUERY_REGISTRY_TABLE QueryTable[2]; RTL_QUERY_REGISTRY_TABLE QueryTable[2];
NTSTATUS Status; NTSTATUS Status;
UNREFERENCED_PARAMETER(RegistryPath); UNREFERENCED_PARAMETER(RegistryPath);
DPRINT1("PCMCIA: DriverEntry\n"); DPRINT1("PCMCIA: DriverEntry\n");
DriverObject->MajorFunction[IRP_MJ_CREATE] = PcmciaCreateClose; DriverObject->MajorFunction[IRP_MJ_CREATE] = PcmciaCreateClose;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = PcmciaCreateClose; DriverObject->MajorFunction[IRP_MJ_CLOSE] = PcmciaCreateClose;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = PcmciaDeviceControl; DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = PcmciaDeviceControl;
DriverObject->MajorFunction[IRP_MJ_PNP] = PcmciaPlugPlay; DriverObject->MajorFunction[IRP_MJ_PNP] = PcmciaPlugPlay;
DriverObject->MajorFunction[IRP_MJ_POWER] = PcmciaPower; DriverObject->MajorFunction[IRP_MJ_POWER] = PcmciaPower;
DriverObject->DriverExtension->AddDevice = PcmciaAddDevice; DriverObject->DriverExtension->AddDevice = PcmciaAddDevice;
DriverObject->DriverUnload = PcmciaUnload; DriverObject->DriverUnload = PcmciaUnload;
RtlZeroMemory(QueryTable, sizeof(RTL_QUERY_REGISTRY_TABLE) * 2); RtlZeroMemory(QueryTable, sizeof(RTL_QUERY_REGISTRY_TABLE) * 2);
QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED; QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED;
QueryTable[0].Name = L"IoctlInterface"; QueryTable[0].Name = L"IoctlInterface";
QueryTable[0].EntryContext = &IoctlEnabled; QueryTable[0].EntryContext = &IoctlEnabled;
Status = RtlQueryRegistryValues(RTL_REGISTRY_SERVICES, Status = RtlQueryRegistryValues(RTL_REGISTRY_SERVICES,
L"Pcmcia\\Parameters", L"Pcmcia\\Parameters",
QueryTable, QueryTable,
NULL, NULL,
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
/* Key not present so assume disabled */ /* Key not present so assume disabled */
IoctlEnabled = FALSE; IoctlEnabled = FALSE;
} }
DPRINT("PCMCIA: Ioctl interface %s\n", DPRINT("PCMCIA: Ioctl interface %s\n",
(IoctlEnabled ? "enabled" : "disabled")); (IoctlEnabled ? "enabled" : "disabled"));
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }

View file

@ -4,32 +4,36 @@
#include <stdio.h> #include <stdio.h>
#include <ntddk.h> #include <ntddk.h>
typedef enum { typedef enum
dsStopped, {
dsStarted, dsStopped,
dsPaused, dsStarted,
dsRemoved, dsPaused,
dsSurpriseRemoved dsRemoved,
dsSurpriseRemoved
} PCMCIA_DEVICE_STATE; } PCMCIA_DEVICE_STATE;
typedef struct _PCMCIA_COMMON_EXTENSION { typedef struct _PCMCIA_COMMON_EXTENSION
PDEVICE_OBJECT Self; {
BOOLEAN IsFDO; PDEVICE_OBJECT Self;
POWER_SEQUENCE PowerSequence; BOOLEAN IsFDO;
PCMCIA_DEVICE_STATE State; POWER_SEQUENCE PowerSequence;
DEVICE_POWER_STATE DevicePowerState; PCMCIA_DEVICE_STATE State;
SYSTEM_POWER_STATE SystemPowerState; DEVICE_POWER_STATE DevicePowerState;
SYSTEM_POWER_STATE SystemPowerState;
} PCMCIA_COMMON_EXTENSION, *PPCMCIA_COMMON_EXTENSION; } PCMCIA_COMMON_EXTENSION, *PPCMCIA_COMMON_EXTENSION;
typedef struct _PCMCIA_PDO_EXTENSION { typedef struct _PCMCIA_PDO_EXTENSION
PCMCIA_COMMON_EXTENSION Common; {
PCMCIA_COMMON_EXTENSION Common;
} PCMCIA_PDO_EXTENSION, *PPCMCIA_PDO_EXTENSION; } PCMCIA_PDO_EXTENSION, *PPCMCIA_PDO_EXTENSION;
typedef struct _PCMCIA_FDO_EXTENSION { typedef struct _PCMCIA_FDO_EXTENSION
PCMCIA_COMMON_EXTENSION Common; {
PDEVICE_OBJECT Ldo; PCMCIA_COMMON_EXTENSION Common;
LIST_ENTRY ChildDeviceList; PDEVICE_OBJECT Ldo;
KSPIN_LOCK Lock; LIST_ENTRY ChildDeviceList;
KSPIN_LOCK Lock;
} PCMCIA_FDO_EXTENSION, *PPCMCIA_FDO_EXTENSION; } PCMCIA_FDO_EXTENSION, *PPCMCIA_FDO_EXTENSION;
/* pdo.c */ /* pdo.c */

View file

@ -16,23 +16,23 @@ NTAPI
PcmciaPdoPlugPlay(PPCMCIA_PDO_EXTENSION PdoExt, PcmciaPdoPlugPlay(PPCMCIA_PDO_EXTENSION PdoExt,
PIRP Irp) PIRP Irp)
{ {
UNREFERENCED_PARAMETER(PdoExt); UNREFERENCED_PARAMETER(PdoExt);
UNIMPLEMENTED; UNIMPLEMENTED;
IoCompleteRequest(Irp, IO_NO_INCREMENT); IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_NOT_SUPPORTED; return STATUS_NOT_SUPPORTED;
} }
NTSTATUS NTSTATUS
NTAPI NTAPI
PcmciaPdoSetPowerState(PPCMCIA_PDO_EXTENSION PdoExt) PcmciaPdoSetPowerState(PPCMCIA_PDO_EXTENSION PdoExt)
{ {
UNREFERENCED_PARAMETER(PdoExt); UNREFERENCED_PARAMETER(PdoExt);
UNIMPLEMENTED; UNIMPLEMENTED;
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }