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

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

Changes to XTIDE Universal BIOS:

  • Redesigned Disk Parameter Tables.
  • Code generalizations for supporting non-IDE devices in the future.
File size: 3.9 KB
Line 
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:
46    pop     ds
47    sti                                 ; Enable interrupts
48    ret
49
50
51;--------------------------------------------------------------------
52; IdeIrq_SetInServiceDPTandClearTaskFlag
53;   Parameters:
54;       DS:DI:  Ptr to DPT (in RAMVARS segment)
55;   Returns:
56;       Nothing
57;   Corrupts registers:
58;       AX
59;--------------------------------------------------------------------
60ALIGN JUMP_ALIGN
61IdeIrq_SetInServiceDPTandClearTaskFlag:
62    mov     [RAMVARS.pInServiceDPT], di
63    push    ds
64    LOAD_BDA_SEGMENT_TO ds, ax, !       ; Also zero AX
65    mov     [BDA.bHDTaskFlg], al
66    pop     ds
67    ret
68
69
70;--------------------------------------------------------------------
71; IDE Interrupt Service Routines.
72;
73; IdeIrq_InterruptServiceRoutineForIrqs2to7
74; IdeIrq_InterruptServiceRoutineForIrqs8to15
75;   Parameters:
76;       Nothing
77;   Returns:
78;       Nothing
79;   Corrupts registers:
80;       Nothing
81;--------------------------------------------------------------------
82ALIGN JUMP_ALIGN
83IdeIrq_InterruptServiceRoutineForIrqs2to7:
84    push    di
85    push    ax
86    call    AcknowledgeIdeInterruptAndSetTaskFlag
87
88    mov     al, CMD_END_OF_INTERRUPT
89    jmp     SHORT AcknowledgeMasterInterruptController
90
91
92ALIGN JUMP_ALIGN
93IdeIrq_InterruptServiceRoutineForIrqs8to15:
94    push    di
95    push    ax
96    call    AcknowledgeIdeInterruptAndSetTaskFlag
97
98    mov     al, CMD_END_OF_INTERRUPT    ; Load EOI command to AL
99    out     WPORT_8259SL_COMMAND, al    ; Acknowledge Slave 8259
100AcknowledgeMasterInterruptController:
101    out     WPORT_8259MA_COMMAND, al    ; Acknowledge Master 8259
102
103    ; Issue Int 15h, function AX=9100h (Interrupt ready)
104    mov     ax, OS_HOOK_DEVICE_POST<<8  ; Interrupt ready, device 0 (HD)
105    int     BIOS_SYSTEM_INTERRUPT_15h
106
107    pop     ax
108    pop     di
109    iret
110
111
112;--------------------------------------------------------------------
113; AcknowledgeIdeInterruptAndSetTaskFlag
114;   Parameters:
115;       Nothing
116;   Returns:
117;       Nothing
118;   Corrupts registers:
119;       AX
120;--------------------------------------------------------------------
121ALIGN JUMP_ALIGN
122AcknowledgeIdeInterruptAndSetTaskFlag:
123    push    ds
124    push    dx
125    push    bx
126
127    ; Reading Status Register acknowledges IDE interrupt
128    call    RamVars_GetSegmentToDS
129    mov     di, [RAMVARS.pInServiceDPT]     ; DS:DI now points to DPT
130    mov     dl, STATUS_REGISTER_in
131    call    Device_InputToALfromIdeRegisterInDL
132
133    ; Set Task Flag
134    LOAD_BDA_SEGMENT_TO ds, ax
135    mov     BYTE [BDA.bHDTaskFlg], 0FFh     ; Set task flag
136
137    pop     bx
138    pop     dx
139    pop     ds
140    ret
Note: See TracBrowser for help on using the repository browser.