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