ReactOS  0.4.15-dev-994-ga9f6032
obsolete.c File Reference
#include "classp.h"
#include "debug.h"
Include dependency graph for obsolete.c:

Go to the source code of this file.

Classes

struct  _CSCAN_LIST_ENTRY
 

Typedefs

typedef struct _CSCAN_LIST_ENTRY CSCAN_LIST_ENTRY
 
typedef struct _CSCAN_LIST_ENTRYPCSCAN_LIST_ENTRY
 

Functions

PIRP ClassRemoveCScanList (IN PCSCAN_LIST List)
 
VOID ClasspInitializeCScanList (IN PCSCAN_LIST List)
 
VOID NTAPI ClassSplitRequest (_In_ PDEVICE_OBJECT Fdo, _In_ PIRP Irp, _In_ ULONG MaximumBytes)
 
NTSTATUS NTAPI ClassIoCompleteAssociated (IN PDEVICE_OBJECT Fdo, IN PIRP Irp, IN PVOID Context)
 
VOID RetryRequest (PDEVICE_OBJECT DeviceObject, PIRP Irp, PSCSI_REQUEST_BLOCK Srb, BOOLEAN Associated, LONGLONG TimeDelta100ns)
 
NTSTATUS NTAPI ClassBuildRequest (_In_ PDEVICE_OBJECT Fdo, _In_ PIRP Irp)
 
VOID ClasspBuildRequestEx (_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, _In_ PIRP Irp, _In_ __drv_aliasesMem PSCSI_REQUEST_BLOCK Srb)
 
VOID ClasspInsertCScanList (IN PLIST_ENTRY ListHead, IN PCSCAN_LIST_ENTRY Entry)
 
VOID ClassInsertCScanList (IN PCSCAN_LIST List, IN PIRP Irp, IN ULONGLONG BlockNumber, IN BOOLEAN LowPriority)
 
VOID ClassFreeOrReuseSrb (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN __drv_freesMem(mem) PSCSI_REQUEST_BLOCK Srb)
 
 _IRQL_requires_max_ (PASSIVE_LEVEL)
 
VOID ClasspStartNextSweep (PCSCAN_LIST List)
 

Typedef Documentation

◆ CSCAN_LIST_ENTRY

◆ PCSCAN_LIST_ENTRY

Function Documentation

◆ _IRQL_requires_max_()

_IRQL_requires_max_ ( PASSIVE_LEVEL  )

Definition at line 956 of file obsolete.c.

960 {
961  PAGED_CODE();
962 
963  // This function is obsolete, but is still called by some of our code.
964  // TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_GENERAL, "ClassDeleteSrbLookasideList is OBSOLETE !"));
965 
966  if (CommonExtension->IsSrbLookasideListInitialized){
967  CommonExtension->IsSrbLookasideListInitialized = FALSE;
968  ExDeleteNPagedLookasideList(&CommonExtension->SrbLookasideList);
969  }
970  else {
971  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_GENERAL, "ClassDeleteSrbLookasideList: attempt to delete uninitialized or freed srblookasidelist"));
972  }
973 }
#define FALSE
Definition: types.h:117
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
VOID NTAPI ExDeleteNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside)
Definition: lookas.c:174
#define PAGED_CODE()

◆ ClassBuildRequest()

NTSTATUS NTAPI ClassBuildRequest ( _In_ PDEVICE_OBJECT  Fdo,
_In_ PIRP  Irp 
)

Definition at line 505 of file obsolete.c.

509 {
510  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Fdo->DeviceExtension;
511 
513 
514  // This function is obsolete, but still called by CDROM.SYS .
515  // TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_GENERAL, "ClassBuildRequest is OBSOLETE !"));
516 
517  //
518  // Allocate an Srb.
519  //
520 
521  srb = ClasspAllocateSrb(fdoExtension);
522 
523  if (srb == NULL) {
525  }
526 
527  ClasspBuildRequestEx(fdoExtension, Irp, srb);
528  return STATUS_SUCCESS;
529 
530 } // end ClassBuildRequest()
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
smooth NULL
Definition: ftsmooth.c:416
#define ClasspAllocateSrb(ext)
Definition: classpnp.h:146
VOID ClasspBuildRequestEx(_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, _In_ PIRP Irp, _In_ __drv_aliasesMem PSCSI_REQUEST_BLOCK Srb)
Definition: obsolete.c:537
return STATUS_SUCCESS
Definition: btrfs.c:3014

◆ ClassFreeOrReuseSrb()

VOID ClassFreeOrReuseSrb ( IN PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension,
IN __drv_freesMem(mem) PSCSI_REQUEST_BLOCK  Srb 
)

Definition at line 882 of file obsolete.c.

