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

Last change on this file since 148 was 148, checked in by aitotat, 13 years ago

Changes to XTIDE Universal BIOS:

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