]> rtime.felk.cvut.cz Git - l4.git/blobdiff - kernel/fiasco/src/kern/ia32/32/thread-ia32-32.cpp
update
[l4.git] / kernel / fiasco / src / kern / ia32 / 32 / thread-ia32-32.cpp
index 058e0fc7214ee1ce1f67e9490a566736ac7b6d30..c75ccba54763e9d8d428dbb49d6d83888ef01667 100644 (file)
@@ -1,8 +1,8 @@
 IMPLEMENTATION[ia32 || ux]:
 
-PRIVATE inline
+PROTECTED inline
 void FIASCO_NORETURN
-Thread::fast_return_to_user(Mword ip, Mword sp, bool = true)
+Thread::fast_return_to_user(Mword ip, Mword sp)
 {
   assert_kdb(cpu_lock.test());
   assert_kdb(current() == this);
@@ -19,7 +19,7 @@ Thread::fast_return_to_user(Mword ip, Mword sp, bool = true)
 }
 
 IMPLEMENT inline
-Mword 
+Mword
 Thread::user_sp() const
 { return regs()->sp(); }
 
@@ -28,7 +28,7 @@ void
 Thread::user_sp(Mword sp)
 { regs()->sp(sp); }
 
-PRIVATE inline
+PROTECTED inline
 int
 Thread::do_trigger_exception(Entry_frame *r, void *ret_handler)
 {
@@ -61,22 +61,6 @@ Thread::restore_exc_state()
 #endif
 }
 
-IMPLEMENTATION[(ia32 || ux) && segments]:
-
-PRIVATE static inline
-void
-Thread::copy_utcb_to_ts_reset_segments(Thread *rcv)
-{ rcv->_gs = rcv->_fs = 0; }
-
-IMPLEMENTATION[(ia32 || ux) && !segments]:
-
-PRIVATE static inline
-void
-Thread::copy_utcb_to_ts_reset_segments(Thread *)
-{}
-
-IMPLEMENTATION[ia32 || ux]:
-
 PRIVATE static inline
 Return_frame *
 Thread::trap_state_to_rf(Trap_state *ts)
@@ -85,8 +69,7 @@ Thread::trap_state_to_rf(Trap_state *ts)
   return reinterpret_cast<Return_frame*>(im)-1;
 }
 
