92 case 0x00:
return "no error";
93 case 0x01:
return "bad command passed to driver";
94 case 0x02:
return "address mark not found or bad sector";
95 case 0x03:
return "diskette write protect error";
96 case 0x04:
return "sector not found";
97 case 0x05:
return "fixed disk reset failed";
98 case 0x06:
return "diskette changed or removed";
99 case 0x07:
return "bad fixed disk parameter table";
100 case 0x08:
return "DMA overrun";
101 case 0x09:
return "DMA access across 64k boundary";
102 case 0x0A:
return "bad fixed disk sector flag";
103 case 0x0B:
return "bad fixed disk cylinder";
104 case 0x0C:
return "unsupported track/invalid media";
105 case 0x0D:
return "invalid number of sectors on fixed disk format";
106 case 0x0E:
return "fixed disk controlled data address mark detected";
107 case 0x0F:
return "fixed disk DMA arbitration level out of range";
108 case 0x10:
return "ECC/CRC error on disk read";
109 case 0x11:
return "recoverable fixed disk data error, data fixed by ECC";
110 case 0x20:
return "controller error (NEC for floppies)";
111 case 0x40:
return "seek failure";
112 case 0x80:
return "time out, drive not ready";
113 case 0xAA:
return "fixed disk drive not ready";
114 case 0xBB:
return "fixed disk undefined error";
115 case 0xCC:
return "fixed disk write fault on selected drive";
116 case 0xE0:
return "fixed disk status error/Error reg = 0";
117 case 0xFF:
return "sense operation failed";
119 default:
return "unknown error code";
125 CHAR ErrorCodeString[200];
130 sprintf(ErrorCodeString,
"%s\n\nError Code: 0x%lx\nError: %s",
133 TRACE(
"%s\n", ErrorCodeString);
142 REGS RegsIn, RegsOut;
144 WARN(
"DiskResetController(0x%x) DISK OPERATION FAILED -- RESETTING CONTROLLER\n", DriveNumber);
156 RegsIn.
b.
dl = DriveNumber;
159 Int386(0x13, &RegsIn, &RegsOut);
166 REGS RegsIn, RegsOut;
170 TRACE(
"PcDiskReadLogicalSectorsLBA() DriveNumber: 0x%x SectorNumber: %I64d SectorCount: %d Buffer: 0x%x\n", DriveNumber, SectorNumber,
SectorCount,
Buffer);
175 Packet->PacketSize =
sizeof(*Packet);
181 Packet->LBAStartBlock = SectorNumber;
194 RegsIn.
b.
dl = DriveNumber;
199 for (RetryCount=0; RetryCount<3; RetryCount++)
201 Int386(0x13, &RegsIn, &RegsOut);
209 else if (RegsOut.
b.
ah == 0x11)
222 DiskError(
"Disk Read Failed in LBA mode", RegsOut.
b.
ah);
223 ERR(
"Disk Read Failed in LBA mode: %x (%s) (DriveNumber: 0x%x SectorNumber: %I64d SectorCount: %d)\n",
232 UCHAR PhysicalSector;
236 ULONG NumberOfSectorsToRead;
237 REGS RegsIn, RegsOut;
240 TRACE(
"PcDiskReadLogicalSectorsCHS()\n");
258 PhysicalSector = 1 + (
UCHAR)(SectorNumber % DriveGeometry.
Sectors);
259 PhysicalHead = (
UCHAR)((SectorNumber / DriveGeometry.
Sectors) % DriveGeometry.
Heads);
260 PhysicalTrack = (
ULONG)((SectorNumber / DriveGeometry.
Sectors) / DriveGeometry.
Heads);
263 if (PhysicalSector > 1)
266 NumberOfSectorsToRead = (DriveGeometry.
Sectors - (PhysicalSector - 1));
273 NumberOfSectorsToRead = DriveGeometry.
Sectors;
279 if ((PhysicalHead >= DriveGeometry.
Heads) ||
280 (PhysicalTrack >= DriveGeometry.
Cylinders) ||
281 ((NumberOfSectorsToRead + PhysicalSector) > (DriveGeometry.
Sectors + 1)) ||
282 (PhysicalSector > DriveGeometry.
Sectors))
284 DiskError(
"Disk read exceeds drive geometry limits.", 0);
307 RegsIn.
b.
al = (
UCHAR)NumberOfSectorsToRead;
308 RegsIn.
b.
ch = (PhysicalTrack & 0xFF);
309 RegsIn.
b.
cl = (
UCHAR)(PhysicalSector + ((PhysicalTrack & 0x300) >> 2));
310 RegsIn.
b.
dh = PhysicalHead;
311 RegsIn.
b.
dl = DriveNumber;
316 for (RetryCount=0; RetryCount<3; RetryCount++)
318 Int386(0x13, &RegsIn, &RegsOut);
326 else if (RegsOut.
b.
ah == 0x11)
341 DiskError(
"Disk Read Failed in CHS mode, after retrying 3 times", RegsOut.
b.
ah);
342 ERR(
"Disk Read Failed in CHS mode, after retrying 3 times: %x (%s) (DriveNumber: 0x%x SectorNumber: %I64d SectorCount: %d)\n",
356 SectorNumber += NumberOfSectorsToRead;
364 static UCHAR LastDriveNumber = 0xff;
366 REGS RegsIn, RegsOut;
368 TRACE(
"DiskInt13ExtensionsSupported()\n");
370 if (DriveNumber == LastDriveNumber)
372 TRACE(
"Using cached value %s for drive 0x%x\n",
373 LastSupported ?
"TRUE" :
"FALSE", DriveNumber);
374 return LastSupported;
385 if (DriveNumber >= 0x8A)
387 LastSupported =
TRUE;
391 LastDriveNumber = DriveNumber;
420 RegsIn.
w.
bx = 0x55AA;
421 RegsIn.
b.
dl = DriveNumber;
424 Int386(0x13, &RegsIn, &RegsOut);
429 LastSupported =
FALSE;
433 if (RegsOut.
w.
bx != 0xAA55)
436 LastSupported =
FALSE;
440 if (!(RegsOut.
w.
cx & 0x0001))
446 DbgPrint(
"Suspicious API subset support bitmap 0x%x on device 0x%lx\n",
447 RegsOut.
w.
cx, DriveNumber);
448 LastSupported =
FALSE;
452 LastSupported =
TRUE;
460 TRACE(
"PcDiskReadLogicalSectors() DriveNumber: 0x%x SectorNumber: %I64d SectorCount: %d Buffer: 0x%x\n",
470 if ((DriveNumber >= 0x80) && ExtensionsSupported)
472 TRACE(
"Using Int 13 Extensions for read. DiskInt13ExtensionsSupported(%d) = %s\n", DriveNumber, ExtensionsSupported ?
"TRUE" :
"FALSE");
486 #if defined(__i386__) || defined(_M_AMD64) 491 #endif // defined __i386__ || defined(_M_AMD64) 495 REGS RegsIn, RegsOut;
498 TRACE(
"DiskGetExtendedDriveParameters()\n");
519 RegsIn.
b.
dl = DriveNumber;
524 Int386(0x13, &RegsIn, &RegsOut);
531 TRACE(
"size of buffer: %x\n",
Ptr[0]);
532 TRACE(
"information flags: %x\n",
Ptr[1]);
533 TRACE(
"number of physical cylinders on drive: %u\n", *(
PULONG)&
Ptr[2]);
534 TRACE(
"number of physical heads on drive: %u\n", *(
PULONG)&
Ptr[4]);
535 TRACE(
"number of physical sectors per track: %u\n", *(
PULONG)&
Ptr[6]);
536 TRACE(
"total number of sectors on drive: %I64u\n", *(
unsigned long long*)&
Ptr[8]);
537 TRACE(
"bytes per sector: %u\n",
Ptr[12]);
540 TRACE(
"EED configuration parameters: %x:%x\n",
Ptr[13],
Ptr[14]);
541 if (
Ptr[13] != 0xffff &&
Ptr[14] != 0xffff)
544 TRACE(
"SpecPtr: %x\n", SpecPtr);
545 TRACE(
"physical I/O port base address: %x\n", *(
PUSHORT)&SpecPtr[0]);
546 TRACE(
"disk-drive control port address: %x\n", *(
PUSHORT)&SpecPtr[2]);
547 TRACE(
"drive flags: %x\n", SpecPtr[4]);
548 TRACE(
"proprietary information: %x\n", SpecPtr[5]);
549 TRACE(
"IRQ for drive: %u\n", SpecPtr[6]);
550 TRACE(
"sector count for multi-sector transfers: %u\n", SpecPtr[7]);
551 TRACE(
"DMA control: %x\n", SpecPtr[8]);
552 TRACE(
"programmed I/O control: %x\n", SpecPtr[9]);
569 REGS RegsIn, RegsOut;
572 TRACE(
"DiskGetDriveGeometry()\n");
575 ExtGeometry.
Size =
sizeof(ExtGeometry);
605 RegsIn.
b.
dl = DriveNumber;
606 RegsIn.
w.
es = 0x0000;
607 RegsIn.
w.
di = 0x0000;
610 Int386(0x13, &RegsIn, &RegsOut);
614 Cylinders = (RegsOut.
b.
cl & 0xC0) << 2;
615 Cylinders += RegsOut.
b.
ch;
BOOLEAN DiskResetController(UCHAR DriveNumber)
_In_ NDIS_ERROR_CODE ErrorCode
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
struct I386_DISK_ADDRESS_PACKET * PI386_DISK_ADDRESS_PACKET
USHORT TransferBufferSegment
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
static BOOLEAN PcDiskReadLogicalSectorsLBA(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
int __cdecl Int386(int ivec, REGS *in, REGS *out)
#define sprintf(buf, format,...)
ULONG PcDiskGetCacheableBlockCount(UCHAR DriveNumber)
#define BIOSCALLBUFSEGMENT
#define INT386_SUCCESS(regs)
static PCSTR DiskGetErrorCodeString(ULONG ErrorCode)
DBG_DEFAULT_CHANNEL(DISK)
VOID UiMessageBox(PCSTR Format,...)
BOOLEAN DiskGetExtendedDriveParameters(UCHAR DriveNumber, PVOID Buffer, USHORT BufferSize)
BOOLEAN PcDiskGetDriveGeometry(UCHAR DriveNumber, PGEOMETRY Geometry)
BOOLEAN PcDiskReadLogicalSectors(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
#define BIOSCALLBUFOFFSET
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define memcpy(s1, s2, n)
static BOOLEAN DiskInt13ExtensionsSupported(UCHAR DriveNumber)
LONG DiskReportError(BOOLEAN bShowError)
struct I386_CDROM_SPEC_PACKET * PI386_CDROM_SPEC_PACKET
static VOID DiskError(PCSTR ErrorString, ULONG ErrorCode)
void WRITE_PORT_UCHAR(PUCHAR Address, UCHAR Value)
#define RtlZeroMemory(Destination, Length)
static BOOLEAN PcDiskReadLogicalSectorsCHS(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
IN BOOLEAN OUT PSTR Buffer
USHORT TransferBufferOffset