00001 #include <l4/sys/types.h>
00002 #include <l4/sys/ipc.h>
00003 #include <l4/names/libnames.h>
00004 #include <l4/omega0/client.h>
00005 #include <omega0_proto.h>
00006 #include "config.h"
00007 #include "internal.h"
00008
00009 #ifdef OMEGA0_LIB_MEASURE_CALL
00010 #include <l4/log/l4log.h>
00011 #include <l4/util/rdtsc.h>
00012 #endif
00013
00014 int omega0_initalized=0;
00015 l4_threadid_t omega0_management_thread = L4_INVALID_ID;
00016
00017
00018 int omega0_init(void){
00019 if(names_waitfor_name(OMEAG0_SERVER_NAME, &omega0_management_thread,
00020 NAMESERVER_WAIT_MS) == 0) return -1;
00021 if(l4_is_invalid_id(omega0_management_thread)) return -1;
00022 omega0_initalized=1;
00023 return 0;
00024 }
00025
00026
00027
00028
00029 int omega0_call(int handle, omege0_request_descriptor type,
00030 l4_umword_t param, l4_timeout_t timeout){
00031 int error;
00032 #ifdef OMEGA0_LIB_MEASURE_CALL
00033 l4_umword_t t;
00034 #endif
00035 l4_msgdope_t result;
00036 l4_umword_t dw0, dw1;
00037 l4_threadid_t server = omega0_management_thread;
00038
00039
00040 if(handle)
00041 server.id.lthread = handle;
00042
00043 error = l4_ipc_call(server, L4_IPC_SHORT_MSG, type, param,
00044 L4_IPC_SHORT_MSG, &dw0, &dw1,
00045 timeout, &result);
00046 if(error) return -error;
00047 #ifdef OMEGA0_LIB_MEASURE_CALL
00048 t = (unsigned)(l4_rdtsc().ll);
00049 LOGl("timediff is %u\n", t-dw1);
00050 #endif
00051 return dw0;
00052 }
00053
00054
00055
00056
00057 int omega0_open_call(int handle, omege0_request_descriptor type,
00058 l4_umword_t param, l4_timeout_t timeout,
00059 l4_threadid_t *alien, l4_umword_t *d0,
00060 l4_umword_t *d1){
00061 int error;
00062 #ifdef OMEGA0_LIB_MEASURE_CALL
00063 l4_umword_t t;
00064 #endif
00065 l4_msgdope_t result;
00066 l4_threadid_t server = omega0_management_thread;
00067
00068
00069 if(handle)
00070 server.id.lthread = handle;
00071
00072 error = l4_ipc_reply_and_wait(server, L4_IPC_SHORT_MSG, type, param,
00073 alien, L4_IPC_SHORT_MSG, d0, d1,
00074 timeout, &result);
00075 if(error) return -error;
00076 #ifdef OMEGA0_LIB_MEASURE_CALL
00077 t = (unsigned)(l4_rdtsc().ll);
00078 LOGl("timediff is %u\n", t-dw1);
00079 #endif
00080 return error;
00081 }
00082
00083
00084
00085
00086 int omega0_call_long(int handle, omege0_request_descriptor type,
00087 l4_umword_t param, l4_threadid_t thread){
00088 int error;
00089 #ifdef OMEGA0_LIB_MEASURE_CALL
00090 l4_umword_t t;
00091 #endif
00092 l4_msgdope_t result;
00093 l4_umword_t dw0, dw1;
00094 l4_threadid_t server = omega0_management_thread;
00095 struct{
00096 l4_fpage_t rcv_fpage;
00097 l4_msgdope_t size;
00098 l4_msgdope_t snd;
00099 l4_umword_t dw0, dw1;
00100 l4_threadid_t threadid;
00101 } message= {rcv_fpage:{0}, size:L4_IPC_DOPE(4,0), snd:L4_IPC_DOPE(4,0),
00102 dw0:0, dw1:0, threadid:thread};
00103
00104
00105 if(handle)
00106 server.id.lthread = handle;
00107
00108 error = l4_ipc_call(server, &message, type, param,
00109 L4_IPC_SHORT_MSG, &dw0, &dw1,
00110 L4_IPC_NEVER, &result);
00111 if(error) return -error;
00112 #ifdef OMEGA0_LIB_MEASURE_CALL
00113 t = (unsigned)(l4_rdtsc().ll);
00114 LOGl("timediff is %u\n", t-dw1);
00115 #endif
00116 return dw0;
00117 }