-PRIVATE static inline NEEDS[Thread::copy_utcb_to_ts_reset_segments,
-                            Thread::trap_is_privileged,
+PRIVATE static inline NEEDS[Thread::trap_is_privileged,
                            Thread::trap_state_to_rf]
 bool FIASCO_WARN_RESULT
 Thread::copy_utcb_to_ts(L4_msg_tag const &tag, Thread *snd, Thread *rcv,
@@ -102,7 +85,7 @@ Thread::copy_utcb_to_ts(L4_msg_tag const &tag, Thread *snd, Thread *rcv,
   if (EXPECT_FALSE(rcv->exception_triggered()))
     {
       // triggered exception pending
-      Mem::memcpy_mwords (&ts->_gs, snd_utcb->values, s > 12 ? 12 : s);
+      Mem::memcpy_mwords(&ts->_gs, snd_utcb->values, s > 12 ? 12 : s);
       if (EXPECT_TRUE(s > 15))
        {
          Continuation::User_return_frame const *s
@@ -114,7 +97,8 @@ Thread::copy_utcb_to_ts(L4_msg_tag const &tag, Thread *snd, Thread *rcv,
   else
     Mem::memcpy_mwords (&ts->_gs, snd_utcb->values, s > 16 ? 16 : s);
 
-  copy_utcb_to_ts_reset_segments(rcv);
+  // reset segments
+  rcv->_gs = rcv->_fs = 0;
 
   if (tag.transfer_fpu() && (rights & L4_fpage::W))
     snd->transfer_fpu(rcv);
@@ -168,7 +152,7 @@ IMPLEMENTATION [ia32 && !ux]:
 IMPLEMENT inline NEEDS[Thread::exception_triggered]
 void
 Thread::user_ip(Mword ip)
-{ 
+{
   if (exception_triggered())
     _exc_cont.ip(ip);
   else
@@ -178,57 +162,57 @@ Thread::user_ip(Mword ip)
 
 PRIVATE inline
 int
-Thread::check_trap13_kernel (Trap_state *ts)
+Thread::check_trap13_kernel(Trap_state *ts)
 {
-  if (EXPECT_FALSE (ts->_trapno == 13 && (ts->_err & 3) == 0))
+  if (EXPECT_FALSE(ts->_trapno == 13 && (ts->_err & 3) == 0))
     {
       // First check if user loaded a segment register with 0 because the
       // resulting exception #13 can be raised from user _and_ kernel. If
       // the user tried to load another segment selector, the thread gets
       // killed.
       // XXX Should we emulate this too? Michael Hohmuth: Yes, we should.
-      if (EXPECT_FALSE (!(ts->_ds & 0xffff)))
+      if (EXPECT_FALSE(!(ts->_ds & 0xffff)))
        {
-         Cpu::set_ds (Gdt::data_segment ());
+         Cpu::set_ds(Gdt::data_segment());
          return 0;
        }
-      if (EXPECT_FALSE (!(ts->_es & 0xffff)))
+      if (EXPECT_FALSE(!(ts->_es & 0xffff)))
        {
-         Cpu::set_es (Gdt::data_segment ());
+         Cpu::set_es(Gdt::data_segment());
          return 0;
        }
-      if (EXPECT_FALSE (!(ts->_fs & 0xffff)))
+      if (EXPECT_FALSE(!(ts->_fs & 0xffff)))
        {
          ts->_fs = Utcb_init::utcb_segment();
          return 0;
        }
-      if (EXPECT_FALSE (!(ts->_gs & 0xffff)))
+      if (EXPECT_FALSE(!(ts->_gs & 0xffff)))
        {
          ts->_gs = Utcb_init::utcb_segment();
          return 0;
        }
-      if (EXPECT_FALSE (ts->_ds & 0xfff8) == Gdt::gdt_code_user)
+      if (EXPECT_FALSE(ts->_ds & 0xfff8) == Gdt::gdt_code_user)
        {
          WARN("%p eip=%08lx: code selector ds=%04lx",
                this, ts->ip(), ts->_ds & 0xffff);
-         Cpu::set_ds (Gdt::data_segment ());
+         Cpu::set_ds(Gdt::data_segment());
          return 0;
        }
-      if (EXPECT_FALSE (ts->_ds & 0xfff8) == Gdt::gdt_code_user)
+      if (EXPECT_FALSE(ts->_es & 0xfff8) == Gdt::gdt_code_user)
        {
          WARN("%p eip=%08lx: code selector es=%04lx",
                this, ts->ip(), ts->_es & 0xffff);
-         Cpu::set_es (Gdt::data_segment ());
+         Cpu::set_es(Gdt::data_segment());
          return 0;
        }
-      if (EXPECT_FALSE (ts->_ds & 0xfff8) == Gdt::gdt_code_user)
+      if (EXPECT_FALSE(ts->_fs & 0xfff8) == Gdt::gdt_code_user)
        {
          WARN("%p eip=%08lx: code selector fs=%04lx",
                this, ts->ip(), ts->_fs & 0xffff);
          ts->_fs = Utcb_init::utcb_segment();
          return 0;
        }
-      if (EXPECT_FALSE (ts->_ds & 0xfff8) == Gdt::gdt_code_user)
+      if (EXPECT_FALSE(ts->_gs & 0xfff8) == Gdt::gdt_code_user)
        {
          WARN("%p eip=%08lx: code selector gs=%04lx",
                this, ts->ip(), ts->_gs & 0xffff);
@@ -268,12 +252,12 @@ Thread::user_invoke()
 }
 
 //---------------------------------------------------------------------------
-IMPLEMENTATION [ia32 & segments]:
+IMPLEMENTATION [ia32]:
 
 #include <feature.h>
 KIP_KERNEL_FEATURE("segments");
 
-PRIVATE inline
+PROTECTED inline
 bool
 Thread::invoke_arch(L4_msg_tag &tag, Utcb *utcb)
 {
@@ -314,17 +298,6 @@ Thread::invoke_arch(L4_msg_tag &tag, Utcb *utcb)
     };
 }
 
-//---------------------------------------------------------------------------
-IMPLEMENTATION [ia32 && !segments]:
-
-PRIVATE inline
-bool
-Thread::invoke_arch(L4_msg_tag &tag, Utcb *utcb)
-{
-  (void)tag; (void)utcb;
-  return false; // not our business
-}
-
 //---------------------------------------------------------------------------
 IMPLEMENTATION [ia32 & (debug | kdb)]:
 
@@ -348,9 +321,8 @@ Thread::call_nested_trap_handler(Trap_state *ts)
   unsigned long &ntr = nested_trap_recover.cpu(log_cpu);
 
 #if 0
-  printf("%s: lcpu%u sp=%p t=%u nested_trap_recover=%ld\n",
-      __func__, log_cpu, (void*)Proc::stack_pointer(), ts->_trapno,
-      ntr);
+  printf("%s: lcpu%u sp=%p t=%lu nested_trap_recover=%ld\n",
+         __func__, log_cpu, (void*)Proc::stack_pointer(), ts->_trapno, ntr);
 #endif
 
   int ret;
@@ -360,7 +332,7 @@ Thread::call_nested_trap_handler(Trap_state *ts)
   struct
   {
     Mword pdir;
-    int (*handler)(Trap_state*, unsigned int);
+    FIASCO_FASTCALL int (*handler)(Trap_state*, unsigned);
     void *stack;
   } p;
 
@@ -410,4 +382,3 @@ Thread::call_nested_trap_handler(Trap_state *ts)
 
   return ret == 0 ? 0 : -1;
 }
-