]> rtime.felk.cvut.cz Git - l4.git/blobdiff - kernel/fiasco/src/kern/ux/task-ux.cpp
update
[l4.git] / kernel / fiasco / src / kern / ux / task-ux.cpp
index 46f5f2eec9dbd75e1f7f7ef2a01be3175ae62bb3..b78d35032f0b65562ab195b81e812db1df910563 100644 (file)
@@ -11,10 +11,8 @@ IMPLEMENTATION [ux]:
 
 IMPLEMENT
 void
-Task::host_init()
-{
-  mem_space()->set_pid (Hostproc::create());
-}
+Task::ux_init()
+{ set_pid(Hostproc::create()); }
 
 PRIVATE inline
 bool
@@ -39,8 +37,7 @@ Task::invoke_arch(L4_msg_tag &tag, Utcb *utcb)
 
           unsigned entry_number  = utcb->values[1];
           unsigned idx           = 2;
-          Mword *trampoline_page = (Mword *)Kmem::phys_to_virt
-                                       (Mem_layout::Trampoline_frame);
+          Mword *trampoline_page = (Mword *)Kmem::kernel_trampoline_page;
 
           for (; idx < tag.words()
               ; idx += Utcb_values_per_ldt_entry,
@@ -88,58 +85,20 @@ Task::invoke_arch(L4_msg_tag &tag, Utcb *utcb)
   return false;
 }
 
-/** Map tracebuffer into each userland task for easy access. */
-IMPLEMENT
-void
-Task::map_tbuf ()
-{
-  return; // FIXME
-#if 0
-  if (id() != Config::sigma0_taskno)
-    {
-      mem_map (sigma0_task, 
-         L4_fpage(0, 1, Config::PAGE_SHIFT, 
-           Kmem::virt_to_phys ((const void*)(Mem_layout::Tbuf_status_page))),
-         nonull_static_cast<Space*>(this),    // to: space
-         L4_fpage(0, 0, Config::PAGE_SHIFT,
-           Mem_layout::Tbuf_ustatus_page, L4_fpage::Cached), 0);
-
-      for (Address size=0; size<Jdb_tbuf::size(); size+=Config::PAGE_SIZE)
-       {
-         mem_map (sigma0_task,                            // from: space
-             L4_fpage(0, 1, Config::PAGE_SHIFT,
-               Kmem::virt_to_phys ((const void*)
-                 (Mem_layout::Tbuf_buffer_area+size))),
-             nonull_static_cast<Space*>(this),    // to: space
-             L4_fpage(0, 0, Config::PAGE_SHIFT, 
-               Mem_layout::Tbuf_ubuffer_area+size, L4_fpage::Cached), 0);
-       }
-    }
-#endif
-}
-
-IMPLEMENT
+PUBLIC
 Task::~Task()
 {
-  free_utcbs();
-  //_state = Dying;
-  //unregister_space();
-  //shutdown();
-  //dequeue_at_parent();
-
-#if 0
-  if (id() == Config::kernel_taskno)
-    {
-      reset_dirty();           // Must not deallocate kernel pagetable.
-      return;                  // No need to kill kernel process.
-    }
-#endif
+  free_ku_mem();
 
-  Lock_guard<Cpu_lock> guard (&cpu_lock);
+  auto guard = lock_guard(cpu_lock);
 
   pid_t hostpid = pid();
   ptrace (PTRACE_KILL, hostpid, NULL, NULL);
 
+  // If we crash very early in the boot process we might get a pid of 0
+  if (EXPECT_FALSE(hostpid == 0))
+    return;
+
   while (waitpid (hostpid, NULL, 0) != hostpid)
     ;
 }
@@ -150,7 +109,7 @@ void
 Task::map_utcb_ptr_page()
 {
   //Mem_space::Status res =
-       mem_space()->v_insert(
+       static_cast<Mem_space*>(this)->v_insert(
            Mem_space::Phys_addr::create(Mem_layout::Utcb_ptr_frame),
            Mem_space::Addr::create(Mem_layout::Utcb_ptr_page_user),
            Mem_space::Size::create(Config::PAGE_SIZE),