source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HIRQ.asm @ 34

Last change on this file since 34 was 34, checked in by aitotat, 14 years ago

OS hooks are now enabled for all builds.
IRQ waiting no longer uses HLT instruction to fix some EMM386 and VCPI issues.

File size: 4.1 KB
Line 
1; File name     :   HIRQ.asm
2; Project name  :   IDE BIOS
3; Created date  :   11.12.2009
4; Last update   :   23.8.2010
5; Author        :   Tomi Tilli
6; Description   :   Interrupt handling related functions.
7
8; Section containing code
9SECTION .text
10
11;--------------------------------------------------------------------
12; HIRQ_WaitForIRQ
13;   Parameters:
14;       DS:     RAMVARS segment
15;   Returns:
16;       CF:     Set if wait done by operating system
17;               Cleared if BIOS must perform task flag polling
18;   Corrupts registers:
19;       AX
20;--------------------------------------------------------------------
21ALIGN JUMP_ALIGN
22HIRQ_WaitForIRQ:
23    test    BYTE [bx+DPT.bDrvCtrl], FLG_IDE_CTRL_nIEN   ; Clears CF
24    jz      SHORT .NotifyOperatingSystemAboutWaitingForIRQ
25    ret     ; Go to poll status register
26
27;--------------------------------------------------------------------
28; .NotifyOperatingSystemAboutWaitingForIRQ
29;   Parameters:
30;       Nothing
31;   Returns:
32;       CF:     Set if wait done by operating system
33;               Cleared if BIOS must perform task flag polling
34;   Corrupts registers:
35;       AX
36;--------------------------------------------------------------------
37ALIGN JUMP_ALIGN
38.NotifyOperatingSystemAboutWaitingForIRQ:
39    push    ds
40
41    LOAD_BDA_SEGMENT_TO ds, ax          ; Zero AX
42    cli                                 ; Disable interrupts
43    cmp     al, [ds:BDA.bHDTaskFlg]     ; Task flag already set?
44    jc      SHORT .ReturnFromWaitNotify ;  If so, skip OS notification
45
46    mov     ah, 90h                     ; Hard disk busy (AX=9000h)
47    int     INTV_SYSTEM_SERVICES        ; OS hook, device busy
48    jnc     SHORT .ReturnFromWaitNotify ; CF cleared, BIOS handles waiting
49
50    ; Make sure that OS hooks are supported, otherwise the CF means unsupported function
51    test    ah, ah                      ; OS hook supported? (clears CF)
52    jnz     SHORT .ReturnFromWaitNotify ; AH has error, BIOS must do the wait
53    stc                                 ; Set CF since wait done by OS
54.ReturnFromWaitNotify:
55    pop     ds
56    sti                                 ; Enable interrupts
57    ret
58
59
60;--------------------------------------------------------------------
61; Clears task (interrupt) flag from BIOS Data Area.
62;
63; HIRQ_ClearTaskFlag
64;   Parameters:
65;       Nothing
66;   Returns:
67;       Nothing
68;   Corrupts registers:
69;       AX
70;--------------------------------------------------------------------
71ALIGN JUMP_ALIGN
72HIRQ_ClearTaskFlag:
73    push    ds
74    LOAD_BDA_SEGMENT_TO ds, ax      ; Also zero AX
75    mov     [BDA.bHDTaskFlg], al
76    pop     ds
77    ret
78
79
80;--------------------------------------------------------------------
81; IDE Interrupt Service Routines.
82;
83; HIRQ_InterruptServiceRoutineForIrqs2to7
84; HIRQ_InterruptServiceRoutineForIrqs8to15
85;   Parameters:
86;       Nothing
87;   Returns:
88;       Nothing
89;   Corrupts registers:
90;       Nothing
91;--------------------------------------------------------------------
92ALIGN JUMP_ALIGN
93HIRQ_InterruptServiceRoutineForIrqs2to7:
94    push    ax
95    call    AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA
96
97    mov     al, CMD_END_OF_INTERRUPT
98    jmp     SHORT AcknowledgeMasterInterruptController
99
100ALIGN JUMP_ALIGN
101HIRQ_InterruptServiceRoutineForIrqs8to15:
102    push    ax
103    call    AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA
104
105    mov     al, CMD_END_OF_INTERRUPT    ; Load EOI command to AL
106    out     WPORT_8259SL_COMMAND, al    ; Acknowledge Slave 8259
107AcknowledgeMasterInterruptController:
108    out     WPORT_8259MA_COMMAND, al    ; Acknowledge Master 8259
109
110    ; Issue Int 15h, function AX=9100h (Interrupt ready)
111    mov     ax, 9100h                   ; Interrupt ready, device 0 (HD)
112    int     INTV_SYSTEM_SERVICES
113
114    pop     ax                          ; Restore AX
115    iret
116
117;--------------------------------------------------------------------
118; Acknowledges IDE interrupt by reading status register and
119; stores Status and Error Registers to BDA. Task flag in BDA will
120; also be set.
121;
122; AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA
123;   Parameters:
124;       Nothing
125;   Returns:
126;       Nothing
127;   Corrupts registers:
128;       AX
129;--------------------------------------------------------------------
130ALIGN JUMP_ALIGN
131AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA:
132    push    ds
133    push    di
134    push    dx
135
136    ; Reading Status Register acknowledges IDE interrupt
137    call    RamVars_GetSegmentToDS
138    call    HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA
139    mov     BYTE [BDA.bHDTaskFlg], 0FFh     ; Set task flag
140
141    pop     dx
142    pop     di
143    pop     ds
144    ret
Note: See TracBrowser for help on using the repository browser.