Changes in / [f0348c8:33fc3ae] in mainline


Ignore:
Files:
3 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • kernel/Makefile

    rf0348c8 r33fc3ae  
    196196        generic/src/console/chardev.c \
    197197        generic/src/console/console.c \
    198         generic/src/console/prompt.c \
    199198        generic/src/cpu/cpu.c \
    200199        generic/src/ddi/ddi.c \
  • kernel/generic/include/debug.h

    rf0348c8 r33fc3ae  
    3737
    3838#include <panic.h>
    39 #include <symtab_lookup.h>
     39#include <symtab.h>
    4040
    4141#define CALLER  ((uintptr_t) __builtin_return_address(0))
  • kernel/generic/include/symtab.h

    rf0348c8 r33fc3ae  
    3636#define KERN_SYMTAB_H_
    3737
    38 #include <symtab_lookup.h>
    39 #include <console/chardev.h>
     38#include <typedefs.h>
    4039
     40#define MAX_SYMBOL_NAME  64
     41
     42struct symtab_entry {
     43        uint64_t address_le;
     44        char symbol_name[MAX_SYMBOL_NAME];
     45};
     46
     47extern int symtab_name_lookup(uintptr_t, const char **, uintptr_t *);
     48extern const char *symtab_fmt_name_lookup(uintptr_t);
     49extern int symtab_addr_lookup(const char *, uintptr_t *);
    4150extern void symtab_print_search(const char *);
    42 extern int symtab_compl(char *, size_t, indev_t *);
     51extern int symtab_compl(char *, size_t);
     52
     53#ifdef CONFIG_SYMTAB
     54
     55/** Symtable linked together by build process
     56 *
     57 */
     58extern struct symtab_entry symbol_table[];
     59
     60#endif /* CONFIG_SYMTAB */
    4361
    4462#endif
  • kernel/generic/src/console/kconsole.c

    rf0348c8 r33fc3ae  
    4343#include <console/chardev.h>
    4444#include <console/cmd.h>
    45 #include <console/prompt.h>
    4645#include <print.h>
    4746#include <panic.h>
     
    202201 *
    203202 */
    204 NO_TRACE static int cmdtab_compl(char *input, size_t size, indev_t * indev)
     203NO_TRACE static int cmdtab_compl(char *input, size_t size)
    205204{
    206205        const char *name = input;
    207206       
    208207        size_t found = 0;
    209         /* Maximum Match Length : Length of longest matching common substring in
    210            case more than one match is found */
    211         size_t max_match_len = size;
    212         size_t max_match_len_tmp = size;
    213         size_t input_len = str_length(input);
    214208        link_t *pos = NULL;
    215209        const char *hint;
    216210        char *output = malloc(MAX_CMDLINE, 0);
    217         size_t hints_to_show = MAX_TAB_HINTS - 1;
    218         size_t total_hints_shown = 0;
    219         bool continue_showing_hints = true;
    220211       
    221212        output[0] = 0;
     
    227218                pos = pos->next;
    228219                found++;
    229         }
    230        
    231         /* If possible completions are more than MAX_TAB_HINTS, ask user whether to display them or not. */
    232         if (found > MAX_TAB_HINTS) {
    233                 printf("\n");
    234                 continue_showing_hints = console_prompt_display_all_hints(indev, found);
    235220        }
    236221       
     
    240225                while (cmdtab_search_one(name, &pos)) {
    241226                        cmd_info_t *hlp = list_get_instance(pos, cmd_info_t, link);
    242 
    243                         if (continue_showing_hints) {
    244                                 printf("%s (%s)\n", hlp->name, hlp->description);
    245                                 --hints_to_show;
    246                                 ++total_hints_shown;
    247 
    248                                 if (hints_to_show == 0 && total_hints_shown != found) { /* Time to ask user to continue */
    249                                         continue_showing_hints = console_prompt_more_hints(indev, &hints_to_show);
    250                                 }
    251                         }
    252 
     227                        printf("%s (%s)\n", hlp->name, hlp->description);
    253228                        pos = pos->next;
    254                         for(max_match_len_tmp = 0; output[max_match_len_tmp] == hlp->name[input_len + max_match_len_tmp]
    255                                         && max_match_len_tmp < max_match_len; ++max_match_len_tmp);
    256                         max_match_len = max_match_len_tmp;
    257                 }
    258                 /* keep only the characters common in all completions */
    259                 output[max_match_len] = 0;
     229                }
    260230        }
    261231       
     
    324294                        if (beg == 0) {
    325295                                /* Command completion */
    326                                 found = cmdtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE), indev);
     296                                found = cmdtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE));
    327297                        } else {
    328298                                /* Symbol completion */
    329                                 found = symtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE), indev);
     299                                found = symtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE));
    330300                        }
    331301                       
    332302                        if (found == 0)
    333303                                continue;
    334 
    335                         /* We have hints, may be many. In case of more than one hint,
    336                            tmp will contain the common prefix. */
     304                       
     305                        if (found > 1) {
     306                                /* No unique hint, list was printed */
     307                                printf("%s> ", prompt);
     308                                printf("%ls", current);
     309                                print_cc('\b', wstr_length(current) - position);
     310                                continue;
     311                        }
     312                       
     313                        /* We have a hint */
     314                       
    337315                        size_t off = 0;
    338316                        size_t i = 0;
     
    342320                                i++;
    343321                        }
    344                        
    345                         if (found > 1) {
    346                                 /* No unique hint, list was printed */
    347                                 printf("%s> ", prompt);
    348                                 printf("%ls", current);
    349                                 position += str_length(tmp);
    350                                 print_cc('\b', wstr_length(current) - position);
    351                                 continue;
    352                         }
    353                        
    354                         /* We have a hint */
    355322                       
    356323                        printf("%ls", current + position);
     
    573540/** Parse command line.
    574541 *
    575  * @param cmdline Command line as read from input device.
     542 * @param cmdline Command line as read from input device. 
    576543 * @param size    Size (in bytes) of the string.
    577544 *
  • kernel/generic/src/debug/symtab.c

    rf0348c8 r33fc3ae  
    4343#include <typedefs.h>
    4444#include <errno.h>
    45 #include <console/prompt.h>
    4645
    4746/** Get name of a symbol that seems most likely to correspond to address.
     
    210209 *
    211210 */
    212 int symtab_compl(char *input, size_t size, indev_t * indev)
     211int symtab_compl(char *input, size_t size)
    213212{
    214213#ifdef CONFIG_SYMTAB
     
    227226        const char *hint;
    228227        char output[MAX_SYMBOL_NAME];
    229         /* Maximum Match Length : Length of longest matching common substring in
    230            case more than one match is found */
    231         size_t max_match_len = size;
    232         size_t max_match_len_tmp = size;
    233         size_t input_len = str_length(input);
    234         char *sym_name;
    235         size_t hints_to_show = MAX_TAB_HINTS - 1;
    236         size_t total_hints_shown = 0;
    237         bool continue_showing_hints = true;
    238228       
    239229        output[0] = 0;
    240 
    241         while ((hint = symtab_search_one(name, &pos))) {
    242                 ++pos;
    243         }
    244 
    245         pos = 0;
    246230       
    247231        while ((hint = symtab_search_one(name, &pos))) {
     
    251235                pos++;
    252236                found++;
    253         }
    254        
    255         /* If possible completions are more than MAX_TAB_HINTS, ask user whether to display them or not. */
    256         if (found > MAX_TAB_HINTS) {
    257                 printf("\n");
    258                 continue_showing_hints = console_prompt_display_all_hints(indev, found);
    259237        }
    260238       
     
    263241                pos = 0;
    264242                while (symtab_search_one(name, &pos)) {
    265                         sym_name = symbol_table[pos].symbol_name;
     243                        printf("%s\n", symbol_table[pos].symbol_name);
    266244                        pos++;
    267 
    268                         if (continue_showing_hints) { /* We are still showing hints */
    269                                 printf("%s\n", sym_name);
    270                                 --hints_to_show;
    271                                 ++total_hints_shown;
    272 
    273                                 if (hints_to_show == 0 && total_hints_shown != found) { /* Time to ask user to continue */
    274                                         continue_showing_hints = console_prompt_more_hints(indev, &hints_to_show);
    275                                 }
    276                         }
    277 
    278                         for(max_match_len_tmp = 0; output[max_match_len_tmp] == sym_name[input_len + max_match_len_tmp]
    279                                         && max_match_len_tmp < max_match_len; ++max_match_len_tmp);
    280                         max_match_len = max_match_len_tmp;
    281245                }
    282                 /* keep only the characters common in all completions */
    283                 output[max_match_len] = 0;
    284246        }
    285247       
  • uspace/app/bdsh/cmds/modules/cat/cat.c

    rf0348c8 r33fc3ae  
    6262static sysarg_t console_rows = 0;
    6363static bool should_quit = false;
    64 static bool dash_represents_stdin = false;
    6564
    6665static console_ctrl_t *console = NULL;
     
    7473        { "more", no_argument, 0, 'm' },
    7574        { "hex", no_argument, 0, 'x' },
    76         { "stdin", no_argument, 0, 's' },
    7775        { 0, 0, 0, 0 }
    7876};
     
    9593                "  -m, --more       Pause after each screen full\n"
    9694                "  -x, --hex        Print bytes as hex values\n"
    97                 "  -s  --stdin      Treat `-' in file list as standard input\n"
    9895                "Currently, %s is under development, some options don't work.\n",
    9996                cmdname, cmdname);
     
    175172        off64_t file_size = 0, length = 0;
    176173
    177         bool reading_stdin = dash_represents_stdin && (str_cmp(fname, "-") == 0);
    178 
    179         if (reading_stdin) {
    180                 fd = fileno(stdin);
    181                 /* Allow storing the whole UTF-8 character. */
    182                 blen = STR_BOUNDS(1);
    183         } else {
    184                 fd = open(fname, O_RDONLY);
    185         }
     174        fd = open(fname, O_RDONLY);
    186175        if (fd < 0) {
    187176                printf("Unable to open %s\n", fname);
     
    218207
    219208        do {
    220                 size_t bytes_to_read;
    221                 if (reading_stdin) {
    222                         bytes_to_read = 1;
    223                 } else {
    224                         if ((length != CAT_FULL_FILE)
    225                             && (length - (off64_t)count <= (off64_t)(blen - copied_bytes))) {
    226                                 bytes_to_read = (size_t) (length - count);
    227                         } else {
    228                                 bytes_to_read = blen - copied_bytes;
    229                         }
    230                 }
    231                 bytes = read(fd, buff + copied_bytes, bytes_to_read);
     209                bytes = read(fd, buff + copied_bytes, (
     210                        (length != CAT_FULL_FILE && length - (off64_t)count <= (off64_t)(blen - copied_bytes)) ?
     211                        (size_t)(length - count) :
     212                        (blen - copied_bytes) ) );
    232213                bytes += copied_bytes;
    233214                copied_bytes = 0;
     
    261242                        reads++;
    262243                }
    263 
    264                 if (reading_stdin) {
    265                         fflush(stdout);
    266                 }
    267244        } while (bytes > 0 && !should_quit && (count < length || length == CAT_FULL_FILE));
    268245
     
    307284
    308285        for (c = 0, optind = 0, opt_ind = 0; c != -1;) {
    309                 c = getopt_long(argc, argv, "xhvmH:t:b:s", long_options, &opt_ind);
     286                c = getopt_long(argc, argv, "xhvmH:t:b:", long_options, &opt_ind);
    310287                switch (c) {
    311288                case 'h':
     
    341318                        hex = true;
    342319                        break;
    343                 case 's':
    344                         dash_represents_stdin = true;
    345                         break;
    346320                }
    347321        }
  • uspace/srv/hid/console/console.c

    rf0348c8 r33fc3ae  
    7676} console_state_t;
    7777
    78 #define UTF8_CHAR_BUFFER_SIZE (STR_BOUNDS(1) + 1)
    79 
    8078typedef struct {
    8179        atomic_t refcnt;           /**< Connection reference count */
    8280        prodcons_t input_pc;       /**< Incoming keyboard events */
    83         char char_remains[UTF8_CHAR_BUFFER_SIZE]; /**< Not yet sent bytes of last char event. */
    84         size_t char_remains_len;   /**< Number of not yet sent bytes. */
    8581       
    8682        fibril_mutex_t mtx;        /**< Lock protecting mutable fields */
     
    617613       
    618614        size_t pos = 0;
    619 
    620         /*
    621          * Read input from keyboard and copy it to the buffer.
    622          * We need to handle situation when wchar is split by 2 following
    623          * reads.
    624          */
    625615        while (pos < size) {
    626                 /* Copy to the buffer remaining characters. */
    627                 while ((pos < size) && (cons->char_remains_len > 0)) {
    628                         buf[pos] = cons->char_remains[0];
     616                link_t *link = prodcons_consume(&cons->input_pc);
     617                kbd_event_t *event = list_get_instance(link, kbd_event_t, link);
     618               
     619                if (event->type == KEY_PRESS) {
     620                        buf[pos] = event->c;
    629621                        pos++;
    630                         /* Unshift the array. */
    631                         for (size_t i = 1; i < cons->char_remains_len; i++) {
    632                                 cons->char_remains[i - 1] = cons->char_remains[i];
    633                         }
    634                         cons->char_remains_len--;
    635                 }
    636                 /* Still not enough? Then get another key from the queue. */
    637                 if (pos < size) {
    638                         link_t *link = prodcons_consume(&cons->input_pc);
    639                         kbd_event_t *event = list_get_instance(link, kbd_event_t, link);
    640 
    641                         /* Accept key presses of printable chars only. */
    642                         if ((event->type == KEY_PRESS) && (event->c != 0)) {
    643                                 wchar_t tmp[2] = { event->c, 0 };
    644                                 wstr_to_str(cons->char_remains, UTF8_CHAR_BUFFER_SIZE, tmp);
    645                                 cons->char_remains_len = str_size(cons->char_remains);
    646                         }
    647 
    648                         free(event);
    649                 }
     622                }
     623               
     624                free(event);
    650625        }
    651626       
     
    955930                fibril_mutex_initialize(&consoles[i].mtx);
    956931                prodcons_initialize(&consoles[i].input_pc);
    957                 consoles[i].char_remains_len = 0;
    958932               
    959933                if (graphics_state == GRAPHICS_FULL) {
Note: See TracChangeset for help on using the changeset viewer.