API

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
Ricky Chilcott

API

Post 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
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re: API

Post 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.
-- Stu --
Ricky Chilcott

Re: API

Post by Ricky Chilcott »

So the API will become whatever my functions/subs in my C code are?

~Chilly
osteron

Re: API

Post 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.
Tim Robinson

Re: API

Post 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.
BLoggins02

Re: API

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