Changes in / [30:20] in xtideuniversalbios


Ignore:
Files:
3 deleted
24 edited

Legend:

Unmodified
Added
Removed
  • /trunk/XTIDE_Universal_BIOS/Inc/Int13h.inc

    r30 r20  
    22; Project name  :   IDE BIOS
    33; Created date  :   23.3.2010
    4 ; Last update   :   29.7.2010
     4; Last update   :   23.3.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Equates used in INT 13h functions.
     
    4444B_TIMEOUT_BSY           EQU     (1000/55)   ; 1000 ms
    4545B_TIMEOUT_RDY           EQU     (1000/55)   ; 1000 ms
    46 B_TIMEOUT_DRQ           EQU     255         ;   14 s (some CF cards occasionally have long write delays)
     46B_TIMEOUT_DRQ           EQU     (5000/55)   ; 5000 ms
    4747B_TIMEOUT_DRVINFO       EQU     (500/55)    ;  500 ms
    4848B_TIMEOUT_RESET         EQU     255         ;   14 s
    49 
    5049
    5150
  • /trunk/XTIDE_Universal_BIOS/Inc/emulate.inc

    r30 r20  
    152152%ifndef USE_386
    153153    %ifidni %1, ax
     154        xor     ax, ax
    154155        mov     al, %2
    155         xor     ah, ah
    156156    %elifidni %1, bx
    157157        mov     bl, %2
    158158        xor     bh, bh      ; %2 may use BX in effective address
    159159    %elifidni %1, cx
     160        xor     cx, cx
    160161        mov     cl, %2
    161         xor     ch, ch
    162162    %elifidni %1, dx
     163        xor     dx, dx
    163164        mov     dl, %2
    164         xor     dh, dh
    165165    %else   ; SI, DI, BP (all may be used in effective address)
    166166        push    ax
     167        xor     ax, ax
    167168        mov     al, %2
    168         xor     ah, ah
    169169        xchg    ax, %1
    170170        pop     ax
  • /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenu.asm

    r30 r20  
    22; Project name  :   IDE BIOS
    33; Created date  :   25.3.2010
    4 ; Last update   :   29.7.2010
     4; Last update   :   1.4.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Displays Boot Menu.
     
    323323;       DS:     RAMVARS segment
    324324;   Returns:
    325 ;       CF:     Set if drive number is valid
     325;       SF:     Set if drive number is valid
    326326;               Clear if drive is not present in system
    327327;   Corrupts registers:
    328 ;       AX, CX
     328;       AX
    329329;--------------------------------------------------------------------
    330330ALIGN JUMP_ALIGN
     
    332332    test    dl, 80h                 ; Floppy drive?
    333333    jz      SHORT .IsFloppyDriveIsInSystem
    334     call    RamVars_GetDriveCounts  ; Hard Disk count to CX
    335     or      cl, 80h                 ; Set Hard Disk bit to CX
    336     jmp     SHORT .CompareDriveNumberToDriveCount
     334    call    RamVars_GetDriveCounts
     335    mov     ax, 7Fh                 ; Load mask to clear floppy bit
     336    and     ax, dx                  ; AX = Hard Disk index
     337    cmp     ax, cx                  ; Valid drive index?
     338    ret
     339ALIGN JUMP_ALIGN
    337340.IsFloppyDriveIsInSystem:
    338     call    FloppyDrive_GetCount    ; Floppy Drive count to CX
    339 .CompareDriveNumberToDriveCount:
     341    call    FloppyDrive_GetCount
    340342    cmp     dl, cl
    341343    ret
  • /trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuEvent.asm

    r30 r20  
    283283    mov     dl, [cs:ROMVARS.bBootDrv]   ; Default boot drive
    284284    call    BootMenu_IsDriveInSystem
    285     jnc     SHORT .DoNotSetDefaultMenuitem
    286     call    DriveXlate_SetDriveToSwap
     285    jns     SHORT .DoNotSetDefaultMenuitem
    287286    call    BootMenu_ConvertDriveToMenuitem
    288287    mov     ax, 1
  • /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm

    r30 r20  
    22; Project name  :   IDE BIOS
    33; Created date  :   21.9.2007
    4 ; Last update   :   1.8.2010
     4; Last update   :   12.4.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Int 13h BIOS functions (Floppy and Hard disk).
     
    5757    call    RamVars_IsFunctionHandledByThisBIOS
    5858    jnc     SHORT Int13h_DirectCallToAnotherBios
    59     ;DEBUG_PRINT_DRIVE_AND_FUNCTION
    6059
    6160    ; Jump to correct BIOS function
     
    8988Int13h_UnsupportedFunction:
    9089Int13h_DirectCallToAnotherBios:
    91     ; Temporarily store original DI and DS from stack to RAMVARS
     90    ; Temporarily store original DI and DS to RAMVARS
    9291    pop     WORD [RAMVARS.wI13hDI]
    9392    pop     WORD [RAMVARS.wI13hDS]
     
    148147;
    149148; Int13h_ReturnWithoutSwappingDrives
    150 ; Int13h_StoreErrorCodeToBDAandPopDSDIandReturn
    151 ; Int13h_StoreErrorCodeToBDAandPopXRegsAndReturn
    152149; Int13h_PopXRegsAndReturn
    153150; Int13h_PopDiDsAndReturn
     
    163160Int13h_ReturnWithoutSwappingDrives:
    164161    pushf
    165     dec     BYTE [RAMVARS.xlateVars+XLATEVARS.bRecurCnt]    ; Preserves CF
    166     call    HError_StoreBiosErrorCodeFromAHtoBDA
    167     jmp     SHORT Int13h_Leave
    168 
    169 ALIGN JUMP_ALIGN
    170 Int13h_StoreErrorCodeToBDAandPopDSDIandReturn:
    171     call    HError_StoreBiosErrorCodeFromAHtoBDA
    172     jmp     SHORT Int13h_PopDiDsAndReturn
    173 
    174 ALIGN JUMP_ALIGN
    175 Int13h_StoreErrorCodeToBDAandPopXRegsAndReturn:
    176     call    HError_StoreBiosErrorCodeFromAHtoBDA
     162    dec     BYTE [RAMVARS.xlateVars+XLATEVARS.bRecurCnt]
     163    jmp     SHORT Int13h_StoreErrorCodeAndLeave
    177164ALIGN JUMP_ALIGN
    178165Int13h_PopXRegsAndReturn:
     
    186173    pushf
    187174    call    DriveXlate_WhenLeavingInt13h
     175Int13h_StoreErrorCodeAndLeave:
     176    LOAD_BDA_SEGMENT_TO ds, di
     177    mov     [BDA.bHDLastSt], ah         ; Store error code
    188178Int13h_Leave:
    189179    popf
  • /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm

    r30 r20  
    22; Project name  :   IDE BIOS
    33; Created date  :   27.9.2007
    4 ; Last update   :   29.7.2010
     4; Last update   :   2.5.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Int 13h function AH=0h, Disk Controller Reset.
     
    2323;       DS:     RAMVARS segment
    2424;   Returns:
    25 ;       AH:     Int 13h return status (from drive requested in DL)
     25;       AH:     Int 13h return status
    2626;       CF:     0 if succesfull, 1 if error
    2727;       IF:     1
     
    3636    push    ax
    3737
    38     eMOVZX  bx, dl                      ; Copy requested drive to BL, zero BH to assume no errors
    39     call    ResetFloppyDrivesWithInt40h
    40     test    bl, 80h
    41     jz      SHORT .SkipHardDiskReset
    42     call    ResetForeignHardDisks
    43     call    AH0h_ResetHardDisksHandledByOurBIOS
    44 ALIGN JUMP_ALIGN
    45 .SkipHardDiskReset:
    46     mov     ah, bh                      ; Copy error code to AH
    47     xor     al, al                      ; Zero AL...
    48     cmp     al, bh                      ; ...and set CF if error
    49     jmp     Int13h_StoreErrorCodeToBDAandPopXRegsAndReturn
     38    test    dl, 80h                     ; Reset floppy drives only?
     39    jz      SHORT .ResetForeignControllers
     40    call    AH0h_ResetOurControllers
     41.ResetForeignControllers:
     42    call    AH0h_ResetFloppyAndForeignHardDiskControllers
     43    jmp     Int13h_PopXRegsAndReturn    ; Return since error
    5044
    5145
    5246;--------------------------------------------------------------------
    53 ; ResetFloppyDrivesWithInt40h
     47; Resets all IDE controllers handled by this BIOS.
     48;
     49; AH0h_ResetOurControllers
    5450;   Parameters:
    55 ;       BL:     Requested drive (DL when entering AH=00h)
    56 ;   Returns:
    57 ;       BH:     Error code from requested drive (if available)
    58 ;   Corrupts registers:
    59 ;       AX, DL, DI
    60 ;--------------------------------------------------------------------   
    61 ALIGN JUMP_ALIGN
    62 ResetFloppyDrivesWithInt40h:
    63     call    GetDriveNumberForForeignBiosesToDL
    64     and     dl, 7Fh                     ; Clear hard disk bit
    65     xor     ah, ah                      ; Disk Controller Reset
    66     int     INTV_FLOPPY_FUNC
    67     jmp     SHORT BackupErrorCodeFromTheRequestedDriveToBH
    68 
    69 
    70 ;--------------------------------------------------------------------
    71 ; ResetForeignHardDisks
    72 ;   Parameters:
    73 ;       BL:     Requested drive (DL when entering AH=00h)
    7451;       DS:     RAMVARS segment
    7552;   Returns:
    76 ;       BH:     Error code from requested drive (if available)
     53;       AH:     Int 13h return status
     54;       CF:     0 if succesfull, 1 if error
    7755;   Corrupts registers:
    78 ;       AX, DL, DI
    79 ;--------------------------------------------------------------------   
     56;       AL, BX, CX, DI
     57;--------------------------------------------------------------------
    8058ALIGN JUMP_ALIGN
    81 ResetForeignHardDisks:
    82     call    GetDriveNumberForForeignBiosesToDL
    83     xor     ah, ah                      ; Disk Controller Reset
    84     pushf                               ; Push flags to simulate INT
    85     cli                                 ; Disable interrupts since INT does that
    86     call    FAR [RAMVARS.fpOldI13h]
    87     sti                                 ; Make sure interrupts are enabled again (some BIOSes fails to enable it)
    88     jmp     SHORT BackupErrorCodeFromTheRequestedDriveToBH
    89 
    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 ;--------------------------------------------------------------------   
     59AH0h_ResetOurControllers:
     60    push    dx
     61    mov     bx, ROMVARS.ideVars0            ; Load offset to first IDEVARS
     62    call    Initialize_GetIdeControllerCountToCX
    10263ALIGN JUMP_ALIGN
    103 GetDriveNumberForForeignBiosesToDL:
    104     mov     dl, bl
    105     call    RamVars_IsDriveHandledByThisBIOS
    106     jc      SHORT .GetFirstDriveForForeignBios
    107     ret     ; Return what was in BL unmodified
    108 ALIGN JUMP_ALIGN
    109 .GetFirstDriveForForeignBios:
    110     mov     dl, 80h
     64.ResetLoop:
     65    call    AH0h_ResetIdevarsController
     66    jc      SHORT .Return
     67    add     bx, BYTE IDEVARS_size
     68    loop    .ResetLoop
     69    xor     ax, ax                          ; Clear AH and CF since no errors
     70.Return:
     71    pop     dx
    11172    ret
    11273
    11374
    11475;--------------------------------------------------------------------
    115 ; ResetHardDisksHandledByOurBIOS
     76; Resets master and slave drive based on either drive number.
     77;
     78; AH0h_ResetIdevarsController
    11679;   Parameters:
    117 ;       BL:     Requested drive (DL when entering AH=00h)
     80;       CS:BX:  Ptr to IDEVARS
    11881;       DS:     RAMVARS segment
    11982;   Returns:
    120 ;       BH:     Error code from requested drive (if available)
     83;       AH:     Int 13h return status
     84;       CF:     0 if succesfull, 1 if error
    12185;   Corrupts registers:
    122 ;       AX, CX, DX, DI
     86;       AL, DX, DI
    12387;--------------------------------------------------------------------
    12488ALIGN JUMP_ALIGN
    125 AH0h_ResetHardDisksHandledByOurBIOS:
    126     mov     dh, [RAMVARS.bDrvCnt]       ; Load drive count to DH
    127     test    dh, dh
    128     jz      SHORT .AllDrivesReset       ; Return if no drives
    129     mov     dl, [RAMVARS.bFirstDrv]     ; Load number of first our drive
    130     add     dh, dl                      ; DH = one past last drive to reset
    131 ALIGN JUMP_ALIGN
    132 .DriveResetLoop:
    133     call    AHDh_ResetDrive
    134     call    .BackupErrorCodeFromMasterOrSlaveToBH
    135     inc     dx
    136     cmp     dl, dh                      ; All done?
    137     jb      SHORT .DriveResetLoop       ;  If not, reset next drive
    138 .AllDrivesReset:
    139     ret
    140 
    141 ;--------------------------------------------------------------------
    142 ; .BackupErrorCodeFromMasterOrSlaveToBH
    143 ;   Parameters:
    144 ;       AH:     Error code for drive DL reset
    145 ;       BL:     Requested drive (DL when entering AH=00h)
    146 ;       DL:     Drive just resetted
    147 ;       DS:     RAMVARS segment
    148 ;   Returns:
    149 ;       BH:     Backuped error code
    150 ;       DL:     Incremented if next drive is slave drive
    151 ;               (=already resetted)
    152 ;   Corrupts registers:
    153 ;       CX, DI
    154 ;--------------------------------------------------------------------
    155 ALIGN JUMP_ALIGN
    156 .BackupErrorCodeFromMasterOrSlaveToBH:
    157     call    BackupErrorCodeFromTheRequestedDriveToBH
    158     mov     cx, [RAMVARS.wIdeBase]      ; Load base port for resetted drive
    159 
    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
     89AH0h_ResetIdevarsController:
     90    mov     dx, [cs:bx+IDEVARS.wPort]
     91    call    FindDPT_ForIdeMasterAtPort      ; Find master drive to DL
     92    jc      SHORT AH0h_ResetMasterAndSlaveDriveWithRetries
     93    call    FindDPT_ForIdeSlaveAtPort       ; Find slave if master not present
     94    jc      SHORT AH0h_ResetMasterAndSlaveDriveWithRetries
     95    clc
    16796    ret
    16897
    16998
    17099;--------------------------------------------------------------------
    171 ; BackupErrorCodeFromTheRequestedDriveToBH
     100; Resets master and slave drive based on either drive number.
     101;
     102; AH0h_ResetMasterAndSlaveDriveWithRetries
    172103;   Parameters:
    173 ;       AH:     Error code from the last resetted drive
    174 ;       DL:     Drive last resetted
    175 ;       BL:     Requested drive (DL when entering AH=00h)
     104;       DL:     Drive number for master or slave drive
    176105;   Returns:
    177 ;       BH:     Backuped error code
     106;       AH:     Int 13h return status
     107;       CF:     0 if succesfull, 1 if error
     108;   Corrupts registers:
     109;       AL, DX, DI
     110;--------------------------------------------------------------------
     111ALIGN JUMP_ALIGN
     112AH0h_ResetMasterAndSlaveDriveWithRetries:
     113    push    cx
     114    push    bx
     115    mov     cx, RETRIES_IF_RESET_FAILS
     116ALIGN JUMP_ALIGN
     117.RetryLoop:
     118    mov     di, cx                      ; Backup counter
     119    call    AHDh_ResetDrive
     120    jnc     SHORT .Return
     121    mov     cx, TIMEOUT_BEFORE_RESET_RETRY
     122    call    SoftDelay_TimerTicks
     123    mov     cx, di
     124    loop    .RetryLoop
     125    mov     ah, RET_HD_RESETFAIL
     126    stc
     127ALIGN JUMP_ALIGN
     128.Return:
     129    pop     bx
     130    pop     cx
     131    ret
     132
     133
     134;--------------------------------------------------------------------
     135; Resets floppy drives and foreign hard disks.
     136;
     137; AH0h_ResetFloppyAndForeignHardDiskControllers
     138;   Parameters:
     139;       DL:     Drive number (ignored so all drives are reset)
     140;               If bit 7 is set all hard disks and floppy disks reset.
     141;   Returns:
     142;       AH:     Int 13h return status
     143;       CF:     0 if succesfull, 1 if error
    178144;   Corrupts registers:
    179145;       Nothing
    180146;--------------------------------------------------------------------
    181147ALIGN JUMP_ALIGN
    182 BackupErrorCodeFromTheRequestedDriveToBH:
    183     cmp     dl, bl              ; Requested drive?
    184     jne     SHORT .Return
    185     mov     bh, ah
    186 ALIGN JUMP_ALIGN
    187 .Return:
     148AH0h_ResetFloppyAndForeignHardDiskControllers:
     149    xor     ah, ah                      ; AH=0h, Disk Controller Reset
     150    pushf                               ; Push flags to simulate INT
     151    cli                                 ; Disable interrupts
     152    call    FAR [RAMVARS.fpOldI13h]
    188153    ret
  • /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH11h_HRecal.asm

    r30 r20  
    22; Project name  :   IDE BIOS
    33; Created date  :   28.9.2007
    4 ; Last update   :   29.7.2010
     4; Last update   :   12.4.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Int 13h function AH=11h, Recalibrate.
     
    5555    mov     cx, 1                       ; Seek to Cylinder 0, Sector 1
    5656    xor     dh, dh                      ; Head 0
    57     jmp     AHCh_SeekToCylinder
     57    call    AHCh_SeekToCylinder
     58    ret
  • /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH14h_HDiag.asm

    r30 r20  
    22; Project name  :   IDE BIOS
    33; Created date  :   28.9.2007
    4 ; Last update   :   1.8.2010
     4; Last update   :   12.4.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Int 13h function AH=14h, Controller Internal Diagnostic.
     
    3333    jnz     SHORT .ReturnError
    3434    xor     ah, ah                      ; Zero AH and CF since success
    35     jmp     Int13h_StoreErrorCodeToBDAandPopDSDIandReturn
     35    jmp     Int13h_PopDiDsAndReturn
    3636.ReturnError:
    3737    mov     ah, RET_HD_RESETFAIL
    3838    stc
    39     jmp     Int13h_StoreErrorCodeToBDAandPopDSDIandReturn
     39    jmp     Int13h_PopDiDsAndReturn
  • /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1h_HStatus.asm

    r30 r20  
    22; Project name  :   IDE BIOS
    33; Created date  :   27.9.2007
    4 ; Last update   :   29.7.2010
     4; Last update   :   12.4.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Int 13h function AH=1h, Read Disk Status.
     
    2828AH1h_HandlerForReadDiskStatus:
    2929    push    ds
    30 
    3130    LOAD_BDA_SEGMENT_TO ds, di
    3231    xor     ah, ah                  ; Zero AH
    3332    cmp     ah, [BDA.bHDLastSt]     ; Set CF if error code is non-zero
    34     xchg    ah, [BDA.bHDLastSt]     ; Last error to AH, zero to BDA
    35 
     33    mov     ah, [BDA.bHDLastSt]
    3634    pop     ds
    3735    jmp     Int13h_PopDiDsAndReturn
  • /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm

    r30 r20  
    22; Project name  :   IDE BIOS
    33; Created date  :   27.9.2007
    4 ; Last update   :   1.8.2010
     4; Last update   :   12.4.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Int 13h function AH=2h, Read Disk Sectors.
     
    6363    mov     ah, RET_HD_INVALID          ; Invalid value passed
    6464    stc                                 ; Set CF since error
    65     jmp     Int13h_StoreErrorCodeToBDAandPopDSDIandReturn
     65    jmp     Int13h_PopDiDsAndReturn
  • /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH8h_HParams.asm

    r30 r20  
    4141; Returns L-CHS parameters for drive and total hard disk count.
    4242;
    43 ; AH8h_GetDriveParameters
     43; AH8h_HParams
    4444;   Parameters:
    4545;       DL:     Drive number
  • /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm

    r30 r20  
    22; Project name  :   IDE BIOS
    33; Created date  :   9.12.2007
    4 ; Last update   :   1.8.2010
     4; Last update   :   26.4.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Int 13h function AH=9h, Initialize Drive Parameters.
     
    7878.InitializeBlockMode:
    7979    call    AH9h_InitializeBlockMode
    80     ;mov        dl, [di+DPT.bDrvNum]        ; Restore DL
     80    ;mov    dl, [di+DPT.bDrvNum]        ; Restore DL
    8181    jc      SHORT .ReturnNotSuccessfull
    8282    and     BYTE [di+DPT.bReset], ~FLG_RESET_nSETBLOCK
    83 
    84     ; Force PIO mode 0
    85     ;call   AH9h_ForcePioMode0
    8683
    8784.ReturnNotSuccessfull:
     
    152149.Return:
    153150    ret
    154 
    155 
    156 ;--------------------------------------------------------------------
    157 ; AH9h_ForcePioMode0
    158 ;   Parameters:
    159 ;       DL:     Drive number
    160 ;       DS:DI:  Ptr to DPT
    161 ;   Returns:
    162 ;       AH:     BIOS Error code
    163 ;       CF:     Cleared if succesfull
    164 ;               Set if any error
    165 ;   Corrupts registers:
    166 ;       AX, BX
    167 ;--------------------------------------------------------------------
    168 ;ALIGN JUMP_ALIGN
    169 ;AH9h_ForcePioMode0:
    170 ;   mov     bh, 08h     ; Parameter to Sector Count Register (PIO Flow Control Transfer Mode 0)
    171 ;   mov     ax, 2303h   ; Feature: Set transfer mode based on value in Sector Count register
    172 ;   int     13h
    173 ;   jc      SHORT .FailedToForcePIO0
    174 ;   ; Debug output here
    175 ;   ret
    176 ;.FailedToForcePIO0:
    177 ;   ; Debug output here
    178 ;   ret
  • /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm

    r30 r20  
    22; Project name  :   IDE BIOS
    33; Created date  :   9.12.2007
    4 ; Last update   :   1.8.2010
     4; Last update   :   12.4.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
    2731    call    AHDh_ResetDrive
    28     jmp     Int13h_StoreErrorCodeToBDAandPopDSDIandReturn
     32    jmp     Int13h_PopXRegsAndReturn
    2933
    3034
     
    4044;       CF:     0 if succesfull, 1 if error
    4145;   Corrupts registers:
    42 ;       DI
     46;       AL, BX, CX, DX
    4347;--------------------------------------------------------------------
    4448ALIGN JUMP_ALIGN
    4549AHDh_ResetDrive:
    46     push    dx
    47     push    cx
    48     push    bx
    49     push    ax
    50 
     50    push    di
    5151    call    FindDPT_ForDriveNumber      ; DS:DI now points to DPT
    5252    call    AHDh_ResetMasterAndSlave
     
    5757    mov     dx, [RAMVARS.wIdeBase]      ; Load base port address
    5858    call    AHDh_InitializeMasterAndSlave
    59 
    60     pop     bx                          ; Pop old AX
    61     mov     al, bl                      ; Restore AL
    62     pop     bx
    63     pop     cx
    64     pop     dx
     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
     65    pop     di
    6566    ret
    6667
     
    109110;       DX:     IDE Base Port address
    110111;   Returns:
    111 ;       AH:     Error code
    112112;       CF:     0 if initialization succesfull
    113113;               1 if any error
    114114;   Corrupts registers:
    115 ;       AL, BX, CX, DX, DI
     115;       AX, BX, CX, DX, DI
    116116;--------------------------------------------------------------------
    117117ALIGN JUMP_ALIGN
     
    136136    ret
    137137.ReturnError:
    138     mov     ah, RET_HD_RESETFAIL        ; Load Reset Failed error code
    139138    stc
    140139    ret
  • /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HError.asm

    r30 r20  
    22; Project name  :   IDE BIOS
    33; Created date  :   30.11.2007
    4 ; Last update   :   1.8.2010
     4; Last update   :   8.4.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Error checking functions for BIOS Hard disk functions.
     
    1010
    1111;--------------------------------------------------------------------
    12 ; HError_ProcessErrorsAfterPollingTaskFlag
     12; Converts Status Register error to BIOS error code.
     13;
     14; HError_GetErrorCodeForStatusReg
    1315;   Parameters:
    14 ;       DS:     RAMVARS segment
    15 ;       ES:     BDA segment (zero)
    16 ;       CF:     Set if timeout
    17 ;               Cleared if task flag was properly set
     16;       AL:     IDE Status Register contents
     17;       DX:     IDE Status Register Address
    1818;   Returns:
    19 ;       AH:     BIOS error code
    20 ;       CF:     Set if error
    21 ;               Cleared if no error
     19;       AH:     Hard disk BIOS error code
     20;       CF:     0 if no errors (AH=RET_HD_SUCCESS)
     21;               1 if some error
     22;   Corrupts registers:
     23;       AL, CX
     24;--------------------------------------------------------------------
     25ALIGN JUMP_ALIGN
     26HError_GetErrorCodeForStatusReg:
     27    ; Get Error Register contents to AH
     28    mov     ah, al                              ; Backup Status Reg to AH
     29    sub     dx, BYTE REGR_IDE_ST-REGR_IDE_ERROR ; Status Reg to Error Reg
     30    in      al, dx                              ; Read Error Register to AL
     31    xchg    al, ah                              ; Swap status and error
     32    add     dx, BYTE REGR_IDE_ST-REGR_IDE_ERROR ; Restore DX
     33
     34    ; Store Register contents to BDA
     35    push    ds
     36    LOAD_BDA_SEGMENT_TO ds, cx
     37    mov     [HDBDA.wHDStAndErr], ax         ; Store Status and Error to BDA
     38    pop     ds
     39
     40    ; Translate registers to BIOS error code
     41    ; Fall to HError_ConvertIdeErrorToBiosRet
     42
     43;--------------------------------------------------------------------
     44; Converts error flags from IDE status and error register contents
     45; to BIOS Int 13h return value.
     46;
     47; HError_ConvertIdeErrorToBiosRet
     48;   Parameters:
     49;       AL:     Status Register Contents
     50;       AH:     Error Register Contents
     51;   Returns:
     52;       AH:     Hard disk BIOS error code
     53;       CF:     0 if no errors (AH=RET_HD_SUCCESS)
     54;               1 if any error
    2255;   Corrupts registers:
    2356;       AL
    2457;--------------------------------------------------------------------
    2558ALIGN JUMP_ALIGN
    26 HError_ProcessErrorsAfterPollingTaskFlag:
    27     jc      SHORT HError_ProcessTimeoutAfterPollingBSYandSomeOtherStatusBit
    28     mov     ax, [es:HDBDA.wHDStAndErr]
    29     call    GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX
    30     mov     [es:BDA.bHDLastSt], ah
    31     mov     BYTE [es:BDA.bHDTaskFlg], 0
    32     ret
    33 
    34 ;--------------------------------------------------------------------
    35 ; HError_ProcessTimeoutAfterPollingBSYandSomeOtherStatusBit
    36 ; HError_ProcessErrorsAfterPollingBSY
    37 ;   Parameters:
    38 ;       DS:     RAMVARS segment
    39 ;   Returns:
    40 ;       AH:     BIOS error code
    41 ;       CF:     Set if error
    42 ;               Cleared if no error
    43 ;   Corrupts registers:
    44 ;       AL
    45 ;--------------------------------------------------------------------
    46 ALIGN JUMP_ALIGN
    47 HError_ProcessTimeoutAfterPollingBSYandSomeOtherStatusBit:
    48     push    ds
    49     push    dx
    50 
    51     call    HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA
    52     call    GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX
    53     jc      SHORT StoreErrorCodeFromAHtoBDA
    54     mov     ah, RET_HD_TIMEOUT          ; Force timeout since no actual error...
    55     stc                                 ; ...but wanted bit was never set
    56     jmp     SHORT StoreErrorCodeFromAHtoBDA
    57 
    58 
    59 ALIGN JUMP_ALIGN
    60 HError_ProcessErrorsAfterPollingBSY:
    61     push    ds
    62     push    dx
    63 
    64     call    HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA
    65     call    GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX
    66 StoreErrorCodeFromAHtoBDA:
    67     mov     [BDA.bHDLastSt], ah         ; Store BIOS error code to BDA
    68 
    69     pop     dx
    70     pop     ds
    71     ret
    72 
    73 
    74 ;--------------------------------------------------------------------
    75 ; HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA
    76 ;   Parameters:
    77 ;       DS:     RAMVARS segment
    78 ;   Returns:
    79 ;       AL:     IDE Status Register contents
    80 ;       AH:     IDE Error Register contents
    81 ;       DS:     BDA segment
    82 ;   Corrupts registers:
    83 ;       DX
    84 ;--------------------------------------------------------------------
    85 ALIGN JUMP_ALIGN
    86 HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA:
    87     mov     dx, [RAMVARS.wIdeBase]      ; Load IDE base port address
    88     inc     dx                          ; Increment to Error Register
    89     in      al, dx                      ; Read Error Register...
    90     mov     ah, al                      ; ...and copy it to AH
    91     add     dx, BYTE REGR_IDE_ST - REGR_IDE_ERROR
    92     in      al, dx                      ; Read Status Register to AL
    93     ; Fall to .StoreStatusAndErrorRegistersFromAXtoBDA
    94 
    95 ;--------------------------------------------------------------------
    96 ; .StoreStatusAndErrorRegistersFromAXtoBDA
    97 ;   Parameters:
    98 ;       AL:     IDE Status Register contents
    99 ;       AH:     IDE Error Register contents
    100 ;   Returns:
    101 ;       DS:     BDA segment (zero)
    102 ;   Corrupts registers:
    103 ;       DX
    104 ;--------------------------------------------------------------------
    105 .StoreStatusAndErrorRegistersFromAXtoBDA:
    106     LOAD_BDA_SEGMENT_TO ds, dx
    107     mov     [HDBDA.wHDStAndErr], ax
    108     ret
    109 
    110 
    111 ;--------------------------------------------------------------------
    112 ; GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX
    113 ;   Parameters:
    114 ;       AL:     IDE Status Register contents
    115 ;       AH:     IDE Error Register contents
    116 ;   Returns:
    117 ;       AH:     BIOS INT 13h error code
    118 ;       CF:     Set if error
    119 ;               Cleared if no error
    120 ;   Corrupts registers:
    121 ;       Nothing
    122 ;--------------------------------------------------------------------
    123 ALIGN JUMP_ALIGN
    124 GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX:
    125     test    al, FLG_IDE_ST_BSY
    126     jz      SHORT .CheckErrorBitsFromStatusRegisterInAL
    127     mov     ah, RET_HD_TIMEOUT
    128     jmp     SHORT .ReturnBiosErrorCodeInAH
    129 
    130 ALIGN JUMP_ALIGN
    131 .CheckErrorBitsFromStatusRegisterInAL:
     59HError_ConvertIdeErrorToBiosRet:
     60    ; Any error?
    13261    test    al, FLG_IDE_ST_DF | FLG_IDE_ST_CORR | FLG_IDE_ST_ERR
    133     jnz     SHORT .ProcessErrorFromStatusRegisterInAL
     62    jnz     SHORT .ReadErrorFromStatusReg
    13463    xor     ah, ah                  ; No errors, zero AH and CF
    13564    ret
    13665
    137 .ProcessErrorFromStatusRegisterInAL:
     66; Convert error code based on status or error register
     67.ReadErrorFromStatusReg:
    13868    test    al, FLG_IDE_ST_ERR      ; Error specified in Error register?
    139     jnz     SHORT .ConvertBiosErrorToAHfromErrorRegisterInAH
     69    jnz     SHORT .ReadErrorFromErrorReg
    14070    mov     ah, RET_HD_ECC          ; Assume ECC corrected error
    14171    test    al, FLG_IDE_ST_CORR     ; ECC corrected error?
    142     jnz     SHORT .ReturnBiosErrorCodeInAH
     72    jnz     SHORT .Return
    14373    mov     ah, RET_HD_CONTROLLER   ; Must be Device Fault
    144     jmp     SHORT .ReturnBiosErrorCodeInAH
     74    jmp     SHORT .Return
    14575
    146 .ConvertBiosErrorToAHfromErrorRegisterInAH:
     76; Convert error register to bios error code
     77.ReadErrorFromErrorReg:
    14778    push    bx
    148     mov     bx, .rgbRetCodeLookup
    149 .ErrorBitLoop:
    150     rcr     ah, 1                   ; Set CF if error bit set
    151     jc      SHORT .LookupErrorCode
    152     inc     bx
    153     cmp     bx, .rgbRetCodeLookup + 8
    154     jb      SHORT .ErrorBitLoop     ; Loop until all bits checked
    155 .LookupErrorCode:
     79    mov     al, ah                  ; Copy error reg to AL...
     80    xor     ah, ah                  ; ...and zero extend to AX
     81    eBSF    bx, ax                  ; Get bit index to BX
     82    mov     ah, RET_HD_STATUSERR    ; Error code if Error Reg is zero
     83    jz      SHORT .SkipLookup       ; Return if error register is zero
    15684    mov     ah, [cs:bx+.rgbRetCodeLookup]
     85.SkipLookup:
    15786    pop     bx
    158 
    159 .ReturnBiosErrorCodeInAH:
     87.Return:
    16088    stc                             ; Set CF since error
    16189    ret
     
    17098    db  RET_HD_UNCORRECC    ; Bit6=UNC, Uncorrectable Data Error
    17199    db  RET_HD_BADSECTOR    ; Bit7=BBK, Bad Block Detected
    172     db  RET_HD_STATUSERR    ; When Error Register is zero
    173 
    174 
    175 ;--------------------------------------------------------------------
    176 ; HError_StoreBiosErrorCodeFromAHtoBDA
    177 ;   Parameters:
    178 ;       AH:     BIOS error code
    179 ;   Returns:
    180 ;       Nothing
    181 ;   Corrupts registers:
    182 ;       DI
    183 ;--------------------------------------------------------------------
    184 ALIGN JUMP_ALIGN
    185 HError_StoreBiosErrorCodeFromAHtoBDA:
    186     push    ds
    187     mov     di, 0                   ; Zero DI and preserve FLAGS
    188     mov     ds, di                  ; Copy BDA segment to DS
    189     mov     [BDA.bHDLastSt], ah
    190     pop     ds
    191     ret
  • /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HIRQ.asm

    r30 r20  
    22; Project name  :   IDE BIOS
    33; Created date  :   11.12.2009
    4 ; Last update   :   1.8.2010
     4; Last update   :   28.3.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Interrupt handling related functions.
     
    2020;               Set if any error
    2121;   Corrupts registers:
    22 ;       AL
     22;       AL, CX
    2323;--------------------------------------------------------------------
    2424ALIGN JUMP_ALIGN
    2525HIRQ_WaitIRQ:
     26    ; Load BDA segment to ES
    2627    push    es
    27 
    28     LOAD_BDA_SEGMENT_TO es, ax
     28    xor     ax, ax                      ; Zero AX and clear CF
     29    mov     es, ax                      ; Copy BDA segment (zero) to ES
     30
     31    ; Check if interrupt has already occurred
     32    cli                                 ; Disable interrupts
     33    cmp     [es:BDA.bHDTaskFlg], al     ; Interrupt ready?
     34    jne     SHORT .CheckIdeErrors       ;  If so, return
     35
    2936%ifdef USE_AT   ; OS hook only available on AT+ machines
    30     call    .NotifyOperatingSystemAboutWaitingForIRQ
    31     cmc
    32     jnc     SHORT .TaskFlagPollingComplete
    33 %endif
    34     call    .WaitUntilTaskFlagIsSet     ; Process errors
    35 
    36 ALIGN JUMP_ALIGN
    37 .TaskFlagPollingComplete:
    38     call    HError_ProcessErrorsAfterPollingTaskFlag
    39     pop     es
    40     ret
    41 
    42 ;--------------------------------------------------------------------
    43 ; .NotifyOperatingSystemAboutWaitingForIRQ
    44 ;   Parameters:
    45 ;       ES:     BDA segment (zero)
    46 ;   Returns:
    47 ;       CF:     Set if wait done by operating system
    48 ;               Cleared if BIOS must perform task flag polling
    49 ;   Corrupts registers:
    50 ;       AX
    51 ;--------------------------------------------------------------------
    52 %ifdef USE_AT
    53 ALIGN JUMP_ALIGN
    54 .NotifyOperatingSystemAboutWaitingForIRQ:
    55     cli                                 ; Disable interrupts
    56     xor     ax, ax
    57     cmp     al, [es:BDA.bHDTaskFlg]     ; Task flag already set?
    58     jc      SHORT .ReturnFromWaitNotify ;  If so, skip OS notification
    59 
     37    ; OS device busy notification
    6038    mov     ah, 90h                     ; Hard disk busy (AX=9000h)
    6139    int     INTV_SYSTEM_SERVICES        ; OS hook, device busy
    62     jnc     SHORT .ReturnFromWaitNotify ; CF cleared, BIOS handles waiting
    63 
    64     ; Make sure that OS hooks are supported, otherwise the CF means unsupported function
    65     test    ah, ah                      ; OS hook supported? (clears CF)
    66     jnz     SHORT .ReturnFromWaitNotify ; AH has error, BIOS must do the wait
    67     stc                                 ; Set CF since wait done by OS
    68 .ReturnFromWaitNotify:
     40    jnc     SHORT .WaitUntilTaskFlagSet ; CF cleared, BIOS handles waiting
     41    test    ah, ah                      ; OS hook supported? (clear CF)
     42    jz      SHORT .CheckIdeErrors       ;  If so, waiting completed
     43ALIGN JUMP_ALIGN
     44.WaitUntilTaskFlagSet:
     45%endif
     46
     47    ; Poll task flag until it has been set by interrupt service routine
     48    call    HIRQ_WaitUntilTaskFlagIsSet
     49    jc      SHORT .ReturnTimeout        ; Return if timeout
     50
     51ALIGN JUMP_ALIGN
     52.CheckIdeErrors:
     53    mov     ax, [es:HDBDA.wHDStAndErr]  ; Load Status and Error regs stored by ISR
     54    call    HError_ConvertIdeErrorToBiosRet
     55.ReturnTimeout:
     56    mov     BYTE [es:BDA.bHDTaskFlg], 0 ; Clear Task Flag
     57    pop     es
    6958    sti                                 ; Enable interrupts
    7059    ret
    71 %endif
     60
    7261
    7362;--------------------------------------------------------------------
    7463; Polls IRQ Task Flag until it has been set or timeout.
    7564;
    76 ; .WaitUntilTaskFlagIsSet
     65; HIRQ_WaitUntilTaskFlagIsSet
    7766;   Parameters:
    7867;       DS:     RAMVARS segment
    7968;       ES:     BDA segment
    8069;   Returns:
    81 ;       CF:     Set if timeout
    82 ;               Cleared if Task Flag set
    83 ;   Corrupts registers:
    84 ;       AX
    85 ;--------------------------------------------------------------------
    86 ALIGN JUMP_ALIGN
    87 .WaitUntilTaskFlagIsSet:
    88     push    cx
    89 
     70;       AH:     BIOS Error code
     71;       CF:     Cleared if wait succesfull
     72;               Set if timeout
     73;   Corrupts registers:
     74;       AL, CX
     75;--------------------------------------------------------------------
     76ALIGN JUMP_ALIGN
     77HIRQ_WaitUntilTaskFlagIsSet:
     78    sti                             ; Enable interrupts
    9079    mov     cl, B_TIMEOUT_DRQ       ; Load timeout ticks
    9180    call    SoftDelay_InitTimeout   ; Initialize timeout counter
     
    9382ALIGN JUMP_ALIGN
    9483.PollIrqFlag:
    95     cli                             ; Disable interrupt until next HLT
    96     cmp     [es:BDA.bHDTaskFlg], al ; Task flag set? (clears CF)
    97     jne     SHORT .Return
     84    cli                             ; Disable interrupts
     85    cmp     [es:BDA.bHDTaskFlg], al ; Task flag set?
     86    jne     SHORT .TaskFlagIsSet    ;  If so, return
    9887    call    SoftDelay_UpdTimeout    ; Update timeout
    99     jc      SHORT .Return           ; Return if timeout
    100     sti                             ; Enable interrupts (STI has delay so HLT will catch all interrupts)
     88    jc      SHORT .Timeout          ; Return if timeout
     89    sti                             ; Enable interrupts (one instruction delay)
    10190    hlt                             ; Sleep until any interrupt
    10291    jmp     SHORT .PollIrqFlag      ; Jump to check if IDE interrupt
    103 ALIGN JUMP_ALIGN
    104 .Return:
    105     pop     cx
    106     sti
     92
     93ALIGN JUMP_ALIGN
     94.TaskFlagIsSet:
     95    xor     ah, ah                  ; Zero AH, clear CF
     96    ret
     97.Timeout:
     98    mov     ah, RET_HD_TIMEOUT      ; Load error code for timeout
    10799    ret
    108100
     
    142134ALIGN JUMP_ALIGN
    143135HIRQ_InterruptServiceRoutineForIrqs2to7:
     136    ; Acknowledge IDE interrupt by reading status register
    144137    push    ax
    145     call    AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA
    146 
     138    call    ISR_IDE_AcknowledgeIdeAndStoreStatusToBDA
    147139    mov     al, CMD_END_OF_INTERRUPT
    148     jmp     SHORT AcknowledgeMasterInterruptController
     140    jmp     SHORT HIRQ_AcknowledgeMasterController
    149141
    150142ALIGN JUMP_ALIGN
    151143HIRQ_InterruptServiceRoutineForIrqs8to15:
    152144    push    ax
    153     call    AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA
     145    call    ISR_IDE_AcknowledgeIdeAndStoreStatusToBDA
    154146
    155147    mov     al, CMD_END_OF_INTERRUPT    ; Load EOI command to AL
    156148    out     WPORT_8259SL_COMMAND, al    ; Acknowledge Slave 8259
    157 AcknowledgeMasterInterruptController:
     149HIRQ_AcknowledgeMasterController:
    158150    out     WPORT_8259MA_COMMAND, al    ; Acknowledge Master 8259
    159151
     
    164156%endif
    165157
     158    ; Restore registers and return from interrupt
    166159    pop     ax                          ; Restore AX
    167160    iret
     161
    168162
    169163;--------------------------------------------------------------------
     
    172166; also be set.
    173167;
    174 ; AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA
     168; ISR_IDE_AcknowledgeIdeAndStoreStatusToBDA
    175169;   Parameters:
    176170;       Nothing
     
    181175;--------------------------------------------------------------------
    182176ALIGN JUMP_ALIGN
    183 AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA:
     177ISR_IDE_AcknowledgeIdeAndStoreStatusToBDA:
    184178    push    ds
    185179    push    di
    186180    push    dx
    187181
     182    ; Read Status and Error registers.
    188183    ; Reading Status Register acknowledges IDE interrupt
    189184    call    RamVars_GetSegmentToDS
    190     call    HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA
    191     mov     BYTE [BDA.bHDTaskFlg], 0FFh     ; Set task flag
     185    mov     dx, [RAMVARS.wIdeBase]      ; Load IDE base port address
     186    inc     dx                          ; Increment to Error Register
     187    in      al, dx                      ; Read Error Register...
     188    mov     ah, al                      ; ...and copy it to AH
     189    add     dx, REGR_IDE_ST-REGR_IDE_ERROR
     190    in      al, dx                      ; Read Status Register to AL
     191
     192    ; Store Status and Error register to BDA and set task flag
     193    LOAD_BDA_SEGMENT_TO ds, dx
     194    mov     [HDBDA.wHDStAndErr], ax     ; Store Status and Error Registers
     195    mov     BYTE [BDA.bHDTaskFlg], 0FFh ; Set task flag
    192196
    193197    pop     dx
  • /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HPIO.asm

    r30 r20  
    22; Project name  :   IDE BIOS
    33; Created date  :   14.12.2007
    4 ; Last update   :   1.8.2010
     4; Last update   :   14.4.2010
    55; Author        :   Tomi Tilli
    66; Description   :   PIO transfer functions.
     
    168168    add     cx, [bp+PIOVARS.wWordsLeft] ; CX to partial block size
    169169    call    [bp+PIOVARS.fnXfer]         ; Transfer possibly partial block
     170    call    HStatus_ReadAndIgnoreAlternateStatus
    170171    jmp     HStatus_WaitBsyDefTime      ; Check for errors
    171172.RetError:
     
    231232HPIO_WriteToDrive:
    232233    cld                                     ; OUTS to increment SI
    233     call    HStatus_WaitDrqDefTime          ; Always poll DRQ for first block, get status reg to DX
     234    call    HStatus_WaitDrqDefTime          ; Always poll DRQ for first block
    234235    jc      SHORT .RetError                 ; Return if error (code in AH)
    235236    sub     dx, BYTE REGR_IDE_ST            ; DX to Data Port address
     
    250251    jmp     HStatus_WaitIrqOrRdy            ; Check for errors
    251252
    252 
     253   
    253254;--------------------------------------------------------------------
    254255; Bus specific transfer functions and lookup table.
  • /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HStatus.asm

    r30 r20  
    22; Project name  :   IDE BIOS
    33; Created date  :   15.12.2009
    4 ; Last update   :   1.8.2010
     4; Last update   :   25.5.2010
    55; Author        :   Tomi Tilli
    66; Description   :   IDE Status Register polling functions.
     
    2525ALIGN JUMP_ALIGN
    2626HStatus_WaitIrqOrRdy:
    27     test    BYTE [bx+DPT.bDrvCtrl], FLG_IDE_CTRL_nIEN
    28     jnz     SHORT .PollRdySinceInterruptsAreDisabled
     27    test    BYTE [di+DPT.bDrvCtrl], FLG_IDE_CTRL_nIEN
     28    jnz     SHORT .PollRdySinceIrqsAreDisabled
    2929    jmp     HIRQ_WaitIRQ
    30 
    31 ALIGN JUMP_ALIGN
    32 .PollRdySinceInterruptsAreDisabled:
     30ALIGN JUMP_ALIGN
     31.PollRdySinceIrqsAreDisabled:
     32    call    HStatus_ReadAndIgnoreAlternateStatus
    3333    mov     cl, B_TIMEOUT_DRQ               ; Load DRQ (not RDY) timeout
    3434    jmp     SHORT HStatus_WaitRdy           ; Jump to poll RDY
     
    3636
    3737;--------------------------------------------------------------------
     38; Reads Alternate Status Register and ignores result.
     39; Alternate Status Register is read to prevent polling host from
     40; reading status before it is valid.
     41;
     42; HStatus_ReadAndIgnoreAlternateStatus
     43;   Parameters:
     44;       DS:BX:  Ptr to DPT
     45;   Returns:
     46;       Nothing
     47;   Corrupts registers:
     48;       AL, CX, DX
     49;--------------------------------------------------------------------
     50ALIGN JUMP_ALIGN
     51HStatus_ReadAndIgnoreAlternateStatus:
     52    mov     cx, bx                          ; Backup BX
     53    eMOVZX  bx, BYTE [bx+DPT.bIdeOff]       ; CS:BX now points to IDEVARS
     54    mov     dx, [cs:bx+IDEVARS.wPortCtrl]   ; DX = Control Block base port
     55    add     dx, BYTE REGR_IDEC_AST          ; DX = Alternate Status Register address
     56    in      al, dx                          ; Read Alternate Status Register
     57    mov     bx, cx                          ; Restore BX
     58    ret
     59
     60
     61;--------------------------------------------------------------------
    3862; Waits until Hard Disk is ready to transfer data.
    3963;
     
    5074ALIGN JUMP_ALIGN
    5175HStatus_WaitIrqOrDrq:
    52     test    BYTE [bx+DPT.bDrvCtrl], FLG_IDE_CTRL_nIEN
    53     jnz     SHORT .PollDrqSinceInterruptsAreDisabled
    54     jmp     HIRQ_WaitIRQ
    55 
    56 ALIGN JUMP_ALIGN
    57 .PollDrqSinceInterruptsAreDisabled:
    5876    push    dx
    5977    push    cx
     78
     79    ; Check if interrupts are enabled
     80    test    BYTE [bx+DPT.bDrvCtrl], FLG_IDE_CTRL_nIEN
     81    jnz     SHORT .PollDRQ                  ; Poll DRQ if IRQ disabled
     82    call    HIRQ_WaitIRQ                    ; Wait for IRQ
     83    jmp     SHORT .Return
     84
     85ALIGN JUMP_ALIGN
     86.PollDRQ:
     87    call    HStatus_ReadAndIgnoreAlternateStatus
    6088    call    HStatus_WaitDrqDefTime
     89ALIGN JUMP_ALIGN
     90.Return:
    6191    pop     cx
    6292    pop     dx
     
    159189; IDE Status register polling.
    160190; This function first waits until controller is not busy.
    161 ; When not busy, IDE Status Register is polled until wanted flag is set.
     191; When not busy, IDE Status Register is polled until wanted
     192; flag (HBIT_ST_DRDY or HBIT_ST_DRQ) is set.
    162193;
    163194; HStatus_PollBusyAndFlg
     
    176207ALIGN JUMP_ALIGN
    177208HStatus_PollBsyAndFlg:
    178     call    SoftDelay_InitTimeout               ; Initialize timeout counter
    179     in      al, dx                              ; Discard contents for first read
    180                                                 ; (should read Alternate Status Register)
     209    call    SoftDelay_InitTimeout       ; Initialize timeout counter
    181210ALIGN JUMP_ALIGN
    182211.PollLoop:
    183     in      al, dx                              ; Load IDE Status Register
    184     test    al, FLG_IDE_ST_BSY                  ; Controller busy?
    185     jnz     SHORT .UpdateTimeout                ;  If so, jump to timeout update
    186     test    al, ah                              ; Test secondary flag
    187     jnz     SHORT GetErrorCodeFromPollingToAH   ; If set, break loop
     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
    188217ALIGN JUMP_ALIGN
    189218.UpdateTimeout:
    190     call    SoftDelay_UpdTimeout                ; Update timeout counter
    191     jnc     SHORT .PollLoop                     ; Loop if time left (sets CF on timeout)
    192     jmp     HError_ProcessTimeoutAfterPollingBSYandSomeOtherStatusBit
     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
    193224
    194225;--------------------------------------------------------------------
     
    210241ALIGN JUMP_ALIGN
    211242HStatus_PollBsy:
    212     call    SoftDelay_InitTimeout               ; Initialize timeout counter
    213     in      al, dx                              ; Discard contents for first read
    214                                                 ; (should read Alternate Status Register)
     243    call    SoftDelay_InitTimeout       ; Initialize timeout counter
    215244ALIGN JUMP_ALIGN
    216245.PollLoop:
    217     in      al, dx                              ; Load IDE Status Reg
    218     test    al, FLG_IDE_ST_BSY                  ; Controller busy?
    219     jz      SHORT GetErrorCodeFromPollingToAH   ;  If not, jump to check errors
    220     call    SoftDelay_UpdTimeout                ; Update timeout counter
    221     jnc     SHORT .PollLoop                     ; Loop if time left (sets CF on timeout)
    222 ALIGN JUMP_ALIGN
    223 GetErrorCodeFromPollingToAH:
    224     jmp     HError_ProcessErrorsAfterPollingBSY
     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
     254ALIGN JUMP_ALIGN
     255HStatus_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:
     261    jmp     HError_GetErrorCodeForStatusReg
  • /trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm

    r30 r20  
    22; Project name  :   IDE BIOS
    33; Created date  :   3.8.2007
    4 ; Last update   :   1.8.2010
     4; Last update   :   2.5.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
     12B_READ_RETRY_DELAY  EQU 3   ; Timer ticks between retries
    1213
    1314
     
    109110ALIGN JUMP_ALIGN
    110111.ReadRetryLoop:
    111     call    .ResetBootDriveFromDL
    112     call    .LoadFirstSectorFromDLtoESBX
     112    call    Int19h_LoadFirstSectorFromDLToESBX
    113113    jnc     SHORT .Return
     114    call    Int19h_ResetDriveOrWait
    114115    dec     di                              ; Decrement retry counter
    115116    jnz     SHORT .ReadRetryLoop            ; Loop while retries left
     
    120121
    121122;--------------------------------------------------------------------
    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 ;--------------------------------------------------------------------
    132 ALIGN 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 ;--------------------------------------------------------------------
    143123; Reads first sector (boot sector) from drive DL to ES:BX.
    144124;
    145 ; .LoadFirstSectorFromDLtoESBX
     125; Int19h_LoadFirstSectorFromDLToESBX
    146126;   Parameters:
    147127;       DL:     Drive to boot from (translated, 00h or 80h)
     
    156136;--------------------------------------------------------------------
    157137ALIGN JUMP_ALIGN
    158 .LoadFirstSectorFromDLtoESBX:
     138Int19h_LoadFirstSectorFromDLToESBX:
    159139    mov     ax, 0201h                       ; Read 1 sector
    160140    mov     cx, 1                           ; Cylinder 0, Sector 1
    161141    xor     dh, dh                          ; Head 0
    162142    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;--------------------------------------------------------------------
     159ALIGN JUMP_ALIGN
     160Int19h_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
     165ALIGN 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
    163171    ret
    164172
  • /trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm

    r30 r20  
    22; Project name  :   IDE BIOS
    33; Created date  :   25.3.2010
    4 ; Last update   :   28.7.2010
     4; Last update   :   2.5.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     cmc
     27    jae     SHORT .Int40hIsAlreadyInstalled
     28    clc
     29    ret
     30ALIGN JUMP_ALIGN
     31.Int40hIsAlreadyInstalled:
     32    stc
    2833    ret
    2934
  • /trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm

    r30 r20  
    22; Project name  :   IDE BIOS
    33; Created date  :   23.3.2010
    4 ; Last update   :   1.8.2010
     4; Last update   :   2.5.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for initializing the BIOS.
     
    418418ALIGN JUMP_ALIGN
    419419Initialize_ResetDetectedDrives:
    420     jmp     AH0h_ResetHardDisksHandledByOurBIOS
     420    ; Initialize to speed up POST. DOS will reset drives anyway.
     421    eMOVZX  cx, BYTE [RAMVARS.bDrvCnt]
     422    jcxz    .Return
     423    mov     dl, [RAMVARS.bFirstDrv]
     424ALIGN JUMP_ALIGN
     425.InitLoop:
     426    call    AH9h_InitializeDriveForUse
     427    inc     dx                  ; Next drive
     428    loop    .InitLoop
     429.Return:
     430    ret
  • /trunk/XTIDE_Universal_BIOS/Src/Main.asm

    r30 r20  
    22; Project name  :   XTIDE Universal BIOS
    33; Created date  :   28.7.2007
    4 ; Last update   :   26.7.2010
     4; Last update   :   2.5.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  "08/01/10"      ; Build data (mm/dd/yy)
     40    at  ROMVARS.rgbDate,    db  "05/02/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.3 (08/01/10)",STOP
     51    at  ROMVARS.szVersion,  db  "v1.1.0 (05/02/10)",STOP
    5252
    5353;---------------------------;
  • /wiki/DriveCompatibility.wiki

    r30 r20  
    11#summary XTIDE Universal BIOS compatibility with hard disks, microdrives and CF cards
    2 #labels Featured
    32<wiki:toc max_depth="1" />
    43
  • /wiki/Manual.wiki

    r30 r20  
    11#summary Instructions for XTIDE Universal BIOS v1.1.0
    2 #labels Featured,Phase-Deploy
    32*Table of Contents*
    43<wiki:toc max_depth="3" />
Note: See TracChangeset for help on using the changeset viewer.