]> git.buserror.net Git - polintos/scott/priv.git/blobdiff - kernel/tests/orb.cc
update
[polintos/scott/priv.git] / kernel / tests / orb.cc
diff --git a/kernel/tests/orb.cc b/kernel/tests/orb.cc
new file mode 100644 (file)
index 0000000..68e0dfc
--- /dev/null
@@ -0,0 +1,44 @@
+// ORB test
+//
+// This software is copyright (c) 2007 Scott Wood <scott@buserror.net>.
+// 
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors or contributors be held liable for any damages
+// arising from the use of this software.
+// 
+// Permission is hereby granted to everyone, free of charge, to use, copy,
+// modify, prepare derivative works of, publish, distribute, perform,
+// sublicense, and/or sell copies of the Software, provided that the above
+// copyright notice and disclaimer of warranty be included in all copies or
+// substantial portions of this software.
+
+#include <kern/types.h>
+#include <kern/libc.h>
+#include <kern/thread.h>
+#include <kern/mem.h>
+#include <kern/orb.h>
+#include <kern/process.h>
+
+extern "C" void arch_new_user_thread(void *, void *);
+extern u32 test_user_ptr;
+using namespace Threads;
+using namespace Mem;
+
+void run_test()
+{
+       Thread *t = sched.new_thread(arch_new_user_thread, (void *)test_user_ptr,
+                                    (void *)(Arch::stack_top + 1), "thread");
+
+       Object obj;
+       proc_addr_space_factory.create(&obj);
+       IAddrSpace aspace = IAddrSpace::downcast(obj);
+       
+       printf("aspace %p created\n", (void *)aspace);
+       
+       ProcAddrSpace *kaspace = static_cast<ProcAddrSpace *>(AddrSpace::classptr(aspace));
+       
+       printf("kaspace %p\n", kaspace);
+
+       t->set_aspace(kaspace);
+       t->wake();
+}