905 {
906  PCOMMON_DEVICE_EXTENSION commonExt = &FdoExtension->CommonExtension;
907 
908  // This function is obsolete, but still called by DISK.SYS .
909  // TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_GENERAL, "ClassFreeOrReuseSrb is OBSOLETE !"));
910 
911  //
912  // safety net. this should never occur. if it does, it's a potential
913  // memory leak.
914  //
916 
917  if (commonExt->IsSrbLookasideListInitialized){
918  /*
919  * Put the SRB back in our lookaside list.
920  *
921  * Note: Some class drivers use ClassIoComplete
922  * to complete SRBs that they themselves allocated.
923  * So we may be putting a "foreign" SRB
924  * (e.g. with a different pool tag) into our lookaside list.
925  */
927  }
928  else {
929  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_GENERAL,"ClassFreeOrReuseSrb: someone is trying to use an uninitialized SrbLookasideList !!!"));
930  FREE_POOL(Srb);
931  }
932 }
FORCEINLINE ULONG SrbGetSrbFlags(_In_ PVOID Srb)
Definition: srbhelper.h:927
#define TEST_FLAG(Flags, Bit)
Definition: classpnp.h:159
#define SRB_FLAGS_FREE_SENSE_BUFFER
Definition: srb.h:398
#define FREE_POOL(_PoolPtr)
Definition: classpnp.h:63
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
BOOLEAN IsSrbLookasideListInitialized
Definition: classpnp.h:610
#define ClasspFreeSrb(ext, srb)
Definition: classpnp.h:150
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by _Success_(), ClassIoComplete(), ClassIoCompleteAssociated(), and ClasspEjectionControl().

◆ ClassInsertCScanList()

VOID ClassInsertCScanList ( IN PCSCAN_LIST  List,
IN PIRP  Irp,
IN ULONGLONG  BlockNumber,
IN BOOLEAN  LowPriority 
)

Definition at line 828 of file obsolete.c.

857 {
858  PCSCAN_LIST_ENTRY entry = (PCSCAN_LIST_ENTRY)Irp->Tail.Overlay.DriverContext;
859 
860  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_GENERAL, "ClassInsertCScanList is OBSOLETE !"));
861 
862  //
863  // Set the block number in the entry. We need this to keep the list sorted.
864  //
865  entry->BlockNumber = BlockNumber;
866 
867  //
868  // If it's a normal priority request and further down the disk than our
869  // current position then insert this entry into the current sweep.
870  //
871 
872  if((LowPriority != TRUE) && (BlockNumber > List->BlockNumber)) {
873  ClasspInsertCScanList(&(List->CurrentSweep), entry);
874  } else {
875  ClasspInsertCScanList(&(List->NextSweep), entry);
876  }
877  return;
878 }
struct _CSCAN_LIST_ENTRY * PCSCAN_LIST_ENTRY
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
LIST_ENTRY List
Definition: psmgr.c:57
uint32_t entry
Definition: isohybrid.c:63
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
Definition: obsolete.c:42
VOID ClasspInsertCScanList(IN PLIST_ENTRY ListHead, IN PCSCAN_LIST_ENTRY Entry)
Definition: obsolete.c:783

◆ ClassIoCompleteAssociated()

NTSTATUS NTAPI ClassIoCompleteAssociated ( IN PDEVICE_OBJECT  Fdo,
IN PIRP  Irp,
IN PVOID  Context 
)

Definition at line 111 of file obsolete.c.

