diff --git a/freeldr/freeldr/asmcode.S b/freeldr/freeldr/asmcode.S index d638a33a81e..29068bc0612 100644 --- a/freeldr/freeldr/asmcode.S +++ b/freeldr/freeldr/asmcode.S @@ -394,6 +394,8 @@ _biosdisk_retval: .long 0 _biosdisk_retrycount: .byte 0 +_biosdisk_error_code: + .byte 0 EXTERN(_BiosInt13Read) .code32 @@ -459,6 +461,8 @@ _biosdisk_read: _biosdisk_error: + movb %ah,_biosdisk_error_code// Save the error code + cmpb $0x11,%ah // Check and see if it was a corrected ECC error je _biosdisk_done // If so then the data is still good, if not fail @@ -570,6 +574,8 @@ _int13_extended_read: _int13_extended_error: + movb %ah,_biosdisk_error_code // Save the error code + cmpb $0x11,%ah // Check and see if it was a corrected ECC error je _int13_extended_done // If so then the data is still good, if not fail @@ -666,6 +672,16 @@ _int13_extension_check_done: pop %ebp ret +/* + * ULONG BiosInt13GetLastErrorCode(VOID); + */ +EXTERN(_BiosInt13GetLastErrorCode) + .code32 + + movzbl _biosdisk_error_code,%eax // Get return value + + ret + /* * int getyear(void); */ diff --git a/freeldr/freeldr/disk.h b/freeldr/freeldr/disk.h index 016a6a754b0..f00a6228399 100644 --- a/freeldr/freeldr/disk.h +++ b/freeldr/freeldr/disk.h @@ -40,6 +40,7 @@ int biosdisk(int cmd, int drive, int head, int track, int sector, int nsects, v BOOL BiosInt13Read(ULONG Drive, ULONG Head, ULONG Track, ULONG Sector, ULONG SectorCount, PVOID Buffer); // Implemented in asmcode.S BOOL BiosInt13ReadExtended(ULONG Drive, ULONG Sector, ULONG SectorCount, PVOID Buffer); // Implemented in asmcode.S BOOL BiosInt13ExtensionsSupported(ULONG Drive); +ULONG BiosInt13GetLastErrorCode(VOID); void stop_floppy(void); // Implemented in asmcode.S int get_heads(int drive); // Implemented in asmcode.S diff --git a/freeldr/freeldr/disk/disk.c b/freeldr/freeldr/disk/disk.c index de371cc4c55..8017f9520dc 100644 --- a/freeldr/freeldr/disk/disk.c +++ b/freeldr/freeldr/disk/disk.c @@ -32,15 +32,19 @@ VOID DiskError(PUCHAR ErrorString) { - DbgPrint((DPRINT_DISK, "%s\n", ErrorString)); + UCHAR ErrorCodeString[80]; + + sprintf(ErrorCodeString, "%s\nError Code: 0x%x", ErrorString, BiosInt13GetLastErrorCode()); + + DbgPrint((DPRINT_DISK, "%s\n", ErrorCodeString)); if (UserInterfaceUp) { - MessageBox(ErrorString); + MessageBox(ErrorCodeString); } else { - printf("%s", ErrorString); + printf("%s", ErrorCodeString); printf("\nPress any key\n"); getch(); }