Remote Procedure Calls
Type Definitons
typedef struct RPC_Service_t_ RPC_Service_t
typedef int(* RPC_Method_t) (RPC_Service_t *service, unsigned arg0, unsigned arg1, unsigned arg2, unsigned arg3)
Any function that wants to implement a RPC call has to have this signature. If function won’t have use for any of arg0arg1arg2arg3service
service Address of RPC object which was used to perform this RPC call. Works like self` variable in Python.
arg0 optional argument to RPC call. Can only be of integral 32-bit large type
arg1 optional argument to RPC call. Can only be of integral 32-bit large type
arg2 optional argument to RPC call. Can only be of integral 32-bit large type
arg3 optional argument to RPC call. Can only be of integral 32-bit large type
- service Address of RPC object which was used to perform this RPC call. Works like self` variable in Python.
- arg0 optional argument to RPC call. Can only be of integral 32-bit large type
- arg1 optional argument to RPC call. Can only be of integral 32-bit large type
- arg2 optional argument to RPC call. Can only be of integral 32-bit large type
- arg3 optional argument to RPC call. Can only be of integral 32-bit large type
typedef RPC_Method_t* VTable_t
VTable is technically just an array of pointers to functions. To make things more user friendly, in real world cases, VTables are usually a structures whose members are pointers to functions. The memory layout of both cases is the same but structures allows for named members.
Functions
get_vtable_process(VTable_t *vtable)
This function will find the process which defined this vtable.
vtable address of the vtable retrieved from the RPC object. process ID of the owning process or E_VTABLE_UNKNOWN
- vtable address of the vtable retrieved from the RPC object.
Returns process ID of the owning process or E_VTABLE_UNKNOWN
bool rpc_stack_push(Process_t process_id)
Registers new process ID in thread’s stack of RPC call owning processes. This stack records which process is “owning” this thread while RPC call is in effect. While RPC call can technically perform another RPC call, this is a stack rather than plain field. New member is always added on top of the stack unless stack is full.
process_id ID of the process owning the RPC method true if process was added, false if stack is already full
- process_id ID of the process owning the RPC method
Returns true if process was added, false if stack is already full
int rpc_stack_pop()
Removes the most recently added entry from thread’s stack of RPC call owning processes. Will do nothing if stack is already empty. new depth of the stack. Returns 0 if stack is empty.
rpc_stack_top()
Returns the process ID of the most recently added entry in thread’s stack of RPC call owning processes. Most recently added process_ID or E_VTABLE_UNKNOWN
int os_rpc_call(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint32_t arg3)
This routine performs remote procedure call. It digs for 5th and 6th argument passed to _rpc_call()_rpc_call()
- method called will be able to access the first four arguments given to the rpc_call()
- when method returns, the os_rpc_return()
- to the calling code and process. method called will be able to access the first four arguments given to the rpc_call()when method returns, the os_rpc_return()to the calling code and process.
int os_rpc_return(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint32_t arg3)
This routine unwinds stack frame used to call RPC method and passes return value from RPC to the caller.
This syscall has to return the control back to the code which called rpc_call
Macros
E_VTABLE_UNKNOWN
Constant denoting that the VTable pointer is not valid.