Changeset 72d120e in mainline for uspace/lib/drv/generic/remote_led_dev.c
- Timestamp:
- 2014-06-16T20:17:44Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5a78e4e
- Parents:
- 9d653e3 (diff), 334bf28 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_led_dev.c
r9d653e3 r72d120e 1 1 /* 2 * Copyright (c) 201 2 Vojtech Horky2 * Copyright (c) 2014 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup msim29 /** @addtogroup libdrv 30 30 * @{ 31 31 */ 32 /** @file HelenOS specific functions for MSIM simulator.32 /** @file 33 33 */ 34 34 35 /* Because of asprintf. */ 36 #define _GNU_SOURCE 37 #include "../../io/input.h" 38 #include "../../io/output.h" 39 #include "../../fault.h" 40 #include "helenos.h" 41 #include <tinput.h> 35 #include <async.h> 42 36 #include <errno.h> 43 #include <stdlib.h> 37 #include <io/pixel.h> 38 #include <macros.h> 39 #include <device/led_dev.h> 40 #include <ops/led_dev.h> 41 #include <ddf/driver.h> 44 42 45 static tinput_t *input_prompt; 43 static void remote_led_color_set(ddf_fun_t *, void *, ipc_callid_t, 44 ipc_call_t *); 46 45 47 /** Terminal and readline initialization 46 /** Remote LED interface operations */ 47 static const remote_iface_func_ptr_t remote_led_dev_iface_ops[] = { 48 [LED_DEV_COLOR_SET] = remote_led_color_set 49 }; 50 51 /** Remote LED interface structure 52 * 53 * Interface for processing requests from remote clients 54 * addressed by the LED interface. 48 55 * 49 56 */ 50 void input_init(void) 57 const remote_iface_t remote_led_dev_iface = { 58 .method_count = ARRAY_SIZE(remote_led_dev_iface_ops), 59 .methods = remote_led_dev_iface_ops 60 }; 61 62 /** Process the color_set() request from the remote client 63 * 64 * @param fun The function to which the data are written 65 * @param ops The local ops structure 66 * 67 */ 68 static void remote_led_color_set(ddf_fun_t *fun, void *ops, ipc_callid_t callid, 69 ipc_call_t *call) 51 70 { 52 input_prompt = tinput_new(); 53 if (input_prompt == NULL) { 54 die(1, "Failed to intialize input."); 71 led_dev_ops_t *led_dev_ops = (led_dev_ops_t *) ops; 72 pixel_t color = DEV_IPC_GET_ARG1(*call); 73 74 if (!led_dev_ops->color_set) { 75 async_answer_0(callid, ENOTSUP); 76 return; 55 77 } 56 helenos_dprinter_init(); 78 79 int rc = (*led_dev_ops->color_set)(fun, color); 80 async_answer_0(callid, rc); 57 81 } 58 82 59 void input_inter(void) 60 { 61 } 62 63 void input_shadow( void) 64 { 65 } 66 67 void input_back( void) 68 { 69 } 70 71 char *helenos_input_get_next_command(void) 72 { 73 tinput_set_prompt(input_prompt, "[msim] "); 74 75 char *commline = NULL; 76 int rc = tinput_read(input_prompt, &commline); 77 78 if (rc == ENOENT) { 79 rc = asprintf(&commline, "quit"); 80 mprintf("Quit\n"); 81 if (rc != EOK) { 82 exit(1); 83 } 84 } 85 86 /* On error, it remains NULL. */ 87 return commline; 88 } 89 90 91 bool stdin_poll(char *key) 92 { 93 cons_event_t ev; 94 suseconds_t timeout = 0; 95 errno = EOK; 96 console_flush(input_prompt->console); 97 bool has_input = console_get_event_timeout(input_prompt->console, &ev, &timeout); 98 if (!has_input) { 99 return false; 100 } 101 102 if (ev.type != CEV_KEY || ev.ev.key.type != KEY_PRESS) 103 return false; 104 105 *key = ev.ev.key.c; 106 107 return true; 108 } 109 83 /** 84 * @} 85 */
Note:
See TracChangeset
for help on using the changeset viewer.