116 {
117  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Fdo->DeviceExtension;
118 
121 
122  PIRP originalIrp = Irp->AssociatedIrp.MasterIrp;
123  LONG irpCount;
124 
126  BOOLEAN retry;
127 
128  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_GENERAL, "ClassIoCompleteAssociated is OBSOLETE !"));
129 
130  //
131  // Check SRB status for success of completing request.
132  //
133  if (SRB_STATUS(srb->SrbStatus) != SRB_STATUS_SUCCESS) {
134 
135  LONGLONG retryInterval;
136 
137  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_GENERAL, "ClassIoCompleteAssociated: IRP %p, SRB %p", Irp, srb));
138 
139  //
140  // Release the queue if it is frozen.
141  //
142 
143  if (srb->SrbStatus & SRB_STATUS_QUEUE_FROZEN) {
144  ClassReleaseQueue(Fdo);
145  }
146 
148  Fdo,
149  Irp,
150  srb,
151  irpStack->MajorFunction,
152  irpStack->MajorFunction == IRP_MJ_DEVICE_CONTROL ?
153  irpStack->Parameters.DeviceIoControl.IoControlCode :
154  0,
156  ((ULONG)(ULONG_PTR)irpStack->Parameters.Others.Argument4),
157  &status,
158  &retryInterval);
159 
160  //
161  // If the status is verified required and the this request
162  // should bypass verify required then retry the request.
163  //
164 
165  if (irpStack->Flags & SL_OVERRIDE_VERIFY_VOLUME &&
167 
169  retry = TRUE;
170  }
171 
172 #ifndef __REACTOS__
173 #pragma warning(suppress:4213) // okay to cast Arg4 as a ulong for this use case
174  if (retry && ((ULONG)(ULONG_PTR)irpStack->Parameters.Others.Argument4)--) {
175 #else
176  if (retry && (*(ULONG *)&irpStack->Parameters.Others.Argument4)--) {
177 #endif
178 
179  //
180  // Retry request. If the class driver has supplied a StartIo,
181  // call it directly for retries.
182  //
183 
184  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_GENERAL, "Retry request %p\n", Irp));
185 
186  if (PORT_ALLOCATED_SENSE(fdoExtension, srb)) {
187  FREE_PORT_ALLOCATED_SENSE_BUFFER(fdoExtension, srb);
188  }
189 
190  RetryRequest(Fdo, Irp, srb, TRUE, retryInterval);
191 
193  }
194 
195  } else {
196 
197  //
198  // Set status for successful request.
199  //
200 
202 
203  } // end if (SRB_STATUS(srb->SrbStatus) ...
204 
205  //
206  // Return SRB to list.
207  //
208 
209  if (PORT_ALLOCATED_SENSE(fdoExtension, srb)) {
210  FREE_PORT_ALLOCATED_SENSE_BUFFER(fdoExtension, srb);
211  }
212 
213  ClassFreeOrReuseSrb(fdoExtension, srb);
214 
215  //
216  // Set status in completing IRP.
217  //
218 
219  Irp->IoStatus.Status = status;
220 
221  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_GENERAL, "ClassIoCompleteAssociated: Partial xfer IRP %p\n", Irp));
222 
223  //
224  // Get next stack location. This original request is unused
225  // except to keep track of the completing partial IRPs so the
226  // stack location is valid.
227  //
228 
229  irpStack = IoGetNextIrpStackLocation(originalIrp);
230 
231  //
232  // Update status only if error so that if any partial transfer
233  // completes with error, then the original IRP will return with
234  // error. If any of the asynchronous partial transfer IRPs fail,
235  // with an error then the original IRP will return 0 bytes transfered.
236  // This is an optimization for successful transfers.
237  //
238 
239  if (!NT_SUCCESS(status)) {
240 
241  originalIrp->IoStatus.Status = status;
242  originalIrp->IoStatus.Information = 0;
243 
244  //
245  // Set the hard error if necessary.
246  //
247 
249  (originalIrp->Tail.Overlay.Thread != NULL)) {
250 
251  //
252  // Store DeviceObject for filesystem.
253  //
254 
255  IoSetHardErrorOrVerifyDevice(originalIrp, Fdo);
256  }
257  }
258 
259  //
260  // Decrement and get the count of remaining IRPs.
261  //
262 
263  irpCount = InterlockedDecrement(
264  (PLONG)&irpStack->Parameters.Others.Argument1);
265 
266  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_GENERAL, "ClassIoCompleteAssociated: Partial IRPs left %d\n",
267  irpCount));
268 
269  //
270  // Ensure that the irpCount doesn't go negative. This was happening once
271  // because classpnp would get confused if it ran out of resources when
272  // splitting the request.
273  //
274 
275  NT_ASSERT(irpCount >= 0);
276 
277  if (irpCount == 0) {
278 
279  //
280  // All partial IRPs have completed.
281  //
282 
283  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_GENERAL,
284  "ClassIoCompleteAssociated: All partial IRPs complete %p\n",
285  originalIrp));
286 
287  if (fdoExtension->CommonExtension.DriverExtension->InitData.ClassStartIo) {
288 
289  //
290  // Acquire a separate copy of the remove lock so the debugging code
291  // works okay and we don't have to hold up the completion of this
292  // irp until after we start the next packet(s).
293  //
294 
295  KIRQL oldIrql;
296  UCHAR uniqueAddress = 0;
297  ClassAcquireRemoveLock(Fdo, (PIRP)&uniqueAddress);
298  ClassReleaseRemoveLock(Fdo, originalIrp);
299  ClassCompleteRequest(Fdo, originalIrp, IO_DISK_INCREMENT);
300 
301  KeRaiseIrql(DISPATCH_LEVEL, &oldIrql);
302  IoStartNextPacket(Fdo, TRUE); // yes, some IO is now cancellable
303  KeLowerIrql(oldIrql);
304 
305  ClassReleaseRemoveLock(Fdo, (PIRP)&uniqueAddress);
306 
307  } else {
308 
309  //
310  // just complete this request
311  //
312 
313  ClassReleaseRemoveLock(Fdo, originalIrp);
314  ClassCompleteRequest(Fdo, originalIrp, IO_DISK_INCREMENT);
315 
316  }
317 
318  }
319 
320  //
321  // Deallocate IRP and indicate the I/O system should not attempt any more
322  // processing.
323  //
324 
325  IoFreeIrp(Irp);
327 
328 } // end ClassIoCompleteAssociated()
VOID RetryRequest(PDEVICE_OBJECT DeviceObject, PIRP Irp, PSCSI_REQUEST_BLOCK Srb, BOOLEAN Associated, LONGLONG TimeDelta100ns)
Definition: obsolete.c:359
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define ClassAcquireRemoveLock(devobj, tag)
Definition: classpnp.h:100
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
BOOLEAN InterpretSenseInfoWithoutHistory(_In_ PDEVICE_OBJECT Fdo, _In_opt_ PIRP OriginalRequest, _In_ PSCSI_REQUEST_BLOCK Srb, UCHAR MajorFunctionCode, ULONG IoDeviceCode, ULONG PreviousRetryCount, _Out_ NTSTATUS *Status, _Out_opt_ _Deref_out_range_(0, MAXIMUM_RETRY_FOR_SINGLE_IO_IN_100NS_UNITS) LONGLONG *RetryIn100nsUnits)
Definition: class.c:12844
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
#define IoIsErrorUserInduced(Status)
Definition: iofuncs.h:2813
LONG NTSTATUS
Definition: precomp.h:26
COMMON_DEVICE_EXTENSION CommonExtension
Definition: classpnp.h:873
VOID NTAPI ClassReleaseQueue(_In_ PDEVICE_OBJECT Fdo)
Definition: class.c:11589
IO_STATUS_BLOCK IoStatus
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
#define STATUS_VERIFY_REQUIRED
Definition: udferr_usr.h:130
UCHAR SrbStatus
Definition: srb.h:243
#define SRB_STATUS(Status)
Definition: srb.h:381
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define STATUS_IO_DEVICE_ERROR
Definition: udferr_usr.h:179
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define IO_DISK_INCREMENT
Definition: iotypes.h:572
long LONG
Definition: pedump.c:60
unsigned char BOOLEAN
VOID NTAPI ClassReleaseRemoveLock(_In_ PDEVICE_OBJECT DeviceObject, _In_opt_ PIRP Tag)
Definition: lock.c:251
smooth NULL
Definition: ftsmooth.c:416
static __inline BOOLEAN PORT_ALLOCATED_SENSE(_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, _In_ PSCSI_REQUEST_BLOCK Srb)
Definition: classpnp.h:1464
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1787
#define MAXIMUM_RETRIES
Definition: class2.h:14
int64_t LONGLONG
Definition: typedefs.h:68
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static __inline VOID FREE_PORT_ALLOCATED_SENSE_BUFFER(_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, _In_ PSCSI_REQUEST_BLOCK Srb)
Definition: classpnp.h:1475
unsigned char UCHAR
Definition: xmlstorage.h:181
#define SRB_STATUS_QUEUE_FROZEN
Definition: srb.h:378
#define InterlockedDecrement
Definition: armddk.h:52
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2691
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
struct tagContext Context
Definition: acpixf.h:1034
unsigned int ULONG
Definition: retypes.h:1
#define SRB_STATUS_SUCCESS
Definition: srb.h:333
VOID NTAPI IoSetHardErrorOrVerifyDevice(IN PIRP Irp, IN PDEVICE_OBJECT DeviceObject)
Definition: util.c:316
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2779
return STATUS_SUCCESS
Definition: btrfs.c:3014
VOID NTAPI ClassCompleteRequest(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ CCHAR PriorityBoost)
Definition: lock.c:401
signed int * PLONG
Definition: retypes.h:5
static SERVICE_STATUS status
Definition: service.c:31
VOID ClassFreeOrReuseSrb(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN __drv_freesMem(mem) PSCSI_REQUEST_BLOCK Srb)
Definition: obsolete.c:882
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
VOID NTAPI IoStartNextPacket(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN Cancelable)
Definition: device.c:1847
#define NT_ASSERT
Definition: rtlfuncs.h:3312
Definition: ps.c:97

