00001
00009
00010
00011
00012
00013 #ifndef __JTOP_SERVER_INCLUDE_OS_L4_H_
00014 #define __JTOP_SERVER_INCLUDE_OS_L4_H_
00015 #include <l4/semaphore/semaphore.h>
00016 #include <l4/thread/thread.h>
00017 #include <l4/util/rdtsc.h>
00018
00019 #define OS_PRIO_STRING "Prio"
00020
00021 typedef l4_threadid_t thread_t;
00022
00023 typedef l4_cpu_time_t cputime_t;
00024 typedef l4semaphore_t os_mutex;
00025
00026 extern inline int os_thread_cmp(thread_t t1, thread_t t2);
00027 extern inline int os_thread_near(thread_t t1, thread_t t2);
00028 extern inline void os_mutex_init(os_mutex *mutex);
00029 extern inline void os_mutex_destroy(os_mutex *mutex);
00030 extern inline void os_mutex_lock(os_mutex *mutex);
00031 extern inline void os_mutex_unlock(os_mutex *mutex);
00032 extern inline int os_time2ms(cputime_t time);
00033 extern inline int os_time2us(cputime_t time);
00034
00035 extern inline int os_thread_cmp(l4_threadid_t t1, l4_threadid_t t2){
00036 return t1.id.task!=t2.id.task?(t1.id.task-t2.id.task):
00037 (t1.id.lthread-t2.id.lthread);
00038 }
00039
00040 extern inline int os_thread_near(thread_t t1, thread_t t2){
00041 return t1.id.task == t2.id.task;
00042 }
00043
00044 extern inline void os_mutex_init(os_mutex *mutex){
00045 *mutex = L4SEMAPHORE_UNLOCKED;
00046 }
00047
00048 extern inline void os_mutex_lock(os_mutex *mutex){
00049 l4semaphore_down(mutex);
00050 }
00051
00052 extern inline void os_mutex_unlock(os_mutex *mutex){
00053 l4semaphore_up(mutex);
00054 }
00055 extern inline void os_mutex_destroy(os_mutex *mutex){
00056 }
00057
00058 extern inline int os_time2ms(cputime_t time){
00059 return time/1000;
00060 }
00061
00062 extern inline int os_time2us(cputime_t time){
00063 return time;
00064 }
00065
00066 #endif