00001
00007
00008 #ifndef __L4_TYPES_H__
00009 #define __L4_TYPES_H__
00010
00011 #include <l4/sys/compiler.h>
00012 #include <l4/sys/consts.h>
00013 #include <l4/sys/l4int.h>
00014 #include_next <l4/sys/types.h>
00015
00020 typedef struct {
00021 l4_umword_t low;
00022 l4_umword_t high;
00023 } l4_low_high_t;
00024
00025
00026
00027
00028
00033 typedef struct {
00034 unsigned version_low:10;
00035 unsigned lthread:7;
00036 unsigned task:11;
00037 unsigned version_high:4;
00038 } l4_threadid_struct_t;
00039
00044 typedef union {
00045 l4_uint32_t raw;
00046 l4_threadid_struct_t id;
00047 } l4_threadid_t;
00048
00053 typedef l4_threadid_t l4_taskid_t;
00054
00059 typedef struct {
00060 unsigned intr:8;
00061 unsigned char zero[3];
00062 } l4_intrid_struct_t;
00063
00068 typedef union {
00069 l4_intrid_struct_t id;
00070 } l4_intrid_t;
00071
00077 #define L4_NIL_ID_INIT {0}
00078 #define L4_NIL_ID ((l4_threadid_t)L4_NIL_ID_INIT)
00079
00080
00085 #define L4_INVALID_ID_INIT {0xffffffff}
00086 #define L4_INVALID_ID ((l4_threadid_t)L4_INVALID_ID_INIT)
00087
00088
00095 L4_INLINE int
00096 l4_is_nil_id(l4_threadid_t id);
00097
00105 L4_INLINE int
00106 l4_is_invalid_id(l4_threadid_t id);
00107
00115 L4_INLINE int
00116 l4_is_irq_id(l4_threadid_t id);
00117
00125 L4_INLINE int
00126 l4_get_irqnr(l4_threadid_t id);
00127
00135 L4_INLINE l4_threadid_t
00136 l4_get_taskid(l4_threadid_t t);
00137
00146 L4_INLINE int
00147 l4_thread_equal(l4_threadid_t t1, l4_threadid_t t2);
00148
00157 L4_INLINE int
00158 l4_task_equal(l4_threadid_t t1, l4_threadid_t t2);
00159
00168 L4_INLINE int
00169 l4_tasknum_equal(l4_threadid_t t1, l4_threadid_t t2);
00170
00178 L4_INLINE void
00179 l4_make_taskid_from_irq(int irq, l4_threadid_t *t);
00180
00181
00182
00183
00184
00185 #include <l4/sys/__l4_fpage-32bit.h>
00186
00187
00188
00189
00190
00195 typedef struct {
00196 unsigned msg_deceited:1;
00197 unsigned fpage_received:1;
00198 unsigned msg_redirected:1;
00199 unsigned src_inside:1;
00200 unsigned snd_error:1;
00201 unsigned error_code:3;
00202 unsigned strings:5;
00203 unsigned dwords:19;
00204 } l4_msgdope_struct_t;
00205
00206
00211 typedef union {
00212 l4_umword_t msgdope;
00213 l4_msgdope_struct_t md;
00214 l4_umword_t raw;
00215 } l4_msgdope_t;
00216
00221 typedef struct {
00222 l4_umword_t snd_size;
00223 l4_umword_t snd_str;
00224 l4_umword_t rcv_size;
00225 l4_umword_t rcv_str;
00226 } l4_strdope_t;
00227
00228
00229
00230
00231
00232 #include <l4/sys/__timeout.h>
00233
00234
00235
00236
00237
00242 typedef struct {
00243 unsigned prio:8;
00247 unsigned small:8;
00250 unsigned state:4;
00288 unsigned time_exp:4;
00289 unsigned time_man:8;
00290 } l4_sched_param_struct_t;
00291
00296 typedef union {
00297 l4_umword_t sched_param;
00298 l4_sched_param_struct_t sp;
00299 } l4_sched_param_t;
00300
00306 #define L4_INVALID_SCHED_PARAM ((l4_sched_param_t){sched_param:~0UL})
00307
00323 #define L4_SMALL_SPACE(size_mb, nr) ((size_mb >> 2) + nr * (size_mb >> 1))
00324
00332 L4_INLINE int
00333 l4_is_invalid_sched_param(l4_sched_param_t sp);
00334
00342 L4_INLINE void
00343 l4_sched_param_set_time(int us, l4_sched_param_t *p);
00344
00345
00346
00347
00348
00349
00350
00351 L4_INLINE int
00352 l4_is_invalid_sched_param(l4_sched_param_t sp)
00353 {
00354 return sp.sched_param == 0xffffffff;
00355 }
00356
00357 L4_INLINE int
00358 l4_is_nil_id(l4_threadid_t id)
00359 {
00360 return id.raw == 0;
00361 }
00362
00363 L4_INLINE int
00364 l4_is_invalid_id(l4_threadid_t id)
00365 {
00366 return id.raw == 0xffffffff;
00367 }
00368
00369 L4_INLINE int
00370 l4_is_irq_id(l4_threadid_t id)
00371 {
00372 return id.raw > 0 && id.raw <= 255;
00373 }
00374
00375 L4_INLINE int
00376 l4_get_irqnr(l4_threadid_t id)
00377 {
00378 return id.raw - 1;
00379 }
00380
00381 L4_INLINE l4_threadid_t
00382 l4_get_taskid(l4_threadid_t t)
00383 {
00384 t.id.lthread = 0;
00385 return t;
00386 }
00387
00388 L4_INLINE int
00389 l4_thread_equal(l4_threadid_t t1, l4_threadid_t t2)
00390 {
00391 return t1.raw == t2.raw;
00392 }
00393
00394 #define TASK_MASK 0xfffe03ff
00395 L4_INLINE int
00396 l4_task_equal(l4_threadid_t t1, l4_threadid_t t2)
00397 {
00398 return (t1.raw & TASK_MASK) == (t2.raw & TASK_MASK);
00399 }
00400
00401 L4_INLINE int
00402 l4_tasknum_equal(l4_threadid_t t1, l4_threadid_t t2)
00403 {
00404 return (t1.id.task == t2.id.task);
00405 }
00406
00407 L4_INLINE void
00408 l4_make_taskid_from_irq(int irq, l4_threadid_t *t)
00409 {
00410 t->raw = irq+1;
00411 }
00412
00413 L4_INLINE void
00414 l4_sched_param_set_time(int us, l4_sched_param_t *p)
00415 {
00416 unsigned m = us;
00417 unsigned e = 15;
00418
00419 while (m > 255)
00420 {
00421 e--;
00422 m >>= 2;
00423 }
00424 p->sp.time_man = m;
00425 p->sp.time_exp = e;
00426 }
00427
00428 #endif