Changeset 6843a9c in mainline for uspace/app/msim/arch_helenos/input.c
- Timestamp:
- 2012-06-29T13:02:14Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 722912e
- Parents:
- ba72f2b (diff), 0bbd13e (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/app/msim/arch_helenos/input.c
rba72f2b r6843a9c 1 1 /* 2 * Copyright (c) 20 09 Lukas Mejdrech2 * Copyright (c) 2012 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libc29 /** @addtogroup msim 30 30 * @{ 31 31 */ 32 /** @file HelenOS specific functions for MSIM simulator. 33 */ 34 #include "../../io/input.h" 35 #include "../../io/output.h" 36 #include "../../fault.h" 37 #include "helenos.h" 38 #include <tinput.h> 39 #include <errno.h> 32 40 33 /** @file 34 * Internetwork layer modules messages. 35 * @see il_remote.h 36 * @see ip_interface.h 37 */ 41 static tinput_t *input_prompt; 38 42 39 #ifndef LIBC_IL_MESSAGES_H_ 40 #define LIBC_IL_MESSAGES_H_ 41 42 #include <ipc/net.h> 43 44 /** Internet layer modules messages. */ 45 typedef enum { 46 /** Device state changed message. 47 * @see il_device_state_msg() 48 */ 49 NET_IL_DEVICE_STATE = NET_IL_FIRST, 50 51 /** Device MTU changed message. 52 * @see il_mtu_changed_msg() 53 */ 54 NET_IL_MTU_CHANGED, 55 56 /** 57 * Device address changed message 58 * @see il_addr_changed_msg() 59 */ 60 NET_IL_ADDR_CHANGED, 61 62 /** Packet received message. 63 * @see il_received_msg() 64 */ 65 NET_IL_RECEIVED 66 } il_messages; 67 68 /** @name Internetwork layer specific message parameters definitions */ 69 /*@{*/ 70 71 /** Return the protocol number message parameter. 72 * 73 * @param[in] call Message call structure. 43 /** Terminal and readline initialization 74 44 * 75 45 */ 76 #define IL_GET_PROTO(call) ((int) IPC_GET_ARG1(call)) 46 void input_init(void) 47 { 48 input_prompt = tinput_new(); 49 if (input_prompt == NULL) { 50 die(1, "Failed to intialize input."); 51 } 52 helenos_dprinter_init(); 53 } 77 54 78 /** Return the registering service message parameter. 79 * 80 * @param[in] call Message call structure. 81 * 82 */ 83 #define IL_GET_SERVICE(call) ((services_t) IPC_GET_ARG2(call)) 55 void input_inter(void) 56 { 57 } 84 58 85 /*@}*/ 59 void input_shadow( void) 60 { 61 } 86 62 87 #endif 63 void input_back( void) 64 { 65 } 88 66 89 /** @} 90 */ 67 char *helenos_input_get_next_command(void) 68 { 69 tinput_set_prompt(input_prompt, "[msim] "); 70 71 char *commline = NULL; 72 int rc = tinput_read(input_prompt, &commline); 73 74 if (rc == ENOENT) { 75 rc = asprintf(&commline, "quit"); 76 mprintf("Quit\n"); 77 if (rc != EOK) { 78 exit(1); 79 } 80 } 81 82 /* On error, it remains NULL. */ 83 return commline; 84 } 85 86 87 bool stdin_poll(char *key) 88 { 89 kbd_event_t ev; 90 suseconds_t timeout = 0; 91 errno = EOK; 92 console_flush(input_prompt->console); 93 bool has_input = console_get_kbd_event_timeout(input_prompt->console, &ev, &timeout); 94 if (!has_input) { 95 return false; 96 } 97 98 if (ev.type != KEY_PRESS) 99 return false; 100 101 *key = ev.c; 102 103 return true; 104 } 105
Note:
See TracChangeset
for help on using the changeset viewer.