30.12.2013 Views

T-Kernel Specification (1.B0.02)

T-Kernel Specification (1.B0.02)

T-Kernel Specification (1.B0.02)

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3.2. SYSTEM CALLS 19<br />

/*<br />

* Common constants<br />

*/<br />

#define NULL 0 /* Null pointer */<br />

#define TA_NULL 0 /* No special attributes indicated */<br />

#define TMO_POL 0 /* Polling */<br />

#define TMO_FEVR (-1) /* Eternal wait */<br />

• A data type that combines two or more data types is represented by its main data type. For<br />

example, the value returned by tk cre tsk can be a task ID or error code, but since it is mainly<br />

a task ID, the data type is ID.<br />

3.2 System Calls<br />

3.2.1 System Call Format<br />

T-<strong>Kernel</strong> adopts C as the standard high-level language, and standardizes interfaces for system call<br />

execution from C language routines.<br />

The method for interfacing at the assembly language level is implementation-dependent and not standardized<br />

here. Calling by means of a C language interface is recommended even when an assembly<br />

language program is created. In this way portability is assured for programs written in assembly language<br />

even if the OS changes, so long as the CPU is the same.<br />

The following common rules are established for system call interfaces.<br />

• All system calls are defined as C functions.<br />

• A function return code of 0 or a positive value indicates normal completion, while negative values<br />

are used for error codes.<br />

All system call interfaces are provided as libraries. C language macros, inline functions and inline<br />

assembly code are not used. The reason is that C macros and inline functions can be used only from<br />

a C program. Moreover, since inline functions and inline assembly are not standard C features, their<br />

functioning is in many cases compiler-dependent, diminishing portability.<br />

3.2.2 System Calls Possible from Task-Independent Portion<br />

It must be possible to issue the following system calls from a task-independent portion and in dispatch<br />

disabled state. Whether other system calls can be issued from a task-independent portion or in dispatch<br />

disabled state is implementation-dependent.<br />

Copyright c○ 2002, 2003 by T-Engine Forum<br />

T-<strong>Kernel</strong> <strong>1.B0.02</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!