Stack for ring 0

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.
Post Reply
pepito

Stack for ring 0

Post by pepito »

I want to implement my system calls via call gates. It is my understanding that the application programs transfer the parameters to the kernel using the stack and when it arrives to the kernel a 'stack switch' happens.

My OS has just 2 levels (ring 0 and ring3) so I just need to set ss0/esp0 to pass parameters from the application programs to the kernel.

My question is: could I use the kernel's stack to set ss0/esp0, or do I need to create a special stack to pass parameters? How big should that stack be?

Thank you

pepito
mikeleany

RE:Stack for ring 0

Post by mikeleany »

You probably can't use your kernel's stack, unless you can make sure that your kernel's stack is empty every time an application needs a ring 0 stack (including for interrupts that don't use task gates). You need to make sure that no two tasks are using the same ring 0 stack at the same time. If you're using call gates, I would recommend using a separate ring 0 stack for each task. It probably doesn't need to be very big.
pepito

RE:Stack for ring 0

Post by pepito »

OK, I need use a separate ring 0 stack for each task...

Is correct to create a stack segment (at the GDT) and divide it into 'n' tasks?
How big each split must be, if I use 31 parameters by call gate?

pepito

(sorry my poor english)
Post Reply