Subversion Repositories Kolibri OS

Rev

Rev 2103 | Rev 2384 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2103 Rev 2112
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2009. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2009. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 7...
7
 
7
 
Line 8... Line 8...
8
$Revision: 2103 $
8
$Revision: 2112 $
9
 
9
 
Line 10... Line 10...
10
 
10
 
11
DRV_COMPAT   equ  5  ;minimal required drivers version
11
DRV_COMPAT   equ  5  ;minimal required drivers version
Line 12... Line -...
12
DRV_CURRENT  equ  6  ;current drivers model version
-
 
13
 
-
 
14
DRV_VERSION equ (DRV_COMPAT shl 16) or DRV_CURRENT
-
 
15
PID_KERNEL  equ 1    ;os_idle thread
-
 
16
 
-
 
17
align 4
-
 
18
proc attach_int_handler stdcall, irq:dword, handler:dword, access_rights:dword
-
 
19
 
-
 
20
         pushfd
-
 
21
         cli
-
 
22
 
-
 
23
         push ebx
-
 
24
 
-
 
25
         mov  ebx, [irq]                   ;irq num
-
 
26
         test ebx, ebx
-
 
27
         jz   .err
-
 
28
         cmp  ebx, 15                      ; hidnplayr says: we only have 16 IRQ's
-
 
29
         ja   .err
-
 
30
         mov  eax, [handler]
-
 
31
         test eax, eax
-
 
32
         jz   .err
-
 
33
 
-
 
34
         mov  [irq_tab+ebx*4], eax
-
 
35
         stdcall enable_irq, [irq]
-
 
36
         pop ebx
-
 
37
         mov eax, 1
-
 
38
         popfd
-
 
39
         ret
-
 
40
.err:
-
 
41
         pop ebx
-
 
42
         xor eax, eax
-
 
43
         popfd
-
 
44
         ret
-
 
45
endp
-
 
46
 
-
 
47
align 4
-
 
48
proc get_int_handler stdcall, irq:dword
-
 
49
 
-
 
50
        mov eax, [irq]
-
 
51
        cmp eax, 15
-
 
52
        ja .fail
-
 
53
        mov eax, [irq_tab + 4 * eax]
-
 
Line 54... Line -...
54
        ret
-
 
55
.fail:
-
 
56
        xor eax, eax
-
 
57
        ret
-
 
58
endp
-
 
59
 
-
 
60
align 4
-
 
61
proc  detach_int_handler
-
 
62
 
-
 
63
	   ret
-
 
64
endp
-
 
65
 
-
 
66
align 4
-
 
67
proc enable_irq stdcall, irq_line:dword
-
 
68
	   mov ebx, [irq_line]
-
 
69
	   mov edx, 0x21
-
 
70
	   cmp ebx, 8
-
 
71
	   jb @F
-
 
72
	   mov edx, 0xA1
-
 
73
	   sub ebx,8
-
 
74
@@:
-
 
75
	   in al,dx
-
 
76
	   btr eax, ebx
-
 
77
	   out dx, al
-
 
78
	   ret
-
 
79
endp
-
 
80
 
-
 
81
align 16
-
 
82
;; proc irq_serv
-
 
83
 
-
 
84
irq_serv:
-
 
85
 
-
 
86
.irq_1:
-
 
87
	   push 1
-
 
88
	   jmp .main
-
 
89
align 4
-
 
90
.irq_2:
-
 
91
	   push 2
-
 
92
	   jmp .main
-
 
93
align 4
-
 
94
.irq_3:
-
 
95
	   push 3
-
 
96
	   jmp .main
-
 
97
align 4
-
 
98
.irq_4:
-
 
99
	   push 4
-
 
100
	   jmp .main
-
 
101
align 4
-
 
102
.irq_5:
-
 
103
	   push 5
-
 
104
	   jmp .main
-
 
105
align 4
-
 
106
.irq_6:
-
 
107
	   push 6
-
 
108
	   jmp .main
-
 
109
align 4
-
 
110
.irq_7:
-
 
111
	   push 7
-
 
112
	   jmp .main
-
 
113
align 4
-
 
114
.irq_8:
-
 
115
	   push 8
-
 
116
	   jmp .main
-
 
117
align 4
-
 
118
.irq_9:
-
 
119
	   push 9
-
 
120
	   jmp .main
-
 
121
align 4
-
 
122
.irq_10:
-
 
123
	   push 10
-
 
124
	   jmp .main
-
 
125
align 4
-
 
126
.irq_11:
-
 
127
	   push 11
-
 
128
	   jmp .main
-
 
129
align 4
-
 
130
.irq_12:
-
 
131
	   push 12
-
 
132
	   jmp .main
-
 
133
; align 4
-
 
134
; .irq_13:
-
 
135
;	   push 13
-
 
136
;	   jmp .main
-
 
137
align 4
-
 
138
.irq_14:
-
 
139
	   push 14
-
 
140
	   jmp .main
-
 
141
align 4
-
 
142
.irq_15:
-
 
143
	   push 15
-
 
144
	   jmp .main
-
 
145
 
-
 
146
align 16
-
 
147
.main:
-
 
148
	   save_ring3_context
-
 
149
	   mov	 eax, [esp + 32]
-
 
150
	   mov	 bx, app_data  ;os_data
-
 
151
	   mov	 ds, bx
-
 
152
	   mov	 es, bx
-
 
153
 
-
 
