I like to know which way is better to implement system calls:
1) Call gates
2) Interrupts
Why?
Thank you
pepito
system calls
RE:system calls
Whichever way you want, because it's your OS. I'm going with call gates though, because they have a built-in way of passing parameters between privilege levels. You can also have more call gates than you can interrupts, but that doesn't really matter too much, because you can use one interrupt (or call gate) for multiple functions.
RE:system calls
How the 'built-in way of passing parameters' works? It sounds interesting!
RE:system calls
What I meant was that with interrupts, you (usually) can't pass parameters on the stack in protected mode, because your interrupt service routing (ISR) is usually more privileged than your application, so when your ISR is called, the processor switches to a different stack for a different privilege level. So any parameters you may have tried to pass to the interrupt on the stack wouldn't be on the new stack. Of course, there are ways that you can get around that, and some people just pass the parameters through registers instead of pushing them onto the stack.
With a call gate, you still have the stack switch, but the difference is that you can tell the CPU to copy your parameters from the old stack to the new stack for you.
To learn more about call gates, stack switching and interrupts, I suggest you refer to section 4.8 (especially 4.8.2 - 4.8.5) and chapter 5 of the Intel Manual Volume 3.
http://developer.intel.com/design/Pentium4/manuals/
With a call gate, you still have the stack switch, but the difference is that you can tell the CPU to copy your parameters from the old stack to the new stack for you.
To learn more about call gates, stack switching and interrupts, I suggest you refer to section 4.8 (especially 4.8.2 - 4.8.5) and chapter 5 of the Intel Manual Volume 3.
http://developer.intel.com/design/Pentium4/manuals/
RE:system calls
I read the manual and I try to write a little example, but it fails.
I just insert a call gate (DPL=3, 0 parameters) at my GDT, and call it from the KERNEL (DPL=0) with the instruction:
call 0x820:0
But the computer restart!
What's wrong?
Where may I get some working example?
Thank you.
I just insert a call gate (DPL=3, 0 parameters) at my GDT, and call it from the KERNEL (DPL=0) with the instruction:
call 0x820:0
But the computer restart!
What's wrong?
Where may I get some working example?
Thank you.
RE:system calls
I get it works!
I was an error at the GDT, but now is working...
Thank you xSadar!
I was an error at the GDT, but now is working...
Thank you xSadar!