431{
436 ULONG DiskByteOffset;
442
444
445 TRACE_(FLOPPY,
"ReadWritePassive called to %s 0x%x bytes from offset 0x%x\n",
449 Stack->Parameters.Write.ByteOffset.u.LowPart));
450
451
453 Irp->IoStatus.Information = 0;
454
455
456
457
458
460 {
461 INFO_(FLOPPY,
"ReadWritePassive(): DO_VERIFY_VOLUME set; Completing with STATUS_VERIFY_REQUIRED\n");
464 return;
465 }
466
467
468
469
472 {
473 WARN_(FLOPPY,
"ReadWritePassive(): unable to detect disk change; Completing with STATUS_UNSUCCESSFUL\n");
476 return;
477 }
478
479 if(DiskChanged)
480 {
481 INFO_(FLOPPY,
"ReadWritePhase1(): detected disk changed: signalling media change and completing\n");
482
483
486
489 return;
490 }
491
492
493
494
496 {
498 {
499 WARN_(FLOPPY,
"ReadWritePassive(): unable to determine media type; completing with STATUS_UNSUCCESSFUL\n");
502 return;
503 }
504
506 {
507 WARN_(FLOPPY,
"ReadWritePassive(): Unknown media in drive; completing with STATUS_UNRECOGNIZED_MEDIA\n");
511 return;
512 }
513 }
514
515
517 {
519 DiskByteOffset =
Stack->Parameters.Read.ByteOffset.u.LowPart;
521 }
522 else
523 {
525 DiskByteOffset =
Stack->Parameters.Write.ByteOffset.u.LowPart;
527 }
528
529
530
531
532
533
534
535
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
604
606 {
607 WARN_(FLOPPY,
"ReadWritePassive(): unable allocate an adapter channel; completing with STATUS_UNSUCCESSFUL\n");
611 }
612
613
614
615
616
617
618
619
620 TransferByteOffset = 0;
621 while(TransferByteOffset <
Length)
622 {
626 ULONG CurrentTransferBytes;
627 UCHAR CurrentTransferSectors;
628
629 INFO_(FLOPPY,
"ReadWritePassive(): iterating in while (TransferByteOffset = 0x%x of 0x%x total) - allocating %d registers\n",
631
633
634
635
636
638 {
639 WARN_(FLOPPY,
"ReadWritePassive(): unable to compute CHS; completing with STATUS_UNSUCCESSFUL\n");
643 return;
644 }
645
646
647
648
650 {
652 {
653 WARN_(FLOPPY,
"ReadWritePassive(): unable to seek; completing with STATUS_UNSUCCESSFUL\n");
658 }
659 }
660
661
662
663
664
665
666
667 INFO_(FLOPPY,
"ReadWritePassive(): computing number of sectors to transfer (StartSector 0x%x): ", StartSector);
668
669
672 {
674 }
675 else
676 {
678 }
679
680 INFO_(FLOPPY,
"0x%x\n", CurrentTransferSectors);
681
683
684
685
686
687
688 INFO_(FLOPPY,
"ReadWritePassive(): Trying to transfer 0x%x bytes\n", CurrentTransferBytes);
689
690 ASSERT(CurrentTransferBytes);
691
693 {
696
698
699 INFO_(FLOPPY,
"ReadWritePassive: limiting transfer to 0x%x bytes (0x%x sectors) due to map registers\n",
700 CurrentTransferBytes, CurrentTransferSectors);
701 }
702
703
704
706
711
712
713
714
716
717
720 {
721 WARN_(FLOPPY,
"ReadWritePassive(): HwReadWriteData returned failure; unable to read; completing with STATUS_UNSUCCESSFUL\n");
726 }
727
728 INFO_(FLOPPY,
"ReadWritePassive(): HwReadWriteData returned -- waiting on event\n");
729
730
731
732
733
735
736
741
742
744 {
745 WARN_(FLOPPY,
"ReadWritePassive(): HwReadWriteResult returned failure; unable to read; completing with STATUS_UNSUCCESSFUL\n");
751 }
752
753 TransferByteOffset += CurrentTransferBytes;
754 }
755
757
758
759 INFO_(FLOPPY,
"ReadWritePassive(): success; Completing with STATUS_SUCCESS\n");
764}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
_In_ PSCSI_REQUEST_BLOCK _In_opt_ PVOID _In_ ULONG _In_ BOOLEAN WriteToDevice
NTSTATUS NTAPI HwReadWriteResult(PCONTROLLER_INFO ControllerInfo)
VOID NTAPI HwDumpRegisters(PCONTROLLER_INFO ControllerInfo)
NTSTATUS NTAPI HwReadWriteData(PCONTROLLER_INFO ControllerInfo, BOOLEAN Read, UCHAR Unit, UCHAR Cylinder, UCHAR Head, UCHAR Sector, UCHAR BytesPerSector, UCHAR EndOfTrack, UCHAR Gap3Length, UCHAR DataLength)
NTSTATUS NTAPI HwDiskChanged(PDRIVE_INFO DriveInfo, PBOOLEAN DiskChanged)
static IO_ALLOCATION_ACTION NTAPI MapRegisterCallback(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID MapRegisterBase, PVOID Context)
static NTSTATUS NTAPI RWComputeCHS(PDRIVE_INFO IN DriveInfo, ULONG IN DiskByteOffset, PUCHAR OUT Cylinder, PUCHAR OUT Head, PUCHAR OUT Sector)
static VOID NTAPI RWFreeAdapterChannel(PADAPTER_OBJECT AdapterObject)
NTSTATUS NTAPI RWDetermineMediaType(PDRIVE_INFO DriveInfo, BOOLEAN OneShot)
static NTSTATUS NTAPI RWSeekToCylinder(PDRIVE_INFO DriveInfo, UCHAR Cylinder)
#define KeRaiseIrql(irql, oldIrql)
#define KeLowerIrql(oldIrql)
VOID NTAPI KeClearEvent(IN PKEVENT Event)
NTSTATUS NTAPI WaitForControllerInterrupt(PCONTROLLER_INFO ControllerInfo, PLARGE_INTEGER Timeout)
NTSTATUS NTAPI ResetChangeFlag(PDRIVE_INFO DriveInfo)
VOID NTAPI SignalMediaChanged(PDEVICE_OBJECT DeviceObject, PIRP Irp)
VOID NTAPI StartMotor(PDRIVE_INFO DriveInfo)
VOID NTAPI StopMotor(PCONTROLLER_INFO ControllerInfo)
BOOLEAN NTAPI IoFlushAdapterBuffers(IN PADAPTER_OBJECT AdapterObject, IN PMDL Mdl, IN PVOID MapRegisterBase, IN PVOID CurrentVa, IN ULONG Length, IN BOOLEAN WriteToDevice)
PHYSICAL_ADDRESS NTAPI IoMapTransfer(IN PADAPTER_OBJECT AdapterObject, IN PMDL Mdl, IN PVOID MapRegisterBase, IN PVOID CurrentVa, IN OUT PULONG Length, IN BOOLEAN WriteToDevice)
_In_ ULONG _In_ ULONG _In_ ULONG Length
NTSTATUS NTAPI IoAllocateAdapterChannel(IN PADAPTER_OBJECT AdapterObject, IN PDEVICE_OBJECT DeviceObject, IN ULONG NumberOfMapRegisters, IN PDRIVER_CONTROL ExecutionRoutine, IN PVOID Context)
#define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation)
struct _CONTROLLER_INFO * ControllerInfo
PDEVICE_OBJECT DeviceObject
CM_FLOPPY_DEVICE_DATA FloppyDeviceData
DISK_GEOMETRY DiskGeometry
#define STATUS_UNRECOGNIZED_MEDIA
#define STATUS_UNSUCCESSFUL
#define STATUS_VERIFY_REQUIRED
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
#define SL_OVERRIDE_VERIFY_VOLUME
#define IO_DISK_INCREMENT
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
#define MmGetMdlVirtualAddress(_Mdl)
#define BYTES_TO_PAGES(Size)