ReactOS 0.4.16-dev-91-g764881a
hardware.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for hardware.c:

Go to the source code of this file.

Functions

static BOOLEAN NTAPI ReadyForWrite (PCONTROLLER_INFO ControllerInfo)
 
static BOOLEAN NTAPI ReadyForRead (PCONTROLLER_INFO ControllerInfo)
 
static NTSTATUS NTAPI Send_Byte (PCONTROLLER_INFO ControllerInfo, UCHAR Byte)
 
static NTSTATUS NTAPI Get_Byte (PCONTROLLER_INFO ControllerInfo, PUCHAR Byte)
 
NTSTATUS NTAPI HwSetDataRate (PCONTROLLER_INFO ControllerInfo, UCHAR DataRate)
 
NTSTATUS NTAPI HwTurnOffMotor (PCONTROLLER_INFO ControllerInfo)
 
NTSTATUS NTAPI HwTurnOnMotor (PDRIVE_INFO DriveInfo)
 
NTSTATUS NTAPI HwSenseDriveStatus (PDRIVE_INFO DriveInfo)
 
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 HwRecalibrateResult (PCONTROLLER_INFO ControllerInfo)
 
NTSTATUS NTAPI HwReadWriteResult (PCONTROLLER_INFO ControllerInfo)
 
NTSTATUS NTAPI HwRecalibrate (PDRIVE_INFO DriveInfo)
 
NTSTATUS NTAPI HwSenseInterruptStatus (PCONTROLLER_INFO ControllerInfo)
 
NTSTATUS NTAPI HwReadId (PDRIVE_INFO DriveInfo, UCHAR Head)
 
NTSTATUS NTAPI HwFormatTrack (PCONTROLLER_INFO ControllerInfo, UCHAR Unit, UCHAR Head, UCHAR BytesPerSector, UCHAR SectorsPerTrack, UCHAR Gap3Length, UCHAR FillerPattern)
 
NTSTATUS NTAPI HwSeek (PDRIVE_INFO DriveInfo, UCHAR Cylinder)
 
NTSTATUS NTAPI HwConfigure (PCONTROLLER_INFO ControllerInfo, BOOLEAN EIS, BOOLEAN EFIFO, BOOLEAN POLL, UCHAR FIFOTHR, UCHAR PRETRK)
 
NTSTATUS NTAPI HwGetVersion (PCONTROLLER_INFO ControllerInfo)
 
NTSTATUS NTAPI HwDiskChanged (PDRIVE_INFO DriveInfo, PBOOLEAN DiskChanged)
 
NTSTATUS NTAPI HwSenseDriveStatusResult (PCONTROLLER_INFO ControllerInfo, PUCHAR Status)
 
NTSTATUS NTAPI HwReadIdResult (PCONTROLLER_INFO ControllerInfo, PUCHAR CurCylinder, PUCHAR CurHead)
 
NTSTATUS NTAPI HwSpecify (PCONTROLLER_INFO ControllerInfo, UCHAR HeadLoadTime, UCHAR HeadUnloadTime, UCHAR StepRateTime, BOOLEAN NonDma)
 
NTSTATUS NTAPI HwReset (PCONTROLLER_INFO ControllerInfo)
 
NTSTATUS NTAPI HwPowerOff (PCONTROLLER_INFO ControllerInfo)
 
VOID NTAPI HwDumpRegisters (PCONTROLLER_INFO ControllerInfo)
 

Function Documentation

◆ Get_Byte()

static NTSTATUS NTAPI Get_Byte ( PCONTROLLER_INFO  ControllerInfo,
PUCHAR  Byte 
)
static

Definition at line 158 of file hardware.c.

176{
177 int i;
178
179 PAGED_CODE();
180
181 for(i = 0; i < 5; i++)
182 {
183 if(ReadyForRead(ControllerInfo))
184 break;
185
187 }
188
189 if (i < 5)
190 {
191 *Byte = READ_PORT_UCHAR(ControllerInfo->BaseAddress + FIFO);
192 return STATUS_SUCCESS;
193 }
194 else
195 {
196 INFO_(FLOPPY, "Get_Byte: timed out trying to write\n");
197 HwDumpRegisters(ControllerInfo);
198 return STATUS_UNSUCCESSFUL;
199 }
200}
#define PAGED_CODE()
unsigned char Byte
Definition: zlib.h:37
VOID NTAPI HwDumpRegisters(PCONTROLLER_INFO ControllerInfo)
Definition: hardware.c:1029
static BOOLEAN NTAPI ReadyForRead(PCONTROLLER_INFO ControllerInfo)
Definition: hardware.c:85
#define FIFO
Definition: hardware.h:49
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
#define KeStallExecutionProcessor(MicroSeconds)
Definition: precomp.h:27
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22
#define INFO_(ch,...)
Definition: debug.h:159
#define STATUS_SUCCESS
Definition: shellext.h:65
PUCHAR BaseAddress
Definition: fdc.h:49
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

