Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

l4_types.h

Go to the documentation of this file.
00001 // AUTOMATICALLY GENERATED -- DO NOT EDIT!         -*- c++ -*-
00002 
00003 #ifndef l4_types_h
00004 #define l4_types_h
00005 
00006 #include "types.h"
00007 
00008 #include "types.h"
00009 
00010 //
00011 // INTERFACE definition follows 
00012 //
00013 
00014 /*
00015  * arch. independent L4 Types
00016  */
00017 
00018 
00020 typedef Unsigned32 Task_num;
00021 
00023 typedef Unsigned32 LThread_num;
00024 
00026 typedef Unsigned32 GThread_num;
00027 
00038 class L4_uid
00039 {
00040 private:
00042   enum
00043   {
00044     Abs_rcv_mask        = 0x1,
00045     Abs_snd_mask        = 0x2,
00046     Abs_rcv_clock       = 0x4,
00047     Abs_snd_clock       = 0x8,
00048     Next_period         = 0x10,
00049     Preemption_id       = 0x20
00050   };
00051 
00052 public:
00054   enum
00055   {
00056     Invalid = 0xffffffff,       
00057     Nil     = 0x00000000,       
00058   };
00059 
00063   L4_uid ();
00064 
00068   L4_uid (Address addr, Address tcb_base, Address tcb_size);
00069 
00074   unsigned version() const;
00075 
00077   LThread_num lthread() const;
00078 
00080   GThread_num gthread() const;
00081 
00083   void version( unsigned );
00084 
00086   void lthread( LThread_num );
00087 
00092   Mword is_nil() const;
00093 
00098   Mword is_invalid() const;
00099 
00101   static L4_uid irq( unsigned irq );
00102 
00104   Mword is_irq() const;
00105 
00111   Mword irq() const;
00112 
00116   L4_uid preemption_id() const;
00117 
00119   bool operator == ( L4_uid o ) const;
00120 
00122   bool operator != ( L4_uid o ) const
00123   { return ! operator == (o); }
00124 
00128   L4_uid (Task_num task, LThread_num lthread);
00129 
00133   Task_num task() const;
00134 
00138   void task (Task_num);
00139 
00143   Task_num chief() const;
00144 
00145   /*
00146    * Set the chief ID.
00147    */
00148   void chief (Task_num);
00149 
00150   /*
00151    * Get the task ID, the local thread-number is set to 0.
00152    */
00153   L4_uid task_id() const;
00154 
00158   bool abs_rcv_timeout() const;
00159 
00163   bool abs_snd_timeout() const;
00164 
00168   bool abs_rcv_clock() const;
00169 
00173   bool abs_snd_clock() const;
00174 
00178   bool next_period() const;
00179 
00183   bool is_preemption() const;
00184 
00188   static unsigned const threads_per_task();
00189 
00195   static Mword const max_threads();
00196 private:
00197 
00198 private:
00199   enum
00200     {
00201       Irq_mask           = 0x00000000000000ffULL,
00202       Low_mask           = 0x00000000ffffffffULL,
00203       Nil_mask           = Low_mask,
00204       Version_low_mask   = 0x00000000000003ffULL,
00205       Version_low_shift  = 0,
00206       Version_low_size   = 10,
00207       Lthread_mask       = 0x000000000001fc00ULL,
00208       Lthread_shift      = Version_low_shift + Version_low_size,
00209       Lthread_size       = 7,
00210       Task_mask          = 0x000000000ffe0000ULL,
00211       Task_shift         = Lthread_shift + Lthread_size,
00212       Task_size          = 11,
00213       Version_high_mask  = 0x00000000f0000000ULL,
00214       Version_high_shift = Task_shift + Task_size,
00215       Version_high_size  = 4,
00216       Site_mask          = 0x0001ffff00000000ULL,
00217       Site_shift         = Version_high_shift + Version_high_size,
00218       Site_size          = 17,
00219       Chief_mask         = 0x0ffe000000000000ULL,
00220       Chief_shift        = Site_shift + Site_size,
00221       Chief_size         = 11,
00222       Nest_mask          = 0xf000000000000000ULL,
00223       Nest_shift         = Chief_shift + Chief_size,
00224       Nest_size          = 4,
00225     };
00226 
00227   Unsigned64 _raw;
00228 
00229 public:
00231   enum
00232     {
00233       Max_tasks          = 1 << Task_size
00234     };
00235 
00239   Unsigned64 raw() const;
00240 
00244   L4_uid (Unsigned64);
00245 
00249   L4_uid (Task_num task, LThread_num lthread, unsigned site,
00250           Task_num chief, unsigned nest = 0, unsigned version = 0);
00251 
00255   unsigned site() const;
00256 
00260   void site (unsigned);
00261 
00265   unsigned nest() const;
00266 
00270   void nest (unsigned);
00271 
00272 public:  
00273   Task_num d_task();
00274   
00275   void d_task(Mword num);
00276   
00277   LThread_num d_thread();
00278   
00279   void d_thread(Mword num);
00280   
00281   static inline Unsigned32 lthread_from_gthread(GThread_num g);
00282   
00283   static inline Unsigned32 task_from_gthread(GThread_num g);
00284   
00285   void print(int task_format = 0) const;
00286 };
00287 
00288 typedef L4_uid Global_id;
00289 
00293 class L4_snd_desc
00294 {
00295 public:
00296 
00300   L4_snd_desc( Mword w = (Mword)-1 );
00301 
00305   Mword deceite() const;
00306 
00310   Mword map() const;
00311 
00315   void *msg() const;
00316 
00320   Mword is_long_ipc() const;
00321 
00326   Mword is_register_ipc() const;
00327 
00331   Mword has_snd() const;
00332 
00333 private:
00334   Mword _d;
00335 
00336 public:  
00337   inline Mword raw() const;
00338 };
00339 
00340 
00347 class L4_fpage
00348 {
00349 public:
00357   L4_fpage (Mword grant, Mword write, Mword order, Mword page);
00358 
00371   L4_fpage( Mword order, Mword page );
00372 
00377   Mword grant() const;
00378 
00383   void grant (Mword g);
00389   Mword write() const;
00390 
00396   void write( Mword w );
00397 
00402   Mword size() const;
00403 
00408   void size( Mword order );
00409 
00414   Mword page() const;
00415 
00420   void page( Mword base );
00421 
00427   Mword is_whole_space() const;
00428 
00434   Mword is_valid() const;
00435 private:
00436 
00437 public:
00441   enum {
00442     Whole_io_space = 16, 
00443     Io_port_max    = 1L << Whole_io_space, 
00444   };
00445 
00452   static L4_fpage io(Mword port, Mword order, Mword grant);
00453 
00458   Mword iopage() const;
00459 
00464   void iopage( Mword addr );
00465 
00470   Mword is_iopage() const;
00471 
00479   Mword is_whole_io_space() const;
00480 
00481 private:
00482   enum {
00483     Iopage_mask  = 0x0ffff000,
00484     Iopage_shift = 12,
00485     Ioid_mask    = 0xf0000000,
00486     Io_id        = 0xf0000000,
00487   };
00488 private:
00489 
00490 public:
00491 
00492   typedef Mword Raw;
00493   typedef Raw Cache_type;
00494 
00498   enum 
00499   {
00500     Whole_space = 32, 
00501   };
00502 
00507   L4_fpage(Raw w = 0);
00508 
00513   Raw raw() const;
00514 
00515 private:
00516 
00517   Raw _raw;
00518 
00519   enum 
00520   { 
00521     /* +--- 32-12 ---+ 11-10 +- 9-8 -+- 7-2 + 1 + 0 +
00522      * | page number |   C   | unused | size | W | G |
00523      * +-------------+-------+--------+------+---+---+ */
00524     Grant_bit        = 0, 
00525     Write_bit        = 1, 
00526     Size_mask        = 0x000000fc,
00527     Size_shift       = 2,
00528     Size_size        = 6,
00529     Cache_type_mask  = 0x00000c00,
00530     Page_mask        = 0xfffff000,
00531     Page_shift       = 0,
00532     Page_size        = 32,
00533   };
00534 
00535 
00536 public:  
00537   inline L4_fpage::Cache_type cache_type() const;
00538 };
00539 
00540 
00544 class L4_rcv_desc
00545 {
00546 public:
00547 
00558   static L4_rcv_desc short_fpage (L4_fpage fp);
00559 
00563   L4_rcv_desc( Mword w = (Mword)-1 );
00564 
00569   Mword open_wait() const;
00570 
00575   Mword rmap() const;
00576 
00582   void *msg() const;
00583 
00589   L4_fpage fpage() const;
00590 
00595   Mword is_register_ipc() const;
00596 
00601   Mword has_receive() const;
00602 
00603 private:
00604   Mword _d;
00605 
00606 
00607 public:  
00609   inline Mword raw() const;
00610 };
00611 
00612 
00616 class Ipc_err
00617 {
00618 public:
00623   Ipc_err( Mword raw = 0 );
00624 
00629   Mword raw() const;
00630 
00635   Mword deceited() const;
00636 
00641   Mword fpage_received() const;
00642 
00647   void fpage_received( Mword f );
00648 
00653   Mword redirected() const;
00654 
00659   Mword src_inside() const;
00660 
00665   Mword snd_error() const;
00666 
00671   Mword error() const;
00672 
00679   void error( Mword error );
00680 
00685   Mword has_error() const;
00686 
00691   const char * str_error() const;
00692 
00698   Mword rcv_map_failed() const;
00699 
00705   Mword snd_map_failed() const;
00706 
00716   void combine( Ipc_err other );
00717 
00722   enum
00723     {
00725       Send_error    =           0x10,
00726       Enot_existent =           0x10, 
00727       Retimeout     =           0x20, 
00728       Setimeout     =           0x30, 
00729       Recanceled    =           0x40, 
00730       Secanceled    =           0x50, 
00731       Remapfailed   =           0x60, 
00732       Semapfailed   =           0x70, 
00733       Resndpfto     =           0x80, 
00734       Sesndpfto     =           0x90, 
00735       Rercvpfto     =           0xA0, 
00736       Sercvpfto     =           0xB0, 
00737       Reaborted     =           0xC0, 
00738       Seaborted     =           0xD0, 
00739       Remsgcut      =           0xE0, 
00740       Semsgcut      =           0xF0, 
00741     };
00742 
00743 private:
00744   enum
00745     {
00746       Deceite_bit      = 0,
00747       Fpage_bit        = 1,
00748       Redirected_bit   = 2,
00749       Src_inside_bit   = 3,
00750       Snd_error_bit    = 4,
00751       Error_code_shift = 5,
00752       Error_code_mask  = 0x7L << Error_code_shift,
00753       Error_code_size  = 3,
00754       Error_shift      = 4,
00755       Error_mask       = 0xfL << Error_shift,
00756       Error_size       = 4,
00757       Cc_mask          = 0xFF,
00758     };
00759 
00760   Mword _raw;
00761 };
00762   
00763 
00770 class L4_msgdope
00771 {
00772 public:
00777   enum {
00779     Send_error    =             0x10, 
00780     Enot_existent =             0x10, 
00781     Retimeout     =             0x20, 
00782     Setimeout     =             0x30, 
00783     Recanceled    =             0x40, 
00784     Secanceled    =             0x50, 
00785     Remapfailed   =             0x60, 
00786     Semapfailed   =             0x70, 
00787     Resndpfto     =             0x80, 
00788     Sesndpfto     =             0x90, 
00789     Rercvpfto     =             0xA0, 
00790     Sercvpfto     =             0xB0, 
00791     Reaborted     =             0xC0, 
00792     Seaborted     =             0xD0, 
00793     Remsgcut      =             0xE0, 
00794     Semsgcut      =             0xF0, 
00795   };
00796 
00801   L4_msgdope( Mword raw = 0 );
00802 
00808   L4_msgdope( Mword mwords, Mword strings );
00809 
00815   L4_msgdope (Ipc_err e);
00816 
00821   Mword raw() const;
00822 
00826   Mword raw_dope() const;
00827 
00832   Mword deceited() const;
00833 
00838   Mword fpage_received() const;
00839 
00844   void fpage_received( Mword f );
00845 
00850   Mword redirected() const;
00851 
00856   Mword src_inside() const;
00857 
00862   Mword snd_error() const;
00863 
00868   Mword error() const;
00869 
00876   void error( Mword error );
00877 
00882   Mword has_error() const;
00883 
00888   const char * str_error() const;
00889 
00894   Mword strings() const;
00895 
00900   void strings( Mword s );
00901 
00906   Mword mwords() const;
00907 
00912   void mwords( Mword w );
00913 
00919   Mword rcv_map_failed() const;
00920 
00926   Mword snd_map_failed() const;
00927 
00937   void combine( L4_msgdope other );
00938 
00944   void combine( Ipc_err e );
00945 
00946 private:
00947   Mword _raw;
00948   enum {
00949     Deceite_bit      = 0,
00950     Fpage_bit        = 1,
00951     Redirected_bit   = 2,
00952     Src_inside_bit   = 3,
00953     Snd_error_bit    = 4,
00954     Error_code_shift = 5,
00955     Error_code_mask  = 0x7L << Error_code_shift,
00956     Error_code_size  = 3,
00957     Error_shift      = 4,
00958     Error_mask       = 0xfL << Error_shift,
00959     Error_size       = 4,
00960     Strings_shift    = Error_code_shift + Error_code_size,
00961     Strings_mask     = 0x1fL << Strings_shift,
00962     Strings_size     = 5,
00963     Mwords_shift     = Strings_shift + Strings_size,
00964     Mwords_mask      = 0x7ffffL << Mwords_shift,
00965     Mwords_size      = 19,
00966     Dope_mask        = Strings_mask | Mwords_mask,
00967   };
00968 
00969 };
00970 
00971 
00977 class L4_str_dope 
00978 {
00979 public:
00981   Mword snd_size;
00982 
00984   Unsigned8 *snd_str;
00985 
00987   Mword rcv_size;
00988 
00990   Unsigned8 *rcv_str;
00991 };
00992 
00993 
00997 class L4_timeout
00998 {
00999 public:
01001   enum {
01002     Never = 0, 
01003   };
01004 
01018   L4_timeout (Mword snd_man, Mword snd_exp, 
01019               Mword rcv_man, Mword rcv_exp, 
01020               Mword snd_pflt, Mword rcv_pflt);
01021 
01026   Mword rcv_pfault() const;
01027 
01033   void rcv_pfault (Mword pr);
01034 
01039   Mword snd_pfault() const;
01040 
01045   void snd_pfault (Mword ps);
01050   explicit L4_timeout( Mword t = 0 );
01051 
01056   Mword raw();
01057 
01063   Mword rcv_exp() const;
01064 
01070   void rcv_exp( Mword er );
01071 
01077   Mword rcv_man() const;
01078 
01084   void rcv_man( Mword mr );
01085 
01091   Mword snd_exp() const;
01092 
01098   void snd_exp( Mword es );
01099 
01105   Mword snd_man() const;
01106 
01112   void snd_man( Mword ms );
01113 
01119   Unsigned64 rcv_microsecs_rel (Unsigned64 clock) const;
01120 
01126   Unsigned64 snd_microsecs_rel (Unsigned64 clock) const;
01127 
01133   Unsigned64 rcv_microsecs_abs (Unsigned64 clock, bool c) const;
01134 
01140   Unsigned64 snd_microsecs_abs (Unsigned64 clock, bool c) const;
01141 
01142 private:
01143   enum
01144     {
01145       Rcv_exp_mask     = 0xf,
01146       Rcv_exp_shift    = 0,
01147 
01148       Snd_exp_mask     = 0xf0,
01149       Snd_exp_shift    = 4,
01150 
01151       Rcv_pfault_mask  = 0xf00,
01152       Rcv_pfault_shift = 8,
01153 
01154       Snd_pfault_mask  = 0xf000,
01155       Snd_pfault_shift = 12,
01156 
01157       Snd_man_mask     = 0xff0000,
01158       Snd_man_shift    = 16,
01159 
01160       Rcv_man_mask     = 0xff000000,
01161       Rcv_man_shift    = 24,
01162     };
01163 
01164   Mword _t;
01165 };
01166 
01167 
01171 class L4_sched_param
01172 {
01173 public:
01174 
01178   L4_sched_param( Mword raw = 0 );
01179 
01184   Mword is_valid() const;
01185 
01190   Mword prio() const;
01191 
01196   void prio( Mword p );
01197 
01202   Mword small() const;
01203 
01208   void small( Mword s );
01209 
01214   Mword mode() const;
01215 
01220   void thread_state( Mword s );
01221 
01227   void time( Unsigned64 t );
01228 
01234   Unsigned64 time();
01235 
01241   Mword time_exp() const;
01242 
01248   void time_exp( Mword e );
01249 
01255   Mword time_man() const;
01256 
01262   void time_man( Mword m );
01263 
01268   Mword raw() const;
01269 
01270 private:
01271 
01272   Mword _raw;
01273 
01274   enum {
01275     Prio_shift     = 0,
01276     Prio_mask      = 0x0ff,
01277     Prio_size      = 8,
01278     Small_shift    = Prio_size + Prio_shift,
01279     Small_size     = 8,
01280     Small_mask     = ((1UL << Small_size) - 1) << Small_shift,
01281     Mode_shift     = Small_shift + Small_size,
01282     Mode_size      = 4,
01283     Mode_mask      = ((1UL << Mode_size) - 1) << Mode_shift,
01284     Time_exp_shift = Mode_shift + Mode_size, 
01285     Time_exp_size  = 4,
01286     Time_exp_mask  = ((1UL << Time_exp_size) - 1) << Time_exp_shift,
01287     Time_man_shift = Time_exp_size + Time_exp_shift,
01288     Time_man_size  = 8,
01289     Time_man_mask  = ((1UL << Time_man_size) - 1) << Time_man_shift,
01290   };
01291 
01292 };
01293 
01294 class L4_pipc
01295 {
01296 private:
01297   enum
01298     {
01299       Clock_shift        = 0,
01300       Id_shift           = 56,
01301       Lost_shift         = 62,
01302       Type_shift         = 63,
01303       Clock_mask         = 0x00ffffffffffffffULL,
01304       Id_mask            = 0x3f00000000000000ULL,
01305       Lost_mask          = 0x4000000000000000ULL,
01306       Type_mask          = 0x8000000000000000ULL,
01307       Low_shift          = 0,
01308       High_shift         = 32,
01309       Low_mask           = 0x00000000ffffffffULL,
01310       High_mask          = 0xffffffff00000000ULL
01311     };
01312 
01316   Unsigned64 _raw;
01317 
01318 public:
01322   Mword low() const;
01323 
01327   Mword high() const;
01328 
01332   L4_pipc (unsigned type, unsigned lost, unsigned id, Cpu_time clock);
01333 };
01334 
01335 
01336 class L4_exception_ipc
01337 {
01338 public:
01339   enum
01340   {
01341     Exception_ipc_cookie_1 = Mword(-0x5),
01342     Exception_ipc_cookie_2 = Mword(-0x21504151),
01343   };
01344 };
01345 
01346 
01347 //----------------------------------------------------------------------------
01348 
01349   
01353 typedef void Utcb;      
01354 typedef L4_uid Local_id;
01355 
01356 //
01357 // IMPLEMENTATION of inline functions (and needed classes)
01358 //
01359 
01360 
01361 
01362 
01363 inline Unsigned32
01364 L4_uid::lthread_from_gthread(GThread_num g)
01365 {
01366   return g % threads_per_task();
01367 }
01368 
01369 
01370 
01371 inline Unsigned32
01372 L4_uid::task_from_gthread(GThread_num g)
01373 {
01374   return g / threads_per_task();
01375 }
01376 
01377 
01378 //
01379 // L4_uid implementation
01380 //
01381 
01382 inline L4_uid::L4_uid()
01383 {}
01384 
01385 
01386 inline bool L4_uid::abs_rcv_timeout() const
01387 { return chief() & Abs_rcv_mask; }
01388 
01389  
01390 inline bool L4_uid::abs_snd_timeout() const
01391 { return chief() & Abs_snd_mask; }
01392 
01393  
01394 inline bool L4_uid::abs_rcv_clock() const
01395 { return chief() & Abs_rcv_clock; }
01396 
01397  
01398 inline bool L4_uid::abs_snd_clock() const
01399 { return chief() & Abs_snd_clock; }
01400 
01401 
01402 inline bool L4_uid::next_period() const
01403 { return chief() & Next_period; }
01404 
01405 
01406 inline bool L4_uid::is_preemption() const
01407 { return chief() & Preemption_id; }
01408 
01409 
01410 
01411 inline L4_uid
01412 L4_uid::preemption_id() const
01413 {
01414   L4_uid id (_raw);
01415   id.chief (Preemption_id);
01416   return id;
01417 }
01418 
01419 
01420 inline unsigned const L4_uid::threads_per_task()
01421 { return 1 << Lthread_size; }
01422 
01423  
01424 inline bool L4_uid::operator == (L4_uid o) const
01425 { return o._raw == _raw; }
01426 
01427 
01428 inline Mword const L4_uid::max_threads()
01429 { return 1 << (Task_size + Lthread_size); }
01430 
01431 
01432 inline Mword L4_uid::irq() const
01433 { return _raw - 1; }
01434 
01435 
01436 inline L4_uid L4_uid::irq(unsigned irq)
01437 { return L4_uid ((irq + 1) & Irq_mask); }
01438 
01439 
01440 inline Mword L4_uid::is_irq() const
01441 { return (_raw & ~Irq_mask) == 0 && _raw; }
01442 
01443 
01444 inline L4_uid L4_uid::task_id() const
01445 { return L4_uid (_raw & ~Lthread_mask); }
01446 
01447 
01448 inline Mword L4_uid::is_nil() const
01449 { return (_raw & Nil_mask) == 0; }
01450 
01451 
01452 inline Mword L4_uid::is_invalid() const
01453 { return (_raw & Low_mask) == Invalid; }
01454 
01455 
01456 
01457 inline L4_uid::L4_uid(Unsigned64 w)
01458       : _raw (w)
01459 {}
01460 
01461 
01462 
01463 inline L4_uid::L4_uid(Task_num task, LThread_num lthread)
01464       : _raw ((((Unsigned64) task    << Task_shift)    & Task_mask) |
01465               (((Unsigned64) lthread << Lthread_shift) & Lthread_mask))
01466 {}
01467 
01468   
01469 
01470 inline L4_uid::L4_uid(Task_num task, LThread_num lthread, unsigned site,
01471                 Task_num chief, unsigned nest, unsigned version) 
01472   : _raw ((((Unsigned64) task    << Task_shift)         & Task_mask)        |
01473           (((Unsigned64) lthread << Lthread_shift)      & Lthread_mask)     |
01474           (((Unsigned64) site    << Site_shift)         & Site_mask)        |
01475           (((Unsigned64) chief   << Chief_shift)        & Chief_mask)       |
01476           (((Unsigned64) nest    << Nest_shift)         & Nest_mask)        |
01477           (((Unsigned64) version << Version_low_shift)  & Version_low_mask) |
01478           (((Unsigned64) version << Version_high_shift) & Version_high_mask))
01479 {}
01480 
01481 
01482 inline Unsigned64 L4_uid::raw() const
01483 { return _raw; }
01484 
01485 
01486 
01487 inline unsigned
01488 L4_uid::version() const
01489 {
01490   return ((_raw & Version_high_mask) >> Version_high_shift) |
01491          ((_raw & Version_low_mask ) >> Version_low_shift);
01492 }
01493 
01494 
01495 
01496 inline void
01497 L4_uid::version(unsigned w)
01498 {
01499   _raw = (_raw & ~(Version_low_mask | Version_high_mask)) |
01500          (((Unsigned64) w << Version_low_shift)  & Version_low_mask) |
01501          (((Unsigned64) w << Version_high_shift) & Version_high_mask);
01502 }
01503 
01504 
01505 
01506 inline LThread_num
01507 L4_uid::lthread() const  
01508 {
01509   // both casts (_raw and Lthread_mask) to unsigned are hints for gcc
01510   return ((unsigned) _raw & (unsigned) Lthread_mask) >> Lthread_shift;
01511 }
01512 
01513 
01514 
01515 inline void
01516 L4_uid::lthread(LThread_num w)
01517 {
01518   _raw = (_raw & ~Lthread_mask) |
01519          (((Unsigned64) w << Lthread_shift) & Lthread_mask);
01520 }
01521 
01522 
01523 
01524 inline Task_num
01525 L4_uid::task() const
01526 {
01527   // both casts (_raw and Task_mask) to unsigned are hints for gcc
01528   return ((unsigned) _raw & (unsigned) Task_mask) >> Task_shift;
01529 }
01530 
01531 
01532 
01533 inline void
01534 L4_uid::task(Task_num w)
01535 {
01536   _raw = (_raw & ~Task_mask) |
01537          (((Unsigned64) w << Task_shift) & Task_mask);
01538 }
01539 
01540 
01541 
01542 inline Task_num
01543 L4_uid::chief() const
01544 {
01545   return (_raw & Chief_mask) >> Chief_shift;
01546 }
01547 
01548 
01549 
01550 inline void
01551 L4_uid::chief(Task_num w)
01552 {
01553   _raw = (_raw & ~Chief_mask) |
01554          (((Unsigned64) w << Chief_shift) & Chief_mask);
01555 }
01556 
01557 
01558 
01559 inline unsigned
01560 L4_uid::site() const
01561 {
01562   return (_raw & Site_mask) >> Site_shift;
01563 }
01564 
01565 
01566 
01567 inline void
01568 L4_uid::site(unsigned w)
01569 {
01570   _raw = (_raw & ~Site_mask) | (((Unsigned64) w << Site_shift) & Site_mask);
01571 }
01572 
01573  
01574 
01575 inline unsigned
01576 L4_uid::nest() const
01577 {
01578   return (_raw & Nest_mask) >> Nest_shift;
01579 }
01580 
01581 
01582 
01583 inline void
01584 L4_uid::nest(unsigned w)
01585 {
01586   _raw = (_raw & ~Nest_mask) | (((Unsigned64) w << Nest_shift) & Nest_mask);
01587 }
01588 
01589 
01590 
01591 inline GThread_num
01592 L4_uid::gthread() const
01593 {
01594   // both casts (_raw and {LTHREAD,TASK}_MASK) to unsigned are hints for gcc
01595   return (((unsigned) _raw & (unsigned) Lthread_mask) >> Lthread_shift) |
01596          (((unsigned) _raw & (unsigned) Task_mask   ) >> (Task_shift - 
01597                                                           Lthread_size));
01598 }
01599 
01600 
01601 
01602 inline L4_uid::L4_uid(Address addr, Address tcb_base, Address tcb_size)
01603       : _raw ( ((addr - tcb_base) / tcb_size) << Lthread_shift )
01604 {}
01605 
01606 
01607 inline Mword L4_snd_desc::raw() const
01608 { return _d; }
01609 
01610 
01611 //
01612 // L4_snd_desc implementation
01613 //
01614 
01615 inline L4_snd_desc::L4_snd_desc( Mword w )
01616   : _d(w)
01617 {}
01618 
01619   
01620 inline Mword L4_snd_desc::deceite() const
01621 { return _d & 1; }
01622 
01623 
01624 inline Mword L4_snd_desc::map() const
01625 { return _d & 2; }
01626 
01627 
01628 inline Mword L4_snd_desc::is_long_ipc() const
01629 { return _d & ~1; }
01630 
01631 
01632 inline Mword L4_snd_desc::is_register_ipc() const
01633 { return (_d & ~1) == 0; }
01634 
01635 
01636 inline Mword L4_snd_desc::has_snd() const
01637 { return _d != (Mword)-1; }
01638 
01639 
01640 inline void *L4_snd_desc::msg() const
01641 { return (void*)(_d & ~3); }
01642 
01643 
01644 
01645 inline L4_fpage::Cache_type
01646 L4_fpage::cache_type() const
01647 { return _raw & Cache_type_mask; }
01648 
01649 
01650 
01651 inline Mword L4_fpage::is_iopage() const
01652 {
01653   return (_raw & Ioid_mask) == Io_id;
01654 }
01655 
01656 
01657 
01658 inline void L4_fpage::iopage( Mword w )
01659 {
01660   _raw = (_raw & ~Iopage_mask) | ((w << Iopage_shift) & Iopage_mask);
01661 }
01662 
01663 
01664 
01665 inline Mword L4_fpage::iopage() const
01666 {
01667   return (_raw & Iopage_mask) >> Iopage_shift;
01668 }
01669 
01670 
01671 
01672 inline L4_fpage L4_fpage::io( Mword port, Mword size, Mword grant )
01673 {
01674   return L4_fpage( (grant ? 1 : 0) 
01675                    | ((port << Iopage_shift) & Iopage_mask)
01676                    | ((size << Size_shift) & Size_mask)
01677                    | Io_id);
01678 }
01679 
01680 
01681 
01682 inline Mword L4_fpage::is_whole_io_space() const
01683 {
01684   return (_raw >> 2) == Whole_io_space;
01685 }
01686 
01687 
01688 
01689 inline Mword 
01690 L4_fpage::is_valid() const
01691 { return _raw; }
01692 
01693 
01694 
01695 inline L4_fpage::L4_fpage(Raw raw)
01696   : _raw(raw)
01697 {}
01698 
01699 
01700 
01701 inline L4_fpage::L4_fpage(Mword grant, Mword write, Mword size, Mword page)
01702   : _raw((grant ? (1<<Grant_bit) : 0)
01703          | (write ? (1<<Write_bit) : 0)
01704          | ((size << Size_shift) & Size_mask)
01705          | ((page << Page_shift) & Page_mask))
01706 {}
01707 
01708 
01709 
01710 inline L4_fpage::L4_fpage(Mword size, Mword page)
01711   : _raw(((size << Size_shift) & Size_mask)
01712          | ((page << Page_shift) 
01713             & Page_mask))
01714 {}
01715 
01716 
01717 
01718 inline Mword 
01719 L4_fpage::grant() const
01720 { return _raw & (1<<Grant_bit); }
01721 
01722 
01723 
01724 inline Mword
01725 L4_fpage::write() const
01726 { return _raw & (1<<Write_bit); }
01727 
01728 
01729 
01730 inline Mword
01731 L4_fpage::size() const
01732 { return (_raw & Size_mask) >> Size_shift; }
01733 
01734 
01735 
01736 inline Mword
01737 L4_fpage::page() const
01738 { return (_raw & Page_mask) >> Page_shift; }
01739 
01740 
01741 
01742 inline void 
01743 L4_fpage::grant(Mword w)
01744 {
01745   if(w)
01746     _raw |= (1<<Grant_bit);
01747   else
01748     _raw &= ~(1<<Grant_bit);
01749 }
01750 
01751 
01752 
01753 inline void 
01754 L4_fpage::write(Mword w)
01755 {
01756   if(w)
01757     _raw |= (1<<Write_bit);
01758   else
01759     _raw &= ~(1<<Write_bit);
01760 }
01761 
01762 
01763 
01764 inline void 
01765 L4_fpage::size(Mword w)
01766 { _raw = (_raw & ~Size_mask) | ((w<<Size_shift) & Size_mask); }
01767 
01768 
01769 
01770 inline void 
01771 L4_fpage::page(Mword w)
01772 { _raw = (_raw & ~Page_mask) | ((w<<Page_shift) & Page_mask); }
01773 
01774 
01775 
01776 inline L4_fpage::Raw
01777 L4_fpage::raw() const
01778 { return _raw; }
01779 
01780 
01781 
01782 inline Mword
01783 L4_fpage::is_whole_space() const
01784 { return (_raw >> 2) == 32; }
01785 
01786 
01788 inline Mword L4_rcv_desc::raw() const
01789 { return _d; }
01790 
01791 
01792 //
01793 // L4_rcv_desc implementation
01794 //
01795 
01796 inline L4_rcv_desc L4_rcv_desc::short_fpage(L4_fpage fp)
01797 { return L4_rcv_desc( 2 /*rmap*/ | (fp.raw() & ~3) ); }
01798 
01799 
01800 inline L4_rcv_desc::L4_rcv_desc( Mword w)
01801   : _d(w)
01802 {}
01803 
01804 
01805 inline Mword L4_rcv_desc::open_wait() const
01806 { return _d & 1; }
01807 
01808 
01809 inline Mword L4_rcv_desc::rmap() const
01810 { return _d & 2; }
01811 
01812 
01813 inline void *L4_rcv_desc::msg() const
01814 { return (void*)(_d & ~3); }
01815 
01816 
01817 inline L4_fpage L4_rcv_desc::fpage() const
01818 { return L4_fpage( _d & ~3 ); }
01819 
01820 
01821 inline Mword L4_rcv_desc::is_register_ipc() const
01822 { return (_d & ~1) == 0; }
01823 
01824   
01825 inline Mword L4_rcv_desc::has_receive() const
01826 { return _d != (Mword)-1; }
01827 
01828 
01829 
01830 //
01831 // Ipc_err implementation
01832 //
01833 
01834 inline Ipc_err::Ipc_err(Mword raw)
01835        : _raw (raw & Cc_mask)
01836 {}
01837 
01838 
01839 inline Mword Ipc_err::raw() const
01840 { return _raw; }
01841 
01842 
01843 inline Mword Ipc_err::deceited() const
01844 { return _raw & (1 << Deceite_bit); }
01845 
01846 
01847 inline Mword Ipc_err::fpage_received() const
01848 { return _raw & (1 << Fpage_bit); }
01849 
01850 
01851 inline Mword Ipc_err::redirected() const
01852 { return _raw & (1 << Redirected_bit); }
01853 
01854 
01855 inline Mword Ipc_err::src_inside() const
01856 { return _raw & (1 << Src_inside_bit); }
01857 
01858 
01859 inline Mword
01860 Ipc_err::snd_error() const
01861 { return _raw & (1 << Snd_error_bit); }
01862 
01863 
01864 inline Mword Ipc_err::has_error() const
01865 { return _raw & Error_mask; }
01866 
01867 
01868 inline Mword Ipc_err::error() const
01869 { return _raw & Error_mask; }
01870 
01871 
01872 inline Mword Ipc_err::rcv_map_failed() const
01873 { return (_raw & Error_mask) == Remapfailed; }
01874 
01875 
01876 inline Mword Ipc_err::snd_map_failed() const
01877 { return (_raw & Error_mask) == Semapfailed; }
01878 
01879 
01880 inline void Ipc_err::error(Mword e)
01881 { _raw = (_raw & ~Error_mask) | (e & Error_mask); }
01882 
01883 
01884 
01885 inline void
01886 Ipc_err::fpage_received(Mword w)
01887 {
01888   if (w)
01889     _raw |= (1L << Fpage_bit);
01890   else
01891     _raw &= ~(1L << Fpage_bit);
01892 }
01893 
01894 
01895 inline void Ipc_err::combine(Ipc_err o)
01896 { _raw = (_raw & ~Error_mask) | o._raw; }
01897 
01898 
01899 //
01900 // L4_msgdope implementation
01901 //
01902 
01903 inline L4_msgdope::L4_msgdope(Mword mwords, Mword strings)
01904   : _raw( ((strings << Strings_shift) & Strings_mask)
01905           |((mwords << Mwords_shift) & Mwords_mask) )
01906 {}
01907 
01908 
01909 
01910 inline L4_msgdope::L4_msgdope( Mword raw )
01911   : _raw(raw)
01912 {}
01913 
01914 
01915 
01916 inline L4_msgdope::L4_msgdope(Ipc_err e)
01917   : _raw (e.raw())
01918 {}
01919 
01920 
01921 inline Mword L4_msgdope::raw() const
01922 { return _raw; }
01923 
01924 
01925 inline Mword L4_msgdope::raw_dope() const
01926 {return _raw & Dope_mask;}
01927 
01928 
01929 inline Mword L4_msgdope::deceited() const
01930 { return _raw & (1 << Deceite_bit); }
01931 
01932 
01933 inline Mword L4_msgdope::fpage_received() const
01934 { return _raw & (1 << Fpage_bit); }
01935 
01936 
01937 inline Mword L4_msgdope::redirected() const
01938 { return _raw & (1 << Redirected_bit); }
01939 
01940 
01941 inline Mword L4_msgdope::src_inside() const
01942 { return _raw & (1 << Src_inside_bit); }
01943 
01944 
01945 inline Mword L4_msgdope::snd_error() const
01946 { return _raw & (1 << Snd_error_bit); }
01947 
01948 
01949 inline Mword L4_msgdope::strings() const
01950 { return (_raw & Strings_mask) >> Strings_shift; }
01951 
01952 
01953 inline Mword L4_msgdope::mwords() const
01954 { return (_raw & Mwords_mask) >> Mwords_shift; }
01955 
01956 
01957 inline void L4_msgdope::mwords( Mword w )
01958 { _raw = (_raw & ~Mwords_mask) | ((w << Mwords_shift) & Mwords_mask); }
01959 
01960 
01961 inline void L4_msgdope::strings( Mword w )
01962 { _raw = (_raw & ~Strings_mask) | ((w << Strings_shift) & Strings_mask); }
01963 
01964 
01965 inline Mword L4_msgdope::has_error() const
01966 { return _raw & Error_mask; }
01967 
01968 
01969 inline Mword L4_msgdope::error() const
01970 { return _raw & Error_mask; }
01971 
01972 
01973 inline Mword L4_msgdope::rcv_map_failed() const
01974 { return (_raw & Error_mask) == Remapfailed; }
01975 
01976 
01977 inline Mword L4_msgdope::snd_map_failed() const
01978 { return (_raw & Error_mask) == Semapfailed; }
01979 
01980 
01981 inline void L4_msgdope::error(Mword e)
01982 { _raw = (_raw & ~Error_mask) | (e & Error_mask); }
01983 
01984 
01985 
01986 inline void
01987 L4_msgdope::fpage_received( Mword w )
01988 {
01989   if(w)
01990     _raw |= (1L << Fpage_bit);
01991   else
01992     _raw &= ~(1L << Fpage_bit);
01993 }
01994 
01995 
01996 inline void L4_msgdope::combine( L4_msgdope o )
01997 { _raw = (_raw & ~Error_mask) | o._raw; }
01998 
01999 
02000 inline void L4_msgdope::combine( Ipc_err e )
02001 { _raw = (_raw & ~Error_mask) | e.raw(); }
02002 
02003 
02004 //
02005 // L4_timeout implementation
02006 //
02007 
02008 inline L4_timeout::L4_timeout(Mword t)
02009   : _t(t)
02010 {}
02011 
02012 
02013 inline Mword L4_timeout::raw()
02014 { return _t; }
02015 
02016 
02017 
02018 inline Unsigned64
02019 L4_timeout::rcv_microsecs_rel(Unsigned64 clock) const
02020 { return clock + ((Unsigned64) (rcv_man()) << ((15 - rcv_exp()) << 1)); }
02021 
02022 
02023 
02024 inline Unsigned64
02025 L4_timeout::snd_microsecs_rel(Unsigned64 clock) const
02026 { return clock + ((Unsigned64) (snd_man()) << ((15 - snd_exp()) << 1)); }
02027 
02028 
02029 
02030 inline Unsigned64
02031 L4_timeout::rcv_microsecs_abs(Unsigned64 clock, bool c) const
02032 {
02033   Mword e = 15 - rcv_exp();
02034   Unsigned64 timeout = clock & ~((1 << e + 8) - 1) | rcv_man() << e;
02035 
02036   if (((clock >> e + 8) & 1) != c)
02037     timeout += 1 << e + 8;
02038 
02039   if (timeout > clock + (1 << e + 8))
02040     timeout -= 1 << e + 9;
02041 
02042   return timeout;
02043 }
02044 
02045 
02046 
02047 inline Unsigned64
02048 L4_timeout::snd_microsecs_abs(Unsigned64 clock, bool c) const
02049 {
02050   Mword e = 15 - snd_exp();
02051   Unsigned64 timeout = clock & ~((1 << e + 8) - 1) | snd_man() << e;
02052 
02053   if (((clock >> e + 8) & 1) != c)
02054     timeout += 1 << e + 8;
02055 
02056   if (timeout > clock + (1 << e + 8))
02057     timeout -= 1 << e + 9;
02058 
02059   return timeout;
02060 }
02061 
02062 
02063 
02064 //
02065 // L4_timeout implementation
02066 //
02067 
02068 inline L4_timeout::L4_timeout(Mword snd_man, Mword snd_exp, 
02069                         Mword rcv_man, Mword rcv_exp, 
02070                         Mword snd_pflt, Mword rcv_pflt)
02071           : _t (((snd_man << Snd_man_shift) & Snd_man_mask) |
02072                 ((snd_exp << Snd_exp_shift) & Snd_exp_mask) |
02073                 ((rcv_man << Rcv_man_shift) & Rcv_man_mask) |
02074                 ((rcv_exp << Rcv_exp_shift) & Rcv_exp_mask) |
02075                 ((rcv_pflt << Rcv_pfault_shift) & Rcv_pfault_mask) |
02076                 ((snd_pflt << Snd_pfault_shift) & Snd_pfault_mask))
02077 {}
02078 
02079  
02080 inline Mword L4_timeout::rcv_exp() const
02081 { return (_t & Rcv_exp_mask) >> Rcv_exp_shift; }
02082 
02083 
02084 inline void L4_timeout::rcv_exp(Mword w)
02085 { _t = (_t & ~Rcv_exp_mask) | ((w << Rcv_exp_shift) & Rcv_exp_mask); }
02086 
02087  
02088 inline Mword L4_timeout::snd_exp() const
02089 { return (_t & Snd_exp_mask) >> Snd_exp_shift; }
02090 
02091 
02092 inline void L4_timeout::snd_exp(Mword w)
02093 { _t = (_t & ~Snd_exp_mask) | ((w << Snd_exp_shift) & Snd_exp_mask); }
02094 
02095 
02096 inline Mword L4_timeout::rcv_pfault() const
02097 { return (_t & Rcv_pfault_mask) >> Rcv_pfault_shift; }
02098 
02099 
02100 inline void L4_timeout::rcv_pfault(Mword w)
02101 { _t = (_t & ~Rcv_pfault_mask) | ((w << Rcv_pfault_shift) & Rcv_pfault_mask); }
02102 
02103 
02104 inline Mword L4_timeout::snd_pfault() const
02105 { return (_t & Snd_pfault_mask) >> Snd_pfault_shift; }
02106 
02107 
02108 inline void L4_timeout::snd_pfault(Mword w)
02109 { _t = (_t & ~Snd_pfault_mask) | ((w << Snd_pfault_shift) & Snd_pfault_mask); }
02110 
02111 
02112 inline Mword L4_timeout::rcv_man() const
02113 { return (_t & Rcv_man_mask) >> Rcv_man_shift; }
02114 
02115 
02116 inline void L4_timeout::rcv_man(Mword w)
02117 { _t = (_t & ~Rcv_man_mask) | ((w << Rcv_man_shift) & Rcv_man_mask); }
02118 
02119 
02120 inline Mword L4_timeout::snd_man() const
02121 { return (_t & Snd_man_mask) >> Snd_man_shift; }
02122 
02123 
02124 inline void L4_timeout::snd_man(Mword w)
02125 { _t = (_t & ~Snd_man_mask) | ((w << Snd_man_shift) & Snd_man_mask); }
02126 
02127 
02128 //
02129 // L4_sched_param implementation
02130 //
02131 
02132 inline L4_sched_param::L4_sched_param( Mword raw )
02133   : _raw(raw)
02134 {}
02135 
02136 
02137 inline Mword L4_sched_param::prio() const
02138 { return (_raw & Prio_mask) >> Prio_shift; }
02139 
02140 
02141 inline void L4_sched_param::prio( Mword p )
02142 { _raw = (_raw & ~Prio_mask) | ((p << Prio_shift) & Prio_mask); }
02143 
02144 
02145 inline Mword L4_sched_param::small() const
02146 { return (_raw & Small_mask) >> Small_shift; }
02147 
02148 
02149 inline void L4_sched_param::small( Mword s )
02150 { _raw = (_raw & ~Small_mask) | ((s << Small_shift) & Small_mask); }
02151 
02152 
02153 inline Mword L4_sched_param::time_exp() const
02154 { return (_raw & Time_exp_mask) >> Time_exp_shift; }
02155 
02156 
02157 inline void L4_sched_param::time_exp( Mword e )
02158 { _raw = (_raw & ~Time_exp_mask) | ((e << Time_exp_shift) & Time_exp_mask); }
02159 
02160 
02161 inline Mword L4_sched_param::time_man() const
02162 { return (_raw & Time_man_mask) >> Time_man_shift; }
02163 
02164 
02165 inline void L4_sched_param::time_man( Mword m )
02166 { _raw = (_raw & ~Time_man_mask) | ((m << Time_man_shift) & Time_man_mask); }
02167 
02168 
02169 inline Mword L4_sched_param::mode() const
02170 { return (_raw & Mode_mask) >> Mode_shift; }
02171 
02172 
02173 inline void L4_sched_param::thread_state( Mword e )
02174 { _raw = (_raw & ~Mode_mask) | ((e << Mode_shift) & Mode_mask); }
02175 
02176 
02177 inline Mword L4_sched_param::raw() const
02178 { return _raw; }
02179 
02180 
02181 inline Mword L4_sched_param::is_valid() const
02182 { return _raw != (Mword)-1; }
02183 
02184 
02185 
02186 inline void
02187 L4_sched_param::time(Unsigned64 t)
02188 {
02189   Mword exp = 15;
02190   while (t > 255)
02191     {
02192       t >>= 2;
02193       exp--;
02194     }
02195 
02196   time_exp(exp);
02197   time_man(t);
02198 }
02199 
02200 
02201 
02202 inline Unsigned64
02203 L4_sched_param::time()
02204 {
02205   if(time_exp())
02206     {
02207       if(time_man())
02208         return (Unsigned64)time_man() << ((15-time_exp()) << 1);
02209       else
02210         return 0;
02211     }
02212   else
02213     return (Unsigned64)-1;
02214 }
02215 
02216 
02217 //
02218 // L4_pipc implementation
02219 //
02220 
02221 inline L4_pipc::L4_pipc(unsigned type, unsigned lost, unsigned id, Cpu_time clock)
02222        : _raw ( (((Unsigned64) type  << Type_shift)  & Type_mask) |
02223                 (((Unsigned64) lost  << Lost_shift)  & Lost_mask) |
02224                 (((Unsigned64) id    << Id_shift)    & Id_mask)   |
02225                 (((Unsigned64) clock << Clock_shift) & Clock_mask))
02226 {}
02227 
02228 
02229 inline Mword L4_pipc::low() const
02230 { return (_raw & Low_mask) >> Low_shift; }
02231 
02232 
02233 inline Mword L4_pipc::high() const
02234 { return (_raw & High_mask) >> High_shift; }
02235 
02236 #endif // l4_types_h

Generated on Mon Sep 26 14:20:11 2005 for Fiasco by  doxygen 1.4.2