ReactOS  0.4.15-dev-1397-g19779b3
pcmcia.c File Reference
#include <pcmcia.h>
#include <debug.h>
Include dependency graph for pcmcia.c:

Go to the source code of this file.

Functions

NTSTATUS NTAPI PcmciaCreateClose (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI PcmciaDeviceControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
VOID NTAPI PcmciaUnload (PDRIVER_OBJECT DriverObject)
 
NTSTATUS NTAPI PcmciaPlugPlay (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI PcmciaPower (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI PcmciaAddDevice (PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT PhysicalDeviceObject)
 
NTSTATUS NTAPI DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
 

Variables

BOOLEAN IoctlEnabled
 
DRIVER_DISPATCH PcmciaCreateClose
 
DRIVER_DISPATCH PcmciaDeviceControl
 
DRIVER_UNLOAD PcmciaUnload
 
DRIVER_DISPATCH PcmciaPlugPlay
 
DRIVER_DISPATCH PcmciaPower
 
DRIVER_ADD_DEVICE PcmciaAddDevice
 

Function Documentation

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( PDRIVER_OBJECT  DriverObject,
PUNICODE_STRING  RegistryPath 
)

Definition at line 224 of file pcmcia.c.

226 {
229 
231 
232  DPRINT1("PCMCIA: DriverEntry\n");
233 
234  DriverObject->MajorFunction[IRP_MJ_CREATE] = PcmciaCreateClose;
235  DriverObject->MajorFunction[IRP_MJ_CLOSE] = PcmciaCreateClose;
237  DriverObject->MajorFunction[IRP_MJ_PNP] = PcmciaPlugPlay;
238  DriverObject->MajorFunction[IRP_MJ_POWER] = PcmciaPower;
239 
240  DriverObject->DriverExtension->AddDevice = PcmciaAddDevice;
241  DriverObject->DriverUnload = PcmciaUnload;
242 
244 
246  QueryTable[0].Name = L"IoctlInterface";
248 
250  L"Pcmcia\\Parameters",
251  QueryTable,
252  NULL,
253  NULL);
254  if (!NT_SUCCESS(Status))
255  {
256  /* Key not present so assume disabled */
258  }
259 
260  DPRINT("PCMCIA: Ioctl interface %s\n",
261  (IoctlEnabled ? "enabled" : "disabled"));
262 
263  return STATUS_SUCCESS;
264 }
_In_ PCWSTR _Inout_ _At_ QueryTable _Pre_unknown_ PRTL_QUERY_REGISTRY_TABLE QueryTable
Definition: rtlfuncs.h:4142
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
DRIVER_DISPATCH PcmciaDeviceControl
Definition: pcmcia.c:35
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:213
DRIVER_DISPATCH PcmciaPower
Definition: pcmcia.c:97
#define RTL_REGISTRY_SERVICES
Definition: nt_native.h:162
DRIVER_UNLOAD PcmciaUnload
Definition: pcmcia.c:65
#define FALSE
Definition: types.h:117
void DPRINT(...)
Definition: polytest.cpp:61
DRIVER_ADD_DEVICE PcmciaAddDevice
Definition: pcmcia.c:180
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
BOOLEAN IoctlEnabled
Definition: pcmcia.c:14
DRIVER_DISPATCH PcmciaPlugPlay
Definition: pcmcia.c:75
#define IRP_MJ_POWER
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
static const WCHAR L[]
Definition: oid.c:1250
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65
#define RTL_QUERY_REGISTRY_REQUIRED
Definition: nt_native.h:132
DRIVER_DISPATCH PcmciaCreateClose
Definition: pcmcia.c:16
#define RTL_QUERY_REGISTRY_DIRECT
Definition: nt_native.h:144
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52

◆ PcmciaAddDevice()

NTSTATUS NTAPI PcmciaAddDevice ( PDRIVER_OBJECT  DriverObject,
PDEVICE_OBJECT  PhysicalDeviceObject 
)

Definition at line 184 of file pcmcia.c.

186 {
187  PPCMCIA_FDO_EXTENSION FdoExt;
190 
191  DPRINT("PCMCIA: AddDevice\n");
192 
194  sizeof(*FdoExt),
195  NULL,
198  FALSE,
199  &Fdo);
200  if (!NT_SUCCESS(Status))
201  return Status;
202 
203  FdoExt = Fdo->DeviceExtension;
204 
205  RtlZeroMemory(FdoExt, sizeof(*FdoExt));
206 
208  KeInitializeSpinLock(&FdoExt->Lock);
209 
210  FdoExt->Common.Self = Fdo;
211  FdoExt->Common.IsFDO = TRUE;
212  FdoExt->Common.State = dsStopped;
213 
216 
217  Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
218 
219  return STATUS_SUCCESS;
220 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
PDEVICE_OBJECT Self
Definition: pcmcia.h:17
#define TRUE
Definition: types.h:120
LIST_ENTRY ChildDeviceList
Definition: pcmcia.h:34
LONG NTSTATUS
Definition: precomp.h:26
KSPIN_LOCK Lock
Definition: pcmcia.h:35
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1155
#define FALSE
Definition: types.h:117
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
void DPRINT(...)
Definition: polytest.cpp:61
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
PCMCIA_COMMON_EXTENSION Common
Definition: pcmcia.h:32
PDEVICE_OBJECT Ldo
Definition: pcmcia.h:33
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
PCMCIA_DEVICE_STATE State
Definition: pcmcia.h:20
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define NULL
Definition: types.h:112
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
#define STATUS_SUCCESS
Definition: shellext.h:65
#define FILE_DEVICE_BUS_EXTENDER
Definition: winioctl.h:147

◆ PcmciaCreateClose()

NTSTATUS NTAPI PcmciaCreateClose ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 20 of file pcmcia.c.

22 {
24 
25  Irp->IoStatus.Status = STATUS_SUCCESS;
26  Irp->IoStatus.Information = 0;
27 
28  DPRINT("PCMCIA: Create/Close\n");
29 
31 
32  return STATUS_SUCCESS;
33 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
#define IO_NO_INCREMENT
Definition: iotypes.h:581
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ PcmciaDeviceControl()

NTSTATUS NTAPI PcmciaDeviceControl ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 39 of file pcmcia.c.

41 {
44 
46 
47  DPRINT("PCMCIA: DeviceIoControl\n");
48 
49  Irp->IoStatus.Information = 0;
50 
51  switch (IrpSp->Parameters.DeviceIoControl.IoControlCode)
52  {
53  default:
54  DPRINT1("PCMCIA: Unknown ioctl code: %x\n", IrpSp->Parameters.DeviceIoControl.IoControlCode);
56  }
57 
58  Irp->IoStatus.Status = Status;
59 
61 
62  return Status;
63 }
return STATUS_NOT_SUPPORTED
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTSTATUS
Definition: precomp.h:26
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
Status
Definition: gdiplustypes.h:24
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define DPRINT1
Definition: precomp.h:8
#define IO_NO_INCREMENT
Definition: iotypes.h:581
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107

◆ PcmciaPlugPlay()

NTSTATUS NTAPI PcmciaPlugPlay ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 79 of file pcmcia.c.

81 {
82  PPCMCIA_COMMON_EXTENSION Common = DeviceObject->DeviceExtension;
83 
84  DPRINT("PCMCIA: PnP\n");
85  if (Common->IsFDO)
86  {
88  Irp);
89  }
90  else
91  {
93  Irp);
94  }
95 }
NTSTATUS NTAPI PcmciaPdoPlugPlay(PPCMCIA_PDO_EXTENSION PdoExt, PIRP Irp)
Definition: pdo.c:16
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS NTAPI PcmciaFdoPlugPlay(PPCMCIA_FDO_EXTENSION FdoExt, PIRP Irp)
Definition: fdo.c:16

◆ PcmciaPower()

NTSTATUS NTAPI PcmciaPower ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 101 of file pcmcia.c.

103 {
104  PPCMCIA_COMMON_EXTENSION Common = DeviceObject->DeviceExtension;
107 
108  switch (IrpSp->MinorFunction)
109  {
110  case IRP_MN_QUERY_POWER:
111  /* I don't see any reason that we should care */
112  DPRINT("PCMCIA: IRP_MN_QUERY_POWER\n");
114  break;
115 
117  DPRINT("PCMCIA: IRP_MN_POWER_SEQUENCE\n");
118  RtlCopyMemory(IrpSp->Parameters.PowerSequence.PowerSequence,
119  &Common->PowerSequence,
120  sizeof(POWER_SEQUENCE));
122  break;
123 
124  case IRP_MN_WAIT_WAKE:
125  /* Not really sure about this */
126  DPRINT("PCMCIA: IRP_MN_WAIT_WAKE\n");
128  break;
129 
130  case IRP_MN_SET_POWER:
131  DPRINT("PCMCIA: IRP_MN_SET_POWER\n");
132  if (IrpSp->Parameters.Power.Type == SystemPowerState)
133  {
134  Common->SystemPowerState = IrpSp->Parameters.Power.State.SystemState;
135 
137  }
138  else
139  {
140  Common->DevicePowerState = IrpSp->Parameters.Power.State.DeviceState;
141 
142  /* Update the POWER_SEQUENCE struct */
143  if (Common->DevicePowerState <= PowerDeviceD1)
144  Common->PowerSequence.SequenceD1++;
145 
146  if (Common->DevicePowerState <= PowerDeviceD2)
147  Common->PowerSequence.SequenceD2++;
148 
149  if (Common->DevicePowerState <= PowerDeviceD3)
150  Common->PowerSequence.SequenceD3++;
151 
152  /* Start the underlying device if we are handling this for a PDO */
153  if (!Common->IsFDO)
155  else
157  }
158 
159  /* Report that we changed state to the Power Manager */
161  IrpSp->Parameters.Power.Type,
162  IrpSp->Parameters.Power.State);
163  break;
164 
165  default:
166  DPRINT1("PCMCIA: Invalid MN code in MJ_POWER handler %x\n", IrpSp->MinorFunction);
167  ASSERT(FALSE);
169  break;
170  }
171 
172  Irp->IoStatus.Status = Status;
173  Irp->IoStatus.Information = 0;
174 
176 
177  return Status;
178 }
DEVICE_POWER_STATE DevicePowerState
Definition: pcmcia.h:21
return STATUS_NOT_SUPPORTED
SYSTEM_POWER_STATE SystemPowerState
Definition: pcmcia.h:22
#define IRP_MN_POWER_SEQUENCE
#define IRP_MN_QUERY_POWER
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
ULONG SequenceD2
Definition: iotypes.h:1163
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
ULONG SequenceD3
Definition: iotypes.h:1164
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:45
#define IRP_MN_SET_POWER
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
NTSTATUS NTAPI PcmciaPdoSetPowerState(PPCMCIA_PDO_EXTENSION PdoExt)
Definition: pdo.c:30
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
ULONG SequenceD1
Definition: iotypes.h:1162
#define DPRINT1
Definition: precomp.h:8
POWER_SEQUENCE PowerSequence
Definition: pcmcia.h:19
#define IO_NO_INCREMENT
Definition: iotypes.h:581
POWER_STATE NTAPI PoSetPowerState(IN PDEVICE_OBJECT DeviceObject, IN POWER_STATE_TYPE Type, IN POWER_STATE State)
Definition: power.c:708
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define IRP_MN_WAIT_WAKE
#define STATUS_SUCCESS
Definition: shellext.h:65
_In_ SYSTEM_POWER_STATE SystemPowerState
Definition: iotypes.h:7498
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107