Referenced by HwGetVersion(), HwReadIdResult(), HwReadWriteResult(), HwRecalibrateResult(), HwSenseDriveStatusResult(), and HwSenseInterruptStatus().

◆ HwConfigure()

NTSTATUS NTAPI HwConfigure ( PCONTROLLER_INFO  ControllerInfo,
BOOLEAN  EIS,
BOOLEAN  EFIFO,
BOOLEAN  POLL,
UCHAR  FIFOTHR,
UCHAR  PRETRK 
)

Definition at line 703 of file hardware.c.

724{
725 UCHAR Buffer[4];
726 int i;
727
728 TRACE_(FLOPPY, "HwConfigure called\n");
729
730 PAGED_CODE();
731
733 Buffer[1] = 0;
734 Buffer[2] = (EIS * CONFIGURE_EIS) + (EFIFO * CONFIGURE_EFIFO) + (POLL * CONFIGURE_POLL) + (FIFOTHR);
735 Buffer[3] = PRETRK;
736
737 for(i = 0; i < 4; i++)
738 if(Send_Byte(ControllerInfo, Buffer[i]) != STATUS_SUCCESS)
739 {
740 WARN_(FLOPPY, "HwConfigure: failed to write the fifo\n");
741 return STATUS_UNSUCCESSFUL;
742 }
743
744 return STATUS_SUCCESS;
745}
Definition: bufpool.h:45
#define TRACE_(x)
Definition: compat.h:76
static NTSTATUS NTAPI Send_Byte(PCONTROLLER_INFO ControllerInfo, UCHAR Byte)
Definition: hardware.c:111
#define CONFIGURE_POLL
Definition: hardware.h:247
#define CONFIGURE_EIS
Definition: hardware.h:249
#define CONFIGURE_EFIFO
Definition: hardware.h:248
#define COMMAND_CONFIGURE
Definition: hardware.h:202
#define WARN_(ch,...)
Definition: debug.h:157
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by InitController().

◆ HwDiskChanged()

NTSTATUS NTAPI HwDiskChanged ( PDRIVE_INFO  DriveInfo,
PBOOLEAN  DiskChanged 
)

Definition at line 785 of file hardware.c.

797{
799 PCONTROLLER_INFO ControllerInfo = (PCONTROLLER_INFO) DriveInfo->ControllerInfo;
800
802
803 TRACE_(FLOPPY, "HwDiskChanged: read 0x%x from DIR\n", Buffer);
804
805 if(ControllerInfo->Model30)
806 {
808 {
809 INFO_(FLOPPY, "HdDiskChanged - Model30 - returning TRUE\n");
810 *DiskChanged = TRUE;
811 }
812 else
813 {
814 INFO_(FLOPPY, "HdDiskChanged - Model30 - returning FALSE\n");
815 *DiskChanged = FALSE;
816 }
817 }
818 else
819 {
821 {
822 INFO_(FLOPPY, "HdDiskChanged - PS2 - returning TRUE\n");
823 *DiskChanged = TRUE;
824 }
825 else
826 {
827 INFO_(FLOPPY, "HdDiskChanged - PS2 - returning FALSE\n");
828 *DiskChanged = FALSE;
829 }
830 }
831
832 return STATUS_SUCCESS;
833}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
struct _CONTROLLER_INFO * PCONTROLLER_INFO
#define DIGITAL_INPUT_REGISTER
Definition: hardware.h:51
#define DIR_DISKETTE_CHANGE
Definition: hardware.h:176
BOOLEAN Model30
Definition: floppy.h:82
struct _CONTROLLER_INFO * ControllerInfo
Definition: fdc.h:23

Referenced by DeviceIoctlPassive(), ReadWritePassive(), and ResetChangeFlag().

◆ HwDumpRegisters()

VOID NTAPI HwDumpRegisters ( PCONTROLLER_INFO  ControllerInfo)

