Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
hi guys
sorry for a new thread.
but if i want to context switch from cpl 3 -> cpl 0 i should push ss3 and esp3 , right ?
so for the first time i create a task i need to initialize its kernel stack.
so which one should point to the userstack and changes automatically as the stack grows or shrinks with the task, is it (2) or (3) ??
please can any one make it clear to me ?
thank you
But I can point out that you (It doesn't seem so, at least) don't have a TSS installed.
When the processor switching from Ring 3 to Ring 0 code, it will load all of the values (kernel stack, etc.) from the first TSS enty.
But I can point out that you (It doesn't seem so, at least) don't have a TSS installed.
When the processor switching from Ring 3 to Ring 0 code, it will load all of the values (kernel stack, etc.) from the first TSS enty.
ofcourse i know that, i'll update the TSS (ss0,esp0) during context switching.
i meant what should point to the real esp of user process which changes automatically as the process do pushes and pops , is it (1) or (2) ?
and the more important issues, when creating a new process which one ( (1) or (2) ) should i point to the end of the memory allocated for the process user stack ?
it seems that no one understood me. i will try to make it clearer.
for example if a user process called a syscall by an int instruction, and the parameters where pushed on the process stack rather than the registers, which is the same technique used by *BSD. so which should point to the real user stack of the process esp3 number (2) or esp number (3) ?
another thing what should i initially set the eso3 number (2) & esp number (3) when i create a new process ?
well, the first part I for one do otherwise: I pass pointers to the system call by putting these values into registers. the systemcall pries the parameters from the saved processor state image in tcb->esp0 then.
second: Hm. You allocate a stack area. Then you pass your ring3 selector into ss3 field and your freshly allocated stack image+sizeof stackimage-4 to the esp3 field. Voila.
third: for ring3->ring0 transitions, you don't need to save off esp3/ss3 (althou in the irq stub one also pushes esp). That's done by int [xx]. YOu need the tss to provide the processor with info about where is the esp0 stack of that task and the according ss0 value.
gdt:
null_desc dd 0h
dd 0h
flat_code dw 0ffffh
dw 0h
db 0h
db 10011110b ; 9eh
db 11001111b ; cfh
db 0h
flat_data dw 0ffffh
dw 0h
db 0h
db 10010010b ; 92h
db 11001111b ; cfh
db 0h
user_code dw 0ffffh
dw 0h
db 0h
db 11111110b
db 11001111b
db 0h
user_data dw 0ffffh
dw 0h
db 0h
db 11110010b
db 11001111b
db 0h
task_state dd 0h
dd 0h