Referenced by RetryRequest().

◆ ClasspBuildRequestEx()

VOID ClasspBuildRequestEx ( _In_ PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension,
_In_ PIRP  Irp,
_In_ __drv_aliasesMem PSCSI_REQUEST_BLOCK  Srb 
)

Definition at line 537 of file obsolete.c.

575 {
578 
579  LARGE_INTEGER startingOffset = currentIrpStack->Parameters.Read.ByteOffset;
580 
581  PCDB cdb;
582  ULONG logicalBlockAddress;
583  USHORT transferBlocks;
586 
587  // This function is obsolete, but still called by CDROM.SYS .
588  // TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_GENERAL, "ClasspBuildRequestEx is OBSOLETE !"));
589 
590  if (Srb == NULL) {
591  NT_ASSERT(FALSE);
592  return;
593  }
594 
595  //
596  // Calculate relative sector address.
597  //
598 
599  logicalBlockAddress =
600  (ULONG)(Int64ShrlMod32(startingOffset.QuadPart,
601  FdoExtension->SectorShift));
602 
603  //
604  // Prepare the SRB.
605  // NOTE - for extended SRB, size used is based on allocation in ClasspAllocateSrb.
606  //
607 
608  if (FdoExtension->AdapterDescriptor->SrbType == SRB_TYPE_STORAGE_REQUEST_BLOCK) {
612  1,
614  if (!NT_SUCCESS(status)) {
615  NT_ASSERT(FALSE);
616  return;
617  }
618 
620  } else {
622 
623  //
624  // Write length to SRB.
625  //
626 
627  Srb->Length = sizeof(SCSI_REQUEST_BLOCK);
628 
629  Srb->Function = SRB_FUNCTION_EXECUTE_SCSI;
630  }
631 
632 
633  //
634  // Set up IRP Address.
635  //
636 
637  SrbSetOriginalRequest(srbHeader, Irp);
638 
639  //
640  // Set up data buffer
641  //
642 
643  SrbSetDataBuffer(srbHeader,
644  MmGetMdlVirtualAddress(Irp->MdlAddress));
645 
646  //
647  // Save byte count of transfer in SRB Extension.
648  //
649 
650  SrbSetDataTransferLength(srbHeader,
651  currentIrpStack->Parameters.Read.Length);
652 
653  //
654  // Initialize the queue actions field.
655  //
656 
658 
659  //
660  // Queue sort key is Relative Block Address.
661  //
662 
663  SrbSetQueueSortKey(srbHeader, logicalBlockAddress);
664 
665  //
666  // Indicate auto request sense by specifying buffer and size.
667  //
668 
669  SrbSetSenseInfoBuffer(srbHeader, FdoExtension->SenseData);
671 
672  //
673  // Set timeout value of one unit per 64k bytes of data.
674  //
675 
676  SrbSetTimeOutValue(srbHeader,
677  ((SrbGetDataTransferLength(srbHeader) + 0xFFFF) >> 16) *
678  FdoExtension->TimeOutValue);
679 
680  //
681  // Indicate that 10-byte CDB's will be used.
682  //
683 
684  SrbSetCdbLength(srbHeader, 10);
685 
686  //
687  // Fill in CDB fields.
688  //
689 
690  cdb = SrbGetCdb(srbHeader);
691  NT_ASSERT(cdb != NULL);
692 
693  transferBlocks = (USHORT)(currentIrpStack->Parameters.Read.Length >>
694  FdoExtension->SectorShift);
695 
696  //
697  // Move little endian values into CDB in big endian format.
698  //
699 
700  cdb->CDB10.LogicalBlockByte0 = ((PFOUR_BYTE)&logicalBlockAddress)->Byte3;
701  cdb->CDB10.LogicalBlockByte1 = ((PFOUR_BYTE)&logicalBlockAddress)->Byte2;
702  cdb->CDB10.LogicalBlockByte2 = ((PFOUR_BYTE)&logicalBlockAddress)->Byte1;
703  cdb->CDB10.LogicalBlockByte3 = ((PFOUR_BYTE)&logicalBlockAddress)->Byte0;
704 
705  cdb->CDB10.TransferBlocksMsb = ((PFOUR_BYTE)&transferBlocks)->Byte1;
706  cdb->CDB10.TransferBlocksLsb = ((PFOUR_BYTE)&transferBlocks)->Byte0;
707 
708  //
709  // Set transfer direction flag and Cdb command.
710  //
711 
712  if (currentIrpStack->MajorFunction == IRP_MJ_READ) {
713 
714  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_RW, "ClassBuildRequest: Read Command\n"));
715 
716  SrbSetSrbFlags(srbHeader, SRB_FLAGS_DATA_IN);
717  cdb->CDB10.OperationCode = SCSIOP_READ;
718 
719  } else {
720 
721  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_RW, "ClassBuildRequest: Write Command\n"));
722 
724  cdb->CDB10.OperationCode = SCSIOP_WRITE;
725 
726  }
727 
728  //
729  // If this is not a write-through request, then allow caching.
730  //
731 
732  if (!(currentIrpStack->Flags & SL_WRITE_THROUGH)) {
733 
735 
736  } else {
737 
738  //
739  // If write caching is enable then force media access in the
740  // cdb.
741  //
742 
743  cdb->CDB10.ForceUnitAccess = FdoExtension->CdbForceUnitAccess;
744  }
745 
748  }
749 
750  //
751  // OR in the default flags from the device object.
752  //
753 
754  SrbSetSrbFlags(srbHeader, FdoExtension->SrbFlags);
755 
756  //
757  // Set up major SCSI function.
758  //
759 
760  nextIrpStack->MajorFunction = IRP_MJ_SCSI;
761 
762  //
763  // Save SRB address in next stack for port driver.
764  //
765 
766  nextIrpStack->Parameters.Scsi.Srb = Srb;
767 
768  //
769  // Save retry count in current IRP stack.
770  //
771 
772  currentIrpStack->Parameters.Others.Argument4 = (PVOID)MAXIMUM_RETRIES;
773 
774  //
775  // Set up IoCompletion routine address.
776  //
777 
779 
780 }
struct _FOUR_BYTE * PFOUR_BYTE
#define SRB_TYPE_STORAGE_REQUEST_BLOCK
Definition: srb.h:655
FORCEINLINE VOID SrbSetOriginalRequest(_In_ PVOID Srb, _In_opt_ PVOID OriginalRequest)
Definition: srbhelper.h:710
FORCEINLINE VOID SrbSetDataTransferLength(_In_ PVOID Srb, _In_ ULONG DataTransferLength)
Definition: srbhelper.h:784
#define MmGetMdlVirtualAddress(_Mdl)
#define TEST_FLAG(Flags, Bit)
Definition: classpnp.h:159
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
NTSTATUS InitializeStorageRequestBlock(_Inout_bytecount_(ByteSize) PSTORAGE_REQUEST_BLOCK Srb, _In_ USHORT AddressType, _In_ ULONG ByteSize, _In_ ULONG NumSrbExData,...)
Definition: srblib.c:206
Definition: cdrw_hw.h:28
LONG NTSTATUS
Definition: precomp.h:26
FORCEINLINE PCDB SrbGetCdb(_In_ PVOID Srb)
Definition: srbhelper.h:583
struct _CDB::_CDB10 CDB10
FORCEINLINE VOID SrbSetSenseInfoBufferLength(_In_ PVOID Srb, _In_ UCHAR SenseInfoBufferLength)
Definition: srbhelper.h:675
#define SRB_FLAGS_DATA_IN
Definition: srb.h:392
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:498
#define IRP_MJ_SCSI
struct SRB_ALIGN _STORAGE_REQUEST_BLOCK_HEADER * PSTORAGE_REQUEST_BLOCK_HEADER
__inline UCHAR GET_FDO_EXTENSON_SENSE_DATA_LENGTH(_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: classpnp.h:1437
#define FALSE
Definition: types.h:117
#define CLASS_SRBEX_SCSI_CDB16_BUFFER_SIZE
Definition: classpnp.h:695
#define SCSIOP_READ
Definition: cdrw_hw.h:905
#define SCSIOP_WRITE
Definition: cdrw_hw.h:906
smooth NULL
Definition: ftsmooth.c:416
* PSTORAGE_REQUEST_BLOCK
Definition: srb.h:652
void * PVOID
Definition: retypes.h:9
NTSTATUS NTAPI ClassIoComplete(IN PDEVICE_OBJECT Fdo, IN PIRP Irp, IN PVOID Context)
Definition: class.c:3768
#define MAXIMUM_RETRIES
Definition: class2.h:14
FORCEINLINE ULONG SrbGetDataTransferLength(_In_ PVOID Srb)
Definition: srbhelper.h:765
FORCEINLINE VOID SrbSetCdbLength(_In_ PVOID Srb, _In_ UCHAR CdbLength)
Definition: srbhelper.h:1093
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
FORCEINLINE VOID SrbSetTimeOutValue(_In_ PVOID Srb, _In_ ULONG TimeOutValue)
Definition: srbhelper.h:821
#define STORAGE_ADDRESS_TYPE_BTL8
Definition: srb.h:657
struct _SCSI_REQUEST_BLOCK SCSI_REQUEST_BLOCK
#define SRB_CLASS_FLAGS_PAGING
Definition: classpnp.h:21
FORCEINLINE VOID SrbSetRequestAttribute(_In_ PVOID Srb, _In_ UCHAR RequestAttribute)
Definition: srbhelper.h:1131
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2691
#define Int64ShrlMod32(a, b)
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
unsigned short USHORT
Definition: pedump.c:61
#define SRB_SIMPLE_TAG_REQUEST
Definition: srb.h:415
#define SRB_FLAGS_DATA_OUT
Definition: srb.h:393
#define SRB_FLAGS_ADAPTER_CACHE_ENABLE
Definition: srb.h:397
#define IRP_PAGING_IO
#define SL_WRITE_THROUGH
Definition: iotypes.h:1788
#define IRP_MJ_READ
Definition: rdpdr.c:46
FORCEINLINE VOID SrbSetDataBuffer(_In_ PVOID Srb, _In_opt_ __drv_aliasesMem PVOID DataBuffer)
Definition: srbhelper.h:747
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:307
unsigned int ULONG
Definition: retypes.h:1
FORCEINLINE VOID SrbSetSenseInfoBuffer(_In_ PVOID Srb, _In_opt_ PVOID SenseInfoBuffer)
Definition: srbhelper.h:657
FORCEINLINE VOID SrbSetSrbFlags(_In_ PVOID Srb, _In_ ULONG Flags)
Definition: srbhelper.h:964
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2779
FORCEINLINE VOID SrbSetQueueSortKey(_In_ PVOID Srb, _In_ ULONG QueueSortKey)
Definition: srbhelper.h:839
static SERVICE_STATUS status
Definition: service.c:31
#define IRP_SYNCHRONOUS_PAGING_IO
LONGLONG QuadPart
Definition: typedefs.h:114
#define NT_ASSERT
Definition: rtlfuncs.h:3312
Definition: ps.c:97

Referenced by ClassBuildRequest().

◆ ClasspInitializeCScanList()

VOID ClasspInitializeCScanList ( IN PCSCAN_LIST  List)

Definition at line 1062 of file obsolete.c.

1063 {
1064  PAGED_CODE();
1065  RtlZeroMemory(List, sizeof(CSCAN_LIST));
1066  InitializeListHead(&(List->CurrentSweep));
1067  InitializeListHead(&(List->NextSweep));
1068 }
LIST_ENTRY List
Definition: psmgr.c:57
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define PAGED_CODE()

◆ ClasspInsertCScanList()

VOID ClasspInsertCScanList ( IN PLIST_ENTRY  ListHead,
IN PCSCAN_LIST_ENTRY  Entry 
)

Definition at line 783 of file obsolete.c.

784 {
786 
787  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_GENERAL, "ClasspInsertCScanList is OBSOLETE !"));
788 
789  //
790  // Iterate through the list. Insert this entry in the sorted list in
791  // order (after other requests for the same block). At each stop if
792  // blockNumber(Entry) >= blockNumber(t) then move on.
793  //
794 
795  for(t = (PCSCAN_LIST_ENTRY) ListHead->Flink;
796  t != (PCSCAN_LIST_ENTRY) ListHead;
797  t = (PCSCAN_LIST_ENTRY) t->Entry.Flink) {
798 
799  if(Entry->BlockNumber < t->BlockNumber) {
800 
801  //
802  // Set the pointers in entry to the right location.
803  //
804 
805  Entry->Entry.Flink = &(t->Entry);
806  Entry->Entry.Blink = t->Entry.Blink;
807 
808  //
809  // Set the pointers in the surrounding elements to refer to us.
810  //
811 
812  t->Entry.Blink->Flink = &(Entry->Entry);
813  t->Entry.Blink = &(Entry->Entry);
814  return;
815  }
816  }
817 
818  //
819  // Insert this entry at the tail of the list. If the list was empty this
820  // will also be the head of the list.
821  //
822 
823  InsertTailList(ListHead, &(Entry->Entry));
824 
825 }
GLdouble GLdouble t
Definition: gl.h:2047
#define InsertTailList(ListHead, Entry)
Entry(ENTRY_TYPE etype)
Definition: entries.cpp:35
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
Definition: obsolete.c:42
base of all file and directory entries
Definition: entries.h:82

