Changeset 6843a9c in mainline for uspace/app/msim/arch_helenos/input.c


Ignore:
Timestamp:
2012-06-29T13:02:14Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
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.
Message:

Merge mainline changes

Trivial conflicts.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/app/msim/arch_helenos/input.c

    rba72f2b r6843a9c  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2012 Vojtech Horky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libc
     29/** @addtogroup msim
    3030 * @{
    3131 */
     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>
    3240
    33 /** @file
    34  * Internetwork layer modules messages.
    35  * @see il_remote.h
    36  * @see ip_interface.h
    37  */
     41static tinput_t *input_prompt;
    3842
    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
    7444 *
    7545 */
    76 #define IL_GET_PROTO(call)  ((int) IPC_GET_ARG1(call))
     46void 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}
    7754
    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))
     55void input_inter(void)
     56{
     57}
    8458
    85 /*@}*/
     59void input_shadow( void)
     60{
     61}
    8662
    87 #endif
     63void input_back( void)
     64{
     65}
    8866
    89 /** @}
    90  */
     67char *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
     87bool 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.