Changeset 97c7682 in mainline for uspace/app/msim/arch_helenos/input.c


Ignore:
Timestamp:
2012-07-14T11:18:40Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
804d9b6
Parents:
0747468 (diff), f0348c8 (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.

Text conflict in boot/arch/arm32/Makefile.inc:

Trivial conflict around ifeq condition.

Text conflict in kernel/arch/arm32/include/mm/page.h:

Added defines and set_pt_levelx_present function.
COnflict looked horrible because of the armv4/v7 split.

File:
1 moved

Legend:

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

    r0747468 r97c7682  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2012 Vojtech Horky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libnet
     29/** @addtogroup msim
    3030 * @{
    3131 */
    32 /** @file
    33  * General CRC and checksum computation.
     32/** @file HelenOS specific functions for MSIM simulator.
    3433 */
     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>
    3540
    36 #ifndef LIBNET_CHECKSUM_H_
    37 #define LIBNET_CHECKSUM_H_
     41static tinput_t *input_prompt;
    3842
    39 #include <byteorder.h>
    40 #include <sys/types.h>
    41 
    42 /** IP checksum value for computed zero checksum.
    43  *
    44  * Zero is returned as 0xFFFF (not flipped)
     43/** Terminal and readline initialization
    4544 *
    4645 */
    47 #define IP_CHECKSUM_ZERO  0xffffU
     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}
    4854
    49 #ifdef __BE__
     55void input_inter(void)
     56{
     57}
    5058
    51 #define compute_crc32(seed, data, length) \
    52         compute_crc32_be(seed, (uint8_t *) data, length)
     59void input_shadow( void)
     60{
     61}
    5362
    54 #endif
     63void input_back( void)
     64{
     65}
    5566
    56 #ifdef __LE__
     67char *helenos_input_get_next_command(void)
     68{
     69        tinput_set_prompt(input_prompt, "[msim] ");
    5770
    58 #define compute_crc32(seed, data, length) \
    59         compute_crc32_le(seed, (uint8_t *) data, length)
     71        char *commline = NULL;
     72        int rc = tinput_read(input_prompt, &commline);
    6073
    61 #endif
     74        if (rc == ENOENT) {
     75                rc = asprintf(&commline, "quit");
     76                mprintf("Quit\n");
     77                if (rc != EOK) {
     78                        exit(1);
     79                }
     80        }
    6281
    63 extern uint32_t compute_crc32_le(uint32_t, uint8_t *, size_t);
    64 extern uint32_t compute_crc32_be(uint32_t, uint8_t *, size_t);
    65 extern uint32_t compute_checksum(uint32_t, uint8_t *, size_t);
    66 extern uint16_t compact_checksum(uint32_t);
    67 extern uint16_t flip_checksum(uint16_t);
    68 extern uint16_t ip_checksum(uint8_t *, size_t);
     82        /* On error, it remains NULL. */
     83        return commline;
     84}
    6985
    70 #endif
    7186
    72 /** @}
    73  */
     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.