Fixed some Task stuff, added DOSFS filesystem
This commit is contained in:
54
task.nasm
54
task.nasm
@@ -1,12 +1,16 @@
|
||||
task_ptr: equ (0x310000-4)
|
||||
|
||||
; return address in EAX
|
||||
; return stack in ECX
|
||||
; we can modify EAX, ECX, EDX
|
||||
; i.e. save all others in task
|
||||
global save_current_task
|
||||
save_current_task:
|
||||
push ebx
|
||||
mov ebx, esp
|
||||
push edx
|
||||
mov edx, esp ; EDX holds our tmp stack, unsaved
|
||||
mov esp, dword [task_ptr] ; load current task pointer
|
||||
push ss
|
||||
push ebp ; return stack
|
||||
push ecx ; return stack
|
||||
pushfd
|
||||
push cs
|
||||
push eax ; return address
|
||||
@@ -14,33 +18,41 @@ push ds ; other segs, pop
|
||||
push es ; before iret
|
||||
push fs ; in exit handler
|
||||
push gs
|
||||
push ebp ; saved
|
||||
push ebx ; saved
|
||||
push esi ; saved
|
||||
push edi ; saved
|
||||
mov dword [task_ptr], esp ; save new task pointer
|
||||
mov esp, ebx
|
||||
pop ebx
|
||||
mov esp, edx
|
||||
pop edx
|
||||
ret
|
||||
|
||||
global return_prev_task
|
||||
return_prev_task:
|
||||
mov edi, eax ; save for later
|
||||
mov esi, dword [task_ptr] ; load current task pointer
|
||||
add dword [task_ptr], 36 ; adjust to last task pointer
|
||||
mov eax, [esi+0] ; gs
|
||||
mov ecx, eax ; save return value for later
|
||||
mov edx, dword [task_ptr] ; load current task pointer
|
||||
add dword [task_ptr], 52 ; adjust to last task pointer
|
||||
mov edi, [edx+0]
|
||||
mov esi, [edx+4]
|
||||
mov ebx, [edx+8]
|
||||
mov ebp, [edx+12]
|
||||
mov eax, [edx+0+16] ; gs
|
||||
mov gs, ax
|
||||
mov eax, [esi+4] ; fs
|
||||
mov eax, [edx+4+16] ; fs
|
||||
mov fs, ax
|
||||
mov eax, [esi+8] ; es
|
||||
mov eax, [edx+8+16] ; es
|
||||
mov es, ax
|
||||
mov ebx, [esi+16] ; eip
|
||||
mov ecx, [esi+20] ; cs
|
||||
mov edx, [esi+24] ; eflags
|
||||
; SS:ESP <- return stack
|
||||
mov esp, [esi+28] ; esp
|
||||
mov eax, [esi+32] ; ss
|
||||
mov esp, [edx+28+16] ; esp
|
||||
mov eax, [edx+32+16] ; ss
|
||||
mov ss, ax
|
||||
mov eax, [esi+12] ; ds
|
||||
mov eax, [edx+24+16] ; eflags
|
||||
push eax
|
||||
mov eax, [edx+20+16] ; cs
|
||||
push eax
|
||||
mov eax, [edx+16+16] ; eip
|
||||
push eax
|
||||
mov eax, [edx+12+16] ; ds
|
||||
mov ds, ax
|
||||
push edx ; eflags
|
||||
push ecx ; cs
|
||||
push ebx ; eip
|
||||
mov eax, edi ; restore return value
|
||||
mov eax, ecx ; restore return value
|
||||
iret
|
||||
|
Reference in New Issue
Block a user