Referenced by ClassInsertCScanList().

◆ ClasspStartNextSweep()

VOID ClasspStartNextSweep ( PCSCAN_LIST  List)

Definition at line 1072 of file obsolete.c.

1073 {
1074  NT_ASSERT(IsListEmpty(&(List->CurrentSweep)) == TRUE);
1075 
1076  //
1077  // If the next sweep is empty then there's nothing to do.
1078  //
1079 
1080  if(IsListEmpty(&(List->NextSweep))) {
1081  return;
1082  }
1083 
1084  //
1085  // Copy the next sweep list head into the current sweep list head.
1086  //
1087 
1088  List->CurrentSweep = List->NextSweep;
1089 
1090  //
1091  // Unlink the next sweep list from the list head now that we have a copy
1092  // of it.
1093  //
1094 
1095  InitializeListHead(&(List->NextSweep));
1096 
1097  //
1098  // Update the next sweep list to point back to the current sweep list head.
1099  //
1100 
1101  List->CurrentSweep.Flink->Blink = &(List->CurrentSweep);
1102  List->CurrentSweep.Blink->Flink = &(List->CurrentSweep);
1103 
1104  return;
1105 }
#define TRUE
Definition: types.h:120
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY List
Definition: psmgr.c:57
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by ClassRemoveCScanList().

