]> git.buserror.net Git - polintos/scott/priv.git/blobdiff - kernel/include/kern/orb.h
random kernel stuff
[polintos/scott/priv.git] / kernel / include / kern / orb.h
index 7618dc72e725d0b138cb079f1a5ee32b14334d3a..f90d0512f3ee0c9355edd5a402d0611c5dd08196 100644 (file)
@@ -2,13 +2,18 @@
 #define _KERN_ORB_H
 
 #include <kern/types.h>
+#include <kern/radix.h>
 #include <orb.h>
 
 #include <util/list.h>
+#include <util/rbtree.h>
+#include <util/radix.h>
+#include <util/bmaptree.h>
+
 #include <System/Objects.h>
 
 namespace Mem {
-       class AddrSpace;
+       class ProcAddrSpace;
 };
 
 namespace Threads {
@@ -16,11 +21,11 @@ namespace Threads {
 };
 
 namespace ORB {
-       typedef ulong ID;
+       typedef u32 ID;
 
        struct CallFrame {
                // Address Space and PC to return to
-               Mem::AddrSpace *ret_aspace;
+               Mem::ProcAddrSpace *ret_aspace;
                ulong ret_pc;
                
                // Caller's PIB Pointer
@@ -49,6 +54,53 @@ namespace ORB {
                
                CallFrame frames[0];
        };
+       
+       struct ObjectHdr;
+       struct Object;
+       typedef u32 ID;
+
+       struct ObjectHdr {
+               ID id;
+
+               union {
+                       struct {
+                               u32 Pointer:1;
+                       };
+                       
+                       u32 flags;
+               };
+       };
+       
+       struct Object : public ObjectHdr {
+               Mem::ProcAddrSpace *aspace;
+               uintptr_t entry;
+       };
+
+       struct ObjectPtr : public ObjectHdr {
+               Object *object;
+       };
+       
+       union ObjTableEntry {
+               ObjectHdr hdr;
+               Object obj;
+               ObjectPtr ptr;
+       };
+
+       typedef Util::RadixTree<ObjTableEntry, ID, 6> IDTable;
+       typedef Util::RadixTree<ObjectHdr *, ID, 4> IDRMap;
+       typedef Util::BitmapTree<ID> IDAlloc;
+
+       class IDSpace {
+               // Reverse mapping of object pointers to local IDs
+               IDTable table;
+               IDRMap rmap;
+               IDAlloc alloc;
+       
+       public:
+               Object *lookup(u32 id);
+               ObjectHdr *get_local_hdr(Object *obj);
+               Object *newobj(Mem::ProcAddrSpace *aspace, uintptr_t entry);
+       };
 }
 
 #endif