ReactOS  0.4.14-dev-317-g96040ec
obsolete.c File Reference
#include "classp.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 NTAPI ClassRemoveCScanList (IN PCSCAN_LIST List)
 
VOID NTAPI 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 NTAPI RetryRequest (PDEVICE_OBJECT DeviceObject, PIRP Irp, PSCSI_REQUEST_BLOCK Srb, BOOLEAN Associated, ULONG RetryInterval)
 
NTSTATUS NTAPI ClassBuildRequest (PDEVICE_OBJECT Fdo, PIRP Irp)
 
VOID NTAPI ClasspBuildRequestEx (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PIRP Irp, IN PSCSI_REQUEST_BLOCK Srb)
 
VOID NTAPI ClasspInsertCScanList (IN PLIST_ENTRY ListHead, IN PCSCAN_LIST_ENTRY Entry)
 
VOID NTAPI ClassInsertCScanList (IN PCSCAN_LIST List, IN PIRP Irp, IN ULONGLONG BlockNumber, IN BOOLEAN LowPriority)
 
VOID NTAPI ClassFreeOrReuseSrb (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PSCSI_REQUEST_BLOCK Srb)
 
VOID NTAPI ClassDeleteSrbLookasideList (IN PCOMMON_DEVICE_EXTENSION CommonExtension)
 
VOID NTAPI ClassInitializeSrbLookasideList (IN PCOMMON_DEVICE_EXTENSION CommonExtension, IN ULONG NumberElements)
 
VOID NTAPI ClasspStartNextSweep (PCSCAN_LIST List)
 

Typedef Documentation

◆ CSCAN_LIST_ENTRY

◆ PCSCAN_LIST_ENTRY

Function Documentation

◆ ClassBuildRequest()

NTSTATUS NTAPI ClassBuildRequest ( PDEVICE_OBJECT  Fdo,
PIRP  Irp 
)

Definition at line 474 of file obsolete.c.

478 {
479  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Fdo->DeviceExtension;
480 
482 
483  // This function is obsolete, but still called by CDROM.SYS .
484  // DBGWARN(("ClassBuildRequest is OBSOLETE !"));
485 
486  //
487  // Allocate an Srb.
488  //
489 
490  srb = ClasspAllocateSrb(fdoExtension);
491 
492  if(srb == NULL) {
494  }
495 
496  ClasspBuildRequestEx(fdoExtension, Irp, srb);
497  return STATUS_SUCCESS;
498 
499 } // end ClassBuildRequest()
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define ClasspAllocateSrb(ext)
Definition: classpnp.h:143
VOID NTAPI ClasspBuildRequestEx(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PIRP Irp, IN PSCSI_REQUEST_BLOCK Srb)
Definition: obsolete.c:503
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by CdRomSwitchModeCompletion().

◆ ClassDeleteSrbLookasideList()

VOID NTAPI ClassDeleteSrbLookasideList ( IN PCOMMON_DEVICE_EXTENSION  CommonExtension)

Definition at line 899 of file obsolete.c.

900 {
901  PAGED_CODE();
902 
903  // This function is obsolete, but is still called by some of our code.
904  // DBGWARN(("ClassDeleteSrbLookasideList is OBSOLETE !"));
905 
906  if (CommonExtension->IsSrbLookasideListInitialized){
907  CommonExtension->IsSrbLookasideListInitialized = FALSE;
908  ExDeleteNPagedLookasideList(&CommonExtension->SrbLookasideList);
909  }
910  else {
911  DBGWARN(("ClassDeleteSrbLookasideList: attempt to delete uninitialized or freed srblookasidelist"));
912  }
913 }
#define PAGED_CODE()
Definition: video.h:57
#define DBGWARN(args_in_parens)
Definition: debug.h:134
VOID NTAPI ExDeleteNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside)
Definition: lookas.c:174

Referenced by CdRomRemoveDevice(), DiskRemoveDevice(), and ScsiFlopRemoveDevice().

◆ ClassFreeOrReuseSrb()

VOID NTAPI ClassFreeOrReuseSrb ( IN PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension,
IN PSCSI_REQUEST_BLOCK  Srb 
)

Definition at line 824 of file obsolete.c.