Definition at line 1029 of file hardware.c.

1035{
1036 UNREFERENCED_PARAMETER(ControllerInfo);
1037
1038 INFO_(FLOPPY, "STATUS:\n");
1039 INFO_(FLOPPY, "STATUS_REGISTER_A = 0x%x\n", READ_PORT_UCHAR(ControllerInfo->BaseAddress + STATUS_REGISTER_A));
1040 INFO_(FLOPPY, "STATUS_REGISTER_B = 0x%x\n", READ_PORT_UCHAR(ControllerInfo->BaseAddress + STATUS_REGISTER_B));
1041 INFO_(FLOPPY, "DIGITAL_OUTPUT_REGISTER = 0x%x\n", READ_PORT_UCHAR(ControllerInfo->BaseAddress + DIGITAL_OUTPUT_REGISTER));
1042 INFO_(FLOPPY, "MAIN_STATUS_REGISTER =0x%x\n", READ_PORT_UCHAR(ControllerInfo->BaseAddress + MAIN_STATUS_REGISTER));
1043 INFO_(FLOPPY, "DIGITAL_INPUT_REGISTER = 0x%x\n", READ_PORT_UCHAR(ControllerInfo->BaseAddress + DIGITAL_INPUT_REGISTER));
1044}
#define STATUS_REGISTER_B
Definition: hardware.h:44
#define STATUS_REGISTER_A
Definition: hardware.h:43
#define DIGITAL_OUTPUT_REGISTER
Definition: hardware.h:45
#define MAIN_STATUS_REGISTER
Definition: hardware.h:47
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317

Referenced by Get_Byte(), HwReset(), ReadWritePassive(), and Send_Byte().

◆ HwFormatTrack()

NTSTATUS NTAPI HwFormatTrack ( PCONTROLLER_INFO  ControllerInfo,
UCHAR  Unit,
UCHAR  Head,
UCHAR  BytesPerSector,
UCHAR  SectorsPerTrack,
UCHAR  Gap3Length,
UCHAR  FillerPattern 
)

Definition at line 611 of file hardware.c.

632{
633 UCHAR Buffer[6];
634 int i;
635
636 TRACE_(FLOPPY, "HwFormatTrack called\n");
637
638 PAGED_CODE();
639
641 Buffer[1] = (Head << COMMAND_HEAD_NUMBER_SHIFT) | Unit;
642 Buffer[2] = BytesPerSector;
644 Buffer[4] = Gap3Length;
645 Buffer[5] = FillerPattern;
646
647 for(i = 0; i < 6; i++)
648 if(Send_Byte(ControllerInfo, Buffer[i]) != STATUS_SUCCESS)
649 {
650 WARN_(FLOPPY, "HwFormatTrack: unable to send bytes to floppy\n");
651 return STATUS_UNSUCCESSFUL;
652 }
653
654 return STATUS_SUCCESS;
655}
#define COMMAND_FORMAT_TRACK
Definition: hardware.h:198
#define COMMAND_HEAD_NUMBER_SHIFT
Definition: hardware.h:236
Unit
Definition: gdiplusenums.h:26
_In_ ULONG _In_ ULONG SectorsPerTrack
Definition: iofuncs.h:2071

◆ HwGetVersion()

NTSTATUS NTAPI HwGetVersion ( PCONTROLLER_INFO  ControllerInfo)

Definition at line 749 of file hardware.c.

762{
764
765 PAGED_CODE();
766
767 if(Send_Byte(ControllerInfo, COMMAND_VERSION) != STATUS_SUCCESS)
768 {
769 WARN_(FLOPPY, "HwGetVersion: unable to write fifo\n");
770 return STATUS_UNSUCCESSFUL;
771 }
772
773 if(Get_Byte(ControllerInfo, &Buffer) != STATUS_SUCCESS)
774 {
775 WARN_(FLOPPY, "HwGetVersion: unable to write fifo\n");
776 return STATUS_UNSUCCESSFUL;
777 }
778
779 INFO_(FLOPPY, "HwGetVersion returning version 0x%x\n", Buffer);
780
781 return Buffer;
782}
static NTSTATUS NTAPI Get_Byte(PCONTROLLER_INFO ControllerInfo, PUCHAR Byte)
Definition: hardware.c:158
#define COMMAND_VERSION
Definition: hardware.h:200

Referenced by InitController().

◆ HwPowerOff()