154
	   cmp	 [v86_irqhooks+eax*8], 0
-
 
155
	   jnz	 v86_irq
-
 
156
 
-
 
157
	   cmp   al, 6
-
 
158
	   jnz   @f
-
 
159
	   push  eax
-
 
160
	   call  [fdc_irq_func]
-
 
161
	   mov	[check_idle_semaphore],5
-
 
162
	   pop   eax
-
 
163
@@:
-
 
164
 
-
 
165
	   cmp   al, 14
-
 
166
	   jnz   @f
-
 
167
	   push  eax
-
 
168
	   call  [irq14_func]
-
 
169
	   mov	[check_idle_semaphore],5
-
 
170
	   pop   eax
-
 
171
@@:
-
 
172
	   cmp   al, 15
-
 
173
	   jnz   @f
-
 
174
	   push  eax
-
 
175
	   call  [irq15_func]
-
 
176
	   mov	[check_idle_semaphore],5
-
 
177
	   pop   eax
-
 
178
@@:
-
 
179
 
-
 
180
	   mov ebx, [irq_tab+eax*4]
-
 
181
	   test ebx, ebx
-
 
182
	   jz .exit
-
 
183
 
-
 
184
	   call ebx
-
 
185
	   mov	[check_idle_semaphore],5
-
 
186
 
-
 
187
.exit:
-
 
188
 
-
 
189
       cmp dword [esp + 32], 8
-
 
190
	   mov al, 0x20
-
 
191
	   jb @f
-
 
192
       out 0xa0, al
-
 
193
@@:
-
 
Line 194... Line 12...
194
	   out 0x20, al
12
DRV_CURRENT  equ  6  ;current drivers model version
195
 
13
 
Line 196... Line 14...
196
	   restore_ring3_context
14
DRV_VERSION equ (DRV_COMPAT shl 16) or DRV_CURRENT
Line 801... Line 619...
801
	   jnz .fix_sec
619
	   jnz .fix_sec
802
.exit:
620
.exit:
803
	   ret
621
	   ret
804
endp
622
endp
Line -... Line 623...
-
 
623
 
805
 
624
align 4
806
proc rebase_coff stdcall uses ebx esi, coff:dword, sym:dword, \
625
proc rebase_coff stdcall uses ebx esi, coff:dword, sym:dword, \
807
	delta:dword
626
	delta:dword
808
	   locals
627
	   locals
809
	     n_sec     dd ?
628
	     n_sec     dd ?
Line 1624... Line 1443...
1624
	   mov [eax+12], edx
1443
	   mov [eax+12], edx
1625
	   mov [eax+16], edx
1444
	   mov [eax+16], edx
Line 1626... Line 1445...
1626
 
1445
 
1627
	   call free	       ;release object memory
1446
	   call free	       ;release object memory
1628
	   ret
-
 
1629
 
-
 
1630
 
-
 
1631
 
-
 
1632
if 0
-
 
1633
 
-
 
1634
irq:
-
 
1635
 
-
 
1636
.irq0:
-
 
1637
	   pusfd
-
 
1638
	   pushad
-
 
1639
	   push IRQ_0
-
 
1640
	   jmp .master
-
 
1641
.irq_1:
-
 
1642
	   pusfd
-
 
1643
	   pushad
-
 
1644
	   push IRQ_1
-
 
1645
	   jmp .master
-
 
1646
 
-
 
1647
.master:
-
 
1648
	   mov ax, app_data
-
 
1649
	   mov ds, eax
-
 
1650
	   mov es, eax
-
 
1651
	   mov ebx, [esp+4]  ;IRQ_xx
-
 
1652
	   mov eax, [irq_handlers+ebx+4]
-
 
1653
	   call intr_handler
-
 
1654
	   mov ecx, [esp+4]
-
 
1655
	   cmp [irq_actids+ecx*4], 0
-
 
1656
	   je @F
-
 
1657
	   in al, 0x21
-
 
1658
	   bts eax, ecx
-
 
1659
	   out 0x21, al
-
 
1660
	   mov al, 0x20
-
 
1661
	   out 0x20, al
-
 
1662
	   jmp .restart
-
 
1663
 
-
 
1664
.slave:
-
 
1665
	   mov ax, app_data
-
 
1666
	   mov ds, eax
-
 
1667
	   mov es, eax
-
 
1668
	   mov ebx, [esp+4]  ;IRQ_xx
-
 
1669
	   mov eax, [irq_handlers+ebx+4]
-
 
1670
	   call intr_handler
-
 
1671
	   mov ecx, [esp+4]
-
 
1672
	   sub ecx, 8
-
 
1673
	   cmp [irq_actids+ecx*4], 0
-
 
1674
	   je @F
-
 
1675
	   in al, 0xA1
-
 
1676
	   bts eax, ecx
-
 
1677
	   out 0xA1, al
-
 
1678
	   mov al, 0x20
-
 
1679
	   out 0xA0, al
-
 
1680
	   out 0x20, al
-
 
1681
.restart:
-
 
1682
	   mov ebx, [next_slot]
-
 
1683
	   test ebx, ebx
-
 
1684
	   jz @F
-
 
1685
	   mov [next_task],0
-
 
1686
	   mov esi, [prev_slot]
-
 
1687
	   call do_change_task
-
 
1688
	   add esp, 4
-
 
1689
	   iretd
-
 
1690
 
-
 
1691
end if
-
 
1692
-
 
1693
-
 
1694
-