847 {
848  PCOMMON_DEVICE_EXTENSION commonExt = &FdoExtension->CommonExtension;
849  //KIRQL oldIrql;
850  //PIRP blockedIrp;
851 
852  // This function is obsolete, but still called by DISK.SYS .
853  // DBGWARN(("ClassFreeOrReuseSrb is OBSOLETE !"));
854 
855  //
856  // safety net. this should never occur. if it does, it's a potential
857  // memory leak.
858  //
860 
861  if (commonExt->IsSrbLookasideListInitialized){
862  /*
863  * Put the SRB back in our lookaside list.
864  *
865  * BUGBUG - Some class drivers use ClassIoComplete
866  * to complete SRBs that they themselves allocated.
867  * So we may be putting a "foreign" SRB
868  * (e.g. with a different pool tag) into our lookaside list.
869  */
871  }
872  else {
873  DBGERR(("ClassFreeOrReuseSrb: someone is trying to use an uninitialized SrbLookasideList !!!"));
874  ExFreePool(Srb);
875  }
876 }
#define TEST_FLAG(Flags, Bit)
Definition: classpnp.h:156
#define SRB_FLAGS_FREE_SENSE_BUFFER
Definition: srb.h:398
#define DBGERR(args_in_parens)
Definition: debug.h:135
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
BOOLEAN IsSrbLookasideListInitialized
Definition: classpnp.h:586
#define ClasspFreeSrb(ext, srb)
Definition: classpnp.h:147
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

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

◆ ClassInitializeSrbLookasideList()

VOID NTAPI ClassInitializeSrbLookasideList ( IN PCOMMON_DEVICE_EXTENSION  CommonExtension,
IN ULONG  NumberElements 
)

Definition at line 941 of file obsolete.c.

943 {
944  PAGED_CODE();
945 
946  // This function is obsolete, but still called by DISK.SYS .
947  // DBGWARN(("ClassInitializeSrbLookasideList is OBSOLETE !"));
948 
949  ASSERT(!CommonExtension->IsSrbLookasideListInitialized);
950  if (!CommonExtension->IsSrbLookasideListInitialized){
951 
952  ExInitializeNPagedLookasideList(&CommonExtension->SrbLookasideList,
953  NULL,
954  NULL,
955  NonPagedPool,
956  sizeof(SCSI_REQUEST_BLOCK),
957  '$scS',
959 
960  CommonExtension->IsSrbLookasideListInitialized = TRUE;
961  }
962 
963 }
#define TRUE
Definition: types.h:120
#define PAGED_CODE()
Definition: video.h:57
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI ExInitializeNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside, IN PALLOCATE_FUNCTION Allocate OPTIONAL, IN PFREE_FUNCTION Free OPTIONAL, IN ULONG Flags, IN SIZE_T Size, IN ULONG Tag, IN USHORT Depth)
Definition: lookas.c:222
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
unsigned short USHORT
Definition: pedump.c:61
_In_ ULONG NumberElements
Definition: classpnp.h:944

Referenced by CdRomInitDevice(), DiskCreatePdo(), DiskInitFdo(), and ScsiFlopInitDevice().

◆ ClassInsertCScanList()

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

Definition at line 772 of file obsolete.c.

801 {
802  PCSCAN_LIST_ENTRY entry = (PCSCAN_LIST_ENTRY)Irp->Tail.Overlay.DriverContext;
803 
804  DBGWARN(("ClassInsertCScanList is OBSOLETE !"));
805 
806  //
807  // Set the block number in the entry. We need this to keep the list sorted.
808  //
809  entry->BlockNumber = BlockNumber;
810 
811  //
812  // If it's a normal priority request and further down the disk than our
813  // current position then insert this entry into the current sweep.
814  //
815 
816  if ((LowPriority == FALSE) && (BlockNumber > List->BlockNumber)) {
817  ClasspInsertCScanList(&(List->CurrentSweep), entry);
818  } else {
819  ClasspInsertCScanList(&(List->NextSweep), entry);
820  }
821  return;
822 }
VOID NTAPI ClasspInsertCScanList(IN PLIST_ENTRY ListHead, IN PCSCAN_LIST_ENTRY Entry)
Definition: obsolete.c:728
_In_ PIRP Irp
Definition: csq.h:116
LIST_ENTRY List
Definition: psmgr.c:57
uint32_t entry
Definition: isohybrid.c:63
Definition: obsolete.c:36
#define DBGWARN(args_in_parens)
Definition: debug.h:134
struct _CSCAN_LIST_ENTRY * PCSCAN_LIST_ENTRY

◆ ClassIoCompleteAssociated()

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

Definition at line 98 of file obsolete.c.

