ReactOS 0.4.15-dev-8131-g4988de4
pcmcia.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Kernel
4 * FILE: drivers/bus/pcmcia/pcmcia.c
5 * PURPOSE: PCMCIA Bus Driver
6 * PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org)
7 */
8
9#include <pcmcia.h>
10
11//#define NDEBUG
12#include <debug.h>
13
15
17
21 PIRP Irp)
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}
34
36
40 PIRP Irp)
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}
64
65DRIVER_UNLOAD PcmciaUnload;
66
67VOID
70{
72 DPRINT("PCMCIA: Unload\n");
73}
74
76
80 PIRP Irp)
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}
96
98
100NTAPI
102 PIRP Irp)
103{
104 PPCMCIA_COMMON_EXTENSION Common = DeviceObject->DeviceExtension;
107
108 switch (IrpSp->MinorFunction)
109 {
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");
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");
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}
179
180DRIVER_ADD_DEVICE PcmciaAddDevice;
181
183NTAPI
186{
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}
221
223NTAPI
226{
229
231
232 DPRINT1("PCMCIA: DriverEntry\n");
233
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",
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}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
NTSTATUS NTAPI PcmciaFdoPlugPlay(PPCMCIA_FDO_EXTENSION FdoExt, PIRP Irp)
Definition: fdo.c:16
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
DRIVER_INITIALIZE DriverEntry
Definition: condrv.c:21
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
Status
Definition: gdiplustypes.h:25
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
@ dsStopped
Definition: isapnp.h:34
#define ASSERT(a)
Definition: mode.c:44
_In_ PCWSTR _Inout_ _At_ QueryTable _Pre_unknown_ PRTL_QUERY_REGISTRY_TABLE QueryTable
Definition: rtlfuncs.h:4208
DRIVER_DISPATCH(nfs41_FsdDispatch)
#define RTL_QUERY_REGISTRY_REQUIRED
Definition: nt_native.h:132
#define RTL_QUERY_REGISTRY_DIRECT
Definition: nt_native.h:144
#define RTL_REGISTRY_SERVICES
Definition: nt_native.h:162
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
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 IoCompleteRequest
Definition: irp.c:1240
POWER_STATE NTAPI PoSetPowerState(IN PDEVICE_OBJECT DeviceObject, IN POWER_STATE_TYPE Type, IN POWER_STATE State)
Definition: power.c:729
@ PowerDeviceD1
Definition: ntpoapi.h:50
@ PowerDeviceD2
Definition: ntpoapi.h:51
@ PowerDeviceD3
Definition: ntpoapi.h:52
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
#define L(x)
Definition: ntvdm.h:50
DRIVER_DISPATCH PcmciaPlugPlay
Definition: pcmcia.c:75
BOOLEAN IoctlEnabled
Definition: pcmcia.c:14
DRIVER_DISPATCH PcmciaDeviceControl
Definition: pcmcia.c:35
DRIVER_DISPATCH PcmciaPower
Definition: pcmcia.c:97
DRIVER_UNLOAD PcmciaUnload
Definition: pcmcia.c:65
DRIVER_ADD_DEVICE PcmciaAddDevice
Definition: pcmcia.c:180
DRIVER_DISPATCH PcmciaCreateClose
Definition: pcmcia.c:16
NTSTATUS NTAPI PcmciaPdoPlugPlay(PPCMCIA_PDO_EXTENSION PdoExt, PIRP Irp)
Definition: pdo.c:16
NTSTATUS NTAPI PcmciaPdoSetPowerState(PPCMCIA_PDO_EXTENSION PdoExt)
Definition: pdo.c:30
#define FILE_DEVICE_BUS_EXTENDER
Definition: winioctl.h:148
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
struct _IO_STACK_LOCATION::@3983::@4019 Power
struct _IO_STACK_LOCATION::@1568::@1569 DeviceIoControl
union _IO_STACK_LOCATION::@1568 Parameters
PPOWER_SEQUENCE PowerSequence
Definition: iotypes.h:3282
PDEVICE_OBJECT Self
Definition: pcmcia.h:17
PCMCIA_DEVICE_STATE State
Definition: pcmcia.h:20
POWER_SEQUENCE PowerSequence
Definition: pcmcia.h:19
SYSTEM_POWER_STATE SystemPowerState
Definition: pcmcia.h:22
DEVICE_POWER_STATE DevicePowerState
Definition: pcmcia.h:21
KSPIN_LOCK Lock
Definition: pcmcia.h:35
PCMCIA_COMMON_EXTENSION Common
Definition: pcmcia.h:32
PDEVICE_OBJECT Ldo
Definition: pcmcia.h:33
LIST_ENTRY ChildDeviceList
Definition: pcmcia.h:34
ULONG SequenceD2
Definition: iotypes.h:1180
ULONG SequenceD1
Definition: iotypes.h:1179
ULONG SequenceD3
Definition: iotypes.h:1181
#define NTAPI
Definition: typedefs.h:36
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
#define IRP_MN_WAIT_WAKE
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IRP_MN_POWER_SEQUENCE
#define IRP_MN_SET_POWER
#define IRP_MJ_POWER
_In_ SYSTEM_POWER_STATE SystemPowerState
Definition: iotypes.h:7519
#define IRP_MN_QUERY_POWER