]> rtime.felk.cvut.cz Git - l4.git/blobdiff - kernel/fiasco/src/kern/factory.cpp
update
[l4.git] / kernel / fiasco / src / kern / factory.cpp
index 3647fc1dfebc4d7b58423de734aa38ad8791eca8..a6fbb740382508a312c24c4fbefb3e0378f1d83a 100644 (file)
@@ -3,7 +3,7 @@ INTERFACE:
 #include "ram_quota.h"
 #include "kobject_helper.h"
 
-class Factory : public Ram_quota, public Kobject_h<Factory>, public Kobject
+class Factory : public Ram_quota, public Kobject_h<Factory>
 {
   FIASCO_DECLARE_KOBJ();
 
@@ -17,7 +17,7 @@ IMPLEMENTATION:
 #include "ipc_gate.h"
 #include "kmem_slab.h"
 #include "task.h"
-#include "thread.h"
+#include "thread_object.h"
 #include "static_init.h"
 #include "l4_buf_iter.h"
 #include "l4_types.h"
@@ -40,15 +40,13 @@ Factory::Factory(Ram_quota *q, unsigned long max)
   : Ram_quota(q, max)
 {}
 
-PRIVATE static inline NOEXPORT NEEDS["kmem_slab.h"]
+
+static Kmem_slab_t<Factory> _factory_allocator("Factory");
+
+PRIVATE static
 Factory::Self_alloc *
 Factory::allocator()
-{
-  static Self_alloc* slabs =
-    new Kmem_slab_simple (sizeof (Factory), sizeof (Mword), "Factory");
-
-  return slabs;
-}
+{ return &_factory_allocator; }
 
 PUBLIC static inline
 Factory *
@@ -101,11 +99,10 @@ Factory::map_obj(Kobject_iface *o, Mword cap, Space *c_space,
   if (!map(o, o_space, c_space, cap, rl.list()))
     {
       delete o;
-      // FIXME: reap stuff if needed
       return commit_result(-L4_err::ENomem);
     }
 
-  // FIXME: reap stuff if needed
+  // return a tag with one typed item for the returned capability
   return commit_result(0, 0, 1);
 }
 
@@ -133,7 +130,7 @@ Factory::new_task(Utcb const *u)
   if (!new_t)
     return 0;
 
-  if (new_t->state() != Task::Ready || !new_t->initialize())
+  if (!new_t->valid() || !new_t->initialize())
     {
       delete new_t;
       return 0;
@@ -146,7 +143,7 @@ PRIVATE inline NOEXPORT
 Kobject_iface *
 Factory::new_thread(Utcb const *)
 {
-  Thread *t = new (this) Thread();
+  Thread_object *t = new (this) Thread_object();
   return t;
 }
 
@@ -164,7 +161,7 @@ Factory::new_gate(L4_msg_tag const &tag, Utcb const *utcb, Obj_space *o_space)
        return reinterpret_cast<Kobject_iface*>(-L4_err::EInval);
 
       unsigned char thread_rights = 0;
-      thread = Kobject::dcast<Thread*>(o_space->lookup_local(bind_thread.obj_index(), &thread_rights));
+      thread = Kobject::dcast<Thread_object*>(o_space->lookup_local(bind_thread.obj_index(), &thread_rights));
 
       if (EXPECT_FALSE(!(thread_rights & L4_fpage::W)))
        return reinterpret_cast<Kobject_iface*>(-L4_err::EPerm);
@@ -187,13 +184,14 @@ Factory::new_semaphore(Utcb const *)
 
 PRIVATE inline NOEXPORT
 Kobject_iface *
-Factory::new_irq(Utcb const *)
+Factory::new_irq(unsigned w, Utcb const *utcb)
 {
-  Irq *i = Irq::allocate(this);
-  return i;
+  if (w >= 3 && utcb->values[2])
+    return Irq::allocate<Irq_muxer>(this);
+  else
+    return Irq::allocate<Irq_sender>(this);
 }
 
-
 PUBLIC
 L4_msg_tag
 Factory::kinvoke(L4_obj_ref ref, Mword rights, Syscall_frame *f,
@@ -255,7 +253,7 @@ Factory::kinvoke(L4_obj_ref ref, Mword rights, Syscall_frame *f,
       break;
 
     case L4_msg_tag::Label_irq:
-      new_o = new_irq(utcb);
+      new_o = new_irq(f->tag().words(), utcb);
       break;
 
     case L4_msg_tag::Label_vm:
@@ -270,7 +268,7 @@ Factory::kinvoke(L4_obj_ref ref, Mword rights, Syscall_frame *f,
     Log_entry *le = tbe->payload<Log_entry>();
     le->op = utcb->values[0];
     le->buffer = buffer.obj_index();
-    le->id = dbg_id();
+    le->id = dbg_info()->dbg_id();
     le->ram = current();
     le->newo = new_o ? new_o->dbg_info()->dbg_id() : ~0);
 
@@ -280,20 +278,20 @@ Factory::kinvoke(L4_obj_ref ref, Mword rights, Syscall_frame *f,
 
 
 //----------------------------------------------------------------------------
-IMPLEMENTATION [svm]:
+IMPLEMENTATION [svm || vmx]:
 
-#include "vm.h"
+#include "vm_factory.h"
 
 PRIVATE inline NOEXPORT
 Kobject_iface *
 Factory::new_vm(Utcb const *)
 {
-  Vm *new_t = Vm::create(this);
+  Vm *new_t = Vm_factory::create(this);
 
   if (!new_t)
     return 0;
 
-  if (new_t->state() != Task::Ready || !new_t->initialize())
+  if (!new_t->valid() || !new_t->initialize())
     {
       delete new_t;
       return 0;
@@ -314,7 +312,7 @@ Factory::new_vm(Utcb const *)
 }
 
 //----------------------------------------------------------------------------
-IMPLEMENTATION [!svm && !tz]:
+IMPLEMENTATION [!svm && !tz && !vmx]:
 
 PRIVATE inline NOEXPORT
 Kobject_iface *