◆ ClassRemoveCScanList()

PIRP ClassRemoveCScanList ( IN PCSCAN_LIST  List)

Definition at line 1109 of file obsolete.c.

1110 {
1112 
1113  //
1114  // If the current sweep is empty then promote the next sweep.
1115  //
1116 
1117  if(IsListEmpty(&(List->CurrentSweep))) {
1119  }
1120 
1121  //
1122  // If the current sweep is still empty then we're done.
1123  //
1124 
1125  if(IsListEmpty(&(List->CurrentSweep))) {
1126  return NULL;
1127  }
1128 
1129  //
1130  // Remove the head entry from the current sweep. Record it's block number
1131  // so that nothing before it on the disk gets into the current sweep.
1132  //
1133 
1134  entry = (PCSCAN_LIST_ENTRY) RemoveHeadList(&(List->CurrentSweep));
1135 
1136  List->BlockNumber = entry->BlockNumber;
1137 
1138  return CONTAINING_RECORD(entry, IRP, Tail.Overlay.DriverContext);
1139 }
struct _CSCAN_LIST_ENTRY * PCSCAN_LIST_ENTRY
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
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
LIST_ENTRY List
Definition: psmgr.c:57
VOID ClasspStartNextSweep(PCSCAN_LIST List)
Definition: obsolete.c:1072
uint32_t entry
Definition: isohybrid.c:63
Definition: obsolete.c:42

