19#define MAX_DRIVES 0x100
33 case 0x00:
return "No error";
34 case 0x10:
return "Drive write protection error";
35 case 0x20:
return "DMA access across 64 kB boundary";
36 case 0x30:
return "End of cylinder";
37 case 0x40:
return "The drive name is invalid or the device have low health";
38 case 0x50:
return "Time out, data not written";
39 case 0x60:
return "Time out, drive not ready";
42 return "Illegal disk address";
44 return "Drive write protection error";
45 case 0x80:
return "Undefined error";
46 case 0x90:
return "Time out error";
47 case 0xA0:
return "CRC error in the ID section";
48 case 0xB0:
return "CRC error in the DATA section";
51 return "Seek failure";
53 return "No data (Sector not found)";
54 case 0xD0:
return "Bad cylinder";
55 case 0xE0:
return "No ID address mark was found";
56 case 0xF0:
return "No DATA address mark was found";
58 default:
return "Unknown error code";
104 WARN(
"DiskResetController(0x%x) DISK OPERATION FAILED -- RESETTING CONTROLLER\n",
107 Regs.
b.
al = DiskDrive->DaUa;
108 Int386(0x1B, &Regs, &Regs);
153 switch (BytesPerSector)
178 REGS RegsIn, RegsOut;
196 RegsIn.
b.
al = DiskDrive->DaUa;
199 RegsIn.
w.
cx = SectorNumber & 0xFFFF;
200 RegsIn.
w.
dx = (SectorNumber >> 16) & 0xFFFF;
205 for (RetryCount = 0; RetryCount < 3; ++RetryCount)
207 Int386(0x1B, &RegsIn, &RegsOut);
219 DiskError(
"Disk Read Failed in LBA mode", RegsOut.
b.
ah);
220 ERR(
"Disk Read Failed in LBA mode: %x (%s) (DriveNumber: 0x%x SectorNumber: %I64u SectorCount: %u)\n",
235 UCHAR PhysicalSector;
239 ULONG NumberOfSectorsToRead;
240 REGS RegsIn, RegsOut;
243 DriveGeometry = DiskDrive->Geometry;
260 if (PhysicalSector > 1)
271 if ((PhysicalHead >= DriveGeometry.
Heads) ||
272 (PhysicalTrack >= DriveGeometry.
Cylinders) ||
273 ((NumberOfSectorsToRead + PhysicalSector) > (DriveGeometry.
SectorsPerTrack + 1)) ||
276 DiskError(
"Disk read exceeds drive geometry limits.", 0);
300 RegsIn.
b.
cl = PhysicalTrack & 0xFFFF;
322 RegsIn.
w.
cx = PhysicalTrack & 0xFFFF;
324 RegsIn.
b.
al = DiskDrive->DaUa;
325 RegsIn.
b.
dl = PhysicalSector;
326 RegsIn.
b.
dh = PhysicalHead;
331 for (RetryCount = 0; RetryCount < 3; ++RetryCount)
333 Int386(0x1B, &RegsIn, &RegsOut);
347 DiskError(
"Disk Read Failed in CHS mode, after retrying 3 times", RegsOut.
b.
ah);
348 ERR(
"Disk Read Failed in CHS mode, after retrying 3 times: %x (%s) (DriveNumber: 0x%x SectorNumber: %I64u SectorCount: %u)\n",
356 SectorNumber += NumberOfSectorsToRead;
368 REGS RegsIn, RegsOut;
369 UCHAR UnitAddress = DaUa & 0x0F;
374 if (DiskEquipment & (1 << UnitAddress))
392 Int386(0x1B, &RegsIn, &RegsOut);
396 DiskDrive->Geometry.Cylinders = RegsOut.
w.
cx;
397 DiskDrive->Geometry.Heads = RegsOut.
b.
dh;
398 DiskDrive->Geometry.SectorsPerTrack = RegsOut.
b.
dl;
399 DiskDrive->Geometry.BytesPerSector = RegsOut.
w.
bx;
403 else if (ScsiParameters != 0)
410 DiskDrive->Geometry.Cylinders = 0xFFFF;
411 DiskDrive->Geometry.Heads = 0xFFFF;
412 DiskDrive->Geometry.SectorsPerTrack = 0xFFFF;
413 DiskDrive->Geometry.BytesPerSector = 2048;
421 DiskDrive->Geometry.Cylinders = 0xFFFF;
422 DiskDrive->Geometry.Heads = 8;
423 DiskDrive->Geometry.SectorsPerTrack = 32;
424 DiskDrive->Geometry.BytesPerSector = 512;
440 DiskDrive->DaUa = DaUa;
442 DiskDrive->Geometry.Sectors = (
ULONGLONG)DiskDrive->Geometry.Cylinders *
443 DiskDrive->Geometry.Heads *
444 DiskDrive->Geometry.SectorsPerTrack;
446 TRACE(
"InitScsiDrive(0x%x) returned:\n"
449 "Sects/Track: 0x%x\n"
450 "Total Sects: 0x%llx\n"
451 "Bytes/Sect : 0x%x\n",
453 DiskDrive->Geometry.Cylinders,
454 DiskDrive->Geometry.Heads,
455 DiskDrive->Geometry.SectorsPerTrack,
456 DiskDrive->Geometry.Sectors,
457 DiskDrive->Geometry.BytesPerSector);
468 REGS RegsIn, RegsOut;
469 ULONG BytesPerSector;
488 Int386(0x1B, &RegsIn, &RegsOut);
494 BytesPerSector = 128 << RegsOut.
b.
ch;
495 switch (BytesPerSector)
501 DiskDrive->Geometry.Cylinders = 80;
502 DiskDrive->Geometry.Heads = 2;
503 DiskDrive->Geometry.SectorsPerTrack = 16;
508 DiskDrive->Geometry.Cylinders = 77;
509 DiskDrive->Geometry.Heads = 2;
510 DiskDrive->Geometry.SectorsPerTrack = 26;
518 DiskDrive->Geometry.Cylinders = 80;
519 DiskDrive->Geometry.Heads = 2;
520 DiskDrive->Geometry.SectorsPerTrack = 18;
525 DiskDrive->Geometry.Cylinders = 80;
526 DiskDrive->Geometry.Heads = 2;
527 DiskDrive->Geometry.SectorsPerTrack = 8;
532 DiskDrive->Geometry.Cylinders = 80;
533 DiskDrive->Geometry.Heads = 2;
534 DiskDrive->Geometry.SectorsPerTrack = 15;
540 DiskDrive->Geometry.Cylinders = 77;
541 DiskDrive->Geometry.Heads = 2;
542 DiskDrive->Geometry.SectorsPerTrack = 8;
549 DiskDrive->Geometry.BytesPerSector = BytesPerSector;
550 DiskDrive->Geometry.Sectors = (
ULONGLONG)DiskDrive->Geometry.Cylinders *
551 DiskDrive->Geometry.Heads *
552 DiskDrive->Geometry.SectorsPerTrack;
554 DiskDrive->DaUa = DaUa;
558 TRACE(
"InitFloppyDrive(0x%x) returned:\n"
561 "Sects/Track: 0x%x\n"
562 "Total Sects: 0x%llx\n"
563 "Bytes/Sect : 0x%x\n",
565 DiskDrive->Geometry.Cylinders,
566 DiskDrive->Geometry.Heads,
567 DiskDrive->Geometry.SectorsPerTrack,
568 DiskDrive->Geometry.Sectors,
569 DiskDrive->Geometry.BytesPerSector);
585 DiskDrive->Geometry.Cylinders = DeviceUnit->
Cylinders;
586 DiskDrive->Geometry.Heads = DeviceUnit->
Heads;
588 DiskDrive->Geometry.BytesPerSector = DeviceUnit->
SectorSize;
591 DiskDrive->DaUa = 0xFF;
592 DiskDrive->AtaUnitNumber = AtaUnitNumber;
608 TRACE(
"InitIdeDrive(0x%x) returned:\n"
611 "Sects/Track: 0x%x\n"
612 "Total Sects: 0x%llx\n"
613 "Bytes/Sect : 0x%x\n",
615 DiskDrive->Geometry.Cylinders,
616 DiskDrive->Geometry.Heads,
617 DiskDrive->Geometry.SectorsPerTrack,
618 DiskDrive->Geometry.Sectors,
619 DiskDrive->Geometry.BytesPerSector);
628 UCHAR BiosFloppyDriveNumber, BiosHardDriveDriveNumber, IdeDetectedCount;
631 TRACE(
"Pc98InitializeBootDevices()\n");
641 BiosFloppyDriveNumber = 0x30;
642 BiosHardDriveDriveNumber = 0x80;
645 for (
i = 0;
i < 4;
i++)
652 ++BiosFloppyDriveNumber;
655 for (
i = 0;
i < 4;
i++)
661 ++BiosFloppyDriveNumber;
664 for (
i = 0;
i < 4;
i++)
670 ++BiosFloppyDriveNumber;
679 for (
i = 0;
i < IdeDetectedCount;
i++)
683 ++BiosHardDriveDriveNumber;
687 for (
i = 0;
i < 7;
i++)
691 ++BiosHardDriveDriveNumber;
724 TRACE(
"Pc98DiskReadLogicalSectors() DriveNumber: 0x%x SectorNumber: %I64u SectorCount: %u Buffer: 0x%x\n",
744 TRACE(
"--> Using LBA\n");
750 TRACE(
"--> Using CHS\n");
762 TRACE(
"Pc98DiskGetDriveGeometry(0x%x)\n", DriveNumber);
VOID DiskError(_In_ PCSTR ErrorString, _In_ ULONG ErrorCode)
#define DBG_DEFAULT_CHANNEL(ch)
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)
static BOOLEAN InitScsiDrive(_Out_ PPC98_DISK_DRIVE DiskDrive, _In_ UCHAR DaUa)
ULONG Pc98DiskGetCacheableBlockCount(_In_ UCHAR DriveNumber)
PCSTR DiskGetErrorCodeString(_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)
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)
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)