NTSTATUS NTAPI HwPowerOff ( PCONTROLLER_INFO  ControllerInfo)

Definition at line 1010 of file hardware.c.

1020{
1021 TRACE_(FLOPPY, "HwPowerOff called on controller 0x%p\n", ControllerInfo);
1022
1024
1025 return STATUS_SUCCESS;
1026}
#define DRSR_POWER_DOWN
Definition: hardware.h:102
#define DATA_RATE_SELECT_REGISTER
Definition: hardware.h:48
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21

Referenced by Unload().

◆ HwReadId()

NTSTATUS NTAPI HwReadId ( PDRIVE_INFO  DriveInfo,
UCHAR  Head 
)

Definition at line 576 of file hardware.c.

588{
589 UCHAR Buffer[2];
590 int i;
591
592 TRACE_(FLOPPY, "HwReadId called\n");
593
594 PAGED_CODE();
595
597 Buffer[1] = (Head << COMMAND_HEAD_NUMBER_SHIFT) | DriveInfo->UnitNumber;
598
599 for(i = 0; i < 2; i++)
600 if(Send_Byte(DriveInfo->ControllerInfo, Buffer[i]) != STATUS_SUCCESS)
601 {
602 WARN_(FLOPPY, "HwReadId: unable to send bytes to fifo\n");
603 return STATUS_UNSUCCESSFUL;
604 }
605
606 return STATUS_SUCCESS;
607}
#define COMMAND_READ_ID
Definition: hardware.h:196
#define READ_ID_MFM
Definition: hardware.h:215
UCHAR UnitNumber
Definition: fdc.h:24

Referenced by RWDetermineMediaType(), and RWSeekToCylinder().

◆ HwReadIdResult()

NTSTATUS NTAPI HwReadIdResult ( PCONTROLLER_INFO  ControllerInfo,
PUCHAR  CurCylinder,
PUCHAR  CurHead 
)

Definition at line 864 of file hardware.c.

883{
884 UCHAR Buffer[7] = {0,0,0,0,0,0,0};
885 int i;
886
887 PAGED_CODE();
888
889 for(i = 0; i < 7; i++)
890 if(Get_Byte(ControllerInfo, &Buffer[i]) != STATUS_SUCCESS)
891 {
892 WARN_(FLOPPY, "ReadIdResult(): can't read from the controller\n");
893 return STATUS_UNSUCCESSFUL;
894 }
895
896 /* Validate that it did what we told it to */
897 INFO_(FLOPPY, "ReadId results: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", Buffer[0], Buffer[1], Buffer[2], Buffer[3],
898 Buffer[4], Buffer[5], Buffer[6]);
899
900 /* Last command successful? */
902 {
903 WARN_(FLOPPY, "ReadId didn't return last command success\n");
904 return STATUS_UNSUCCESSFUL;
905 }
906
907 /* ID mark found? */
909 {
910 WARN_(FLOPPY, "ReadId didn't find an address mark\n");
911 return STATUS_UNSUCCESSFUL;
912 }
913
914 if(CurCylinder)
915 *CurCylinder = Buffer[3];
916
917 if(CurHead)
918 *CurHead = Buffer[4];
919
920 return STATUS_SUCCESS;
921}
#define SR0_LCS_SUCCESS
Definition: hardware.h:133
#define SR0_LAST_COMMAND_STATUS
Definition: hardware.h:118
#define SR1_CANNOT_FIND_ID_ADDRESS
Definition: hardware.h:139

Referenced by RWDetermineMediaType(), and RWSeekToCylinder().

◆ HwReadWriteData()

NTSTATUS NTAPI HwReadWriteData ( PCONTROLLER_INFO  ControllerInfo,
BOOLEAN  Read,
UCHAR  Unit,
UCHAR  Cylinder,
UCHAR  Head,
UCHAR  Sector,
UCHAR  BytesPerSector,
UCHAR  EndOfTrack,
UCHAR  Gap3Length,
UCHAR  DataLength 
)

Definition at line 322 of file hardware.c.