103 {
104  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Fdo->DeviceExtension;
105 
108 
109  PIRP originalIrp = Irp->AssociatedIrp.MasterIrp;
110  LONG irpCount;
111 
113  BOOLEAN retry;
114 
115  DBGWARN(("ClassIoCompleteAssociated is OBSOLETE !"));
116 
117  //
118  // Check SRB status for success of completing request.
119  //
120 
121  if (SRB_STATUS(srb->SrbStatus) != SRB_STATUS_SUCCESS) {
122 
123  ULONG retryInterval;
124 
125  DebugPrint((2,"ClassIoCompleteAssociated: IRP %p, SRB %p", Irp, srb));
126 
127  //
128  // Release the queue if it is frozen.
129  //
130 
131  if (srb->SrbStatus & SRB_STATUS_QUEUE_FROZEN) {
132  ClassReleaseQueue(Fdo);
133  }
134 
135  retry = ClassInterpretSenseInfo(
136  Fdo,
137  srb,
138  irpStack->MajorFunction,
139  irpStack->MajorFunction == IRP_MJ_DEVICE_CONTROL ?
140  irpStack->Parameters.DeviceIoControl.IoControlCode :
141  0,
143  ((ULONG)(ULONG_PTR)irpStack->Parameters.Others.Argument4),
144  &status,
145  &retryInterval);
146 
147  //
148  // If the status is verified required and the this request
149  // should bypass verify required then retry the request.
150  //
151 
152  if (irpStack->Flags & SL_OVERRIDE_VERIFY_VOLUME &&
154 
156  retry = TRUE;
157  }
158 
159  if (retry && ((*(PCHAR*)&irpStack->Parameters.Others.Argument4)--)) {
160 
161  //
162  // Retry request. If the class driver has supplied a StartIo,
163  // call it directly for retries.
164  //
165 
166  DebugPrint((1, "Retry request %p\n", Irp));
167 
168  if (PORT_ALLOCATED_SENSE(fdoExtension, srb)) {
169  FREE_PORT_ALLOCATED_SENSE_BUFFER(fdoExtension, srb);
170  }
171 
172  RetryRequest(Fdo, Irp, srb, TRUE, retryInterval);
173 
175  }
176 
177  } else {
178 
179  //
180  // Set status for successful request.
181  //
182 
184 
185  } // end if (SRB_STATUS(srb->SrbStatus) ...
186 
187  //
188  // Return SRB to list.
189  //
190 
191  if (PORT_ALLOCATED_SENSE(fdoExtension, srb)) {
192  FREE_PORT_ALLOCATED_SENSE_BUFFER(fdoExtension, srb);
193  }
194 
195  ClassFreeOrReuseSrb(fdoExtension, srb);
196 
197  //
198  // Set status in completing IRP.
199  //
200 
201  Irp->IoStatus.Status = status;
202 
203  DebugPrint((2, "ClassIoCompleteAssociated: Partial xfer IRP %p\n", Irp));
204 
205  //
206  // Get next stack location. This original request is unused
207  // except to keep track of the completing partial IRPs so the
208  // stack location is valid.
209  //
210 
211  irpStack = IoGetNextIrpStackLocation(originalIrp);
212 
213  //
214  // Update status only if error so that if any partial transfer
215  // completes with error, then the original IRP will return with
216  // error. If any of the asynchronous partial transfer IRPs fail,
217  // with an error then the original IRP will return 0 bytes transfered.
218  // This is an optimization for successful transfers.
219  //
220 
221  if (!NT_SUCCESS(status)) {
222 
223  originalIrp->IoStatus.Status = status;
224  originalIrp->IoStatus.Information = 0;
225 
226  //
227  // Set the hard error if necessary.
228  //
229 
231 
232  //
233  // Store DeviceObject for filesystem.
234  //
235 
236  IoSetHardErrorOrVerifyDevice(originalIrp, Fdo);
237  }
238  }
239 
240  //
241  // Decrement and get the count of remaining IRPs.
242  //
243 
244  irpCount = InterlockedDecrement(
245  (PLONG)&irpStack->Parameters.Others.Argument1);
246 
247  DebugPrint((2, "ClassIoCompleteAssociated: Partial IRPs left %d\n",
248  irpCount));
249 
250  //
251  // Ensure that the irpCount doesn't go negative. This was happening once
252  // because classpnp would get confused if it ran out of resources when
253  // splitting the request.
254  //
255 
256  ASSERT(irpCount >= 0);
257 
258  if (irpCount == 0) {
259 
260  //
261  // All partial IRPs have completed.
262  //
263 
264  DebugPrint((2,
265  "ClassIoCompleteAssociated: All partial IRPs complete %p\n",
266  originalIrp));
267 
268  if (fdoExtension->CommonExtension.DriverExtension->InitData.ClassStartIo) {
269 
270  //
271  // Acquire a separate copy of the remove lock so the debugging code
272  // works okay and we don't have to hold up the completion of this
273  // irp until after we start the next packet(s).
274  //
275 
276  KIRQL oldIrql;
277  UCHAR uniqueAddress;
278  ClassAcquireRemoveLock(Fdo, (PIRP)&uniqueAddress);
279  ClassReleaseRemoveLock(Fdo, originalIrp);
280  ClassCompleteRequest(Fdo, originalIrp, IO_DISK_INCREMENT);
281 
282  KeRaiseIrql(DISPATCH_LEVEL, &oldIrql);
283  IoStartNextPacket(Fdo, FALSE);
284  KeLowerIrql(oldIrql);
285 
286  ClassReleaseRemoveLock(Fdo, (PIRP)&uniqueAddress);
287 
288  } else {
289 
290  //
291  // just complete this request
292  //
293 
294  ClassReleaseRemoveLock(Fdo, originalIrp);
295  ClassCompleteRequest(Fdo, originalIrp, IO_DISK_INCREMENT);
296 
297  }
298 
299  }
300 
301  //
302  // Deallocate IRP and indicate the I/O system should not attempt any more
303  // processing.
304  //
305 
306  IoFreeIrp(Irp);
308 
309 } // end ClassIoCompleteAssociated()
signed char * PCHAR
Definition: retypes.h:7
VOID NTAPI ClassReleaseQueue(IN PDEVICE_OBJECT Fdo)
Definition: class.c:8160
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define TRUE
Definition: types.h:120
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define ClassAcquireRemoveLock(devobj, tag)
Definition: classpnp.h:97
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
_In_ PIRP Irp
Definition: csq.h:116
#define IoIsErrorUserInduced(Status)
Definition: iofuncs.h:2769
LONG NTSTATUS
Definition: precomp.h:26
COMMON_DEVICE_EXTENSION CommonExtension
Definition: classpnp.h:695
VOID NTAPI RetryRequest(PDEVICE_OBJECT DeviceObject, PIRP Irp, PSCSI_REQUEST_BLOCK Srb, BOOLEAN Associated, ULONG RetryInterval)
Definition: obsolete.c:340
#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:63
#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:568
long LONG
Definition: pedump.c:60
unsigned char BOOLEAN
static __inline BOOLEAN PORT_ALLOCATED_SENSE(_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, _In_ PSCSI_REQUEST_BLOCK Srb)
Definition: classpnp.h:1244
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1780
#define MAXIMUM_RETRIES
Definition: class2.h:14
#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:1255
BOOLEAN NTAPI ClassInterpretSenseInfo(IN PDEVICE_OBJECT Fdo, IN PSCSI_REQUEST_BLOCK Srb, IN UCHAR MajorFunctionCode, IN ULONG IoDeviceCode, IN ULONG RetryCount, OUT NTSTATUS *Status, OUT OPTIONAL ULONG *RetryInterval)
Definition: class.c:2994
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
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:2647
ULONG NTAPI DebugPrint(IN PSTRING DebugString, IN ULONG ComponentId, IN ULONG Level)
Definition: debug.c:23
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
VOID NTAPI ClassCompleteRequest(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN CCHAR PriorityBoost)
Definition: lock.c:376
VOID NTAPI ClassFreeOrReuseSrb(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PSCSI_REQUEST_BLOCK Srb)
Definition: obsolete.c:824
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
struct tagContext Context
Definition: acpixf.h:1024
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
#define DBGWARN(args_in_parens)
Definition: debug.h:134
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2938
signed int * PLONG
Definition: retypes.h:5
static SERVICE_STATUS status
Definition: service.c:31
VOID NTAPI ClassReleaseRemoveLock(IN PDEVICE_OBJECT DeviceObject, IN OPTIONAL PIRP Tag)
Definition: lock.c:212
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
VOID NTAPI IoStartNextPacket(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN Cancelable)
Definition: device.c:1847
Definition: ps.c:97

