Remote Procedure Calls
API to create remote procedure call services and to call them.
Function-like Macros
interface_cast(type, service)
This macro performs conditional typecasting of service type to another service type. Type cast will only be performed if both services implement the same interface type (which means that both services contain vtable member and both these vtable members are of the same type). If service types don’t match the typecast won’t be made, most probably leading to a compilation warning that pointer types don’t match.
type resulting service type
service pointer to service
- type resulting service type
- service pointer to service
rpc_call(service_instance, method_name, ...)
Calls service published by different thread and/or process. Service can take 0 to 4 arguments, which are passed down to it. Return value of service is passed back to the caller. Services are represented by structures allocated in service provider thread. These structures have to contain pointer to their virtual method table as their first member. Virtual method table is then queried for presence of method name used to perform the call. If such method exists, then arguments used to perform the call are checked against method prototype.
service_instance address of service instance, which is being called
method_name name of method within service, which has to be called whatever value service returned
- service_instance address of service instance, which is being called
- method_name name of method within service, which has to be called
Returns whatever value service returned
int _rpc_call(unsigned arg0, unsigned arg1, unsigned arg2, unsigned arg3, void *service, unsigned method, unsigned canary)
This function is actually called when user calles rpc_call()
- service address of service instance
- method offset of method in VMT of service
- arg0 1st argument to the RPC call
- arg1 2nd argument to the RPC call
- arg2 3rd argument to the RPC call
- arg3 4th argument to the RPC call
- canary canary value passed to the call
void rpc_return(void)
Used automatically.
Kernel uses this to return from RPC. It is hooked into RPC call chain automatically, no need to call it manually from RPC method. It is sufficient to return from RPC to call this.
Macros
IMPLEMENTATION(service)
Use of this macro starts implementation of methods for certain service. It enables use of the this
service name of type which describes the service whose methods are being implemented
- service name of type which describes the service whose methods are being implemented
IMPLEMENTATION_OF(service, interface)
Use of this macro starts implementation of methods for certain service. It enables use of the this
service type of structure, which holds instances of service
interface type describing virtual method table of the implemented interface
- service type of structure, which holds instances of service
- interface type describing virtual method table of the implemented interface
INSTANCE(a)
Syntactic sugar to make argument type-compatible with interface declaration. This allows to work with any specific type of service inside its implementation and use of such specialized implementations to initialize generic interface. As a matter of fact, the only allowed argument of this macro is thisDue to the API of RPC calls, you HAVE
this
this