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