◆ ClasspBuildRequestEx()

VOID NTAPI ClasspBuildRequestEx ( IN PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension,
IN PIRP  Irp,
IN PSCSI_REQUEST_BLOCK  Srb 
)

Definition at line 503 of file obsolete.c.

541 {
544 
545  LARGE_INTEGER startingOffset = currentIrpStack->Parameters.Read.ByteOffset;
546 
547  PCDB cdb;
548  ULONG logicalBlockAddress;
549  USHORT transferBlocks;
550 
551  // This function is obsolete, but still called by CDROM.SYS .
552  // DBGWARN(("ClasspBuildRequestEx is OBSOLETE !"));
553 
554  //
555  // Prepare the SRB.
556  //
557 
559 
560  //
561  // Calculate relative sector address.
562  //
563 
564  logicalBlockAddress =
565  (ULONG)(Int64ShrlMod32(startingOffset.QuadPart,
566  FdoExtension->SectorShift));
567 
568  //
569  // Write length to SRB.
570  //
571 
572  Srb->Length = sizeof(SCSI_REQUEST_BLOCK);
573 
574  //
575  // Set up IRP Address.
576  //
577 
578  Srb->OriginalRequest = Irp;
579 
580  //
581  // Set up target ID and logical unit number.
582  //
583 
584  Srb->Function = SRB_FUNCTION_EXECUTE_SCSI;
585  Srb->DataBuffer = MmGetMdlVirtualAddress(Irp->MdlAddress);
586 
587  //
588  // Save byte count of transfer in SRB Extension.
589  //
590 
591  Srb->DataTransferLength = currentIrpStack->Parameters.Read.Length;
592 
593  //
594  // Initialize the queue actions field.
595  //
596 
597  Srb->QueueAction = SRB_SIMPLE_TAG_REQUEST;
598 
599  //
600  // Queue sort key is Relative Block Address.
601  //
602 
603  Srb->QueueSortKey = logicalBlockAddress;
604 
605  //
606  // Indicate auto request sense by specifying buffer and size.
607  //
608 
609  Srb->SenseInfoBuffer = FdoExtension->SenseData;
610  Srb->SenseInfoBufferLength = SENSE_BUFFER_SIZE;
611 
612  //
613  // Set timeout value of one unit per 64k bytes of data.
614  //
615 
616  Srb->TimeOutValue = ((Srb->DataTransferLength + 0xFFFF) >> 16) *
617  FdoExtension->TimeOutValue;
618 
619  //
620  // Zero statuses.
621  //
622 
623  Srb->SrbStatus = Srb->ScsiStatus = 0;
624  Srb->NextSrb = 0;
625 
626  //
627  // Indicate that 10-byte CDB's will be used.
628  //
629 
630  Srb->CdbLength = 10;
631 
632  //
633  // Fill in CDB fields.
634  //
635 
636  cdb = (PCDB)Srb->Cdb;
637 
638  transferBlocks = (USHORT)(currentIrpStack->Parameters.Read.Length >>
639  FdoExtension->SectorShift);
640 
641  //
642  // Move little endian values into CDB in big endian format.
643  //
644 
645  cdb->CDB10.LogicalBlockByte0 = ((PFOUR_BYTE)&logicalBlockAddress)->Byte3;
646  cdb->CDB10.LogicalBlockByte1 = ((PFOUR_BYTE)&logicalBlockAddress)->Byte2;
647  cdb->CDB10.LogicalBlockByte2 = ((PFOUR_BYTE)&logicalBlockAddress)->Byte1;
648  cdb->CDB10.LogicalBlockByte3 = ((PFOUR_BYTE)&logicalBlockAddress)->Byte0;
649 
650  cdb->CDB10.TransferBlocksMsb = ((PFOUR_BYTE)&transferBlocks)->Byte1;
651  cdb->CDB10.TransferBlocksLsb = ((PFOUR_BYTE)&transferBlocks)->Byte0;
652 
653  //
654  // Set transfer direction flag and Cdb command.
655  //
656 
657  if (currentIrpStack->MajorFunction == IRP_MJ_READ) {
658 
659  DebugPrint((3, "ClassBuildRequest: Read Command\n"));
660 
661  SET_FLAG(Srb->SrbFlags, SRB_FLAGS_DATA_IN);
662  cdb->CDB10.OperationCode = SCSIOP_READ;
663 
664  } else {
665 
666  DebugPrint((3, "ClassBuildRequest: Write Command\n"));
667 
668  SET_FLAG(Srb->SrbFlags, SRB_FLAGS_DATA_OUT);
669  cdb->CDB10.OperationCode = SCSIOP_WRITE;
670  }
671 
672  //
673  // If this is not a write-through request, then allow caching.
674  //
675 
676  if (!(currentIrpStack->Flags & SL_WRITE_THROUGH)) {
677 
679 
680  } else {
681 
682  //
683  // If write caching is enable then force media access in the
684  // cdb.
685  //
686 
687  if (FdoExtension->DeviceFlags & DEV_WRITE_CACHE) {
688  cdb->CDB10.ForceUnitAccess = TRUE;
689  }
690  }
691 
693  SET_FLAG(Srb->SrbFlags, SRB_CLASS_FLAGS_PAGING);
694  }
695 
696  //
697  // OR in the default flags from the device object.
698  //
699 
700  SET_FLAG(Srb->SrbFlags, FdoExtension->SrbFlags);
701 
702  //
703  // Set up major SCSI function.
704  //
705 
706  nextIrpStack->MajorFunction = IRP_MJ_SCSI;
707 
708  //
709  // Save SRB address in next stack for port driver.
710  //
711 
712  nextIrpStack->Parameters.Scsi.Srb = Srb;
713 
714  //
715  // Save retry count in current IRP stack.
716  //
717 
718  currentIrpStack->Parameters.Others.Argument4 = (PVOID)MAXIMUM_RETRIES;
719 
720  //
721  // Set up IoCompletion routine address.
722  //
723 
725 
726 }
struct _FOUR_BYTE * PFOUR_BYTE
#define TRUE
Definition: types.h:120
#define MmGetMdlVirtualAddress(_Mdl)
#define TEST_FLAG(Flags, Bit)
Definition: classpnp.h:156
_In_ PIRP Irp
Definition: csq.h:116
Definition: cdrw_hw.h:28
struct _CDB::_CDB10 CDB10
#define SRB_FLAGS_DATA_IN
Definition: srb.h:392
#define SENSE_BUFFER_SIZE
Definition: cdrw_hw.h:1183
#define DEV_WRITE_CACHE
Definition: class2.h:21
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
#define IRP_MJ_SCSI
#define SCSIOP_READ
Definition: cdrw_hw.h:905
#define SCSIOP_WRITE
Definition: cdrw_hw.h:906
union _CDB * PCDB
void * PVOID
Definition: retypes.h:9
#define MAXIMUM_RETRIES
Definition: class2.h:14
NTSTATUS NTAPI ClassIoComplete(IN PDEVICE_OBJECT Fdo, IN PIRP Irp, IN PVOID Context)
Definition: class.c:2432
struct _SCSI_REQUEST_BLOCK SCSI_REQUEST_BLOCK
#define SRB_CLASS_FLAGS_PAGING
Definition: classpnp.h:21
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
#define SET_FLAG(Flags, Bit)
Definition: classpnp.h:154
ULONG NTAPI DebugPrint(IN PSTRING DebugString, IN ULONG ComponentId, IN ULONG Level)
Definition: debug.c:23
#define Int64ShrlMod32(a, b)
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
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:1781
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:307
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
#define IRP_SYNCHRONOUS_PAGING_IO
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by ClassBuildRequest().