◆ PcmciaUnload()

VOID NTAPI PcmciaUnload ( PDRIVER_OBJECT  DriverObject)

Definition at line 69 of file pcmcia.c.

70 {
72  DPRINT("PCMCIA: Unload\n");
73 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
void DPRINT(...)
Definition: polytest.cpp:61
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213

Variable Documentation

◆ IoctlEnabled

BOOLEAN IoctlEnabled

Definition at line 14 of file pcmcia.c.

Referenced by DriverEntry().

◆ PcmciaAddDevice

DRIVER_ADD_DEVICE PcmciaAddDevice

Definition at line 180 of file pcmcia.c.

Referenced by DriverEntry().

◆ PcmciaCreateClose

DRIVER_DISPATCH PcmciaCreateClose

Definition at line 16 of file pcmcia.c.

Referenced by DriverEntry().

◆ PcmciaDeviceControl

DRIVER_DISPATCH PcmciaDeviceControl

Definition at line 35 of file pcmcia.c.

Referenced by DriverEntry().

◆ PcmciaPlugPlay

DRIVER_DISPATCH PcmciaPlugPlay

Definition at line 75 of file pcmcia.c.

Referenced by DriverEntry().

◆ PcmciaPower

DRIVER_DISPATCH PcmciaPower

Definition at line 97 of file pcmcia.c.

Referenced by DriverEntry().

◆ PcmciaUnload

DRIVER_UNLOAD PcmciaUnload

Definition at line 65 of file pcmcia.c.

Referenced by DriverEntry().