ReactOS  0.4.14-dev-41-g31d7680
isapnp.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS ISA PnP Bus driver
3  * FILE: isapnp.c
4  * PURPOSE: Driver entry
5  * PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org)
6  */
7 
8 #include <isapnp.h>
9 
10 #define NDEBUG
11 #include <debug.h>
12 
13 static IO_COMPLETION_ROUTINE ForwardIrpCompletion;
14 
15 static
17 NTAPI
20  IN PIRP Irp,
22 {
23 
25 
26  if (Irp->PendingReturned)
28 
30 }
31 
33 NTAPI
36  IN PIRP Irp)
37 {
38  KEVENT Event;
40 
43 
45 
46  Status = IoCallDriver(FdoExt->Ldo, Irp);
47  if (Status == STATUS_PENDING)
48  {
50  if (NT_SUCCESS(Status))
51  Status = Irp->IoStatus.Status;
52  }
53 
54  return Status;
55 }
56 
58 
59 static
61 NTAPI
64  IN PIRP Irp)
65 {
66  Irp->IoStatus.Status = STATUS_SUCCESS;
67  Irp->IoStatus.Information = FILE_OPENED;
68 
69  DPRINT("%s(%p, %p)\n", __FUNCTION__, DeviceObject, Irp);
70 
72 
73  return STATUS_SUCCESS;
74 }
75 
77 
78 static
80 NTAPI
83  IN PIRP Irp)
84 {
87 
88  DPRINT("%s(%p, %p)\n", __FUNCTION__, DeviceObject, Irp);
89 
90  switch (IrpSp->Parameters.DeviceIoControl.IoControlCode)
91  {
92  default:
93  DPRINT1("Unknown ioctl code: %x\n", IrpSp->Parameters.DeviceIoControl.IoControlCode);
95  break;
96  }
97 
98  Irp->IoStatus.Status = Status;
100 
101  return Status;
102 }
103 
105 
106 static
107 NTSTATUS
108 NTAPI
111  IN PIRP Irp)
112 {
113  DPRINT("%s(%p, %p)\n", __FUNCTION__, DeviceObject, Irp);
114 
115  Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
116  Irp->IoStatus.Information = 0;
117 
119 
120  return STATUS_NOT_SUPPORTED;
121 }
122 
123 static
124 NTSTATUS
125 NTAPI
129 {
130  PDEVICE_OBJECT Fdo;
131  PISAPNP_FDO_EXTENSION FdoExt;
133 
135 
137  sizeof(*FdoExt),
138  NULL,
141  TRUE,
142  &Fdo);
143  if (!NT_SUCCESS(Status))
144  {
145  DPRINT1("Failed to create FDO (0x%x)\n", Status);
146  return Status;
147  }
148 
149  FdoExt = Fdo->DeviceExtension;
150  RtlZeroMemory(FdoExt, sizeof(*FdoExt));
151 
152  FdoExt->Common.Self = Fdo;
153  FdoExt->Common.IsFdo = TRUE;
154  FdoExt->Common.State = dsStopped;
155  FdoExt->Pdo = PhysicalDeviceObject;
156  FdoExt->Ldo = IoAttachDeviceToDeviceStack(Fdo,
158 
160  KeInitializeSpinLock(&FdoExt->Lock);
161 
162  Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
163 
164  return STATUS_SUCCESS;
165 }
166 
168 
169 static
170 NTSTATUS
171 NTAPI
174  IN PIRP Irp)
175 {
178 
179  DPRINT("%s(%p, %p)\n", __FUNCTION__, DeviceObject, Irp);
180 
181  if (DevExt->IsFdo)
182  {
183  return IsaFdoPnp((PISAPNP_FDO_EXTENSION)DevExt,
184  Irp,
185  IrpSp);
186  }
187  else
188  {
189  return IsaPdoPnp((PISAPNP_LOGICAL_DEVICE)DevExt,
190  Irp,
191  IrpSp);
192  }
193 }
194 
195 NTSTATUS
196 NTAPI
200 {
201  DPRINT("%s(%p, %wZ)\n", __FUNCTION__, DriverObject, RegistryPath);
202 
210 
211  return STATUS_SUCCESS;
212 }
213 
214 /* EOF */
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define IN
Definition: typedefs.h:38
#define TRUE
Definition: types.h:120
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:63
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
LIST_ENTRY DeviceListHead
Definition: isapnp.h:27
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_OPENED
Definition: nt_native.h:769
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1114
PDEVICE_OBJECT Pdo
Definition: isapnp.h:26
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
static DRIVER_DISPATCH IsaReadWrite
Definition: isapnp.c:104
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
static NTSTATUS NTAPI IsaAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
Definition: isapnp.c:126
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2820
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
PDRIVER_EXTENSION DriverExtension
Definition: iotypes.h:2174
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
ISAPNP_DEVICE_STATE State
Definition: isapnp.h:20
NTSTATUS NTAPI IsaForwardIrpSynchronous(IN PISAPNP_FDO_EXTENSION FdoExt, IN PIRP Irp)
Definition: isapnp.c:34
KSPIN_LOCK Lock
Definition: isapnp.h:30
static DRIVER_DISPATCH IsaPnp
Definition: isapnp.c:167
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
ISAPNP_COMMON_EXTENSION Common
Definition: isapnp.h:24
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
static IO_COMPLETION_ROUTINE ForwardIrpCompletion
Definition: isapnp.c:13
DRIVER_DISPATCH(nfs41_FsdDispatch)
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PDRIVER_ADD_DEVICE AddDevice
Definition: iotypes.h:2112
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
Definition: isapnp.c:197
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define DPRINT1
Definition: precomp.h:8
#define IRP_MJ_READ
Definition: rdpdr.c:46
NTSTATUS NTAPI IsaPdoPnp(IN PISAPNP_LOGICAL_DEVICE LogDev, IN PIRP Irp, IN PIO_STACK_LOCATION IrpSp)
Definition: pdo.c:40
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: iotypes.h:2181
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define IO_NO_INCREMENT
Definition: iotypes.h:566
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:261
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
static DRIVER_DISPATCH IsaIoctl
Definition: isapnp.c:76
PDEVICE_OBJECT Ldo
Definition: isapnp.h:25
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define FILE_DEVICE_BUS_EXTENDER
Definition: winioctl.h:147
#define __FUNCTION__
Definition: types.h:112
PDEVICE_OBJECT Self
Definition: isapnp.h:18
NTSTATUS NTAPI IsaFdoPnp(IN PISAPNP_FDO_EXTENSION FdoExt, IN PIRP Irp, IN PIO_STACK_LOCATION IrpSp)
Definition: fdo.c:99
static DRIVER_DISPATCH IsaCreateClose
Definition: isapnp.c:57
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52