Skip to content

Commit 4ffe8e8

Browse files
committed
[FREELDR] disk/fs: Improve some TRACEs and comments (reactos#8400)
- Enhance some TRACEs. - Improve printf formatters. - Checking for success is part of the operation, no need to comment on that.
1 parent 5f243e6 commit 4ffe8e8

File tree

7 files changed

+51
-54
lines changed

7 files changed

+51
-54
lines changed

boot/freeldr/freeldr/arch/i386/pc/pcdisk.c

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ static VOID DiskError(PCSTR ErrorString, ULONG ErrorCode)
171171
ErrorString, ErrorCode, DiskGetErrorCodeString(ErrorCode));
172172

173173
ERR("%s\n", ErrorCodeString);
174-
175174
UiMessageBox(ErrorCodeString);
176175
}
177176

@@ -276,14 +275,18 @@ DiskInt13ExtensionsSupported(IN UCHAR DriveNumber)
276275
return FALSE;
277276
}
278277

278+
#if DBG
279+
TRACE("Drive 0x%x: INT 13h Extended version: 0x%02x, API bitmap: 0x%04x\n",
280+
DriveNumber, RegsOut.b.ah, RegsOut.w.cx);
281+
#endif
279282
if (!(RegsOut.w.cx & 0x0001))
280283
{
281284
/*
282285
* CX = API subset support bitmap.
283286
* Bit 0, extended disk access functions (AH=42h-44h,47h,48h) supported.
284287
*/
285-
WARN("Suspicious API subset support bitmap 0x%x on device 0x%lx\n",
286-
RegsOut.w.cx, DriveNumber);
288+
WARN("Drive 0x%x: Suspicious API subset support bitmap 0x%04x\n",
289+
DriveNumber, RegsOut.w.cx);
287290
return FALSE;
288291
}
289292

@@ -333,37 +336,37 @@ DiskGetExtendedDriveParameters(
333336
RtlCopyMemory(Buffer, Ptr, BufferSize);
334337

335338
#if DBG
336-
TRACE("size of buffer: %x\n", Ptr[0]);
337-
TRACE("information flags: %x\n", Ptr[1]);
338-
TRACE("number of physical cylinders on drive: %u\n", *(PULONG)&Ptr[2]);
339-
TRACE("number of physical heads on drive: %u\n", *(PULONG)&Ptr[4]);
340-
TRACE("number of physical sectors per track: %u\n", *(PULONG)&Ptr[6]);
341-
TRACE("total number of sectors on drive: %I64u\n", *(PULONGLONG)&Ptr[8]);
342-
TRACE("bytes per sector: %u\n", Ptr[12]);
339+
TRACE("Size of buffer: 0x%x\n", Ptr[0]);
340+
TRACE("Information flags: 0x%x\n", Ptr[1]);
341+
TRACE("Number of physical cylinders on drive: %u\n", *(PULONG)&Ptr[2]);
342+
TRACE("Number of physical heads on drive: %u\n", *(PULONG)&Ptr[4]);
343+
TRACE("Number of physical sectors per track: %u\n", *(PULONG)&Ptr[6]);
344+
TRACE("Total number of sectors on drive: %I64u\n", *(PULONGLONG)&Ptr[8]);
345+
TRACE("Bytes per sector: %u\n", Ptr[12]);
343346
if (Ptr[0] >= 0x1e)
344347
{
345348
// Ptr[13]: offset, Ptr[14]: segment
346349
TRACE("EDD configuration parameters: %x:%x\n", Ptr[14], Ptr[13]);
347350
if (Ptr[13] != 0xffff && Ptr[14] != 0xffff)
348351
{
349352
PUCHAR SpecPtr = (PUCHAR)(ULONG_PTR)((Ptr[14] << 4) + Ptr[13]);
350-
TRACE("SpecPtr: %x\n", SpecPtr);
351-
TRACE("physical I/O port base address: %x\n", *(PUSHORT)&SpecPtr[0]);
352-
TRACE("disk-drive control port address: %x\n", *(PUSHORT)&SpecPtr[2]);
353-
TRACE("drive flags: %x\n", SpecPtr[4]);
354-
TRACE("proprietary information: %x\n", SpecPtr[5]);
353+
TRACE("SpecPtr: 0x%x\n", SpecPtr);
354+
TRACE("Physical I/O port base address: 0x%x\n", *(PUSHORT)&SpecPtr[0]);
355+
TRACE("Disk-drive control port address: 0x%x\n", *(PUSHORT)&SpecPtr[2]);
356+
TRACE("Head register upper nibble: 0x%x\n", SpecPtr[4]);
357+
TRACE("BIOS Vendor-specific: 0x%x\n", SpecPtr[5]);
355358
TRACE("IRQ for drive: %u\n", SpecPtr[6]);
356-
TRACE("sector count for multi-sector transfers: %u\n", SpecPtr[7]);
357-
TRACE("DMA control: %x\n", SpecPtr[8]);
358-
TRACE("programmed I/O control: %x\n", SpecPtr[9]);
359-
TRACE("drive options: %x\n", *(PUSHORT)&SpecPtr[10]);
359+
TRACE("Sector count for multi-sector transfers: %u\n", SpecPtr[7]);
360+
TRACE("DMA control: 0x%x\n", SpecPtr[8]);
361+
TRACE("Programmed I/O control: 0x%x\n", SpecPtr[9]);
362+
TRACE("Drive options: 0x%x\n", *(PUSHORT)&SpecPtr[10]);
360363
}
361364
}
362365
if (Ptr[0] >= 0x42)
363366
{
364-
TRACE("signature: %x\n", Ptr[15]);
367+
TRACE("Signature: 0x%x\n", Ptr[15]);
365368
}
366-
#endif
369+
#endif // DBG
367370

368371
return TRUE;
369372
}
@@ -393,11 +396,13 @@ InitDriveGeometry(
393396
"Cylinders : 0x%x\n"
394397
"Heads : 0x%x\n"
395398
"Sects/Track: 0x%x\n"
399+
"Total Sects: 0x%llx\n"
396400
"Bytes/Sect : 0x%x\n",
397401
DriveNumber,
398402
DiskDrive->ExtGeometry.Cylinders,
399403
DiskDrive->ExtGeometry.Heads,
400404
DiskDrive->ExtGeometry.SectorsPerTrack,
405+
DiskDrive->ExtGeometry.Sectors,
401406
DiskDrive->ExtGeometry.BytesPerSector);
402407
}
403408

