Changeset 97c7682 in mainline for uspace/app/msim/arch_helenos/input.c
- Timestamp:
- 2012-07-14T11:18:40Z (12 years ago)
- 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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/msim/arch_helenos/input.c
r0747468 r97c7682 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 libnet29 /** @addtogroup msim 30 30 * @{ 31 31 */ 32 /** @file 33 * General CRC and checksum computation. 32 /** @file HelenOS specific functions for MSIM simulator. 34 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> 35 40 36 #ifndef LIBNET_CHECKSUM_H_ 37 #define LIBNET_CHECKSUM_H_ 41 static tinput_t *input_prompt; 38 42 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 45 44 * 46 45 */ 47 #define IP_CHECKSUM_ZERO 0xffffU 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 } 48 54 49 #ifdef __BE__ 55 void input_inter(void) 56 { 57 } 50 58 51 #define compute_crc32(seed, data, length) \ 52 compute_crc32_be(seed, (uint8_t *) data, length) 59 void input_shadow( void) 60 { 61 } 53 62 54 #endif 63 void input_back( void) 64 { 65 } 55 66 56 #ifdef __LE__ 67 char *helenos_input_get_next_command(void) 68 { 69 tinput_set_prompt(input_prompt, "[msim] "); 57 70 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); 60 73 61 #endif 74 if (rc == ENOENT) { 75 rc = asprintf(&commline, "quit"); 76 mprintf("Quit\n"); 77 if (rc != EOK) { 78 exit(1); 79 } 80 } 62 81 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 } 69 85 70 #endif71 86 72 /** @} 73 */ 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.