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

Last change on this file since 114 was 86, checked in by krille_n_@…, 14 years ago

Size optimizations in various files in the XTIDE BIOS.
Also added a new include file for generic macros (macros.inc).

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