Rev 8866 | Rev 8874 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8866 | Rev 8869 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; Copyright (C) KolibriOS team 2004-2021. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2021. All rights reserved. ;; |
4 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
4 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line 7... | ||
7 | 7 | ||
Line 8... | Line 8... | ||
8 | $Revision: 8866 $ |
8 | $Revision: 8869 $ |
9 | 9 | ||
10 | 10 | ||
Line 91... | Line 91... | ||
91 | align 4 |
91 | align 4 |
92 | do_change_task: |
92 | do_change_task: |
93 | ;param: |
93 | ;param: |
94 | ; ebx = address of the APPDATA for incoming task (new) |
94 | ; ebx = address of the APPDATA for incoming task (new) |
95 | ;warning: |
95 | ;warning: |
96 | ; [CURRENT_TASK] and [TASK_BASE] must be changed before (e.g. in find_next_task) |
96 | ; [current_slot_idx] and [TASK_BASE] must be changed before (e.g. in find_next_task) |
97 | ; [current_slot] is the outcoming (old), and set here to a new value (ebx) |
97 | ; [current_slot] is the outcoming (old), and set here to a new value (ebx) |
98 | ;scratched: eax,ecx,esi |
98 | ;scratched: eax,ecx,esi |
99 | mov esi, ebx |
99 | mov esi, ebx |
100 | xchg esi, [current_slot] |
100 | xchg esi, [current_slot] |
101 | ; set new stack after saving old |
101 | ; set new stack after saving old |
Line 138... | Line 138... | ||
138 | jnc .no_xsave |
138 | jnc .no_xsave |
139 | mov ecx, [esi+APPDATA.fpu_state] |
139 | mov ecx, [esi+APPDATA.fpu_state] |
140 | mov eax, [xsave_eax] |
140 | mov eax, [xsave_eax] |
141 | mov edx, [xsave_edx] |
141 | mov edx, [xsave_edx] |
142 | xsave [ecx] |
142 | xsave [ecx] |
143 | mov ecx, [CURRENT_TASK] |
143 | mov ecx, [current_slot_idx] |
144 | mov [fpu_owner], ecx |
144 | mov [fpu_owner], ecx |
145 | mov ecx, [current_slot] |
145 | mov ecx, [current_slot] |
146 | mov ecx, [ecx+APPDATA.fpu_state] |
146 | mov ecx, [ecx+APPDATA.fpu_state] |
147 | xrstor [ecx] |
147 | xrstor [ecx] |
148 | .no_xsave: |
148 | .no_xsave: |
Line 259... | Line 259... | ||
259 | ;retval: |
259 | ;retval: |
260 | ; ebx = address of the APPDATA for the selected task (slot-base) |
260 | ; ebx = address of the APPDATA for the selected task (slot-base) |
261 | ; edi = address of the TASKDATA for the selected task |
261 | ; edi = address of the TASKDATA for the selected task |
262 | ; ZF = 1 if the task is the same |
262 | ; ZF = 1 if the task is the same |
263 | ;warning: |
263 | ;warning: |
264 | ; [CURRENT_TASK] = bh , [TASK_BASE] = edi -- as result |
264 | ; [current_slot_idx] = bh , [TASK_BASE] = edi -- as result |
265 | ; [current_slot] is not set to new value (ebx)!!! |
265 | ; [current_slot] is not set to new value (ebx)!!! |
266 | ;scratched: eax,ecx |
266 | ;scratched: eax,ecx |
267 | proc find_next_task |
267 | proc find_next_task |
268 | call update_counters |
268 | call update_counters |
269 | spin_lock_irqsave SchedulerLock |
269 | spin_lock_irqsave SchedulerLock |
Line 286... | Line 286... | ||
286 | jz .priority_next |
286 | jz .priority_next |
287 | .task_loop: |
287 | .task_loop: |
288 | mov ebx, [ebx+APPDATA.in_schedule.next] |
288 | mov ebx, [ebx+APPDATA.in_schedule.next] |
289 | mov edi, ebx |
289 | mov edi, ebx |
290 | shr edi, 3 |
290 | shr edi, 3 |
291 | add edi, CURRENT_TASK - (SLOT_BASE shr 3) |
291 | add edi, TASK_TABLE - (SLOT_BASE shr 3) |
292 | mov al, [edi+TASKDATA.state] |
292 | mov al, [edi+TASKDATA.state] |
293 | test al, al |
293 | test al, al |
294 | jz .task_found ; state == 0 |
294 | jz .task_found ; state == 0 |
295 | cmp al, 5 |
295 | cmp al, 5 |
296 | jne .task_next ; state == 1,2,3,4,9 |
296 | jne .task_next ; state == 1,2,3,4,9 |
Line 326... | Line 326... | ||
326 | pop ecx |
326 | pop ecx |
327 | spin_unlock_irqrestore SchedulerLock |
327 | spin_unlock_irqrestore SchedulerLock |
328 | .found: |
328 | .found: |
329 | ; the line below assumes APPDATA is 256 bytes long and SLOT_BASE is |
329 | ; the line below assumes APPDATA is 256 bytes long and SLOT_BASE is |
330 | ; aligned on 0x10000 |
330 | ; aligned on 0x10000 |
331 | mov [CURRENT_TASK], bh |
331 | mov byte [current_slot_idx], bh |
332 | mov [TASK_BASE], edi |
332 | mov [TASK_BASE], edi |
333 | rdtsc ;call _rdtsc |
333 | rdtsc ;call _rdtsc |
334 | mov [edi+TASKDATA.counter_add], eax; for next using update_counters |
334 | mov [edi+TASKDATA.counter_add], eax; for next using update_counters |
335 | cmp ebx, [current_slot] |
335 | cmp ebx, [current_slot] |
336 | ret |
336 | ret |