Improved disk error reporting
authorBrian Palmer <brianp@sginet.com>
Tue, 22 Jan 2002 23:56:08 +0000 (23:56 +0000)
committerBrian Palmer <brianp@sginet.com>
Tue, 22 Jan 2002 23:56:08 +0000 (23:56 +0000)
svn path=/trunk/; revision=2544

freeldr/freeldr/asmcode.S
freeldr/freeldr/disk.h
freeldr/freeldr/disk/disk.c

index d638a33..29068bc 100644 (file)
@@ -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);
  */
index 016a6a7..f00a622 100644 (file)
@@ -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
index de371cc..8017f95 100644 (file)
 
 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();
        }