API interface


 
Contents:

Accessing the kernel

The kernel is designed to allow optimized assembly to go as quick as possible. High level languages should access the kernel through shared code rather than directly.

The kernel is accessed with software interrupts, 1 interrupt per service.
 
Interrupt Service
 0x30  Memory
 0x31  System
 0x32  Time
 0x33  Network
 0x34  Message
 0x35  File
 0x36  User Interface
 

Parameters are passed to services and returned in registers using this order:
    EBX
    ECX
    EDX
    ESI
    EDI

The function number goes into EAX. Certain ranges have been defined for kernel function types:
 
 
Range Use
 0 to 127  Functions for applications
 128 to 255  Functions for drivers
 256 or above  Non-standard/creator defined
 

For example, in order to call time services 0x41 (to sleep for a while) you'd need these assembly instructions:

    mov ebx,sleepTime      ;Number of milli-seconds to sleep for
    mov eax,0x41           ;Function number
    int 0x32               ;Call time services
    test al,al             ;Was there an error?
    jne error              ; yes

Every service returns an error code in AL, 0 means no error - an up to date list of error codes is available from the source code here.

All registers that aren't used to output parameters will be returned unmodified. If only part of a register is used to return a paramter the contents of the rest of the register will be undefined (for example, AL is always used so AH and the rest of EAX is always undefined on return).



Messaging Protocol

Messages are small packets of data transferred from message port to message port. Each message port has a unique ID refered to in this documentation in several ways, message port ID (or port ID), sender ID (if the message port is being used to send a message), or receiver ID (if the message port is the target of a message).

Messages consist of 4 data dwords, 2 have reserved meanings and 2 are for general purpose use.
 
 
Dword name Standard Use
 Sender ID  To identify the message port the message came from
 Function number  To identify the purpose of the message
 Data1  General purpose data
 Data2  General purpose data
 

The lowest 8 bits of the function number (called the message type byte) determines the type of each message. The meaning of this byte is:
 
Bit Meaning when set
 0  Message expects a reply
 1  Message is a reply
 7  Message refers to data block
 

Typical values are:
 
Value Normal use
 000  New message that expects no reply
 001  New message that expects a reply
 002  Reply message that expects no reply
 003  Reply message that expects a reply
 080  New block that expects no reply message
 081  New block that expects a reply message
 082  Reply to a block that expects no reply message
 083  Reply to a block that expects a reply message
 

If a message has an attached data block data1 will contain the length of the block and data2 will contain the start address of the block. The block itself will be read-only and must be released by message services 0x68.


Home  Index
Copyright 1998, Brendan Trotter