Subversion Repositories Kolibri OS

Rev

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

Rev 387 Rev 420
Line 3... Line 3...
3
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 4... Line 4...
4
 
4
 
5
 
5
 
-
 
6
align 32
6
align 32
7
irq0:
7
irq0:
8
        pushfd
8
        save_ring3_context
9
        pushad
9
	mov   ax, os_data
10
        mov   ax, app_data  ;
Line 10... Line 11...
10
	mov   ds, ax
11
        mov   ds, ax
Line 19... Line 20...
19
        jb    .nocounter
20
        jb    .nocounter
20
        add   eax,100
21
        add   eax,100
21
        mov   [next_usage_update],eax
22
        mov   [next_usage_update],eax
22
        call  updatecputimes
23
        call  updatecputimes
23
     .nocounter:
24
.nocounter:
24
 
-
 
25
        cmp   [DONT_SWITCH], byte 1
25
        cmp   [DONT_SWITCH], byte 1
26
        jne   .change_task
26
        jne   .change_task
Line 27... Line 27...
27
 
27
 
28
        mov   al,0x20   ; send End Of Interrupt signal
28
        mov   al,0x20   ; send End Of Interrupt signal
29
        mov   dx,0x20
29
        mov   dx,0x20
Line 30... Line 30...
30
        out   dx,al
30
        out   dx,al
Line -... Line 31...
-
 
31
 
31
 
32
        mov   [DONT_SWITCH], byte 0
32
        mov   [DONT_SWITCH], byte 0
33
 
Line 33... Line 34...
33
 
34
        popad
34
        restore_ring3_context
35
        popfd
Line 35... Line 36...
35
        iret
36
        iretd
Line 48... Line 49...
48
        jnz   .return
49
        jnz   .return
Line 49... Line 50...
49
 
50
 
Line 50... Line 51...
50
        call  do_change_task
51
        call  do_change_task
-
 
52
 
51
 
53
.return:
52
     .return:
54
        popad
Line 53... Line 55...
53
        restore_ring3_context
55
        popfd
54
        iret
56
        iretd
Line 83... Line 85...
83
        call  do_change_task
85
        call  do_change_task
Line 84... Line 86...
84
 
86
 
85
     .return:
87
.return:
86
        popad
88
        popad
87
        popfd
-
 
88
 
89
        popfd
Line 89... Line 90...
89
        ret
90
        ret
90
 
91
 
Line 103... Line 104...
103
 
104
 
104
 
105
 
105
update_counters:
106
update_counters:
106
        mov   edi, [TASK_BASE]
107
        mov   edi, [TASK_BASE]
107
        mov   ebx, [edi+TASKDATA.counter_add] ; time stamp counter add
108
        mov   ebx, [edi+TASKDATA.counter_add] ; time stamp counter add
108
        call  _rdtsc
109
        rdtsc
109
        sub   eax, ebx
110
        sub   eax, ebx
110
        add   eax, [edi+TASKDATA.counter_sum] ; counter sum
111
        add   eax, [edi+TASKDATA.counter_sum] ; counter sum
Line 162... Line 163...
162
        mov   [edi+TASKDATA.state], byte 0
163
        mov   [edi+TASKDATA.state], byte 0
163
      .noevents:
164
.noevents:
164
      .found:
165
.found:
165
        mov   [CURRENT_TASK],ebx
166
        mov   [CURRENT_TASK],ebx
166
        mov   [TASK_BASE],edi
167
        mov   [TASK_BASE],edi
167
        call  _rdtsc
168
        rdtsc                     ;call  _rdtsc
168
        mov   [edi+TASKDATA.counter_add],eax
169
        mov   [edi+TASKDATA.counter_add],eax
Line -... Line 170...
-
 
170
 
169
 
171
        mov esi, [prev_slot]
170
	xor   eax, eax
172
	xor   eax, eax
171
        cmp   ebx, [prev_slot]
173
        cmp   ebx, esi
172
        sete  al
174
        sete  al
Line 173... Line 175...
173
ret
175
ret
-
 
176
 
-
 
177
; in: ebx = TSS selector index
-
 
178
;
-
 
179
; param
-
 
180
;  ebx = incoming task
174
 
181
;  esi = outcomig task
-
 
182
 
175
; in: ebx = TSS selector index
183
do_change_task:
-
 
184
 
-
 
185
        shl ebx, 8
-
 
186
        add ebx, SLOT_BASE
-
 
187
        mov [current_slot], ebx
-
 
188
        shl esi, 8
-
 
189
        add esi, SLOT_BASE
-
 
190
 
-
 
191
        mov [esi+APPDATA.saved_esp], esp
-
 
192
        mov esp, [ebx+APPDATA.saved_esp]
176
do_change_task:
193
 
-
 
194
        mov eax, [ebx+APPDATA.dir_table]
-
 
195
        mov cr3, eax
177
        shl   ebx, 3
196
 
178
        xor   eax, eax
197
        mov ebx, [ebx+APPDATA.pl0_stack]
-
 
198
        add ebx, RING0_STACK_SIZE
179
        add   ebx, tss0
199
        mov [tss_data+TSS._esp0], ebx
180
        mov   [far_jump.sel],  bx   ; selector
200
        mov ecx, cr0
181
        mov   [far_jump.offs], eax  ; offset
201
        or ecx, CR0_TS   ;set task switch flag
-
 
202
        mov cr0, ecx
182
        jmp   pword [far_jump]
203
        inc   [context_counter] ;noname & halyavin
Line -... Line 204...
-
 
204
 
-
 
205
        ret
-
 
206
 
-
 
207
;
-
 
208
;        shl   ebx, 3
-
 
209
;        xor   eax, eax
-
 
210
;        add   ebx, tss0
-
 
211
;        mov   [far_jump.sel],  bx   ; selector
-
 
212
;        mov   [far_jump.offs], eax  ; offset
-
 
213
;        jmp   pword [far_jump]
Line 183... Line 214...
183
        inc   [context_counter] ;noname & halyavin
214
;        inc   [context_counter] ;noname & halyavin
184
ret
215
;ret