7. WrmOS: API

← 6. WrmOS: root-task Alpha

Contents
7.1 Overview
7.2 L4 API
7.3 WrmOS API

7.1 Overview [up]


One part of OS API is provided by L4 API, that is described in L4 Kernel Reference Manual Version X.2. Other part of OS API is provided by WrmOS API, that is including system calls, Alpha calls and additional functions. WrmOS API partially cover L4 API.

7.2 L4 API [up]


L4 system calls and helpers for them are wrapped by C-functions, that is listed below. All functions are located in lib/l4/inc/l4_api.h.

Function Description
l4_kip() Get Kernel Interface Page address through system call or from stored value in static memory.
l4_utcb() Get User Thread Control Block address. No system calls.
l4_ipc() Do Inter Process Communication system call. It is used for data exchange and threads synchronization. It may have only send phase, only receive phase or both.
l4_send() Do only send phase of IPC. It is helper for l4_ipc().
l4_receive() Do only receive phase of IPC. It is helper for l4_ipc().
l4_unmap() Do Unmap system call.
l4_thread_control() Do Thread Control system call.
l4_space_control() Do Space Control system call.
l4_memory_control() Do Memory Control system call.
l4_system_clock() Get system clock value through System Clock system call.
l4_thread_switch() Do Thread Switch system call.
l4_schedule() Do Schedule system call.
l4_exchange_registers() Do Exchange Registers system call.
l4_kdb() Do Kernel Debug system call.
l4_kdb_putsn() Print message through KDB system call. It is helper for l4_kdb().
l4_exreg_ip() Read or/and set thread's instruction pointer. It is helper for l4_exchange_registers().
l4_exreg_flags() Read or/and set thread's flags. It is helper for l4_exchange_registers().
l4_exreg_pager() Read or/and set thread's pager. It is helper for l4_exchange_registers().

7.3 WrmOS API [up]


WrmOS API provides control for all OS objects such applications, threads, mutexes, devices and other. All functions are located in lib/wrmos/inc/wrm_*.h. They are listed below.

Function Description
Application functions (lib/wrmos/inc/wrm_app.h)
wrm_app_threads() Get thread IDs range for required application.
Thread functions (lib/wrmos/inc/wrm_thr.h)
wrm_task_create() Create new task and thread inside him.
wrm_thread_create() Create thread inside required task.
Named thread functions (lib/wrmos/inc/wrm_nthr.h)
wrm_nthread_register() Register thread by name. It allows other application get thread ID by registered name.
wrm_nthread_get_id() Get named thread ID by name.
Device functions (lib/wrmos/inc/wrm_dev.h)
wrm_dev_map_io() Map memory mapped device area to caller address space.
wrm_dev_attach_int() Set caller thread as interrupt handler.
wrm_dev_detach_int() Remove caller thread from interrupt handlers.
wrm_dev_wait_int() Wait attached interrupt.
Logging functions (lib/wrmos/inc/wrm_log.h)
wrm_loge() Print error message.
wrm_logw() Print warning message.
wrm_logi() Print information message.
wrm_logd() Print debug message.
Memory functions (lib/wrmos/inc/wrm_mem.h)
wrm_mem_get_usual() Get from Alpha usual memory allowed for caller application.
wrm_mem_get_named() Get from Alpha named memory allowed for caller application.
Memory pool functions (lib/wrmos/inc/wrm_mpool.h)
wrm_mpool_dump() Print a state of application memory pool.
wrm_mpool_add() Add memory to memory pool.
wrm_mpool_alloc() Get memory from memory pool.
wrm_mpool_alloc_log2sz() Get memory from memory pool.
wrm_mpool_size() Get size of memory pool.
wrm_malloc() Memory alloc wrapper to use as malloc-callback in wlibc library.
Mutex functions (lib/wrmos/inc/wrm_mtx.h)
wrm_mtx_init() Initialize mutex structure.
wrm_mtx_destroy() Destroy mutex structure.
wrm_mtx_lock() Lock the mutex.
wrm_mtx_unlock() Unlock the mutex.
Semaphore functions (lib/wrmos/inc/wrm_sem.h)
wrm_sem_init() Initialize semaphore structure.
wrm_sem_destroy() Destroy semaphore structure.
wrm_sem_value() Get semaphore value.
wrm_sem_wait() Wait the semaphore.
wrm_sem_post() Post the semaphore.
Spin lock functions (lib/wrmos/inc/wrm_slock.h)
wrm_spinlock_init() Initialize spin lock structure.
wrm_spinlock_lock() Lock the spin lock.
wrm_spinlock_unlock() Unlock the spin lock.

← 6. WrmOS: root-task Alpha