This file documents the use of the URIBO-uITRON4.0-Kernel.

Copyright (C) 2007,2008,2009,2010
256TECH Co., Ltd.
Masahiro Sakamoto
mail:m-sakamoto(AT)users.sourceforge.net
http://uribo.sourceforge.net

This is a real-time OS based on uITRON4.0 full specification.

URIBO is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

URIBO is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with URIBO; see the file COPYING and COPYING.LESSER. If not, see (http://www.gnu.org/licenses/).

Table of Contents


Introduction

URIBO is easy to use because it generates a object dynamically without configurator. This is designed to be suitable for even 16 bits microcomputer. The C compiler suitable for this is only GCC.

Documents

Documents are in the directory: (URIBO INSTALLED DIR)/doc/.

Targets being supported now

About uITRON

The uITRON4.0 Specification is an open real-time kernel specification developed by ITRON Association. The uITRON4.0 Specification document can be obtained from the TRON Association web site (http://www.assoc.tron.org).

uITRON abbreviations

The kernel objects as follows.

1 Quick start

Install GCC, GDB, and GDB-stub

Please refer to (URIBO INSTALLED DIR)/doc/inst_(TARGET NAME).html

Build sample application

Load the application to RAM of the target by GDB

e.g., The target is AE-H8/3069-LAN. If you want to use USB-serial cable, please specify /dev/ttyUSB0 etc. instead of /dev/ttyS0 in .gdbinit script.

Run

Please do continue command. Sample appplication outputs printf messages to GDB console as follows.

2 Configuration

2.1 Kernel compiling options

You can enable or disable some kernel functions. These are pre-processor symbols when compiling kernel. e.g., Please add "-D_KERNEL_ASSERT" option to the CFLAGS line in the Makefile if you want to enable service call assertion.

2.1.1 Service call assertion (_KERNEL_ASSERT)

The service call assertion is enabled if "_KERNEL_ASSERT" symbol is defined. The kernel displays the message following "KERNEL ASSERT" when an error is found at the exit of service calls or system functions , and passes GDB the control. However, the following errors are ignored: E_TMOUT, E_RLWAI, and E_DLT.

2.1.2 Enable mutex (_KERNEL_MTX)

The mutex function is enabled if "_KERNEL_MTX" symbol is defined. The kernel is impemented under not "the strict priority control rule" but "the simplified priority control roule". However, if you do not need mutex, I recommend it not to be enabled because mutex code is too heavy for uITRON kernel.

2.1.3 Enable overrun handler (_KERNEL_OVR)

The overrun handler is enabled if "_KERNEL_OVR" symbol is defined. The kernel defines system timer interrupt handler as not INH but ISR if this is enabled.

2.1.4 No static error checking (_KERNEL_NO_STATIC_ERR)

The omission of checking static error is enabled if "_KERNEL_NO_STATIC_ERR" symbol is defined. "static errro" means the check on parameters of service call at the entrance. This option is used to omit that checking and make fast. The kernel will record the found error in "SYSER" variable. (However, the following errors are ignored: E_TMOUT, E_RLWAI, and E_DLT.) So, you might be able to enable this if "SYSER" keeps 0.

2.1.5 No stack filling (_KERNEL_NO_STKFIL)

The omission of filling stacks with fixed pattern is enabled if "_KERNEL_NO_STKFIL" symbol is defined. The kernel will fill stacks of user task with the ID of the task at cre_tsk(). The kernel will fill stack of interrupt handler with 0xdd and will fill stack of system timer task with 0xee at sysini(). These are used to check the quantity consumed of the stack later. You can make initialization fast at sysini() and cre_tsk() by this option.

2.1.6 Not cleared BSS (_KERNEL_NO_BSSCLR)

The kernel will clear some important variables of itself at sysini() if "_KERNEL_NO_BSSCLR" symbol is defined. You must use this option if your C start up routine omits to clear BSS section by 0.

2.1.7 Kernel debugging (_KERNEL_DEBUG)

The kernel debugging code is enabled if "_KERNEL_DEBUG" symbol is defined. That code can find kernel internal error.

2.2 Kernel configuration header

Please inlcude "config.h" at only by one of application source files. This header file defines default values of kernel configuration and defines pointer array for objects, etc. It is all done if you are satisfied with those default values.
(e.g., "main.c" includes "config.h") Or, please define the value at before "config.h" if you want to override defaults.
(e.g., Override muximum number of task priority)

2.2.1 Maximum number of task priority (TPRI_MAX)

This value defines the muximum number of task priority. Default value is 8. So, in that case you can use priority from 1 to 8. It relates to the size of ready-queue and of waiting-queue in any object: e.g., semaphore which has "TA_TPRI" attribute. The size of a priority queue is TPRI_MAX * sizeof(void *).

2.2.2 Maximum number of kernel objects (?????_MAX)

These values defines the muximum value of object ID. e.g., You can use ID from 1 to 8 if the value is 8. The size of an array for object pointer which is defined at "config.h" is (the maximum number) * sizeof(void *).

2.2.3 Stack size for non-task contexts (ISTKSZ/TSTKSZ)

"Non-task contexts" means two contexts of interrupt handler and of time event handler. The kernel will fill stack of interrupt handler with 0xdd and will fill stack of system timer task with 0xee at sysini(). These are used to check the quantity consumed of the stack later. Note: "T_CTX" is structured data set of task context and it includes the image of the CPU registers.

2.2.4 Memory pool sizes (SYSMSZ/MPLMSZ/STKMSZ)

The kernel has 3 internal memory pools.

System memory size (SYSMSZ)

"System memory" is a space for structured data of kernel objects. e.g., "T_TCB" structured data will be allocated in pool of system memory at cre_tsk() or "T_SEM" will be allocated at cre_sem(). Default value is 0 and you are able not to define "SYSMSZ" if you are not interested about this size. In that case, the data will be allocated in pool of stack memory and it is easy.

Memory pool memory size (MPLMSZ)

"Memory pool memory" is a space for buffers of MPL/MPF/MBF. e.g., The message buffer will be allocated in pool of memory pool memory at cre_mbf(). Default value is 0 and you are able not to define "MPLMSZ" if you are not interested about this size. In that case, the buffer will be allocated in pool of stack memory and it is easy.

Stack memory size (STKMSZ)

"Stack memory" is a space for stack of user tasks, stack of interrupt handler, and stack of system timer task. Default value is 0 and you are able not to define "STKMSZ" if you are not interested about this size. In that case, most amounts of main() stack will be allocated as pool of stack memory and it is easy.

2.2.5 Hashed queue sizes (TMRQSZ/CYCQSZ/ALMQSZ/ISRQSZ)

The kernel has 4 hashed queues. The memory size of a queue is (queue size) * sizeof(void *). The size and throughput are in the relation of the trade-off.

2.2.6 Kernel interrupt level (KNL_LEVEL)

You can change kernel interrupt level if the CPU has two or more levels. The kernel sets interrupt level to this value at inner critical section. Please note that the interrupt which has higher level than this value is out of control by kernel, and the handler for that can not call uITRON service calls. In addition, the "higer" handler must be defined by NOT def_inh()/cre_isr() service calls but as interrupt function (e.g., with "#pragma interrupt" or with "interrupt" attribute, and which will be driven by interrupt vector directly). The default value is defined at "config_s.h" in each taget directory. Level 1 is lowest level and NEVER define this to 0.

2.3 System timer interval (MSEC)

This value means system timer interval in millisecond. This is convenient for the apprlication but the kernel never use. The default value is defined to 10 at "kernel.h". e.g., This value used like as follows if you want 1000 milliseconds delay. e.g., If you want to change interval to 1 millisecond, You must define "MSEC" before "kernel.h" at all of application source file. And you must change initial count of timer hardware at intsta() to adjust for interval to be 1 millisecond. Please note that the kernel load grows when interval is shortened.

3 Enhanced API from uITRON4.0 specification

3.1 System functions (Not uITRON)

Most system functions are used to initializes the kernel. e.g., The initialization of a simple application with two tasks that switches over alternately is as follows.

3.1.1 sysini

SYNOPSIS DESCRIPTION ERRORS

3.1.2 intsta

SYNOPSIS DESCRIPTION ERRORS

3.1.3 syssta

SYNOPSIS DESCRIPTION ERRORS

3.1.4 intext

SYNOPSIS DESCRIPTION ERRORS

3.2 Enhanced service calls

3.2.1 create TSK/DTQ/MBF/MPF/MPL with auto allocation

SYNOPSIS DESCRIPTION

3.2.2 INH/ISR with interrupt mask

SYNOPSIS DESCRIPTION ERRORS

3.2.3 chg_ims

SYNOPSIS DESCRIPTION ERRORS

3.2.4 get_ims

SYNOPSIS DESCRIPTION ERRORS

3.2.5 ref_sys

SYNOPSIS DESCRIPTION ERRORS

3.2.6 ref_cfg

SYNOPSIS DESCRIPTION ERRORS

3.2.7 vcan_wup (Not uITRON)

SYNOPSIS DESCRIPTION

3.2.8 vget_tid (Not uITRON)

SYNOPSIS DESCRIPTION

3.2.9 vdis_psw (Not uITRON)

SYNOPSIS DESCRIPTION RETURN VALUES

3.2.10 vset_psw (Not uITRON)

SYNOPSIS DESCRIPTION

3.2.11 No effect of TA_HLNG/TA_ASM attributes

A task or a handler has TA_HLNG (High-level language) or TA_ASM (Assembly language) attribute in uITRON specification. However, the kernel will ignore these attributes because it assumes that all tasks and all handlers are in C language. And, you must write same calling sequence as C function if you want in assembly language.

3.2.12 Get inner kernel memory information by ref_mpl

The kernel has 3 internal memory pools. You can get usage information of these pools by ref_mpl service call with special ID as follows.

3.2.13 Byte mode data queue

"TA_BYTE" attribute was added to data queue at (a)cre_dtq. You can reduce buffer memory size by this option if you need only 8-bits data in data queue. The kernel sends only lower 8-bits data to data queue at (p|ip|t|f|if)snd_dtq. The kernel gets only 8-bits data from data queue and fill upper 24-bits of data by 0 at (p|t)rcv_dtq.

e.g., 16 bytes data queue:

4 URIBO service calls list

Note: The service calls list includes abbreviations as follows.

4.1 Task management

4.2 Task dependent synchronization

4.3 Task exception

4.4 Synchronization and communication

4.5 Extended synchronization and communication

4.6 Memory pool

4.7 Timer

4.8 System state management

4.9 Interrupt

4.10 Extended service call

4.11 System configuration


5 How to boot from ROM

5.1 Build

There is a sample application to boot from ROM at e.g., A sample for AE-H8/3069-LAN Please use files as follows to build a ROM application.

5.2 Program target

Please install the HEX file of application to target ROM.

(e.g., For AE-H8/3069-LAN)

Please install test.mot same as h8-stub installation .
This application output printf messages to not GDB console but SCI1 port (CN4) because it is not include GDB stub. So, you should use serial terminal emulator like as "gtkterm" to see messages. Please set serial to: 38400bps, no-parity, 1 stop bit, no-flow.


6 SIO driver (data queueu sample)

There is an innterupt driven SIO driver sample (sio.h/sio.c). This is an usage example of data queue, too.

6.1 ini_sio

SYNOPSIS DESCRIPTION RETURN VALUES

6.2 put_sio

SYNOPSIS DESCRIPTION

6.3 get_sio

SYNOPSIS DESCRIPTION RETURN VALUES

Copyright (C) 256TECH Co., Ltd.
Masahiro Sakamoto
mail:m-sakamoto(AT)users.sourceforge.net