Suppose you want to sent a structure of userspace to the Kernel through servers.
1. Define your structure in a .h file that can be imported both from the user-space and kernel
2. Define your own message . A structure for the server and one for the kernel in ipc.h
Example:
typedef struct {
vir_bytes ctx; /* mcontext_t * */
uint8_t padding[52];
} mess_lc_pm_mcontext;
_ASSERT_MSG_SIZE(mess_lc_pm_mcontext);
typedef struct {
endpoint_t endpt;
vir_bytes ctx_ptr;
uint8_t padding[48];
} mess_lsys_krn_sys_getmcontext;
_ASSERT_MSG_SIZE(mess_lsys_krn_sys_getmcontext);
3. Your user space function will take as a parameter of type pointer
Example:
int function_test_newstruct(mystruct * var){
....
}
4. The function that is the bridge between the server and the kernel must take two parameters.
Example:
int sys_mcehandler(endpoint_t proc,vir_bytes vars)
{
....
}
5. In the Kernel, Use this function to make the copy.
int data_copy(endpoint_t from, vir_bytes from_addr, endpoint_t to, vir_bytes to_addr, size_t bytes);
Note: The same principle is used to copy data from the Kernel to user space through the servers.