ReactOS  0.4.14-dev-114-gc8cbd56
fdo.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Storport Driver
3  * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE: Storport FDO code
5  * COPYRIGHT: Copyright 2017 Eric Kohl (eric.kohl@reactos.org)
6  */
7 
8 /* INCLUDES *******************************************************************/
9 
10 #include "precomp.h"
11 
12 #define NDEBUG
13 #include <debug.h>
14 
15 
16 /* FUNCTIONS ******************************************************************/
17 
18 static
19 BOOLEAN
20 NTAPI
22  _In_ PKINTERRUPT Interrupt,
24 {
25  PFDO_DEVICE_EXTENSION DeviceExtension;
26 
27  DPRINT1("PortFdoInterruptRoutine(%p %p)\n",
28  Interrupt, ServiceContext);
29 
30  DeviceExtension = (PFDO_DEVICE_EXTENSION)ServiceContext;
31 
32  return MiniportHwInterrupt(&DeviceExtension->Miniport);
33 }
34 
35 
36 static
39  _In_ PFDO_DEVICE_EXTENSION DeviceExtension)
40 {
41  ULONG Vector;
42  KIRQL Irql;
47 
48  DPRINT1("PortFdoConnectInterrupt(%p)\n",
49  DeviceExtension);
50 
51  /* No resources, no interrupt. Done! */
52  if (DeviceExtension->AllocatedResources == NULL ||
53  DeviceExtension->TranslatedResources == NULL)
54  {
55  DPRINT1("Checkpoint\n");
56  return STATUS_SUCCESS;
57  }
58 
59  /* Get the interrupt data from the resource list */
60  Status = GetResourceListInterrupt(DeviceExtension,
61  &Vector,
62  &Irql,
64  &ShareVector,
65  &Affinity);
66  if (!NT_SUCCESS(Status))
67  {
68  DPRINT1("GetResourceListInterrupt() failed (Status 0x%08lx)\n", Status);
69  return Status;
70  }
71 
72  DPRINT1("Vector: %lu\n", Vector);
73  DPRINT1("Irql: %lu\n", Irql);
74 
75  DPRINT1("Affinity: 0x%08lx\n", Affinity);
76 
77  /* Connect the interrupt */
78  Status = IoConnectInterrupt(&DeviceExtension->Interrupt,
80  DeviceExtension,
81  NULL,
82  Vector,
83  Irql,
84  Irql,
87  Affinity,
88  FALSE);
89  if (NT_SUCCESS(Status))
90  {
91  DeviceExtension->InterruptIrql = Irql;
92  }
93  else
94  {
95  DPRINT1("IoConnectInterrupt() failed (Status 0x%08lx)\n", Status);
96  }
97 
98  return Status;
99 }
100 
101 
102 static
103 NTSTATUS
105  _In_ PFDO_DEVICE_EXTENSION DeviceExtension)
106 {
107  PHW_INITIALIZATION_DATA InitData;
108  INTERFACE_TYPE InterfaceType;
110 
111  DPRINT1("PortFdoStartDevice(%p)\n", DeviceExtension);
112 
113  /* Get the interface type of the lower device */
114  InterfaceType = GetBusInterface(DeviceExtension->LowerDevice);
115  if (InterfaceType == InterfaceTypeUndefined)
116  return STATUS_NO_SUCH_DEVICE;
117 
118  /* Get the driver init data for the given interface type */
119  InitData = PortGetDriverInitData(DeviceExtension->DriverExtension,
120  InterfaceType);
121  if (InitData == NULL)
122  return STATUS_NO_SUCH_DEVICE;
123 
124  /* Initialize the miniport */
125  Status = MiniportInitialize(&DeviceExtension->Miniport,
126  DeviceExtension,
127  InitData);
128  if (!NT_SUCCESS(Status))
129  {
130  DPRINT1("MiniportInitialize() failed (Status 0x%08lx)\n", Status);
131  return Status;
132  }
133 
134  /* Call the miniports FindAdapter function */
135  Status = MiniportFindAdapter(&DeviceExtension->Miniport);
136  if (!NT_SUCCESS(Status))
137  {
138  DPRINT1("MiniportFindAdapter() failed (Status 0x%08lx)\n", Status);
139  return Status;
140  }
141 
142  /* Connect the configured interrupt */
143  Status = PortFdoConnectInterrupt(DeviceExtension);
144  if (!NT_SUCCESS(Status))
145  {
146  DPRINT1("PortFdoConnectInterrupt() failed (Status 0x%08lx)\n", Status);
147  return Status;
148  }
149 
150  /* Call the miniports HwInitialize function */
151  Status = MiniportHwInitialize(&DeviceExtension->Miniport);
152  if (!NT_SUCCESS(Status))
153  {
154  DPRINT1("MiniportHwInitialize() failed (Status 0x%08lx)\n", Status);
155  return Status;
156  }
157 
158  /* Call the HwPassiveInitRoutine function, if available */
159  if (DeviceExtension->HwPassiveInitRoutine != NULL)
160  {
161  DPRINT1("Calling HwPassiveInitRoutine()\n");
162  if (!DeviceExtension->HwPassiveInitRoutine(&DeviceExtension->Miniport.MiniportExtension->HwDeviceExtension))
163  {
164  DPRINT1("HwPassiveInitRoutine() failed\n");
165  return STATUS_UNSUCCESSFUL;
166  }
167  }
168 
169  return STATUS_SUCCESS;
170 }
171 
172 
173 static
174 NTSTATUS
175 NTAPI
177  _In_ PFDO_DEVICE_EXTENSION DeviceExtension,
178  _In_ PIRP Irp)
179 {
180  PIO_STACK_LOCATION Stack;
182 
183  DPRINT1("PortFdoStartDevice(%p %p)\n",
184  DeviceExtension, Irp);
185 
186  ASSERT(DeviceExtension->ExtensionType == FdoExtension);
187 
188  /* Get the current stack location */
190 
191  /* Start the lower device if the FDO is in 'stopped' state */
192  if (DeviceExtension->PnpState == dsStopped)
193  {
194  Status = ForwardIrpAndWait(DeviceExtension->LowerDevice, Irp);
195  if (!NT_SUCCESS(Status))
196  {
197  DPRINT1("ForwardIrpAndWait() failed (Status 0x%08lx)\n", Status);
198  return Status;
199  }
200  }
201 
202  /* Change to the 'started' state */
203  DeviceExtension->PnpState = dsStarted;
204 
205  /* Copy the raw and translated resource lists into the device extension */
206  if (Stack->Parameters.StartDevice.AllocatedResources != NULL &&
207  Stack->Parameters.StartDevice.AllocatedResourcesTranslated != NULL)
208  {
209  DeviceExtension->AllocatedResources = CopyResourceList(NonPagedPool,
210  Stack->Parameters.StartDevice.AllocatedResources);
211  if (DeviceExtension->AllocatedResources == NULL)
212  return STATUS_NO_MEMORY;
213 
214  DeviceExtension->TranslatedResources = CopyResourceList(NonPagedPool,
215  Stack->Parameters.StartDevice.AllocatedResourcesTranslated);
216  if (DeviceExtension->TranslatedResources == NULL)
217  return STATUS_NO_MEMORY;
218  }
219 
220  /* Get the bus interface of the lower (bus) device */
221  Status = QueryBusInterface(DeviceExtension->LowerDevice,
222  (PGUID)&GUID_BUS_INTERFACE_STANDARD,
223  sizeof(BUS_INTERFACE_STANDARD),
224  1,
225  &DeviceExtension->BusInterface,
226  NULL);
227  DPRINT1("Status: 0x%08lx\n", Status);
228  if (NT_SUCCESS(Status))
229  {
230  DPRINT1("Context: %p\n", DeviceExtension->BusInterface.Context);
231  DeviceExtension->BusInitialized = TRUE;
232  }
233 
234  /* Start the miniport (FindAdapter & Initialize) */
235  Status = PortFdoStartMiniport(DeviceExtension);
236  if (!NT_SUCCESS(Status))
237  {
238  DPRINT1("FdoStartMiniport() failed (Status 0x%08lx)\n", Status);
239  DeviceExtension->PnpState = dsStopped;
240  }
241 
242  return Status;
243 }
244 
245 
246 static
247 NTSTATUS
250 {
252  PIO_STACK_LOCATION IrpStack;
253  KEVENT Event;
254 // KIRQL Irql;
255  PIRP Irp;
257  PSENSE_DATA SenseBuffer;
258  BOOLEAN KeepTrying = TRUE;
259  ULONG RetryCount = 0;
261  PCDB Cdb;
262 // PSCSI_PORT_LUN_EXTENSION LunExtension;
263 // PFDO_DEVICE_EXTENSION DeviceExtension;
264 
265  DPRINT("PortSendInquiry(%p)\n", PdoExtension);
266 
267  if (PdoExtension->InquiryBuffer == NULL)
268  {
270  if (PdoExtension->InquiryBuffer == NULL)
272  }
273 
275  if (SenseBuffer == NULL)
276  {
278  }
279 
280  while (KeepTrying)
281  {
282  /* Initialize event for waiting */
285  FALSE);
286 
287  /* Create an IRP */
289  PdoExtension->Device,
290  NULL,
291  0,
292  PdoExtension->InquiryBuffer,
294  TRUE,
295  &Event,
296  &IoStatusBlock);
297  if (Irp == NULL)
298  {
299  DPRINT("IoBuildDeviceIoControlRequest() failed\n");
300 
301  /* Quit the loop */
303  KeepTrying = FALSE;
304  continue;
305  }
306 
307  /* Prepare SRB */
309 
310  Srb.Length = sizeof(SCSI_REQUEST_BLOCK);
311  Srb.OriginalRequest = Irp;
312  Srb.PathId = PdoExtension->Bus;
313  Srb.TargetId = PdoExtension->Target;
314  Srb.Lun = PdoExtension->Lun;
315  Srb.Function = SRB_FUNCTION_EXECUTE_SCSI;
317  Srb.TimeOutValue = 4;
318  Srb.CdbLength = 6;
319 
320  Srb.SenseInfoBuffer = SenseBuffer;
321  Srb.SenseInfoBufferLength = SENSE_BUFFER_SIZE;
322 
323  Srb.DataBuffer = PdoExtension->InquiryBuffer;
324  Srb.DataTransferLength = INQUIRYDATABUFFERSIZE;
325 
326  /* Attach Srb to the Irp */
327  IrpStack = IoGetNextIrpStackLocation(Irp);
328  IrpStack->Parameters.Scsi.Srb = &Srb;
329 
330  /* Fill in CDB */
331  Cdb = (PCDB)Srb.Cdb;
332  Cdb->CDB6INQUIRY.OperationCode = SCSIOP_INQUIRY;
333  Cdb->CDB6INQUIRY.LogicalUnitNumber = PdoExtension->Lun;
334  Cdb->CDB6INQUIRY.AllocationLength = INQUIRYDATABUFFERSIZE;
335 
336  /* Call the driver */
337  Status = IoCallDriver(PdoExtension->Device, Irp);
338 
339  /* Wait for it to complete */
340  if (Status == STATUS_PENDING)
341  {
342  DPRINT1("PortSendInquiry(): Waiting for the driver to process request...\n");
344  Executive,
345  KernelMode,
346  FALSE,
347  NULL);
349  }
350 
351  DPRINT("PortSendInquiry(): Request processed by driver, status = 0x%08X\n", Status);
352 
353  if (SRB_STATUS(Srb.SrbStatus) == SRB_STATUS_SUCCESS)
354  {
355  DPRINT("Found a device!\n");
356 
357  /* Quit the loop */
359  KeepTrying = FALSE;
360  continue;
361  }
362 
363  DPRINT("Inquiry SRB failed with SrbStatus 0x%08X\n", Srb.SrbStatus);
364 
365  /* Check if the queue is frozen */
366  if (Srb.SrbStatus & SRB_STATUS_QUEUE_FROZEN)
367  {
368  /* Something weird happened, deal with it (unfreeze the queue) */
369  KeepTrying = FALSE;
370 
371  DPRINT("SpiSendInquiry(): the queue is frozen at TargetId %d\n", Srb.TargetId);
372 
373 // LunExtension = SpiGetLunExtension(DeviceExtension,
374 // LunInfo->PathId,
375 // LunInfo->TargetId,
376 // LunInfo->Lun);
377 
378  /* Clear frozen flag */
379 // LunExtension->Flags &= ~LUNEX_FROZEN_QUEUE;
380 
381  /* Acquire the spinlock */
382 // KeAcquireSpinLock(&DeviceExtension->SpinLock, &Irql);
383 
384  /* Process the request */
385 // SpiGetNextRequestFromLun(DeviceObject->DeviceExtension, LunExtension);
386 
387  /* SpiGetNextRequestFromLun() releases the spinlock,
388  so we just lower irql back to what it was before */
389 // KeLowerIrql(Irql);
390  }
391 
392  /* Check if data overrun happened */
393  if (SRB_STATUS(Srb.SrbStatus) == SRB_STATUS_DATA_OVERRUN)
394  {
395  DPRINT("Data overrun at TargetId %d\n", PdoExtension->Target);
396 
397  /* Quit the loop */
399  KeepTrying = FALSE;
400  }
401  else if ((Srb.SrbStatus & SRB_STATUS_AUTOSENSE_VALID) &&
402  SenseBuffer->SenseKey == SCSI_SENSE_ILLEGAL_REQUEST)
403  {
404  /* LUN is not valid, but some device responds there.
405  Mark it as invalid anyway */
406 
407  /* Quit the loop */
409  KeepTrying = FALSE;
410  }
411  else
412  {
413  /* Retry a couple of times if no timeout happened */
414  if ((RetryCount < 2) &&
415  (SRB_STATUS(Srb.SrbStatus) != SRB_STATUS_NO_DEVICE) &&
417  {
418  RetryCount++;
419  KeepTrying = TRUE;
420  }
421  else
422  {
423  /* That's all, quit the loop */
424  KeepTrying = FALSE;
425 
426  /* Set status according to SRB status */
427  if (SRB_STATUS(Srb.SrbStatus) == SRB_STATUS_BAD_FUNCTION ||
429  {
431  }
432  else
433  {
435  }
436  }
437  }
438  }
439 
440  /* Free the sense buffer */
441  ExFreePoolWithTag(SenseBuffer, TAG_SENSE_DATA);
442 
443  DPRINT("PortSendInquiry() done with Status 0x%08X\n", Status);
444 
445  return Status;
446 }
447 
448 
449 
450 static
451 NTSTATUS
453  _In_ PFDO_DEVICE_EXTENSION DeviceExtension)
454 {
456  ULONG Bus, Target; //, Lun;
458 
459  DPRINT("PortFdoScanBus(%p)\n", DeviceExtension);
460 
461  DPRINT("NumberOfBuses: %lu\n", DeviceExtension->Miniport.PortConfig.NumberOfBuses);
462  DPRINT("MaximumNumberOfTargets: %lu\n", DeviceExtension->Miniport.PortConfig.MaximumNumberOfTargets);
463  DPRINT("MaximumNumberOfLogicalUnits: %lu\n", DeviceExtension->Miniport.PortConfig.MaximumNumberOfLogicalUnits);
464 
465  /* Scan all buses */
466  for (Bus = 0; Bus < DeviceExtension->Miniport.PortConfig.NumberOfBuses; Bus++)
467  {
468  DPRINT("Scanning bus %ld\n", Bus);
469 
470  /* Scan all targets */
471  for (Target = 0; Target < DeviceExtension->Miniport.PortConfig.MaximumNumberOfTargets; Target++)
472  {
473  DPRINT(" Scanning target %ld:%ld\n", Bus, Target);
474 
475  DPRINT(" Scanning logical unit %ld:%ld:%ld\n", Bus, Target, 0);
476  Status = PortCreatePdo(DeviceExtension, Bus, Target, 0, &PdoExtension);
477  if (NT_SUCCESS(Status))
478  {
479  /* Scan LUN 0 */
481  DPRINT("PortSendInquiry returned 0x%08lx\n", Status);
482  if (!NT_SUCCESS(Status))
483  {
485  }
486  else
487  {
488  DPRINT("VendorId: %.8s\n", PdoExtension->InquiryBuffer->VendorId);
489  DPRINT("ProductId: %.16s\n", PdoExtension->InquiryBuffer->ProductId);
490  DPRINT("ProductRevisionLevel: %.4s\n", PdoExtension->InquiryBuffer->ProductRevisionLevel);
491  DPRINT("VendorSpecific: %.20s\n", PdoExtension->InquiryBuffer->VendorSpecific);
492  }
493  }
494 
495 #if 0
496  /* Scan all logical units */
497  for (Lun = 1; Lun < DeviceExtension->Miniport.PortConfig.MaximumNumberOfLogicalUnits; Lun++)
498  {
499  DPRINT(" Scanning logical unit %ld:%ld:%ld\n", Bus, Target, Lun);
500  Status = PortSendInquiry(DeviceExtension->Device, Bus, Target, Lun);
501  DPRINT("PortSendInquiry returned 0x%08lx\n", Status);
502  if (!NT_SUCCESS(Status))
503  break;
504  }
505 #endif
506  }
507  }
508 
509  DPRINT("PortFdoScanBus() done!\n");
510 
511  return STATUS_SUCCESS;
512 }
513 
514 
515 static
516 NTSTATUS
518  _In_ PFDO_DEVICE_EXTENSION DeviceExtension,
520 {
522 
523  DPRINT1("PortFdoQueryBusRelations(%p %p)\n",
524  DeviceExtension, Information);
525 
526  Status = PortFdoScanBus(DeviceExtension);
527 
528  DPRINT1("Units found: %lu\n", DeviceExtension->PdoCount);
529 
530  *Information = 0;
531 
532  return Status;
533 }
534 
535 
536 static
537 NTSTATUS
539  PFDO_DEVICE_EXTENSION DeviceExtension,
540  PIRP Irp)
541 {
542  PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList;
543 
544  DPRINT1("PortFdoFilterRequirements(%p %p)\n", DeviceExtension, Irp);
545 
546  /* Get the bus number and the slot number */
547  RequirementsList =(PIO_RESOURCE_REQUIREMENTS_LIST)Irp->IoStatus.Information;
548  if (RequirementsList != NULL)
549  {
550  DeviceExtension->BusNumber = RequirementsList->BusNumber;
551  DeviceExtension->SlotNumber = RequirementsList->SlotNumber;
552  }
553 
554  return STATUS_SUCCESS;
555 }
556 
557 
558 NTSTATUS
559 NTAPI
562  _In_ PIRP Irp)
563 {
564  PFDO_DEVICE_EXTENSION DeviceExtension;
565 // PIO_STACK_LOCATION Stack;
568 
569  DPRINT("PortFdoScsi(%p %p)\n", DeviceObject, Irp);
570 
572  ASSERT(DeviceExtension);
573  ASSERT(DeviceExtension->ExtensionType == FdoExtension);
574 
575 // Stack = IoGetCurrentIrpStackLocation(Irp);
576 
577 
578  Irp->IoStatus.Information = Information;
579  Irp->IoStatus.Status = Status;
581 
582  return Status;
583 }
584 
585 
586 NTSTATUS
587 NTAPI
590  _In_ PIRP Irp)
591 {
592  PFDO_DEVICE_EXTENSION DeviceExtension;
593  PIO_STACK_LOCATION Stack;
596 
597  DPRINT1("PortFdoPnp(%p %p)\n",
598  DeviceObject, Irp);
599 
601  ASSERT(DeviceExtension);
602  ASSERT(DeviceExtension->ExtensionType == FdoExtension);
603 
605 
606  switch (Stack->MinorFunction)
607  {
608  case IRP_MN_START_DEVICE: /* 0x00 */
609  DPRINT1("IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
610  Status = PortFdoStartDevice(DeviceExtension, Irp);
611  break;
612 
613  case IRP_MN_QUERY_REMOVE_DEVICE: /* 0x01 */
614  DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_REMOVE_DEVICE\n");
615  break;
616 
617  case IRP_MN_REMOVE_DEVICE: /* 0x02 */
618  DPRINT1("IRP_MJ_PNP / IRP_MN_REMOVE_DEVICE\n");
619  break;
620 
621  case IRP_MN_CANCEL_REMOVE_DEVICE: /* 0x03 */
622  DPRINT1("IRP_MJ_PNP / IRP_MN_CANCEL_REMOVE_DEVICE\n");
623  break;
624 
625  case IRP_MN_STOP_DEVICE: /* 0x04 */
626  DPRINT1("IRP_MJ_PNP / IRP_MN_STOP_DEVICE\n");
627  break;
628 
629  case IRP_MN_QUERY_STOP_DEVICE: /* 0x05 */
630  DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_STOP_DEVICE\n");
631  break;
632 
633  case IRP_MN_CANCEL_STOP_DEVICE: /* 0x06 */
634  DPRINT1("IRP_MJ_PNP / IRP_MN_CANCEL_STOP_DEVICE\n");
635  break;
636 
637  case IRP_MN_QUERY_DEVICE_RELATIONS: /* 0x07 */
638  DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS\n");
639  switch (Stack->Parameters.QueryDeviceRelations.Type)
640  {
641  case BusRelations:
642  DPRINT1(" IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations\n");
643  Status = PortFdoQueryBusRelations(DeviceExtension, &Information);
644  break;
645 
646  case RemovalRelations:
647  DPRINT1(" IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / RemovalRelations\n");
648  return ForwardIrpAndForget(DeviceExtension->LowerDevice, Irp);
649 
650  default:
651  DPRINT1(" IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
652  Stack->Parameters.QueryDeviceRelations.Type);
653  return ForwardIrpAndForget(DeviceExtension->LowerDevice, Irp);
654  }
655  break;
656 
657  case IRP_MN_FILTER_RESOURCE_REQUIREMENTS: /* 0x0d */
658  DPRINT1("IRP_MJ_PNP / IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n");
659  PortFdoFilterRequirements(DeviceExtension, Irp);
660  return ForwardIrpAndForget(DeviceExtension->LowerDevice, Irp);
661 
662  case IRP_MN_QUERY_PNP_DEVICE_STATE: /* 0x14 */
663  DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_PNP_DEVICE_STATE\n");
664  break;
665 
666  case IRP_MN_DEVICE_USAGE_NOTIFICATION: /* 0x16 */
667  DPRINT1("IRP_MJ_PNP / IRP_MN_DEVICE_USAGE_NOTIFICATION\n");
668  break;
669 
670  case IRP_MN_SURPRISE_REMOVAL: /* 0x17 */
671  DPRINT1("IRP_MJ_PNP / IRP_MN_SURPRISE_REMOVAL\n");
672  break;
673 
674  default:
675  DPRINT1("IRP_MJ_PNP / Unknown IOCTL 0x%lx\n", Stack->MinorFunction);
676  return ForwardIrpAndForget(DeviceExtension->LowerDevice, Irp);
677  }
678 
679  Irp->IoStatus.Information = Information;
680  Irp->IoStatus.Status = Status;
682 
683  return Status;
684 }
685 
686 /* EOF */
NTSTATUS NTAPI PortFdoScsi(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: fdo.c:560
#define IRP_MN_CANCEL_REMOVE_DEVICE
UCHAR SenseKey
Definition: cdrw_hw.h:1167
#define TRUE
Definition: types.h:120
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK _In_ ULONG _In_ KIRQL _In_ KIRQL _In_ KINTERRUPT_MODE InterruptMode
Definition: iofuncs.h:798
#define IRP_MN_REMOVE_DEVICE
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
enum _INTERFACE_TYPE INTERFACE_TYPE
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR _In_ UCHAR _In_ UCHAR Lun
Definition: classpnp.h:1117
NTSTATUS NTAPI ForwardIrpAndWait(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.c:32
static NTSTATUS PortSendInquiry(_In_ PPDO_DEVICE_EXTENSION PdoExtension)
Definition: fdo.c:248
#define SRB_STATUS_AUTOSENSE_VALID
Definition: srb.h:379
_In_ PIRP Irp
Definition: csq.h:116
PCM_RESOURCE_LIST CopyResourceList(POOL_TYPE PoolType, PCM_RESOURCE_LIST Source)
Definition: misc.c:132
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK _In_ ULONG _In_ KIRQL _In_ KIRQL _In_ KINTERRUPT_MODE _In_ BOOLEAN ShareVector
Definition: iofuncs.h:798
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
Definition: cdrw_hw.h:28
LONG NTSTATUS
Definition: precomp.h:26
static NTSTATUS GetBusInterface(IN PFDO_DEVICE_EXTENSION DeviceExtension)
Definition: fdo.c:18
#define TAG_SENSE_DATA
Definition: precomp.h:33
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define SRB_STATUS_NO_DEVICE
Definition: srb.h:340
EXTENSION_TYPE ExtensionType
Definition: precomp.h:92
#define SRB_STATUS_BAD_SRB_BLOCK_LENGTH
Definition: srb.h:352
#define SRB_FLAGS_DATA_IN
Definition: srb.h:392
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
_Out_ PKIRQL Irql
Definition: csq.h:179
#define SRB_STATUS(Status)
Definition: srb.h:381
#define SENSE_BUFFER_SIZE
Definition: cdrw_hw.h:1183
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define STATUS_IO_DEVICE_ERROR
Definition: udferr_usr.h:179
UCHAR KIRQL
Definition: env_spec_w32.h:591
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define IRP_MN_QUERY_REMOVE_DEVICE
NTSTATUS NTAPI IoConnectInterrupt(OUT PKINTERRUPT *InterruptObject, IN PKSERVICE_ROUTINE ServiceRoutine, IN PVOID ServiceContext, IN PKSPIN_LOCK SpinLock, IN ULONG Vector, IN KIRQL Irql, IN KIRQL SynchronizeIrql, IN KINTERRUPT_MODE InterruptMode, IN BOOLEAN ShareVector, IN KAFFINITY ProcessorEnableMask, IN BOOLEAN FloatingSave)
Definition: irq.c:22
PHW_INITIALIZATION_DATA PortGetDriverInitData(PDRIVER_OBJECT_EXTENSION DriverExtension, INTERFACE_TYPE InterfaceType)
Definition: storport.c:78
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
static NTSTATUS PortFdoScanBus(_In_ PFDO_DEVICE_EXTENSION DeviceExtension)
Definition: fdo.c:452
smooth NULL
Definition: ftsmooth.c:416
#define INQUIRYDATABUFFERSIZE
Definition: cdrw_hw.h:1113
enum _KINTERRUPT_MODE KINTERRUPT_MODE
union _CDB * PCDB
#define _Out_
Definition: no_sal2.h:323
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS PortDeletePdo(_In_ PPDO_DEVICE_EXTENSION PdoExtension)
Definition: pdo.c:87
#define IRP_MN_QUERY_STOP_DEVICE
#define SCSIOP_INQUIRY
Definition: cdrw_hw.h:888
#define SRB_STATUS_BAD_FUNCTION
Definition: srb.h:356
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
static BOOLEAN NTAPI PortFdoInterruptRoutine(_In_ PKINTERRUPT Interrupt, _In_ PVOID ServiceContext)
Definition: fdo.c:21
#define IRP_MN_STOP_DEVICE
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
NTSTATUS MiniportHwInitialize(_In_ PMINIPORT Miniport)
Definition: miniport.c:335
#define IRP_MN_START_DEVICE
#define SRB_FLAGS_DISABLE_SYNCH_TRANSFER
Definition: srb.h:389
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:170
BOOLEAN MiniportHwInterrupt(_In_ PMINIPORT Miniport)
Definition: miniport.c:351
NTSTATUS NTAPI PortFdoPnp(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: fdo.c:588
#define SRB_STATUS_DATA_OVERRUN
Definition: srb.h:349
_Must_inspect_result_ typedef _In_ ULONG _In_ BOOLEAN Target
Definition: iotypes.h:1068
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID ServiceContext
Definition: iofuncs.h:798
struct _SCSI_REQUEST_BLOCK SCSI_REQUEST_BLOCK
static NTSTATUS PortFdoFilterRequirements(PFDO_DEVICE_EXTENSION DeviceExtension, PIRP Irp)
Definition: fdo.c:538
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
ULONG BusNumber
Definition: pci.h:84
#define SRB_STATUS_QUEUE_FROZEN
Definition: srb.h:378
NTSTATUS NTAPI ForwardIrpAndForget(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.c:66
NDIS_STATUS NTAPI MiniportInitialize(OUT PNDIS_STATUS OpenErrorStatus, OUT PUINT SelectedMediumIndex, IN PNDIS_MEDIUM MediumArray, IN UINT MediumArraySize, IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE WrapperConfigurationContext)
Definition: ndis.c:88
NTSTATUS MiniportFindAdapter(_In_ PMINIPORT Miniport)
Definition: miniport.c:283
#define SRB_STATUS_SELECTION_TIMEOUT
Definition: srb.h:342
static NTSTATUS PortFdoStartMiniport(_In_ PFDO_DEVICE_EXTENSION DeviceExtension)
Definition: fdo.c:104
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
#define IOCTL_SCSI_EXECUTE_IN
Definition: cdrw_hw.h:1451
Status
Definition: gdiplustypes.h:24
NTSTATUS PortCreatePdo(_In_ PFDO_DEVICE_EXTENSION FdoDeviceExtension, _In_ ULONG Bus, _In_ ULONG Target, _In_ ULONG Lun, _Out_ PPDO_DEVICE_EXTENSION *PdoDeviceExtension)
Definition: pdo.c:19
#define _In_
Definition: no_sal2.h:204
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
static NTSTATUS PortFdoConnectInterrupt(_In_ PFDO_DEVICE_EXTENSION DeviceExtension)
Definition: fdo.c:38
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
struct _IO_RESOURCE_REQUIREMENTS_LIST * PIO_RESOURCE_REQUIREMENTS_LIST
NTSTATUS QueryBusInterface(PDEVICE_OBJECT DeviceObject, PGUID Guid, USHORT Size, USHORT Version, PBUS_INTERFACE_STANDARD Interface, PVOID InterfaceSpecificData)
Definition: misc.c:162
ULONG_PTR KAFFINITY
Definition: compat.h:75
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK _In_ ULONG Vector
Definition: iofuncs.h:798
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
static NTSTATUS PortFdoQueryBusRelations(_In_ PFDO_DEVICE_EXTENSION DeviceExtension, _Out_ PULONG_PTR Information)
Definition: fdo.c:517
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
static NTSTATUS NTAPI PortFdoStartDevice(_In_ PFDO_DEVICE_EXTENSION DeviceExtension, _In_ PIRP Irp)
Definition: fdo.c:176
#define IRP_MN_QUERY_DEVICE_RELATIONS
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:881
#define DPRINT1
Definition: precomp.h:8
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:307
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define SRB_STATUS_SUCCESS
Definition: srb.h:333
uint32_t * PULONG_PTR
Definition: typedefs.h:63
PDEVICE_OBJECT LowerDevice
Definition: i8042prt.h:130
#define IRP_MN_CANCEL_STOP_DEVICE
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define IRP_MN_DEVICE_USAGE_NOTIFICATION
struct _CDB::_CDB6INQUIRY CDB6INQUIRY
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
#define SCSI_SENSE_ILLEGAL_REQUEST
Definition: cdrw_hw.h:1192
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define IRP_MN_QUERY_PNP_DEVICE_STATE
Iosb Information
Definition: create.c:4377
NTSTATUS GetResourceListInterrupt(PFDO_DEVICE_EXTENSION DeviceExtension, PULONG Vector, PKIRQL Irql, KINTERRUPT_MODE *InterruptMode, PBOOLEAN ShareVector, PKAFFINITY Affinity)
Definition: misc.c:282
#define TAG_INQUIRY_DATA
Definition: precomp.h:32