Changeset 26 in xtideuniversalbios


Ignore:
Timestamp:
Jul 26, 2010, 6:30:33 PM (14 years ago)
Author:
aitotat
google:author:
aitotat
Message:

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

Location:
trunk/XTIDE_Universal_BIOS
Files:
2 added
6 edited

Legend:

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

    r23 r26  
    22; Project name  :   IDE BIOS
    33; Created date  :   27.9.2007
    4 ; Last update   :   1.7.2010
     4; Last update   :   26.7.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Int 13h function AH=0h, Disk Controller Reset.
     
    3737
    3838    eMOVZX  bx, dl                      ; Copy requested drive to BL, zero BH to assume no errors
    39     call    AH0h_ResetFloppyDrivesWithInt40h
    40     test    bl, 80h                     ; Reset hard disks too?
    41     jz      SHORT .Return
    42     call    AH0h_ResetForeignHardDisks
    43     call    AH0h_ResetAllOurControllers
     39    call    ResetFloppyDrivesWithInt40h
     40    test    bl, 80h
     41    jz      SHORT .SkipHardDiskReset
     42    call    ResetForeignHardDisks
     43    call    ResetHardDisksHandledByOurBIOS
    4444ALIGN JUMP_ALIGN
    45 .Return:
     45.SkipHardDiskReset:
    4646    mov     ah, bh                      ; Copy error code to AH
    4747    xor     al, al                      ; Zero AL...
     
    5151
    5252;--------------------------------------------------------------------
    53 ; AH0h_ResetFloppyDrivesWithInt40h
     53; ResetFloppyDrivesWithInt40h
    5454;   Parameters:
    5555;       BL:     Requested drive (DL when entering AH=00h)
     
    6161;--------------------------------------------------------------------   
    6262ALIGN JUMP_ALIGN
    63 AH0h_ResetFloppyDrivesWithInt40h:
    64     xor     ax, ax                      ; Disk Controller Reset
     63ResetFloppyDrivesWithInt40h:
     64    xor     ah, ah                      ; Disk Controller Reset
    6565    and     dl, 7Fh                     ; Clear bit 7
    6666    int     INTV_FLOPPY_FUNC
    67     jmp     SHORT AH0h_BackupErrorCodeFromTheRequestedDriveToBH
     67    jmp     SHORT BackupErrorCodeFromTheRequestedDriveToBH
    6868
    6969
    7070;--------------------------------------------------------------------
    71 ; AH0h_ResetForeignHardDisks
     71; ResetForeignHardDisks
    7272;   Parameters:
    7373;       BL:     Requested drive (DL when entering AH=00h)
     
    7979;--------------------------------------------------------------------   
    8080ALIGN JUMP_ALIGN
    81 AH0h_ResetForeignHardDisks:
    82     mov     cl, [RAMVARS.bFirstDrv]     ; Load number of first our drive
    83     and     cx, BYTE 7Fh                ; CX = number of drives to reset
    84     jz      SHORT .Return
    85     mov     dl, 80h                     ; Start resetting from drive 80h
    86 ALIGN JUMP_ALIGN
    87 .DriveResetLoop:
     81ResetForeignHardDisks:
     82    mov     dl, bl                      ; Drive to reset
    8883    mov     ah, 0Dh                     ; Reset Hard Disk (Alternate reset)
     84
    8985    pushf                               ; Push flags to simulate INT
    9086    cli                                 ; Disable interrupts since INT does that
    9187    call    FAR [RAMVARS.fpOldI13h]
    9288    sti                                 ; Make sure interrupts are enabled again (some BIOSes fails to enable it)
    93     call    AH0h_BackupErrorCodeFromTheRequestedDriveToBH
    94     inc     dx                          ; Next drive to reset
    95     loop    .DriveResetLoop
    96 ALIGN JUMP_ALIGN
    97 .Return:
    98     ret
     89
     90    jmp     SHORT BackupErrorCodeFromTheRequestedDriveToBH
    9991
    10092
    10193;--------------------------------------------------------------------
    102 ; AH0h_ResetAllOurControllers
     94; ResetHardDisksHandledByOurBIOS
    10395;   Parameters:
    10496;       BL:     Requested drive (DL when entering AH=00h)
     
    10799;       BH:     Error code from requested drive (if available)
    108100;   Corrupts registers:
    109 ;       AX, CX, DX, DI
     101;       AX, CX, DX
    110102;--------------------------------------------------------------------
    111103ALIGN JUMP_ALIGN
    112 AH0h_ResetAllOurControllers:
    113     push    si
    114     mov     si, ROMVARS.ideVars0            ; Load offset to first IDEVARS
    115     call    Initialize_GetIdeControllerCountToCX
     104ResetHardDisksHandledByOurBIOS:
     105    mov     dh, [RAMVARS.bDrvCnt]       ; Load drive count to DH
     106    test    dh, dh
     107    jz      SHORT .AllDrivesReset       ; Return if no drives
     108    mov     dl, [RAMVARS.bFirstDrv]     ; Load number of first our drive
     109    add     dh, dl                      ; DH = one past last drive to reset
    116110ALIGN JUMP_ALIGN
    117 .ResetLoop:
    118     call    AH0h_ResetIdevarsControllerMasterAndSlaveDrives
    119     add     si, BYTE IDEVARS_size
    120     loop    .ResetLoop
    121 .Return:
    122     pop     si
     111.DriveResetLoop:
     112    call    AHDh_ResetDrive
     113    call    BackupErrorCodeFromTheRequestedDriveToBH
     114    call    .SkipNextDriveIfItIsSlaveForThisController
     115    inc     dx
     116    cmp     dl, dh                      ; All done?
     117    jb      SHORT .DriveResetLoop       ;  If not, reset next drive
     118.AllDrivesReset:
     119    ret
     120
     121;--------------------------------------------------------------------
     122; .SkipNextDriveIfItIsSlaveForThisController
     123;   Parameters:
     124;       DL:     Drive just resetted
     125;       DS:     RAMVARS segment
     126;   Returns:
     127;       DL:     Incremented if next drive is slave drive
     128;               (=already resetted)
     129;   Corrupts registers:
     130;       AX, CX
     131;--------------------------------------------------------------------
     132ALIGN JUMP_ALIGN
     133.SkipNextDriveIfItIsSlaveForThisController:
     134    push    di
     135
     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;--------------------------------------------------------------------
     163ALIGN 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:
    123170    ret
    124171
    125172
    126173;--------------------------------------------------------------------
    127 ; AH0h_ResetIdevarsControllerMasterAndSlaveDrives
    128 ;   Parameters:
    129 ;       BL:     Requested drive (DL when entering AH=00h)
    130 ;       CS:SI:  Ptr to IDEVARS
    131 ;       DS:     RAMVARS segment
    132 ;   Returns:
    133 ;       BH:     Error code from requested drive (if available)
    134 ;   Corrupts registers:
    135 ;       AX, DX, DI
    136 ;--------------------------------------------------------------------
    137 ALIGN JUMP_ALIGN
    138 AH0h_ResetIdevarsControllerMasterAndSlaveDrives:
    139     mov     dx, [cs:si+IDEVARS.wPort]
    140     call    FindDPT_ForIdeMasterAtPort      ; Find master drive to DL
    141     jc      SHORT AH0h_ResetMasterAndSlaveDriveWithRetries
    142     call    FindDPT_ForIdeSlaveAtPort       ; Find slave if master not present
    143     jc      SHORT AH0h_ResetMasterAndSlaveDriveWithRetries
    144     ret
    145 
    146 ;--------------------------------------------------------------------
    147 ; AH0h_ResetMasterAndSlaveDriveWithRetries
    148 ;   Parameters:
    149 ;       BL:     Requested drive (DL when entering AH=00h)
    150 ;       DL:     Drive number for master or slave drive
    151 ;       DS:     RAMVARS segment
    152 ;   Returns:
    153 ;       BH:     Error code from requested drive (if available)
    154 ;   Corrupts registers:
    155 ;       AX, DI
    156 ;--------------------------------------------------------------------
    157 ALIGN JUMP_ALIGN
    158 AH0h_ResetMasterAndSlaveDriveWithRetries:
    159     push    dx
    160     push    cx
    161     push    bx
    162     mov     di, RETRIES_IF_RESET_FAILS
    163 ALIGN JUMP_ALIGN
    164 .RetryLoop:
    165     call    AHDh_ResetDrive
    166     jnc     SHORT .Return               ; Jump if successful
    167     mov     cx, TIMEOUT_BEFORE_RESET_RETRY
    168     call    SoftDelay_TimerTicks
    169     dec     di
    170     jnz     SHORT .RetryLoop
    171 ALIGN JUMP_ALIGN
    172 .Return:
    173     pop     bx
    174     pop     cx
    175     pop     dx
    176     ; Fall to AH0h_BackupErrorCodeFromTheRequestedDriveToBH
    177 
    178 ;--------------------------------------------------------------------
    179 ; AH0h_BackupErrorCodeFromTheRequestedDriveToBH
     174; BackupErrorCodeFromTheRequestedDriveToBH
    180175;   Parameters:
    181176;       AH:     Error code from the last resetted drive
     
    188183;--------------------------------------------------------------------
    189184ALIGN JUMP_ALIGN
    190 AH0h_BackupErrorCodeFromTheRequestedDriveToBH:
    191     cmp     dl, bl                      ; Requested drive?
     185BackupErrorCodeFromTheRequestedDriveToBH:
     186    cmp     dl, bl              ; Requested drive?
    192187    jne     SHORT .Return
    193188    mov     bh, ah
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm

    r3 r26  
    22; Project name  :   IDE BIOS
    33; Created date  :   9.12.2007
    4 ; Last update   :   12.4.2010
     4; Last update   :   26.7.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Int 13h function AH=Dh, Reset Hard Disk (Alternate reset).
     
    2525ALIGN JUMP_ALIGN
    2626AHDh_HandlerForResetHardDisk:
    27     push    dx
    28     push    cx
    29     push    bx
    30     push    ax
    3127    call    AHDh_ResetDrive
    32     jmp     Int13h_PopXRegsAndReturn
     28    jmp     Int13h_PopDiDsAndReturn
    3329
    3430
     
    4440;       CF:     0 if succesfull, 1 if error
    4541;   Corrupts registers:
    46 ;       AL, BX, CX, DX
     42;       Nothing
    4743;--------------------------------------------------------------------
    4844ALIGN JUMP_ALIGN
    4945AHDh_ResetDrive:
    5046    push    di
     47    push    dx
     48    push    cx
     49    push    bx
     50    push    ax
     51
    5152    call    FindDPT_ForDriveNumber      ; DS:DI now points to DPT
    5253    call    AHDh_ResetMasterAndSlave
     
    5758    mov     dx, [RAMVARS.wIdeBase]      ; Load base port address
    5859    call    AHDh_InitializeMasterAndSlave
    59     jc      SHORT .ReturnError
    60     xor     ax, ax                      ; Clear AH since success
    61     pop     di
    62     ret
    63 .ReturnError:
    64     mov     ah, RET_HD_RESETFAIL        ; Load Reset Failed error code
     60
     61    pop     bx                          ; Pop old AX
     62    mov     al, bl                      ; Restore AL
     63    pop     bx
     64    pop     cx
     65    pop     dx
    6566    pop     di
    6667    ret
     
    110111;       DX:     IDE Base Port address
    111112;   Returns:
     113;       AH:     Error code
    112114;       CF:     0 if initialization succesfull
    113115;               1 if any error
    114116;   Corrupts registers:
    115 ;       AX, BX, CX, DX, DI
     117;       AL, BX, CX, DX, DI
    116118;--------------------------------------------------------------------
    117119ALIGN JUMP_ALIGN
     
    136138    ret
    137139.ReturnError:
     140    mov     ah, RET_HD_RESETFAIL        ; Load Reset Failed error code
    138141    stc
    139142    ret
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HPIO.asm

    r3 r26  
    232232HPIO_WriteToDrive:
    233233    cld                                     ; OUTS to increment SI
    234     call    HStatus_WaitDrqDefTime          ; Always poll DRQ for first block
     234    call    HStatus_WaitDrqDefTime          ; Always poll DRQ for first block, get data port to DX
    235235    jc      SHORT .RetError                 ; Return if error (code in AH)
    236236    sub     dx, BYTE REGR_IDE_ST            ; DX to Data Port address
     
    251251    jmp     HStatus_WaitIrqOrRdy            ; Check for errors
    252252
    253    
     253
    254254;--------------------------------------------------------------------
    255255; Bus specific transfer functions and lookup table.
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HStatus.asm

    r10 r26  
    22; Project name  :   IDE BIOS
    33; Created date  :   15.12.2009
    4 ; Last update   :   25.5.2010
     4; Last update   :   26.6.2010
    55; Author        :   Tomi Tilli
    66; Description   :   IDE Status Register polling functions.
     
    2525ALIGN JUMP_ALIGN
    2626HStatus_WaitIrqOrRdy:
    27     test    BYTE [di+DPT.bDrvCtrl], FLG_IDE_CTRL_nIEN
     27    test    BYTE [bx+DPT.bDrvCtrl], FLG_IDE_CTRL_nIEN
    2828    jnz     SHORT .PollRdySinceIrqsAreDisabled
    2929    jmp     HIRQ_WaitIRQ
  • trunk/XTIDE_Universal_BIOS/Src/Main.asm

    r23 r26  
    22; Project name  :   XTIDE Universal BIOS
    33; Created date  :   28.7.2007
    4 ; Last update   :   1.7.2010
     4; Last update   :   26.7.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Main file for BIOS. This is the only file that needs
     
    3838    at  ROMVARS.bRomSize,   db  CNT_ROM_BLOCKS  ; ROM size in 512B blocks
    3939    at  ROMVARS.rgbJump,    jmp Initialize_FromMainBiosRomSearch
    40     at  ROMVARS.rgbDate,    db  "07/01/10"      ; Build data (mm/dd/yy)
     40    at  ROMVARS.rgbDate,    db  "07/26/10"      ; Build data (mm/dd/yy)
    4141    at  ROMVARS.rgbSign,    db  "XTIDE110"      ; Signature for flash program
    4242    at  ROMVARS.szTitle
     
    4949        db  " (XT)=-",STOP
    5050%endif
    51     at  ROMVARS.szVersion,  db  "v1.1.1 (07/01/10)",STOP
     51    at  ROMVARS.szVersion,  db  "v1.1.2 (07/26/10)",STOP
    5252
    5353;---------------------------;
Note: See TracChangeset for help on using the changeset viewer.