Changeset 27 in xtideuniversalbios


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.
Location:
trunk/XTIDE_Universal_BIOS
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Doc/changes.txt

    r26 r27  
    1 XTIDE Universal BIOS v1.1.2 (26 July 2010)
    2 *Fixed a bug where Disk Parameter Table was accessed with wrong pointer register after writing last block
    3 *Cleaned AH=00h, Disk Controller Reset a bit
     1XTIDE Universal BIOS v1.1.2 (28 July 2010)
     2  * v1.1.1 broke booting from foreign drives, it is now fixed.
     3  * Fixed a bug where Disk Parameter Table was accessed with wrong pointer register after writing last block.
     4  * Cleaned AH=00h, Disk Controller Reset a bit.
     5  * Timeout errors might now get translated for better error codes on certain situations.
    46
    57
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm

    r3 r27  
    8888Int13h_UnsupportedFunction:
    8989Int13h_DirectCallToAnotherBios:
    90     ; Temporarily store original DI and DS to RAMVARS
     90    ; Temporarily store original DI and DS from stack to RAMVARS
    9191    pop     WORD [RAMVARS.wI13hDI]
    9292    pop     WORD [RAMVARS.wI13hDS]
  • 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
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm

    r26 r27  
    22; Project name  :   IDE BIOS
    33; Created date  :   9.12.2007
    4 ; Last update   :   26.7.2010
     4; Last update   :   28.7.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Int 13h function AH=Dh, Reset Hard Disk (Alternate reset).
     
    4040;       CF:     0 if succesfull, 1 if error
    4141;   Corrupts registers:
    42 ;       Nothing
     42;       DI
    4343;--------------------------------------------------------------------
    4444ALIGN JUMP_ALIGN
    4545AHDh_ResetDrive:
    46     push    di
    4746    push    dx
    4847    push    cx
     
    6463    pop     cx
    6564    pop     dx
    66     pop     di
    6765    ret
    6866
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HError.asm

    r3 r27  
    22; Project name  :   IDE BIOS
    33; Created date  :   30.11.2007
    4 ; Last update   :   8.4.2010
     4; Last update   :   28.7.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Error checking functions for BIOS Hard disk functions.
     
    88; Section containing code
    99SECTION .text
     10
     11;--------------------------------------------------------------------
     12; HError_GetErrorCodeToAHforBitPollingTimeout
     13;   Parameters:
     14;       AL:     IDE Status Register contents
     15;       DX:     IDE Status Register Address
     16;   Returns:
     17;       AH:     Hard disk BIOS error code
     18;       CF:     Set since error
     19;   Corrupts registers:
     20;       AL, CX
     21;--------------------------------------------------------------------
     22ALIGN JUMP_ALIGN
     23HError_GetErrorCodeToAHforBitPollingTimeout:
     24    test    al, FLG_IDE_ST_BSY                      ; Other bits undefined when BSY set
     25    jnz     SHORT HError_GetErrorCodeForStatusReg   ; Busy, normal timeout
     26    test    al, FLG_IDE_ST_DF | FLG_IDE_ST_CORR | FLG_IDE_ST_ERR
     27    jnz     SHORT HError_GetErrorCodeForStatusReg   ; Not busy but some error
     28    or      al, FLG_IDE_ST_BSY                      ; Polled bit got never set, force timeout
     29    ; Fall to HError_GetErrorCodeForStatusReg
    1030
    1131;--------------------------------------------------------------------
     
    3757    mov     [HDBDA.wHDStAndErr], ax         ; Store Status and Error to BDA
    3858    pop     ds
    39 
    40     ; Translate registers to BIOS error code
    4159    ; Fall to HError_ConvertIdeErrorToBiosRet
    4260
     
    5876ALIGN JUMP_ALIGN
    5977HError_ConvertIdeErrorToBiosRet:
    60     ; Any error?
     78    test    al, FLG_IDE_ST_BSY
     79    jnz     SHORT .TimeoutError
    6180    test    al, FLG_IDE_ST_DF | FLG_IDE_ST_CORR | FLG_IDE_ST_ERR
    6281    jnz     SHORT .ReadErrorFromStatusReg
    6382    xor     ah, ah                  ; No errors, zero AH and CF
     83    ret
     84
     85.TimeoutError:
     86    mov     ah, RET_HD_TIMEOUT
     87    stc
    6488    ret
    6589
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HStatus.asm

    r26 r27  
    22; Project name  :   IDE BIOS
    33; Created date  :   15.12.2009
    4 ; Last update   :   26.6.2010
     4; Last update   :   28.7.2010
    55; Author        :   Tomi Tilli
    66; Description   :   IDE Status Register polling functions.
     
    189189; IDE Status register polling.
    190190; This function first waits until controller is not busy.
    191 ; When not busy, IDE Status Register is polled until wanted
    192 ; flag (HBIT_ST_DRDY or HBIT_ST_DRQ) is set.
     191; When not busy, IDE Status Register is polled until wanted flag is set.
    193192;
    194193; HStatus_PollBusyAndFlg
     
    207206ALIGN JUMP_ALIGN
    208207HStatus_PollBsyAndFlg:
    209     call    SoftDelay_InitTimeout       ; Initialize timeout counter
     208    call    SoftDelay_InitTimeout               ; Initialize timeout counter
    210209ALIGN JUMP_ALIGN
    211210.PollLoop:
    212     in      al, dx                      ; Load IDE Status Register
    213     test    al, FLG_IDE_ST_BSY          ; Controller busy?
    214     jnz     SHORT .UpdateTimeout        ;  If so, jump to timeout update
    215     test    al, ah                      ; Test secondary flag
    216     jnz     SHORT HStatus_PollCompleted ; If set, break loop
     211    in      al, dx                              ; Load IDE Status Register
     212    test    al, FLG_IDE_ST_BSY                  ; Controller busy?
     213    jnz     SHORT .UpdateTimeout                ;  If so, jump to timeout update
     214    test    al, ah                              ; Test secondary flag
     215    jnz     SHORT GetErrorCodeFromPollingToAH   ; If set, break loop
    217216ALIGN JUMP_ALIGN
    218217.UpdateTimeout:
    219     call    SoftDelay_UpdTimeout        ; Update timeout counter
    220     jnc     SHORT .PollLoop             ; Loop if time left (sets CF on timeout)
    221     mov     ah, RET_HD_TIMEOUT          ; Load error code for timeout
    222     ret
    223 
     218    call    SoftDelay_UpdTimeout                ; Update timeout counter
     219    jnc     SHORT .PollLoop                     ; Loop if time left (sets CF on timeout)
     220    jmp     HError_GetErrorCodeToAHforBitPollingTimeout
    224221
    225222;--------------------------------------------------------------------
     
    241238ALIGN JUMP_ALIGN
    242239HStatus_PollBsy:
    243     call    SoftDelay_InitTimeout       ; Initialize timeout counter
     240    call    SoftDelay_InitTimeout               ; Initialize timeout counter
    244241ALIGN JUMP_ALIGN
    245242.PollLoop:
    246     in      al, dx                      ; Load IDE Status Reg
    247     test    al, FLG_IDE_ST_BSY          ; Controller busy? (clears CF)
    248     jz      SHORT HStatus_PollCompleted ;  If not, jump to check errors
    249     call    SoftDelay_UpdTimeout        ; Update timeout counter
    250     jnc     SHORT .PollLoop             ; Loop if time left (sets CF on timeout)
    251     mov     ah, RET_HD_TIMEOUT          ; Load error code for timeout
    252     ret
    253 
    254 ALIGN JUMP_ALIGN
    255 HStatus_PollCompleted:
    256     test    al, FLG_IDE_ST_DF | FLG_IDE_ST_ERR
    257     jnz     SHORT .GetErrorCode         ;  If errors, jump to get error code
    258     xor     ah, ah                      ; Zero AH and clear CF
    259     ret
    260 .GetErrorCode:
     243    in      al, dx                              ; Load IDE Status Reg
     244    test    al, FLG_IDE_ST_BSY                  ; Controller busy?
     245    jz      SHORT GetErrorCodeFromPollingToAH   ;  If not, jump to check errors
     246    call    SoftDelay_UpdTimeout                ; Update timeout counter
     247    jnc     SHORT .PollLoop                     ; Loop if time left (sets CF on timeout)
     248ALIGN JUMP_ALIGN
     249GetErrorCodeFromPollingToAH:
    261250    jmp     HError_GetErrorCodeForStatusReg
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm

    r3 r27  
    22; Project name  :   IDE BIOS
    33; Created date  :   25.3.2010
    4 ; Last update   :   2.5.2010
     4; Last update   :   28.7.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Various floppy drive related functions that
     
    2525FloppyDrive_IsInt40hInstalled:
    2626    cmp     WORD [es:INTV_FLOPPY_FUNC*4+2], 0C000h  ; Any ROM segment?
    27     jae     SHORT .Int40hIsAlreadyInstalled
    28     clc
    29     ret
    30 ALIGN JUMP_ALIGN
    31 .Int40hIsAlreadyInstalled:
    32     stc
     27    cmc
    3328    ret
    3429
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm

    r23 r27  
    22; Project name  :   IDE BIOS
    33; Created date  :   23.3.2010
    4 ; Last update   :   1.7.2010
     4; Last update   :   28.7.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for initializing the BIOS.
     
    418418ALIGN JUMP_ALIGN
    419419Initialize_ResetDetectedDrives:
    420     xor     ah, ah              ; Disk Controller Reset
    421     mov     dl, 80h             ; Reset all floppy drives and hard disks
    422     int     INTV_DISK_FUNC
    423     ret
     420    xor     bx, bx
     421    call    ResetFloppyDrivesWithInt40h
     422    mov     bl, 80h
     423    call    ResetForeignHardDisks
     424    jmp     AH0h_ResetHardDisksHandledByOurBIOS
  • trunk/XTIDE_Universal_BIOS/Src/Main.asm

    r26 r27  
    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/26/10"      ; Build data (mm/dd/yy)
     40    at  ROMVARS.rgbDate,    db  "07/28/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.2 (07/26/10)",STOP
     51    at  ROMVARS.szVersion,  db  "v1.1.2 (07/28/10)",STOP
    5252
    5353;---------------------------;
Note: See TracChangeset for help on using the changeset viewer.