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 "../../state.h" 14#include "../dispatch.h" 15#include "screen_dspace.h" 16#include "stdio_dspace.h" 17#include <refos/refos.h> 18 19/*! @file 20 @brief Timer dataspace interface functions. 21 22 This module implements a subset of the dataspace interface (<refos-rpc/data_server.h>), 23 for screen devices. The common dataspace dispatcher module delegates calls to us if it has 24 decided that the recieved message is a timer dataspace call. 25 26 This is a thin layer basically wrapping the device_screen module, which has the concrete 27 implementations. 28*/ 29 30 31seL4_CPtr 32screen_open_handler(void *rpc_userptr , char* rpc_name , int rpc_flags , int rpc_mode , 33 int rpc_size , int* rpc_errno) 34{ 35 /* Return the serial dataspace badged EP. */ 36 assert(conServ.screenBadgeEP); 37 if (conServ.devScreen.initialised) { 38 SET_ERRNO_PTR(rpc_errno, ESUCCESS); 39 return conServ.screenBadgeEP; 40 } 41 SET_ERRNO_PTR(rpc_errno, EFILENOTFOUND); 42 return 0; 43} 44 45int 46screen_write_handler(void *rpc_userptr , seL4_CPtr rpc_dspace_fd , uint32_t rpc_offset , 47 rpc_buffer_t rpc_buf , uint32_t rpc_count) 48{ 49 assert(rpc_dspace_fd == CONSERV_DSPACE_BADGE_SCREEN); 50 if (!conServ.devScreen.initialised) { 51 ROS_WARNING("Screen dataspace recieved but no screen available."); 52 return -1; 53 } 54 device_screen_write(&conServ.devScreen, (char*) rpc_buf.data, (int) rpc_buf.count); 55 return rpc_buf.count; 56} 57 58int 59screen_getc_handler(void *rpc_userptr , seL4_CPtr rpc_dspace_fd , int rpc_block) 60{ 61 return serial_getc_handler(rpc_userptr, rpc_dspace_fd, rpc_block); 62} 63 64refos_err_t 65screen_putc_handler(void *rpc_userptr , seL4_CPtr rpc_dspace_fd , int rpc_c) 66{ 67 assert(rpc_dspace_fd == CONSERV_DSPACE_BADGE_SCREEN); 68 if (!conServ.devScreen.initialised) { 69 ROS_WARNING("Screen dataspace recieved but no screen available."); 70 return -1; 71 } 72 char c = (char) rpc_c; 73 device_screen_write(&conServ.devScreen, &c, 1); 74 return ESUCCESS; 75}