]> git.buserror.net Git - polintos/scott/priv.git/blob - kernel/orb/invoke.cc
b2e5de80bb05d3a9304dd158e95529abe64ac915
[polintos/scott/priv.git] / kernel / orb / invoke.cc
1 // orb/invoke.cc -- Method Invocation
2 //
3 // This software is copyright (c) 2006 Scott Wood <scott@buserror.net>.
4 // 
5 // This software is provided 'as-is', without any express or implied warranty.
6 // In no event will the authors or contributors be held liable for any damages
7 // arising from the use of this software.
8 // 
9 // Permission is hereby granted to everyone, free of charge, to use, copy,
10 // modify, prepare derivative works of, publish, distribute, perform,
11 // sublicense, and/or sell copies of the Software, provided that the above
12 // copyright notice and disclaimer of warranty be included in all copies or
13 // substantial portions of this software.
14
15 #include <kern/types.h>
16 #include <kern/orb.h>
17 #include <kern/pagealloc.h>
18 #include <kern/compiler.h>
19 #include <arch/usercopy.h>
20 #include <orb.h>
21
22 using System::RunTime::ParamInfoBlock;
23 using namespace ORB;
24 using Threads::Thread;
25
26 namespace ORB {
27         static CallFrame *new_frame(Thread *thread)
28         {
29                 CallStackHeader *hdr = thread->orbstack_top_hdr;
30                 
31                 if (unlikely(thread->orbstack_top == hdr->num_frames - 1)) {
32                         hdr = static_cast<CallStackHeader *>(Mem::alloc_pages(1));
33                         new(hdr) CallStackHeader;
34                         hdr->thread = thread;
35                         hdr->num_frames = (Arch::page_size - sizeof(CallStackHeader)) /
36                                           sizeof(CallFrame);
37
38                         thread->orbstack_top_hdr->node.add_front(&hdr->node);
39                         thread->orbstack_top_hdr = hdr;
40                         thread->orbstack_top = 0;
41                         return &hdr->frames[0];
42                 }
43                 
44                 return &hdr->frames[thread->orbstack_top += 1];
45         }
46 }
47
48 extern "C" void invoke_method(ulong objid, ulong methid,
49                               ParamInfoBlock *user_pib, ulong ret_pc)
50 {
51         ParamInfoBlock pib = Arch::copyin(user_pib);
52         CallFrame *frame = new_frame(curthread);
53         
54         frame->object = objid;
55         frame->method = methid;
56         frame->caller_user_pib = user_pib;
57         frame->ret_pc = ret_pc;
58         
59         printf("invoke_method: frame %p object %lx method %lx pib %p ret %lx\n",
60                frame, frame->object, frame->method, frame->caller_user_pib,
61                frame->ret_pc);
62         
63         
64 }