◆ ClassSplitRequest()

VOID NTAPI ClassSplitRequest ( _In_ PDEVICE_OBJECT  Fdo,
_In_ PIRP  Irp,
_In_ ULONG  MaximumBytes 
)

Definition at line 61 of file obsolete.c.

62 {
63  PFUNCTIONAL_DEVICE_EXTENSION fdoExt = Fdo->DeviceExtension;
64  PCLASS_PRIVATE_FDO_DATA fdoData = fdoExt->PrivateFdoData;
65 
66  if (MaximumBytes > fdoData->HwMaxXferLen) {
67  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_RW, "ClassSplitRequest - driver requesting split to size that "
68  "hardware is unable to handle!\n"));
69  }
70 
71  if (MaximumBytes < fdoData->HwMaxXferLen){
72  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_RW, "ClassSplitRequest - driver requesting smaller HwMaxXferLen "
73  "than required"));
74  fdoData->HwMaxXferLen = MAX(MaximumBytes, PAGE_SIZE);
75  }
76 
78 }
_In_ PIRP Irp
Definition: csq.h:116
#define FALSE
Definition: types.h:117
#define PAGE_SIZE
Definition: env_spec_w32.h:49
NTSTATUS ServiceTransferRequest(PDEVICE_OBJECT Fdo, PIRP Irp, BOOLEAN PostToDpc)
Definition: class.c:3341
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
T MAX(T a, T b)
Definition: polytest.cpp:85

◆ RetryRequest()

VOID RetryRequest ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp,
PSCSI_REQUEST_BLOCK  Srb,
BOOLEAN  Associated,
LONGLONG  TimeDelta100ns 
)

Definition at line 359 of file obsolete.c.

