2005-10-06 19:56:22 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; IRQ0 HANDLER (TIMER INTERRUPT) ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
align 32
|
|
|
|
irq0:
|
2006-01-25 14:19:21 +01:00
|
|
|
save_ring3_context
|
2005-10-16 15:30:23 +02:00
|
|
|
mov ax, os_data
|
|
|
|
mov ds, ax
|
|
|
|
mov es, ax
|
2005-10-06 19:56:22 +02:00
|
|
|
|
|
|
|
mov edi,[0x3000]
|
|
|
|
shl edi, 3
|
|
|
|
; fields of TSS descriptor:
|
2006-04-10 17:20:34 +02:00
|
|
|
; mov [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b
|
2005-10-06 19:56:22 +02:00
|
|
|
|
|
|
|
inc dword [timer_ticks]
|
|
|
|
|
|
|
|
mov eax, [timer_ticks]
|
2005-11-10 18:59:41 +01:00
|
|
|
call playNote ; <<<--- Speaker driver
|
|
|
|
|
2005-10-06 19:56:22 +02:00
|
|
|
cmp eax,[next_usage_update]
|
|
|
|
jb .nocounter
|
|
|
|
add eax,100
|
|
|
|
mov [next_usage_update],eax
|
|
|
|
call updatecputimes
|
|
|
|
.nocounter:
|
|
|
|
|
|
|
|
mov edi, [0x3010]
|
|
|
|
|
|
|
|
mov ebx, [edi+0x18] ; time stamp counter add
|
|
|
|
call _rdtsc
|
|
|
|
sub eax, ebx
|
|
|
|
add eax, [edi+0x14] ; counter sum
|
|
|
|
mov [edi+0x14], eax
|
|
|
|
|
|
|
|
mov ebx,[0x3000]
|
2005-11-07 16:50:30 +01:00
|
|
|
mov [prev_slot], ebx
|
2005-10-06 19:56:22 +02:00
|
|
|
|
2005-10-16 15:30:23 +02:00
|
|
|
cmp [0xffff], byte 1
|
|
|
|
je .do_not_change_task
|
2005-10-06 19:56:22 +02:00
|
|
|
|
2005-11-07 16:50:30 +01:00
|
|
|
|
2005-10-06 19:56:22 +02:00
|
|
|
.waiting_for_termination:
|
|
|
|
.waiting_for_reuse:
|
2005-11-07 16:50:30 +01:00
|
|
|
.waiting_for_event:
|
2006-01-25 14:19:21 +01:00
|
|
|
.suspended:
|
2005-11-07 16:50:30 +01:00
|
|
|
cmp ebx, [0x3004]
|
|
|
|
jb @f
|
|
|
|
mov edi, 0x3000
|
|
|
|
xor ebx, ebx
|
|
|
|
@@:
|
|
|
|
|
2005-10-06 19:56:22 +02:00
|
|
|
add edi,0x20
|
|
|
|
inc ebx
|
|
|
|
|
|
|
|
mov al, byte [edi+0xA]
|
2006-01-25 14:19:21 +01:00
|
|
|
cmp al, 1
|
|
|
|
jz .suspended
|
|
|
|
cmp al, 2
|
|
|
|
jz .suspended
|
2005-10-06 19:56:22 +02:00
|
|
|
cmp al, 3
|
|
|
|
je .waiting_for_termination
|
|
|
|
cmp al, 4
|
|
|
|
je .waiting_for_termination
|
|
|
|
cmp al, 9
|
|
|
|
je .waiting_for_reuse
|
|
|
|
|
|
|
|
mov [0x3000],ebx
|
|
|
|
mov [0x3010],edi
|
|
|
|
|
2005-11-07 16:50:30 +01:00
|
|
|
cmp al, 5
|
|
|
|
jne .noevents
|
|
|
|
call get_event_for_app
|
|
|
|
test eax, eax
|
|
|
|
jz .waiting_for_event
|
|
|
|
mov [event_sched], eax
|
|
|
|
mov [edi+0xA], byte 0
|
2005-11-25 08:33:08 +01:00
|
|
|
.noevents:
|
2005-11-07 16:50:30 +01:00
|
|
|
cmp ebx, [prev_slot]
|
|
|
|
sete [0xffff]
|
|
|
|
|
|
|
|
|
2005-10-16 15:30:23 +02:00
|
|
|
.do_not_change_task:
|
2005-10-06 19:56:22 +02:00
|
|
|
|
|
|
|
call _rdtsc
|
|
|
|
mov [edi+0x18],eax
|
|
|
|
|
|
|
|
shl ebx, 3
|
|
|
|
xor eax, eax
|
|
|
|
add ebx, tss0
|
2005-10-27 14:40:46 +02:00
|
|
|
mov word [far_jump.sel], bx ; selector
|
|
|
|
mov dword [far_jump.offs], eax ; offset
|
2006-07-14 12:42:05 +02:00
|
|
|
|
|
|
|
cmp [irq0needeoi],byte 0
|
|
|
|
mov [irq0needeoi],byte 1
|
|
|
|
jz .noeoi
|
2005-10-06 19:56:22 +02:00
|
|
|
|
|
|
|
mov al,0x20 ; send End Of Interrupt signal
|
|
|
|
mov dx,0x20
|
|
|
|
out dx,al
|
2006-07-14 12:42:05 +02:00
|
|
|
.noeoi:
|
2005-10-16 15:30:23 +02:00
|
|
|
|
2005-10-17 17:53:11 +02:00
|
|
|
cmp [0xffff],byte 0
|
|
|
|
je .switch
|
|
|
|
dec byte [0xffff]
|
2005-10-24 19:14:59 +02:00
|
|
|
jz @f
|
2005-10-17 17:53:11 +02:00
|
|
|
.switch:
|
2005-10-27 14:40:46 +02:00
|
|
|
jmp pword [far_jump]
|
2005-10-17 17:53:11 +02:00
|
|
|
inc [context_counter] ;noname & halyavin
|
2005-10-16 15:30:23 +02:00
|
|
|
@@:
|
2005-10-17 17:53:11 +02:00
|
|
|
|
2006-01-25 14:19:21 +01:00
|
|
|
restore_ring3_context
|
2005-10-16 15:30:23 +02:00
|
|
|
iret
|
|
|
|
|
|
|
|
|
|
|
|
uglobal
|
2005-11-07 16:50:30 +01:00
|
|
|
align 4
|
2005-10-27 14:40:46 +02:00
|
|
|
far_jump:
|
|
|
|
.offs dd ?
|
|
|
|
.sel dw ?
|
|
|
|
context_counter dd ? ;noname & halyavin
|
|
|
|
next_usage_update dd ?
|
|
|
|
timer_ticks dd ?
|
2005-11-07 16:50:30 +01:00
|
|
|
prev_slot dd ?
|
|
|
|
event_sched dd ?
|
2005-10-06 19:56:22 +02:00
|
|
|
endg
|
2006-07-14 12:42:05 +02:00
|
|
|
iglobal
|
|
|
|
irq0needeoi db 1
|
|
|
|
endg
|
2005-10-06 19:56:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
change_task:
|
|
|
|
|
2006-07-14 12:42:05 +02:00
|
|
|
pushfd
|
|
|
|
cli
|
2005-10-06 19:56:22 +02:00
|
|
|
mov [0xffff],byte 2
|
|
|
|
|
2006-07-14 12:42:05 +02:00
|
|
|
mov [irq0needeoi],byte 0
|
2005-10-06 19:56:22 +02:00
|
|
|
dec dword [timer_ticks] ; because irq0 will increase it
|
|
|
|
|
|
|
|
int 0x20 ; irq0 handler
|
2006-07-14 12:42:05 +02:00
|
|
|
popfd
|
2005-10-06 19:56:22 +02:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
updatecputimes:
|
|
|
|
|
|
|
|
mov eax,[idleuse]
|
|
|
|
mov [idleusesec],eax
|
|
|
|
mov [idleuse],dword 0
|
|
|
|
mov ecx, [0x3004]
|
|
|
|
mov edi, 0x3020
|
|
|
|
.newupdate:
|
|
|
|
mov ebx,[edi+0x14]
|
|
|
|
mov [edi+0x1c],ebx
|
|
|
|
mov [edi+0x14],dword 0
|
|
|
|
add edi,0x20
|
|
|
|
dec ecx
|
|
|
|
jnz .newupdate
|
|
|
|
|
|
|
|
ret
|