1 // orb/invoke.cc -- Method Invocation
3 // This software is copyright (c) 2006 Scott Wood <scott@buserror.net>.
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.
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.
15 #include <kern/types.h>
17 #include <kern/pagealloc.h>
18 #include <kern/compiler.h>
19 #include <kern/thread.h>
21 #include <arch/usercopy.h>
25 using System::RunTime::ParamInfoBlock;
27 using Threads::Thread;
30 static CallFrame *new_frame(Thread *thread)
32 CallStackHeader *hdr = thread->orbstack_top_hdr;
34 if (unlikely(thread->orbstack_top == hdr->num_frames - 1)) {
35 hdr = static_cast<CallStackHeader *>(Mem::alloc_pages(1));
36 new(hdr) CallStackHeader;
38 hdr->num_frames = (Arch::page_size - sizeof(CallStackHeader)) /
41 thread->orbstack_top_hdr->node.add_front(&hdr->node);
42 thread->orbstack_top_hdr = hdr;
43 thread->orbstack_top = 0;
44 return &hdr->frames[0];
47 return &hdr->frames[++thread->orbstack_top];
50 ObjectHdr *IDSpace::get_local_hdr(Object *obj)
52 ObjectHdr *hdr = idrmap.lookup(obj->id);
61 extern "C" void invoke_method(u32 objid, u32 methid, ParamInfoBlock *user_pib,
64 ParamInfoBlock pib = Arch::copyin(user_pib);
65 CallFrame *frame = new_frame(curthread);
67 frame->object = objid;
68 frame->method = methid;
69 frame->caller_user_pib = user_pib;
70 frame->ret_pc = ret_pc;
72 printf("invoke_method: frame %p object %x method %x pib %p ret %lx\n",
73 frame, frame->object, frame->method, frame->caller_user_pib,