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

Last change on this file since 147 was 116, checked in by krille_n_@…, 13 years ago

Changes to all parts of the project:

  • Removed a redundant macro (HPIO_NORMALIZE_PTR)
  • Deleted XTIDE_Universal_BIOS/Inc/BiosData.inc since that was also redundant.
  • Size optimization: Changed the LOAD_BDA_SEGMENT_TO macro to use the stack on 186+ processors (the old behaviour can still be used where needed).
  • Made other minor size optimizations and cleanups to various functions, mostly in the Int13h handler.
File size: 4.1 KB
RevLine 
[116]1; Project name : XTIDE Universal BIOS
[3]2; Description : Interrupt handling related functions.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
[34]8; HIRQ_WaitForIRQ
[3]9; Parameters:
10; DS: RAMVARS segment
11; Returns:
[34]12; CF: Set if wait done by operating system
13; Cleared if BIOS must perform task flag polling
[3]14; Corrupts registers:
[34]15; AX
[3]16;--------------------------------------------------------------------
17ALIGN JUMP_ALIGN
[34]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
[3]22
[28]23;--------------------------------------------------------------------
24; .NotifyOperatingSystemAboutWaitingForIRQ
25; Parameters:
[34]26; Nothing
[28]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:
[34]35 push ds
36
[116]37 LOAD_BDA_SEGMENT_TO ds, ax, ! ; Zero AX
[3]38 cli ; Disable interrupts
[86]39 cmp al, [BDA.bHDTaskFlg] ; Task flag already set?
[28]40 jc SHORT .ReturnFromWaitNotify ; If so, skip OS notification
[3]41
42 mov ah, 90h ; Hard disk busy (AX=9000h)
43 int INTV_SYSTEM_SERVICES ; OS hook, device busy
[28]44 jnc SHORT .ReturnFromWaitNotify ; CF cleared, BIOS handles waiting
[3]45
[28]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:
[34]51 pop ds
[3]52 sti ; Enable interrupts
53 ret
54
[28]55
[3]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
[116]70 LOAD_BDA_SEGMENT_TO ds, ax, ! ; Also zero AX
[3]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
[28]91 call AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA
92
[3]93 mov al, CMD_END_OF_INTERRUPT
[28]94 jmp SHORT AcknowledgeMasterInterruptController
[3]95
[35]96
[3]97ALIGN JUMP_ALIGN
98HIRQ_InterruptServiceRoutineForIrqs8to15:
99 push ax
[28]100 call AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA
[3]101
102 mov al, CMD_END_OF_INTERRUPT ; Load EOI command to AL
103 out WPORT_8259SL_COMMAND, al ; Acknowledge Slave 8259
[28]104AcknowledgeMasterInterruptController:
[3]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;
[28]119; AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA
[3]120; Parameters:
121; Nothing
122; Returns:
123; Nothing
124; Corrupts registers:
125; AX
126;--------------------------------------------------------------------
127ALIGN JUMP_ALIGN
[28]128AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA:
[3]129 push ds
130 push di
131
132 ; Reading Status Register acknowledges IDE interrupt
[34]133 call RamVars_GetSegmentToDS
134 call HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA
[35]135
136 ; Set Task Flag
137 LOAD_BDA_SEGMENT_TO ds, ax
[28]138 mov BYTE [BDA.bHDTaskFlg], 0FFh ; Set task flag
[3]139
140 pop di
141 pop ds
142 ret
Note: See TracBrowser for help on using the repository browser.