wip: better way of handling thread switch (iret in the switch)
This commit is contained in:
@ -1,27 +1,21 @@
|
||||
.intel_syntax noprefix
|
||||
.set CLEAR_ERRNO_INTNO, 0x08
|
||||
|
||||
.section .text
|
||||
.global switch_thread
|
||||
|
||||
switch_thread:
|
||||
mov edx, DWORD PTR [esp]
|
||||
cmp DWORD PTR [current_tcb], 0
|
||||
je .LABEL1
|
||||
mov eax, [current_tcb]
|
||||
|
||||
// save the current stack pointer to the old stack
|
||||
mov [eax+0], esp
|
||||
|
||||
// stack pointer + the 4 regs pushed
|
||||
// and + 1 to get the argument (next thread)
|
||||
.LABEL1:
|
||||
mov esi, [esp+4]
|
||||
mov [current_tcb], esi
|
||||
|
||||
mov eax, [current_tcb]
|
||||
|
||||
mov esp, [eax+0] // get esp
|
||||
|
||||
push edx
|
||||
|
||||
ret
|
||||
mov eax, [esp + 4]
|
||||
mov esp, eax
|
||||
|
||||
pop eax
|
||||
mov ds, eax
|
||||
|
||||
popa
|
||||
|
||||
call pic_send_eoi
|
||||
|
||||
add esp, CLEAR_ERRNO_INTNO
|
||||
|
||||
iret
|
||||
|
||||
Reference in New Issue
Block a user