◆ ClasspInitializeCScanList()

VOID NTAPI ClasspInitializeCScanList ( IN PCSCAN_LIST  List)

Definition at line 965 of file obsolete.c.

966 {
967  PAGED_CODE();
968  RtlZeroMemory(List, sizeof(CSCAN_LIST));
969  InitializeListHead(&(List->CurrentSweep));
970  InitializeListHead(&(List->NextSweep));
971 }
#define PAGED_CODE()
Definition: video.h:57
LIST_ENTRY List
Definition: psmgr.c:57
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261

◆ ClasspInsertCScanList()

VOID NTAPI ClasspInsertCScanList ( IN PLIST_ENTRY  ListHead,
IN PCSCAN_LIST_ENTRY  Entry 
)

Definition at line 728 of file obsolete.c.

729 {
731 
732  DBGWARN(("ClasspInsertCScanList is OBSOLETE !"));
733 
734  //
735  // Iterate through the list. Insert this entry in the sorted list in
736  // order (after other requests for the same block). At each stop if
737  // blockNumber(Entry) >= blockNumber(t) then move on.
738  //
739 
740  for(t = (PCSCAN_LIST_ENTRY) ListHead->Flink;
741  t != (PCSCAN_LIST_ENTRY) ListHead;
742  t = (PCSCAN_LIST_ENTRY) t->Entry.Flink) {
743 
744  if(Entry->BlockNumber < t->BlockNumber) {
745 
746  //
747  // Set the pointers in entry to the right location.
748  //
749 
750  Entry->Entry.Flink = &(t->Entry);
751  Entry->Entry.Blink = t->Entry.Blink;
752 
753  //
754  // Set the pointers in the surrounding elements to refer to us.
755  //
756 
757  t->Entry.Blink->Flink = &(Entry->Entry);
758  t->Entry.Blink = &(Entry->Entry);
759  return;
760  }
761  }
762 
763  //
764  // Insert this entry at the tail of the list. If the list was empty this
765  // will also be the head of the list.
766  //
767 
768  InsertTailList(ListHead, &(Entry->Entry));
769 
770 }
GLdouble GLdouble t
Definition: gl.h:2047
#define InsertTailList(ListHead, Entry)
Entry(ENTRY_TYPE etype)
Definition: entries.cpp:35
Definition: obsolete.c:36
#define DBGWARN(args_in_parens)
Definition: debug.h:134
base of all file and directory entries
Definition: entries.h:82

