Page 1 of 1

Some drivers / modules / IDT question.

Posted: Tue Nov 08, 2005 12:00 am
by mrkaktus
I have write bootloader that puts me in PM, my kernel counts RAM size and enables A20 line. Now I know that I need to write IDT supprot, PIC and so on. But I have a question. In your's OS's what way you choose ? Are you linking every procedure to Interrupts like it was done in RM for example, or you're not using Int's for chandling yours procedures? Should I create some module/driver manager better? What way should I take ?

Re: Some drivers / modules / IDT question.

Posted: Tue Nov 08, 2005 12:00 am
by JAAman
most OSs use soft-ints for accessing the kernel API, as it is the simplest, and most compatable way

you cannot CALL directly from user code into kernel code, as that would be a security violation, so another method must be used: either soft-ints, syscall, or sysenter

usually, the kernel provides a small, well defined, set of procedures to be called with a single soft-int, and all other code is restricted from being accessed by user-level code (since its only called from system-level code, it doesn't need a soft-int interface, and can be called directly)

Re: Some drivers / modules / IDT question.

Posted: Tue Nov 08, 2005 12:00 am
by mrkaktus
like int 0x21 in DOS?

Re: Some drivers / modules / IDT question.

Posted: Wed Nov 09, 2005 12:00 am
by JAAman
yes that is an example, although DOS calls could have been 'patched' in (as a library with run-time linking) but they chose not to
but in PMode you CANNOT call so you need a protected method of entering code at specific entry points, while denying access to the rest of the kernel (including unprotected code that does things you don't want your apps to do)

DOS uses 0x21
linux uses 0x80
windows probably uses different ones depending on which version (windows forbids software from making syscalls)

then, by placing your kernel in pages marked as ring0, the applications (running at ring3) cannot enter or even read, the kernel code or data except though authorized entry points

the job of a modern OS is to deny access of the hardware to programs, in order to increase stability and security, alowing apps to enter kernel code at will completely defeats both points

use a TSS structure to provide the CPU with a separate stack for use in ring0 -- you won't be corrupting the stack for syscalls but with a separate ring0 stack you can gaurentee that you will always have plenty of clean stack space

ps. do you have the intel manuals?