351{
352 UCHAR Buffer[9];
353 int i;
354
355 PAGED_CODE();
356
357 /* Shouldn't be using DataLength in this driver */
358 ASSERT(DataLength == 0xff);
359
360 /* Build the command to send */
361 if(Read)
363 else
365
367
368 Buffer[1] = (Head << COMMAND_HEAD_NUMBER_SHIFT) | Unit;
369 Buffer[2] = Cylinder;
370 Buffer[3] = Head;
371 Buffer[4] = Sector;
372 Buffer[5] = BytesPerSector;
373 Buffer[6] = EndOfTrack;
374 Buffer[7] = Gap3Length;
375 Buffer[8] = DataLength;
376
377 /* Send the command */
378 for(i = 0; i < 9; i++)
379 {
380 INFO_(FLOPPY, "HwReadWriteData: Sending a command byte to the FIFO: 0x%x\n", Buffer[i]);
381
382 if(Send_Byte(ControllerInfo, Buffer[i]) != STATUS_SUCCESS)
383 {
384 WARN_(FLOPPY, "HwReadWriteData: Unable to write to the FIFO\n");
385 return STATUS_UNSUCCESSFUL;
386 }
387 }
388
389 return STATUS_SUCCESS;
390}
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1444
#define READ_DATA_MT
Definition: hardware.h:212
#define READ_DATA_MFM
Definition: hardware.h:211
#define COMMAND_WRITE_DATA
Definition: hardware.h:191
#define COMMAND_READ_DATA
Definition: hardware.h:192
#define ASSERT(a)
Definition: mode.c:44
_In_ BOOLEAN Read
Definition: strmini.h:479

Referenced by ReadWritePassive().

◆ HwReadWriteResult()

NTSTATUS NTAPI HwReadWriteResult ( PCONTROLLER_INFO  ControllerInfo)

Definition at line 462 of file hardware.c.

477{
478 UCHAR Buffer[7];
479 int i;
480
481 PAGED_CODE();
482
483 for(i = 0; i < 7; i++)
484 if(Get_Byte(ControllerInfo, &Buffer[i]) != STATUS_SUCCESS)
485 {
486 WARN_(FLOPPY, "HwReadWriteResult: unable to read fifo\n");
487 return STATUS_UNSUCCESSFUL;
488 }
489
490 /* Validate that it did what we told it to */
491 INFO_(FLOPPY, "HwReadWriteResult results: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", Buffer[0], Buffer[1], Buffer[2], Buffer[3],
492 Buffer[4], Buffer[5], Buffer[6]);
493
494 /* Last command successful? */
496 return STATUS_UNSUCCESSFUL;
497
498 return STATUS_SUCCESS;
499}

Referenced by ReadWritePassive().

◆ HwRecalibrate()

NTSTATUS NTAPI HwRecalibrate ( PDRIVE_INFO  DriveInfo)

Definition at line 503 of file hardware.c.

514{
515 PCONTROLLER_INFO ControllerInfo = DriveInfo->ControllerInfo;
516 UCHAR Unit = DriveInfo->UnitNumber;
517 UCHAR Buffer[2];
518 int i;
519
520 TRACE_(FLOPPY, "HwRecalibrate called\n");
521
522 PAGED_CODE();
523
525 Buffer[1] = Unit;
526
527 for(i = 0; i < 2; i++)
528 if(Send_Byte(ControllerInfo, Buffer[i]) != STATUS_SUCCESS)
529 {
530 WARN_(FLOPPY, "HwRecalibrate: unable to write FIFO\n");
531 return STATUS_UNSUCCESSFUL;
532 }
533
534 return STATUS_SUCCESS;
535}
#define COMMAND_RECALIBRATE
Definition: hardware.h:193

Referenced by Recalibrate(), and RWDetermineMediaType().

◆ HwRecalibrateResult()

NTSTATUS NTAPI HwRecalibrateResult ( PCONTROLLER_INFO  ControllerInfo)

Definition at line 394 of file hardware.c.

