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