]> git.buserror.net Git - polintos/scott/priv.git/blob - kernel/orb/invoke.cc
Switch to a simple X11-style license.
[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 // Permission is hereby granted, free of charge, to any person obtaining a copy of
6 // this software and associated documentation files (the "Software"), to deal with
7 // the Software without restriction, including without limitation the rights to
8 // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9 // of the Software, and to permit persons to whom the Software is furnished to do
10 // so, subject to the following condition:
11 // 
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
14 // 
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
18 // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
21 // SOFTWARE.
22
23 #include <kern/types.h>
24 #include <kern/orb.h>
25 #include <kern/pagealloc.h>
26 #include <kern/compiler.h>
27 #include <arch/usercopy.h>
28 #include <orb.h>
29
30 using System::RunTime::ParamInfoBlock;
31 using namespace ORB;
32 using Threads::Thread;
33
34 namespace ORB {
35         static CallFrame *new_frame(Thread *thread)
36         {
37                 CallStackHeader *hdr = thread->orbstack_top_hdr;
38                 
39                 if (unlikely(thread->orbstack_top == hdr->num_frames - 1)) {
40                         hdr = static_cast<CallStackHeader *>(Mem::alloc_pages(1));
41                         new(hdr) CallStackHeader;
42                         hdr->thread = thread;
43                         hdr->num_frames = (Arch::page_size - sizeof(CallStackHeader)) /
44                                           sizeof(CallFrame);
45
46                         thread->orbstack_top_hdr->node.add_front(&hdr->node);
47                         thread->orbstack_top_hdr = hdr;
48                         thread->orbstack_top = 0;
49                         return &hdr->frames[0];
50                 }
51                 
52                 return &hdr->frames[thread->orbstack_top += 1];
53         }
54 }
55
56 extern "C" void invoke_method(ulong objid, ulong methid,
57                               ParamInfoBlock *user_pib, ulong ret_pc)
58 {
59         ParamInfoBlock pib = Arch::copyin(user_pib);
60         CallFrame *frame = new_frame(curthread);
61         
62         frame->object = objid;
63         frame->method = methid;
64         frame->caller_user_pib = user_pib;
65         frame->ret_pc = ret_pc;
66         
67         printf("invoke_method: frame %p object %lx method %lx pib %p ret %lx\n",
68                frame, frame->object, frame->method, frame->caller_user_pib,
69                frame->ret_pc);
70         
71         
72 }