ReactOS 0.4.17-dev-1190-g4c812f4
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#include "inline.h"
12
13#define NDEBUG
14#include <debug.h>
15
16
17/* FUNCTIONS ******************************************************************/
18
19/* Starved request queue, a cancel safe queue over STARVED_REQUEST_QUEUE */
20
21static
22VOID
27{
29
30 InsertTailList(&Queue->ListHead, &Irp->Tail.Overlay.ListEntry);
31}
32
33static
34VOID
39{
41
42 RemoveEntryList(&Irp->Tail.Overlay.ListEntry);
43}
44
45static
46PIRP
52{
55
57
58 Entry = (Irp == NULL) ? Queue->ListHead.Flink : Irp->Tail.Overlay.ListEntry.Flink;
59
60 if (Entry == &Queue->ListHead)
61 {
62 return NULL;
63 }
64
65 return CONTAINING_RECORD(Entry, IRP, Tail.Overlay.ListEntry);
66}
67
68static
69VOID
74{
76
78}
79
80static
81VOID
86{
88
90}
91
92static
93VOID
98{
100
102}
103
107{
109 InitializeListHead(&Queue->ListHead);
110
111 return IoCsqInitialize(&Queue->Csq,
118}
119
123VOID
126 _In_ PIRP Irp)
127{
128 IoCsqInsertIrp(&FdoExtension->StarvedRequests.Csq, Irp, NULL);
129}
130
134VOID
137{
138 PIRP Irp;
139
140 Irp = IoCsqRemoveNextIrp(&FdoExtension->StarvedRequests.Csq, NULL);
141 if (Irp == NULL)
142 {
143 return;
144 }
145
147}
148
152VOID
155{
156 PIRP Irp;
157
158 while ((Irp = IoCsqRemoveNextIrp(&FdoExtension->StarvedRequests.Csq, NULL)) != NULL)
159 {
161 }
162}
163
167VOID
170{
171 ULONG SrbExtensionSize = FdoExtension->HwInitData->SrbExtensionSize;
172
173 FdoExtension->ReservedRequestReference =
175 sizeof(*FdoExtension->ReservedRequestReference),
177 if (FdoExtension->ReservedRequestReference == NULL)
178 {
179 DPRINT1("Failed to reserve a request packet\n");
180 return;
181 }
182
183 if (SrbExtensionSize == 0)
184 {
185 return;
186 }
187
188 FdoExtension->ReservedSrbExtension = ExAllocatePoolWithTag(NonPagedPool,
189 SrbExtensionSize,
191 if (FdoExtension->ReservedSrbExtension == NULL)
192 {
193 DPRINT1("Failed to reserve an SRB extension\n");
194
195 /* A packet alone is useless if the miniport wants an SRB extension */
196 ExFreePoolWithTag(FdoExtension->ReservedRequestReference, TAG_QUEUED_REQUEST);
197 FdoExtension->ReservedRequestReference = NULL;
198 }
199}
200
204VOID
207{
208 if (FdoExtension->ReservedSrbExtension != NULL)
209 {
210 ExFreePoolWithTag(FdoExtension->ReservedSrbExtension, TAG_SRB_EXTENSION);
211 FdoExtension->ReservedSrbExtension = NULL;
212 }
213
214 if (FdoExtension->ReservedRequestReference != NULL)
215 {
216 ExFreePoolWithTag(FdoExtension->ReservedRequestReference, TAG_QUEUED_REQUEST);
217 FdoExtension->ReservedRequestReference = NULL;
218 }
219}
220
221static
223NTAPI
227{
228 PFDO_DEVICE_EXTENSION DeviceExtension;
229
230 // DPRINT1("PortFdoInterruptRoutine(%p %p)\n",
231 // Interrupt, ServiceContext);
232
233 DeviceExtension = (PFDO_DEVICE_EXTENSION)ServiceContext;
234
235 return MiniportHwInterrupt(&DeviceExtension->Miniport);
236}
237
238
239static
242 _In_ PFDO_DEVICE_EXTENSION DeviceExtension)
243{
245 KIRQL Irql;
250
251 DPRINT("PortFdoConnectInterrupt(%p)\n",
252 DeviceExtension);
253
254 /* No resources, no interrupt. Done! */
255 if (DeviceExtension->AllocatedResources == NULL ||
256 DeviceExtension->TranslatedResources == NULL)
257 {
258 DPRINT("Checkpoint\n");
259 return STATUS_SUCCESS;
260 }
261
262 /* Get the interrupt data from the resource list */
263 Status = GetResourceListInterrupt(DeviceExtension,
264 &Vector,
265 &Irql,
268 &Affinity);
269 if (!NT_SUCCESS(Status))
270 {
271 DPRINT("GetResourceListInterrupt() failed (Status 0x%08lx)\n", Status);
272 return Status;
273 }
274
275 DPRINT1("Vector: %lu\n", Vector);
276 DPRINT1("Irql: %lu\n", Irql);
277
278 DPRINT1("Affinity: 0x%08lx\n", Affinity);
279
280 /* Connect the interrupt */
281 Status = IoConnectInterrupt(&DeviceExtension->Interrupt,
283 DeviceExtension,
284 NULL,
285 Vector,
286 Irql,
287 Irql,
290 Affinity,
291 FALSE);
292 if (NT_SUCCESS(Status))
293 {
294 DeviceExtension->InterruptIrql = Irql;
295 }
296 else
297 {
298 DPRINT1("IoConnectInterrupt() failed (Status 0x%08lx)\n", Status);
299 }
300
301 return Status;
302}
303
304
305static
308 _In_ PFDO_DEVICE_EXTENSION DeviceExtension)
309{
313
314 DPRINT1("PortFdoStartMiniport(%p)\n", DeviceExtension);
315
316 /* Get the interface type of the lower device */
317 InterfaceType = GetBusInterface(DeviceExtension->LowerDevice);
320
321 /* Get the driver init data for the given interface type */
322 InitData = PortGetDriverInitData(DeviceExtension->DriverExtension,
324 if (InitData == NULL)
326
327 /* Initialize the miniport */
328 Status = MiniportInitialize(&DeviceExtension->Miniport,
329 DeviceExtension,
330 InitData);
331 if (!NT_SUCCESS(Status))
332 {
333 DPRINT1("MiniportInitialize() failed (Status 0x%08lx)\n", Status);
334 return Status;
335 }
336
337 /* Call the miniports FindAdapter function */
338 Status = MiniportFindAdapter(&DeviceExtension->Miniport);
339 if (!NT_SUCCESS(Status))
340 {
341 DPRINT1("MiniportFindAdapter() failed (Status 0x%08lx)\n", Status);
342 return Status;
343 }
344
345 /* Connect the configured interrupt */
346 Status = PortFdoConnectInterrupt(DeviceExtension);
347 if (!NT_SUCCESS(Status))
348 {
349 DPRINT1("PortFdoConnectInterrupt() failed (Status 0x%08lx)\n", Status);
350 return Status;
351 }
352
353 // FIXME: Find an appropriate place
354 DeviceExtension->OutstandingRequestMax = DeviceExtension->Miniport.PortConfig.MaxNumberOfIO;
355
356 /* Call the miniports HwInitialize function */
357 Status = MiniportHwInitialize(&DeviceExtension->Miniport);
358 if (!NT_SUCCESS(Status))
359 {
360 DPRINT1("MiniportHwInitialize() failed (Status 0x%08lx)\n", Status);
361 return Status;
362 }
363
364 /* Call the HwPassiveInitRoutine function, if available */
365 if (DeviceExtension->HwPassiveInitRoutine != NULL)
366 {
367 DPRINT1("Calling HwPassiveInitRoutine()\n");
368 if (!DeviceExtension->HwPassiveInitRoutine(&DeviceExtension->Miniport.MiniportExtension->HwDeviceExtension))
369 {
370 DPRINT1("HwPassiveInitRoutine() failed\n");
371 return STATUS_UNSUCCESSFUL;
372 }
373 }
374
375 return STATUS_SUCCESS;
376}
377
378
379static
382 _In_ PFDO_DEVICE_EXTENSION DeviceExtension,
383 _In_ PIRP Irp)
384{
388
389 DPRINT1("PortFdoStartDevice(%p %p)\n",
390 DeviceExtension, Irp);
391
392 ASSERT(DeviceExtension->ExtensionType == FdoExtension);
393
394 /* Get the current stack location */
396
397 /* Start the lower device if the FDO is in 'stopped' state */
398 if (DeviceExtension->PnpState == dsStopped)
399 {
400 if (IoForwardIrpSynchronously(DeviceExtension->LowerDevice, Irp))
401 {
402 Status = Irp->IoStatus.Status;
403 }
404 else
405 {
407 }
408
409 if (!NT_SUCCESS(Status))
410 {
411 DPRINT1("Lower device failed the IRP (Status 0x%08lx)\n", Status);
412 return Status;
413 }
414 }
415
416 /* Change to the 'started' state */
417 DeviceExtension->PnpState = dsStarted;
418
419 /* Copy the raw and translated resource lists into the device extension */
420 if (Stack->Parameters.StartDevice.AllocatedResources != NULL &&
421 Stack->Parameters.StartDevice.AllocatedResourcesTranslated != NULL)
422 {
423 DeviceExtension->AllocatedResources = CopyResourceList(NonPagedPool,
424 Stack->Parameters.StartDevice.AllocatedResources);
425 if (DeviceExtension->AllocatedResources == NULL)
426 return STATUS_NO_MEMORY;
427
428 DeviceExtension->TranslatedResources = CopyResourceList(NonPagedPool,
429 Stack->Parameters.StartDevice.AllocatedResourcesTranslated);
430 if (DeviceExtension->TranslatedResources == NULL)
431 return STATUS_NO_MEMORY;
432 }
433
434 /* Get the bus interface of the lower (bus) device */
435 Status = QueryBusInterface(DeviceExtension->LowerDevice,
436 (PGUID)&GUID_BUS_INTERFACE_STANDARD,
438 1,
439 &DeviceExtension->BusInterface,
440 NULL);
441 DPRINT1("Status: 0x%08lx\n", Status);
442 if (NT_SUCCESS(Status))
443 {
444 DPRINT1("Context: %p\n", DeviceExtension->BusInterface.Context);
445 DeviceExtension->BusInitialized = TRUE;
446 }
447
448 /* Start the miniport (FindAdapter & Initialize) */
449 Status = PortFdoStartMiniport(DeviceExtension);
450 if (!NT_SUCCESS(Status))
451 {
452 DPRINT1("FdoStartMiniport() failed (Status 0x%08lx)\n", Status);
453 DeviceExtension->PnpState = dsStopped;
454 }
455 else
456 {
457 /* SrbExtensionSize is only known once the miniport is up */
458 PortAllocateRequestReserve(DeviceExtension);
459 }
460
461 /* Claim and increase SCSI port number */
462 /* TODO: Reverse this when stopping adapter */
463 ConfigInfo = IoGetConfigurationInformation();
464 DeviceExtension->ScsiPortNumber = ConfigInfo->ScsiPortCount;
465 ConfigInfo->ScsiPortCount++;
466
467 return Status;
468}
469
470
471static
475 _Out_ PULONG LunCount)
476{
479 PCDB Cdb;
480 PIRP Irp;
482 PIO_STACK_LOCATION IrpStack;
484 PSENSE_DATA SenseBuffer;
486 PREPORT_LUNS_DATA ReportLunsData;
487 BOOLEAN KeepTrying = TRUE;
488 BOOLEAN BufferReallocated = FALSE;
489 ULONG RetryCount = 0;
490
491 DPRINT("PortSendReportLuns(%p)\n", PdoExtension);
492
493 /* Allocate sense buffer */
494 /* TODO: Reuse sense buffers */
495 /* FIXME: Do we need sense buffer here? Can I pass a NULL? */
497 if (SenseBuffer == NULL)
498 {
500 }
501
502 /* Allocate REPORT LUNS return buffer. Use buffer size for the case of a single LUN */
504 ReportLunsData =
506 if (ReportLunsData == NULL)
507 {
509 }
510
511 while (KeepTrying)
512 {
513 /* Initialize event for waiting */
516 FALSE);
517
518 /* Create an IRP */
520 PdoExtension->Device,
521 NULL,
522 0,
523 ReportLunsData,
525 TRUE,
526 &Event,
528 if (Irp == NULL)
529 {
530 DPRINT("IoBuildDeviceIoControlRequest() failed\n");
531
532 /* Quit the loop */
534 KeepTrying = FALSE;
535 continue;
536 }
537
538 /* Prepare SRB */
540
541 Srb.Length = sizeof(SCSI_REQUEST_BLOCK);
543 Srb.PathId = PdoExtension->Bus;
544 Srb.TargetId = PdoExtension->Target;
545 Srb.Lun = PdoExtension->Lun;
548 Srb.TimeOutValue = 4;
549 Srb.CdbLength = 12;
550
551 Srb.SenseInfoBuffer = SenseBuffer;
553
554 Srb.DataBuffer = ReportLunsData;
556
557 /* Attach Srb to the Irp */
558 IrpStack = IoGetNextIrpStackLocation(Irp);
559 IrpStack->Parameters.Scsi.Srb = &Srb;
560
561 /* Fill in CDB */
562 Cdb = (PCDB)Srb.Cdb;
563 Cdb->REPORT_LUNS.OperationCode = SCSIOP_REPORT_LUNS;
564 Cdb->REPORT_LUNS.AllocationLength[0] = (BufferSize >> (0*8)) & 0xFF;
565 Cdb->REPORT_LUNS.AllocationLength[1] = (BufferSize >> (1*8)) & 0xFF;
566 Cdb->REPORT_LUNS.AllocationLength[2] = (BufferSize >> (2*8)) & 0xFF;
567 Cdb->REPORT_LUNS.AllocationLength[3] = (BufferSize >> (3*8)) & 0xFF;
568
569 /* Call the driver */
571
572 /* Wait for it to complete */
574 {
575 DPRINT1("PortSendReportLuns(): Waiting for the driver to process request...\n");
577 Executive,
579 FALSE,
580 NULL);
581 Status = IoStatusBlock.Status;
582 }
583
584 DPRINT("PortSendReportLuns(): Request processed by driver, status = 0x%08X\n", Status);
585
587 {
588 ULONG DataSize = 0;
589
590 /* Extract LUN count from the return data. This is the sole purpose of this function */
591 DataSize |= (((ULONG)ReportLunsData->LunListLength[0]) << (8*0));
592 DataSize |= (((ULONG)ReportLunsData->LunListLength[1]) << (8*1));
593 DataSize |= (((ULONG)ReportLunsData->LunListLength[2]) << (8*2));
594 DataSize |= (((ULONG)ReportLunsData->LunListLength[3]) << (8*3));
595 *LunCount = ((DataSize - FIELD_OFFSET(REPORT_LUNS_DATA, LunDescriptor)) /
596 sizeof(LUN_DESCRIPTOR));
597
598 /* Quit the loop */
600 KeepTrying = FALSE;
601 continue;
602 }
603
604 DPRINT1("REPORT_LUNS SRB failed with SrbStatus 0x%08X Status %08X\n",
606
607 /* Check if the queue is frozen */
609 {
610 /* Something weird happened, deal with it (unfreeze the queue) */
611 KeepTrying = FALSE;
612
613 DPRINT1("PortSendReportLuns(): the queue is frozen at TargetId %d\n", Srb.TargetId);
614 /* TODO: What do we do with this crap */
615#if 0
616 LunExtension = SpiGetLunExtension(DeviceExtension,
617 LunInfo->PathId,
618 LunInfo->TargetId,
619 LunInfo->Lun);
620
621 /* Clear frozen flag */
622 LunExtension->Flags &= ~LUNEX_FROZEN_QUEUE;
623
624 /* Acquire the spinlock */
625 KeAcquireSpinLock(&DeviceExtension->SpinLock, &Irql);
626
627 /* Process the request */
628 SpiGetNextRequestFromLun(DeviceObject->DeviceExtension, LunExtension);
629
630 /* SpiGetNextRequestFromLun() releases the spinlock,
631 so we just lower irql back to what it was before */
633#endif
634 }
635
636 /* Check if data overrun happened, then resize buffer once */
637 /* FIXME: Needs coverage test */
639 {
640 /* If the buffer has already been reallocated we ditch the device */
641 if (BufferReallocated)
642 {
643 DPRINT1("Data overrun again (!) at TargetId %d, give up\n", PdoExtension->Target);
644
646 KeepTrying = FALSE;
647 continue;
648 }
649
650 /* Miniport will return how many bytes should we actually allocate */
651 BufferSize = 0;
652 BufferSize |= (((ULONG)ReportLunsData->LunListLength[0]) << (8*0));
653 BufferSize |= (((ULONG)ReportLunsData->LunListLength[1]) << (8*1));
654 BufferSize |= (((ULONG)ReportLunsData->LunListLength[2]) << (8*2));
655 BufferSize |= (((ULONG)ReportLunsData->LunListLength[3]) << (8*3));
656
657 DPRINT1("Data overrun at TargetId %d, %d bytes needed\n",
658 PdoExtension->Target,
659 BufferSize);
660
661 /* Allocate a larger buffer */
662 ExFreePoolWithTag(ReportLunsData, TAG_REPORT_LUN_DATA);
664 if (ReportLunsData == NULL)
665 {
666 DPRINT1("Cannot reallocate REPORT_LUNS buffer\n");
667
669 KeepTrying = FALSE;
670 continue;
671 }
672 BufferReallocated = TRUE;
673
674 /* Continue trying with a larger buffer */
675 continue;
676 }else
677 {
678 /* Retry a couple of times if no timeout happened */
679 if ((RetryCount < 2) &&
682 {
683 RetryCount++;
684 KeepTrying = TRUE;
685 }
686 else
687 {
688 /* That's all, quit the loop */
689 KeepTrying = FALSE;
690
691 /* Set status according to SRB status */
694 {
696 }
697 else
698 {
700 }
701 }
702 }
703 }
704
705 /* Free Sense data and Report LUNs buffer */
706 ExFreePoolWithTag(ReportLunsData, TAG_REPORT_LUN_DATA);
707 ExFreePoolWithTag(SenseBuffer, TAG_SENSE_DATA);
708
709 DPRINT1("PortSendReportLuns() done with Status 0x%08X\n", Status);
710
711 return Status;
712}
713
714
715static
719{
721 PIO_STACK_LOCATION IrpStack;
723// KIRQL Irql;
724 PIRP Irp;
726 PSENSE_DATA SenseBuffer;
727 BOOLEAN KeepTrying = TRUE;
728 ULONG RetryCount = 0;
730 PCDB Cdb;
731// PSCSI_PORT_LUN_EXTENSION LunExtension;
732// PFDO_DEVICE_EXTENSION DeviceExtension;
733
734 DPRINT("PortSendInquiry(%p)\n", PdoExtension);
735
736 if (PdoExtension->InquiryBuffer == NULL)
737 {
739 if (PdoExtension->InquiryBuffer == NULL)
741 }
742
744 if (SenseBuffer == NULL)
745 {
747 }
748
749 while (KeepTrying)
750 {
751 /* Initialize event for waiting */
754 FALSE);
755
756 /* Create an IRP */
758 PdoExtension->Device,
759 NULL,
760 0,
761 PdoExtension->InquiryBuffer,
763 TRUE,
764 &Event,
766 if (Irp == NULL)
767 {
768 DPRINT1("IoBuildDeviceIoControlRequest() failed\n");
769
770 /* Quit the loop */
772 KeepTrying = FALSE;
773 continue;
774 }
775
776 /* Prepare SRB */
778
779 Srb.Length = sizeof(SCSI_REQUEST_BLOCK);
781 Srb.PathId = PdoExtension->Bus;
782 Srb.TargetId = PdoExtension->Target;
783 Srb.Lun = PdoExtension->Lun;
786 Srb.TimeOutValue = 4;
787 Srb.CdbLength = 6;
788
789 Srb.SenseInfoBuffer = SenseBuffer;
791
792 Srb.DataBuffer = PdoExtension->InquiryBuffer;
794
795 /* Attach Srb to the Irp */
796 IrpStack = IoGetNextIrpStackLocation(Irp);
797 IrpStack->Parameters.Scsi.Srb = &Srb;
798
799 /* Fill in CDB */
800 Cdb = (PCDB)Srb.Cdb;
801 Cdb->CDB6INQUIRY.OperationCode = SCSIOP_INQUIRY;
802 Cdb->CDB6INQUIRY.LogicalUnitNumber = PdoExtension->Lun;
803 Cdb->CDB6INQUIRY.AllocationLength = INQUIRYDATABUFFERSIZE;
804
805 /* Call the driver */
807
808 /* Wait for it to complete */
809 if (Status == STATUS_PENDING)
810 {
811 DPRINT1("PortSendInquiry(): Waiting for the driver to process request...\n");
813 Executive,
815 FALSE,
816 NULL);
817 Status = IoStatusBlock.Status;
818 }
819
820 DPRINT1("PortSendInquiry(): Request processed by driver, status = 0x%08X\n", Status);
821
823 {
824 DPRINT1("Found a device!\n");
825
826 /* Quit the loop */
828 KeepTrying = FALSE;
829 continue;
830 }
831
832 DPRINT1("Inquiry SRB failed with SrbStatus 0x%08X\n", Srb.SrbStatus);
833
834 /* Check if the queue is frozen */
836 {
837 /* Something weird happened, deal with it (unfreeze the queue) */
838 KeepTrying = FALSE;
839
840 DPRINT1("SpiSendInquiry(): the queue is frozen at TargetId %d\n", Srb.TargetId);
841
842// LunExtension = SpiGetLunExtension(DeviceExtension,
843// LunInfo->PathId,
844// LunInfo->TargetId,
845// LunInfo->Lun);
846
847 /* Clear frozen flag */
848// LunExtension->Flags &= ~LUNEX_FROZEN_QUEUE;
849
850 /* Acquire the spinlock */
851// KeAcquireSpinLock(&DeviceExtension->SpinLock, &Irql);
852
853 /* Process the request */
854// SpiGetNextRequestFromLun(DeviceObject->DeviceExtension, LunExtension);
855
856 /* SpiGetNextRequestFromLun() releases the spinlock,
857 so we just lower irql back to what it was before */
858// KeLowerIrql(Irql);
859 }
860
861 /* Check if data overrun happened */
863 {
864 DPRINT("Data overrun at TargetId %d\n", PdoExtension->Target);
865
866 /* Quit the loop */
868 KeepTrying = FALSE;
869 }
871 SenseBuffer->SenseKey == SCSI_SENSE_ILLEGAL_REQUEST)
872 {
873 /* LUN is not valid, but some device responds there.
874 Mark it as invalid anyway */
875
876 /* Quit the loop */
878 KeepTrying = FALSE;
879 }
880 else
881 {
882 /* Retry a couple of times if no timeout happened */
883 if ((RetryCount < 2) &&
886 {
887 RetryCount++;
888 KeepTrying = TRUE;
889 }
890 else
891 {
892 /* That's all, quit the loop */
893 KeepTrying = FALSE;
894
895 /* Set status according to SRB status */
898 {
900 }
901 else
902 {
904 }
905 }
906 }
907 }
908
909 /* Free the sense buffer */
910 ExFreePoolWithTag(SenseBuffer, TAG_SENSE_DATA);
911
912 DPRINT1("PortSendInquiry() done with Status 0x%08X\n", Status);
913
914 return Status;
915}
916
917
918
919static
922 _In_ PFDO_DEVICE_EXTENSION DeviceExtension)
923{
925 ULONG Bus, Target; //, Lun;
927 ULONG LunCount = 0;
928
929 DPRINT("PortFdoScanBus(%p)\n", DeviceExtension);
930
931 DPRINT("NumberOfBuses: %lu\n", DeviceExtension->Miniport.PortConfig.NumberOfBuses);
932 DPRINT("MaximumNumberOfTargets: %lu\n", DeviceExtension->Miniport.PortConfig.MaximumNumberOfTargets);
933 DPRINT("MaximumNumberOfLogicalUnits: %lu\n", DeviceExtension->Miniport.PortConfig.MaximumNumberOfLogicalUnits);
934
935 /* Scan all buses */
936 for (Bus = 0; Bus < DeviceExtension->Miniport.PortConfig.NumberOfBuses; Bus++)
937 {
938 DPRINT("Scanning bus %ld\n", Bus);
939
940 /* Scan all targets */
941 for (Target = 0; Target < DeviceExtension->Miniport.PortConfig.MaximumNumberOfTargets; Target++)
942 {
943 DPRINT(" Scanning target %ld:%ld\n", Bus, Target);
944
945 DPRINT(" Scanning logical unit %ld:%ld:%ld\n", Bus, Target, 0);
946 Status = PortCreatePdo(DeviceExtension, Bus, Target, 0, &PdoExtension);
947 if (NT_SUCCESS(Status))
948 {
949 /* Send Report LUNs first */
951
952 /* Scan LUN 0 */
954 DPRINT("PortSendInquiry returned 0x%08lx\n", Status);
955 if (!NT_SUCCESS(Status))
956 {
958 }
959 else
960 {
961 DPRINT("VendorId: %.8s\n", PdoExtension->InquiryBuffer->VendorId);
962 DPRINT("ProductId: %.16s\n", PdoExtension->InquiryBuffer->ProductId);
963 DPRINT("ProductRevisionLevel: %.4s\n", PdoExtension->InquiryBuffer->ProductRevisionLevel);
964 DPRINT("VendorSpecific: %.20s\n", PdoExtension->InquiryBuffer->VendorSpecific);
965 }
966 }
967
968#if 0
969 /* Scan all logical units */
970 for (Lun = 1; Lun < DeviceExtension->Miniport.PortConfig.MaximumNumberOfLogicalUnits; Lun++)
971 {
972 DPRINT(" Scanning logical unit %ld:%ld:%ld\n", Bus, Target, Lun);
973 Status = PortSendInquiry(DeviceExtension->Device, Bus, Target, Lun);
974 DPRINT("PortSendInquiry returned 0x%08lx\n", Status);
975 if (!NT_SUCCESS(Status))
976 break;
977 }
978#endif
979 }
980 }
981
982 DPRINT("PortFdoScanBus() done!\n");
983
984 return STATUS_SUCCESS;
985}
986
987
988static
991 _In_ PFDO_DEVICE_EXTENSION DeviceExtension,
993{
995 PDEVICE_RELATIONS DeviceRelations = NULL;
998 PLIST_ENTRY PdoEntry;
999 ULONG PdoCount, PdoIndex = 0;
1000
1001 DPRINT("PortFdoQueryBusRelations(%p %p)\n",
1002 DeviceExtension, Information);
1003
1004 Status = PortFdoScanBus(DeviceExtension);
1005
1006 PdoCount = DeviceExtension->PdoCount;
1007
1008 DPRINT1("Units found: %lu\n", PdoCount);
1009
1010 /* Following part referred to SCSIport */
1011 DeviceRelations = ExAllocatePoolWithTag(PagedPool,
1012 FIELD_OFFSET(DEVICE_RELATIONS, Objects[PdoCount]),
1014 if (!DeviceRelations)
1015 {
1016 *Information = 0;
1018 }
1019
1020 /* Set PDO pointers */
1021 KeAcquireInStackQueuedSpinLock(&DeviceExtension->PdoListLock, &LockHandle);
1022
1023 for (PdoEntry = DeviceExtension->PdoListHead.Flink;
1024 PdoEntry != &DeviceExtension->PdoListHead && PdoIndex < PdoCount;
1025 PdoEntry = PdoEntry->Flink)
1026 {
1029 PdoListEntry);
1030
1031 if (PdoExtension->PnpState == dsRemoved ||
1032 PdoExtension->PnpState == dsSurpriseRemoved)
1033 {
1034 continue;
1035 }
1036
1038
1039 DeviceRelations->Objects[PdoIndex] = PdoExtension->Device;
1040
1041 /* Next one */
1042 ++PdoIndex;
1043 }
1044
1046
1047 DeviceRelations->Count = PdoIndex;
1048
1049 *Information = (ULONG_PTR)DeviceRelations;
1050
1051 return Status;
1052}
1053
1054
1055static
1058 PFDO_DEVICE_EXTENSION DeviceExtension,
1059 PIRP Irp)
1060{
1062
1063 DPRINT("PortFdoFilterRequirements(%p %p)\n", DeviceExtension, Irp);
1064
1065 /* Get the bus number and the slot number */
1066 RequirementsList =(PIO_RESOURCE_REQUIREMENTS_LIST)Irp->IoStatus.Information;
1068 {
1069 DeviceExtension->BusNumber = RequirementsList->BusNumber;
1070 DeviceExtension->SlotNumber = RequirementsList->SlotNumber;
1071 }
1072
1073 return STATUS_SUCCESS;
1074}
1075
1076
1080 _In_ ULONG Bus,
1082 _In_ ULONG Lun)
1083{
1086 PLIST_ENTRY PdoEntry;
1087
1089
1090 for (PdoEntry = FdoExtension->PdoListHead.Flink;
1091 PdoEntry != &FdoExtension->PdoListHead;
1092 PdoEntry = PdoEntry->Flink)
1093 {
1094 PdoExtension = CONTAINING_RECORD(PdoEntry, PDO_DEVICE_EXTENSION, PdoListEntry);
1095
1096 if (PdoExtension->Bus == Bus && PdoExtension->Target == Target &&
1097 PdoExtension->Lun == Lun)
1098 {
1100 return PdoExtension;
1101 }
1102 }
1103
1105 return NULL;
1106}
1107
1108
1110NTAPI
1113 _In_ PIRP Irp)
1114{
1115 PFDO_DEVICE_EXTENSION DeviceExtension;
1116// PIO_STACK_LOCATION Stack;
1119
1120 DPRINT("PortFdoScsi(%p %p)\n", DeviceObject, Irp);
1121
1122 DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
1123 ASSERT(DeviceExtension);
1124 ASSERT(DeviceExtension->ExtensionType == FdoExtension);
1125
1126// Stack = IoGetCurrentIrpStackLocation(Irp);
1127
1128
1129 Irp->IoStatus.Information = Information;
1130 Irp->IoStatus.Status = Status;
1132
1133 return Status;
1134}
1135
1136
1138NTAPI
1141 _In_ PIRP Irp)
1142{
1143 PFDO_DEVICE_EXTENSION DeviceExtension;
1147
1148 DPRINT1("PortFdoPnp(%p %p)\n",
1149 DeviceObject, Irp);
1150
1151 DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
1152 ASSERT(DeviceExtension);
1153 ASSERT(DeviceExtension->ExtensionType == FdoExtension);
1154
1156
1157 switch (Stack->MinorFunction)
1158 {
1159 case IRP_MN_START_DEVICE: /* 0x00 */
1160 DPRINT("IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
1161 Status = PortFdoStartDevice(DeviceExtension, Irp);
1162 break;
1163
1164 case IRP_MN_QUERY_REMOVE_DEVICE: /* 0x01 */
1165 DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_REMOVE_DEVICE\n");
1166 break;
1167
1168 case IRP_MN_REMOVE_DEVICE: /* 0x02 */
1169 DPRINT1("IRP_MJ_PNP / IRP_MN_REMOVE_DEVICE\n");
1170 PortFlushStarvedRequests(DeviceExtension);
1171 PortFreeRequestReserve(DeviceExtension);
1173 break;
1174
1175 case IRP_MN_CANCEL_REMOVE_DEVICE: /* 0x03 */
1176 DPRINT1("IRP_MJ_PNP / IRP_MN_CANCEL_REMOVE_DEVICE\n");
1177 break;
1178
1179 case IRP_MN_STOP_DEVICE: /* 0x04 */
1180 DPRINT1("IRP_MJ_PNP / IRP_MN_STOP_DEVICE\n");
1181 break;
1182
1183 case IRP_MN_QUERY_STOP_DEVICE: /* 0x05 */
1184 DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_STOP_DEVICE\n");
1185 break;
1186
1187 case IRP_MN_CANCEL_STOP_DEVICE: /* 0x06 */
1188 DPRINT1("IRP_MJ_PNP / IRP_MN_CANCEL_STOP_DEVICE\n");
1189 break;
1190
1191 case IRP_MN_QUERY_DEVICE_RELATIONS: /* 0x07 */
1192 switch (Stack->Parameters.QueryDeviceRelations.Type)
1193 {
1194 case BusRelations:
1195 DPRINT(" IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations\n");
1196 Status = PortFdoQueryBusRelations(DeviceExtension, &Information);
1197 break;
1198
1199 case RemovalRelations:
1200 DPRINT1(" IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / RemovalRelations\n");
1201 return ForwardIrpAndForget(DeviceExtension->LowerDevice, Irp);
1202
1203 default:
1204 DPRINT1(" IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
1205 Stack->Parameters.QueryDeviceRelations.Type);
1206 return ForwardIrpAndForget(DeviceExtension->LowerDevice, Irp);
1207 }
1208 break;
1209
1211 DPRINT("IRP_MJ_PNP / IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n");
1212 PortFdoFilterRequirements(DeviceExtension, Irp);
1213 return ForwardIrpAndForget(DeviceExtension->LowerDevice, Irp);
1214
1215 case IRP_MN_QUERY_PNP_DEVICE_STATE: /* 0x14 */
1216 DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_PNP_DEVICE_STATE\n");
1217 break;
1218
1219 case IRP_MN_DEVICE_USAGE_NOTIFICATION: /* 0x16 */
1220 DPRINT1("IRP_MJ_PNP / IRP_MN_DEVICE_USAGE_NOTIFICATION\n");
1221 break;
1222
1223 case IRP_MN_SURPRISE_REMOVAL: /* 0x17 */
1224 DPRINT1("IRP_MJ_PNP / IRP_MN_SURPRISE_REMOVAL\n");
1225 break;
1226
1227 default:
1228 DPRINT1("IRP_MJ_PNP / Unknown IOCTL 0x%lx\n", Stack->MinorFunction);
1229 return ForwardIrpAndForget(DeviceExtension->LowerDevice, Irp);
1230 }
1231
1232 Irp->IoStatus.Information = Information;
1233 Irp->IoStatus.Status = Status;
1235
1236 return Status;
1237}
1238
1239/* EOF */
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
unsigned char BOOLEAN
Definition: actypes.h:127
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
_In_ PSCSI_REQUEST_BLOCK Srb
Definition: cdrom.h:989
#define IOCTL_SCSI_EXECUTE_IN
Definition: cdrw_hw.h:1451
#define SCSIOP_INQUIRY
Definition: cdrw_hw.h:888
#define SENSE_BUFFER_SIZE
Definition: cdrw_hw.h:1183
#define SCSI_SENSE_ILLEGAL_REQUEST
Definition: cdrw_hw.h:1192
union _CDB * PCDB
#define INQUIRYDATABUFFERSIZE
Definition: cdrw_hw.h:1113
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR _In_ UCHAR _In_ UCHAR Lun
Definition: classpnp.h:1315
NTKERNELAPI NTSTATUS NTAPI IoCsqInitialize(_Out_ PIO_CSQ Csq, _In_ PIO_CSQ_INSERT_IRP CsqInsertIrp, _In_ PIO_CSQ_REMOVE_IRP CsqRemoveIrp, _In_ PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp, _In_ PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock, _In_ PIO_CSQ_RELEASE_LOCK CsqReleaseLock, _In_ PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp)
Set up a CSQ struct to initialize the queue.
Definition: csq.c:103
_In_opt_ PIRP _In_opt_ PVOID PeekContext
Definition: csq.h:160
_Out_ PKIRQL Irql
Definition: csq.h:179
NTKERNELAPI VOID NTAPI IoCsqInsertIrp(_Inout_ PIO_CSQ Csq, _Inout_ PIRP Irp, _Out_opt_ PIO_CSQ_IRP_CONTEXT Context)
Insert an IRP into the CSQ.
Definition: csq.c:177
NTKERNELAPI PIRP NTAPI IoCsqRemoveNextIrp(_Inout_ PIO_CSQ Csq, _In_opt_ PVOID PeekContext)
IoCsqRemoveNextIrp - Removes the next IRP from the queue.
Definition: csq.c:398
IO_CSQ Csq
Definition: csqrtns.c:46
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
#define BufferSize
Definition: mmc.h:75
_In_ ULONG BufferSize
Definition: dispmprt.h:490
_In_ PIO_STATUS_BLOCK IoStatusBlock
Definition: dispmprt.h:608
_Check_return_ _In_ DXGK_EVENT_TYPE _In_ ULONG Event
Definition: dispmprt.h:1287
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
ULONG_PTR KAFFINITY
Definition: compat.h:85
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
@ dsSurpriseRemoved
Definition: pci.h:39
@ dsRemoved
Definition: pci.h:38
#define ULONG_PTR
Definition: config.h:101
#define SCSIOP_REPORT_LUNS
Definition: scsi.h:921
struct _SCSI_REQUEST_BLOCK SCSI_REQUEST_BLOCK
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:315
#define SRB_STATUS_DATA_OVERRUN
Definition: srb.h:357
#define SRB_STATUS_ABORTED
Definition: srb.h:342
#define SRB_STATUS_PENDING
Definition: srb.h:340
#define SRB_STATUS_BAD_SRB_BLOCK_LENGTH
Definition: srb.h:360
#define SRB_STATUS_AUTOSENSE_VALID
Definition: srb.h:387
#define SRB_FLAGS_DATA_IN
Definition: srb.h:400
#define SRB_STATUS_SELECTION_TIMEOUT
Definition: srb.h:350
#define SRB_STATUS_BAD_FUNCTION
Definition: srb.h:364
#define SRB_FLAGS_DISABLE_SYNCH_TRANSFER
Definition: srb.h:397
#define SRB_STATUS(Status)
Definition: srb.h:389
#define SRB_STATUS_QUEUE_FROZEN
Definition: srb.h:386
#define SRB_STATUS_NO_DEVICE
Definition: srb.h:348
#define SRB_STATUS_SUCCESS
Definition: srb.h:341
INTERFACE_TYPE GetBusInterface(PDEVICE_OBJECT DeviceObject)
Definition: misc.c:33
NTSTATUS QueryBusInterface(PDEVICE_OBJECT DeviceObject, PGUID Guid, USHORT Size, USHORT Version, PBUS_INTERFACE_STANDARD Interface, PVOID InterfaceSpecificData)
Definition: misc.c:122
PCM_RESOURCE_LIST CopyResourceList(POOL_TYPE PoolType, PCM_RESOURCE_LIST Source)
Definition: misc.c:92
NTSTATUS GetResourceListInterrupt(PFDO_DEVICE_EXTENSION DeviceExtension, PULONG Vector, PKIRQL Irql, KINTERRUPT_MODE *InterruptMode, PBOOLEAN ShareVector, PKAFFINITY Affinity)
Definition: misc.c:242
NTSTATUS NTAPI PortPdoScsi(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: srb.c:516
#define TAG_SRB_EXTENSION
Definition: precomp.h:41
#define TAG_DEVICE_RELATION
Definition: precomp.h:30
#define TAG_QUEUED_REQUEST
Definition: precomp.h:40
#define TAG_REPORT_LUN_DATA
Definition: precomp.h:38
struct _REPORT_LUNS_DATA REPORT_LUNS_DATA
PHW_INITIALIZATION_DATA PortGetDriverInitData(PDRIVER_OBJECT_EXTENSION DriverExtension, INTERFACE_TYPE InterfaceType)
Definition: storport.c:81
struct _REPORT_LUNS_DATA * PREPORT_LUNS_DATA
#define TAG_INQUIRY_DATA
Definition: precomp.h:37
@ PdoExtension
Definition: precomp.h:61
@ FdoExtension
Definition: precomp.h:60
#define TAG_SENSE_DATA
Definition: precomp.h:39
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:50
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertTailList(ListHead, Entry)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
KIRQL * PKIRQL
Definition: env_spec_w32.h:592
#define NonPagedPool
Definition: env_spec_w32.h:307
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
#define PagedPool
Definition: env_spec_w32.h:308
Status
Definition: gdiplustypes.h:24
VOID FASTCALL KeAcquireInStackQueuedSpinLock(IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:130
VOID FASTCALL KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:166
DRIVER_DISPATCH ForwardIrpAndForget
Definition: i8042prt.h:341
FORCEINLINE VOID StorpCompleteRequest(_In_ PIRP Irp, _In_ UCHAR SrbStatus, _In_ NTSTATUS IrpStatus)
Completes a request with specified SRB status and IRP status.
Definition: inline.h:19
PCONFIGURATION_INFORMATION NTAPI IoGetConfigurationInformation(VOID)
Returns a pointer to the I/O manager's global configuration information structure.
Definition: iorsrce.c:998
@ dsStopped
Definition: isapnp.h:30
@ dsStarted
Definition: isapnp.h:31
_In_ PIRP Irp
Definition: kse.h:79
if(dx< 0)
Definition: linetemp.h:194
VOID NTAPI ExDeleteNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside)
Definition: lookas.c:170
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4755
#define KernelMode
Definition: asm.h:38
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
@ NotificationEvent
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IoCompleteRequest
Definition: irp.c:1272
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:913
BOOLEAN NTAPI IoForwardIrpSynchronously(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1657
#define IoCallDriver
Definition: irp.c:1257
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:23
@ InterfaceTypeUndefined
Definition: restypes.h:121
enum _INTERFACE_TYPE INTERFACE_TYPE
_In_opt_ WDFREQUEST _In_ ULONG _In_ BOOLEAN _In_ PCDB Cdb
Definition: scratch.h:159
enum _KINTERRUPT_MODE KINTERRUPT_MODE
Entry
Definition: section.c:5216
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
VOID SpiGetNextRequestFromLun(_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, _Inout_ PSCSI_PORT_LUN_EXTENSION LunExtension, _Inout_opt_ PKIRQL OldIrql)
Definition: scsi.c:342
static NTSTATUS PortFdoStartMiniport(_In_ PFDO_DEVICE_EXTENSION DeviceExtension)
Definition: fdo.c:307
VOID PortFlushStarvedRequests(_In_ PFDO_DEVICE_EXTENSION FdoExtension)
Fails every queued request, for when the adapter goes away.
Definition: fdo.c:153
PPDO_DEVICE_EXTENSION FdoFindLun(_In_ PFDO_DEVICE_EXTENSION FdoExtension, _In_ ULONG Bus, _In_ ULONG Target, _In_ ULONG Lun)
Definition: fdo.c:1078
static VOID NTAPI PortStarvedCsqInsertIrp(_In_ PIO_CSQ Csq, _In_ PIRP Irp)
Definition: fdo.c:24
static NTSTATUS PortFdoFilterRequirements(PFDO_DEVICE_EXTENSION DeviceExtension, PIRP Irp)
Definition: fdo.c:1057
static NTSTATUS PortSendInquiry(_In_ PPDO_DEVICE_EXTENSION PdoExtension)
Definition: fdo.c:717
static NTSTATUS PortFdoScanBus(_In_ PFDO_DEVICE_EXTENSION DeviceExtension)
Definition: fdo.c:921
static NTSTATUS PortSendReportLuns(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _Out_ PULONG LunCount)
Definition: fdo.c:473
VOID PortFreeRequestReserve(_In_ PFDO_DEVICE_EXTENSION FdoExtension)
Releases the reserve. No request may be using it anymore.
Definition: fdo.c:205
NTSTATUS PortInitializeStarvedRequestQueue(_In_ PSTARVED_REQUEST_QUEUE Queue)
Definition: fdo.c:105
VOID PortQueueStarvedRequest(_In_ PFDO_DEVICE_EXTENSION FdoExtension, _In_ PIRP Irp)
Queues a request that could not allocate its private contexts.
Definition: fdo.c:124
static VOID NTAPI PortStarvedCsqAcquireLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: fdo.c:71
static NTSTATUS PortFdoStartDevice(_In_ PFDO_DEVICE_EXTENSION DeviceExtension, _In_ PIRP Irp)
Definition: fdo.c:381
static NTSTATUS PortFdoQueryBusRelations(_In_ PFDO_DEVICE_EXTENSION DeviceExtension, _Out_ PULONG_PTR Information)
Definition: fdo.c:990
static BOOLEAN NTAPI PortFdoInterruptRoutine(_In_ PKINTERRUPT Interrupt, _In_ PVOID ServiceContext)
Definition: fdo.c:224
VOID PortRetryStarvedRequest(_In_ PFDO_DEVICE_EXTENSION FdoExtension)
Retries one queued request, so each completion lets exactly one through.
Definition: fdo.c:135
static PIRP NTAPI PortStarvedCsqPeekNextIrp(_In_ PIO_CSQ Csq, _In_ PIRP Irp, _In_ PVOID PeekContext)
Definition: fdo.c:48
static VOID NTAPI PortStarvedCsqRemoveIrp(_In_ PIO_CSQ Csq, _In_ PIRP Irp)
Definition: fdo.c:36
NTSTATUS NTAPI PortFdoScsi(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: fdo.c:1111
static VOID NTAPI PortStarvedCsqCompleteCanceledIrp(_In_ PIO_CSQ Csq, _In_ PIRP Irp)
Definition: fdo.c:95
static VOID NTAPI PortStarvedCsqReleaseLock(_In_ PIO_CSQ Csq, _In_ KIRQL Irql)
Definition: fdo.c:83
VOID PortAllocateRequestReserve(_In_ PFDO_DEVICE_EXTENSION FdoExtension)
Reserves the memory a single request needs, so IO can still be issued out of pool.
Definition: fdo.c:168
static NTSTATUS PortFdoConnectInterrupt(_In_ PFDO_DEVICE_EXTENSION DeviceExtension)
Definition: fdo.c:241
NTSTATUS NTAPI PortFdoPnp(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: fdo.c:1139
NTSTATUS MiniportFindAdapter(_In_ PMINIPORT Miniport)
Definition: miniport.c:294
BOOLEAN MiniportHwInterrupt(_In_ PMINIPORT Miniport)
Definition: miniport.c:362
NTSTATUS MiniportHwInitialize(_In_ PMINIPORT Miniport)
Definition: miniport.c:346
NTSTATUS PortDeletePdo(_In_ PPDO_DEVICE_EXTENSION PdoExtension)
Definition: pdo.c:108
NTSTATUS PortCreatePdo(_In_ PFDO_DEVICE_EXTENSION FdoDeviceExtension, _In_ ULONG Bus, _In_ ULONG Target, _In_ ULONG Lun, _Out_ PPDO_DEVICE_EXTENSION *PdoDeviceExtension)
Definition: pdo.c:21
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2165
PDEVICE_OBJECT LowerDevice
Definition: i8042prt.h:130
ULONG BusNumber
Definition: pci.h:88
NPAGED_LOOKASIDE_LIST RequestReferenceLookaside
Definition: precomp.h:281
EXTENSION_TYPE ExtensionType
Definition: precomp.h:230
Definition: csq.h:222
union _IO_STACK_LOCATION::@1814 Parameters
struct _IO_STACK_LOCATION::@5020::@5042 Scsi
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
UCHAR LunListLength[4]
Definition: precomp.h:379
ULONG TimeOutValue
Definition: srb.h:262
UCHAR TargetId
Definition: srb.h:254
PVOID OriginalRequest
Definition: srb.h:266
UCHAR SenseInfoBufferLength
Definition: srb.h:259
PVOID DataBuffer
Definition: srb.h:263
UCHAR PathId
Definition: srb.h:253
UCHAR CdbLength
Definition: srb.h:258
UCHAR Cdb[16]
Definition: srb.h:279
PVOID SenseInfoBuffer
Definition: srb.h:264
UCHAR Function
Definition: srb.h:250
ULONG DataTransferLength
Definition: srb.h:261
ULONG SrbFlags
Definition: srb.h:260
USHORT Length
Definition: srb.h:249
UCHAR SrbStatus
Definition: srb.h:251
UCHAR SenseKey
Definition: cdrw_hw.h:1167
#define STATUS_PENDING
Definition: telnetd.h:14
uint32_t * PULONG_PTR
Definition: typedefs.h:65
uint32_t * PULONG
Definition: typedefs.h:59
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NTAPI
Definition: typedefs.h:36
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_IO_DEVICE_ERROR
Definition: udferr_usr.h:179
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
Definition: cdrw_hw.h:28
struct _CDB::_CDB6INQUIRY CDB6INQUIRY
struct _CDB::_REPORT_LUNS REPORT_LUNS
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2061
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
Definition: wdfdevice.h:2231
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
Definition: wdffdo.h:463
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFINTERRUPT * Interrupt
Definition: wdfinterrupt.h:379
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049
_In_ WDFIORESREQLIST RequirementsList
Definition: wdfresource.h:65
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:174
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2702
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK _In_ ULONG _In_ KIRQL _In_ KIRQL _In_ KINTERRUPT_MODE InterruptMode
Definition: iofuncs.h:806
_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:807
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID ServiceContext
Definition: iofuncs.h:801
#define IRP_MN_CANCEL_STOP_DEVICE
@ RemovalRelations
Definition: iotypes.h:2157
@ BusRelations
Definition: iotypes.h:2154
#define IRP_MN_QUERY_PNP_DEVICE_STATE
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IRP_MN_START_DEVICE
#define IRP_MN_DEVICE_USAGE_NOTIFICATION
#define IRP_MN_REMOVE_DEVICE
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IRP_MN_QUERY_STOP_DEVICE
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_STOP_DEVICE
struct _IO_RESOURCE_REQUIREMENTS_LIST * PIO_RESOURCE_REQUIREMENTS_LIST
#define IRP_MN_QUERY_REMOVE_DEVICE
*LockHandle LockHandle _Out_ PKLOCK_QUEUE_HANDLE LockHandle
Definition: kefuncs.h:717
@ Executive
Definition: ketypes.h:467
#define ObReferenceObject
Definition: obfuncs.h:204