ReactOS  0.4.13-dev-544-gede3fdd
storport.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 driver main file
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 /* GLOBALS ********************************************************************/
17 
19 
20 
21 /* FUNCTIONS ******************************************************************/
22 
23 static
28 {
29  PDRIVER_INIT_DATA InitData;
30 
31  DPRINT1("PortAddDriverInitData()\n");
32 
34  sizeof(DRIVER_INIT_DATA),
36  if (InitData == NULL)
37  return STATUS_NO_MEMORY;
38 
39  RtlCopyMemory(&InitData->HwInitData,
41  sizeof(HW_INITIALIZATION_DATA));
42 
43  InsertHeadList(&DriverExtension->InitDataListHead,
44  &InitData->Entry);
45 
46  return STATUS_SUCCESS;
47 }
48 
49 
50 static
51 VOID
54 {
55  PDRIVER_INIT_DATA InitData;
56  PLIST_ENTRY ListEntry;
57 
58  DPRINT1("PortDeleteDriverInitData()\n");
59 
60  ListEntry = DriverExtension->InitDataListHead.Flink;
61  while (ListEntry != &DriverExtension->InitDataListHead)
62  {
63  InitData = CONTAINING_RECORD(ListEntry,
65  Entry);
66 
67  RemoveEntryList(&InitData->Entry);
68 
69  ExFreePoolWithTag(InitData,
71 
72  ListEntry = DriverExtension->InitDataListHead.Flink;
73  }
74 }
75 
76 
80  INTERFACE_TYPE InterfaceType)
81 {
82  PDRIVER_INIT_DATA InitData;
83  PLIST_ENTRY ListEntry;
84 
85  DPRINT1("PortGetDriverInitData()\n");
86 
87  ListEntry = DriverExtension->InitDataListHead.Flink;
88  while (ListEntry != &DriverExtension->InitDataListHead)
89  {
90  InitData = CONTAINING_RECORD(ListEntry,
92  Entry);
93  if (InitData->HwInitData.AdapterInterfaceType == InterfaceType)
94  return &InitData->HwInitData;
95 
96  ListEntry = ListEntry->Flink;
97  }
98 
99  return NULL;
100 }
101 
102 
103 static
104 VOID
106  PFDO_DEVICE_EXTENSION DeviceExtension,
108  PVOID LockContext,
110 {
111  DPRINT1("PortAcquireSpinLock(%p %lu %p %p)\n",
112  DeviceExtension, SpinLock, LockContext, LockHandle);
113 
114  LockHandle->Lock = SpinLock;
115 
116  switch (SpinLock)
117  {
118  case DpcLock: /* 1, */
119  DPRINT1("DpcLock\n");
120  break;
121 
122  case StartIoLock: /* 2 */
123  DPRINT1("StartIoLock\n");
124  break;
125 
126  case InterruptLock: /* 3 */
127  DPRINT1("InterruptLock\n");
128  if (DeviceExtension->Interrupt == NULL)
129  LockHandle->Context.OldIrql = 0;
130  else
131  LockHandle->Context.OldIrql = KeAcquireInterruptSpinLock(DeviceExtension->Interrupt);
132  break;
133  }
134 }
135 
136 
137 static
138 VOID
140  PFDO_DEVICE_EXTENSION DeviceExtension,
142 {
143  DPRINT1("PortReleaseSpinLock(%p %p)\n",
144  DeviceExtension, LockHandle);
145 
146  switch (LockHandle->Lock)
147  {
148  case DpcLock: /* 1, */
149  DPRINT1("DpcLock\n");
150  break;
151 
152  case StartIoLock: /* 2 */
153  DPRINT1("StartIoLock\n");
154  break;
155 
156  case InterruptLock: /* 3 */
157  DPRINT1("InterruptLock\n");
158  if (DeviceExtension->Interrupt != NULL)
159  KeReleaseInterruptSpinLock(DeviceExtension->Interrupt,
160  LockHandle->Context.OldIrql);
161  break;
162  }
163 }
164 
165 
166 static
167 NTSTATUS
168 NTAPI
172 {
173  PDRIVER_OBJECT_EXTENSION DriverObjectExtension;
174  PFDO_DEVICE_EXTENSION DeviceExtension = NULL;
175  WCHAR NameBuffer[80];
177  PDEVICE_OBJECT Fdo = NULL;
180 
181  DPRINT1("PortAddDevice(%p %p)\n",
183 
186 
187  swprintf(NameBuffer,
188  L"\\Device\\RaidPort%lu",
189  PortNumber);
190  RtlInitUnicodeString(&DeviceName, NameBuffer);
191  PortNumber++;
192 
193  DPRINT1("Creating device: %wZ\n", &DeviceName);
194 
195  /* Create the port device */
197  sizeof(FDO_DEVICE_EXTENSION),
198  &DeviceName,
201  FALSE,
202  &Fdo);
203  if (!NT_SUCCESS(Status))
204  {
205  DPRINT1("IoCreateDevice() failed (Status 0x%08lx)\n", Status);
206  return Status;
207  }
208 
209  DPRINT1("Created device: %wZ (%p)\n", &DeviceName, Fdo);
210 
211  /* Initialize the device */
212  Fdo->Flags |= DO_DIRECT_IO;
213  Fdo->Flags |= DO_POWER_PAGABLE;
214 
215  /* Initialize the device extension */
216  DeviceExtension = (PFDO_DEVICE_EXTENSION)Fdo->DeviceExtension;
217  RtlZeroMemory(DeviceExtension, sizeof(FDO_DEVICE_EXTENSION));
218 
219  DeviceExtension->ExtensionType = FdoExtension;
220 
221  DeviceExtension->Device = Fdo;
222  DeviceExtension->PhysicalDevice = PhysicalDeviceObject;
223 
224  DeviceExtension->PnpState = dsStopped;
225 
226  InitializeListHead(&DeviceExtension->UnitListHead);
227 
228  /* Attach the FDO to the device stack */
231  &DeviceExtension->LowerDevice);
232  if (!NT_SUCCESS(Status))
233  {
234  DPRINT1("IoAttachDeviceToDeviceStackSafe() failed (Status 0x%08lx)\n", Status);
235  IoDeleteDevice(Fdo);
236  return Status;
237  }
238 
239  /* Insert the FDO to the drivers FDO list */
240  DriverObjectExtension = IoGetDriverObjectExtension(DriverObject,
241  (PVOID)DriverEntry);
242  ASSERT(DriverObjectExtension->ExtensionType == DriverExtension);
243 
244  DeviceExtension->DriverExtension = DriverObjectExtension;
245 
246  KeAcquireInStackQueuedSpinLock(&DriverObjectExtension->AdapterListLock,
247  &LockHandle);
248 
249  InsertHeadList(&DriverObjectExtension->AdapterListHead,
250  &DeviceExtension->AdapterListEntry);
251  DriverObjectExtension->AdapterCount++;
252 
254 
255  /* The device has been initialized */
256  Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
257 
258  DPRINT1("PortAddDevice() done (Status 0x%08lx)\n", Status);
259 
260  return Status;
261 }
262 
263 
264 static
265 VOID
266 NTAPI
269 {
271 
272  DPRINT1("PortUnload(%p)\n",
273  DriverObject);
274 
276  (PVOID)DriverEntry);
277  if (DriverExtension != NULL)
278  {
280  }
281 }
282 
283 
284 static
285 NTSTATUS
286 NTAPI
289  IN PIRP Irp)
290 {
291  DPRINT1("PortDispatchCreate(%p %p)\n",
292  DeviceObject, Irp);
293 
294  Irp->IoStatus.Status = STATUS_SUCCESS;
295  Irp->IoStatus.Information = FILE_OPENED;
296 
298 
299  return STATUS_SUCCESS;
300 }
301 
302 
303 static
304 NTSTATUS
305 NTAPI
308  IN PIRP Irp)
309 {
310  DPRINT1("PortDispatchClose(%p %p)\n",
311  DeviceObject, Irp);
312 
313  Irp->IoStatus.Status = STATUS_SUCCESS;
314  Irp->IoStatus.Information = 0;
315 
317 
318  return STATUS_SUCCESS;
319 }
320 
321 
322 static
323 NTSTATUS
324 NTAPI
327  IN PIRP Irp)
328 {
329  DPRINT1("PortDispatchDeviceControl(%p %p)\n",
330  DeviceObject, Irp);
331 
332  Irp->IoStatus.Status = STATUS_SUCCESS;
333  Irp->IoStatus.Information = 0;
334 
336 
337  return STATUS_SUCCESS;
338 }
339 
340 
341 static
342 NTSTATUS
343 NTAPI
346  IN PIRP Irp)
347 {
348  PFDO_DEVICE_EXTENSION DeviceExtension;
349 
350  DPRINT1("PortDispatchScsi(%p %p)\n",
351  DeviceObject, Irp);
352 
354  DPRINT1("ExtensionType: %u\n", DeviceExtension->ExtensionType);
355 
356  switch (DeviceExtension->ExtensionType)
357  {
358  case FdoExtension:
359  return PortFdoScsi(DeviceObject,
360  Irp);
361 
362  case PdoExtension:
363  return PortPdoScsi(DeviceObject,
364  Irp);
365 
366  default:
367  Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
368  Irp->IoStatus.Information = 0;
370  return STATUS_UNSUCCESSFUL;
371  }
372 
373  return STATUS_SUCCESS;
374 }
375 
376 
377 static
378 NTSTATUS
379 NTAPI
382  IN PIRP Irp)
383 {
384  DPRINT1("PortDispatchSystemControl(%p %p)\n",
385  DeviceObject, Irp);
386 
387  Irp->IoStatus.Status = STATUS_SUCCESS;
388  Irp->IoStatus.Information = 0;
389 
391 
392  return STATUS_SUCCESS;
393 }
394 
395 
396 static
397 NTSTATUS
398 NTAPI
401  IN PIRP Irp)
402 {
403  PFDO_DEVICE_EXTENSION DeviceExtension;
404 
405  DPRINT1("PortDispatchPnp(%p %p)\n",
406  DeviceObject, Irp);
407 
409  DPRINT1("ExtensionType: %u\n", DeviceExtension->ExtensionType);
410 
411  switch (DeviceExtension->ExtensionType)
412  {
413  case FdoExtension:
414  return PortFdoPnp(DeviceObject,
415  Irp);
416 
417  case PdoExtension:
418  return PortPdoPnp(DeviceObject,
419  Irp);
420 
421  default:
422  Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
423  Irp->IoStatus.Information = 0;
425  return STATUS_UNSUCCESSFUL;
426  }
427 }
428 
429 
430 static
431 NTSTATUS
432 NTAPI
435  IN PIRP Irp)
436 {
437  DPRINT1("PortDispatchPower(%p %p)\n",
438  DeviceObject, Irp);
439 
440  Irp->IoStatus.Status = STATUS_SUCCESS;
441  Irp->IoStatus.Information = 0;
442 
444 
445  return STATUS_SUCCESS;
446 }
447 
448 
449 /* PUBLIC FUNCTIONS ***********************************************************/
450 
451 /*
452  * @implemented
453  */
454 NTSTATUS
455 NTAPI
459 {
460  DPRINT1("DriverEntry(%p %p)\n", DriverObject, RegistryPath);
461  return STATUS_SUCCESS;
462 }
463 
464 
465 /*
466  * @unimplemented
467  */
469 PUCHAR
470 NTAPI
472  _In_ PVOID HwDeviceExtension,
474 {
475  DPRINT1("StorPortAllocateRegistryBuffer()\n");
477  return NULL;
478 }
479 
480 
481 /*
482  * @unimplemented
483  */
485 BOOLEAN
486 NTAPI
488  _In_ PVOID HwDeviceExtension,
489  _In_ ULONG RequestsToComplete)
490 {
491  DPRINT1("StorPortBuzy()\n");
493  return FALSE;
494 }
495 
496 
497 /*
498  * @unimplemented
499  */
501 VOID
502 NTAPI
504  _In_ PVOID HwDeviceExtension,
505  _In_ UCHAR PathId,
507  _In_ UCHAR Lun,
508  _In_ UCHAR SrbStatus)
509 {
510  DPRINT1("StorPortCompleteRequest()\n");
512 }
513 
514 
515 /*
516  * @implemented
517  */
519 ULONG
520 NTAPI
523 {
524  DPRINT1("StorPortConvertPhysicalAddressToUlong()\n");
525 
526  return Address.u.LowPart;
527 }
528 
529 
530 /*
531  * @implemented
532  */
535 NTAPI
537  _In_ ULONG_PTR UlongAddress)
538 {
540 
541  DPRINT1("StorPortConvertUlongToPhysicalAddress()\n");
542 
543  Address.QuadPart = UlongAddress;
544  return Address;
545 }
546 
547 
548 /*
549  * @implemented
550  */
552 VOID
554  _In_ ULONG DebugPrintLevel,
555  _In_ PCHAR DebugMessage,
556  ...)
557 {
558  va_list ap;
559 
560  va_start(ap, DebugMessage);
561  vDbgPrintExWithPrefix("STORMINI: ", 0x58, DebugPrintLevel, DebugMessage, ap);
562  va_end(ap);
563 }
564 
565 
566 /*
567  * @unimplemented
568  */
570 BOOLEAN
571 NTAPI
573  _In_ PVOID HwDeviceExtension,
574  _In_ UCHAR PathId,
576  _In_ UCHAR Lun,
577  _In_ ULONG RequestsToComplete)
578 {
579  DPRINT1("StorPortDeviceBusy()\n");
581  return FALSE;
582 }
583 
584 
585 /*
586  * @unimplemented
587  */
589 BOOLEAN
590 NTAPI
592  _In_ PVOID HwDeviceExtension,
593  _In_ UCHAR PathId,
595  _In_ UCHAR Lun)
596 {
597  DPRINT1("StorPortDeviceReady()\n");
599  return FALSE;
600 }
601 
602 
603 /*
604  * @unimplemented
605  */
607 ULONG
609  _In_ STORPORT_FUNCTION_CODE FunctionCode,
610  _In_ PVOID HwDeviceExtension,
611  ...)
612 {
613  DPRINT1("StorPortExtendedFunction(%d %p ...)\n",
614  FunctionCode, HwDeviceExtension);
616  return STATUS_NOT_IMPLEMENTED;
617 }
618 
619 
620 /*
621  * @implemented
622  */
624 VOID
625 NTAPI
627  _In_ PVOID HwDeviceExtension,
628  _In_ PVOID MappedAddress)
629 {
630  DPRINT1("StorPortFreeDeviceBase(%p %p)\n",
631  HwDeviceExtension, MappedAddress);
632 }
633 
634 
635 /*
636  * @unimplemented
637  */
639 VOID
640 NTAPI
642  _In_ PVOID HwDeviceExtension,
644 {
645  DPRINT1("StorPortFreeRegistryBuffer()\n");
647 }
648 
649 
650 /*
651  * @implemented
652  */
654 ULONG
655 NTAPI
657  _In_ PVOID DeviceExtension,
658  _In_ ULONG BusDataType,
659  _In_ ULONG SystemIoBusNumber,
662  _In_ ULONG Length)
663 {
664  PMINIPORT_DEVICE_EXTENSION MiniportExtension;
667 
668  DPRINT1("StorPortGetBusData(%p %lu %lu %lu %p %lu)\n",
669  DeviceExtension, BusDataType, SystemIoBusNumber, SlotNumber, Buffer, Length);
670 
671  /* Get the miniport extension */
672  MiniportExtension = CONTAINING_RECORD(DeviceExtension,
674  HwDeviceExtension);
675  DPRINT1("DeviceExtension %p MiniportExtension %p\n",
676  DeviceExtension, MiniportExtension);
677 
678  Interface = &MiniportExtension->Miniport->DeviceExtension->BusInterface;
679 
680  if (BusDataType == 4)
681  BusDataType = 0;
682 
683  ReturnLength = Interface->GetBusData(Interface->Context,
684  BusDataType,
685  Buffer,
686  0,
687  Length);
688  DPRINT1("ReturnLength: %lu\n", ReturnLength);
689 
690  return ReturnLength;
691 }
692 
693 
694 /*
695  * @implemented
696  */
698 PVOID
699 NTAPI
701  _In_ PVOID HwDeviceExtension,
703  _In_ ULONG SystemIoBusNumber,
704  _In_ STOR_PHYSICAL_ADDRESS IoAddress,
706  _In_ BOOLEAN InIoSpace)
707 {
708  PMINIPORT_DEVICE_EXTENSION MiniportExtension;
710  PVOID MappedAddress;
712 
713  DPRINT1("StorPortGetDeviceBase(%p %lu %lu 0x%I64x %lu %u)\n",
714  HwDeviceExtension, BusType, SystemIoBusNumber, IoAddress.QuadPart, NumberOfBytes, InIoSpace);
715 
716  /* Get the miniport extension */
717  MiniportExtension = CONTAINING_RECORD(HwDeviceExtension,
719  HwDeviceExtension);
720  DPRINT1("HwDeviceExtension %p MiniportExtension %p\n",
721  HwDeviceExtension, MiniportExtension);
722 
723  if (!TranslateResourceListAddress(MiniportExtension->Miniport->DeviceExtension,
724  BusType,
725  SystemIoBusNumber,
726  IoAddress,
728  InIoSpace,
730  {
731  DPRINT1("Checkpoint!\n");
732  return NULL;
733  }
734 
735  DPRINT1("Translated Address: 0x%I64x\n", TranslatedAddress.QuadPart);
736 
737  /* In I/O space */
738  if (InIoSpace)
739  {
740  DPRINT1("Translated Address: %p\n", (PVOID)(ULONG_PTR)TranslatedAddress.QuadPart);
742  }
743 
744  /* In memory space */
745  MappedAddress = MmMapIoSpace(TranslatedAddress,
747  FALSE);
748  DPRINT1("Mapped Address: %p\n", MappedAddress);
749 
750  Status = AllocateAddressMapping(&MiniportExtension->Miniport->DeviceExtension->MappedAddressList,
751  IoAddress,
752  MappedAddress,
754  SystemIoBusNumber);
755  if (!NT_SUCCESS(Status))
756  {
757  DPRINT1("Checkpoint!\n");
758  MappedAddress = NULL;
759  }
760 
761  DPRINT1("Mapped Address: %p\n", MappedAddress);
762  return MappedAddress;
763 }
764 
765 
766 /*
767  * @unimplemented
768  */
770 PVOID
771 NTAPI
773  _In_ PVOID HwDeviceExtension,
774  _In_ UCHAR PathId,
776  _In_ UCHAR Lun)
777 {
778  DPRINT1("StorPortGetLogicalUnit()\n");
780  return NULL;
781 }
782 
783 
784 /*
785  * @implemented
786  */
789 NTAPI
791  _In_ PVOID HwDeviceExtension,
794  _Out_ ULONG *Length)
795 {
796  PMINIPORT_DEVICE_EXTENSION MiniportExtension;
797  PFDO_DEVICE_EXTENSION DeviceExtension;
800 
801  DPRINT1("StorPortGetPhysicalAddress(%p %p %p %p)\n",
802  HwDeviceExtension, Srb, VirtualAddress, Length);
803 
804  /* Get the miniport extension */
805  MiniportExtension = CONTAINING_RECORD(HwDeviceExtension,
807  HwDeviceExtension);
808  DPRINT1("HwDeviceExtension %p MiniportExtension %p\n",
809  HwDeviceExtension, MiniportExtension);
810 
811  DeviceExtension = MiniportExtension->Miniport->DeviceExtension;
812 
813  /* Inside of the uncached extension? */
814  if (((ULONG_PTR)VirtualAddress >= (ULONG_PTR)DeviceExtension->UncachedExtensionVirtualBase) &&
815  ((ULONG_PTR)VirtualAddress <= (ULONG_PTR)DeviceExtension->UncachedExtensionVirtualBase + DeviceExtension->UncachedExtensionSize))
816  {
818 
820  *Length = DeviceExtension->UncachedExtensionSize - Offset;
821 
822  return PhysicalAddress;
823  }
824 
825  // FIXME
826 
827 
829  *Length = 1;
830 // UNIMPLEMENTED;
831 
832 // *Length = 0;
833 // PhysicalAddress.QuadPart = (LONGLONG)0;
834 
835  return PhysicalAddress;
836 }
837 
838 
839 /*
840  * @unimplemented
841  */
844 NTAPI
846  _In_ PVOID DeviceExtension,
848 {
849  DPRINT1("StorPortGetScatterGatherList()\n");
851  return NULL;
852 }
853 
854 
855 /*
856  * @implemented
857  */
860 NTAPI
862  _In_ PVOID DeviceExtension,
863  _In_ UCHAR PathId,
865  _In_ UCHAR Lun,
866  _In_ LONG QueueTag)
867 {
868  DPRINT("StorPortGetSrb()\n");
869  return NULL;
870 }
871 
872 
873 /*
874  * @implemented
875  */
877 PVOID
878 NTAPI
880  _In_ PVOID HwDeviceExtension,
883 {
884  PMINIPORT_DEVICE_EXTENSION MiniportExtension;
885  PFDO_DEVICE_EXTENSION DeviceExtension;
886  PHYSICAL_ADDRESS LowestAddress, HighestAddress, Alignment;
887 
888  DPRINT1("StorPortGetUncachedExtension(%p %p %lu)\n",
889  HwDeviceExtension, ConfigInfo, NumberOfBytes);
890 
891  /* Get the miniport extension */
892  MiniportExtension = CONTAINING_RECORD(HwDeviceExtension,
894  HwDeviceExtension);
895  DPRINT1("HwDeviceExtension %p MiniportExtension %p\n",
896  HwDeviceExtension, MiniportExtension);
897 
898  DeviceExtension = MiniportExtension->Miniport->DeviceExtension;
899 
900  /* Return the uncached extension base address if we already have one */
901  if (DeviceExtension->UncachedExtensionVirtualBase != NULL)
902  return DeviceExtension->UncachedExtensionVirtualBase;
903 
904  // FIXME: Set DMA stuff here?
905 
906  /* Allocate the uncached extension */
907  Alignment.QuadPart = 0;
908  LowestAddress.QuadPart = 0;
909  HighestAddress.QuadPart = 0x00000000FFFFFFFF;
911  LowestAddress,
912  HighestAddress,
913  Alignment,
914  MmCached);
915  if (DeviceExtension->UncachedExtensionVirtualBase == NULL)
916  return NULL;
917 
919  DeviceExtension->UncachedExtensionSize = NumberOfBytes;
920 
921  return DeviceExtension->UncachedExtensionVirtualBase;
922 }
923 
924 
925 /*
926  * @unimplemented
927  */
929 PVOID
930 NTAPI
932  _In_ PVOID HwDeviceExtension,
934 {
935  DPRINT1("StorPortGetVirtualAddress(%p %I64x)\n",
936  HwDeviceExtension, PhysicalAddress.QuadPart);
938  return NULL;
939 }
940 
941 
942 /*
943  * @implemented
944  */
946 ULONG
947 NTAPI
953 {
956  PDRIVER_OBJECT_EXTENSION DriverObjectExtension;
958 
959  DPRINT1("StorPortInitialize(%p %p %p %p)\n",
961 
962  DPRINT1("HwInitializationDataSize: %lu\n", HwInitializationData->HwInitializationDataSize);
963  DPRINT1("AdapterInterfaceType: %u\n", HwInitializationData->AdapterInterfaceType);
964  DPRINT1("HwInitialize: %p\n", HwInitializationData->HwInitialize);
965  DPRINT1("HwStartIo: %p\n", HwInitializationData->HwStartIo);
966  DPRINT1("HwInterrupt: %p\n", HwInitializationData->HwInterrupt);
967  DPRINT1("HwFindAdapter: %p\n", HwInitializationData->HwFindAdapter);
968  DPRINT1("HwResetBus: %p\n", HwInitializationData->HwResetBus);
969  DPRINT1("HwDmaStarted: %p\n", HwInitializationData->HwDmaStarted);
970  DPRINT1("HwAdapterState: %p\n", HwInitializationData->HwAdapterState);
971  DPRINT1("DeviceExtensionSize: %lu\n", HwInitializationData->DeviceExtensionSize);
972  DPRINT1("SpecificLuExtensionSize: %lu\n", HwInitializationData->SpecificLuExtensionSize);
973  DPRINT1("SrbExtensionSize: %lu\n", HwInitializationData->SrbExtensionSize);
974  DPRINT1("NumberOfAccessRanges: %lu\n", HwInitializationData->NumberOfAccessRanges);
975 
976  /* Check parameters */
977  if ((DriverObject == NULL) ||
978  (RegistryPath == NULL) ||
980  {
981  DPRINT1("Invalid parameter!\n");
983  }
984 
985  /* Check initialization data */
986  if ((HwInitializationData->HwInitializationDataSize < sizeof(HW_INITIALIZATION_DATA)) ||
987  (HwInitializationData->HwInitialize == NULL) ||
988  (HwInitializationData->HwStartIo == NULL) ||
989  (HwInitializationData->HwFindAdapter == NULL) ||
990  (HwInitializationData->HwResetBus == NULL))
991  {
992  DPRINT1("Revision mismatch!\n");
994  }
995 
996  DriverObjectExtension = IoGetDriverObjectExtension(DriverObject,
997  (PVOID)DriverEntry);
998  if (DriverObjectExtension == NULL)
999  {
1000  DPRINT1("No driver object extension!\n");
1001 
1003  (PVOID)DriverEntry,
1004  sizeof(DRIVER_OBJECT_EXTENSION),
1005  (PVOID *)&DriverObjectExtension);
1006  if (!NT_SUCCESS(Status))
1007  {
1008  DPRINT1("IoAllocateDriverObjectExtension() failed (Status 0x%08lx)\n", Status);
1009  return Status;
1010  }
1011 
1012  DPRINT1("Driver object extension created!\n");
1013 
1014  /* Initialize the driver object extension */
1015  RtlZeroMemory(DriverObjectExtension,
1016  sizeof(DRIVER_OBJECT_EXTENSION));
1017 
1018  DriverObjectExtension->ExtensionType = DriverExtension;
1019  DriverObjectExtension->DriverObject = DriverObject;
1020 
1021  InitializeListHead(&DriverObjectExtension->AdapterListHead);
1022  KeInitializeSpinLock(&DriverObjectExtension->AdapterListLock);
1023 
1024  InitializeListHead(&DriverObjectExtension->InitDataListHead);
1025 
1026  /* Set handlers */
1028 // DriverObject->DriverStartIo = PortStartIo;
1037  }
1038 
1039  /* Add the initialzation data to the driver extension */
1040  Status = PortAddDriverInitData(DriverObjectExtension,
1042 
1043  DPRINT1("StorPortInitialize() done (Status 0x%08lx)\n", Status);
1044 
1045  return Status;
1046 }
1047 
1048 
1049 /*
1050  * @unimplemented
1051  */
1053 VOID
1054 NTAPI
1056  _In_ PVOID HwDeviceExtension,
1058  _In_ UCHAR PathId,
1060  _In_ UCHAR Lun,
1062  _In_ ULONG UniqueId)
1063 {
1064  DPRINT1("ScsiPortLogError() called\n");
1065  DPRINT1("PathId: 0x%02x TargetId: 0x%02x Lun: 0x%02x ErrorCode: 0x%08lx UniqueId: 0x%08lx\n",
1066  PathId, TargetId, Lun, ErrorCode, UniqueId);
1067 
1068  DPRINT1("ScsiPortLogError() done\n");
1069 }
1070 
1071 
1072 /*
1073  * @implemented
1074  */
1076 VOID
1077 NTAPI
1081  _In_ ULONG Length)
1082 {
1084 }
1085 
1086 
1087 /*
1088  * @unimplemented
1089  */
1091 VOID
1093  _In_ SCSI_NOTIFICATION_TYPE NotificationType,
1094  _In_ PVOID HwDeviceExtension,
1095  ...)
1096 {
1097  PMINIPORT_DEVICE_EXTENSION MiniportExtension = NULL;
1098  PFDO_DEVICE_EXTENSION DeviceExtension = NULL;
1099  PHW_PASSIVE_INITIALIZE_ROUTINE HwPassiveInitRoutine;
1100  PSTORPORT_EXTENDED_FUNCTIONS *ppExtendedFunctions;
1101  PBOOLEAN Result;
1102  PSTOR_DPC Dpc;
1103  PHW_DPC_ROUTINE HwDpcRoutine;
1104  va_list ap;
1105 
1107  PVOID LockContext;
1110 
1111  DPRINT1("StorPortNotification(%x %p)\n",
1112  NotificationType, HwDeviceExtension);
1113 
1114  /* Get the miniport extension */
1115  if (HwDeviceExtension != NULL)
1116  {
1117  MiniportExtension = CONTAINING_RECORD(HwDeviceExtension,
1119  HwDeviceExtension);
1120  DPRINT1("HwDeviceExtension %p MiniportExtension %p\n",
1121  HwDeviceExtension, MiniportExtension);
1122 
1123  DeviceExtension = MiniportExtension->Miniport->DeviceExtension;
1124  }
1125 
1126  va_start(ap, HwDeviceExtension);
1127 
1128  switch (NotificationType)
1129  {
1130  case RequestComplete:
1131  DPRINT1("RequestComplete\n");
1133  DPRINT1("Srb %p\n", Srb);
1134  if (Srb->OriginalRequest != NULL)
1135  {
1136  DPRINT1("Need to complete the IRP!\n");
1137 
1138  }
1139  break;
1140 
1142  DPRINT1("GetExtendedFunctionTable\n");
1144  if (ppExtendedFunctions != NULL)
1145  *ppExtendedFunctions = NULL; /* FIXME */
1146  break;
1147 
1149  DPRINT1("EnablePassiveInitialization\n");
1151  DPRINT1("HwPassiveInitRoutine %p\n", HwPassiveInitRoutine);
1153 
1154  *Result = FALSE;
1155 
1156  if ((DeviceExtension != NULL) &&
1157  (DeviceExtension->HwPassiveInitRoutine == NULL))
1158  {
1159  DeviceExtension->HwPassiveInitRoutine = HwPassiveInitRoutine;
1160  *Result = TRUE;
1161  }
1162  break;
1163 
1164  case InitializeDpc:
1165  DPRINT1("InitializeDpc\n");
1167  DPRINT1("Dpc %p\n", Dpc);
1168  HwDpcRoutine = (PHW_DPC_ROUTINE)va_arg(ap, PHW_DPC_ROUTINE);
1169  DPRINT1("HwDpcRoutine %p\n", HwDpcRoutine);
1170 
1171  KeInitializeDpc((PRKDPC)&Dpc->Dpc,
1172  (PKDEFERRED_ROUTINE)HwDpcRoutine,
1173  (PVOID)DeviceExtension);
1174  KeInitializeSpinLock(&Dpc->Lock);
1175  break;
1176 
1177  case AcquireSpinLock:
1178  DPRINT1("AcquireSpinLock\n");
1180  DPRINT1("SpinLock %lu\n", SpinLock);
1181  LockContext = (PVOID)va_arg(ap, PVOID);
1182  DPRINT1("LockContext %p\n", LockContext);
1184  DPRINT1("LockHandle %p\n", LockHandle);
1185  PortAcquireSpinLock(DeviceExtension,
1186  SpinLock,
1187  LockContext,
1188  LockHandle);
1189  break;
1190 
1191  case ReleaseSpinLock:
1192  DPRINT1("ReleaseSpinLock\n");
1194  DPRINT1("LockHandle %p\n", LockHandle);
1195  PortReleaseSpinLock(DeviceExtension,
1196  LockHandle);
1197  break;
1198 
1199  default:
1200  DPRINT1("Unsupported Notification %lx\n", NotificationType);
1201  break;
1202  }
1203 
1204  va_end(ap);
1205 }
1206 
1207 
1208 /*
1209  * @unimplemented
1210  */
1212 BOOLEAN
1213 NTAPI
1215  _In_ PVOID HwDeviceExtension,
1216  _In_ ULONG TimeOut)
1217 {
1218  DPRINT1("StorPortPause()\n");
1219  UNIMPLEMENTED;
1220  return FALSE;
1221 }
1222 
1223 
1224 /*
1225  * @unimplemented
1226  */
1228 BOOLEAN
1229 NTAPI
1231  _In_ PVOID HwDeviceExtension,
1232  _In_ UCHAR PathId,
1234  _In_ UCHAR Lun,
1235  _In_ ULONG TimeOut)
1236 {
1237  DPRINT1("StorPortPauseDevice()\n");
1238  UNIMPLEMENTED;
1239  return FALSE;
1240 }
1241 
1242 
1243 #if defined(_M_AMD64)
1244 /*
1245  * @implemented
1246  */
1247 /* KeQuerySystemTime is an inline function,
1248  so we cannot forward the export to ntoskrnl */
1250 VOID
1251 NTAPI
1253  _Out_ PLARGE_INTEGER CurrentTime)
1254 {
1255  DPRINT1("StorPortQuerySystemTime(%p)\n", CurrentTime);
1256 
1257  KeQuerySystemTime(CurrentTime);
1258 }
1259 #endif /* defined(_M_AMD64) */
1260 
1261 
1262 /*
1263  * @unimplemented
1264  */
1266 BOOLEAN
1267 NTAPI
1269  _In_ PVOID HwDeviceExtension)
1270 {
1271  DPRINT1("StorPortReady()\n");
1272  UNIMPLEMENTED;
1273  return FALSE;
1274 }
1275 
1276 
1277 /*
1278  * @unimplemented
1279  */
1281 BOOLEAN
1282 NTAPI
1284  _In_ PVOID HwDeviceExtension,
1286  _In_ ULONG Global,
1287  _In_ ULONG Type,
1288  _In_ PUCHAR Buffer,
1290 {
1291  DPRINT1("StorPortRegistryRead()\n");
1292  UNIMPLEMENTED;
1293  return FALSE;
1294 }
1295 
1296 
1297 /*
1298  * @unimplemented
1299  */
1301 BOOLEAN
1302 NTAPI
1304  _In_ PVOID HwDeviceExtension,
1306  _In_ ULONG Global,
1307  _In_ ULONG Type,
1308  _In_ PUCHAR Buffer,
1310 {
1311  DPRINT1("StorPortRegistryWrite()\n");
1312  UNIMPLEMENTED;
1313  return FALSE;
1314 }
1315 
1316 
1317 /*
1318  * @unimplemented
1319  */
1321 BOOLEAN
1322 NTAPI
1324  _In_ PVOID HwDeviceExtension)
1325 {
1326  DPRINT1("StorPortResume()\n");
1327  UNIMPLEMENTED;
1328  return FALSE;
1329 }
1330 
1331 
1332 /*
1333  * @unimplemented
1334  */
1336 BOOLEAN
1337 NTAPI
1339  _In_ PVOID HwDeviceExtension,
1340  _In_ UCHAR PathId,
1342  _In_ UCHAR Lun)
1343 {
1344  DPRINT1("StorPortResumeDevice()\n");
1345  UNIMPLEMENTED;
1346  return FALSE;
1347 }
1348 
1349 
1350 /*
1351  * @implemented
1352  */
1354 ULONG
1355 NTAPI
1357  _In_ PVOID DeviceExtension,
1358  _In_ ULONG BusDataType,
1359  _In_ ULONG SystemIoBusNumber,
1362  _In_ ULONG Offset,
1363  _In_ ULONG Length)
1364 {
1365  PMINIPORT_DEVICE_EXTENSION MiniportExtension;
1368 
1369  DPRINT1("StorPortSetBusData(%p %lu %lu %lu %p %lu %lu)\n",
1370  DeviceExtension, BusDataType, SystemIoBusNumber, SlotNumber, Buffer, Offset, Length);
1371 
1372  MiniportExtension = CONTAINING_RECORD(DeviceExtension,
1374  HwDeviceExtension);
1375  DPRINT1("DeviceExtension %p MiniportExtension %p\n",
1376  DeviceExtension, MiniportExtension);
1377 
1378  Interface = &MiniportExtension->Miniport->DeviceExtension->BusInterface;
1379 
1380  ReturnLength = Interface->SetBusData(Interface->Context,
1381  BusDataType,
1382  Buffer,
1383  Offset,
1384  Length);
1385  DPRINT1("ReturnLength: %lu\n", ReturnLength);
1386 
1387  return ReturnLength;
1388 }
1389 
1390 
1391 /*
1392  * @unimplemented
1393  */
1395 BOOLEAN
1396 NTAPI
1398  _In_ PVOID HwDeviceExtension,
1399  _In_ UCHAR PathId,
1401  _In_ UCHAR Lun,
1402  _In_ ULONG Depth)
1403 {
1404  DPRINT1("StorPortSetDeviceQueueDepth()\n");
1405  UNIMPLEMENTED;
1406  return FALSE;
1407 }
1408 
1409 
1410 /*
1411  * @implemented
1412  */
1414 VOID
1415 NTAPI
1417  _In_ ULONG Delay)
1418 {
1420 }
1421 
1422 
1423 /*
1424  * @unimplemented
1425  */
1427 VOID
1428 NTAPI
1430  _In_ PVOID HwDeviceExtension,
1431  _In_ PSTOR_SYNCHRONIZED_ACCESS SynchronizedAccessRoutine,
1433 {
1434  DPRINT1("StorPortSynchronizeAccess()\n");
1435  UNIMPLEMENTED;
1436 }
1437 
1438 
1439 /*
1440  * @implemented
1441  */
1443 BOOLEAN
1444 NTAPI
1446  _In_ PVOID HwDeviceExtension,
1448  _In_ ULONG SystemIoBusNumber,
1449  _In_ STOR_PHYSICAL_ADDRESS IoAddress,
1451  _In_ BOOLEAN InIoSpace)
1452 {
1453  DPRINT1("StorPortValidateRange()\n");
1454  return TRUE;
1455 }
1456 
1457 /* EOF */
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define STATUS_REVISION_MISMATCH
Definition: ntstatus.h:311
signed char * PCHAR
Definition: retypes.h:7
NTSTATUS NTAPI PortFdoScsi(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: fdo.c:494
#define DO_POWER_PAGABLE
STORPORT_API ULONG NTAPI StorPortConvertPhysicalAddressToUlong(_In_ STOR_PHYSICAL_ADDRESS Address)
Definition: storport.c:521
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
static VOID PortReleaseSpinLock(PFDO_DEVICE_EXTENSION DeviceExtension, PSTOR_LOCK_HANDLE LockHandle)
Definition: storport.c:139
#define IN
Definition: typedefs.h:38
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION _In_ ULONG _In_ SIZE_T _In_ ULONG _In_ USHORT Depth
Definition: exfuncs.h:656
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
PKINTERRUPT Interrupt
Definition: parport.h:51
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
PHYSICAL_ADDRESS UncachedExtensionPhysicalBase
Definition: precomp.h:109
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
PVOID UncachedExtensionVirtualBase
Definition: precomp.h:108
enum _INTERFACE_TYPE INTERFACE_TYPE
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR _In_ UCHAR _In_ UCHAR Lun
Definition: classpnp.h:1117
_IRQL_requires_same_ _In_opt_ PVOID Argument1
Definition: cmtypes.h:694
Type
Definition: Type.h:6
STORPORT_API VOID NTAPI StorPortMoveMemory(_Out_writes_bytes_(Length) PVOID Destination, _In_reads_bytes_(Length) PVOID Source, _In_ ULONG Length)
Definition: storport.c:1078
NTSTATUS NTAPI IoAllocateDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress, IN ULONG DriverObjectExtensionSize, OUT PVOID *DriverObjectExtension)
Definition: driver.c:1764
STORPORT_API STOR_PHYSICAL_ADDRESS NTAPI StorPortGetPhysicalAddress(_In_ PVOID HwDeviceExtension, _In_opt_ PSCSI_REQUEST_BLOCK Srb, _In_ PVOID VirtualAddress, _Out_ ULONG *Length)
Definition: storport.c:790
enum _STORPORT_FUNCTION_CODE STORPORT_FUNCTION_CODE
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
static NTSTATUS NTAPI PortDispatchPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: storport.c:399
STORPORT_API VOID NTAPI StorPortStallExecution(_In_ ULONG Delay)
Definition: storport.c:1416
enum _SCSI_NOTIFICATION_TYPE SCSI_NOTIFICATION_TYPE
struct _SCSI_REQUEST_BLOCK * PSCSI_REQUEST_BLOCK
PDEVICE_OBJECT Device
Definition: precomp.h:94
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE BusType
Definition: halfuncs.h:156
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR PathId
Definition: classpnp.h:1117
static VOID PortDeleteDriverInitData(PDRIVER_OBJECT_EXTENSION DriverExtension)
Definition: storport.c:52
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
NTSTATUS NTAPI PortPdoPnp(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: pdo.c:35
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR _In_ UCHAR TargetId
Definition: classpnp.h:1117
unsigned char * PUCHAR
Definition: retypes.h:3
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ PVOID _In_ struct _HW_INITIALIZATION_DATA _In_ PVOID HwContext
Definition: srb.h:664
#define FILE_OPENED
Definition: nt_native.h:769
static NTSTATUS NTAPI PortAddDevice(_In_ PDRIVER_OBJECT DriverObject, _In_ PDEVICE_OBJECT PhysicalDeviceObject)
Definition: storport.c:169
STORPORT_API BOOLEAN NTAPI StorPortPause(_In_ PVOID HwDeviceExtension, _In_ ULONG TimeOut)
Definition: storport.c:1214
static NTSTATUS PortAddDriverInitData(PDRIVER_OBJECT_EXTENSION DriverExtension, PHW_INITIALIZATION_DATA HwInitializationData)
Definition: storport.c:25
static NTSTATUS NTAPI PortDispatchScsi(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: storport.c:344
PHW_INITIALIZATION_DATA PortGetDriverInitData(PDRIVER_OBJECT_EXTENSION DriverExtension, INTERFACE_TYPE InterfaceType)
Definition: storport.c:78
STOR_SYNCHRONIZED_ACCESS * PSTOR_SYNCHRONIZED_ACCESS
Definition: storport.h:2188
#define TAG_INIT_DATA
Definition: precomp.h:27
EXTENSION_TYPE ExtensionType
Definition: precomp.h:92
enum _STOR_SPINLOCK STOR_SPINLOCK
PVOID NTAPI MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
Definition: iosup.c:47
WCHAR DeviceName[]
Definition: adapter.cpp:21
VOID FASTCALL KeAcquireInStackQueuedSpinLock(IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:130
STORPORT_API PSCSI_REQUEST_BLOCK NTAPI StorPortGetSrb(_In_ PVOID DeviceExtension, _In_ UCHAR PathId, _In_ UCHAR TargetId, _In_ UCHAR Lun, _In_ LONG QueueTag)
Definition: storport.c:861
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG _Out_ PPHYSICAL_ADDRESS TranslatedAddress
Definition: iofuncs.h:2268
NTSTATUS AllocateAddressMapping(PMAPPED_ADDRESS *MappedAddressList, STOR_PHYSICAL_ADDRESS IoAddress, PVOID MappedAddress, ULONG NumberOfBytes, ULONG BusNumber)
Definition: misc.c:331
STORPORT_API BOOLEAN NTAPI StorPortReady(_In_ PVOID HwDeviceExtension)
Definition: storport.c:1268
UNICODE_STRING Global
Definition: symlink.c:37
EXTENSION_TYPE ExtensionType
Definition: precomp.h:60
STORPORT_API VOID NTAPI StorPortFreeRegistryBuffer(_In_ PVOID HwDeviceExtension, _In_ PUCHAR Buffer)
Definition: storport.c:641
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
#define _In_opt_
Definition: no_sal2.h:213
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK SpinLock
Definition: iofuncs.h:798
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define IRP_MJ_SCSI
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
STORPORT_API VOID NTAPI StorPortSynchronizeAccess(_In_ PVOID HwDeviceExtension, _In_ PSTOR_SYNCHRONIZED_ACCESS SynchronizedAccessRoutine, _In_opt_ PVOID Context)
Definition: storport.c:1429
STORPORT_API BOOLEAN NTAPI StorPortSetDeviceQueueDepth(_In_ PVOID HwDeviceExtension, _In_ UCHAR PathId, _In_ UCHAR TargetId, _In_ UCHAR Lun, _In_ ULONG Depth)
Definition: storport.c:1397
_In_ PUNICODE_STRING ValueName
Definition: cmfuncs.h:264
LIST_ENTRY AdapterListEntry
Definition: precomp.h:99
STORPORT_API STOR_PHYSICAL_ADDRESS NTAPI StorPortConvertUlongToPhysicalAddress(_In_ ULONG_PTR UlongAddress)
Definition: storport.c:536
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FILE_DEVICE_CONTROLLER
Definition: winioctl.h:109
#define va_end(ap)
Definition: acmsvcex.h:90
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
long LONG
Definition: pedump.c:60
_In_ ULONG BufferLength
Definition: usbdlib.h:225
PDRIVER_EXTENSION DriverExtension
Definition: iotypes.h:2173
BOOLEAN TranslateResourceListAddress(PFDO_DEVICE_EXTENSION DeviceExtension, INTERFACE_TYPE BusType, ULONG SystemIoBusNumber, STOR_PHYSICAL_ADDRESS IoAddress, ULONG NumberOfBytes, BOOLEAN InIoSpace, PPHYSICAL_ADDRESS TranslatedAddress)
Definition: misc.c:213
union Alignment_ Alignment
VOID NTAPI KeReleaseInterruptSpinLock(IN PKINTERRUPT Interrupt, IN KIRQL OldIrql)
Definition: spinlock.c:165
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
ULONG PortNumber
Definition: storport.c:18
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
PDRIVER_OBJECT_EXTENSION DriverExtension
Definition: precomp.h:97
static WCHAR Address[46]
Definition: ping.c:68
#define _Out_writes_bytes_(size)
Definition: no_sal2.h:370
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define _Out_
Definition: no_sal2.h:323
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
#define IoCompleteRequest
Definition: irp.c:1240
char * va_list
Definition: acmsvcex.h:78
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
static NTSTATUS NTAPI PortDispatchSystemControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: storport.c:380
struct _STOR_LOCK_HANDLE * PSTOR_LOCK_HANDLE
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
_In_ PVOID Argument2
Definition: classpnp.h:680
#define STORPORT_API
Definition: storport.h:33
KSPIN_LOCK AdapterListLock
Definition: precomp.h:63
STORPORT_API VOID NTAPI StorPortLogError(_In_ PVOID HwDeviceExtension, _In_opt_ PSCSI_REQUEST_BLOCK Srb, _In_ UCHAR PathId, _In_ UCHAR TargetId, _In_ UCHAR Lun, _In_ ULONG ErrorCode, _In_ ULONG UniqueId)
Definition: storport.c:1055
ULONG UncachedExtensionSize
Definition: precomp.h:110
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
VOID FASTCALL KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:166
STORPORT_API PVOID NTAPI StorPortGetLogicalUnit(_In_ PVOID HwDeviceExtension, _In_ UCHAR PathId, _In_ UCHAR TargetId, _In_ UCHAR Lun)
Definition: storport.c:772
STORPORT_API ULONG StorPortExtendedFunction(_In_ STORPORT_FUNCTION_CODE FunctionCode, _In_ PVOID HwDeviceExtension,...)
Definition: storport.c:608
_In_ LARGE_INTEGER _In_opt_ PKDPC Dpc
Definition: kefuncs.h:524
STORPORT_API VOID StorPortDebugPrint(_In_ ULONG DebugPrintLevel, _In_ PCHAR DebugMessage,...)
Definition: storport.c:553
__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
NTSTATUS NTAPI PortPdoScsi(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: pdo.c:20
#define swprintf(buf, format,...)
Definition: sprintf.c:56
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:2875
NTSTATUS NTAPI PortFdoPnp(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: fdo.c:523
STORPORT_API BOOLEAN NTAPI StorPortResumeDevice(_In_ PVOID HwDeviceExtension, _In_ UCHAR PathId, _In_ UCHAR TargetId, _In_ UCHAR Lun)
Definition: storport.c:1338
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
KIRQL NTAPI KeAcquireInterruptSpinLock(IN PKINTERRUPT Interrupt)
Definition: spinlock.c:148
struct _MINIPORT * Miniport
Definition: precomp.h:72
PHW_PASSIVE_INITIALIZE_ROUTINE HwPassiveInitRoutine
Definition: precomp.h:111
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
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG _In_ ULONG SlotNumber
Definition: halfuncs.h:156
static VOID NTAPI PortUnload(_In_ PDRIVER_OBJECT DriverObject)
Definition: storport.c:267
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1060
unsigned char UCHAR
Definition: xmlstorage.h:181
static NTSTATUS NTAPI PortDispatchPower(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: storport.c:433
PDEVICE_OBJECT PhysicalDevice
Definition: precomp.h:96
char * PBOOLEAN
Definition: retypes.h:11
#define IRP_MJ_POWER
STORPORT_API BOOLEAN NTAPI StorPortResume(_In_ PVOID HwDeviceExtension)
Definition: storport.c:1323
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
STORPORT_API PSTOR_SCATTER_GATHER_LIST NTAPI StorPortGetScatterGatherList(_In_ PVOID DeviceExtension, _In_ PSCSI_REQUEST_BLOCK Srb)
Definition: storport.c:845
static const WCHAR L[]
Definition: oid.c:1250
static NTSTATUS NTAPI PortDispatchClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: storport.c:306
Definition: ketypes.h:687
KDEFERRED_ROUTINE * PKDEFERRED_ROUTINE
Definition: ketypes.h:678
PDRIVER_UNLOAD DriverUnload
Definition: iotypes.h:2179
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1842
Definition: typedefs.h:117
_In_ ULONG _In_ BOOLEAN _Must_inspect_result_ PVOID * VirtualAddress
Definition: ndis.h:3791
STORPORT_API ULONG NTAPI StorPortGetBusData(_In_ PVOID DeviceExtension, _In_ ULONG BusDataType, _In_ ULONG SystemIoBusNumber, _In_ ULONG SlotNumber, _Out_ _When_(Length !=0, _Out_writes_bytes_(Length)) PVOID Buffer, _In_ ULONG Length)
Definition: storport.c:656
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
STORPORT_API BOOLEAN NTAPI StorPortRegistryWrite(_In_ PVOID HwDeviceExtension, _In_ PUCHAR ValueName, _In_ ULONG Global, _In_ ULONG Type, _In_ PUCHAR Buffer, _In_ ULONG BufferLength)
Definition: storport.c:1303
#define _In_reads_bytes_(size)
Definition: no_sal2.h:229
#define IRP_MJ_SYSTEM_CONTROL
VOID(* PHW_DPC_ROUTINE)(_In_ PSTOR_DPC Dpc, _In_ PVOID HwDeviceExtension, _In_ PVOID SystemArgument1, _In_ PVOID SystemArgument2)
Definition: storport.h:2176
Status
Definition: gdiplustypes.h:24
STORPORT_API BOOLEAN NTAPI StorPortDeviceReady(_In_ PVOID HwDeviceExtension, _In_ UCHAR PathId, _In_ UCHAR TargetId, _In_ UCHAR Lun)
Definition: storport.c:591
LIST_ENTRY Entry
Definition: precomp.h:54
#define _In_
Definition: no_sal2.h:204
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1250
PDRIVER_ADD_DEVICE AddDevice
Definition: iotypes.h:2111
#define va_arg(ap, T)
Definition: acmsvcex.h:89
STORPORT_API BOOLEAN NTAPI StorPortBusy(_In_ PVOID HwDeviceExtension, _In_ ULONG RequestsToComplete)
Definition: storport.c:487
static NTSTATUS NTAPI PortDispatchCreate(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: storport.c:287
static VOID PortAcquireSpinLock(PFDO_DEVICE_EXTENSION DeviceExtension, STOR_SPINLOCK SpinLock, PVOID LockContext, PSTOR_LOCK_HANDLE LockHandle)
Definition: storport.c:105
STORPORT_API BOOLEAN NTAPI StorPortRegistryRead(_In_ PVOID HwDeviceExtension, _In_ PUCHAR ValueName, _In_ ULONG Global, _In_ ULONG Type, _In_ PUCHAR Buffer, _In_ PULONG BufferLength)
Definition: storport.c:1283
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
STORPORT_API BOOLEAN NTAPI StorPortPauseDevice(_In_ PVOID HwDeviceExtension, _In_ UCHAR PathId, _In_ UCHAR TargetId, _In_ UCHAR Lun, _In_ ULONG TimeOut)
Definition: storport.c:1230
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
STORPORT_API VOID NTAPI StorPortFreeDeviceBase(_In_ PVOID HwDeviceExtension, _In_ PVOID MappedAddress)
Definition: storport.c:626
unsigned int * PULONG
Definition: retypes.h:1
#define va_start(ap, A)
Definition: acmsvcex.h:91
NTSYSAPI NTSTATUS WINAPI vDbgPrintExWithPrefix(LPCSTR, ULONG, ULONG, LPCSTR, __ms_va_list)
STORPORT_API ULONG NTAPI StorPortSetBusDataByOffset(_In_ PVOID DeviceExtension, _In_ ULONG BusDataType, _In_ ULONG SystemIoBusNumber, _In_ ULONG SlotNumber, _In_reads_bytes_(Length) PVOID Buffer, _In_ ULONG Offset, _In_ ULONG Length)
Definition: storport.c:1356
#define _When_(expr, annos)
Definition: no_sal2.h:639
LIST_ENTRY AdapterListHead
Definition: precomp.h:64
UNICODE_STRING * PUNICODE_STRING
Definition: env_spec_w32.h:373
#define DPRINT1
Definition: precomp.h:8
DEVICE_STATE PnpState
Definition: i8042prt.h:132
STORPORT_API ULONG NTAPI StorPortInitialize(_In_ PVOID Argument1, _In_ PVOID Argument2, _In_ struct _HW_INITIALIZATION_DATA *HwInitializationData, _In_opt_ PVOID HwContext)
Definition: storport.c:948
STORPORT_API PVOID NTAPI StorPortGetDeviceBase(_In_ PVOID HwDeviceExtension, _In_ INTERFACE_TYPE BusType, _In_ ULONG SystemIoBusNumber, _In_ STOR_PHYSICAL_ADDRESS IoAddress, _In_ ULONG NumberOfBytes, _In_ BOOLEAN InIoSpace)
Definition: storport.c:700
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: iotypes.h:2180
struct _STOR_DPC * PSTOR_DPC
INTERFACE_TYPE AdapterInterfaceType
Definition: srb.h:557
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:997
NTSTATUS NTAPI DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath)
Definition: storport.c:456
STORPORT_API VOID NTAPI StorPortCompleteRequest(_In_ PVOID HwDeviceExtension, _In_ UCHAR PathId, _In_ UCHAR TargetId, _In_ UCHAR Lun, _In_ UCHAR SrbStatus)
Definition: storport.c:503
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:565
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
BOOLEAN(* PHW_PASSIVE_INITIALIZE_ROUTINE)(_In_ PVOID DeviceExtension)
Definition: storport.h:2171
static NTSTATUS NTAPI PortDispatchDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: storport.c:325
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNIMPLEMENTED
Definition: debug.h:114
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
STORPORT_API PVOID NTAPI StorPortGetVirtualAddress(_In_ PVOID HwDeviceExtension, _In_ STOR_PHYSICAL_ADDRESS PhysicalAddress)
Definition: storport.c:931
#define ULONG_PTR
Definition: config.h:101
STORPORT_API BOOLEAN NTAPI StorPortValidateRange(_In_ PVOID HwDeviceExtension, _In_ INTERFACE_TYPE BusType, _In_ ULONG SystemIoBusNumber, _In_ STOR_PHYSICAL_ADDRESS IoAddress, _In_ ULONG NumberOfBytes, _In_ BOOLEAN InIoSpace)
Definition: storport.c:1445
PHYSICAL_ADDRESS NTAPI MmGetPhysicalAddress(IN PVOID Address)
Definition: stubs.c:682
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
*LockHandle LockHandle _Out_ PKLOCK_QUEUE_HANDLE LockHandle
Definition: kefuncs.h:742
PDEVICE_OBJECT LowerDevice
Definition: i8042prt.h:130
STORPORT_API VOID NTAPI StorPortQuerySystemTime(_Out_ PLARGE_INTEGER CurrentTime)
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:711
return STATUS_SUCCESS
Definition: btrfs.c:2777
STORPORT_API VOID StorPortNotification(_In_ SCSI_NOTIFICATION_TYPE NotificationType, _In_ PVOID HwDeviceExtension,...)
Definition: storport.c:1092
STORPORT_API BOOLEAN NTAPI StorPortDeviceBusy(_In_ PVOID HwDeviceExtension, _In_ UCHAR PathId, _In_ UCHAR TargetId, _In_ UCHAR Lun, _In_ ULONG RequestsToComplete)
Definition: storport.c:572
LIST_ENTRY UnitListHead
Definition: precomp.h:116
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:99
base of all file and directory entries
Definition: entries.h:82
struct _DRIVER_OBJECT * PDRIVER_OBJECT
_Must_inspect_result_ _In_ PVOID _In_ struct _HW_INITIALIZATION_DATA * HwInitializationData
Definition: srb.h:664
STORPORT_API PVOID NTAPI StorPortGetUncachedExtension(_In_ PVOID HwDeviceExtension, _In_ PPORT_CONFIGURATION_INFORMATION ConfigInfo, _In_ ULONG NumberOfBytes)
Definition: storport.c:879
STORPORT_API PUCHAR NTAPI StorPortAllocateRegistryBuffer(_In_ PVOID HwDeviceExtension, _In_ PULONG Length)
Definition: storport.c:471
LONGLONG QuadPart
Definition: typedefs.h:112
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
HW_INITIALIZATION_DATA HwInitData
Definition: precomp.h:55
PVOID NTAPI MmAllocateContiguousMemorySpecifyCache(IN SIZE_T NumberOfBytes, IN PHYSICAL_ADDRESS LowestAcceptableAddress OPTIONAL, IN PHYSICAL_ADDRESS HighestAcceptableAddress, IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, IN MEMORY_CACHING_TYPE CacheType OPTIONAL)
Definition: contmem.c:569