ReactOS  0.4.15-dev-1177-g6cb3b62
fdo.c File Reference
#include "parport.h"
Include dependency graph for fdo.c:

Go to the source code of this file.

Functions

NTSTATUS NTAPI AddDeviceInternal (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT Pdo, IN PULONG pLptPortNumber OPTIONAL, OUT PDEVICE_OBJECT *pFdo OPTIONAL)
 
NTSTATUS NTAPI FdoStartDevice (IN PDEVICE_OBJECT DeviceObject, IN PCM_RESOURCE_LIST ResourceList, IN PCM_RESOURCE_LIST ResourceListTranslated)
 
static NTSTATUS FdoCreateRawParallelPdo (IN PDEVICE_OBJECT DeviceObject)
 
static NTSTATUS FdoQueryBusRelations (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
 
NTSTATUS NTAPI AddDevice (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT Pdo)
 
NTSTATUS NTAPI FdoCreate (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI FdoClose (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI FdoCleanup (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI FdoRead (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI FdoWrite (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI FdoPnp (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI FdoPower (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 

Function Documentation

◆ AddDevice()

NTSTATUS NTAPI AddDevice ( IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  Pdo 
)

Definition at line 388 of file fdo.c.

390 {
391  DPRINT("AddDevice(%p %p)\n", DriverObject, Pdo);
392 
393  /* Serial.sys is a legacy driver. AddDevice is called once
394  * with a NULL Pdo just after the driver initialization.
395  * Detect this case and return success.
396  */
397  if (Pdo == NULL)
398  return STATUS_SUCCESS;
399 
400  /* We have here a PDO not null. It represents a real serial
401  * port. So call the internal AddDevice function.
402  */
404 }
_In_ PDEVICE_OBJECT Pdo
Definition: classpnp.h:318
smooth NULL
Definition: ftsmooth.c:416
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS NTAPI AddDeviceInternal(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT Pdo, IN PULONG pLptPortNumber OPTIONAL, OUT PDEVICE_OBJECT *pFdo OPTIONAL)
Definition: fdo.c:14
return STATUS_SUCCESS
Definition: btrfs.c:3014

◆ AddDeviceInternal()

NTSTATUS NTAPI AddDeviceInternal ( IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  Pdo,
IN PULONG pLptPortNumber  OPTIONAL,
OUT PDEVICE_OBJECT *pFdo  OPTIONAL 
)

Definition at line 14 of file fdo.c.

18 {
19  PFDO_DEVICE_EXTENSION DeviceExtension = NULL;
20  PDEVICE_OBJECT Fdo = NULL;
21  WCHAR DeviceNameBuffer[32];
24 
25  DPRINT("AddDeviceInternal()\n");
26 
28  ASSERT(Pdo);
29 
30  /* Create new device object */
31  swprintf(DeviceNameBuffer,
32  L"\\Device\\ParallelPort%lu",
33  IoGetConfigurationInformation()->ParallelCount);
35  DeviceNameBuffer);
36 
38  sizeof(FDO_DEVICE_EXTENSION),
39  &DeviceName,
42  FALSE,
43  &Fdo);
44  if (!NT_SUCCESS(Status))
45  {
46  DPRINT1("IoCreateDevice() failed (Status 0x%08lx)\n", Status);
47  Fdo = NULL;
48  goto done;
49  }
50 
51  DeviceExtension = (PFDO_DEVICE_EXTENSION)Fdo->DeviceExtension;
52  RtlZeroMemory(DeviceExtension,
53  sizeof(FDO_DEVICE_EXTENSION));
54 
55  DeviceExtension->Common.IsFDO = TRUE;
56  DeviceExtension->Common.PnpState = dsStopped;
57 
59  DeviceExtension->Pdo = Pdo;
60 
62  Pdo,
63  &DeviceExtension->LowerDevice);
64  if (!NT_SUCCESS(Status))
65  {
66  DPRINT1("IoAttachDeviceToDeviceStackSafe() failed (Status 0x%08lx)\n", Status);
67  goto done;
68  }
69 
70  if (DeviceExtension->LowerDevice->Flags & DO_POWER_PAGABLE)
71  Fdo->Flags |= DO_POWER_PAGABLE;
72 
73  if (DeviceExtension->LowerDevice->Flags & DO_BUFFERED_IO)
74  Fdo->Flags |= DO_BUFFERED_IO;
75 
76  if (DeviceExtension->LowerDevice->Flags & DO_DIRECT_IO)
77  Fdo->Flags |= DO_DIRECT_IO;
78 
79  /* Choose default strategy */
80  if ((Fdo->Flags & (DO_BUFFERED_IO | DO_DIRECT_IO)) == 0)
81  Fdo->Flags |= DO_BUFFERED_IO;
82 
84 
85  if (pFdo)
86  {
87  *pFdo = Fdo;
88  }
89 
90  return STATUS_SUCCESS;
91 
92 done:
93  if (Fdo)
94  {
95  IoDeleteDevice(Fdo);
96  }
97 
98  return Status;
99 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define DO_POWER_PAGABLE
_In_ PDEVICE_OBJECT Pdo
Definition: classpnp.h:318
PCONFIGURATION_INFORMATION NTAPI IoGetConfigurationInformation(VOID)
Definition: iorsrce.c:830
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
WCHAR DeviceName[]
Definition: adapter.cpp:21
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
#define FALSE
Definition: types.h:117
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
void DPRINT(...)
Definition: polytest.cpp:61
__wchar_t WCHAR
Definition: xmlstorage.h:180
NTSTATUS NTAPI IoAttachDeviceToDeviceStackSafe(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice, IN OUT PDEVICE_OBJECT *AttachedToDeviceObject)
Definition: device.c:980
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define FILE_DEVICE_PARALLEL_PORT
Definition: winioctl.h:127
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
static const WCHAR L[]
Definition: oid.c:1250
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:81
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define DPRINT1
Definition: precomp.h:8
PDEVICE_OBJECT Pdo
Definition: i8042prt.h:128
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
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
PDEVICE_OBJECT LowerDevice
Definition: i8042prt.h:130
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by AddDevice().

◆ FdoCleanup()

NTSTATUS NTAPI FdoCleanup ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 462 of file fdo.c.

464 {
465  DPRINT("FdoCleanup()\n");
466 
467  Irp->IoStatus.Information = 0;
468  Irp->IoStatus.Status = STATUS_SUCCESS;
470 
471  return STATUS_SUCCESS;
472 }
_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
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by DispatchCleanup().

◆ FdoClose()

NTSTATUS NTAPI FdoClose ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 442 of file fdo.c.

444 {
445  PFDO_DEVICE_EXTENSION pDeviceExtension;
446 
447  DPRINT("FdoClose()\n");
448 
449  pDeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
450  pDeviceExtension->OpenCount--;
451 
452  Irp->IoStatus.Information = 0;
453  Irp->IoStatus.Status = STATUS_SUCCESS;
455 
456  return STATUS_SUCCESS;
457 }
_In_ PIRP Irp
Definition: csq.h:116
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define IO_NO_INCREMENT
Definition: iotypes.h:581
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by DispatchClose().

◆ FdoCreate()

NTSTATUS NTAPI FdoCreate ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 409 of file fdo.c.

411 {
412  PFDO_DEVICE_EXTENSION DeviceExtension;
413  PIO_STACK_LOCATION Stack;
415 
416  DPRINT("FdoCreate()\n");
417 
419  DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
420 
421  if (Stack->Parameters.Create.Options & FILE_DIRECTORY_FILE)
422  {
423  DPRINT1("Not a directory\n");
425  goto done;
426  }
427 
428  DPRINT("Open parallel port %lu: successful\n", DeviceExtension->PortNumber);
429  DeviceExtension->OpenCount++;
430 
431 done:
432  Irp->IoStatus.Status = Status;
433  Irp->IoStatus.Information = 0;
435 
436  return Status;
437 }
_In_ PIRP Irp
Definition: csq.h:116
#define FILE_DIRECTORY_FILE
Definition: constants.h:491
LONG NTSTATUS
Definition: precomp.h:26
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
#define STATUS_NOT_A_DIRECTORY
Definition: udferr_usr.h:169
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
if(!(yy_init))
Definition: macro.lex.yy.c:714
Status
Definition: gdiplustypes.h:24
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define DPRINT1
Definition: precomp.h:8
#define IO_NO_INCREMENT
Definition: iotypes.h:581
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
return STATUS_SUCCESS
Definition: btrfs.c:3014
HRESULT Create([out]ITransactionReceiver **ppReceiver)

Referenced by DispatchCreate().

◆ FdoCreateRawParallelPdo()

static NTSTATUS FdoCreateRawParallelPdo ( IN PDEVICE_OBJECT  DeviceObject)
static

Definition at line 216 of file fdo.c.

218 {
219  PFDO_DEVICE_EXTENSION FdoDeviceExtension;
220  PPDO_DEVICE_EXTENSION PdoDeviceExtension = NULL;
222  WCHAR DeviceNameBuffer[32];
223  WCHAR LinkNameBuffer[32];
224  WCHAR LptPortBuffer[32];
226  UNICODE_STRING LinkName;
227  UNICODE_STRING LptPort;
232 
233  DPRINT("FdoCreateRawParallelPdo()\n");
234 
235  FdoDeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
236 
237  /* Create new device object */
238  swprintf(DeviceNameBuffer,
239  L"\\Device\\Parallel%lu",
240  FdoDeviceExtension->PortNumber);
242  DeviceNameBuffer);
243 
244  Status = IoCreateDevice(DeviceObject->DriverObject,
245  sizeof(PDO_DEVICE_EXTENSION),
246  &DeviceName,
248  0,
249  FALSE,
250  &Pdo);
251  if (!NT_SUCCESS(Status))
252  {
253  DPRINT1("IoCreateDevice() failed with status 0x%08x\n", Status);
254  goto done;
255  }
256 
259 
260  PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)Pdo->DeviceExtension;
261  RtlZeroMemory(PdoDeviceExtension, sizeof(PDO_DEVICE_EXTENSION));
262 
263  PdoDeviceExtension->Common.IsFDO = FALSE;
264  PdoDeviceExtension->Common.PnpState = dsStopped;
265 
266  Pdo->StackSize = DeviceObject->StackSize + 1;
267 
268  FdoDeviceExtension->AttachedRawPdo = Pdo;
269  PdoDeviceExtension->AttachedFdo = DeviceObject;
270 
271  PdoDeviceExtension->PortNumber = FdoDeviceExtension->PortNumber;
272  PdoDeviceExtension->LptPort = PdoDeviceExtension->PortNumber + 1;
273 
274 
275  /* Create link \DosDevices\LPTX -> \Device\ParallelY */
276  swprintf(LinkNameBuffer, L"\\DosDevices\\LPT%lu", PdoDeviceExtension->LptPort);
277  RtlInitUnicodeString(&LinkName, LinkNameBuffer);
278  Status = IoCreateSymbolicLink(&LinkName,
279  &DeviceName);
280  if (!NT_SUCCESS(Status))
281  {
282  DPRINT1("IoCreateSymbolicLink() failed with status 0x%08x\n", Status);
283  goto done;
284  }
285 
286  swprintf(LptPortBuffer, L"LPT%lu", PdoDeviceExtension->LptPort);
287  RtlInitUnicodeString(&LptPort, LptPortBuffer);
288 
289  /* Write an entry value under HKLM\HARDWARE\DeviceMap\PARALLEL PORTS. */
290  /* This step is not mandatory, so do not exit in case of error. */
292  L"\\Registry\\Machine\\HARDWARE\\DeviceMap\\PARALLEL PORTS");
294  &KeyName,
296  NULL,
297  NULL);
298 
299  Status = ZwCreateKey(&KeyHandle,
302  0,
303  NULL,
305  NULL);
306  if (NT_SUCCESS(Status))
307  {
308  /* Key = \Device\Parallelx, Value = LPTx */
309  ZwSetValueKey(KeyHandle,
310  &DeviceName,
311  0,
312  REG_SZ,
313  LptPortBuffer,
314  LptPort.Length + sizeof(WCHAR));
316  }
317 
320 
321 done:
322  if (!NT_SUCCESS(Status))
323  {
324  if (Pdo)
325  {
326  ASSERT(PdoDeviceExtension);
328  }
329  }
330 
331  return Status;
332 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define DO_POWER_PAGABLE
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
_In_ PDEVICE_OBJECT Pdo
Definition: classpnp.h:318
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
WCHAR DeviceName[]
Definition: adapter.cpp:21
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
PDEVICE_OBJECT AttachedRawPdo
Definition: parport.h:43
#define FILE_DEVICE_CONTROLLER
Definition: winioctl.h:109
#define FALSE
Definition: types.h:117
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define DO_BUS_ENUMERATED_DEVICE
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:56
void DPRINT(...)
Definition: polytest.cpp:61
PDEVICE_OBJECT AttachedFdo
Definition: parport.h:59
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
#define swprintf(buf, format,...)
Definition: sprintf.c:56
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
static const WCHAR L[]
Definition: oid.c:1250
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define DPRINT1
Definition: precomp.h:8
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
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060
#define REG_SZ
Definition: layer.c:22

Referenced by FdoQueryBusRelations().

◆ FdoPnp()

NTSTATUS NTAPI FdoPnp ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 505 of file fdo.c.

507 {
509  PIO_STACK_LOCATION Stack;
512 
513  DPRINT("FdoPnp()\n");
514 
516  MinorFunction = Stack->MinorFunction;
517 
518  switch (MinorFunction)
519  {
520  /* FIXME: do all these minor functions
521  IRP_MN_QUERY_REMOVE_DEVICE 0x1
522  IRP_MN_REMOVE_DEVICE 0x2
523  {
524  TRACE_(SERIAL, "IRP_MJ_PNP / IRP_MN_REMOVE_DEVICE\n");
525  IoAcquireRemoveLock
526  IoReleaseRemoveLockAndWait
527  pass request to DeviceExtension-LowerDriver
528  disable interface
529  IoDeleteDevice(Fdo) and/or IoDetachDevice
530  break;
531  }
532  IRP_MN_CANCEL_REMOVE_DEVICE 0x3
533  IRP_MN_STOP_DEVICE 0x4
534  IRP_MN_QUERY_STOP_DEVICE 0x5
535  IRP_MN_CANCEL_STOP_DEVICE 0x6
536  IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations (optional) 0x7
537  IRP_MN_QUERY_DEVICE_RELATIONS / RemovalRelations (optional) 0x7
538  IRP_MN_QUERY_INTERFACE (optional) 0x8
539  IRP_MN_QUERY_CAPABILITIES (optional) 0x9
540  IRP_MN_FILTER_RESOURCE_REQUIREMENTS (optional) 0xd
541  IRP_MN_QUERY_PNP_DEVICE_STATE (optional) 0x14
542  IRP_MN_DEVICE_USAGE_NOTIFICATION (required or optional) 0x16
543  IRP_MN_SURPRISE_REMOVAL 0x17
544  */
545  case IRP_MN_START_DEVICE: /* 0x0 */
546  DPRINT("IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
547 
548  ASSERT(((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Common.PnpState == dsStopped);
549 
550  /* Call lower driver */
552  if (NT_SUCCESS(Status))
553  {
555  Stack->Parameters.StartDevice.AllocatedResources,
556  Stack->Parameters.StartDevice.AllocatedResourcesTranslated);
557  }
558  break;
559 
560  case IRP_MN_QUERY_DEVICE_RELATIONS: /* (optional) 0x7 */
561  switch (Stack->Parameters.QueryDeviceRelations.Type)
562  {
563  case BusRelations:
564  DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations\n");
566  Irp->IoStatus.Status = Status;
568  return Status;
569 
570  case RemovalRelations:
571  DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / RemovalRelations\n");
573 
574  default:
575  DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
576  Stack->Parameters.QueryDeviceRelations.Type);
578  }
579  break;
580 
581  case IRP_MN_FILTER_RESOURCE_REQUIREMENTS: /* (optional) 0xd */
582  DPRINT("IRP_MJ_PNP / IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n");
584 
585  default:
586  DPRINT("Unknown minor function 0x%x\n", MinorFunction);
588  }
589 
590  Irp->IoStatus.Information = Information;
591  Irp->IoStatus.Status = Status;
593 
594  return Status;
595 }
static NTSTATUS FdoQueryBusRelations(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: fdo.c:337
NTSTATUS NTAPI ForwardIrpAndForget(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.c:66
NTSTATUS NTAPI ForwardIrpAndWait(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.c:32
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
LONG NTSTATUS
Definition: precomp.h:26
Iosb Information
Definition: create.c:4353
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IRP_MN_START_DEVICE
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSTATUS NTAPI FdoStartDevice(IN PDEVICE_OBJECT DeviceObject, IN PCM_RESOURCE_LIST ResourceList, IN PCM_RESOURCE_LIST ResourceListTranslated)
Definition: fdo.c:104
Status
Definition: gdiplustypes.h:24
_In_ UCHAR MinorFunction
Definition: pofuncs.h:42
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define IRP_MN_QUERY_DEVICE_RELATIONS
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:581
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107

Referenced by DispatchPnp().

◆ FdoPower()

NTSTATUS NTAPI FdoPower ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 600 of file fdo.c.

602 {
603  PDEVICE_OBJECT LowerDevice;
604 
605  DPRINT("FdoPower()\n");
606 
607  LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
610  return PoCallDriver(LowerDevice, Irp);
611 }
_In_ PIRP Irp
Definition: csq.h:116
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
void DPRINT(...)
Definition: polytest.cpp:61
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:737
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421

Referenced by DispatchPower().

◆ FdoQueryBusRelations()

static NTSTATUS FdoQueryBusRelations ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)
static

Definition at line 337 of file fdo.c.

341 {
342  PFDO_DEVICE_EXTENSION DeviceExtension;
343  PDEVICE_RELATIONS DeviceRelations;
344  ULONG Size;
345  ULONG i;
346  ULONG PdoCount = 0;
348 
350 
351  DPRINT("FdoQueryBusRelations()\n");
352 
353  DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
354  ASSERT(DeviceExtension->Common.IsFDO);
355 
356  /* TODO: Enumerate parallel devices and create their PDOs */
357 
359  if (!NT_SUCCESS(Status))
360  return Status;
361 
362  PdoCount++;
363 
364  /* Allocate a buffer for the device relations */
365  Size = sizeof(DEVICE_RELATIONS) + sizeof(PDEVICE_OBJECT) * (PdoCount - 1);
366  DeviceRelations = ExAllocatePoolWithTag(PagedPool, Size, PARPORT_TAG);
367  if (DeviceRelations == NULL)
369 
370  /* Fill the buffer */
371  i = 0;
372  ObReferenceObject(DeviceExtension->AttachedRawPdo);
373  DeviceRelations->Objects[i] = DeviceExtension->AttachedRawPdo;
374  DeviceRelations->Count = 1;
375 
376  Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
377 
378  DPRINT("Done\n");
379 
380  return STATUS_SUCCESS;
381 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
static NTSTATUS FdoCreateRawParallelPdo(IN PDEVICE_OBJECT DeviceObject)
Definition: fdo.c:216
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2143
LONG NTSTATUS
Definition: precomp.h:26
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
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
PDEVICE_OBJECT AttachedRawPdo
Definition: parport.h:43
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Status
Definition: gdiplustypes.h:24
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:81
#define PARPORT_TAG
Definition: parport.h:68
struct _DEVICE_RELATIONS DEVICE_RELATIONS
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define ObReferenceObject
Definition: obfuncs.h:204
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by FdoPnp().

◆ FdoRead()

NTSTATUS NTAPI FdoRead ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 477 of file fdo.c.

479 {
480  DPRINT("FdoRead()\n");
481 
482  Irp->IoStatus.Information = 0;
483  Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
485  return STATUS_NOT_SUPPORTED;
486 }
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
#define IO_NO_INCREMENT
Definition: iotypes.h:581

Referenced by DispatchRead().

◆ FdoStartDevice()

NTSTATUS NTAPI FdoStartDevice ( IN PDEVICE_OBJECT  DeviceObject,
IN PCM_RESOURCE_LIST  ResourceList,
IN PCM_RESOURCE_LIST  ResourceListTranslated 
)

Definition at line 104 of file fdo.c.

107 {
108  PFDO_DEVICE_EXTENSION DeviceExtension;
109  ULONG i;
110 // ULONG Vector = 0;
111 // KIRQL Dirql = 0;
112 // KAFFINITY Affinity = 0;
113 // KINTERRUPT_MODE InterruptMode = Latched;
114 // BOOLEAN ShareInterrupt = TRUE;
115 
116  DPRINT("FdoStartDevice ()\n");
117 
118  DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
119 
120  ASSERT(DeviceExtension);
121  ASSERT(DeviceExtension->Common.IsFDO == TRUE);
122 
123  if (!ResourceList)
124  {
125  DPRINT1("No allocated resources sent to driver\n");
127  }
128 
129  if (ResourceList->Count != 1)
130  {
131  DPRINT1("Wrong number of allocated resources sent to driver\n");
133  }
134 
135  if ((ResourceList->List[0].PartialResourceList.Version != 1) ||
136  (ResourceList->List[0].PartialResourceList.Revision != 1) ||
137  (ResourceListTranslated->List[0].PartialResourceList.Version != 1) ||
138  (ResourceListTranslated->List[0].PartialResourceList.Revision != 1))
139  {
140  DPRINT1("Revision mismatch: %u.%u != 1.1 or %u.%u != 1.1\n",
141  ResourceList->List[0].PartialResourceList.Version,
142  ResourceList->List[0].PartialResourceList.Revision,
143  ResourceListTranslated->List[0].PartialResourceList.Version,
144  ResourceListTranslated->List[0].PartialResourceList.Revision);
146  }
147 
148  DeviceExtension->BaseAddress = 0;
149 
150  for (i = 0; i < ResourceList->List[0].PartialResourceList.Count; i++)
151  {
152  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[i];
153  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptorTranslated = &ResourceListTranslated->List[0].PartialResourceList.PartialDescriptors[i];
154 
155  switch (PartialDescriptor->Type)
156  {
157  case CmResourceTypePort:
158  DPRINT("Port: BaseAddress 0x%lx Length %lu\n",
159  PartialDescriptor->u.Port.Start.u.LowPart,
160  PartialDescriptor->u.Port.Length);
161 
162  if (DeviceExtension->BaseAddress == 0)
163  {
164  if (PartialDescriptor->u.Port.Length < 3)
166 
167  DeviceExtension->BaseAddress = PartialDescriptor->u.Port.Start.u.LowPart;
168  }
169  break;
170 
172  DPRINT("Interrupt: Level %lu Vector %lu\n",
173  PartialDescriptorTranslated->u.Interrupt.Level,
174  PartialDescriptorTranslated->u.Interrupt.Vector);
175 
176 // Dirql = (KIRQL)PartialDescriptorTranslated->u.Interrupt.Level;
177 // Vector = PartialDescriptorTranslated->u.Interrupt.Vector;
178 // Affinity = PartialDescriptorTranslated->u.Interrupt.Affinity;
179 
180 // if (PartialDescriptorTranslated->Flags & CM_RESOURCE_INTERRUPT_LATCHED)
181 // InterruptMode = Latched;
182 // else
183 // InterruptMode = LevelSensitive;
184 
185 // ShareInterrupt = (PartialDescriptorTranslated->ShareDisposition == CmResourceShareShared);
186  break;
187 
188  default:
189  DPRINT1("Other resource: \n");
190  break;
191  }
192  }
193 
194  DPRINT("New LPT port: Base 0x%lx\n",
195  DeviceExtension->BaseAddress);
196 
197  if (!DeviceExtension->BaseAddress)
199 
200 #if 0
201  if (!Dirql)
203 #endif
204 
205  DeviceExtension->Common.PnpState = dsStarted;
206 
207 
208  /* We don't really care if the call succeeded or not... */
209 
210  return STATUS_SUCCESS;
211 }
#define STATUS_REVISION_MISMATCH
Definition: ntstatus.h:325
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TRUE
Definition: types.h:120
const MUI_LANGUAGE_RESOURCE ResourceList[]
Definition: muilanguages.h:414
#define CmResourceTypePort
Definition: hwresource.cpp:123
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
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
void DPRINT(...)
Definition: polytest.cpp:61
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@384::@386 Port
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
COMMON_DEVICE_EXTENSION Common
Definition: pci.h:81
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@384::@387 Interrupt
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@384 u
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by FdoPnp().

◆ FdoWrite()

NTSTATUS NTAPI FdoWrite ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 491 of file fdo.c.

493 {
494  DPRINT("FdoWrite()\n");
495 
496  Irp->IoStatus.Information = 0;
497  Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
499  return STATUS_NOT_SUPPORTED;
500 }
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
#define IO_NO_INCREMENT
Definition: iotypes.h:581

Referenced by DispatchWrite().