Page 1 of 1

API

Posted: Wed May 23, 2001 2:24 pm
by Ricky Chilcott
How would i go about implimenting a standard API for my OS?  I would like this API to be available to all programs available in my OS?  How would i go about doing this?

~Ricky

Re: API

Posted: Wed May 23, 2001 10:48 pm
by df
All you need to do to make your API available is document it!

the API delivery mechanism can be any multitude of methods from INT calls to a syscall jump table, etc.

as long as its documented nicely.

Re: API

Posted: Thu May 24, 2001 11:05 am
by Ricky Chilcott
So the API will become whatever my functions/subs in my C code are?

~Chilly

Re: API

Posted: Fri May 25, 2001 11:09 am
by osteron
An API is just a set of functions (interface) that you the programmer expose to allow other programmers to use that code. Other programmers will know how to use it if you
document it.
So essentially yes, the declarations in your C header files become your API.

Re: API

Posted: Sun May 27, 2001 10:45 am
by Tim Robinson
Examples of APIs range from DOS (a few 8086 interrupts and functions for the few services that it provides) to BeOS (a whole class library including interfaces to the kernel, the GUI, the file system, and a lot more).

So it's up to you -- decide on a means of calling your kernel (a system call interface -- on the x86, usually by interrupts) and write a HLL layer around it.

Re: API

Posted: Mon Jul 23, 2001 7:31 pm
by BLoggins02
Just to clarify here, if you're writing your OS in protected mode and you're using multiple levels of protection, you can't just export the addresses of entry points into the kernel and then document those, because user code jumping from a numerically higher CPL to a lower DPL will cause a protection fault. ?That's what the talk concerning syscalls, ints etc... are about. ?With interrupts, your API is more processor independent and you have the choice of running the system call as a new task or in the context of the task that called it. OTOH, using intel call gates is also a very good way of doing a system call. ?You put a call gate entry into the GDT (with the offset of some handler), then you just call that call gate, and there you are executing the kernel code. ?Check out the 80386 Programmer's Reference Manual at http://webster.cs.ucr.edu/Page_asm/Doc386/TOC.HTM for more info on this type of stuff.