Ignore:
Timestamp:
Jul 28, 2010, 6:53:32 PM (14 years ago)
Author:
aitotat
google:author:
aitotat
Message:
  • v1.1.1 broke booting from foreign drives, it is now fixed.
  • Fixed a bug where Disk Parameter Table was accessed with wrong pointer register after writing last block.
  • Cleaned AH=00h, Disk Controller Reset a bit.
  • Timeout errors might now get translated for better error codes on certain situations.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm

    r26 r27  
    22; Project name  :   IDE BIOS
    33; Created date  :   27.9.2007
    4 ; Last update   :   26.7.2010
     4; Last update   :   28.7.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Int 13h function AH=0h, Disk Controller Reset.
     
    4141    jz      SHORT .SkipHardDiskReset
    4242    call    ResetForeignHardDisks
    43     call    ResetHardDisksHandledByOurBIOS
     43    call    AH0h_ResetHardDisksHandledByOurBIOS
    4444ALIGN JUMP_ALIGN
    4545.SkipHardDiskReset:
    4646    mov     ah, bh                      ; Copy error code to AH
    4747    xor     al, al                      ; Zero AL...
    48     sub     al, ah                      ; ...and set CF if error
     48    cmp     al, bh                      ; ...and set CF if error
    4949    jmp     Int13h_PopXRegsAndReturn
    5050
     
    5454;   Parameters:
    5555;       BL:     Requested drive (DL when entering AH=00h)
    56 ;       DL:     Drive number
    5756;   Returns:
    5857;       BH:     Error code from requested drive (if available)
    5958;   Corrupts registers:
    60 ;       AX, DL
     59;       AX, DL, DI
    6160;--------------------------------------------------------------------   
    6261ALIGN JUMP_ALIGN
    6362ResetFloppyDrivesWithInt40h:
     63    call    GetDriveNumberForForeignBiosesToDL
     64    and     dl, 7Fh                     ; Clear hard disk bit
    6465    xor     ah, ah                      ; Disk Controller Reset
    65     and     dl, 7Fh                     ; Clear bit 7
    6666    int     INTV_FLOPPY_FUNC
    6767    jmp     SHORT BackupErrorCodeFromTheRequestedDriveToBH
     
    7676;       BH:     Error code from requested drive (if available)
    7777;   Corrupts registers:
    78 ;       AX, DL
     78;       AX, DL, DI
    7979;--------------------------------------------------------------------   
    8080ALIGN JUMP_ALIGN
    8181ResetForeignHardDisks:
    82     mov     dl, bl                      ; Drive to reset
    83     mov     ah, 0Dh                     ; Reset Hard Disk (Alternate reset)
    84 
     82    call    GetDriveNumberForForeignBiosesToDL
     83    xor     ah, ah                      ; Disk Controller Reset
    8584    pushf                               ; Push flags to simulate INT
    8685    cli                                 ; Disable interrupts since INT does that
    8786    call    FAR [RAMVARS.fpOldI13h]
    8887    sti                                 ; Make sure interrupts are enabled again (some BIOSes fails to enable it)
     88    jmp     SHORT BackupErrorCodeFromTheRequestedDriveToBH
    8989
    90     jmp     SHORT BackupErrorCodeFromTheRequestedDriveToBH
     90
     91;--------------------------------------------------------------------
     92; GetDriveNumberForForeignBiosesToDL
     93;   Parameters:
     94;       BL:     Requested drive (DL when entering AH=00h)
     95;       DS:     RAMVARS segment
     96;   Returns:
     97;       DL:     BL if foreign drive
     98;               80h if our drive
     99;   Corrupts registers:
     100;       DI
     101;--------------------------------------------------------------------   
     102ALIGN JUMP_ALIGN
     103GetDriveNumberForForeignBiosesToDL:
     104    mov     dl, bl
     105    call    RamVars_IsDriveHandledByThisBIOS
     106    jc      SHORT .GetFirstDriveForForeignBios
     107    ret     ; Return what was in BL unmodified
     108ALIGN JUMP_ALIGN
     109.GetFirstDriveForForeignBios:
     110    mov     dl, 80h
     111    ret
    91112
    92113
     
    99120;       BH:     Error code from requested drive (if available)
    100121;   Corrupts registers:
    101 ;       AX, CX, DX
     122;       AX, CX, DX, DI
    102123;--------------------------------------------------------------------
    103124ALIGN JUMP_ALIGN
    104 ResetHardDisksHandledByOurBIOS:
     125AH0h_ResetHardDisksHandledByOurBIOS:
    105126    mov     dh, [RAMVARS.bDrvCnt]       ; Load drive count to DH
    106127    test    dh, dh
     
    111132.DriveResetLoop:
    112133    call    AHDh_ResetDrive
    113     call    BackupErrorCodeFromTheRequestedDriveToBH
    114     call    .SkipNextDriveIfItIsSlaveForThisController
     134    call    .BackupErrorCodeFromMasterOrSlaveToBH
    115135    inc     dx
    116136    cmp     dl, dh                      ; All done?
     
    120140
    121141;--------------------------------------------------------------------
    122 ; .SkipNextDriveIfItIsSlaveForThisController
     142; .BackupErrorCodeFromMasterOrSlaveToBH
    123143;   Parameters:
     144;       AH:     Error code for drive DL reset
     145;       BL:     Requested drive (DL when entering AH=00h)
    124146;       DL:     Drive just resetted
    125147;       DS:     RAMVARS segment
    126148;   Returns:
     149;       BH:     Backuped error code
    127150;       DL:     Incremented if next drive is slave drive
    128151;               (=already resetted)
    129152;   Corrupts registers:
    130 ;       AX, CX
     153;       CX, DI
    131154;--------------------------------------------------------------------
    132155ALIGN JUMP_ALIGN
    133 .SkipNextDriveIfItIsSlaveForThisController:
    134     push    di
     156.BackupErrorCodeFromMasterOrSlaveToBH:
     157    call    BackupErrorCodeFromTheRequestedDriveToBH
     158    mov     cx, [RAMVARS.wIdeBase]      ; Load base port for resetted drive
    135159
    136     call    .GetBasePortToAXfromDriveInDL
    137     xchg    cx, ax
    138 
    139     inc     dx
    140     call    .GetBasePortToAXfromDriveInDL
    141     jnc     SHORT .SkipNextDrive
    142 
    143     cmp     ax, cx
    144     je      SHORT .SkipNextDrive        ; Same controller so slave already reset
    145 
    146     dec     dx                          ; Restore DX
    147 .SkipNextDrive:
    148     pop     di
    149     ret
    150 
    151 ;--------------------------------------------------------------------
    152 ; .GetBasePortToAXfromDriveInDL
    153 ;   Parameters:
    154 ;       DL:     Drive whose base port to find
    155 ;       DS:     RAMVARS segment
    156 ;   Returns:
    157 ;       AX:     Base port (if drive found)
    158 ;       CF:     Set if drive found
    159 ;               Cleared if drive not found
    160 ;   Corrupts registers:
    161 ;       DI
    162 ;--------------------------------------------------------------------
    163 ALIGN JUMP_ALIGN
    164 .GetBasePortToAXfromDriveInDL:
    165     call    FindDPT_ForDriveNumber      ; Get DPT to DS:DI
    166     jnc     SHORT .DriveNotFound
    167     eMOVZX  di, BYTE [di+DPT.bIdeOff]   ; CS:DI now points to IDEVARS
    168     mov     ax, [cs:di+IDEVARS.wPort]
    169 .DriveNotFound:
     160    inc     dx                          ; DL to next drive
     161    call    FindDPT_ForDriveNumber      ; Get DPT to DS:DI, store port to RAMVARS
     162    jnc     SHORT .NoMoreDrivesOrNoSlaveDrive
     163    cmp     cx, [RAMVARS.wIdeBase]      ; Next drive is from same controller?
     164    je      SHORT BackupErrorCodeFromTheRequestedDriveToBH
     165.NoMoreDrivesOrNoSlaveDrive:
     166    dec     dx
    170167    ret
    171168
Note: See TracChangeset for help on using the changeset viewer.