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

Last change on this file since 84 was 35, checked in by Tomi Tilli, 14 years ago

Cleaned recent changes a bit to save few bytes.

File size: 4.2 KB
Line 
1; File name : HIRQ.asm
2; Project name : IDE BIOS
3; Created date : 11.12.2009
4; Last update : 24.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
100
101ALIGN JUMP_ALIGN
102HIRQ_InterruptServiceRoutineForIrqs8to15:
103 push ax
104 call AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA
105
106 mov al, CMD_END_OF_INTERRUPT ; Load EOI command to AL
107 out WPORT_8259SL_COMMAND, al ; Acknowledge Slave 8259
108AcknowledgeMasterInterruptController:
109 out WPORT_8259MA_COMMAND, al ; Acknowledge Master 8259
110
111 ; Issue Int 15h, function AX=9100h (Interrupt ready)
112 mov ax, 9100h ; Interrupt ready, device 0 (HD)
113 int INTV_SYSTEM_SERVICES
114
115 pop ax ; Restore AX
116 iret
117
118;--------------------------------------------------------------------
119; Acknowledges IDE interrupt by reading status register and
120; stores Status and Error Registers to BDA. Task flag in BDA will
121; also be set.
122;
123; AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA
124; Parameters:
125; Nothing
126; Returns:
127; Nothing
128; Corrupts registers:
129; AX
130;--------------------------------------------------------------------
131ALIGN JUMP_ALIGN
132AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA:
133 push ds
134 push di
135
136 ; Reading Status Register acknowledges IDE interrupt
137 call RamVars_GetSegmentToDS
138 call HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA
139
140 ; Set Task Flag
141 LOAD_BDA_SEGMENT_TO ds, ax
142 mov BYTE [BDA.bHDTaskFlg], 0FFh ; Set task flag
143
144 pop di
145 pop ds
146 ret
Note: See TracBrowser for help on using the repository browser.