Rev 26 | Rev 66 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 26 | Rev 40 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; IRQ0 HANDLER (TIMER INTERRUPT) ;; |
2 | ;; IRQ0 HANDLER (TIMER INTERRUPT) ;; |
3 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
3 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4 | 4 | ||
5 | align 32 |
5 | align 32 |
6 | irq0: |
6 | irq0: |
7 | pushad |
- | |
8 | push ds es |
7 | save_ring3_context |
9 | mov ax, os_data |
8 | mov ax, os_data |
10 | mov ds, ax |
9 | mov ds, ax |
11 | mov es, ax |
10 | mov es, ax |
12 | 11 | ||
13 | mov edi,[0x3000] |
12 | mov edi,[0x3000] |
14 | shl edi, 3 |
13 | shl edi, 3 |
15 | ; fields of TSS descriptor: |
14 | ; fields of TSS descriptor: |
16 | mov [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b |
15 | mov [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b |
17 | 16 | ||
18 | inc dword [timer_ticks] |
17 | inc dword [timer_ticks] |
19 | 18 | ||
20 | mov eax, [timer_ticks] |
19 | mov eax, [timer_ticks] |
21 | call playNote ; <<<--- Speaker driver |
20 | call playNote ; <<<--- Speaker driver |
22 | 21 | ||
23 | cmp eax,[next_usage_update] |
22 | cmp eax,[next_usage_update] |
24 | jb .nocounter |
23 | jb .nocounter |
25 | add eax,100 |
24 | add eax,100 |
26 | mov [next_usage_update],eax |
25 | mov [next_usage_update],eax |
27 | call updatecputimes |
26 | call updatecputimes |
28 | .nocounter: |
27 | .nocounter: |
29 | 28 | ||
30 | mov edi, [0x3010] |
29 | mov edi, [0x3010] |
31 | 30 | ||
32 | mov ebx, [edi+0x18] ; time stamp counter add |
31 | mov ebx, [edi+0x18] ; time stamp counter add |
33 | call _rdtsc |
32 | call _rdtsc |
34 | sub eax, ebx |
33 | sub eax, ebx |
35 | add eax, [edi+0x14] ; counter sum |
34 | add eax, [edi+0x14] ; counter sum |
36 | mov [edi+0x14], eax |
35 | mov [edi+0x14], eax |
37 | 36 | ||
38 | mov ebx,[0x3000] |
37 | mov ebx,[0x3000] |
39 | mov [prev_slot], ebx |
38 | mov [prev_slot], ebx |
40 | 39 | ||
41 | cmp [0xffff], byte 1 |
40 | cmp [0xffff], byte 1 |
42 | je .do_not_change_task |
41 | je .do_not_change_task |
43 | 42 | ||
44 | 43 | ||
45 | .waiting_for_termination: |
44 | .waiting_for_termination: |
46 | .waiting_for_reuse: |
45 | .waiting_for_reuse: |
47 | .waiting_for_event: |
46 | .waiting_for_event: |
- | 47 | .suspended: |
|
48 | cmp ebx, [0x3004] |
48 | cmp ebx, [0x3004] |
49 | jb @f |
49 | jb @f |
50 | mov edi, 0x3000 |
50 | mov edi, 0x3000 |
51 | xor ebx, ebx |
51 | xor ebx, ebx |
52 | @@: |
52 | @@: |
53 | 53 | ||
54 | add edi,0x20 |
54 | add edi,0x20 |
55 | inc ebx |
55 | inc ebx |
56 | 56 | ||
57 | mov al, byte [edi+0xA] |
57 | mov al, byte [edi+0xA] |
- | 58 | cmp al, 1 |
|
- | 59 | jz .suspended |
|
- | 60 | cmp al, 2 |
|
- | 61 | jz .suspended |
|
58 | cmp al, 3 |
62 | cmp al, 3 |
59 | je .waiting_for_termination |
63 | je .waiting_for_termination |
60 | cmp al, 4 |
64 | cmp al, 4 |
61 | je .waiting_for_termination |
65 | je .waiting_for_termination |
62 | cmp al, 9 |
66 | cmp al, 9 |
63 | je .waiting_for_reuse |
67 | je .waiting_for_reuse |
64 | 68 | ||
65 | mov [0x3000],ebx |
69 | mov [0x3000],ebx |
66 | mov [0x3010],edi |
70 | mov [0x3010],edi |
67 | 71 | ||
68 | cmp al, 5 |
72 | cmp al, 5 |
69 | jne .noevents |
73 | jne .noevents |
70 | call get_event_for_app |
74 | call get_event_for_app |
71 | test eax, eax |
75 | test eax, eax |
72 | jz .waiting_for_event |
76 | jz .waiting_for_event |
73 | mov [event_sched], eax |
77 | mov [event_sched], eax |
74 | mov [edi+0xA], byte 0 |
78 | mov [edi+0xA], byte 0 |
75 | .noevents: |
79 | .noevents: |
76 | cmp ebx, [prev_slot] |
80 | cmp ebx, [prev_slot] |
77 | sete [0xffff] |
81 | sete [0xffff] |
78 | 82 | ||
79 | 83 | ||
80 | .do_not_change_task: |
84 | .do_not_change_task: |
81 | 85 | ||
82 | call _rdtsc |
86 | call _rdtsc |
83 | mov [edi+0x18],eax |
87 | mov [edi+0x18],eax |
84 | 88 | ||
85 | shl ebx, 3 |
89 | shl ebx, 3 |
86 | xor eax, eax |
90 | xor eax, eax |
87 | add ebx, tss0 |
91 | add ebx, tss0 |
88 | mov word [far_jump.sel], bx ; selector |
92 | mov word [far_jump.sel], bx ; selector |
89 | mov dword [far_jump.offs], eax ; offset |
93 | mov dword [far_jump.offs], eax ; offset |
90 | 94 | ||
91 | mov al,0x20 ; send End Of Interrupt signal |
95 | mov al,0x20 ; send End Of Interrupt signal |
92 | mov dx,0x20 |
96 | mov dx,0x20 |
93 | out dx,al |
97 | out dx,al |
94 | 98 | ||
95 | cmp [0xffff],byte 0 |
99 | cmp [0xffff],byte 0 |
96 | je .switch |
100 | je .switch |
97 | dec byte [0xffff] |
101 | dec byte [0xffff] |
98 | jz @f |
102 | jz @f |
99 | .switch: |
103 | .switch: |
100 | jmp pword [far_jump] |
104 | jmp pword [far_jump] |
101 | inc [context_counter] ;noname & halyavin |
105 | inc [context_counter] ;noname & halyavin |
102 | @@: |
106 | @@: |
103 | 107 | ||
104 | pop es ds |
- | |
105 | popad |
108 | restore_ring3_context |
106 | iret |
109 | iret |
107 | 110 | ||
108 | 111 | ||
109 | uglobal |
112 | uglobal |
110 | align 4 |
113 | align 4 |
111 | far_jump: |
114 | far_jump: |
112 | .offs dd ? |
115 | .offs dd ? |
113 | .sel dw ? |
116 | .sel dw ? |
114 | context_counter dd ? ;noname & halyavin |
117 | context_counter dd ? ;noname & halyavin |
115 | next_usage_update dd ? |
118 | next_usage_update dd ? |
116 | timer_ticks dd ? |
119 | timer_ticks dd ? |
117 | prev_slot dd ? |
120 | prev_slot dd ? |
118 | event_sched dd ? |
121 | event_sched dd ? |
119 | endg |
122 | endg |
120 | 123 | ||
121 | 124 | ||
122 | align 4 |
125 | align 4 |
123 | change_task: |
126 | change_task: |
124 | 127 | ||
125 | mov [0xffff],byte 2 |
128 | mov [0xffff],byte 2 |
126 | 129 | ||
127 | dec dword [timer_ticks] ; because irq0 will increase it |
130 | dec dword [timer_ticks] ; because irq0 will increase it |
128 | 131 | ||
129 | int 0x20 ; irq0 handler |
132 | int 0x20 ; irq0 handler |
130 | 133 | ||
131 | ret |
134 | ret |
132 | 135 | ||
133 | 136 | ||
134 | 137 | ||
135 | align 4 |
138 | align 4 |
136 | updatecputimes: |
139 | updatecputimes: |
137 | 140 | ||
138 | mov eax,[idleuse] |
141 | mov eax,[idleuse] |
139 | mov [idleusesec],eax |
142 | mov [idleusesec],eax |
140 | mov [idleuse],dword 0 |
143 | mov [idleuse],dword 0 |
141 | mov ecx, [0x3004] |
144 | mov ecx, [0x3004] |
142 | mov edi, 0x3020 |
145 | mov edi, 0x3020 |
143 | .newupdate: |
146 | .newupdate: |
144 | mov ebx,[edi+0x14] |
147 | mov ebx,[edi+0x14] |
145 | mov [edi+0x1c],ebx |
148 | mov [edi+0x1c],ebx |
146 | mov [edi+0x14],dword 0 |
149 | mov [edi+0x14],dword 0 |
147 | add edi,0x20 |
150 | add edi,0x20 |
148 | dec ecx |
151 | dec ecx |
149 | jnz .newupdate |
152 | jnz .newupdate |
150 | 153 | ||
151 | ret---><---><<---> |
154 | ret---><---><<---> |