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

Legend:

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

    r3 r28  
    22; Project name  :   IDE BIOS
    33; Created date  :   11.12.2009
    4 ; Last update   :   28.3.2010
     4; Last update   :   1.8.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Interrupt handling related functions.
     
    2020;               Set if any error
    2121;   Corrupts registers:
    22 ;       AL, CX
     22;       AL
    2323;--------------------------------------------------------------------
    2424ALIGN JUMP_ALIGN
    2525HIRQ_WaitIRQ:
    26     ; Load BDA segment to ES
    2726    push    es
    28     xor     ax, ax                      ; Zero AX and clear CF
    29     mov     es, ax                      ; Copy BDA segment (zero) to ES
    3027
    31     ; Check if interrupt has already occurred
     28    LOAD_BDA_SEGMENT_TO es, ax
     29%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
     36ALIGN 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
     53ALIGN JUMP_ALIGN
     54.NotifyOperatingSystemAboutWaitingForIRQ:
    3255    cli                                 ; Disable interrupts
    33     cmp     [es:BDA.bHDTaskFlg], al     ; Interrupt ready?
    34     jne     SHORT .CheckIdeErrors       ;  If so, return
     56    xor     ax, ax
     57    cmp     al, [es:BDA.bHDTaskFlg]     ; Task flag already set?
     58    jc      SHORT .ReturnFromWaitNotify ;  If so, skip OS notification
    3559
    36 %ifdef USE_AT   ; OS hook only available on AT+ machines
    37     ; OS device busy notification
    3860    mov     ah, 90h                     ; Hard disk busy (AX=9000h)
    3961    int     INTV_SYSTEM_SERVICES        ; OS hook, device busy
    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
    43 ALIGN JUMP_ALIGN
    44 .WaitUntilTaskFlagSet:
    45 %endif
     62    jnc     SHORT .ReturnFromWaitNotify ; CF cleared, BIOS handles waiting
    4663
    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 
    51 ALIGN 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
     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:
    5869    sti                                 ; Enable interrupts
    5970    ret
    60 
     71%endif
    6172
    6273;--------------------------------------------------------------------
    6374; Polls IRQ Task Flag until it has been set or timeout.
    6475;
    65 ; HIRQ_WaitUntilTaskFlagIsSet
     76; .WaitUntilTaskFlagIsSet
    6677;   Parameters:
    6778;       DS:     RAMVARS segment
    6879;       ES:     BDA segment
    6980;   Returns:
    70 ;       AH:     BIOS Error code
    71 ;       CF:     Cleared if wait succesfull
    72 ;               Set if timeout
     81;       CF:     Set if timeout
     82;               Cleared if Task Flag set
    7383;   Corrupts registers:
    74 ;       AL, CX
     84;       AX
    7585;--------------------------------------------------------------------
    7686ALIGN JUMP_ALIGN
    77 HIRQ_WaitUntilTaskFlagIsSet:
    78     sti                             ; Enable interrupts
     87.WaitUntilTaskFlagIsSet:
     88    push    cx
     89
    7990    mov     cl, B_TIMEOUT_DRQ       ; Load timeout ticks
    8091    call    SoftDelay_InitTimeout   ; Initialize timeout counter
     
    8293ALIGN JUMP_ALIGN
    8394.PollIrqFlag:
    84     cli                             ; Disable interrupts
    85     cmp     [es:BDA.bHDTaskFlg], al ; Task flag set?
    86     jne     SHORT .TaskFlagIsSet    ;  If so, return
     95    cli                             ; Disable interrupt until next HLT
     96    cmp     [es:BDA.bHDTaskFlg], al ; Task flag set? (clears CF)
     97    jne     SHORT .Return
    8798    call    SoftDelay_UpdTimeout    ; Update timeout
    88     jc      SHORT .Timeout          ; Return if timeout
    89     sti                             ; Enable interrupts (one instruction delay)
     99    jc      SHORT .Return           ; Return if timeout
     100    sti                             ; Enable interrupts (STI has delay so HLT will catch all interrupts)
    90101    hlt                             ; Sleep until any interrupt
    91102    jmp     SHORT .PollIrqFlag      ; Jump to check if IDE interrupt
    92 
    93103ALIGN 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
     104.Return:
     105    pop     cx
     106    sti
    99107    ret
    100108
     
    134142ALIGN JUMP_ALIGN
    135143HIRQ_InterruptServiceRoutineForIrqs2to7:
    136     ; Acknowledge IDE interrupt by reading status register
    137144    push    ax
    138     call    ISR_IDE_AcknowledgeIdeAndStoreStatusToBDA
     145    call    AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA
     146
    139147    mov     al, CMD_END_OF_INTERRUPT
    140     jmp     SHORT HIRQ_AcknowledgeMasterController
     148    jmp     SHORT AcknowledgeMasterInterruptController
    141149
    142150ALIGN JUMP_ALIGN
    143151HIRQ_InterruptServiceRoutineForIrqs8to15:
    144152    push    ax
    145     call    ISR_IDE_AcknowledgeIdeAndStoreStatusToBDA
     153    call    AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA
    146154
    147155    mov     al, CMD_END_OF_INTERRUPT    ; Load EOI command to AL
    148156    out     WPORT_8259SL_COMMAND, al    ; Acknowledge Slave 8259
    149 HIRQ_AcknowledgeMasterController:
     157AcknowledgeMasterInterruptController:
    150158    out     WPORT_8259MA_COMMAND, al    ; Acknowledge Master 8259
    151159
     
    156164%endif
    157165
    158     ; Restore registers and return from interrupt
    159166    pop     ax                          ; Restore AX
    160167    iret
    161 
    162168
    163169;--------------------------------------------------------------------
     
    166172; also be set.
    167173;
    168 ; ISR_IDE_AcknowledgeIdeAndStoreStatusToBDA
     174; AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA
    169175;   Parameters:
    170176;       Nothing
     
    175181;--------------------------------------------------------------------
    176182ALIGN JUMP_ALIGN
    177 ISR_IDE_AcknowledgeIdeAndStoreStatusToBDA:
     183AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA:
    178184    push    ds
    179185    push    di
    180186    push    dx
    181187
    182     ; Read Status and Error registers.
    183188    ; Reading Status Register acknowledges IDE interrupt
    184189    call    RamVars_GetSegmentToDS
    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
     190    call    HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA
     191    mov     BYTE [BDA.bHDTaskFlg], 0FFh     ; Set task flag
    196192
    197193    pop     dx
Note: See TracChangeset for help on using the changeset viewer.