ReactOS  0.4.14-dev-552-g2fad488
mmc.c
Go to the documentation of this file.
1 /*--
2 
3 Copyright (C) Microsoft Corporation, 2000
4 
5 Module Name:
6 
7  mmc.c
8 
9 Abstract:
10 
11  This file is used to extend cdrom.sys to detect and use mmc-compatible
12  drives' capabilities more wisely.
13 
14 Environment:
15 
16  kernel mode only
17 
18 Notes:
19 
20  SCSI Tape, CDRom and Disk class drivers share common routines
21  that can be found in the CLASS directory (..\ntos\dd\class).
22 
23 Revision History:
24 
25 --*/
26 
27 #include "cdrom.h"
28 
30 NTAPI
32  IN PDEVICE_OBJECT Fdo,
35  IN FEATURE_NUMBER StartingFeature,
36  IN ULONG RequestedType
37  );
38 
39 VOID
40 NTAPI
43  IN ULONG Usable
44  );
45 
47 NTAPI
50  IN PIRP Irp,
51  IN PDEVICE_OBJECT Fdo
52  );
53 
54 VOID
55 NTAPI
57  PDEVICE_OBJECT Fdo
58  );
59 
60 /*++
61 
62  NOT DOCUMENTED YET - may be called at up to DISPATCH_LEVEL
63  if memory is non-paged
64  PRESUMES ALL DATA IS ACCESSIBLE based on FeatureBuffer
65 
66 --*/
67 VOID
68 NTAPI
70  IN PFEATURE_DATA_PROFILE_LIST ProfileHeader,
71  IN FEATURE_PROFILE_TYPE ProfileToFind,
73  )
74 {
76  ULONG numberOfProfiles;
77  ULONG i;
78 
79  ASSERT((ProfileHeader->Header.AdditionalLength % 4) == 0);
80 
81  *Found = FALSE;
82 
83  numberOfProfiles = ProfileHeader->Header.AdditionalLength / 4;
84  profile = ProfileHeader->Profiles; // zero-sized array
85 
86  for (i = 0; i < numberOfProfiles; i++) {
87 
88  FEATURE_PROFILE_TYPE currentProfile;
89 
90  currentProfile =
91  (profile->ProfileNumber[0] << 8) |
92  (profile->ProfileNumber[1] & 0xff);
93 
94  if (currentProfile == ProfileToFind) {
95 
96  *Found = TRUE;
97 
98  }
99 
100  profile++;
101  }
102  return;
103 
104 }
105 
106 
107 /*++
108 
109  NOT DOCUMENTED YET - may be called at up to DISPATCH_LEVEL
110  if memory is non-paged
111 
112 --*/
113 PVOID
114 NTAPI
116  IN PGET_CONFIGURATION_HEADER FeatureBuffer,
117  IN ULONG Length,
118  IN FEATURE_NUMBER Feature
119  )
120 {
121  PUCHAR buffer;
122  PUCHAR limit;
123 
124  if (Length < sizeof(GET_CONFIGURATION_HEADER) + sizeof(FEATURE_HEADER)) {
125  return NULL;
126  }
127 
128  //
129  // set limit to point to first illegal address
130  //
131 
132  limit = (PUCHAR)FeatureBuffer;
133  limit += Length;
134 
135  //
136  // set buffer to point to first page
137  //
138 
139  buffer = FeatureBuffer->Data;
140 
141  //
142  // loop through each page until we find the requested one, or
143  // until it's not safe to access the entire feature header
144  // (if equal, have exactly enough for the feature header)
145  //
146  while (buffer + sizeof(FEATURE_HEADER) <= limit) {
147 
149  FEATURE_NUMBER thisFeature;
150 
151  thisFeature =
152  (header->FeatureCode[0] << 8) |
153  (header->FeatureCode[1]);
154 
155  if (thisFeature == Feature) {
156 
157  PUCHAR temp;
158 
159  //
160  // if don't have enough memory to safely access all the feature
161  // information, return NULL
162  //
163  temp = buffer;
164  temp += sizeof(FEATURE_HEADER);
165  temp += header->AdditionalLength;
166 
167  if (temp > limit) {
168 
169  //
170  // this means the transfer was cut-off, an insufficiently
171  // small buffer was given, or other arbitrary error. since
172  // it's not safe to view the amount of data (even though
173  // the header is safe) in this feature, pretend it wasn't
174  // transferred at all...
175  //
176 
178  "Feature %x exists, but not safe to access all its "
179  "data. returning NULL\n", Feature));
180  return NULL;
181  } else {
182  return buffer;
183  }
184  }
185 
186  if (header->AdditionalLength % 4) {
187  ASSERT(!"Feature page AdditionalLength field must be integral multiple of 4!\n");
188  return NULL;
189  }
190 
191  buffer += sizeof(FEATURE_HEADER);
192  buffer += header->AdditionalLength;
193 
194  }
195  return NULL;
196 }
197 
198 /*++
199 
200 Private so we can later expose to someone wanting to use a preallocated buffer
201 
202 --*/
203 NTSTATUS
204 NTAPI
206  IN PDEVICE_OBJECT Fdo,
209  OUT PULONG ValidBytes,
210  IN FEATURE_NUMBER StartingFeature,
211  IN ULONG RequestedType
212  )
213 {
214  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension;
215  PCDROM_DATA cdData;
216  SCSI_REQUEST_BLOCK srb;
217  PCDB cdb;
218  ULONG_PTR returned;
220 
221  PAGED_CODE();
222  ASSERT(Buffer);
223  ASSERT(ValidBytes);
224 
225  *ValidBytes = 0;
226  returned = 0;
227 
228  RtlZeroMemory(&srb, sizeof(SCSI_REQUEST_BLOCK));
230 
231  fdoExtension = Fdo->DeviceExtension;
232  cdData = (PCDROM_DATA)(fdoExtension->CommonExtension.DriverData);
233 
236  }
237 
239  srb.CdbLength = 10;
240 
241  cdb = (PCDB)srb.Cdb;
242  cdb->GET_CONFIGURATION.OperationCode = SCSIOP_GET_CONFIGURATION;
243  cdb->GET_CONFIGURATION.RequestType = (UCHAR)RequestedType;
244  cdb->GET_CONFIGURATION.StartingFeature[0] = (UCHAR)(StartingFeature >> 8);
245  cdb->GET_CONFIGURATION.StartingFeature[1] = (UCHAR)(StartingFeature & 0xff);
246  cdb->GET_CONFIGURATION.AllocationLength[0] = (UCHAR)(BufferSize >> 8);
247  cdb->GET_CONFIGURATION.AllocationLength[1] = (UCHAR)(BufferSize & 0xff);
248 
250  BufferSize, FALSE);
251  returned = srb.DataTransferLength;
252 
254  "CdromGetConfiguration: Status was %x\n", status));
255 
257 
258  //
259  // if returned more than can be stored in a ULONG, return false
260  //
261 
262  if (returned > (ULONG)(-1)) {
263  return STATUS_UNSUCCESSFUL;
264  }
265  ASSERT(returned <= BufferSize);
266  *ValidBytes = (ULONG)returned;
267  return STATUS_SUCCESS;
268 
269  } else {
270 
272  "CdromGetConfiguration: failed %x\n", status));
273  return status;
274 
275  }
276  ASSERT(FALSE);
277  return STATUS_UNSUCCESSFUL;
278 }
279 
280 /*++
281 
282  Allocates buffer with configuration info, returns STATUS_SUCCESS
283  or an error if one occurred
284 
285  NOTE: does not handle case where more than 65000 bytes are returned,
286  which requires multiple calls with different starting feature
287  numbers.
288 
289 --*/
290 NTSTATUS
291 NTAPI
293  IN PDEVICE_OBJECT Fdo,
296  IN FEATURE_NUMBER StartingFeature,
297  IN ULONG RequestedType
298  )
299 {
300  //PFUNCTIONAL_DEVICE_EXTENSION fdoExtension;
301  GET_CONFIGURATION_HEADER header; // eight bytes, not a lot
303  ULONG returned;
304  ULONG size;
305  ULONG i;
307 
308  PAGED_CODE();
309 
310 
311  //fdoExtension = Fdo->DeviceExtension;
312  *Buffer = NULL;
313  *BytesReturned = 0;
314 
315  buffer = NULL;
316  returned = 0;
317 
318  //
319  // send the first request down to just get the header
320  //
321 
322  status = CdRompGetConfiguration(Fdo, &header, sizeof(header),
323  &returned, StartingFeature, RequestedType);
324 
325  if (!NT_SUCCESS(status)) {
326  return status;
327  }
328 
329  //
330  // now try again, using information returned to allocate
331  // just enough memory
332  //
333 
334  size = header.DataLength[0] << 24 |
335  header.DataLength[1] << 16 |
336  header.DataLength[2] << 8 |
337  header.DataLength[3] << 0 ;
338 
339 
340  for (i = 0; i < 4; i++) {
341 
342  //
343  // the datalength field is the size *following*
344  // itself, so adjust accordingly
345  //
346 
347  size += 4*sizeof(UCHAR);
348 
349  //
350  // make sure the size is reasonable
351  //
352 
353  if (size <= sizeof(FEATURE_HEADER)) {
355  "CdromGetConfiguration: drive reports only %x bytes?\n",
356  size));
357  return STATUS_UNSUCCESSFUL;
358  }
359 
360  //
361  // allocate the memory
362  //
363 
366  size,
368 
369  if (buffer == NULL) {
371  }
372 
373  //
374  // send the first request down to just get the header
375  //
376 
377  status = CdRompGetConfiguration(Fdo, buffer, size, &returned,
378  StartingFeature, RequestedType);
379 
380  if (!NT_SUCCESS(status)) {
382  return status;
383  }
384 
385  if (returned > size) {
387  return STATUS_INTERNAL_ERROR;
388  }
389 
390  returned = buffer->DataLength[0] << 24 |
391  buffer->DataLength[1] << 16 |
392  buffer->DataLength[2] << 8 |
393  buffer->DataLength[3] << 0 ;
394  returned += 4*sizeof(UCHAR);
395 
396  if (returned <= size) {
397  *Buffer = buffer;
398  *BytesReturned = size; // amount of 'safe' memory
399  return STATUS_SUCCESS;
400  }
401 
402  //
403  // else retry using the new size....
404  //
405 
406  size = returned;
408  buffer = NULL;
409 
410  }
411 
412  //
413  // it failed after a number of attempts, so just fail.
414  //
415 
417  "CdRomGetConfiguration: Failed %d attempts to get all feature "
418  "information\n", i));
419  return STATUS_IO_DEVICE_ERROR;
420 }
421 
422 VOID
423 NTAPI
425  IN PDEVICE_OBJECT Fdo,
426  OUT PBOOLEAN IsMmc
427  )
428 {
429  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Fdo->DeviceExtension;
430  PCOMMON_DEVICE_EXTENSION commonExtension = Fdo->DeviceExtension;
431  PCDROM_DATA cdData = commonExtension->DriverData;
432  GET_CONFIGURATION_HEADER localHeader;
434  ULONG usable;
435  ULONG size;
436  ULONG previouslyFailed;
437 
438  PAGED_CODE();
439  ASSERT( commonExtension->IsFdo );
440 
441  *IsMmc = FALSE;
442 
443  //
444  // read the registry in case the drive failed previously,
445  // and a timeout is occurring.
446  //
447 
448  previouslyFailed = FALSE;
449  ClassGetDeviceParameter(fdoExtension,
452  &previouslyFailed
453  );
454 
455  if (previouslyFailed) {
457  }
458 
459  //
460  // check for the following profiles:
461  //
462  // ProfileList
463  //
464 
466  &localHeader,
467  sizeof(localHeader),
468  &usable,
471 
476 
478  "GetConfiguration Failed (%x), device %p not mmc-compliant\n",
479  status, Fdo
480  ));
481  previouslyFailed = TRUE;
482  ClassSetDeviceParameter(fdoExtension,
485  previouslyFailed
486  );
487  return;
488 
489  } else if (!NT_SUCCESS(status)) {
490 
492  "GetConfiguration Failed, status %x -- defaulting to -ROM\n",
493  status));
494  return;
495 
496  } else if (usable < sizeof(GET_CONFIGURATION_HEADER)) {
497 
499  "GetConfiguration Failed, returned only %x bytes!\n", usable));
500  previouslyFailed = TRUE;
501  ClassSetDeviceParameter(fdoExtension,
504  previouslyFailed
505  );
506  return;
507 
508  }
509 
510  size = (localHeader.DataLength[0] << 24) |
511  (localHeader.DataLength[1] << 16) |
512  (localHeader.DataLength[2] << 8) |
513  (localHeader.DataLength[3] << 0);
514 
515  if(size <= 4) {
517  "GetConfiguration Failed, claims MMC support but doesn't "
518  "correctly return config length!\n"));
519  return;
520  }
521 
522  size += 4; // sizeof the datalength fields
523 
524 #if DBG
525  {
526  PGET_CONFIGURATION_HEADER dbgBuffer;
527  NTSTATUS dbgStatus;
528 
530  (SIZE_T)size,
532  if (dbgBuffer != NULL) {
533  RtlZeroMemory(dbgBuffer, size);
534 
535  dbgStatus = CdRompGetConfiguration(Fdo, dbgBuffer, size,
538 
539  if (NT_SUCCESS(dbgStatus)) {
540  CdRompPrintAllFeaturePages(dbgBuffer, usable);
541  }
542  ExFreePool(dbgBuffer);
543  }
544  }
545 #endif // DBG
546 
547  *IsMmc = TRUE;
548  return;
549 }
550 
551 VOID
552 NTAPI
555  IN ULONG Usable
556  )
557 {
559 
561 // items expected to ALWAYS be current
564  if (header != NULL) {
566  "CdromGetConfiguration: CurrentProfile %x "
567  "with %x bytes of data at %p\n",
568  Buffer->CurrentProfile[0] << 8 |
569  Buffer->CurrentProfile[1],
570  Usable, Buffer));
571  }
572 
574  if (header) {
576  "CdromGetConfiguration: %s %s\n",
577  (header->Current ?
578  "Currently supports" : "Is able to support"),
579  "CORE Features"
580  ));
581  }
582 
584  if (header) {
586  "CdromGetConfiguration: %s %s\n",
587  (header->Current ?
588  "Currently supports" : "Is able to support"),
589  "Morphing"
590  ));
591  }
592 
594  if (header) {
596  "CdromGetConfiguration: %s %s\n",
597  (header->Current ?
598  "Currently supports" : "Is able to support"),
599  "Multi-Read"
600  ));
601  }
603  if (header) {
605  "CdromGetConfiguration: %s %s\n",
606  (header->Current ?
607  "Currently supports" : "Is able to support"),
608  "Removable Medium"
609  ));
610  }
611 
613  if (header) {
615  "CdromGetConfiguration: %s %s\n",
616  (header->Current ?
617  "Currently supports" : "Is able to support"),
618  "Timeouts"
619  ));
620  }
621 
623  if (header) {
625  "CdromGetConfiguration: %s %s\n",
626  (header->Current ?
627  "Currently supports" : "Is able to support"),
628  "Power Management"
629  ));
630  }
631 
633  if (header) {
635  "CdromGetConfiguration: %s %s\n",
636  (header->Current ?
637  "Currently supports" : "Is able to support"),
638  "Embedded Changer"
639  ));
640  }
641 
643  if (header) {
645  "CdromGetConfiguration: %s %s\n",
646  (header->Current ?
647  "Currently supports" : "Is able to support"),
648  "LUN Serial Number"
649  ));
650  }
651 
652 
654  if (header) {
656  "CdromGetConfiguration: %s %s\n",
657  (header->Current ?
658  "Currently supports" : "Is able to support"),
659  "Microcode Update"
660  ));
661  }
662 
664 // items expected not to always be current
667  if (header) {
669  "CdromGetConfiguration: %s %s\n",
670  (header->Current ?
671  "Currently supports" : "Is able to support"),
672  "Analogue CD Audio Operations"
673  ));
674  }
675 
677  if (header) {
679  "CdromGetConfiguration: %s %s\n",
680  (header->Current ?
681  "Currently supports" : "Is able to support"),
682  "reading from CD-ROM/R/RW"
683  ));
684  }
685 
687  if (header) {
689  "CdromGetConfiguration: %s %s\n",
690  (header->Current ?
691  "Currently supports" : "Is able to support"),
692  "CD Recording (Mastering)"
693  ));
694  }
695 
697  if (header) {
699  "CdromGetConfiguration: %s %s\n",
700  (header->Current ?
701  "Currently supports" : "Is able to support"),
702  "CD Recording (Track At Once)"
703  ));
704  }
705 
707  if (header) {
709  "CdromGetConfiguration: %s %s\n",
710  (header->Current ?
711  "Currently supports" : "Is able to support"),
712  "DVD CSS"
713  ));
714  }
715 
717  if (header) {
719  "CdromGetConfiguration: %s %s\n",
720  (header->Current ?
721  "Currently supports" : "Is able to support"),
722  "DVD Structure Reads"
723  ));
724  }
725 
727  if (header) {
729  "CdromGetConfiguration: %s %s\n",
730  (header->Current ?
731  "Currently supports" : "Is able to support"),
732  "DVD Recording (Mastering)"
733  ));
734  }
735 
737  if (header) {
739  "CdromGetConfiguration: %s %s\n",
740  (header->Current ?
741  "Currently supports" : "Is able to support"),
742  "DVD Disc Control Blocks"
743  ));
744  }
745 
747  if (header) {
749  "CdromGetConfiguration: %s %s\n",
750  (header->Current ?
751  "Currently supports" : "Is able to support"),
752  "Formatting"
753  ));
754  }
755 
757  if (header) {
759  "CdromGetConfiguration: %s %s\n",
760  (header->Current ?
761  "Currently supports" : "Is able to support"),
762  "Random Reads"
763  ));
764  }
765 
767  if (header) {
769  "CdromGetConfiguration: %s %s\n",
770  (header->Current ?
771  "Currently supports" : "Is able to support"),
772  "Random Writes"
773  ));
774  }
775 
777  if (header) {
779  "CdromGetConfiguration: %s %s\n",
780  (header->Current ?
781  "Currently supports" : "Is able to support"),
782  "Restricted Overwrites."
783  ));
784  }
785 
787  if (header) {
789  "CdromGetConfiguration: %s %s\n",
790  (header->Current ?
791  "Currently supports" : "Is able to support"),
792  "Write Once Media"
793  ));
794  }
795 
797  if (header) {
799  "CdromGetConfiguration: %s %s\n",
800  (header->Current ?
801  "Currently supports" : "Is able to support"),
802  "Sector Erasable Media"
803  ));
804  }
805 
807  if (header) {
809  "CdromGetConfiguration: %s %s\n",
810  (header->Current ?
811  "Currently supports" : "Is able to support"),
812  "Incremental Streaming Writing"
813  ));
814  }
815 
817  if (header) {
819  "CdromGetConfiguration: %s %s\n",
820  (header->Current ?
821  "Currently supports" : "Is able to support"),
822  "Real-time Streaming Reads"
823  ));
824  }
825 
827  if (header) {
829  "CdromGetConfiguration: %s %s\n",
830  (header->Current ?
831  "Currently supports" : "Is able to support"),
832  "S.M.A.R.T."
833  ));
834  }
835 
837  if (header) {
839  "CdromGetConfiguration: %s %s\n",
840  (header->Current ?
841  "Currently supports" : "Is able to support"),
842  "defect management"
843  ));
844  }
845  return;
846 }
847 
848 NTSTATUS
849 NTAPI
852  IN PIRP Irp,
853  IN PDEVICE_OBJECT Fdo
854  )
855 {
856  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Fdo->DeviceExtension;
857  //PCOMMON_DEVICE_EXTENSION commonExtension = Fdo->DeviceExtension;
858  PCDROM_DATA cdData = fdoExtension->CommonExtension.DriverData;
859  PCDROM_MMC_EXTENSION mmcData = &(cdData->Mmc);
860  PSCSI_REQUEST_BLOCK srb = &(mmcData->CapabilitiesSrb);
863  //PIRP delayedIrp;
864  ULONG retryCount;
866 
867 
868  // completion routine should retry as necessary.
869  // when success, clear the flag to allow startio to proceed.
870  // else fail original request when retries are exhausted.
871 
872  ASSERT(mmcData->CapabilitiesIrp == Irp);
873 
874  // for now, if succeeded, just print the new pages.
875 
876  if (SRB_STATUS(srb->SrbStatus) != SRB_STATUS_SUCCESS) {
877 
878  //
879  // ISSUE-2000/4/20-henrygab - should we try to reallocate if size
880  // available became larger than what we
881  // originally allocated? otherwise, it
882  // is possible (not probable) that we
883  // would miss the feature. can check
884  // that by finding out what the last
885  // feature is in the current group.
886  //
887 
888  BOOLEAN retry;
889  ULONG retryInterval;
890 
891  //
892  // Release the queue if it is frozen.
893  //
894 
895  if (srb->SrbStatus & SRB_STATUS_QUEUE_FROZEN) {
896  ClassReleaseQueue(Fdo);
897  }
898 
899  retry = ClassInterpretSenseInfo(
900  Fdo,
901  srb,
902  irpStack->MajorFunction,
903  0,
904  MAXIMUM_RETRIES - ((ULONG)(ULONG_PTR)irpStack->Parameters.Others.Argument4),
905  &status,
906  &retryInterval);
907 
908  //
909  // DATA_OVERRUN is not an error in this case....
910  //
911 
912  if (status == STATUS_DATA_OVERRUN) {
914  }
915 
916  //
917  // override verify_volume based on original irp's settings
918  //
919 
920  if (TEST_FLAG(irpStack->Flags, SL_OVERRIDE_VERIFY_VOLUME) &&
923  retry = TRUE;
924  }
925 
926  //
927  // get current retry count
928  //
929  retryCount = PtrToUlong(irpStack->Parameters.Others.Argument1);
930 
931  if (retry && retryCount) {
932 
933  //
934  // update retry count
935  //
936  irpStack->Parameters.Others.Argument1 = UlongToPtr(retryCount-1);
937 
938 
939  delay.QuadPart = retryInterval;
940  delay.QuadPart *= (LONGLONG)1000 * 1000 * 10;
941 
942  //
943  // retry the request
944  //
945 
947  "Not using ClassRetryRequest Yet\n"));
949  "Retry update capabilities %p\n", Irp));
951 
952  CdRomRetryRequest(fdoExtension, Irp, retryInterval, TRUE);
953 
954  //
955  // ClassRetryRequest(Fdo, Irp, delay);
956  //
957 
959 
960  }
961 
962  } else {
963 
965 
966  }
967 
968  Irp->IoStatus.Status = status;
969 
971 
972 
974 }
975 
976 VOID
977 NTAPI
979  PDEVICE_OBJECT Fdo
980  )
981 {
982  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Fdo->DeviceExtension;
983  //PCOMMON_DEVICE_EXTENSION commonExtension = Fdo->DeviceExtension;
984  PCDROM_DATA cdData = fdoExtension->CommonExtension.DriverData;
985  PCDROM_MMC_EXTENSION mmcData = &(cdData->Mmc);
986  PIO_STACK_LOCATION nextStack;
988  PCDB cdb;
989  ULONG bufferSize;
990  PIRP irp;
991 
992  ASSERT(mmcData->UpdateState);
993  ASSERT(ExQueryDepthSList(&(mmcData->DelayedIrps)) != 0);
994  ASSERT(mmcData->CapabilitiesIrp != NULL);
995  ASSERT(mmcData->CapabilitiesMdl != NULL);
996  ASSERT(mmcData->CapabilitiesBuffer);
997  ASSERT(mmcData->CapabilitiesBufferSize != 0);
998  ASSERT(fdoExtension->SenseData);
999 
1000  //
1001  // do *NOT* call IoReuseIrp(), since it would zero out our
1002  // current irp stack location, which we really don't want
1003  // to happen. it would also set the current irp stack location
1004  // to one greater than currently exists (to give max irp usage),
1005  // but we don't want that either, since we use the top irp stack.
1006  //
1007  // IoReuseIrp(mmcData->CapabilitiesIrp, STATUS_UNSUCCESSFUL);
1008  //
1009 
1010  irp = mmcData->CapabilitiesIrp;
1011  srb = &(mmcData->CapabilitiesSrb);
1012  cdb = (PCDB)(srb->Cdb);
1013  bufferSize = mmcData->CapabilitiesBufferSize;
1014 
1015  //
1016  // zero stuff out
1017  //
1018 
1019  RtlZeroMemory(srb, sizeof(SCSI_REQUEST_BLOCK));
1020  RtlZeroMemory(fdoExtension->SenseData, sizeof(SENSE_DATA));
1021  RtlZeroMemory(mmcData->CapabilitiesBuffer, bufferSize);
1022 
1023  //
1024  // setup the srb
1025  //
1026 
1031  srb->SenseInfoBuffer = fdoExtension->SenseData;
1032  srb->DataBuffer = mmcData->CapabilitiesBuffer;
1035  srb->ScsiStatus = 0;
1036  srb->SrbStatus = 0;
1037  srb->NextSrb = NULL;
1038  srb->OriginalRequest = irp;
1039  srb->SrbFlags = fdoExtension->SrbFlags;
1040  srb->CdbLength = 10;
1043 
1044  //
1045  // setup the cdb
1046  //
1047 
1048  cdb->GET_CONFIGURATION.OperationCode = SCSIOP_GET_CONFIGURATION;
1050  cdb->GET_CONFIGURATION.StartingFeature[0] = 0;
1051  cdb->GET_CONFIGURATION.StartingFeature[1] = 0;
1052  cdb->GET_CONFIGURATION.AllocationLength[0] = (UCHAR)(bufferSize >> 8);
1053  cdb->GET_CONFIGURATION.AllocationLength[1] = (UCHAR)(bufferSize & 0xff);
1054 
1055  //
1056  // setup the irp
1057  //
1058 
1059  nextStack = IoGetNextIrpStackLocation(irp);
1060  nextStack->MajorFunction = IRP_MJ_SCSI;
1061  nextStack->Parameters.Scsi.Srb = srb;
1062  irp->MdlAddress = mmcData->CapabilitiesMdl;
1063  irp->AssociatedIrp.SystemBuffer = mmcData->CapabilitiesBuffer;
1065  TRUE, TRUE, TRUE);
1066 
1067  return;
1068 
1069 }
1070 
1071 VOID
1072 NTAPI
1074  IN PDEVICE_OBJECT Fdo,
1075  IN PVOID Context
1076  )
1077 {
1078  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Fdo->DeviceExtension;
1079  PCOMMON_DEVICE_EXTENSION commonExtension = Fdo->DeviceExtension;
1080  PCDROM_DATA cdData = fdoExtension->CommonExtension.DriverData;
1081  PCDROM_MMC_EXTENSION mmcData = &(cdData->Mmc);
1083  PSCSI_REQUEST_BLOCK srb = &(mmcData->CapabilitiesSrb);
1084  NTSTATUS status;
1085 
1086 
1087  ASSERT(Context == NULL);
1088 
1089  //
1090  // NOTE: a remove lock is unnecessary, since the delayed irp
1091  // will have said lock held for itself, preventing a remove.
1092  //
1094 
1095  ASSERT(thisStack->Parameters.Others.Argument1 == Fdo);
1096  ASSERT(thisStack->Parameters.Others.Argument2 == mmcData->CapabilitiesBuffer);
1097  ASSERT(thisStack->Parameters.Others.Argument3 == &(mmcData->CapabilitiesSrb));
1098 
1099  mmcData->WriteAllowed = FALSE; // default to read-only
1100 
1101  //
1102  // set max retries, and also allow volume verify override based on
1103  // original (delayed) irp
1104  //
1105 
1106  thisStack->Parameters.Others.Argument4 = (PVOID)MAXIMUM_RETRIES;
1107 
1108  //
1109  // send to self... note that SL_OVERRIDE_VERIFY_VOLUME is not required,
1110  // as this is IRP_MJ_INTERNAL_DEVICE_CONTROL
1111  //
1112 
1113  IoCallDriver(commonExtension->LowerDeviceObject, mmcData->CapabilitiesIrp);
1114 
1117 
1118  status = mmcData->CapabilitiesIrp->IoStatus.Status;
1119 
1120  if (!NT_SUCCESS(status)) {
1121 
1122  goto FinishDriveUpdate;
1123 
1124  }
1125 
1126  //
1127  // we've updated the feature set, so update whether or not reads and writes
1128  // are allowed or not.
1129  //
1130 
1132  "CdRomUpdateMmc => Succeeded "
1133  "--------------------"
1134  "--------------------\n"));
1135 
1136  /*++
1137 
1138  NOTE: It is important to only use srb->DataTransferLength worth
1139  of data at this point, since the bufferSize is what is
1140  *available* to use, not what was *actually* used.
1141 
1142  --*/
1143 
1144 #if DBG
1146  srb->DataTransferLength);
1147 #endif // DBG
1148 
1149  //
1150  // update whether or not writes are allowed. this is currently defined
1151  // as requiring TargetDefectManagement and RandomWritable features
1152  //
1153  {
1154  PFEATURE_HEADER defectHeader;
1155  PFEATURE_HEADER writableHeader;
1156 
1157  defectHeader = CdRomFindFeaturePage(mmcData->CapabilitiesBuffer,
1158  srb->DataTransferLength,
1160  writableHeader = CdRomFindFeaturePage(mmcData->CapabilitiesBuffer,
1161  srb->DataTransferLength,
1163 
1164  if ((defectHeader != NULL) && (writableHeader != NULL) &&
1165  (defectHeader->Current) && (writableHeader->Current)) {
1166 
1167  //
1168  // this should be the *ONLY* place writes are set to allowed
1169  //
1170 
1172  "CdRomUpdateMmc => Writes *allowed*\n"));
1173  mmcData->WriteAllowed = TRUE;
1174 
1175  } else {
1176 
1177  if (defectHeader == NULL) {
1179  "CdRomUpdateMmc => No writes - %s = %s\n",
1180  "defect management", "DNE"));
1181  } else {
1183  "CdRomUpdateMmc => No writes - %s = %s\n",
1184  "defect management", "Not Current"));
1185  }
1186  if (writableHeader == NULL) {
1188  "CdRomUpdateMmc => No writes - %s = %s\n",
1189  "sector writable", "DNE"));
1190  } else {
1192  "CdRomUpdateMmc => No writes - %s = %s\n",
1193  "sector writable", "Not Current"));
1194  }
1195  } // end of feature checking
1196  } // end of check for writability
1197 
1198  //
1199  // update the cached partition table information
1200  //
1201  // NOTE: THIS WILL CURRENTLY CAUSE A DEADLOCK!
1202  //
1203  // ISSUE-2000/06/20-henrygab - partition support not implemented
1204  // IoReadPartitionTable must be done
1205  // at PASSIVE level, requiring a thread
1206  // or worker item or other such method.
1207  //
1208 #if 0
1209  status = IoReadPartitionTable(Fdo, 1 << fdoExtension->SectorShift,
1210  TRUE, &mmcData->PartitionList);
1211  if (!NT_SUCCESS(status)) {
1212 
1213  goto FinishDriveUpdate;
1214 
1215  }
1216 #endif
1217 
1219 
1220 FinishDriveUpdate:
1221 
1222  CdRompFlushDelayedList(Fdo, mmcData, status, TRUE);
1223 
1224  return;
1225 }
1226 
1227 VOID
1228 NTAPI
1230  IN PDEVICE_OBJECT Fdo,
1231  IN PCDROM_MMC_EXTENSION MmcData,
1232  IN NTSTATUS Status,
1233  IN BOOLEAN CalledFromWorkItem
1234  )
1235 {
1236 #ifdef __REACTOS__
1238 #else
1240 #endif
1241  PIRP irp;
1242 
1243  // NOTE - REF #0002
1244  //
1245  // need to set the new state first to prevent deadlocks.
1246  // this is only done from the workitem, to prevent any
1247  // edge cases where we'd "lose" the UpdateRequired
1248  //
1249  // then, must ignore the state, since it's not guaranteed to
1250  // be the same any longer. the only thing left is to handle
1251  // all the delayed irps by flushing the queue and sending them
1252  // back onto the StartIo queue for the device.
1253  //
1254 
1255  if (CalledFromWorkItem) {
1256 
1257  LONG oldState;
1258  LONG newState;
1259 
1260  if (NT_SUCCESS(Status)) {
1261  newState = CdromMmcUpdateComplete;
1262  } else {
1263  newState = CdromMmcUpdateRequired;
1264  }
1265 
1266  oldState = InterlockedCompareExchange(&MmcData->UpdateState,
1267  newState,
1269  ASSERT(oldState == CdromMmcUpdateStarted);
1270 
1271  } else {
1272 
1273  //
1274  // just flushing the queue if not called from the workitem,
1275  // and we don't want to ever fail the queue in those cases.
1276  //
1277 
1279 
1280  }
1281 
1282  list = ExInterlockedFlushSList(&MmcData->DelayedIrps);
1283 
1284  // if this assert fires, it means that we have started
1285  // a workitem when the previous workitem took the delayed
1286  // irp. if this happens, then the logic in HACKHACK #0002
1287  // is either flawed or the rules set within are not being
1288  // followed. this would require investigation.
1289 
1290  ASSERT(list != NULL);
1291 
1292  //
1293  // now either succeed or fail all the delayed irps, according
1294  // to the update status.
1295  //
1296 
1297  while (list != NULL) {
1298 
1299  irp = (PIRP)( ((PUCHAR)list) -
1300  FIELD_OFFSET(IRP, Tail.Overlay.DriverContext[0])
1301  );
1302  list = list->Next;
1303  irp->Tail.Overlay.DriverContext[0] = 0;
1304  irp->Tail.Overlay.DriverContext[1] = 0;
1305  irp->Tail.Overlay.DriverContext[2] = 0;
1306  irp->Tail.Overlay.DriverContext[3] = 0;
1307 
1308  if (NT_SUCCESS(Status)) {
1309 
1311  "CdRomUpdateMmc => Re-sending delayed irp %p\n",
1312  irp));
1313  IoStartPacket(Fdo, irp, NULL, NULL);
1314 
1315  } else {
1316 
1318  "CdRomUpdateMmc => Failing delayed irp %p with "
1319  " status %x\n", irp, Status));
1320  irp->IoStatus.Information = 0;
1321  irp->IoStatus.Status = Status;
1322  ClassReleaseRemoveLock(Fdo, irp);
1324 
1325  }
1326 
1327  } // while (list)
1328 
1329  return;
1330 
1331 }
1332 
1333 VOID
1334 NTAPI
1336  IN PDEVICE_OBJECT Fdo
1337  )
1338 {
1339  PCOMMON_DEVICE_EXTENSION commonExtension = Fdo->DeviceExtension;
1340  PCDROM_DATA cddata = commonExtension->DriverData;
1341  PCDROM_MMC_EXTENSION mmcData = &cddata->Mmc;
1342  //NTSTATUS status;
1343 
1344  if (mmcData->CapabilitiesWorkItem) {
1346  mmcData->CapabilitiesWorkItem = NULL;
1347  }
1348  if (mmcData->CapabilitiesIrp) {
1349  IoFreeIrp(mmcData->CapabilitiesIrp);
1350  mmcData->CapabilitiesIrp = NULL;
1351  }
1352  if (mmcData->CapabilitiesMdl) {
1353  IoFreeMdl(mmcData->CapabilitiesMdl);
1354  mmcData->CapabilitiesMdl = NULL;
1355  }
1356  if (mmcData->CapabilitiesBuffer) {
1357  ExFreePool(mmcData->CapabilitiesBuffer);
1358  mmcData->CapabilitiesBuffer = NULL;
1359  }
1360  mmcData->CapabilitiesBuffer = 0;
1361  mmcData->IsMmc = FALSE;
1362  mmcData->WriteAllowed = FALSE;
1363 
1364  return;
1365 }
1366 
1367 NTSTATUS
1368 NTAPI
1370  IN PDEVICE_OBJECT Fdo
1371  )
1372 {
1373  PCOMMON_DEVICE_EXTENSION commonExtension = Fdo->DeviceExtension;
1374  PCDROM_DATA cddata = commonExtension->DriverData;
1375  PCDROM_MMC_EXTENSION mmcData = &cddata->Mmc;
1376  PIO_STACK_LOCATION irpStack;
1377  NTSTATUS status;
1378 
1379  ASSERT(mmcData->CapabilitiesWorkItem == NULL);
1380  ASSERT(mmcData->CapabilitiesIrp == NULL);
1381  ASSERT(mmcData->CapabilitiesMdl == NULL);
1382  ASSERT(mmcData->CapabilitiesBuffer == NULL);
1383  ASSERT(mmcData->CapabilitiesBufferSize == 0);
1384 
1386  &mmcData->CapabilitiesBuffer,
1387  &mmcData->CapabilitiesBufferSize,
1390  if (!NT_SUCCESS(status)) {
1391  ASSERT(mmcData->CapabilitiesBuffer == NULL);
1392  ASSERT(mmcData->CapabilitiesBufferSize == 0);
1393  return status;
1394  }
1395  ASSERT(mmcData->CapabilitiesBuffer != NULL);
1396  ASSERT(mmcData->CapabilitiesBufferSize != 0);
1397 
1398  mmcData->CapabilitiesMdl = IoAllocateMdl(mmcData->CapabilitiesBuffer,
1399  mmcData->CapabilitiesBufferSize,
1400  FALSE, FALSE, NULL);
1401  if (mmcData->CapabilitiesMdl == NULL) {
1402  ExFreePool(mmcData->CapabilitiesBuffer);
1403  mmcData->CapabilitiesBufferSize = 0;
1405  }
1406 
1407 
1408  mmcData->CapabilitiesIrp = IoAllocateIrp(Fdo->StackSize + 2, FALSE);
1409  if (mmcData->CapabilitiesIrp == NULL) {
1410  IoFreeMdl(mmcData->CapabilitiesMdl);
1411  ExFreePool(mmcData->CapabilitiesBuffer);
1412  mmcData->CapabilitiesBufferSize = 0;
1414  }
1415 
1416  mmcData->CapabilitiesWorkItem = IoAllocateWorkItem(Fdo);
1417  if (mmcData->CapabilitiesWorkItem == NULL) {
1418  IoFreeIrp(mmcData->CapabilitiesIrp);
1419  IoFreeMdl(mmcData->CapabilitiesMdl);
1420  ExFreePool(mmcData->CapabilitiesBuffer);
1421  mmcData->CapabilitiesBufferSize = 0;
1423  }
1424 
1425  //
1426  // everything has been allocated, so now prepare it all....
1427  //
1428 
1431  KeInitializeSpinLock(&mmcData->DelayedLock);
1432 
1433  //
1434  // use the extra stack for internal bookkeeping
1435  //
1437  irpStack = IoGetCurrentIrpStackLocation(mmcData->CapabilitiesIrp);
1438  irpStack->Parameters.Others.Argument1 = Fdo;
1439  irpStack->Parameters.Others.Argument2 = mmcData->CapabilitiesBuffer;
1440  irpStack->Parameters.Others.Argument3 = &(mmcData->CapabilitiesSrb);
1441  // arg 4 is the retry count
1442 
1443  //
1444  // set the completion event to FALSE for now
1445  //
1446 
1449  return STATUS_SUCCESS;
1450 
1451 }
1452 
NTSTATUS NTAPI CdRomGetConfiguration(IN PDEVICE_OBJECT Fdo, OUT PGET_CONFIGURATION_HEADER *Buffer, OUT PULONG BytesReturned, IN FEATURE_NUMBER StartingFeature, IN ULONG RequestedType)
Definition: mmc.c:292
KEVENT CapabilitiesEvent
Definition: cdrom.h:135
_Must_inspect_result_ typedef _In_ PVOID Unused
Definition: iotypes.h:1129
#define IN
Definition: typedefs.h:38
PMDL CapabilitiesMdl
Definition: cdrom.h:132
#define STATUS_NO_MEDIA_IN_DEVICE
Definition: udferr_usr.h:141
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI CdRompGetConfiguration(IN PDEVICE_OBJECT Fdo, IN PGET_CONFIGURATION_HEADER Buffer, IN ULONG BufferSize, OUT PULONG ValidBytes, IN FEATURE_NUMBER StartingFeature, IN ULONG RequestedType)
Definition: mmc.c:205
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
VOID NTAPI CdRomDeAllocateMmcResources(IN PDEVICE_OBJECT Fdo)
Definition: mmc.c:1335
ULONG SrbFlags
Definition: srb.h:252
PVOID OriginalRequest
Definition: srb.h:258
UCHAR Cdb[16]
Definition: srb.h:271
#define CDROM_NON_MMC_DRIVE_NAME
Definition: cdrom.h:352
#define STATUS_DATA_OVERRUN
Definition: udferr_usr.h:152
Definition: ntbasedef.h:635
#define ExInterlockedFlushSList(SListHead)
Definition: exfuncs.h:169
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
#define TEST_FLAG(Flags, Bit)
Definition: classpnp.h:156
_In_ PIRP Irp
Definition: csq.h:116
#define SRB_FLAGS_NO_QUEUE_FREEZE
Definition: srb.h:396
PVOID DataBuffer
Definition: srb.h:255
#define CDROM_SUBKEY_NAME
Definition: cdrom.h:350
#define CDROM_GET_CONFIGURATION_TIMEOUT
Definition: cdrom.h:54
#define CdromMmcUpdateStarted
Definition: cdrom.h:118
struct _CDB::_GET_CONFIGURATION GET_CONFIGURATION
unsigned char * PUCHAR
Definition: retypes.h:3
ULONG DataTransferLength
Definition: srb.h:253
VOID NTAPI MmBuildMdlForNonPagedPool(IN PMDL Mdl)
Definition: mdlsup.c:428
Definition: cdrw_hw.h:28
LONG NTSTATUS
Definition: precomp.h:26
COMMON_DEVICE_EXTENSION CommonExtension
Definition: classpnp.h:695
struct _FEATURE_HEADER * PFEATURE_HEADER
PVOID NTAPI CdRomFindFeaturePage(IN PGET_CONFIGURATION_HEADER FeatureBuffer, IN ULONG Length, IN FEATURE_NUMBER Feature)
Definition: mmc.c:115
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define InterlockedCompareExchange
Definition: interlocked.h:104
UCHAR CdbLength
Definition: srb.h:250
GLuint buffer
Definition: glext.h:5915
PIO_WORKITEM CapabilitiesWorkItem
Definition: cdrom.h:130
VOID NTAPI CdRomFindProfileInProfiles(IN PFEATURE_DATA_PROFILE_LIST ProfileHeader, IN FEATURE_PROFILE_TYPE ProfileToFind, OUT PBOOLEAN Found)
Definition: mmc.c:69
IRP
Definition: iotypes.h:2463
struct _SCSI_REQUEST_BLOCK * NextSrb
Definition: srb.h:257
UCHAR QueueAction
Definition: srb.h:249
#define SRB_FLAGS_DATA_IN
Definition: srb.h:392
#define STATUS_VERIFY_REQUIRED
Definition: udferr_usr.h:130
PIO_WORKITEM NTAPI IoAllocateWorkItem(IN PDEVICE_OBJECT DeviceObject)
Definition: iowork.c:75
ULONG TimeOutValue
Definition: srb.h:254
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
enum _FEATURE_PROFILE_TYPE FEATURE_PROFILE_TYPE
UCHAR SrbStatus
Definition: srb.h:243
VOID NTAPI IoFreeWorkItem(IN PIO_WORKITEM IoWorkItem)
Definition: iowork.c:64
#define SRB_STATUS(Status)
Definition: srb.h:381
#define SENSE_BUFFER_SIZE
Definition: cdrw_hw.h:1183
#define PAGED_CODE()
Definition: video.h:57
GLint limit
Definition: glext.h:10326
#define KdPrintEx(_x_)
Definition: kdfuncs.h:114
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define IRP_MJ_SCSI
#define STATUS_IO_DEVICE_ERROR
Definition: udferr_usr.h:179
#define SCSI_GET_CONFIGURATION_REQUEST_TYPE_CURRENT
Definition: ntddmmc.h:16
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:451
NTSTATUS NTAPI CdRomUpdateMmcDriveCapabilitiesCompletion(IN PDEVICE_OBJECT Unused, IN PIRP Irp, IN PDEVICE_OBJECT Fdo)
Definition: mmc.c:850
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
NTSTATUS NTAPI ClassSetDeviceParameter(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PWSTR SubkeyName OPTIONAL, IN PWSTR ParameterName, IN ULONG ParameterValue)
Definition: utils.c:136
ULONG_PTR HackFlags
Definition: cdrom.h:163
long LONG
Definition: pedump.c:60
UCHAR ScsiStatus
Definition: srb.h:244
SCSI_REQUEST_BLOCK CapabilitiesSrb
Definition: cdrom.h:136
#define CDROM_HACK_BAD_GET_CONFIG_SUPPORT
Definition: cdrom.h:64
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
VOID NTAPI IoStartPacket(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PULONG Key, IN PDRIVER_CANCEL CancelFunction)
Definition: device.c:1876
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
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
struct _CDROM_DATA * PCDROM_DATA
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI CdRomPrepareUpdateCapabilitiesIrp(PDEVICE_OBJECT Fdo)
Definition: mmc.c:978
union _CDB * PCDB
#define IoCompleteRequest
Definition: irp.c:1240
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1780
NTSTATUS NTAPI CdRomAllocateMmcResources(IN PDEVICE_OBJECT Fdo)
Definition: mmc.c:1369
VOID NTAPI CdRompFlushDelayedList(IN PDEVICE_OBJECT Fdo, IN PCDROM_MMC_EXTENSION MmcData, IN NTSTATUS Status, IN BOOLEAN CalledFromWorkItem)
Definition: mmc.c:1229
Definition: bufpool.h:45
return Found
Definition: dirsup.c:1270
void * PVOID
Definition: retypes.h:9
VOID NTAPI ClassGetDeviceParameter(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PWSTR SubkeyName OPTIONAL, IN PWSTR ParameterName, IN OUT PULONG ParameterValue)
Definition: utils.c:52
#define MAXIMUM_RETRIES
Definition: class2.h:14
#define UlongToPtr(u)
Definition: config.h:106
#define PtrToUlong(u)
Definition: config.h:107
UCHAR Current
Definition: ntddmmc.h:30
int64_t LONGLONG
Definition: typedefs.h:66
GLsizeiptr size
Definition: glext.h:5919
NTSTATUS NTAPI ClassSendSrbSynchronous(PDEVICE_OBJECT Fdo, PSCSI_REQUEST_BLOCK Srb, PVOID BufferAddress, ULONG BufferLength, BOOLEAN WriteToDevice)
Definition: class.c:2648
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG WriteAllowed
Definition: cdrom.h:123
UCHAR Function
Definition: srb.h:242
#define BufferSize
Definition: classpnp.h:419
#define PSLIST_ENTRY
Definition: rtltypes.h:130
USHORT Length
Definition: srb.h:241
FORCEINLINE USHORT ExQueryDepthSList(_In_ PSLIST_HEADER SListHead)
Definition: exfuncs.h:153
VOID NTAPI ClassReleaseQueue(IN PDEVICE_OBJECT Fdo)
Definition: class.c:8160
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
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
struct _FEATURE_HEADER FEATURE_HEADER
unsigned char UCHAR
Definition: xmlstorage.h:181
char * PBOOLEAN
Definition: retypes.h:11
NTSTATUS NTAPI CdRomRetryRequest(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PIRP Irp, IN ULONG Delay, IN BOOLEAN ResendIrp)
Definition: cdrom.c:6371
#define SRB_STATUS_QUEUE_FROZEN
Definition: srb.h:378
void delay(unsigned msec)
Definition: i386rtl.c:32
#define SCSI_GET_CONFIGURATION_REQUEST_TYPE_ALL
Definition: ntddmmc.h:15
VOID NTAPI CdRomUpdateMmcDriveCapabilities(IN PDEVICE_OBJECT Fdo, IN PVOID Context)
Definition: mmc.c:1073
ULONG CapabilitiesBufferSize
Definition: cdrom.h:134
Definition: _list.h:228
#define CdromMmcUpdateComplete
Definition: cdrom.h:116
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
NTSTATUS FASTCALL IoReadPartitionTable(IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize, IN BOOLEAN ReturnRecognizedPartitions, OUT PDRIVE_LAYOUT_INFORMATION *PartitionBuffer)
Definition: partition.c:495
#define SET_FLAG(Flags, Bit)
Definition: classpnp.h:154
enum _FEATURE_NUMBER FEATURE_NUMBER
Status
Definition: gdiplustypes.h:24
PMDL NTAPI IoAllocateMdl(IN PVOID VirtualAddress, IN ULONG Length, IN BOOLEAN SecondaryBuffer, IN BOOLEAN ChargeQuota, IN PIRP Irp)
Definition: iomdl.c:22
SLIST_HEADER DelayedIrps
Definition: cdrom.h:127
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
ULONG_PTR SIZE_T
Definition: typedefs.h:78
UCHAR SenseInfoBufferLength
Definition: srb.h:251
#define IO_CD_ROM_INCREMENT
Definition: iotypes.h:567
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
static calc_node_t temp
Definition: rpn_ieee.c:38
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
_In_ FILTER_INFORMATION_CLASS _In_ ULONG _Out_ PULONG BytesReturned
Definition: fltkernel.h:1716
#define list
Definition: rosglue.h:35
#define SRB_SIMPLE_TAG_REQUEST
Definition: srb.h:415
#define SCSI_REQUEST_BLOCK_SIZE
Definition: srb.h:274
unsigned int * PULONG
Definition: retypes.h:1
PDEVICE_OBJECT LowerDeviceObject
Definition: classpnp.h:574
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define SCSIOP_GET_CONFIGURATION
Definition: cdrw_hw.h:930
IO_COMPLETION_ROUTINE * PIO_COMPLETION_ROUTINE
Definition: iotypes.h:2480
#define STATUS_IO_TIMEOUT
Definition: udferr_usr.h:163
#define CdromMmcUpdateRequired
Definition: cdrom.h:117
CDROM_MMC_EXTENSION Mmc
Definition: cdrom.h:157
KSPIN_LOCK DelayedLock
Definition: cdrom.h:128
PVOID SenseInfoBuffer
Definition: srb.h:256
#define OUT
Definition: typedefs.h:39
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
#define ExInitializeSListHead
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:307
PVOID PIRP
Definition: usb.h:38
unsigned int ULONG
Definition: retypes.h:1
struct _GET_CONFIGURATION_HEADER * PGET_CONFIGURATION_HEADER
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define SRB_STATUS_SUCCESS
Definition: srb.h:333
#define profile
Definition: kernel32.h:12
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
Definition: irp.c:615
PGET_CONFIGURATION_HEADER CapabilitiesBuffer
Definition: cdrom.h:133
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
PIRP CapabilitiesIrp
Definition: cdrom.h:131
return STATUS_SUCCESS
Definition: btrfs.c:2938
static SERVICE_STATUS status
Definition: service.c:31
FORCEINLINE VOID IoSetNextIrpStackLocation(_Inout_ PIRP Irp)
Definition: iofuncs.h:2632
struct CFHEADER header
Definition: fdi.c:101
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define CDROM_TAG_FEATURE
Definition: cdrom.h:323
VOID NTAPI ClassReleaseRemoveLock(IN PDEVICE_OBJECT DeviceObject, IN OPTIONAL PIRP Tag)
Definition: lock.c:212
VOID NTAPI CdRompPrintAllFeaturePages(IN PGET_CONFIGURATION_HEADER Buffer, IN ULONG Usable)
Definition: mmc.c:553
VOID NTAPI CdRomIsDeviceMmcDevice(IN PDEVICE_OBJECT Fdo, OUT PBOOLEAN IsMmc)
Definition: mmc.c:424
Definition: ps.c:97