Referenced by ClassInsertCScanList().

◆ ClasspStartNextSweep()

VOID NTAPI ClasspStartNextSweep ( PCSCAN_LIST  List)

Definition at line 973 of file obsolete.c.

974 {
975  ASSERT(IsListEmpty(&(List->CurrentSweep)) == TRUE);
976 
977  //
978  // If the next sweep is empty then there's nothing to do.
979  //
980 
981  if(IsListEmpty(&(List->NextSweep))) {
982  return;
983  }
984 
985  //
986  // Copy the next sweep list head into the current sweep list head.
987  //
988 
989  List->CurrentSweep = List->NextSweep;
990 
991  //
992  // Unlink the next sweep list from the list head now that we have a copy
993  // of it.
994  //
995 
996  InitializeListHead(&(List->NextSweep));
997 
998  //
999  // Update the next sweep list to point back to the current sweep list head.
1000  //
1001 
1002  List->CurrentSweep.Flink->Blink = &(List->CurrentSweep);
1003  List->CurrentSweep.Blink->Flink = &(List->CurrentSweep);
1004 
1005  return;
1006 }
#define TRUE
Definition: types.h:120
struct _LIST_ENTRY * Blink
Definition: typedefs.h:120
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
LIST_ENTRY List
Definition: psmgr.c:57
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944

