ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 13.06.2025

Просмотров: 4206

Скачиваний: 0

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

B RoBIOS Operating System

B.5.5 System Functions

Miscellaneous system functions:

char *OSVersion

(void);

Input:

NONE

Output:

OS version

Semantics:

Returns string containing running RoBIOS version.

Example:

"3.1b"

int OSError (char *msg,int number,BOOL dead);

Input:

(msg) pointer to message

(number) int number

(dead) switch to choose dead end or key wait

Valid values are:

0 = no dead end

Output:

NONE

1 = dead end

Semantics:

Print message and number to display then

stop processor (dead end) or wait for key

int OSMachineType (void);

Input:

NONE

Output:

Type of used hardware

Valid values are:

Semantics:

VEHICLE, PLATFORM, WALKER

Inform the user in which environment the program runs.

int OSMachineSpeed (void);

Input:

NONE

Output:

actual clockrate of CPU in Hz

Semantics:

Inform the user how fast the processor runs.

char* OSMachineName (void);

Input:

NONE

Output:

Name of actual Eyebot

Semantics:

Inform the user with which name the Eyebot is

titled (entered in HDT).

unsigned char OSMachineID (void);

Input:

NONE

Output:

ID of actual Eyebot

Semantics:

Inform the user with which ID the Eyebot is titled

(entered in HDT).

void *HDTFindEntry(TypeID typeid,DeviceSemantics semantics);

Input:

(typeid)

Type identifier tag of the category

(e.g. MOTOR, for a motor type)

(semantics) Semantics itentifier tag (e.g. MOTOR_LEFT,

Output:

specifying which of several motors)

Reference to matching HDT entry

Semantics:

This function is used by device drivers to search for

first entry that matches the semantics and returns a

pointer to the corresponding data structure.

See HDT description in HDT.txt .

Interrupts:

int OSEnable (void);

Input:

NONE

Output:

NONE

Semantics:

Enable all cpu-interrupts

int OSDisable (void);

Input:

NONE

392


RoBIOS Library Functions

Output:

NONE

Semantics:

Disable all cpu-interrupts

Saving of variables in TPU-RAM (SAVEVAR1-3 occupied by RoBiOS):

int OSGetVar (int num);

Input:

(num) number of tpupram save location

Valid values:

SAVEVAR1-4 for word saving

SAVEVAR1a-4a/1b-4b for byte saving

Output:

(returncode) the value saved

Valid values are: 0-65535 for word saving

Semantics:

0-255 for byte saving

Get the value from the given save location

int OSPutVar (int num, int value);

Input:

(num) number of tpupram save location

valid values are: SAVEVAR1-4 for word saving

SAVEVAR1a-4a/1b-4b for byte saving

(value) value to be stored

Valid values are: 0-65535 for word saving

Output:

0-255 for byte saving

NONE

Semantics:

Save the value to the given save location

B.5.6 Multitasking

RoBiOS implements both preemptive and cooperative multitasking. One of these modes needs to be selected when initializing multitasking operation.

int OSMTInit (BYTE mode);

Input:

(mode)

operation mode

Output:

Valid

values are: COOP=DEFAULT,PREEMPT

NONE

Semantics:

Initialize multithreading environment

tcb *OSSpawn (char *name,int code,int stksiz,int pri,int uid);

Input:

(name) pointer to thread name

(code) thread start address

(stksize) size of thread stack

(pri) thread priority

Valid values are: MINPRI-MAXPRI

Output:

(uid) thread user id

(returncode) pointer to initialized thread

Semantics:

control block

Initialize new thread, tcb is initialized and

inserted in scheduler queue but not set to

READY

int OSMTStatus (void);

Input:

NONE

Output:

PREEMPT, COOP, NOTASK

Semantics:

returns actual multitasking mode (preemptive,

cooperative or sequential)

int OSReady (struct tcb *thread);

Input:

(thread) pointer to thread control block

Output:

NONE

Semantics:

