Skip to content

Latest commit

 

History

History
186 lines (116 loc) · 6.79 KB

kernel.7.adoc

File metadata and controls

186 lines (116 loc) · 6.79 KB

GeckOS V2.0 Kernel Interface Description

Introduction

This document gives an overview on the GeckOS V2 kernel interface.

I try to keep this documentation as correct and up-to-date as possible, but if in doubt, read the source…​

There are comments like "this need not be available in all OS implementations". These comments mostly refer to the embedded versions of the OS where the kernel can be shortened to (almost) 2k in size by leaving out some stuff not necessary for the particular application.

Kernel Interface Description

Most kernel routines return an error code in the accumlator (a), if the carry flag is reset upon return. Otherwise the ac might contain data.

Please note that, in the real system the address could be basically anywhere depending on the architecture. The loader relocates them on the basis of the OSA2KERNEL label: the file contains it as undefined label, and the loader relocates the kernel addresses that are stored as offset to this base as appropriate. In this table only the offsets to the kernel jump table label OSA2KERNEL are given.

GENERIC CALLS

+$00 RESET

System reset

MEMORY MANAGEMENT / MMU CALLS

For more information on MMU memory management handling see MMU.

+$03 ENMEM

Enable 4k memory block, no in xr, for memory management - MMU version only

+$06 SETBLK

set memory block ac at MMU entry yr - returns old entry in ac. MMU version only

+$2d SBRK

sets the freely available RAM area in the active environment

STREAM HANDLING

The stream handling is described further in section Streams.

+$09 GETSTR

Get a free stream. increase read and write task counter

+$0c FRESTR

decreases read and write task counter, thus freeing the stream, if both result in zero.

+$0f PUTC

puts a byte on the stream.

+$12 GETC

Get a byte from the stream.

+$15 UNGETC

Gives byte from stream back.

+$18 STRCMD

executes a stream command.

DEVICE HANDLING

Device handling is further described in section Devices.

+$1b DEVCMD

executes device commands.

SCHEDULER CALLS

The scheduler is further described in section Scheduler.

+$1e FORK

start a new task.

+$21 TERM

ends the current thread.

+$24 KILL

ends a complete task, with all threads in them.

+$27 YIELD

just give control back to the scheduler.

+$2a FORKT

forks a new thread in the current task.

+$30 GETINFO2

returns process information about all (up to 16) running tasks

+$33 DUP

set new STD* stream

+$5a GETPID

returns the current task ID in x and the current thread ID

+$5d SLOCK

locks scheduler to actual task.

+$60 RENICE

changes the priority of the current task.

+$63 CHECKCHLD

returns status of terminates children (if SIG_CHLD is set)

+$66 SETINFO

setinfo updates the task table

SEMAPHORES

Semaphores are further described in section Semaphores.

+$36 GETSEM

gets a free semaphore.

+$39 FRESEM

frees a semaphore.

+$3c PSEM2

'PSEM' operation on a given semaphore. task waits till semaphore is freed.

+$3f VSEM

'VSEM' operation on semaphore, allows other tasks to grab the semaphore.

MESSAGING

The interprocess communication using SEND and RECEIVE is further described in section SEND/RECEIVE.

+$42 SEND

send a message to another task

+$45 RECEIVE

receives a message.

+$4e TDUP

register a task for a (negative) system message destination number.

+$51 XRECEIVE

receives a message from a specified task only.

SIGNALS

Signals are further described in section Signals.

+$48 SETSIG

sets the signal address and the signal mask

+$4b SENDSIG

send a signal to another task ID

NMI HANDLING

+$54 SETNMI

in systems without MMU, set/add a system NMI routine address.

+$57 CTRLNMI

Send NMI ON/OFF command in AC to all currently chained NMI ctrl routines

Further extensions

+$5a GETPID

Get thread and task IDs for the current thread.

+$5d SLOCK

Lock the scheduler to the own thread (deprecated)

+$60 RENICE

Change the task priority

+$63 CHECKCHLD

Check the status of terminated or suspended child tasks

+$66 SETINFO

Set fields in the task table

+$69 LOCKSEM

Lock a semaphore to the current task (even after doing VSEM)

+$6c JOBCMD

Job control functions

ERROR CODES

Error codes are described in section Errors.

BOOT PROCESS

The boot process is further discussed in section Startup.

FILE HANDLING

For file handling see the section Filesystems.

INTERNET CONNECTIVITY

For accessing the internet, see section SLIP.

HISTORY

The change from kernel 1.3 to kernel 2.0 is radical in some things, but conservative in others. The complete environment handling has been rewritten to make it easier to port to different platforms. Also threads have been introduced. Therefore all the memory management and interprocess communication calls have changed as well. The scheduler is now a lot faster, as no more checks are done for threads in the waiting list.

Although most routines have been rewritten, many of these calls still have the same parameters and behave the same way. Also the PCBUF is still used (unfortunately). This is the general communications buffer needed for filesystem operation and some kernel calls. It is a global buffer, and as such it is protected by the SEM_SENDBUF system semaphore. Each task that wants to use has to allocate this semaphore with PSEM before using the buffer.

Also there still is no block oriented communication, although the stream based communication has been improved by the out-of-band error, brk and push/pull flags.