00001
00002
00003 #ifndef entry_frame_h
00004 #define entry_frame_h
00005
00006 #include "l4_types.h"
00007
00008 #include "types.h"
00009
00010
00011
00012
00013
00014
00022 class Syscall_frame
00023 {private:
00024
00025 protected:
00026 Mword ecx;
00027 Mword edx;
00028 Mword esi;
00029 Mword edi;
00030 Mword ebx;
00031 Mword ebp;
00032 Mword eax;
00033 };
00034
00035 class Return_frame
00036 {
00037 public:
00038 Mword ip() const;
00039 void ip(Mword _pc);
00040
00041 Mword sp() const;
00042 void sp(Mword _sp);
00043 private:
00044
00045 private:
00046 Mword eip;
00047 Unsigned16 csseg, __csu;
00048 Mword eflags;
00049 Mword esp;
00050 Unsigned16 ssseg, __ssu;
00051
00052 public:
00053 inline Mword flags() const;
00054
00055 inline void flags(Mword _flags);
00056
00057 inline Mword cs() const;
00058
00059 inline void cs(Mword _cs);
00060
00061 inline Mword ss() const;
00062
00063 inline void ss(Mword _ss);
00064 };
00065
00073 class Entry_frame : public Syscall_frame, public Return_frame
00074 {};
00075
00079 class Sys_ipc_frame : public Syscall_frame
00080 {
00081 public:
00083 Mword msg_word (Utcb *dst, unsigned index) const;
00084
00086 void set_msg_word (Utcb *u, unsigned index, Mword value);
00087
00090 void set_msg_word (unsigned index, Mword value);
00091
00093 void rcv_src( L4_uid id );
00094
00096 L4_uid rcv_src() const;
00097
00099 L4_uid snd_dst() const;
00100
00102 Mword has_snd_dst() const;
00103
00105 Mword has_snd() const;
00106
00108 Mword irq() const;
00109
00111 L4_timeout timeout() const;
00112
00114 static unsigned num_snd_reg_words();
00115
00117 static unsigned num_rcv_reg_words();
00118
00120 Mword has_abs_snd_timeout() const;
00121
00123 Mword abs_snd_clock() const;
00124
00126 Mword has_abs_rcv_timeout() const;
00127
00129 Mword abs_rcv_clock() const;
00130
00132 void snd_desc(Mword w);
00133
00135 L4_snd_desc snd_desc() const;
00136
00138 void copy_msg(Sys_ipc_frame *to) const;
00139
00141 void rcv_desc(L4_rcv_desc d);
00142
00144 L4_rcv_desc rcv_desc() const;
00145
00147 Mword msg_word(unsigned index) const;
00148
00150 L4_msgdope msg_dope() const;
00151
00153 void msg_dope(L4_msgdope d);
00154
00156 void msg_dope_set_error(Mword);
00157
00159 void msg_dope_combine(Ipc_err e);
00160
00162 static unsigned num_reg_words();
00163 };
00164
00168 class Sys_id_nearest_frame : public Syscall_frame
00169 {
00170 public:
00172 L4_uid dst() const;
00173
00175 void type( Mword type );
00176
00178 void nearest( L4_uid id );
00179 };
00180
00184 class Sys_ex_regs_frame : public Syscall_frame
00185 {
00186 public:
00188 Mword sp() const;
00189
00191 Mword ip() const;
00192
00194 L4_uid pager() const;
00195
00197 void old_eflags( Mword oefl );
00198
00200 void old_sp( Mword osp );
00201
00203 void old_ip( Mword oip );
00204
00206 void old_pager( L4_uid id );
00207
00209 LThread_num lthread() const;
00210
00212 Task_num task() const;
00213
00215 Mword no_cancel() const;
00216
00218 L4_uid preempter() const;
00219
00221 void old_preempter(L4_uid id);
00222
00223 Mword alien() const;
00224 };
00225
00229 class Sys_thread_switch_frame : public Syscall_frame
00230 {
00231 public:
00233 L4_uid dst() const;
00234
00236 Mword id() const;
00237
00239 void left (Unsigned64 t);
00240
00242 void ret (Mword val);
00243 };
00244
00248 class Sys_unmap_frame : public Syscall_frame
00249 {
00250 public:
00252 bool self_unmap() const;
00253
00255 L4_fpage fpage() const;
00256
00258 Mword map_mask() const;
00259
00261 bool downgrade() const;
00262 };
00263
00267 class Sys_task_new_frame : public Syscall_frame
00268 {
00269 public:
00271 Mword mcp() const;
00272
00274 L4_uid new_chief() const;
00275
00277 Mword sp() const;
00278
00280 Mword ip() const;
00281
00283 Mword has_pager() const;
00284
00286 L4_uid pager() const;
00287
00289 L4_uid dst() const;
00290
00292 void new_taskid( L4_uid id );
00293
00294 Mword alien() const;
00295 };
00296
00300 class Sys_thread_schedule_frame : public Syscall_frame
00301 {
00302 public:
00304 L4_sched_param param() const;
00305
00307 Unsigned64 time() const;
00308
00310 L4_uid preempter() const;
00311
00313 L4_uid dst() const;
00314
00316 void old_param(L4_sched_param op);
00317
00319 void time(Unsigned64 t);
00320
00322 void old_preempter(L4_uid id);
00323
00325 void partner(L4_uid id);
00326 };
00327
00331 class Sys_thread_privctrl_frame : public Syscall_frame
00332 {
00333 public:
00334 Mword command() const;
00335 L4_uid dst() const;
00336 Mword entry_func() const;
00337 void ret_val(Mword v);
00338 };
00339
00340 extern "C" void Entry_frame_Syscall_frame_cast_problem();
00341
00342
00343
00344
00345
00346
00347 template< typename Cl > inline Cl *sys_frame_cast( Entry_frame *e );
00348
00349
00350
00351
00352
00353
00354
00355
00356 inline Mword
00357 Return_frame::flags() const
00358 { return eflags; }
00359
00360
00361
00362 inline void
00363 Return_frame::flags(Mword _flags)
00364 { eflags = _flags; }
00365
00366
00367
00368 inline Mword
00369 Return_frame::cs() const
00370 { return csseg; }
00371
00372
00373
00374 inline void
00375 Return_frame::cs(Mword _cs)
00376 { csseg = _cs; }
00377
00378
00379
00380 inline Mword
00381 Return_frame::ss() const
00382 { return ssseg; }
00383
00384
00385
00386 inline void
00387 Return_frame::ss(Mword _ss)
00388 { ssseg = _ss; }
00389
00390
00391
00392
00393
00394
00395 inline Address
00396 Return_frame::ip() const
00397 { return eip; }
00398
00399
00400
00401 inline void
00402 Return_frame::ip(Mword _pc)
00403 { eip = _pc; }
00404
00405
00406
00407 inline Address
00408 Return_frame::sp() const
00409 { return esp; }
00410
00411
00412
00413 inline void
00414 Return_frame::sp(Mword _sp)
00415 { esp = _sp; }
00416
00417
00418
00419 inline Mword Sys_ipc_frame::msg_word(Utcb*, unsigned index) const
00420 {
00421 return msg_word (index);
00422 }
00423
00424
00425
00426
00427
00428
00429 inline Mword Sys_ipc_frame::has_snd_dst() const
00430 {
00431 return esi;
00432 }
00433
00434
00435
00436 inline Mword Sys_ipc_frame::irq() const
00437 {
00438 return esi -1;
00439 }
00440
00441
00442
00443 inline void Sys_ipc_frame::snd_desc(Mword w)
00444 {
00445 eax =w;
00446 }
00447
00448
00449
00450 inline L4_snd_desc Sys_ipc_frame::snd_desc() const
00451 {
00452 return eax;
00453 }
00454
00455
00456
00457 inline Mword Sys_ipc_frame::has_snd() const
00458 {
00459 return snd_desc().has_snd();
00460 }
00461
00462
00463
00464 inline L4_timeout Sys_ipc_frame::timeout() const
00465 {
00466 return L4_timeout(ecx);
00467 }
00468
00469
00470
00471 inline L4_rcv_desc Sys_ipc_frame::rcv_desc() const
00472 {
00473 return ebp;
00474 }
00475
00476
00477
00478 inline void Sys_ipc_frame::rcv_desc(L4_rcv_desc d)
00479 {
00480 ebp = d.raw();
00481 }
00482
00483
00484
00485 inline L4_msgdope Sys_ipc_frame::msg_dope() const
00486 {
00487 return L4_msgdope(eax);
00488 }
00489
00490
00491
00492 inline void Sys_ipc_frame::msg_dope_set_error(Mword e)
00493 {
00494 reinterpret_cast<L4_msgdope&>(eax).error(e);
00495 }
00496
00497
00498
00499 inline unsigned Sys_ipc_frame::num_snd_reg_words()
00500 {
00501 return num_reg_words();
00502 }
00503
00504
00505
00506 inline unsigned Sys_ipc_frame::num_rcv_reg_words()
00507 {
00508 return num_reg_words();
00509 }
00510
00511
00512
00513 inline void Sys_ipc_frame::msg_dope(L4_msgdope d)
00514 {
00515 eax = d.raw();
00516 }
00517
00518
00519
00520 inline void Sys_ipc_frame::msg_dope_combine(Ipc_err e)
00521 {
00522 L4_msgdope m(eax);
00523 m.combine(e);
00524 eax = m.raw();
00525 }
00526
00527
00528
00529 inline void Sys_ipc_frame::rcv_src(L4_uid id)
00530 {
00531 esi = id.raw();
00532 edi = (id.raw() >> 32);
00533 }
00534
00535
00536
00537 inline L4_uid Sys_ipc_frame::rcv_src() const
00538 {
00539 return L4_uid(((Unsigned64)edi << 32) | (Unsigned64)esi);
00540 }
00541
00542
00543
00544 inline L4_uid Sys_ipc_frame::snd_dst() const
00545 {
00546 return L4_uid( (Unsigned64)esi | ((Unsigned64)edi << 32) );
00547 }
00548
00549
00550
00551 inline Mword Sys_ipc_frame::msg_word(unsigned index) const
00552 {
00553 switch(index)
00554 {
00555 case 0:
00556 return edx;
00557 case 1:
00558 return ebx;
00559 default:
00560 return 0;
00561 }
00562 }
00563
00564
00565
00566 inline void Sys_ipc_frame::set_msg_word(unsigned index, Mword value)
00567 {
00568 switch(index)
00569 {
00570 case 0:
00571 edx = value;
00572 break;
00573 case 1:
00574 ebx = value;
00575 break;
00576 default:
00577 break;
00578 }
00579 }
00580
00581
00582
00583 inline unsigned Sys_ipc_frame::num_reg_words()
00584 {
00585 return 2;
00586 }
00587
00588
00589
00590 inline void Sys_ipc_frame::copy_msg(Sys_ipc_frame *to) const
00591 {
00592
00593 Unsigned32 tmp_edx = edx, tmp_ebx = ebx;
00594 to->edx = tmp_edx;
00595 to->ebx = tmp_ebx;
00596 }
00597
00598
00599
00600 inline Mword Sys_ipc_frame::has_abs_snd_timeout() const
00601 {
00602 return snd_dst().abs_snd_timeout();
00603 }
00604
00605
00606 inline Mword Sys_ipc_frame::abs_snd_clock() const
00607 {
00608 return snd_dst().abs_snd_clock();
00609 }
00610
00611
00612
00613 inline Mword Sys_ipc_frame::has_abs_rcv_timeout() const
00614 {
00615 return snd_dst().abs_rcv_timeout();
00616 }
00617
00618
00619
00620 inline Mword Sys_ipc_frame::abs_rcv_clock() const
00621 {
00622 return snd_dst().abs_rcv_clock();
00623 }
00624
00625
00626
00627
00628
00629
00630 inline void Sys_id_nearest_frame::type(Mword type)
00631 {
00632 eax = type;
00633 }
00634
00635
00636
00637
00638 inline L4_uid Sys_id_nearest_frame::dst() const
00639 {
00640 return L4_uid( (Unsigned64)esi | ((Unsigned64)edi << 32) );
00641 }
00642
00643
00644
00645 inline void Sys_id_nearest_frame::nearest(L4_uid id)
00646 {
00647 esi = id.raw();
00648 edi = (id.raw() >> 32);
00649 }
00650
00651
00652
00653
00654
00655
00656 inline Task_num Sys_ex_regs_frame::lthread() const
00657 {
00658 return eax & (1 << 7) - 1;
00659 }
00660
00661
00662
00663 inline Task_num Sys_ex_regs_frame::task() const
00664 {
00665 return (eax >> 7) & ((1 << 11) - 1);
00666 }
00667
00668
00669
00670 inline Mword Sys_ex_regs_frame::alien() const
00671 {
00672 return eax & (1 << 29);
00673 }
00674
00675
00676
00677 inline Mword Sys_ex_regs_frame::no_cancel() const
00678 {
00679 return eax & (1 << 30);
00680 }
00681
00682
00683
00684 inline Mword Sys_ex_regs_frame::sp() const
00685 {
00686 return ecx;
00687 }
00688
00689
00690
00691 inline Mword Sys_ex_regs_frame::ip() const
00692 {
00693 return edx;
00694 }
00695
00696
00697
00698 inline void Sys_ex_regs_frame::old_eflags(Mword oefl)
00699 {
00700 eax = oefl;
00701 }
00702
00703
00704
00705 inline void Sys_ex_regs_frame::old_sp(Mword osp)
00706 {
00707 ecx = osp;
00708 }
00709
00710
00711
00712 inline void Sys_ex_regs_frame::old_ip(Mword oip)
00713 {
00714 edx = oip;
00715 }
00716
00717
00718
00719
00720 inline L4_uid Sys_ex_regs_frame::preempter() const
00721 {
00722 return L4_uid( (Unsigned64)ebx | ((Unsigned64)ebp << 32) );
00723 }
00724
00725
00726
00727 inline L4_uid Sys_ex_regs_frame::pager() const
00728 {
00729 return L4_uid( (Unsigned64)esi | ((Unsigned64)edi << 32) );
00730 }
00731
00732
00733
00734 inline void Sys_ex_regs_frame::old_preempter(L4_uid id)
00735 {
00736 ebx = id.raw(); ebp = id.raw() >> 32;
00737 }
00738
00739
00740
00741 inline void Sys_ex_regs_frame::old_pager(L4_uid id)
00742 {
00743 esi = id.raw();
00744 edi = id.raw() >> 32;
00745 }
00746
00747
00748
00749
00750
00751
00752 inline Mword
00753 Sys_thread_switch_frame::id() const
00754 {
00755 return eax;
00756 }
00757
00758
00759
00760 inline void
00761 Sys_thread_switch_frame::left(Unsigned64 t)
00762 {
00763 ecx = t;
00764 edx = t >> 32;
00765 }
00766
00767
00768
00769 inline void
00770 Sys_thread_switch_frame::ret(Mword val)
00771 {
00772 eax = val;
00773 }
00774
00775
00776
00777
00778
00779 inline L4_uid
00780 Sys_thread_switch_frame::dst() const
00781 {
00782 return L4_uid ((Unsigned64) esi);
00783 }
00784
00785
00786
00787
00788
00789
00790 inline L4_fpage Sys_unmap_frame::fpage() const
00791 {
00792 return L4_fpage(eax);
00793 }
00794
00795
00796
00797 inline Mword Sys_unmap_frame::map_mask() const
00798 {
00799 return ecx;
00800 }
00801
00802
00803
00804 inline bool Sys_unmap_frame::downgrade() const
00805 {
00806 return !(ecx & 2);
00807 }
00808
00809
00810
00811 inline bool Sys_unmap_frame::self_unmap() const
00812 {
00813 return ecx & 0x80000000;
00814 }
00815
00816
00817
00818
00819
00820
00821 inline Mword Sys_task_new_frame::alien() const
00822 {
00823 return eax & (1 << 31);
00824 }
00825
00826
00827
00828 inline Mword Sys_task_new_frame::mcp() const
00829 {
00830 return eax & ~(1 << 31);
00831 }
00832
00833
00834
00835 inline Mword Sys_task_new_frame::sp() const
00836 {
00837 return ecx;
00838 }
00839
00840
00841
00842 inline Mword Sys_task_new_frame::ip() const
00843 {
00844 return edx;
00845 }
00846
00847
00848
00849 inline Mword Sys_task_new_frame::has_pager() const
00850 {
00851 return ebx;
00852 }
00853
00854
00855
00856
00857 inline L4_uid Sys_task_new_frame::new_chief() const
00858 {
00859 return L4_uid( (Unsigned64)(eax & ~(1 << 31)));
00860 }
00861
00862
00863
00864 inline L4_uid Sys_task_new_frame::pager() const
00865 {
00866 return L4_uid( (Unsigned64)ebx | ((Unsigned64)ebp << 32) );
00867 }
00868
00869
00870
00871 inline L4_uid Sys_task_new_frame::dst() const
00872 {
00873 return L4_uid( (Unsigned64)esi | ((Unsigned64)edi << 32) );
00874 }
00875
00876
00877
00878 inline void Sys_task_new_frame::new_taskid(L4_uid id)
00879 {
00880 esi = id.raw();
00881 edi = id.raw() >> 32;
00882 }
00883
00884
00885
00886
00887
00888
00889 inline L4_sched_param
00890 Sys_thread_schedule_frame::param() const
00891 {
00892 return L4_sched_param (eax);
00893 }
00894
00895
00896
00897 inline void
00898 Sys_thread_schedule_frame::old_param(L4_sched_param op)
00899 {
00900 eax = op.raw();
00901 }
00902
00903
00904
00905 inline Unsigned64
00906 Sys_thread_schedule_frame::time() const
00907 {
00908 return (Unsigned64) edx << 32 | (Unsigned64) ecx;
00909 }
00910
00911
00912
00913 inline void
00914 Sys_thread_schedule_frame::time(Unsigned64 t)
00915 {
00916 ecx = t;
00917 edx = t >> 32;
00918 }
00919
00920
00921
00922
00923 inline L4_uid
00924 Sys_thread_schedule_frame::preempter() const
00925 {
00926 return L4_uid ((Unsigned64) ebx | (Unsigned64) ebp << 32);
00927 }
00928
00929
00930
00931 inline L4_uid
00932 Sys_thread_schedule_frame::dst() const
00933 {
00934 return L4_uid ((Unsigned64) esi | (Unsigned64) edi << 32);
00935 }
00936
00937
00938
00939 inline void
00940 Sys_thread_schedule_frame::old_preempter(L4_uid id)
00941 {
00942 ebx = id.raw();
00943 ebp = id.raw() >> 32;
00944 }
00945
00946
00947
00948 inline void
00949 Sys_thread_schedule_frame::partner(L4_uid id)
00950 {
00951 esi = id.raw();
00952 edi = id.raw() >> 32;
00953 }
00954
00955
00956
00957 template< typename Cl > inline Cl *sys_frame_cast( Entry_frame *e )
00958 {
00959 Cl *r = nonull_static_cast<Cl*>(nonull_static_cast<Syscall_frame*>(e));
00960 if(((void*)e) != ((void*)r))
00961 Entry_frame_Syscall_frame_cast_problem();
00962 return r;
00963 }
00964
00965 #endif // entry_frame_h