Changeset 28 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm


Ignore:
Timestamp:
Aug 1, 2010, 5:57:24 PM (14 years ago)
Author:
aitotat
google:author:
aitotat
Message:
  • v1.1.1 broke booting from foreign drives, it is now fixed.
  • Improved error handling a bit.
  • Longer DRQ and IRQ timeouts to minimize write timouts with some (bad) CF cards.
  • Default boot menu drive should now be properly selected.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm

    r3 r28  
    22; Project name  :   IDE BIOS
    33; Created date  :   3.8.2007
    4 ; Last update   :   2.5.2010
     4; Last update   :   1.8.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Int 19h BIOS functions (Boot Strap Loader).
     
    1010
    1111B_READ_RETRY_TIMES  EQU 3   ; Number of times to retry
    12 B_READ_RETRY_DELAY  EQU 3   ; Timer ticks between retries
    1312
    1413
     
    110109ALIGN JUMP_ALIGN
    111110.ReadRetryLoop:
    112     call    Int19h_LoadFirstSectorFromDLToESBX
     111    call    .ResetBootDriveFromDL
     112    call    .LoadFirstSectorFromDLtoESBX
    113113    jnc     SHORT .Return
    114     call    Int19h_ResetDriveOrWait
    115114    dec     di                              ; Decrement retry counter
    116115    jnz     SHORT .ReadRetryLoop            ; Loop while retries left
     
    121120
    122121;--------------------------------------------------------------------
     122; .ResetBootDriveFromDL
     123;   Parameters:
     124;       DL:     Drive to boot from (translated, 00h or 80h)
     125;   Returns:
     126;       AH:     INT 13h error code
     127;       CF:     Cleared if read successfull
     128;               Set if any error
     129;   Corrupts registers:
     130;       AL
     131;--------------------------------------------------------------------
     132ALIGN JUMP_ALIGN
     133.ResetBootDriveFromDL:
     134    xor     ax, ax                          ; AH=0h, Disk Controller Reset
     135    test    dl, 80h                         ; Floppy drive?
     136    jz      SHORT .ResetDriveFromDL         ;  If so, jump to reset
     137    mov     ah, 0Dh                         ; AH=Dh, Reset Hard Disk (Alternate reset)
     138.ResetDriveFromDL:
     139    int     INTV_DISK_FUNC
     140    ret
     141
     142;--------------------------------------------------------------------
    123143; Reads first sector (boot sector) from drive DL to ES:BX.
    124144;
    125 ; Int19h_LoadFirstSectorFromDLToESBX
     145; .LoadFirstSectorFromDLtoESBX
    126146;   Parameters:
    127147;       DL:     Drive to boot from (translated, 00h or 80h)
     
    136156;--------------------------------------------------------------------
    137157ALIGN JUMP_ALIGN
    138 Int19h_LoadFirstSectorFromDLToESBX:
     158.LoadFirstSectorFromDLtoESBX:
    139159    mov     ax, 0201h                       ; Read 1 sector
    140160    mov     cx, 1                           ; Cylinder 0, Sector 1
    141161    xor     dh, dh                          ; Head 0
    142162    int     INTV_DISK_FUNC
    143     ret
    144 
    145 
    146 ;--------------------------------------------------------------------
    147 ; Reset drive controller or waits a while before retrying
    148 ; to load boot sector.
    149 ;
    150 ; Int19h_ResetDriveOrWait
    151 ;   Parameters:
    152 ;       DL:     Drive to boot from (translated, 00h or 80h)
    153 ;       DI:     Retry counter
    154 ;   Returns:
    155 ;       Nothing
    156 ;   Corrupts registers:
    157 ;       CX
    158 ;--------------------------------------------------------------------
    159 ALIGN JUMP_ALIGN
    160 Int19h_ResetDriveOrWait:
    161     test    di, 1<<0                        ; Reset on every other retry
    162     jnz     SHORT .ResetDrive
    163     mov     cx, B_READ_RETRY_DELAY          ; Wait for a while
    164     jmp     SoftDelay_TimerTicks
    165 ALIGN JUMP_ALIGN
    166 .ResetDrive:
    167     xor     cx, cx
    168     xchg    cx, ax                          ; AH=0h, Disk Controller Reset
    169     int     INTV_DISK_FUNC
    170     xchg    ax, cx                          ; Restore AX
    171163    ret
    172164
Note: See TracChangeset for help on using the changeset viewer.