409{
410 UCHAR Buffer[2];
411 int i;
412
413 PAGED_CODE();
414
416 {
417 WARN_(FLOPPY, "HwRecalibrateResult: Unable to write the controller\n");
418 return STATUS_UNSUCCESSFUL;
419 }
420
421 for(i = 0; i < 2; i++)
422 if(Get_Byte(ControllerInfo, &Buffer[i]) != STATUS_SUCCESS)
423 {
424 WARN_(FLOPPY, "HwRecalibrateResult: unable to read FIFO\n");
425 return STATUS_UNSUCCESSFUL;
426 }
427
428 /* Validate that it did what we told it to */
429 INFO_(FLOPPY, "HwRecalibrateResult results: ST0: 0x%x PCN: 0x%x\n", Buffer[0], Buffer[1]);
430
431 /*
432 * Buffer[0] = ST0
433 * Buffer[1] = PCN
434 */
435
436 /* Is the PCN 0? */
437 if(Buffer[1] != 0)
438 {
439 WARN_(FLOPPY, "HwRecalibrateResult: PCN not 0\n");
440 return STATUS_UNSUCCESSFUL;
441 }
442
443 /* test seek complete */
445 {
446 WARN_(FLOPPY, "HwRecalibrateResult: Failed to complete the seek\n");
447 return STATUS_UNSUCCESSFUL;
448 }
449
450 /* Is the equipment check flag set? Could be no disk in drive... */
452 {
453 WARN_(FLOPPY, "HwRecalibrateResult: Seeked to track 0 successfully, but EC is set; returning failure\n");
454 return STATUS_UNSUCCESSFUL;
455 }
456
457 return STATUS_SUCCESS;
458}
#define COMMAND_SENSE_INTERRUPT_STATUS
Definition: hardware.h:194
#define SR0_EQUIPMENT_CHECK
Definition: hardware.h:116
#define SR0_SEEK_COMPLETE
Definition: hardware.h:117

Referenced by Recalibrate(), and RWDetermineMediaType().

◆ HwReset()

NTSTATUS NTAPI HwReset ( PCONTROLLER_INFO  ControllerInfo)

Definition at line 973 of file hardware.c.

983{
984 TRACE_(FLOPPY, "HwReset called\n");
985
986 /* Write the reset bit in the DRSR */
988
989 /* Check for the reset bit in the DOR and set it if necessary (see Intel doc) */
991 {
992 HwDumpRegisters(ControllerInfo);
993 INFO_(FLOPPY, "HwReset: Setting Enable bit\n");
995 HwDumpRegisters(ControllerInfo);
996
998 {
999 WARN_(FLOPPY, "HwReset: failed to set the DOR enable bit!\n");
1000 HwDumpRegisters(ControllerInfo);
1001 return STATUS_UNSUCCESSFUL;
1002 }
1003 }
1004
1005 return STATUS_SUCCESS;
1006}
#define DRSR_SW_RESET
Definition: hardware.h:103
#define DOR_RESET
Definition: hardware.h:75
#define DOR_DMA_IO_INTERFACE_ENABLE
Definition: hardware.h:76

Referenced by InitController().

◆ HwSeek()

NTSTATUS NTAPI HwSeek ( PDRIVE_INFO  DriveInfo,
UCHAR  Cylinder 
)

Definition at line 659 of file hardware.c.

671{
672 LARGE_INTEGER Delay;
673 UCHAR Buffer[3];
674 int i;
675
676 TRACE_(FLOPPY, "HwSeek called for cyl 0x%x\n", Cylinder);
677
678 PAGED_CODE();
679
680 Buffer[0] = COMMAND_SEEK;
681 Buffer[1] = DriveInfo->UnitNumber;
682 Buffer[2] = Cylinder;
683
684 for(i = 0; i < 3; i++)
685 if(Send_Byte(DriveInfo->ControllerInfo, Buffer[i]) != STATUS_SUCCESS)
686 {
687 WARN_(FLOPPY, "HwSeek: failed to write fifo\n");
688 return STATUS_UNSUCCESSFUL;
689 }
690
691 /* Wait for the head to settle */
692 Delay.QuadPart = 10 * 1000;
693 Delay.QuadPart *= -1;
694 Delay.QuadPart *= DriveInfo->FloppyDeviceData.HeadSettleTime;
695
697
698 return STATUS_SUCCESS;
699}
#define COMMAND_SEEK
Definition: hardware.h:199
#define KeDelayExecutionThread(mode, foo, t)
Definition: env_spec_w32.h:484
#define KernelMode
Definition: asm.h:34
CM_FLOPPY_DEVICE_DATA FloppyDeviceData
Definition: fdc.h:27
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by ResetChangeFlag(), and RWSeekToCylinder().

◆ HwSenseDriveStatus()

NTSTATUS NTAPI HwSenseDriveStatus ( PDRIVE_INFO  DriveInfo)

Definition at line 287 of file hardware.c.

