1 | ; Project name : XTIDE Universal BIOS
|
---|
2 | ; Description : Interrupt handling related functions.
|
---|
3 |
|
---|
4 | ;
|
---|
5 | ; XTIDE Universal BIOS and Associated Tools
|
---|
6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
|
---|
7 | ;
|
---|
8 | ; This program is free software; you can redistribute it and/or modify
|
---|
9 | ; it under the terms of the GNU General Public License as published by
|
---|
10 | ; the Free Software Foundation; either version 2 of the License, or
|
---|
11 | ; (at your option) any later version.
|
---|
12 | ;
|
---|
13 | ; This program is distributed in the hope that it will be useful,
|
---|
14 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
16 | ; GNU General Public License for more details.
|
---|
17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
18 | ;
|
---|
19 |
|
---|
20 | ; Section containing code
|
---|
21 | SECTION .text
|
---|
22 |
|
---|
23 | ;--------------------------------------------------------------------
|
---|
24 | ; IdeIrq_WaitForIRQ
|
---|
25 | ; Parameters:
|
---|
26 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
27 | ; Returns:
|
---|
28 | ; Nothing
|
---|
29 | ; Corrupts registers:
|
---|
30 | ; AX
|
---|
31 | ;--------------------------------------------------------------------
|
---|
32 | ALIGN JUMP_ALIGN
|
---|
33 | IdeIrq_WaitForIRQ:
|
---|
34 | push ds
|
---|
35 |
|
---|
36 | LOAD_BDA_SEGMENT_TO ds, ax, ! ; Zero AX
|
---|
37 | mov ah, OS_HOOK_DEVICE_BUSY ; Hard disk busy (AX=9000h)
|
---|
38 | cli ; Disable interrupts
|
---|
39 | cmp al, [BDA.bHDTaskFlg] ; Task flag already set?
|
---|
40 | jc SHORT .ReturnFromWaitNotify ; If so, skip OS notification
|
---|
41 | int BIOS_SYSTEM_INTERRUPT_15h ; OS hook, device busy
|
---|
42 |
|
---|
43 | .ReturnFromWaitNotify:
|
---|
44 | sti ; Enable interrupts
|
---|
45 | pop ds
|
---|
46 | ret
|
---|
47 |
|
---|
48 |
|
---|
49 | ;--------------------------------------------------------------------
|
---|
50 | ; IDE Interrupt Service Routines.
|
---|
51 | ;
|
---|
52 | ; IdeIrq_InterruptServiceRoutineForIrqs2to7
|
---|
53 | ; IdeIrq_InterruptServiceRoutineForIrqs8to15
|
---|
54 | ; Parameters:
|
---|
55 | ; Nothing
|
---|
56 | ; Returns:
|
---|
57 | ; Nothing
|
---|
58 | ; Corrupts registers:
|
---|
59 | ; Nothing
|
---|
60 | ;--------------------------------------------------------------------
|
---|
61 | ALIGN JUMP_ALIGN
|
---|
62 | IdeIrq_InterruptServiceRoutineForIrqs2to7:
|
---|
63 | push di
|
---|
64 | push ax
|
---|
65 | call AcknowledgeIdeInterruptAndSetTaskFlag
|
---|
66 |
|
---|
67 | mov al, COMMAND_END_OF_INTERRUPT
|
---|
68 | jmp SHORT AcknowledgeMasterInterruptController
|
---|
69 |
|
---|
70 |
|
---|
71 | ALIGN JUMP_ALIGN
|
---|
72 | IdeIrq_InterruptServiceRoutineForIrqs8to15:
|
---|
73 | push di
|
---|
74 | push ax
|
---|
75 | call AcknowledgeIdeInterruptAndSetTaskFlag
|
---|
76 |
|
---|
77 | mov al, COMMAND_END_OF_INTERRUPT
|
---|
78 | out SLAVE_8259_COMMAND_out, al ; Acknowledge Slave 8259
|
---|
79 | AcknowledgeMasterInterruptController:
|
---|
80 | out MASTER_8259_COMMAND_out, al ; Acknowledge Master 8259
|
---|
81 |
|
---|
82 | ; Issue Int 15h, function AX=9100h (Interrupt ready)
|
---|
83 | clc ; Must be called with CF clear
|
---|
84 | mov ax, OS_HOOK_DEVICE_POST<<8 ; Interrupt ready, device 0 (HD)
|
---|
85 | int BIOS_SYSTEM_INTERRUPT_15h
|
---|
86 |
|
---|
87 | pop ax
|
---|
88 | pop di
|
---|
89 | iret
|
---|
90 |
|
---|
91 |
|
---|
92 | ;--------------------------------------------------------------------
|
---|
93 | ; AcknowledgeIdeInterruptAndSetTaskFlag
|
---|
94 | ; Parameters:
|
---|
95 | ; Nothing
|
---|
96 | ; Returns:
|
---|
97 | ; Nothing
|
---|
98 | ; Corrupts registers:
|
---|
99 | ; AX
|
---|
100 | ;--------------------------------------------------------------------
|
---|
101 | ALIGN JUMP_ALIGN
|
---|
102 | AcknowledgeIdeInterruptAndSetTaskFlag:
|
---|
103 | push ds
|
---|
104 | push si
|
---|
105 | push dx
|
---|
106 | push bx
|
---|
107 |
|
---|
108 | ; Reading Status Register acknowledges IDE interrupt
|
---|
109 | call RamVars_GetSegmentToDS
|
---|
110 | mov bl, FLGH_DPT_INTERRUPT_IN_SERVICE
|
---|
111 | call FindDPT_ToDSDIforFlagsHighInBL
|
---|
112 | INPUT_TO_AL_FROM_IDE_REGISTER STATUS_REGISTER_in
|
---|
113 |
|
---|
114 | ; Clear Interrupt In-Service Flag from DPT
|
---|
115 | and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_INTERRUPT_IN_SERVICE
|
---|
116 |
|
---|
117 | ; Set Task Flag
|
---|
118 | LOAD_BDA_SEGMENT_TO ds, ax
|
---|
119 | mov BYTE [BDA.bHDTaskFlg], 0FFh ; Set task flag
|
---|
120 |
|
---|
121 | pop bx
|
---|
122 | pop dx
|
---|
123 | pop si
|
---|
124 | pop ds
|
---|
125 | ret
|
---|