ReactOS  0.4.15-dev-976-g0f66c66
pdo.c File Reference
#include "serenum.h"
#include <debug.h>
Include dependency graph for pdo.c:

Go to the source code of this file.

Functions

static NTSTATUS SerenumPdoStartDevice (IN PDEVICE_OBJECT DeviceObject)
 
static NTSTATUS SerenumPdoQueryId (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, OUT ULONG_PTR *Information)
 
static NTSTATUS SerenumPdoQueryDeviceRelations (IN PDEVICE_OBJECT DeviceObject, OUT PDEVICE_RELATIONS *pDeviceRelations)
 
NTSTATUS SerenumPdoPnp (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 

Function Documentation

◆ SerenumPdoPnp()

NTSTATUS SerenumPdoPnp ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 109 of file pdo.c.

112 {
114  PIO_STACK_LOCATION Stack;
117 
119  MinorFunction = Stack->MinorFunction;
120 
121  switch (MinorFunction)
122  {
123  /* FIXME: do all these minor functions
124  IRP_MN_QUERY_REMOVE_DEVICE 0x1
125  IRP_MN_REMOVE_DEVICE 0x2
126  IRP_MN_CANCEL_REMOVE_DEVICE 0x3
127  IRP_MN_STOP_DEVICE 0x4
128  IRP_MN_QUERY_STOP_DEVICE 0x5
129  IRP_MN_CANCEL_STOP_DEVICE 0x6
130  IRP_MN_QUERY_DEVICE_RELATIONS / EjectionRelations (optional) 0x7
131  IRP_MN_QUERY_INTERFACE (required or optional) 0x8
132  IRP_MN_READ_CONFIG (required or optional) 0xf
133  IRP_MN_WRITE_CONFIG (required or optional) 0x10
134  IRP_MN_EJECT (required or optional) 0x11
135  IRP_MN_SET_LOCK (required or optional) 0x12
136  IRP_MN_QUERY_ID / BusQueryDeviceID 0x13
137  IRP_MN_QUERY_ID / BusQueryCompatibleIDs (optional) 0x13
138  IRP_MN_QUERY_ID / BusQueryInstanceID (optional) 0x13
139  IRP_MN_QUERY_PNP_DEVICE_STATE (optional) 0x14
140  IRP_MN_DEVICE_USAGE_NOTIFICATION (required or optional) 0x16
141  IRP_MN_SURPRISE_REMOVAL 0x17
142  */
143  case IRP_MN_START_DEVICE: /* 0x0 */
144  {
145  TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
147  break;
148  }
149  case IRP_MN_QUERY_DEVICE_RELATIONS: /* 0x7 */
150  {
151  switch (Stack->Parameters.QueryDeviceRelations.Type)
152  {
153  case RemovalRelations:
154  {
156  }
158  {
159  PDEVICE_RELATIONS DeviceRelations = NULL;
160  TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / TargetDeviceRelation\n");
162  Information = (ULONG_PTR)DeviceRelations;
163  break;
164  }
165  default:
166  {
167  WARN_(SERENUM, "IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
168  Stack->Parameters.QueryDeviceRelations.Type);
169  ASSERT(FALSE);
171  break;
172  }
173  }
174  break;
175  }
176  case IRP_MN_QUERY_CAPABILITIES: /* 0x9 */
177  {
179  ULONG i;
180  TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_QUERY_CAPABILITIES\n");
181 
182  DeviceCapabilities = (PDEVICE_CAPABILITIES)Stack->Parameters.DeviceCapabilities.Capabilities;
183  /* FIXME: capabilities can change with connected device */
184  DeviceCapabilities->LockSupported = FALSE;
185  DeviceCapabilities->EjectSupported = FALSE;
186  DeviceCapabilities->Removable = TRUE;
187  DeviceCapabilities->DockDevice = FALSE;
188  DeviceCapabilities->UniqueID = FALSE;
189  DeviceCapabilities->SilentInstall = FALSE;
190  DeviceCapabilities->RawDeviceOK = TRUE;
191  DeviceCapabilities->SurpriseRemovalOK = TRUE;
192  DeviceCapabilities->HardwareDisabled = FALSE; /* FIXME */
193  //DeviceCapabilities->NoDisplayInUI = FALSE; /* FIXME */
194  DeviceCapabilities->DeviceState[0] = PowerDeviceD0; /* FIXME */
195  for (i = 0; i < PowerSystemMaximum; i++)
196  DeviceCapabilities->DeviceState[i] = PowerDeviceD3; /* FIXME */
197  //DeviceCapabilities->DeviceWake = PowerDeviceUndefined; /* FIXME */
198  DeviceCapabilities->D1Latency = 0; /* FIXME */
199  DeviceCapabilities->D2Latency = 0; /* FIXME */
200  DeviceCapabilities->D3Latency = 0; /* FIXME */
202  break;
203  }
204  case IRP_MN_QUERY_RESOURCES: /* 0xa */
205  {
206  TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_QUERY_RESOURCES\n");
207  /* Serial devices don't need resources, except the ones of
208  * the serial port. This PDO is the serial device PDO, so
209  * report no resource by not changing Information and
210  * Status
211  */
212  Information = Irp->IoStatus.Information;
213  Status = Irp->IoStatus.Status;
214  break;
215  }
216  case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: /* 0xb */
217  {
218  TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n");
219  /* Serial devices don't need resources, except the ones of
220  * the serial port. This PDO is the serial device PDO, so
221  * report no resource by not changing Information and
222  * Status
223  */
224  Information = Irp->IoStatus.Information;
225  Status = Irp->IoStatus.Status;
226  break;
227  }
228  case IRP_MN_QUERY_DEVICE_TEXT: /* 0xc */
229  {
230  switch (Stack->Parameters.QueryDeviceText.DeviceTextType)
231  {
233  {
236  TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / DeviceTextDescription\n");
237 
238  Source = &((PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->DeviceDescription;
240  if (!Description)
242  else
243  {
244  RtlCopyMemory(Description, Source->Buffer, Source->Length);
245  Description[Source->Length / sizeof(WCHAR)] = L'\0';
248  }
249  break;
250  }
252  {
253  /* We don't have any text location to report,
254  * and this query is optional, so ignore it.
255  */
256  Information = Irp->IoStatus.Information;
257  Status = Irp->IoStatus.Status;
258  break;
259  }
260  default:
261  {
262  WARN_(SERENUM, "IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_TEXT / unknown type 0x%lx\n",
263  Stack->Parameters.QueryDeviceText.DeviceTextType);
264  ASSERT(FALSE);
266  }
267  }
268  break;
269  }
271  {
273  }
274  case IRP_MN_QUERY_ID: /* 0x13 */
275  {
277  break;
278  }
279  case IRP_MN_QUERY_BUS_INFORMATION: /* 0x15 */
280  {
281  PPNP_BUS_INFORMATION BusInfo;
282  TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_QUERY_BUS_INFORMATION\n");
283 
285  if (!BusInfo)
287  else
288  {
289  memcpy(
290  &BusInfo->BusTypeGuid,
291  &GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR,
292  sizeof(BusInfo->BusTypeGuid));
293  BusInfo->LegacyBusType = PNPBus;
294  /* We're the only serial bus enumerator on the computer */
295  BusInfo->BusNumber = 0;
296  Information = (ULONG_PTR)BusInfo;
298  }
299  break;
300  }
301  default:
302  {
303  /* We can't forward request to the lower driver, because
304  * we are a Pdo, so we don't have lower driver... */
305  WARN_(SERENUM, "IRP_MJ_PNP / unknown minor function 0x%lx\n", MinorFunction);
306  ASSERT(FALSE);
307  Information = Irp->IoStatus.Information;
308  Status = Irp->IoStatus.Status;
309  }
310  }
311 
312  Irp->IoStatus.Information = Information;
313  Irp->IoStatus.Status = Status;
315  return Status;
316 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define IRP_MN_QUERY_RESOURCES
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define IRP_MN_QUERY_ID
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
uint16_t * PWSTR
Definition: typedefs.h:56
static NTSTATUS SerenumPdoStartDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: pdo.c:15
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS
LONG NTSTATUS
Definition: precomp.h:26
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
static const WCHAR Description[]
Definition: oid.c:1266
#define SERENUM_TAG
Definition: serenum.h:58
Iosb Information
Definition: create.c:4353
uint32_t ULONG_PTR
Definition: typedefs.h:65
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
#define FALSE
Definition: types.h:117
static NTSTATUS SerenumPdoQueryId(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, OUT ULONG_PTR *Information)
Definition: pdo.c:29
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
struct _PNP_BUS_INFORMATION * PPNP_BUS_INFORMATION
#define IoCompleteRequest
Definition: irp.c:1240
#define DeviceCapabilities
Definition: wingdi.h:4448
#define TRACE_(x)
Definition: compat.h:76
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define IRP_MN_START_DEVICE
#define for
Definition: utility.h:88
static NTSTATUS SerenumPdoQueryDeviceRelations(IN PDEVICE_OBJECT DeviceObject, OUT PDEVICE_RELATIONS *pDeviceRelations)
Definition: pdo.c:83
NTSTATUS NTAPI ForwardIrpToAttachedFdoAndForget(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: misc.c:152
#define IRP_MN_QUERY_DEVICE_TEXT
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define IRP_MN_QUERY_BUS_INFORMATION
Status
Definition: gdiplustypes.h:24
static const WCHAR L[]
Definition: oid.c:1250
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
_In_ UCHAR MinorFunction
Definition: pofuncs.h:42
* PDEVICE_CAPABILITIES
Definition: iotypes.h:932
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:570
#define ULONG_PTR
Definition: config.h:101
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2779
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define WARN_(ch,...)
Definition: debug.h:157
INTERFACE_TYPE LegacyBusType
Definition: cmtypes.h:365
#define IRP_MN_QUERY_CAPABILITIES

Referenced by SerenumPnp().

◆ SerenumPdoQueryDeviceRelations()

static NTSTATUS SerenumPdoQueryDeviceRelations ( IN PDEVICE_OBJECT  DeviceObject,
OUT PDEVICE_RELATIONS pDeviceRelations 
)
static

Definition at line 83 of file pdo.c.

86 {
87  PFDO_DEVICE_EXTENSION DeviceExtension;
88  PDEVICE_RELATIONS DeviceRelations;
89 
91  ASSERT(DeviceExtension->Common.IsFDO);
92 
93  DeviceRelations = (PDEVICE_RELATIONS)ExAllocatePoolWithTag(
94  PagedPool,
95  sizeof(DEVICE_RELATIONS),
96  SERENUM_TAG);
97  if (!DeviceRelations)
99 
101  DeviceRelations->Count = 1;
102  DeviceRelations->Objects[0] = DeviceObject;
103 
104  *pDeviceRelations = DeviceRelations;
105  return STATUS_SUCCESS;
106 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2062
#define SERENUM_TAG
Definition: serenum.h:58
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
struct _DEVICE_RELATIONS * PDEVICE_RELATIONS
PVOID DeviceExtension
Definition: env_spec_w32.h:418
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:81
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
#define ObReferenceObject
Definition: obfuncs.h:204
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by SerenumPdoPnp().

◆ SerenumPdoQueryId()

static NTSTATUS SerenumPdoQueryId ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
OUT ULONG_PTR Information 
)
static

Definition at line 29 of file pdo.c.

33 {
34  PPDO_DEVICE_EXTENSION DeviceExtension;
35  ULONG IdType;
39 
43 
44  switch (IdType)
45  {
46  case BusQueryDeviceID:
47  {
48  TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryDeviceID\n");
49  SourceString = &DeviceExtension->DeviceId;
50  break;
51  }
53  {
54  TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryHardwareIDs\n");
55  SourceString = &DeviceExtension->HardwareIds;
56  break;
57  }
59  TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryCompatibleIDs\n");
60  SourceString = &DeviceExtension->CompatibleIds;
61  break;
62  case BusQueryInstanceID:
63  {
64  TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryInstanceID\n");
65  SourceString = &DeviceExtension->InstanceId;
66  break;
67  }
68  default:
69  WARN_(SERENUM, "IRP_MJ_PNP / IRP_MN_QUERY_ID / unknown query id type 0x%lx\n", IdType);
70  ASSERT(FALSE);
71  return STATUS_NOT_SUPPORTED;
72  }
73 
77  &String);
78  *Information = (ULONG_PTR)String.Buffer;
79  return Status;
80 }
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
UNICODE_STRING HardwareIds
Definition: serenum.h:54
static WCHAR String[]
Definition: stringtable.c:55
Iosb Information
Definition: create.c:4353
#define FALSE
Definition: types.h:117
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
_In_ BUS_QUERY_ID_TYPE IdType
Definition: classpnp.h:374
#define TRACE_(x)
Definition: compat.h:76
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
Definition: isapnp.h:82
NTSTATUS DuplicateUnicodeString(IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
Definition: misc.c:72
UNICODE_STRING DeviceId
Definition: serenum.h:52
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1868
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define ULONG_PTR
Definition: config.h:101
UNICODE_STRING CompatibleIds
Definition: serenum.h:55
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2779
#define WARN_(ch,...)
Definition: debug.h:157
UNICODE_STRING InstanceId
Definition: serenum.h:53

Referenced by SerenumPdoPnp().

◆ SerenumPdoStartDevice()

static NTSTATUS SerenumPdoStartDevice ( IN PDEVICE_OBJECT  DeviceObject)
static

Definition at line 15 of file pdo.c.

17 {
18  PPDO_DEVICE_EXTENSION DeviceExtension;
19 
21 
22  ASSERT(DeviceExtension->Common.PnpState == dsStopped);
23 
24  DeviceExtension->Common.PnpState = dsStarted;
25  return STATUS_SUCCESS;
26 }
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
PVOID DeviceExtension
Definition: env_spec_w32.h:418
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:56
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by SerenumPdoPnp().