299{
300 UCHAR Buffer[2];
301 int i;
302
303 PAGED_CODE();
304
305 TRACE_(FLOPPY, "HwSenseDriveStatus called\n");
306
308 Buffer[1] = DriveInfo->UnitNumber; /* hard-wired to head 0 for now */
309
310 for(i = 0; i < 2; i++)
311 if(Send_Byte(DriveInfo->ControllerInfo, Buffer[i]) != STATUS_SUCCESS)
312 {
313 WARN_(FLOPPY, "HwSenseDriveStatus: failed to write FIFO\n");
314 return STATUS_UNSUCCESSFUL;
315 }
316
317 return STATUS_SUCCESS;
318}
#define COMMAND_SENSE_DRIVE_STATUS
Definition: hardware.h:190

Referenced by DeviceIoctlPassive().

◆ HwSenseDriveStatusResult()

NTSTATUS NTAPI HwSenseDriveStatusResult ( PCONTROLLER_INFO  ControllerInfo,
PUCHAR  Status 
)

Definition at line 836 of file hardware.c.

848{
849 PAGED_CODE();
850
851 if(Get_Byte(ControllerInfo, Status) != STATUS_SUCCESS)
852 {
853 WARN_(FLOPPY, "HwSenseDriveStatus: unable to read fifo\n");
854 return STATUS_UNSUCCESSFUL;
855 }
856
857 TRACE_(FLOPPY, "HwSenseDriveStatusResult: ST3: 0x%x\n", *Status);
858
859 return STATUS_SUCCESS;
860}
Status
Definition: gdiplustypes.h:25

Referenced by DeviceIoctlPassive().

◆ HwSenseInterruptStatus()

NTSTATUS NTAPI HwSenseInterruptStatus ( PCONTROLLER_INFO  ControllerInfo)

Definition at line 539 of file hardware.c.

548{
549 UCHAR Buffer[2];
550 int i;
551
552 PAGED_CODE();
553
555 {
556 WARN_(FLOPPY, "HwSenseInterruptStatus: failed to write controller\n");
557 return STATUS_UNSUCCESSFUL;
558 }
559
560 for(i = 0; i < 2; i++)
561 {
562 if(Get_Byte(ControllerInfo, &Buffer[i]) != STATUS_SUCCESS)
563 {
564 WARN_(FLOPPY, "HwSenseInterruptStatus: failed to read controller\n");
565 return STATUS_UNSUCCESSFUL;
566 }
567 }
568
569 INFO_(FLOPPY, "HwSenseInterruptStatus returned 0x%x 0x%x\n", Buffer[0], Buffer[1]);
570
571 return STATUS_SUCCESS;
572}

Referenced by InitController(), ResetChangeFlag(), and RWSeekToCylinder().

◆ HwSetDataRate()

NTSTATUS NTAPI HwSetDataRate ( PCONTROLLER_INFO  ControllerInfo,
UCHAR  DataRate 
)

Definition at line 204 of file hardware.c.

213{
214 TRACE_(FLOPPY, "HwSetDataRate called; writing rate code 0x%x to offset 0x%x\n", DataRate, DATA_RATE_SELECT_REGISTER);
215
216 WRITE_PORT_UCHAR(ControllerInfo->BaseAddress + DATA_RATE_SELECT_REGISTER, DataRate);
217
218 return STATUS_SUCCESS;
219}

Referenced by InitController(), Recalibrate(), and RWDetermineMediaType().

◆ HwSpecify()

NTSTATUS NTAPI HwSpecify ( PCONTROLLER_INFO  ControllerInfo,
UCHAR  HeadLoadTime,
UCHAR  HeadUnloadTime,
UCHAR  StepRateTime,
BOOLEAN  NonDma 
)

Definition at line 925 of file hardware.c.

946{
947 UCHAR Buffer[3];
948 int i;
949
951 /*
952 Buffer[1] = (StepRateTime << 4) + HeadUnloadTime;
953 Buffer[2] = (HeadLoadTime << 1) + (NonDma ? 1 : 0);
954 */
955 Buffer[1] = 0xdf;
956 Buffer[2] = 0x2;
957
958 //INFO_(FLOPPY, "HwSpecify: sending 0x%x 0x%x 0x%x to FIFO\n", Buffer[0], Buffer[1], Buffer[2]);
959 WARN_(FLOPPY, "HWSPECIFY: FIXME - sending 0x3 0xd1 0x2 to FIFO\n");
960
961 for(i = 0; i < 3; i++)
962 if(Send_Byte(ControllerInfo, Buffer[i]) != STATUS_SUCCESS)
963 {
964 WARN_(FLOPPY, "HwSpecify: unable to write to controller\n");
965 return STATUS_UNSUCCESSFUL;
966 }
967
968 return STATUS_SUCCESS;
969}
#define COMMAND_SPECIFY
Definition: hardware.h:189