Set status of given thread to READY

int OSSuspend (struct tcb *thread);

Input:

(thread) pointer to thread control block

393


B RoBIOS Operating System

Output:

NONE

Semantics:

Set status of given thread to SUSPEND

int OSReschedule (void);

Input:

NONE

Output:

NONE

Semantics:

Choose new current thread

int OSYield (void);

Input:

NONE

Output:

NONE

Semantics:

Suspend current thread and reschedule

int OSRun (struct tcb *thread);

Input:

(thread) pointer to thread control block

Output:

NONE

Semantics:

READY given thread and reschedule

int OSGetUID (thread);

Input:

(thread) pointer to thread control block

Output:

(tcb *)0 for current thread

(returncode) UID of thread

Semantics:

Get the UID of the given thread

int OSKill (struct tcb *thread);

Input:

(thread) pointer to thread control block

Output:

NONE

Semantics:

Remove given thread and reschedule

int OSExit (int code);

Input:

(code) exit code

Output:

NONE

Semantics:

Kill current thread with given exit code and message

int OSPanic (char *msg);

Input:

(msg) pointer to message text

Output:

NONE

Semantics:

Dead end multithreading error, print message to display

and stop processor

int OSSleep (int n)

Input:

(n) number of 1/100 secs to sleep

Output:

NONE

Semantics:

Let current thread sleep for at least n*1/100

seconds. In multithreaded mode, this will

reschedule another thread. Outside

multi-threaded mode, it will call OSWait().

int OSForbid (void)

Input:

NONE

Output:

NONE

Semantics:

disable thread switching in preemptive mode

int OSPermit (void)

Input:

NONE

Output:

NONE

Semantics:

enable thread switching in preemptive mode

In the functions described above the parameter "thread" can always be a pointer to a tcb or 0 for current thread.

Semaphores:

int OSSemInit (struct

sem *sem,int val);

Input:

(sem)

pointer to a semaphore

394


RoBIOS Library Functions

Output:

(val)

start value

NONE

Semantics:

Initialize semaphore with given start value

int OSSemP (struct sem *sem);

to a semaphore

Input:

(sem) pointer

Output:

NONE

Semantics:

Do semaphore P (down) operation

int OSSemV (struct sem *sem);

to a semaphore

Input:

(sem) pointer

Output:

NONE

Semantics:

Do semaphore V (up) operation

B.5.7 Timer

int OSSetTime (int hrs,int mins,int secs);

Input:

(hrs) value for hours

(mins) value for minutes

Output:

(secs) value for seconds

NONE

Semantics:

Set system clock to given time

int OSGetTime (int *hrs,int *mins,int *secs,int *ticks);

Input:

(hrs) pointer to int for hours

(mins) pointer to int for minutes

(secs) pointer to int for seconds

Output:

(ticks) pointer to int for ticks

(hrs) value of hours

(mins) value of minutes

(secs) value of seconds

Semantics:

(ticks) value of ticks

Get system time, one second has 100 ticks

int OSShowTime (void);

Input:

NONE

Output:

NONE

Semantics:

Print system time to display

int OSGetCount (void);

Input:

NONE

Output:

(returncode) number of 1/100 seconds since last reset

Semantics:

Get the number of 1/100 seconds since last reset.

Type int is 32 bits, so this value will wrap

around after ~248 days.

int OSWait (int n);

Input:

(n) time to wait

Output:

NONE

Semantics:

Busy loop for n*1/100 seconds.

Timer-IRQ:

TimerHandle OSAttachTimer (int scale, TimerFnc function);

Input:

(scale) prescale value

for 100Hz Timer (1 to ...)

Output:

(TimerFnc) function to

be called periodically

(TimerHandle) handle to reference the IRQ-slot

A value of 0 indicates

an error due to a full list

Semantics:

(max. 16).

the irq-list.

Attach an irq-routine (void function(void)) to

The scale parameter adjusts the call frequency

(100/scale Hz)

395