Referenced by ClassRemoveCScanList().

◆ ClassRemoveCScanList()

PIRP NTAPI ClassRemoveCScanList ( IN PCSCAN_LIST  List)

Definition at line 1008 of file obsolete.c.

1009 {
1011 
1012  //
1013  // If the current sweep is empty then promote the next sweep.
1014  //
1015 
1016  if(IsListEmpty(&(List->CurrentSweep))) {
1018  }
1019 
1020  //
1021  // If the current sweep is still empty then we're done.
1022  //
1023 
1024  if(IsListEmpty(&(List->CurrentSweep))) {
1025  return NULL;
1026  }
1027 
1028  //
1029  // Remove the head entry from the current sweep. Record it's block number
1030  // so that nothing before it on the disk gets into the current sweep.
1031  //
1032 
1033  entry = (PCSCAN_LIST_ENTRY) RemoveHeadList(&(List->CurrentSweep));
1034 
1035  List->BlockNumber = entry->BlockNumber;
1036 
1037  return CONTAINING_RECORD(entry, IRP, Tail.Overlay.DriverContext);
1038 }
IRP
Definition: iotypes.h:2463
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
VOID NTAPI ClasspStartNextSweep(PCSCAN_LIST List)
Definition: obsolete.c:973
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
uint32_t entry
Definition: isohybrid.c:63
Definition: obsolete.c:36
struct _CSCAN_LIST_ENTRY * PCSCAN_LIST_ENTRY

◆ ClassSplitRequest()

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

Definition at line 49 of file obsolete.c.

50 {
51  PFUNCTIONAL_DEVICE_EXTENSION fdoExt = Fdo->DeviceExtension;
52  PCLASS_PRIVATE_FDO_DATA fdoData = fdoExt->PrivateFdoData;
53 
54  if (MaximumBytes > fdoData->HwMaxXferLen) {
55  DBGERR(("ClassSplitRequest - driver requesting split to size that "
56  "hardware is unable to handle!\n"));
57  }
58 
59  if (MaximumBytes < fdoData->HwMaxXferLen){
60  DBGWARN(("ClassSplitRequest - driver requesting smaller HwMaxXferLen "
61  "than required"));
62  fdoData->HwMaxXferLen = MAX(MaximumBytes, PAGE_SIZE);
63  }
64 
66 }
VOID NTAPI ServiceTransferRequest(PDEVICE_OBJECT Fdo, PIRP Irp)
Definition: class.c:2246
_In_ PIRP Irp
Definition: csq.h:116
#define DBGERR(args_in_parens)
Definition: debug.h:135
#define PAGE_SIZE
Definition: env_spec_w32.h:49
T MAX(T a, T b)
Definition: polytest.cpp:85
#define DBGWARN(args_in_parens)
Definition: debug.h:134

