1/* 2 * Copyright 2016, Data61 3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO) 4 * ABN 41 687 119 230. 5 * 6 * This software may be distributed and modified according to the terms of 7 * the BSD 2-Clause license. Note that NO WARRANTY is provided. 8 * See "LICENSE_BSD2.txt" for details. 9 * 10 * @TAG(D61_BSD) 11 */ 12 13#include "dispatch.h" 14#include "serv_dispatch.h" 15#include "../badge.h" 16#include "../state.h" 17#include <refos/error.h> 18#include <refos-rpc/serv_server.h> 19#include <refos-rpc/proc_client.h> 20#include <refos-rpc/proc_client_helper.h> 21 22/*! @file 23 @brief Handles server connection and session establishment syscalls. 24 25 This file contains the handlers for serv interface syscalls. It should implement the 26 declarations in the generated <refos-rpc/serv_server.h>. 27*/ 28 29seL4_CPtr 30serv_connect_direct_handler(void *rpc_userptr , seL4_CPtr rpc_liveness , int* rpc_errno) 31{ 32 struct srv_client *anonc = (struct srv_client *) rpc_userptr; 33 srv_msg_t *m = (srv_msg_t *) anonc->rpcClient.userptr; 34 assert(anonc->magic == CONSERV_DISPATCH_ANON_CLIENT_MAGIC); 35 struct srv_client *c = conServCommon->ctable_connect_direct_handler( 36 conServCommon, m, rpc_liveness, rpc_errno); 37 return c ? c->session : (seL4_CPtr) 0; 38} 39 40refos_err_t 41serv_ping_handler(void *rpc_userptr) 42{ 43 dprintf(COLOUR_Y "CONSOLE SERVER RECIEVED PING!!! HI THERE! (���_���)" COLOUR_RESET "\n"); 44 return ESUCCESS; 45} 46 47refos_err_t 48serv_set_param_buffer_handler(void *rpc_userptr , seL4_CPtr rpc_parambuffer_dataspace , 49 uint32_t rpc_parambuffer_size) 50{ 51 struct srv_client *c = (struct srv_client *) rpc_userptr; 52 srv_msg_t *m = (srv_msg_t *) c->rpcClient.userptr; 53 assert(c->magic == CONSERV_CLIENT_MAGIC); 54 return conServCommon->ctable_set_param_buffer_handler(conServCommon, c, m, 55 rpc_parambuffer_dataspace, rpc_parambuffer_size); 56} 57 58void 59serv_disconnect_direct_handler(void *rpc_userptr) 60{ 61 struct srv_client *c = (struct srv_client *) rpc_userptr; 62 assert(c->magic == CONSERV_CLIENT_MAGIC); 63 dprintf("Console server disconnecting client cID = %d. Bye! (D:)\n", c->cID); 64 return conServCommon->ctable_disconnect_direct_handler(conServCommon, c); 65} 66 67int 68check_dispatch_serv(srv_msg_t *m, void **userptr) 69{ 70 int label = seL4_GetMR(0); 71 if (label == RPC_SERV_CONNECT_DIRECT && m->badge != 0) { 72 return DISPATCH_PASS; 73 } 74 return check_dispatch_interface(m, userptr, RPC_SERV_LABEL_MIN, RPC_SERV_LABEL_MAX); 75}