19#define MAX_DRIVES 0x100
47 case 0x00:
return "No error";
48 case 0x10:
return "Drive write protection error";
49 case 0x20:
return "DMA access across 64 kB boundary";
50 case 0x30:
return "End of cylinder";
51 case 0x40:
return "The drive name is invalid or the device have low health";
52 case 0x50:
return "Time out, data not written";
53 case 0x60:
return "Time out, drive not ready";
56 return "Illegal disk address";
58 return "Drive write protection error";
59 case 0x80:
return "Undefined error";
60 case 0x90:
return "Time out error";
61 case 0xA0:
return "CRC error in the ID section";
62 case 0xB0:
return "CRC error in the DATA section";
65 return "Seek failure";
67 return "No data (Sector not found)";
68 case 0xD0:
return "Bad cylinder";
69 case 0xE0:
return "No ID address mark was found";
70 case 0xF0:
return "No DATA address mark was found";
72 default:
return "Unknown error code";
82 CHAR ErrorCodeString[200];
88 sizeof(ErrorCodeString),
89 "%s\n\nError Code: 0x%lx\nError: %s",
94 ERR(
"%s\n", ErrorCodeString);
141 WARN(
"DiskResetController(0x%x) DISK OPERATION FAILED -- RESETTING CONTROLLER\n",
144 Regs.
b.
al = DiskDrive->DaUa;
145 Int386(0x1B, &Regs, &Regs);
190 switch (BytesPerSector)
215 REGS RegsIn, RegsOut;
233 RegsIn.
b.
al = DiskDrive->DaUa;
236 RegsIn.
w.
cx = SectorNumber & 0xFFFF;
237 RegsIn.
w.
dx = (SectorNumber >> 16) & 0xFFFF;
242 for (RetryCount = 0; RetryCount < 3; ++RetryCount)
244 Int386(0x1B, &RegsIn, &RegsOut);
256 DiskError(
"Disk Read Failed in LBA mode", RegsOut.
b.
ah);
257 ERR(
"Disk Read Failed in LBA mode: %x (%s) (DriveNumber: 0x%x SectorNumber: %I64u SectorCount: %u)\n",
272 UCHAR PhysicalSector;
276 ULONG NumberOfSectorsToRead;
277 REGS RegsIn, RegsOut;
280 DriveGeometry = DiskDrive->Geometry;
297 if (PhysicalSector > 1)
308 if ((PhysicalHead >= DriveGeometry.
Heads) ||
309 (PhysicalTrack >= DriveGeometry.
Cylinders) ||
310 ((NumberOfSectorsToRead + PhysicalSector) > (DriveGeometry.
SectorsPerTrack + 1)) ||
313 DiskError(
"Disk read exceeds drive geometry limits.", 0);
337 RegsIn.
b.
cl = PhysicalTrack & 0xFFFF;
359 RegsIn.
w.
cx = PhysicalTrack & 0xFFFF;
361 RegsIn.
b.
al = DiskDrive->DaUa;
362 RegsIn.
b.
dl = PhysicalSector;
363 RegsIn.
b.
dh = PhysicalHead;
368 for (RetryCount = 0; RetryCount < 3; ++RetryCount)
370 Int386(0x1B, &RegsIn, &RegsOut);
384 DiskError(
"Disk Read Failed in CHS mode, after retrying 3 times", RegsOut.
b.
ah);
385 ERR(
"Disk Read Failed in CHS mode, after retrying 3 times: %x (%s) (DriveNumber: 0x%x SectorNumber: %I64u SectorCount: %u)\n",
393 SectorNumber += NumberOfSectorsToRead;
405 REGS RegsIn, RegsOut;
406 UCHAR UnitAddress = DaUa & 0x0F;
411 if (DiskEquipment & (1 << UnitAddress))
429 Int386(0x1B, &RegsIn, &RegsOut);
433 DiskDrive->Geometry.Cylinders = RegsOut.
w.
cx;
434 DiskDrive->Geometry.Heads = RegsOut.
b.
dh;
435 DiskDrive->Geometry.SectorsPerTrack = RegsOut.
b.
dl;
436 DiskDrive->Geometry.BytesPerSector = RegsOut.
w.
bx;
439 else if (ScsiParameters != 0)
446 DiskDrive->Geometry.Cylinders = 0xFFFF;
447 DiskDrive->Geometry.Heads = 0xFFFF;
448 DiskDrive->Geometry.SectorsPerTrack = 0xFFFF;
449 DiskDrive->Geometry.BytesPerSector = 2048;
457 DiskDrive->Geometry.Cylinders = 0xFFFF;
458 DiskDrive->Geometry.Heads = 8;
459 DiskDrive->Geometry.SectorsPerTrack = 32;
460 DiskDrive->Geometry.BytesPerSector = 512;
476 DiskDrive->DaUa = DaUa;
478 DiskDrive->Geometry.Sectors = (
ULONGLONG)DiskDrive->Geometry.Cylinders *
479 DiskDrive->Geometry.Heads *
480 DiskDrive->Geometry.SectorsPerTrack;
482 TRACE(
"InitScsiDrive(0x%x) returned:\n"
485 "Sects/Track: 0x%x\n"
486 "Total Sects: 0x%llx\n"
487 "Bytes/Sect : 0x%x\n",
489 DiskDrive->Geometry.Cylinders,
490 DiskDrive->Geometry.Heads,
491 DiskDrive->Geometry.SectorsPerTrack,
492 DiskDrive->Geometry.Sectors,
493 DiskDrive->Geometry.BytesPerSector);
504 REGS RegsIn, RegsOut;
505 ULONG BytesPerSector;
524 Int386(0x1B, &RegsIn, &RegsOut);
530 BytesPerSector = 128 << RegsOut.
b.
ch;
531 switch (BytesPerSector)
537 DiskDrive->Geometry.Cylinders = 80;
538 DiskDrive->Geometry.Heads = 2;
539 DiskDrive->Geometry.SectorsPerTrack = 16;
544 DiskDrive->Geometry.Cylinders = 77;
545 DiskDrive->Geometry.Heads = 2;
546 DiskDrive->Geometry.SectorsPerTrack = 26;
554 DiskDrive->Geometry.Cylinders = 80;
555 DiskDrive->Geometry.Heads = 2;
556 DiskDrive->Geometry.SectorsPerTrack = 18;
561 DiskDrive->Geometry.Cylinders = 80;
562 DiskDrive->Geometry.Heads = 2;
563 DiskDrive->Geometry.SectorsPerTrack = 8;
568 DiskDrive->Geometry.Cylinders = 80;
569 DiskDrive->Geometry.Heads = 2;
570 DiskDrive->Geometry.SectorsPerTrack = 15;
576 DiskDrive->Geometry.Cylinders = 77;
577 DiskDrive->Geometry.Heads = 2;
578 DiskDrive->Geometry.SectorsPerTrack = 8;
585 DiskDrive->Geometry.BytesPerSector = BytesPerSector;
586 DiskDrive->Geometry.Sectors = (
ULONGLONG)DiskDrive->Geometry.Cylinders *
587 DiskDrive->Geometry.Heads *
588 DiskDrive->Geometry.SectorsPerTrack;
590 DiskDrive->DaUa = DaUa;
594 TRACE(
"InitFloppyDrive(0x%x) returned:\n"
597 "Sects/Track: 0x%x\n"
598 "Total Sects: 0x%llx\n"
599 "Bytes/Sect : 0x%x\n",
601 DiskDrive->Geometry.Cylinders,
602 DiskDrive->Geometry.Heads,
603 DiskDrive->Geometry.SectorsPerTrack,
604 DiskDrive->Geometry.Sectors,
605 DiskDrive->Geometry.BytesPerSector);
621 DiskDrive->Geometry.Cylinders = DeviceUnit->
Cylinders;
622 DiskDrive->Geometry.Heads = DeviceUnit->
Heads;
624 DiskDrive->Geometry.BytesPerSector = DeviceUnit->
SectorSize;
627 DiskDrive->DaUa = 0xFF;
628 DiskDrive->AtaUnitNumber = AtaUnitNumber;
644 TRACE(
"InitIdeDrive(0x%x) returned:\n"
647 "Sects/Track: 0x%x\n"
648 "Total Sects: 0x%llx\n"
649 "Bytes/Sect : 0x%x\n",
651 DiskDrive->Geometry.Cylinders,
652 DiskDrive->Geometry.Heads,
653 DiskDrive->Geometry.SectorsPerTrack,
654 DiskDrive->Geometry.Sectors,
655 DiskDrive->Geometry.BytesPerSector);
664 UCHAR BiosFloppyDriveNumber, BiosHardDriveDriveNumber, IdeDetectedCount;
667 TRACE(
"Pc98InitializeBootDevices()\n");
677 BiosFloppyDriveNumber = 0x30;
678 BiosHardDriveDriveNumber = 0x80;
681 for (
i = 0;
i < 4;
i++)
688 ++BiosFloppyDriveNumber;
691 for (
i = 0;
i < 4;
i++)
697 ++BiosFloppyDriveNumber;
700 for (
i = 0;
i < 4;
i++)
706 ++BiosFloppyDriveNumber;
715 for (
i = 0;
i <= IdeDetectedCount;
i++)
719 ++BiosHardDriveDriveNumber;
723 for (
i = 0;
i < 7;
i++)
727 ++BiosHardDriveDriveNumber;
760 TRACE(
"Pc98DiskReadLogicalSectors() DriveNumber: 0x%x SectorNumber: %I64u SectorCount: %u Buffer: 0x%x\n",
780 TRACE(
"--> Using LBA\n");
786 TRACE(
"--> Using CHS\n");
798 TRACE(
"Pc98DiskGetDriveGeometry(0x%x)\n", DriveNumber);
#define DBG_DEFAULT_CHANNEL(ch)
VOID UiMessageBox(_In_ PCSTR Format,...)
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
_In_ PUSB_DEVICE_HANDLE _Out_ PUSHORT DeviceAddress
BOOLEAN PcInitializeBootDevices(VOID)
PDEVICE_UNIT AtaGetDevice(_In_ UCHAR UnitNumber)
BOOLEAN AtaInit(_Out_ PUCHAR DetectedCount)
BOOLEAN AtaReadLogicalSectors(_In_ PDEVICE_UNIT DeviceUnit, _In_ ULONG64 SectorNumber, _In_ ULONG SectorCount, _Out_writes_bytes_all_(SectorCount *DeviceUnit->SectorSize) PVOID Buffer)
#define DRIVE_FLAGS_REMOVABLE
#define DRIVE_FLAGS_INITIALIZED
_In_ NDIS_ERROR_CODE ErrorCode
#define _Out_writes_bytes_all_(s)
NTSTRSAFEVAPI RtlStringCbPrintfA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
static BOOLEAN InitScsiDrive(_Out_ PPC98_DISK_DRIVE DiskDrive, _In_ UCHAR DaUa)
ULONG Pc98DiskGetCacheableBlockCount(_In_ UCHAR DriveNumber)
static VOID DiskError(_In_ PCSTR ErrorString, _In_ ULONG ErrorCode)
static BOOLEAN InitFloppyDrive(_Out_ PPC98_DISK_DRIVE DiskDrive, _In_ UCHAR DaUa)
static BOOLEAN Pc98DiskReadLogicalSectorsCHS(_In_ PPC98_DISK_DRIVE DiskDrive, _In_ ULONG64 SectorNumber, _In_ ULONG SectorCount, _Out_writes_bytes_all_(SectorCount *DiskDrive->Geometry.BytesPerSector) PVOID Buffer)
static PC98_DISK_DRIVE Pc98DiskDrive[MAX_DRIVES]
static BOOLEAN Pc98DiskReadLogicalSectorsLBA(_In_ PPC98_DISK_DRIVE DiskDrive, _In_ ULONG64 SectorNumber, _In_ ULONG SectorCount, _Out_writes_bytes_all_(SectorCount *DiskDrive->Geometry.BytesPerSector) PVOID Buffer)
BOOLEAN Pc98DiskGetDriveGeometry(_In_ UCHAR DriveNumber, _Out_ PGEOMETRY Geometry)
BOOLEAN Pc98InitializeBootDevices(VOID)
BOOLEAN Pc98DiskReadLogicalSectors(_In_ UCHAR DriveNumber, _In_ ULONGLONG SectorNumber, _In_ ULONG SectorCount, _Out_ PVOID Buffer)
LONG DiskReportError(_In_ BOOLEAN bShowError)
CONFIGURATION_TYPE DiskGetConfigType(_In_ UCHAR DriveNumber)
static UCHAR BytesPerSectorToSectorLengthCode(_In_ ULONG BytesPerSector)
static BOOLEAN DiskResetController(_In_ PPC98_DISK_DRIVE DiskDrive)
static BOOLEAN InitIdeDrive(_Out_ PPC98_DISK_DRIVE DiskDrive, _In_ UCHAR AtaUnitNumber)
static PCSTR DiskGetErrorCodeString(_In_ ULONG ErrorCode)
PPC98_DISK_DRIVE Pc98DiskDriveNumberToDrive(_In_ UCHAR DriveNumber)
#define INT386_SUCCESS(regs)
int __cdecl Int386(int ivec, REGS *in, REGS *out)
enum _CONFIGURATION_TYPE CONFIGURATION_TYPE
Data structure for the ATA device.
ULONG BytesPerSector
Number of bytes per sector.
ULONG Cylinders
Number of cylinders on the disk.
ULONG SectorsPerTrack
Number of sectors per track.
ULONG Heads
Number of heads on the disk.
#define RtlZeroMemory(Destination, Length)
#define SECONDBYTE(VALUE)