Referenced by CdRomStartIo(), and CdRomSwitchModeCompletion().

◆ RetryRequest()

VOID NTAPI RetryRequest ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp,
PSCSI_REQUEST_BLOCK  Srb,
BOOLEAN  Associated,
ULONG  RetryInterval 
)

Definition at line 340 of file obsolete.c.

347 {
350  ULONG transferByteCount;
351 
352  // This function is obsolete but is still used by some of our class drivers.
353  // DBGWARN(("RetryRequest is OBSOLETE !"));
354 
355  //
356  // Determine the transfer count of the request. If this is a read or a
357  // write then the transfer count is in the Irp stack. Otherwise assume
358  // the MDL contains the correct length. If there is no MDL then the
359  // transfer length must be zero.
360  //
361 
362  if (currentIrpStack->MajorFunction == IRP_MJ_READ ||
363  currentIrpStack->MajorFunction == IRP_MJ_WRITE) {
364 
365  transferByteCount = currentIrpStack->Parameters.Read.Length;
366 
367  } else if (Irp->MdlAddress != NULL) {
368 
369  //
370  // Note this assumes that only read and write requests are spilt and
371  // other request do not need to be. If the data buffer address in
372  // the MDL and the SRB don't match then transfer length is most
373  // likely incorrect.
374  //
375 
376  ASSERT(Srb->DataBuffer == MmGetMdlVirtualAddress(Irp->MdlAddress));
377  transferByteCount = Irp->MdlAddress->ByteCount;
378 
379  } else {
380 
381  transferByteCount = 0;
382  }
383 
384  //
385  // this is a safety net. this should not normally be hit, since we are
386  // not guaranteed to be an fdoExtension
387  //
388 
390 
391  //
392  // Reset byte count of transfer in SRB Extension.
393  //
394 
395  Srb->DataTransferLength = transferByteCount;
396 
397  //
398  // Zero SRB statuses.
399  //
400 
401  Srb->SrbStatus = Srb->ScsiStatus = 0;
402 
403  //
404  // Set the no disconnect flag, disable synchronous data transfers and
405  // disable tagged queuing. This fixes some errors.
406  // NOTE: Cannot clear these flags, just add to them
407  //
408 
412 
413  Srb->QueueTag = SP_UNTAGGED;
414 
415  //
416  // Set up major SCSI function.
417  //
418 
419  nextIrpStack->MajorFunction = IRP_MJ_SCSI;
420 
421  //
422  // Save SRB address in next stack for port driver.
423  //
424 
425  nextIrpStack->Parameters.Scsi.Srb = Srb;
426 
427 
429 
430  {
431  LARGE_INTEGER retry100ns;
432  retry100ns.QuadPart = RetryInterval; // seconds
433  retry100ns.QuadPart *= (LONGLONG)1000 * 1000 * 10;
434 
435  ClassRetryRequest(DeviceObject, Irp, retry100ns);
436  }
437  return;
438 } // end RetryRequest()
#define TRUE
Definition: types.h:120
#define MmGetMdlVirtualAddress(_Mdl)
#define TEST_FLAG(Flags, Bit)
Definition: classpnp.h:156
#define SRB_FLAGS_FREE_SENSE_BUFFER
Definition: srb.h:398
_In_ PIRP Irp
Definition: csq.h:116
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
#define SP_UNTAGGED
Definition: srb.h:225
#define IRP_MJ_SCSI
#define CLEAR_FLAG(Flags, Bit)
Definition: classpnp.h:155
smooth NULL
Definition: ftsmooth.c:416
int64_t LONGLONG
Definition: typedefs.h:66
#define SRB_FLAGS_DISABLE_SYNCH_TRANSFER
Definition: srb.h:389
NTSTATUS NTAPI ClassIoComplete(IN PDEVICE_OBJECT Fdo, IN PIRP Irp, IN PVOID Context)
Definition: class.c:2432
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define SRB_FLAGS_DISABLE_DISCONNECT
Definition: srb.h:388
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
#define SET_FLAG(Flags, Bit)
Definition: classpnp.h:154
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define IRP_MJ_READ
Definition: rdpdr.c:46
VOID NTAPI ClassRetryRequest(IN PDEVICE_OBJECT SelfDeviceObject, IN PIRP Irp, IN LARGE_INTEGER TimeDelta100ns)
Definition: class.c:8780
unsigned int ULONG
Definition: retypes.h:1
#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:2772
#define SRB_FLAGS_QUEUE_ACTION_ENABLE
Definition: srb.h:387
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by ClassIoCompleteAssociated().