Changeset 1bebadee in mainline


Ignore:
Timestamp:
2012-07-18T11:11:29Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c5cbc1b7
Parents:
1f7da3b (diff), 730dce77 (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.

Conflict in uspace/lib/drv/generic/dev_iface.c:

Resolved by using c99 method for array initialization for ahci too.

AHCI drivers
kernel console tab completion

Files:
17 added
14 edited

Legend:

Unmodified
Added
Removed
  • boot/Makefile.common

    r1f7da3b r1bebadee  
    9898        $(USPACE_PATH)/srv/bd/part/guid_part/g_part \
    9999        $(USPACE_PATH)/srv/bd/part/mbr_part/mbr_part \
     100        $(USPACE_PATH)/srv/bd/sata_bd/sata_bd \
    100101        $(USPACE_PATH)/srv/clipboard/clipboard \
    101102        $(USPACE_PATH)/srv/fs/tmpfs/tmpfs \
     
    124125        nic/ne2k \
    125126        nic/e1k \
    126         nic/rtl8139
     127        nic/rtl8139 \
     128        block/ahci
    127129
    128130RD_DRV_CFG =
  • kernel/Makefile

    r1f7da3b r1bebadee  
    196196        generic/src/console/chardev.c \
    197197        generic/src/console/console.c \
     198        generic/src/console/prompt.c \
    198199        generic/src/cpu/cpu.c \
    199200        generic/src/ddi/ddi.c \
  • kernel/generic/include/debug.h

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

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

    r1f7da3b r1bebadee  
    4343#include <console/chardev.h>
    4444#include <console/cmd.h>
     45#include <console/prompt.h>
    4546#include <print.h>
    4647#include <panic.h>
     
    201202 *
    202203 */
    203 NO_TRACE static int cmdtab_compl(char *input, size_t size)
     204NO_TRACE static int cmdtab_compl(char *input, size_t size, indev_t *indev)
    204205{
    205206        const char *name = input;
    206207       
    207208        size_t found = 0;
     209       
     210        /*
     211         * Maximum Match Length: Length of longest matching common
     212         * substring in case more than one match is found.
     213         */
     214        size_t max_match_len = size;
     215        size_t max_match_len_tmp = size;
     216        size_t input_len = str_length(input);
    208217        link_t *pos = NULL;
    209218        const char *hint;
    210219        char *output = malloc(MAX_CMDLINE, 0);
     220        size_t hints_to_show = MAX_TAB_HINTS - 1;
     221        size_t total_hints_shown = 0;
     222        bool continue_showing_hints = true;
    211223       
    212224        output[0] = 0;
     
    218230                pos = pos->next;
    219231                found++;
     232        }
     233       
     234        /*
     235         * If the number of possible completions is more than MAX_TAB_HINTS,
     236         * ask the user whether to display them or not.
     237         */
     238        if (found > MAX_TAB_HINTS) {
     239                printf("\n");
     240                continue_showing_hints =
     241                    console_prompt_display_all_hints(indev, found);
    220242        }
    221243       
     
    225247                while (cmdtab_search_one(name, &pos)) {
    226248                        cmd_info_t *hlp = list_get_instance(pos, cmd_info_t, link);
    227                         printf("%s (%s)\n", hlp->name, hlp->description);
     249                       
     250                        if (continue_showing_hints) {
     251                                printf("%s (%s)\n", hlp->name, hlp->description);
     252                                --hints_to_show;
     253                                ++total_hints_shown;
     254                               
     255                                if ((hints_to_show == 0) && (total_hints_shown != found)) {
     256                                        /* Ask user to continue */
     257                                        continue_showing_hints =
     258                                            console_prompt_more_hints(indev, &hints_to_show);
     259                                }
     260                        }
     261                       
    228262                        pos = pos->next;
    229                 }
     263                       
     264                        for (max_match_len_tmp = 0;
     265                            (output[max_match_len_tmp] ==
     266                            hlp->name[input_len + max_match_len_tmp]) &&
     267                            (max_match_len_tmp < max_match_len); ++max_match_len_tmp);
     268                       
     269                        max_match_len = max_match_len_tmp;
     270                }
     271               
     272                /* Keep only the characters common in all completions */
     273                output[max_match_len] = 0;
    230274        }
    231275       
     
    280324                                continue;
    281325                       
    282                         /* Find the beginning of the word
    283                            and copy it to tmp */
     326                        /*
     327                         * Find the beginning of the word
     328                         * and copy it to tmp
     329                         */
    284330                        size_t beg;
    285331                        for (beg = position - 1; (beg > 0) && (!isspace(current[beg]));
     
    294340                        if (beg == 0) {
    295341                                /* Command completion */
    296                                 found = cmdtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE));
     342                                found = cmdtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE), indev);
    297343                        } else {
    298344                                /* Symbol completion */
    299                                 found = symtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE));
     345                                found = symtab_compl(tmp, STR_BOUNDS(MAX_CMDLINE), indev);
    300346                        }
    301347                       
    302348                        if (found == 0)
    303349                                continue;
    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                        
     350
     351                        /*
     352                         * We have hints, possibly many. In case of more than one hint,
     353                         * tmp will contain the common prefix.
     354                         */
    315355                        size_t off = 0;
    316356                        size_t i = 0;
     
    318358                                if (!wstr_linsert(current, ch, position + i, MAX_CMDLINE))
    319359                                        break;
     360                               
    320361                                i++;
    321362                        }
     363                       
     364                        if (found > 1) {
     365                                /* No unique hint, list was printed */
     366                                printf("%s> ", prompt);
     367                                printf("%ls", current);
     368                                position += str_length(tmp);
     369                                print_cc('\b', wstr_length(current) - position);
     370                                continue;
     371                        }
     372                       
     373                        /* We have a hint */
    322374                       
    323375                        printf("%ls", current + position);
     
    540592/** Parse command line.
    541593 *
    542  * @param cmdline Command line as read from input device. 
     594 * @param cmdline Command line as read from input device.
    543595 * @param size    Size (in bytes) of the string.
    544596 *
  • kernel/generic/src/debug/symtab.c

    r1f7da3b r1bebadee  
    4343#include <typedefs.h>
    4444#include <errno.h>
     45#include <console/prompt.h>
    4546
    4647/** Get name of a symbol that seems most likely to correspond to address.
     
    209210 *
    210211 */
    211 int symtab_compl(char *input, size_t size)
     212int symtab_compl(char *input, size_t size, indev_t *indev)
    212213{
    213214#ifdef CONFIG_SYMTAB
     
    227228        char output[MAX_SYMBOL_NAME];
    228229       
     230        /*
     231         * Maximum Match Length: Length of longest matching common substring in
     232         * case more than one match is found.
     233         */
     234        size_t max_match_len = size;
     235        size_t max_match_len_tmp = size;
     236        size_t input_len = str_length(input);
     237        char *sym_name;
     238        size_t hints_to_show = MAX_TAB_HINTS - 1;
     239        size_t total_hints_shown = 0;
     240        bool continue_showing_hints = true;
     241       
    229242        output[0] = 0;
     243       
     244        while ((hint = symtab_search_one(name, &pos)))
     245                pos++;
     246       
     247        pos = 0;
    230248       
    231249        while ((hint = symtab_search_one(name, &pos))) {
     
    235253                pos++;
    236254                found++;
     255        }
     256       
     257        /*
     258         * If the number of possible completions is more than MAX_TAB_HINTS,
     259         * ask the user whether to display them or not.
     260         */
     261        if (found > MAX_TAB_HINTS) {
     262                printf("\n");
     263                continue_showing_hints =
     264                    console_prompt_display_all_hints(indev, found);
    237265        }
    238266       
     
    241269                pos = 0;
    242270                while (symtab_search_one(name, &pos)) {
    243                         printf("%s\n", symbol_table[pos].symbol_name);
     271                        sym_name = symbol_table[pos].symbol_name;
    244272                        pos++;
     273                       
     274                        if (continue_showing_hints) {
     275                                /* We are still showing hints */
     276                                printf("%s\n", sym_name);
     277                                --hints_to_show;
     278                                ++total_hints_shown;
     279                               
     280                                if ((hints_to_show == 0) && (total_hints_shown != found)) {
     281                                        /* Ask the user to continue */
     282                                        continue_showing_hints =
     283                                            console_prompt_more_hints(indev, &hints_to_show);
     284                                }
     285                        }
     286                       
     287                        for (max_match_len_tmp = 0;
     288                            (output[max_match_len_tmp] ==
     289                            sym_name[input_len + max_match_len_tmp]) &&
     290                            (max_match_len_tmp < max_match_len); ++max_match_len_tmp);
     291                       
     292                        max_match_len = max_match_len_tmp;
    245293                }
     294               
     295                /* Keep only the characters common in all completions */
     296                output[max_match_len] = 0;
    246297        }
    247298       
  • uspace/Makefile

    r1f7da3b r1bebadee  
    8989        srv/vfs \
    9090        srv/bd/ata_bd \
     91        srv/bd/sata_bd \
    9192        srv/bd/file_bd \
    9293        srv/bd/gxe_bd \
     
    110111        drv/infrastructure/root \
    111112        drv/infrastructure/rootvirt \
     113        drv/block/ahci \
    112114        drv/char/i8042 \
    113115        drv/char/ps2mouse \
  • uspace/app/bdsh/cmds/modules/cat/cat.c

    r1f7da3b r1bebadee  
    6262static sysarg_t console_rows = 0;
    6363static bool should_quit = false;
     64static bool dash_represents_stdin = false;
    6465
    6566static console_ctrl_t *console = NULL;
     
    7374        { "more", no_argument, 0, 'm' },
    7475        { "hex", no_argument, 0, 'x' },
     76        { "stdin", no_argument, 0, 's' },
    7577        { 0, 0, 0, 0 }
    7678};
     
    9395                "  -m, --more       Pause after each screen full\n"
    9496                "  -x, --hex        Print bytes as hex values\n"
     97                "  -s  --stdin      Treat `-' in file list as standard input\n"
    9598                "Currently, %s is under development, some options don't work.\n",
    9699                cmdname, cmdname);
     
    172175        off64_t file_size = 0, length = 0;
    173176
    174         fd = open(fname, O_RDONLY);
     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       
    175186        if (fd < 0) {
    176187                printf("Unable to open %s\n", fname);
     
    207218
    208219        do {
    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) ) );
     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               
     232                bytes = read(fd, buff + copied_bytes, bytes_to_read);
    213233                bytes += copied_bytes;
    214234                copied_bytes = 0;
     
    242262                        reads++;
    243263                }
     264               
     265                if (reading_stdin)
     266                        fflush(stdout);
    244267        } while (bytes > 0 && !should_quit && (count < length || length == CAT_FULL_FILE));
    245268
     
    284307
    285308        for (c = 0, optind = 0, opt_ind = 0; c != -1;) {
    286                 c = getopt_long(argc, argv, "xhvmH:t:b:", long_options, &opt_ind);
     309                c = getopt_long(argc, argv, "xhvmH:t:b:s", long_options, &opt_ind);
    287310                switch (c) {
    288311                case 'h':
     
    318341                        hex = true;
    319342                        break;
     343                case 's':
     344                        dash_represents_stdin = true;
     345                        break;
    320346                }
    321347        }
  • uspace/lib/c/Makefile

    r1f7da3b r1bebadee  
    7171        generic/device/nic.c \
    7272        generic/device/pci.c \
     73        generic/device/ahci.c \
    7374        generic/elf/elf_load.c \
    7475        generic/event.c \
  • uspace/lib/c/include/ipc/dev_iface.h

    r1f7da3b r1bebadee  
    5757        /** Interface provided by USB HID devices. */
    5858        USBHID_DEV_IFACE,
     59        /** Interface provided by AHCI devices. */
     60        AHCI_DEV_IFACE,
    5961
    6062        DEV_IFACE_MAX
  • uspace/lib/drv/Makefile

    r1f7da3b r1bebadee  
    4646        generic/remote_pci.c \
    4747        generic/remote_usbhc.c \
    48         generic/remote_usbhid.c
     48        generic/remote_usbhid.c \
     49        generic/remote_ahci.c
    4950
    5051include $(USPACE_PREFIX)/Makefile.common
  • uspace/lib/drv/generic/dev_iface.c

    r1f7da3b r1bebadee  
    4848#include "remote_audio_mixer.h"
    4949#include "remote_audio_pcm.h"
     50#include "remote_ahci.h"
    5051
    5152static const iface_dipatch_table_t remote_ifaces = {
     
    6061                [USBHC_DEV_IFACE] = &remote_usbhc_iface,
    6162                [USBHID_DEV_IFACE] = &remote_usbhid_iface,
     63                [AHCI_DEV_IFACE] = &remote_ahci_iface,
    6264        }
    6365};
  • uspace/srv/devman/main.c

    r1f7da3b r1bebadee  
    419419       
    420420        /* Check that function with same name is not there already. */
    421         if (find_fun_node_in_device(tree, pdev, fun_name) != NULL) {
     421        fun_node_t *tfun = find_fun_node_in_device(tree, pdev, fun_name);
     422        if (tfun) {
     423                fun_del_ref(tfun);      /* drop the new unwanted reference */
    422424                fibril_rwlock_write_unlock(&tree->rwlock);
    423425                dev_del_ref(pdev);
  • uspace/srv/hid/console/console.c

    r1f7da3b r1bebadee  
    7676} console_state_t;
    7777
     78#define UTF8_CHAR_BUFFER_SIZE (STR_BOUNDS(1) + 1)
     79
    7880typedef struct {
    7981        atomic_t refcnt;           /**< Connection reference count */
    8082        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. */
    8185       
    8286        fibril_mutex_t mtx;        /**< Lock protecting mutable fields */
     
    613617       
    614618        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         */
    615625        while (pos < size) {
    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;
     626                /* Copy to the buffer remaining characters. */
     627                while ((pos < size) && (cons->char_remains_len > 0)) {
     628                        buf[pos] = cons->char_remains[0];
    621629                        pos++;
    622                 }
    623                
    624                 free(event);
     630                       
     631                        /* Unshift the array. */
     632                        for (size_t i = 1; i < cons->char_remains_len; i++)
     633                                cons->char_remains[i - 1] = cons->char_remains[i];
     634                       
     635                        cons->char_remains_len--;
     636                }
     637               
     638                /* Still not enough? Then get another key from the queue. */
     639                if (pos < size) {
     640                        link_t *link = prodcons_consume(&cons->input_pc);
     641                        kbd_event_t *event = list_get_instance(link, kbd_event_t, link);
     642                       
     643                        /* Accept key presses of printable chars only. */
     644                        if ((event->type == KEY_PRESS) && (event->c != 0)) {
     645                                wchar_t tmp[2] = { event->c, 0 };
     646                                wstr_to_str(cons->char_remains, UTF8_CHAR_BUFFER_SIZE, tmp);
     647                                cons->char_remains_len = str_size(cons->char_remains);
     648                        }
     649                       
     650                        free(event);
     651                }
    625652        }
    626653       
     
    930957                fibril_mutex_initialize(&consoles[i].mtx);
    931958                prodcons_initialize(&consoles[i].input_pc);
     959                consoles[i].char_remains_len = 0;
    932960               
    933961                if (graphics_state == GRAPHICS_FULL) {
Note: See TracChangeset for help on using the changeset viewer.