source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeIrq.asm@ 208

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

Changes to XTIDE Universal BIOS:

  • Minor size optimizations.
  • Tried to minimize the time spent with interrupts disabled in IdeIrq.asm and Int13h.asm
File size: 3.5 KB
RevLine 
[150]1; Project name : XTIDE Universal BIOS
2; Description : Interrupt handling related functions.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; IdeIrq_WaitForIRQ
9; Parameters:
10; DS:DI: Ptr to DPT (in 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
18IdeIrq_WaitForIRQ:
19
20;--------------------------------------------------------------------
21; .NotifyOperatingSystemAboutWaitingForIRQ
22; Parameters:
23; Nothing
24; Returns:
25; CF: Set if wait done by operating system
26; Cleared if BIOS must perform task flag polling
27; Corrupts registers:
28; AX
29;--------------------------------------------------------------------
30.NotifyOperatingSystemAboutWaitingForIRQ:
31 push ds
32
33 LOAD_BDA_SEGMENT_TO ds, ax, ! ; Zero AX
34 mov ah, OS_HOOK_DEVICE_BUSY ; Hard disk busy (AX=9000h)
35 cli ; Disable interrupts
36 cmp al, [BDA.bHDTaskFlg] ; Task flag already set?
37 jc SHORT .ReturnFromWaitNotify ; If so, skip OS notification
38 int BIOS_SYSTEM_INTERRUPT_15h ; OS hook, device busy
39 jnc SHORT .ReturnFromWaitNotify ; CF cleared, BIOS handles waiting
40
41 ; Make sure that OS hooks are supported, otherwise the CF means unsupported function
42 test ah, ah ; OS hook supported? (clears CF)
43 jnz SHORT .ReturnFromWaitNotify ; AH has error, BIOS must do the wait
44 stc ; Set CF since wait done by OS
45.ReturnFromWaitNotify:
[161]46 sti ; Enable interrupts
[150]47 pop ds
48 ret
49
50
51;--------------------------------------------------------------------
52; IDE Interrupt Service Routines.
53;
54; IdeIrq_InterruptServiceRoutineForIrqs2to7
55; IdeIrq_InterruptServiceRoutineForIrqs8to15
56; Parameters:
57; Nothing
58; Returns:
59; Nothing
60; Corrupts registers:
61; Nothing
62;--------------------------------------------------------------------
63ALIGN JUMP_ALIGN
64IdeIrq_InterruptServiceRoutineForIrqs2to7:
65 push di
66 push ax
67 call AcknowledgeIdeInterruptAndSetTaskFlag
68
[152]69 mov al, COMMAND_END_OF_INTERRUPT
[150]70 jmp SHORT AcknowledgeMasterInterruptController
71
72
73ALIGN JUMP_ALIGN
74IdeIrq_InterruptServiceRoutineForIrqs8to15:
75 push di
76 push ax
77 call AcknowledgeIdeInterruptAndSetTaskFlag
78
[152]79 mov al, COMMAND_END_OF_INTERRUPT
80 out SLAVE_8259_COMMAND_out, al ; Acknowledge Slave 8259
[150]81AcknowledgeMasterInterruptController:
[152]82 out MASTER_8259_COMMAND_out, al ; Acknowledge Master 8259
[150]83
84 ; Issue Int 15h, function AX=9100h (Interrupt ready)
85 mov ax, OS_HOOK_DEVICE_POST<<8 ; Interrupt ready, device 0 (HD)
86 int BIOS_SYSTEM_INTERRUPT_15h
87
88 pop ax
89 pop di
90 iret
91
92
93;--------------------------------------------------------------------
94; AcknowledgeIdeInterruptAndSetTaskFlag
95; Parameters:
96; Nothing
97; Returns:
98; Nothing
99; Corrupts registers:
100; AX
101;--------------------------------------------------------------------
102ALIGN JUMP_ALIGN
103AcknowledgeIdeInterruptAndSetTaskFlag:
104 push ds
[152]105 push si
[150]106 push dx
107 push bx
108
109 ; Reading Status Register acknowledges IDE interrupt
110 call RamVars_GetSegmentToDS
[152]111 call FindDPT_ToDSDIforInterruptInService
[150]112 mov dl, STATUS_REGISTER_in
[160]113 call IdeIO_InputToALfromIdeRegisterInDL
[150]114
[152]115 ; Clear Interrupt In-Service Flag from DPT
[158]116 and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_INTERRUPT_IN_SERVICE
[152]117
[150]118 ; Set Task Flag
119 LOAD_BDA_SEGMENT_TO ds, ax
120 mov BYTE [BDA.bHDTaskFlg], 0FFh ; Set task flag
121
122 pop bx
123 pop dx
[152]124 pop si
[150]125 pop ds
126 ret
Note: See TracBrowser for help on using the repository browser.