Page 1 of 1
I need to ask - even if I`m the idiot afterwards
Posted: Sat Dec 13, 2003 12:16 pm
by TheStupidOne
Hello Guys,
I`m planning as you guessed an OS, what surprise....
Anyway, besides trying to learn assembler I came up with a question:
How do I make the functions that I implement in the Kernel (printf, etc.) available to other programs (yeah, that is if I get so far...)?
Re:I need to ask - even if I`m the idiot afterwards
Posted: Sat Dec 13, 2003 12:36 pm
by Tim
Set up an interrupt handler in your kernel. Programs can use the INT instruction to invoke that handler.
Re:I need to ask - even if I`m the idiot afterwards
Posted: Sat Dec 13, 2003 1:09 pm
by TheStupidOne
Bear with me.
I know it may sound stupid again, but I can`t imagine how to do this in C++/C. I mean I normally don`t use/see any assembler routines that call an INT. All C/C++.
P.S: Does someone know good tutorials on Interrupt Handlers or do I have to finally buy the book from Tanenbaum?
Re:I need to ask - even if I`m the idiot afterwards
Posted: Sat Dec 13, 2003 1:53 pm
by Candy
TheStupidOne wrote:
Bear with me.
I know it may sound stupid again, but I can`t imagine how to do this in C++/C. I mean I normally don`t use/see any assembler routines that call an INT. All C/C++.
P.S: Does someone know good tutorials on Interrupt Handlers or do I have to finally buy the book from Tanenbaum?
Hidden part of the OS.
There is a library you ALWAYS link along (when using normal compilation) but you never actually use. It's called libc, linked with (usually) -lc and contains a lot of wrapper functions for C users to use, that clean up the arguments and call the interrupt (or use syscall or sysenter or something like that). The handler (which is again assembly) then passes those arguments to the handler, which ends up calling the function you intended to call. In the end, aside from this bit, all you see from the mechanism is that the CPU goes to kernel mode.
You will need to use assembly.