]> git.buserror.net Git - polintos/scott/priv.git/blob - kernel/include/kern/orb.h
Use a radix tree for IDRMap.
[polintos/scott/priv.git] / kernel / include / kern / orb.h
1 #ifndef _KERN_ORB_H
2 #define _KERN_ORB_H
3
4 #include <kern/types.h>
5 #include <kern/radix.h>
6 #include <orb.h>
7
8 #include <util/list.h>
9 #include <util/rbtree.h>
10 #include <System/Objects.h>
11
12 namespace Mem {
13         class ProcAddrSpace;
14 };
15
16 namespace Threads {
17         class Thread;
18 };
19
20 namespace ORB {
21         typedef u32 ID;
22
23         struct CallFrame {
24                 // Address Space and PC to return to
25                 Mem::ProcAddrSpace *ret_aspace;
26                 ulong ret_pc;
27                 
28                 // Caller's PIB Pointer
29                 System::RunTime::ParamInfoBlock *caller_user_pib;
30                 
31                 // Object and Method that were called -- it probably isn't strictly
32                 // necessary to keep track of this here, but it'd help in doing a
33                 // "traceforward" of the method invocation stack in order to
34                 // debug a stalled method call.
35                 
36                 ID object, method;
37         };
38         
39         struct CallStackHeader {
40                 Threads::Thread *thread;
41                 Util::List node;
42                 
43                 // Number of CallFrames under this header.
44                 // For a full page, this is:
45                 //   (Arch::page_size - sizeof(CallStackHeader)) / sizeof(CallFrame)
46                 // There is also a much smaller group of call frames in the Thread
47                 // structure, so that an ORB stack page doesn't need to be allocated
48                 // in the common case of shallow method nesting.
49         
50                 int num_frames;
51                 
52                 CallFrame frames[0];
53         };
54         
55         struct ObjectHdr;
56         struct Object;
57         
58         typedef u32 ID;
59         typedef Util::RadixTree<ObjectHdr, ID> IDRMap;
60
61         struct ObjectHdr {
62                 ID id;
63
64                 union {
65                         struct {
66                                 u32 Pointer:1;
67                         };
68                         
69                         u32 flags;
70                 };
71         };
72         
73         struct Object : public ObjectHdr {
74                 Mem::ProcAddrSpace *aspace;
75                 uintptr_t entry;
76         };
77
78         struct ObjectPtr : public ObjectHdr {
79                 Object *object;
80         };
81
82         class IDSpace {
83                 // Reverse mapping of object pointers to local IDs
84                 IDRMap id_rmap;
85         
86         public:
87                 Object *lookup(u32 id);
88                 u32 rlookup(Object *obj);
89         };
90 }
91
92 #endif