ReactOS  0.4.14-dev-991-g696cdc6
fdo.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS ISA PnP Bus driver
3  * FILE: fdo.c
4  * PURPOSE: FDO-specific code
5  * PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org)
6  */
7 
8 #include <isapnp.h>
9 
10 #define NDEBUG
11 #include <debug.h>
12 
14 NTAPI
17  IN PIRP Irp,
19 {
21  KIRQL OldIrql;
22 
25 
26  KeAcquireSpinLock(&FdoExt->Lock, &OldIrql);
27 
29  if (!NT_SUCCESS(Status))
30  {
31  KeReleaseSpinLock(&FdoExt->Lock, OldIrql);
32  return Status;
33  }
34 
35  FdoExt->Common.State = dsStarted;
36 
37  KeReleaseSpinLock(&FdoExt->Lock, OldIrql);
38 
39  return STATUS_SUCCESS;
40 }
41 
43 NTAPI
46  IN PIRP Irp,
48 {
50  PLIST_ENTRY CurrentEntry;
51  PISAPNP_LOGICAL_DEVICE IsaDevice;
52  PDEVICE_RELATIONS DeviceRelations;
53  KIRQL OldIrql;
54  ULONG i = 0;
55 
56  if (IrpSp->Parameters.QueryDeviceRelations.Type != BusRelations)
57  return Irp->IoStatus.Status;
58 
59  KeAcquireSpinLock(&FdoExt->Lock, &OldIrql);
60 
61  Status = IsaHwFillDeviceList(FdoExt);
62  if (!NT_SUCCESS(Status))
63  {
64  KeReleaseSpinLock(&FdoExt->Lock, OldIrql);
65  return Status;
66  }
67 
68  DeviceRelations = ExAllocatePool(NonPagedPool,
69  sizeof(DEVICE_RELATIONS) + sizeof(DEVICE_OBJECT) * (FdoExt->DeviceCount - 1));
70  if (!DeviceRelations)
71  {
72  KeReleaseSpinLock(&FdoExt->Lock, OldIrql);
74  }
75 
76  CurrentEntry = FdoExt->DeviceListHead.Flink;
77  while (CurrentEntry != &FdoExt->DeviceListHead)
78  {
79  IsaDevice = CONTAINING_RECORD(CurrentEntry, ISAPNP_LOGICAL_DEVICE, ListEntry);
80 
81  DeviceRelations->Objects[i++] = IsaDevice->Common.Self;
82 
83  ObReferenceObject(IsaDevice->Common.Self);
84 
85  CurrentEntry = CurrentEntry->Flink;
86  }
87 
88  DeviceRelations->Count = FdoExt->DeviceCount;
89 
90  KeReleaseSpinLock(&FdoExt->Lock, OldIrql);
91 
92  Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
93 
94  return STATUS_SUCCESS;
95 }
96 
98 NTAPI
100  IN PISAPNP_FDO_EXTENSION FdoExt,
101  IN PIRP Irp,
103 {
104  NTSTATUS Status = Irp->IoStatus.Status;
105 
106  switch (IrpSp->MinorFunction)
107  {
108  case IRP_MN_START_DEVICE:
110 
111  if (NT_SUCCESS(Status))
112  Status = IsaFdoStartDevice(FdoExt, Irp, IrpSp);
113 
114  Irp->IoStatus.Status = Status;
115 
117  return Status;
118 
119  case IRP_MN_STOP_DEVICE:
120  FdoExt->Common.State = dsStopped;
121 
123  break;
124 
127 
128  Irp->IoStatus.Status = Status;
129 
131  return Status;
132 
134  DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n");
135  break;
136 
137  default:
138  DPRINT1("Unknown PnP code: %x\n", IrpSp->MinorFunction);
139  break;
140  }
141 
143 
144  return IoCallDriver(FdoExt->Ldo, Irp);
145 }
NTSTATUS NTAPI IsaFdoQueryDeviceRelations(IN PISAPNP_FDO_EXTENSION FdoExt, IN PIRP Irp, IN PIO_STACK_LOCATION IrpSp)
Definition: fdo.c:44
#define IN
Definition: typedefs.h:39
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2055
LONG NTSTATUS
Definition: precomp.h:26
UCHAR KIRQL
Definition: env_spec_w32.h:591
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS NTAPI IsaForwardIrpSynchronous(IN PISAPNP_FDO_EXTENSION FdoExt, IN PIRP Irp)
Definition: isapnp.c:34
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
NTSTATUS NTAPI IsaHwDetectReadDataPort(IN PISAPNP_FDO_EXTENSION FdoExt)
Definition: hardware.c:540
struct _LIST_ENTRY * Flink
Definition: typedefs.h:120
#define IRP_MN_STOP_DEVICE
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define IRP_MN_START_DEVICE
ISAPNP_COMMON_EXTENSION Common
Definition: isapnp.h:35
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
Definition: typedefs.h:118
NTSTATUS NTAPI IsaFdoStartDevice(IN PISAPNP_FDO_EXTENSION FdoExt, IN PIRP Irp, IN PIO_STACK_LOCATION IrpSp)
Definition: fdo.c:15
Status
Definition: gdiplustypes.h:24
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define DPRINT1
Definition: precomp.h:8
#define ObReferenceObject
Definition: obfuncs.h:204
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define ULONG_PTR
Definition: config.h:101
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2938
NTSTATUS NTAPI IsaHwFillDeviceList(IN PISAPNP_FDO_EXTENSION FdoExt)
Definition: hardware.c:579
PDEVICE_OBJECT Self
Definition: isapnp.h:19
NTSTATUS NTAPI IsaFdoPnp(IN PISAPNP_FDO_EXTENSION FdoExt, IN PIRP Irp, IN PIO_STACK_LOCATION IrpSp)
Definition: fdo.c:99