366 {
369  ULONG transferByteCount;
370  ULONG dataTransferLength;
372 
373  // This function is obsolete but is still used by some of our class drivers.
374  // TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_GENERAL, "RetryRequest is OBSOLETE !"));
375 
376  //
377  // Determine the transfer count of the request. If this is a read or a
378  // write then the transfer count is in the Irp stack. Otherwise assume
379  // the MDL contains the correct length. If there is no MDL then the
380  // transfer length must be zero.
381  //
382 
383  dataTransferLength = SrbGetDataTransferLength(srbHeader);
384  if (currentIrpStack->MajorFunction == IRP_MJ_READ ||
385  currentIrpStack->MajorFunction == IRP_MJ_WRITE) {
386 
387  _Analysis_assume_(currentIrpStack->Parameters.Read.Length <= dataTransferLength);
388  transferByteCount = currentIrpStack->Parameters.Read.Length;
389 
390  } else if (Irp->MdlAddress != NULL) {
391 
392  //
393  // Note this assumes that only read and write requests are spilt and
394  // other request do not need to be. If the data buffer address in
395  // the MDL and the SRB don't match then transfer length is most
396  // likely incorrect.
397  //
398 
399  NT_ASSERT(SrbGetDataBuffer(srbHeader) == MmGetMdlVirtualAddress(Irp->MdlAddress));
400  _Analysis_assume_(Irp->MdlAddress->ByteCount <= dataTransferLength);
401  transferByteCount = Irp->MdlAddress->ByteCount;
402 
403  } else {
404 
405  transferByteCount = 0;
406  }
407 
408  //
409  // this is a safety net. this should not normally be hit, since we are
410  // not guaranteed to be an fdoExtension
411  //
412 
414 
415  //
416  // Reset byte count of transfer in SRB Extension.
417  //
418 
419  SrbSetDataTransferLength(srbHeader, transferByteCount);
420 
421  //
422  // Zero SRB statuses.
423  //
424 
425  srbHeader->SrbStatus = 0;
426  SrbSetScsiStatus(srbHeader, 0);
427 
428  //
429  // If this is the last retry, then disable all the special flags.
430  //
431 
432  if ( 0 == (ULONG)(ULONG_PTR)currentIrpStack->Parameters.Others.Argument4 ) {
433  //
434  // Set the no disconnect flag, disable synchronous data transfers and
435  // disable tagged queuing. This fixes some errors.
436  // NOTE: Cannot clear these flags, just add to them
437  //
438 
439  SrbSetSrbFlags(srbHeader,
442 
443  SrbSetQueueTag(srbHeader, SP_UNTAGGED);
444  }
445 
446 
447  //
448  // Set up major SCSI function.
449  //
450 
451  nextIrpStack->MajorFunction = IRP_MJ_SCSI;
452 
453  //
454  // Save SRB address in next stack for port driver.
455  //
456 
457  nextIrpStack->Parameters.Scsi.Srb = Srb;
458 
459  if (Associated){
461  }
462  else {
464  }
465 
466  ClassRetryRequest(DeviceObject, Irp, TimeDelta100ns);
467  return;
468 } // end RetryRequest()
FORCEINLINE ULONG SrbGetSrbFlags(_In_ PVOID Srb)
Definition: srbhelper.h:927
FORCEINLINE VOID SrbSetDataTransferLength(_In_ PVOID Srb, _In_ ULONG DataTransferLength)
Definition: srbhelper.h:784
#define MmGetMdlVirtualAddress(_Mdl)
#define TEST_FLAG(Flags, Bit)
Definition: classpnp.h:159
#define SRB_FLAGS_FREE_SENSE_BUFFER
Definition: srb.h:398
FORCEINLINE VOID SrbSetQueueTag(_In_ PVOID Srb, _In_ ULONG QueueTag)
Definition: srbhelper.h:853
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
FORCEINLINE PVOID SrbGetDataBuffer(_In_ PVOID Srb)
Definition: srbhelper.h:728
FORCEINLINE VOID SrbClearSrbFlags(_In_ PVOID Srb, _In_ ULONG Flags)
Definition: srbhelper.h:982
VOID ClassRetryRequest(IN PDEVICE_OBJECT SelfDeviceObject, IN PIRP Irp, _In_ _In_range_(0, MAXIMUM_RETRY_FOR_SINGLE_IO_IN_100NS_UNITS) IN LONGLONG TimeDelta100ns)
Definition: class.c:12317
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:498
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define SP_UNTAGGED
Definition: srb.h:225
#define IRP_MJ_SCSI
struct SRB_ALIGN _STORAGE_REQUEST_BLOCK_HEADER * PSTORAGE_REQUEST_BLOCK_HEADER
FORCEINLINE VOID SrbSetScsiStatus(_In_ PVOID Srb, _In_ UCHAR ScsiStatus)
Definition: srbhelper.h:1056
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI ClassIoComplete(IN PDEVICE_OBJECT Fdo, IN PIRP Irp, IN PVOID Context)
Definition: class.c:3768
FORCEINLINE ULONG SrbGetDataTransferLength(_In_ PVOID Srb)
Definition: srbhelper.h:765
#define SRB_FLAGS_DISABLE_SYNCH_TRANSFER
Definition: srb.h:389
#define SRB_FLAGS_DISABLE_DISCONNECT
Definition: srb.h:388
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2691
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
#define IRP_MJ_READ
Definition: rdpdr.c:46
NTSTATUS NTAPI ClassIoCompleteAssociated(IN PDEVICE_OBJECT Fdo, IN PIRP Irp, IN PVOID Context)
Definition: obsolete.c:111
unsigned int ULONG
Definition: retypes.h:1
FORCEINLINE VOID SrbSetSrbFlags(_In_ PVOID Srb, _In_ ULONG Flags)
Definition: srbhelper.h:964
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2779
#define SRB_FLAGS_QUEUE_ACTION_ENABLE
Definition: srb.h:387
#define _Analysis_assume_(expr)
Definition: no_sal2.h:10
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by ClassIoCompleteAssociated().