@@ -444,7 +449,7 @@ InitDriveGeometry(
444449
DiskDrive->Geometry.Cylinders = Cylinders;
445450
DiskDrive->Geometry.Heads = RegsOut.b.dh + 1;
446451
DiskDrive->Geometry.SectorsPerTrack = RegsOut.b.cl & 0x3F;
447-
DiskDrive->Geometry.BytesPerSector = 512; /* Just assume 512 bytes per sector */
452+
DiskDrive->Geometry.BytesPerSector = 512; /* Just assume 512 bytes per sector */
448453

449454
DiskDrive->Geometry.Sectors = (ULONGLONG)DiskDrive->Geometry.Cylinders *
450455
DiskDrive->Geometry.Heads *
@@ -453,12 +458,14 @@ InitDriveGeometry(
453458
TRACE("Regular Int13h(0x%x) returned:\n"
454459
"Cylinders : 0x%x\n"
455460
"Heads : 0x%x\n"
456-
"Sects/Track: 0x%x (original 0x%x)\n"
461+
"Sects/Track: 0x%x\n"
462+
"Total Sects: 0x%llx\n"
457463
"Bytes/Sect : 0x%x\n",
458464
DriveNumber,
459465
DiskDrive->Geometry.Cylinders,
460466
DiskDrive->Geometry.Heads,
461-
DiskDrive->Geometry.SectorsPerTrack, RegsOut.b.cl,
467+
DiskDrive->Geometry.SectorsPerTrack,
468+
DiskDrive->Geometry.Sectors,
462469
DiskDrive->Geometry.BytesPerSector);
463470

464471
return Success;
@@ -616,7 +623,7 @@ PcDiskReadLogicalSectorsLBA(
616623

617624
/* If we get here then the read failed */
618625
DiskError("Disk Read Failed in LBA mode", RegsOut.b.ah);
619-
ERR("Disk Read Failed in LBA mode: %x (%s) (DriveNumber: 0x%x SectorNumber: %I64d SectorCount: %d)\n",
626+
ERR("Disk Read Failed in LBA mode: %x (%s) (DriveNumber: 0x%x SectorNumber: %I64u SectorCount: %u)\n",
620627
RegsOut.b.ah, DiskGetErrorCodeString(RegsOut.b.ah),
621628
DriveNumber, SectorNumber, SectorCount);
622629

@@ -719,7 +726,7 @@ PcDiskReadLogicalSectorsCHS(
719726
if (RetryCount >= 3)
720727
{
721728
DiskError("Disk Read Failed in CHS mode, after retrying 3 times", RegsOut.b.ah);
722-
ERR("Disk Read Failed in CHS mode, after retrying 3 times: %x (%s) (DriveNumber: 0x%x SectorNumber: %I64d SectorCount: %d)\n",
729+
ERR("Disk Read Failed in CHS mode, after retrying 3 times: %x (%s) (DriveNumber: 0x%x SectorNumber: %I64u SectorCount: %u)\n",
723730
RegsOut.b.ah, DiskGetErrorCodeString(RegsOut.b.ah),
724731
DriveNumber, SectorNumber, SectorCount);
725732
return FALSE;
@@ -750,7 +757,7 @@ PcDiskReadLogicalSectors(
750757
{
751758
PPC_DISK_DRIVE DiskDrive;
752759

753-
TRACE("PcDiskReadLogicalSectors() DriveNumber: 0x%x SectorNumber: %I64d SectorCount: %d Buffer: 0x%x\n",
760+
TRACE("PcDiskReadLogicalSectors() DriveNumber: 0x%x SectorNumber: %I64u SectorCount: %u Buffer: 0x%x\n",
754761
DriveNumber, SectorNumber, SectorCount, Buffer);
755762

756763
/* 16-bit BIOS addressing limitation */

boot/freeldr/freeldr/arch/i386/pc98/pc98disk.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ Pc98DiskReadLogicalSectorsLBA(
226226

227227
/* If we get here then the read failed */
228228
DiskError("Disk Read Failed in LBA mode", RegsOut.b.ah);
229-
ERR("Disk Read Failed in LBA mode: %x (%s) (DriveNumber: 0x%x SectorNumber: %I64d SectorCount: %d)\n",
229+
ERR("Disk Read Failed in LBA mode: %x (%s) (DriveNumber: 0x%x SectorNumber: %I64u SectorCount: %u)\n",
230230
RegsOut.b.ah, DiskGetErrorCodeString(RegsOut.b.ah),
231231
DiskDrive->DaUa, SectorNumber, SectorCount);
232232

@@ -367,7 +367,7 @@ Pc98DiskReadLogicalSectorsCHS(
367367
if (RetryCount >= 3)
368368
{
369369
DiskError("Disk Read Failed in CHS mode, after retrying 3 times", RegsOut.b.ah);
370-
ERR("Disk Read Failed in CHS mode, after retrying 3 times: %x (%s) (DriveNumber: 0x%x SectorNumber: %I64d SectorCount: %d)\n",
370+
ERR("Disk Read Failed in CHS mode, after retrying 3 times: %x (%s) (DriveNumber: 0x%x SectorNumber: %I64u SectorCount: %u)\n",
371371
RegsOut.b.ah, DiskGetErrorCodeString(RegsOut.b.ah),
372372
DiskDrive->DaUa, SectorNumber, SectorCount);
373373
return FALSE;
@@ -476,11 +476,13 @@ InitScsiDrive(
476476
"Cylinders : 0x%x\n"
477477
"Heads : 0x%x\n"
478478
"Sects/Track: 0x%x\n"
479+
"Total Sects: 0x%llx\n"
479480
"Bytes/Sect : 0x%x\n",
480481
DaUa,
481482
DiskDrive->Geometry.Cylinders,
482483
DiskDrive->Geometry.Heads,
483484
DiskDrive->Geometry.SectorsPerTrack,
485+
DiskDrive->Geometry.Sectors,
484486
DiskDrive->Geometry.BytesPerSector);
485487

486488
return TRUE;
@@ -513,11 +515,13 @@ InitIdeDrive(
513515
"Cylinders : 0x%x\n"
514516
"Heads : 0x%x\n"
515517
"Sects/Track: 0x%x\n"
518+
"Total Sects: 0x%llx\n"
516519
"Bytes/Sect : 0x%x\n",
517520
UnitNumber,
518521
DiskDrive->Geometry.Cylinders,
519522
DiskDrive->Geometry.Heads,
520523
DiskDrive->Geometry.SectorsPerTrack,
524+
DiskDrive->Geometry.Sectors,
521525
DiskDrive->Geometry.BytesPerSector);
522526

523527
return TRUE;
@@ -586,11 +590,13 @@ InitHardDrive(
586590
"Cylinders : 0x%x\n"
587591
"Heads : 0x%x\n"
588592
"Sects/Track: 0x%x\n"
593+
"Total Sects: 0x%llx\n"
589594
"Bytes/Sect : 0x%x\n",
590595
DaUa,
591596
DiskDrive->Geometry.Cylinders,
592597
DiskDrive->Geometry.Heads,
593598
DiskDrive->Geometry.SectorsPerTrack,
599+
DiskDrive->Geometry.Sectors,
594600
DiskDrive->Geometry.BytesPerSector);
595601

596602
return TRUE;
@@ -701,11 +707,13 @@ InitFloppyDrive(
701707
"Cylinders : 0x%x\n"
702708
"Heads : 0x%x\n"
703709
"Sects/Track: 0x%x\n"
710+
"Total Sects: 0x%llx\n"
704711
"Bytes/Sect : 0x%x\n",
705712
DaUa,
706713
DiskDrive->Geometry.Cylinders,
707714
DiskDrive->Geometry.Heads,
708715
DiskDrive->Geometry.SectorsPerTrack,
716+
DiskDrive->Geometry.Sectors,
709717
DiskDrive->Geometry.BytesPerSector);
710718

711719
return TRUE;
@@ -838,7 +846,7 @@ Pc98DiskReadLogicalSectors(
838846
{
839847
PPC98_DISK_DRIVE DiskDrive;
840848

841-
TRACE("Pc98DiskReadLogicalSectors() DriveNumber: 0x%x SectorNumber: %I64d SectorCount: %d Buffer: 0x%x\n",
849+
TRACE("Pc98DiskReadLogicalSectors() DriveNumber: 0x%x SectorNumber: %I64u SectorCount: %u Buffer: 0x%x\n",
842850
DriveNumber, SectorNumber, SectorCount, Buffer);
843851

844852
/* 16-bit BIOS addressing limitation */

boot/freeldr/freeldr/arch/i386/xbox/xboxdisk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ XboxDiskReadLogicalSectors(
8686
{
8787
PDEVICE_UNIT DeviceUnit;
8888

89-
TRACE("XboxDiskReadLogicalSectors() DriveNumber: 0x%x SectorNumber: %I64d SectorCount: %d Buffer: 0x%x\n",
89+
TRACE("XboxDiskReadLogicalSectors() DriveNumber: 0x%x SectorNumber: %I64u SectorCount: %u Buffer: 0x%x\n",
9090
DriveNumber, SectorNumber, SectorCount, Buffer);
9191

9292
DeviceUnit = XboxDiskDriveNumberToDeviceUnit(DriveNumber);

boot/freeldr/freeldr/lib/cache/cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ BOOLEAN CacheReadDiskSectors(UCHAR DiskNumber, ULONGLONG StartSector, ULONG Sect
121121
ULONG BlockCount;
122122
ULONG Idx;
123123

124-
TRACE("CacheReadDiskSectors() DiskNumber: 0x%x StartSector: %I64d SectorCount: %d Buffer: 0x%x\n", DiskNumber, StartSector, SectorCount, Buffer);
124+
TRACE("CacheReadDiskSectors() DiskNumber: 0x%x StartSector: %I64u SectorCount: %u Buffer: 0x%x\n", DiskNumber, StartSector, SectorCount, Buffer);
125125

126126
// If we aren't initialized yet then they can't do this
127127
if (CacheManagerInitialized == FALSE)

boot/freeldr/freeldr/lib/fs/ext.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,15 +1328,9 @@ ARC_STATUS ExtRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count)
13281328
ULONGLONG BytesReadBig;
13291329
BOOLEAN Success;
13301330

1331-
//
1332-
// Read data
1333-
//
1331+
/* Read data */
13341332
Success = ExtReadFileBig(FileHandle, N, &BytesReadBig, Buffer);
13351333
*Count = (ULONG)BytesReadBig;
1336-
1337-
//
1338-
// Check for success
1339-
//
13401334
if (Success)
13411335
return ESUCCESS;
13421336
else

boot/freeldr/freeldr/lib/fs/fat.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,14 +1464,8 @@ ARC_STATUS FatRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count)
14641464
PFAT_FILE_INFO FileHandle = FsGetDeviceSpecific(FileId);
14651465
BOOLEAN Success;
14661466

1467-
//
1468-
// Call old read method
1469-
//
1467+
/* Call old read method */
14701468
Success = FatReadFile(FileHandle, N, Count, Buffer);
1471-
1472-
//
1473-
// Check for success
1474-
//
14751469
if (Success)
14761470
return ESUCCESS;
14771471
else

boot/freeldr/freeldr/lib/fs/ntfs.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static BOOLEAN NtfsDiskRead(PNTFS_VOLUME_INFO Volume, ULONGLONG Offset, ULONGLON
149149
ULONG ReadLength;
150150
ARC_STATUS Status;
151151

152-
TRACE("NtfsDiskRead - Offset: %I64d Length: %I64d\n", Offset, Length);
152+
TRACE("NtfsDiskRead - Offset: %I64u Length: %I64u\n", Offset, Length);
153153

154154
//
155155
// I. Read partial first sector if needed
@@ -831,16 +831,10 @@ ARC_STATUS NtfsRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count)
831831
PNTFS_FILE_HANDLE FileHandle = FsGetDeviceSpecific(FileId);
832832
ULONGLONG BytesRead64;
833833

834-
//
835-
// Read file
836-
//
834+
/* Read data */
837835
BytesRead64 = NtfsReadAttribute(FileHandle->Volume, FileHandle->DataContext, FileHandle->Offset, Buffer, N);
838836
FileHandle->Offset += BytesRead64;
839837
*Count = (ULONG)BytesRead64;
840-
841-
//
842-
// Check for success
843-
//
844838
if (BytesRead64 > 0)
845839
return ESUCCESS;
846840
else

0 commit comments

Comments
 (0)