]> rtime.felk.cvut.cz Git - l4.git/blobdiff - kernel/fiasco/src/kern/factory.cpp
update
[l4.git] / kernel / fiasco / src / kern / factory.cpp
index 4261cae76a711aa0ee249388647c27604e6ac391..2ff5451efffd0db398d3fbec3735b905f12262a2 100644 (file)
@@ -75,7 +75,7 @@ PUBLIC
 void Factory::operator delete (void *_f)
 {
   Factory *f = (Factory*)_f;
-  LOG_TRACE("Factory delete", "fa del", ::current(), 0, {});
+  LOG_TRACE("Factory delete", "fa del", ::current(), Tb_entry_empty, {});
 
   if (!f->parent())
     return;
@@ -89,7 +89,7 @@ void Factory::operator delete (void *_f)
 
 PRIVATE
 L4_msg_tag
-Factory::map_obj(Kobject_iface *o, Mword cap, Space *c_space,
+Factory::map_obj(Kobject_iface *o, Cap_index cap, Space *c_space,
                  Obj_space *o_space)
 {
   Reap_list rl;
@@ -149,11 +149,11 @@ Factory::new_gate(L4_msg_tag const &tag, Utcb const *utcb, Obj_space *o_space,
       if (EXPECT_FALSE(!bind_thread.is_objpage()))
        return 0;
 
-      unsigned char thread_rights = 0;
+      L4_fpage::Rights thread_rights = L4_fpage::Rights(0);
       thread = Kobject::dcast<Thread_object*>(o_space->lookup_local(bind_thread.obj_index(), &thread_rights));
 
       *err = L4_err::EPerm;
-      if (EXPECT_FALSE(!(thread_rights & L4_fpage::W)))
+      if (EXPECT_FALSE(!(thread_rights & L4_fpage::Rights::W())))
        return 0;
     }
 #if 0
@@ -177,7 +177,7 @@ Factory::new_irq(unsigned w, Utcb const *utcb, int *)
 
 PUBLIC
 L4_msg_tag
-Factory::kinvoke(L4_obj_ref ref, Mword rights, Syscall_frame *f,
+Factory::kinvoke(L4_obj_ref ref, L4_fpage::Rights rights, Syscall_frame *f,
                  Utcb const *utcb, Utcb *)
 {
   register Context *const c_thread = ::current();
@@ -186,7 +186,7 @@ Factory::kinvoke(L4_obj_ref ref, Mword rights, Syscall_frame *f,
   if (EXPECT_FALSE(f->tag().proto() != L4_msg_tag::Label_factory))
     return commit_result(-L4_err::EBadproto);
 
-  if (EXPECT_FALSE(!(rights & L4_fpage::W)))
+  if (EXPECT_FALSE(!(rights & L4_fpage::Rights::CS())))
     return commit_result(-L4_err::EPerm);
 
   if (EXPECT_FALSE(!ref.have_recv()))
@@ -218,7 +218,7 @@ Factory::kinvoke(L4_obj_ref ref, Mword rights, Syscall_frame *f,
   // We take the existence_lock for syncronizing maps...
   // This is kind of coarse grained
   // try_lock fails if the lock is neither locked nor unlocked
-  if (!space_lock_guard.try_lock(&c_space->existence_lock))
+  if (!space_lock_guard.check_and_lock(&c_space->existence_lock))
     return commit_error(utcb, L4_error(L4_error::Overflow, L4_error::Rcv));
 
   Lock_guard<Cpu_lock, Lock_guard_inverse_policy> cpu_lock_guard(&cpu_lock);
@@ -253,13 +253,12 @@ Factory::kinvoke(L4_obj_ref ref, Mword rights, Syscall_frame *f,
       return commit_result(-L4_err::ENodev);
     }
 
-  LOG_TRACE("Kobject create", "new", ::current(), __factory_log_fmt,
-    Log_entry *le = tbe->payload<Log_entry>();
-    le->op = utcb->values[0];
-    le->buffer = buffer.obj_index();
-    le->id = dbg_info()->dbg_id();
-    le->ram = current();
-    le->newo = new_o ? new_o->dbg_info()->dbg_id() : ~0);
+  LOG_TRACE("Kobject create", "new", ::current(), Log_entry,
+    l->op = utcb->values[0];
+    l->buffer = buffer.obj_index();
+    l->id = dbg_info()->dbg_id();
+    l->ram = current();
+    l->newo = new_o ? new_o->dbg_info()->dbg_id() : ~0);
 
   if (new_o)
     return map_obj(new_o, buffer.obj_index(), c_space, c_space);
@@ -270,9 +269,10 @@ Factory::kinvoke(L4_obj_ref ref, Mword rights, Syscall_frame *f,
 
 
 //----------------------------------------------------------------------------
-IMPLEMENTATION [svm || vmx]:
+IMPLEMENTATION [svm || vmx || arm_em_tz]:
 
 #include "vm_factory.h"
+#include "vm.h"
 
 PRIVATE inline NOEXPORT
 Kobject_iface *
@@ -284,20 +284,8 @@ Factory::new_vm(Utcb const *, int *err)
   return 0;
 }
 
-IMPLEMENTATION [tz]:
-
-#include "vm.h"
-
-PRIVATE inline NOEXPORT
-Kobject_iface *
-Factory::new_vm(Utcb const *, int *err)
-{
-  *err = L4_err::ENomem;
-  return Vm::create(this);
-}
-
 //----------------------------------------------------------------------------
-IMPLEMENTATION [!svm && !tz && !vmx]:
+IMPLEMENTATION [!svm && !vmx && !arm_em_tz]:
 
 PRIVATE inline NOEXPORT
 Kobject_iface *
@@ -315,15 +303,15 @@ INTERFACE [debug]:
 EXTENSION class Factory
 {
 private:
-  struct Log_entry
+  struct Log_entry : public Tb_entry
   {
     Smword op;
-    Mword buffer;
+    Cap_index buffer;
     Mword id;
     Mword ram;
     Mword newo;
+    unsigned print(int max, char *buf) const;
   };
-  static unsigned log_fmt(Tb_entry *, int, char *) asm ("__factory_log_fmt");
 };
 
 // ------------------------------------------------------------------------
@@ -331,17 +319,17 @@ IMPLEMENTATION [debug]:
 
 IMPLEMENT
 unsigned
-Factory::log_fmt(Tb_entry *e, int maxlen, char *buf)
+Factory::Log_entry::print(int maxlen, char *buf) const
 {
   static char const *const ops[] =
   { /*   0 */ "gate", "irq", 0, 0, 0, 0, 0, 0,
     /*  -8 */ 0, 0, 0, "task", "thread", 0, 0, "factory",
     /* -16 */ "vm", 0, 0, 0, "sem" }; 
-  Log_entry *le = e->payload<Log_entry>();
-  char const *op = -le->op <= (int)(sizeof(ops)/sizeof(ops[0]))
-    ? ops[-le->op] : "invalid op";
-  if (!op)
-    op = "(nan)";
+  char const *_op = -op <= (int)(sizeof(ops)/sizeof(ops[0]))
+    ? ops[-op] : "invalid op";
+  if (!_op)
+    _op = "(nan)";
 
-  return snprintf(buf, maxlen, "factory=%lx [%s] new=%lx cap=[C:%lx] ram=%lx", le->id, op, le->newo, le->buffer, le->ram);
+  return snprintf(buf, maxlen, "factory=%lx [%s] new=%lx cap=[C:%lx] ram=%lx",
+                  id, _op, newo, cxx::int_value<Cap_index>(buffer), ram);
 }