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