Referenced by InitController(), and RWDetermineMediaType().

◆ HwTurnOffMotor()

NTSTATUS NTAPI HwTurnOffMotor ( PCONTROLLER_INFO  ControllerInfo)

Definition at line 223 of file hardware.c.

235{
236 TRACE_(FLOPPY, "HwTurnOffMotor: writing byte 0x%x to offset 0x%x\n", DOR_FDC_ENABLE|DOR_DMA_IO_INTERFACE_ENABLE, DIGITAL_OUTPUT_REGISTER);
237
239
240 return STATUS_SUCCESS;
241}
#define DOR_FDC_ENABLE
Definition: hardware.h:74

Referenced by MotorStopDpcFunc().

◆ HwTurnOnMotor()

NTSTATUS NTAPI HwTurnOnMotor ( PDRIVE_INFO  DriveInfo)

Definition at line 245 of file hardware.c.

257{
258 PCONTROLLER_INFO ControllerInfo = DriveInfo->ControllerInfo;
259 UCHAR Unit = DriveInfo->UnitNumber;
261
262 PAGED_CODE();
263
264 /* turn on motor */
265 Buffer = Unit;
266
269
270 if(Unit == 0)
272 else if (Unit == 1)
274 else if (Unit == 2)
276 else if (Unit == 3)
278
279 TRACE_(FLOPPY, "HwTurnOnMotor: writing byte 0x%x to offset 0x%x\n", Buffer, DIGITAL_OUTPUT_REGISTER);
281
282 return STATUS_SUCCESS;
283}
#define DOR_FLOPPY_MOTOR_ON_A
Definition: hardware.h:77
#define DOR_FLOPPY_MOTOR_ON_D
Definition: hardware.h:80
#define DOR_FLOPPY_MOTOR_ON_C
Definition: hardware.h:79
#define DOR_FLOPPY_MOTOR_ON_B
Definition: hardware.h:78

Referenced by StartMotor().

◆ ReadyForRead()

static BOOLEAN NTAPI ReadyForRead ( PCONTROLLER_INFO  ControllerInfo)
static

Definition at line 85 of file hardware.c.

97{
99
100 if(!(Status & MSR_IO_DIRECTION)) /* Read = 1 */
101 return FALSE;
102
104 return FALSE;
105
106 return TRUE;
107}
#define MSR_IO_DIRECTION
Definition: hardware.h:95
#define MSR_DATA_REG_READY_FOR_IO
Definition: hardware.h:96

Referenced by Get_Byte().

◆ ReadyForWrite()

static BOOLEAN NTAPI ReadyForWrite ( PCONTROLLER_INFO  ControllerInfo)
static

Definition at line 59 of file hardware.c.

71{
73
74 if(Status & MSR_IO_DIRECTION) /* 0 for out */
75 return FALSE;
76
78 return FALSE;
79
80 return TRUE;
81}

Referenced by Send_Byte().

◆ Send_Byte()

static NTSTATUS NTAPI Send_Byte ( PCONTROLLER_INFO  ControllerInfo,
UCHAR  Byte 
)
static

Definition at line 111 of file hardware.c.

130{
131 int i;
132
133 PAGED_CODE();
134
135 for(i = 0; i < 5; i++)
136 {
137 if(ReadyForWrite(ControllerInfo))
138 break;
139
141 }
142
143 if (i < 5)
144 {
145 WRITE_PORT_UCHAR(ControllerInfo->BaseAddress + FIFO, Byte);
146 return STATUS_SUCCESS;
147 }
148 else
149 {
150 INFO_(FLOPPY, "Send_Byte: timed out trying to write\n");
151 HwDumpRegisters(ControllerInfo);
152 return STATUS_UNSUCCESSFUL;
153 }
154}
static BOOLEAN NTAPI ReadyForWrite(PCONTROLLER_INFO ControllerInfo)
Definition: hardware.c:59

Referenced by HwConfigure(), HwFormatTrack(), HwGetVersion(), HwReadId(), HwReadWriteData(), HwRecalibrate(), HwRecalibrateResult(), HwSeek(), HwSenseDriveStatus(), HwSenseInterruptStatus(), and HwSpecify().