Changeset 86ffa27f in mainline for uspace/lib


Ignore:
Timestamp:
2011-08-07T11:21:44Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cc574511
Parents:
15f3c3f (diff), e8067c0 (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.

Location:
uspace/lib
Files:
39 added
1 deleted
45 edited
4 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/block/libblock.c

    r15f3c3f r86ffa27f  
    258258static hash_index_t cache_hash(unsigned long *key)
    259259{
    260         return *key & (CACHE_BUCKETS - 1);
     260        return MERGE_LOUP32(key[0], key[1]) & (CACHE_BUCKETS - 1);
    261261}
    262262
     
    264264{
    265265        block_t *b = hash_table_get_instance(item, block_t, hash_link);
    266         return b->lba == *key;
     266        return b->lba == MERGE_LOUP32(key[0], key[1]);
    267267}
    268268
     
    305305        cache->blocks_cluster = cache->lblock_size / devcon->pblock_size;
    306306
    307         if (!hash_table_create(&cache->block_hash, CACHE_BUCKETS, 1,
     307        if (!hash_table_create(&cache->block_hash, CACHE_BUCKETS, 2,
    308308            &cache_ops)) {
    309309                free(cache);
     
    344344                }
    345345
    346                 unsigned long key = b->lba;
    347                 hash_table_remove(&cache->block_hash, &key, 1);
     346                unsigned long key[2] = {
     347                        LOWER32(b->lba),
     348                        UPPER32(b->lba)
     349                };
     350                hash_table_remove(&cache->block_hash, key, 2);
    348351               
    349352                free(b->data);
     
    398401        block_t *b;
    399402        link_t *l;
    400         unsigned long key = ba;
     403        unsigned long key[2] = {
     404                LOWER32(ba),
     405                UPPER32(ba)
     406        };
     407
    401408        int rc;
    402409       
     
    413420
    414421        fibril_mutex_lock(&cache->lock);
    415         l = hash_table_find(&cache->block_hash, &key);
     422        l = hash_table_find(&cache->block_hash, key);
    416423        if (l) {
    417424found:
     
    451458                         * Try to recycle a block from the free list.
    452459                         */
    453                         unsigned long temp_key;
    454460recycle:
    455461                        if (list_empty(&cache->free_list)) {
     
    499505                                        goto retry;
    500506                                }
    501                                 l = hash_table_find(&cache->block_hash, &key);
     507                                l = hash_table_find(&cache->block_hash, key);
    502508                                if (l) {
    503509                                        /*
     
    522528                         */
    523529                        list_remove(&b->free_link);
    524                         temp_key = b->lba;
    525                         hash_table_remove(&cache->block_hash, &temp_key, 1);
     530                        unsigned long temp_key[2] = {
     531                                LOWER32(b->lba),
     532                                UPPER32(b->lba)
     533                        };
     534                        hash_table_remove(&cache->block_hash, temp_key, 2);
    526535                }
    527536
     
    531540                b->lba = ba;
    532541                b->pba = ba_ltop(devcon, b->lba);
    533                 hash_table_insert(&cache->block_hash, &key, &b->hash_link);
     542                hash_table_insert(&cache->block_hash, key, &b->hash_link);
    534543
    535544                /*
     
    643652                         * Take the block out of the cache and free it.
    644653                         */
    645                         unsigned long key = block->lba;
    646                         hash_table_remove(&cache->block_hash, &key, 1);
     654                        unsigned long key[2] = {
     655                                LOWER32(block->lba),
     656                                UPPER32(block->lba)
     657                        };
     658                        hash_table_remove(&cache->block_hash, key, 2);
    647659                        fibril_mutex_unlock(&block->lock);
    648660                        free(block->data);
  • uspace/lib/c/Makefile

    r15f3c3f r86ffa27f  
    5959-include arch/$(UARCH)/Makefile.inc
    6060
    61 EXTRA_CFLAGS += -I../../srv/loader/include
    62 
    6361GENERIC_SOURCES = \
    6462        generic/libc.c \
     
    7068        generic/device/hw_res.c \
    7169        generic/device/char_dev.c \
     70        generic/elf/elf_load.c \
    7271        generic/event.c \
    7372        generic/errno.c \
     
    134133                generic/dlfcn.c \
    135134                generic/rtld/rtld.c \
    136                 generic/rtld/elf_load.c \
    137135                generic/rtld/dynamic.c \
    138136                generic/rtld/module.c \
  • uspace/lib/c/arch/abs32le/include/elf_linux.h

    r15f3c3f r86ffa27f  
    11/*
    2  * Copyright (c) 2011 Vojtech Horky
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup drvusbmast
     29/** @addtogroup libcabs32le
    3030 * @{
    3131 */
    3232/** @file
    33  * SCSI related structures.
    3433 */
    3534
    36 #ifndef USB_USBMAST_SCSI_H_
    37 #define USB_USBMAST_SCSI_H_
     35#ifndef LIBC_abs32le_ELF_LINUX_H_
     36#define LBIC_abs32le_ELF_LINUX_H_
    3837
     38#include <libarch/istate.h>
    3939#include <sys/types.h>
    40 #include <usb/usb.h>
    4140
    4241typedef struct {
    43         uint8_t op_code;
    44         uint8_t lun_evpd;
    45         uint8_t page_code;
    46         uint16_t alloc_length;
    47         uint8_t ctrl;
    48 } __attribute__((packed)) scsi_cmd_inquiry_t;
     42} elf_regs_t;
     43
     44static inline void istate_to_elf_regs(istate_t *istate, elf_regs_t *elf_regs)
     45{
     46        (void) istate; (void) elf_regs;
     47}
    4948
    5049#endif
    5150
    52 /**
    53  * @}
     51/** @}
    5452 */
  • uspace/lib/c/arch/mips32/Makefile.common

    r15f3c3f r86ffa27f  
    2727#
    2828
    29 GCC_CFLAGS += -mips3
     29GCC_CFLAGS += -mips3 -mabi=32
    3030
    3131ENDIANESS = LE
  • uspace/lib/c/arch/mips32/include/atomic.h

    r15f3c3f r86ffa27f  
    3131 */
    3232/** @file
    33  * @ingroup libcmips32eb
     33 * @ingroup libcmips32
    3434 */
    3535
  • uspace/lib/c/arch/mips32/include/fibril.h

    r15f3c3f r86ffa27f  
    2727 */
    2828
    29 /** @addtogroup libcmips32     
     29/** @addtogroup libcmips32
    3030 * @{
    3131 */
    3232/** @file
    33  * @ingroup libcmips32eb       
     33 * @ingroup libcmips32
    3434 */
    3535
  • uspace/lib/c/arch/mips32/include/thread.h

    r15f3c3f r86ffa27f  
    2727 */
    2828
    29 /** @addtogroup libcmips32     
     29/** @addtogroup libcmips32
    3030 * @{
    3131 */
    3232/** @file
    33  * @ingroup libcmips32eb       
     33 * @ingroup libcmips32
    3434 */
    3535
  • uspace/lib/c/arch/mips32/include/tls.h

    r15f3c3f r86ffa27f  
    2727 */
    2828
    29 /** @addtogroup libcmips32     
     29/** @addtogroup libcmips32
    3030 * @{
    3131 */
    3232/** @file
    33  * @ingroup libcmips32eb       
     33 * @ingroup libcmips32
    3434 */
    3535
  • uspace/lib/c/arch/mips32/include/types.h

    r15f3c3f r86ffa27f  
    3131 */
    3232/** @file
    33  * @ingroup libcmips32eb
     33 * @ingroup libcmips32
    3434 */
    3535
  • uspace/lib/c/arch/mips32/src/syscall.c

    r15f3c3f r86ffa27f  
    2727 */
    2828
    29  /** @addtogroup libcmips32
     29/** @addtogroup libcmips32
    3030 * @{
    3131 */
    3232/** @file
    33   * @ingroup libcmips32eb       
     33  * @ingroup libcmips32
    3434 */
    3535
     
    6464}
    6565
    66  /** @}
     66/** @}
    6767 */
    68 
  • uspace/lib/c/arch/mips32/src/tls.c

    r15f3c3f r86ffa27f  
    2727 */
    2828
    29 /** @addtogroup libcmips32     
     29/** @addtogroup libcmips32
    3030 * @{
    3131 */
    3232/** @file
    33  * @ingroup libcmips32eb       
     33 * @ingroup libcmips32
    3434 */
    3535
  • uspace/lib/c/arch/mips32eb/Makefile.common

    r15f3c3f r86ffa27f  
    2727#
    2828
    29 GCC_CFLAGS += -mips3
     29GCC_CFLAGS += -mips3 -mabi=32
    3030
    3131ENDIANESS = BE
  • uspace/lib/c/generic/elf/elf_load.c

    r15f3c3f r86ffa27f  
    2929 */
    3030
    31 /** @addtogroup generic 
     31/** @addtogroup generic
    3232 * @{
    3333 */
     
    4949#include <assert.h>
    5050#include <as.h>
     51#include <elf/elf.h>
    5152#include <unistd.h>
    5253#include <fcntl.h>
     
    5556#include <entry_point.h>
    5657
    57 #include "elf.h"
    58 #include "elf_load.h"
     58#include <elf/elf_load.h>
    5959
    6060#define DPRINTF(...)
     
    7474static int load_segment(elf_ld_t *elf, elf_segment_header_t *entry);
    7575
    76 /** Read until the buffer is read in its entirety. */
    77 static int my_read(int fd, void *buf, size_t len)
    78 {
    79         int cnt = 0;
    80         do {
    81                 buf += cnt;
    82                 len -= cnt;
    83                 cnt = read(fd, buf, len);
    84         } while ((cnt > 0) && ((len - cnt) > 0));
    85 
    86         return cnt;
    87 }
    88 
    8976/** Load ELF binary from a file.
    9077 *
     
    160147        int i, rc;
    161148
    162         rc = my_read(elf->fd, header, sizeof(elf_header_t));
    163         if (rc < 0) {
     149        rc = read_all(elf->fd, header, sizeof(elf_header_t));
     150        if (rc != sizeof(elf_header_t)) {
    164151                DPRINTF("Read error.\n");
    165152                return EE_INVALID;
     
    222209                        + i * sizeof(elf_segment_header_t), SEEK_SET);
    223210
    224                 rc = my_read(elf->fd, &segment_hdr,
     211                rc = read_all(elf->fd, &segment_hdr,
    225212                    sizeof(elf_segment_header_t));
    226                 if (rc < 0) {
     213                if (rc != sizeof(elf_segment_header_t)) {
    227214                        DPRINTF("Read error.\n");
    228215                        return EE_INVALID;
     
    244231                    + i * sizeof(elf_section_header_t), SEEK_SET);
    245232
    246                 rc = my_read(elf->fd, &section_hdr,
     233                rc = read_all(elf->fd, &section_hdr,
    247234                    sizeof(elf_section_header_t));
    248                 if (rc < 0) {
     235                if (rc != sizeof(elf_section_header_t)) {
    249236                        DPRINTF("Read error.\n");
    250237                        return EE_INVALID;
     
    334321        uintptr_t seg_addr;
    335322        size_t mem_sz;
    336         int rc;
     323        ssize_t rc;
    337324
    338325        bias = elf->bias;
     
    412399                if (now > left) now = left;
    413400
    414                 rc = my_read(elf->fd, dp, now);
    415 
    416                 if (rc < 0) {
     401                rc = read_all(elf->fd, dp, now);
     402
     403                if (rc != (ssize_t) now) {
    417404                        DPRINTF("Read error.\n");
    418405                        return EE_INVALID;
  • uspace/lib/c/generic/io/console.c

    r15f3c3f r86ffa27f  
    7676bool console_kcon(void)
    7777{
    78 #if 0
    7978        return __SYSCALL0(SYS_DEBUG_ACTIVATE_CONSOLE);
    80 #endif
    81        
    82         return false;
    8379}
    8480
  • uspace/lib/c/generic/io/io.c

    r15f3c3f r86ffa27f  
    594594                }
    595595               
    596                 buf += now;
     596                data += now;
    597597                stream->buf_head += now;
    598598                buf_free -= now;
    599599                bytes_left -= now;
    600600                total_written += now;
     601                stream->buf_state = _bs_write;
    601602               
    602603                if (buf_free == 0) {
     
    606607                }
    607608        }
    608        
    609         if (total_written > 0)
    610                 stream->buf_state = _bs_write;
    611609
    612610        if (need_flush)
     
    714712off64_t ftell(FILE *stream)
    715713{
     714        _fflushbuf(stream);
    716715        return lseek(stream->fd, 0, SEEK_CUR);
    717716}
  • uspace/lib/c/generic/rtld/module.c

    r15f3c3f r86ffa27f  
    3535 */
    3636
     37#include <adt/list.h>
     38#include <elf/elf_load.h>
     39#include <fcntl.h>
     40#include <loader/pcb.h>
    3741#include <stdio.h>
    3842#include <stdlib.h>
    3943#include <unistd.h>
    40 #include <fcntl.h>
    41 #include <adt/list.h>
    42 #include <loader/pcb.h>
    4344
    4445#include <rtld/rtld.h>
     
    4748#include <rtld/rtld_arch.h>
    4849#include <rtld/module.h>
    49 #include <elf_load.h>
    5050
    5151/** (Eagerly) process all relocation tables in a module.
     
    9393module_t *module_find(const char *name)
    9494{
    95         link_t *head = &runtime_env->modules_head;
    96 
    97         link_t *cur;
    9895        module_t *m;
    9996        const char *p, *soname;
     
    110107
    111108        /* Traverse list of all modules. Not extremely fast, but simple */
    112         DPRINTF("head = %p\n", head);
    113         for (cur = head->next; cur != head; cur = cur->next) {
     109        list_foreach(runtime_env->modules, cur) {
    114110                DPRINTF("cur = %p\n", cur);
    115111                m = list_get_instance(cur, module_t, modules_link);
     
    177173
    178174        /* Insert into the list of loaded modules */
    179         list_append(&m->modules_link, &runtime_env->modules_head);
     175        list_append(&m->modules_link, &runtime_env->modules);
    180176
    181177        return m;
     
    249245void modules_process_relocs(module_t *start)
    250246{
    251         link_t *head = &runtime_env->modules_head;
    252 
    253         link_t *cur;
    254         module_t *m;
    255 
    256         for (cur = head->next; cur != head; cur = cur->next) {
     247        module_t *m;
     248
     249        list_foreach(runtime_env->modules, cur) {
    257250                m = list_get_instance(cur, module_t, modules_link);
    258251
     
    268261void modules_untag(void)
    269262{
    270         link_t *head = &runtime_env->modules_head;
    271 
    272         link_t *cur;
    273         module_t *m;
    274 
    275         for (cur = head->next; cur != head; cur = cur->next) {
     263        module_t *m;
     264
     265        list_foreach(runtime_env->modules, cur) {
    276266                m = list_get_instance(cur, module_t, modules_link);
    277267                m->bfs_tag = false;
  • uspace/lib/c/generic/rtld/rtld.c

    r15f3c3f r86ffa27f  
    4444{
    4545        runtime_env = &rt_env_static;
    46         list_initialize(&runtime_env->modules_head);
     46        list_initialize(&runtime_env->modules);
    4747        runtime_env->next_bias = 0x2000000;
    4848        runtime_env->program = NULL;
  • uspace/lib/c/generic/rtld/symbol.c

    r15f3c3f r86ffa27f  
    3838#include <stdlib.h>
    3939
     40#include <elf/elf.h>
    4041#include <rtld/rtld.h>
    4142#include <rtld/rtld_debug.h>
    4243#include <rtld/symbol.h>
    43 #include <elf.h>
    4444
    4545/*
     
    118118        module_t *m, *dm;
    119119        elf_symbol_t *sym, *s;
    120         link_t queue_head;
     120        list_t queue;
    121121        size_t i;
    122122
     
    132132
    133133        /* Insert root (the program) into the queue and tag it */
    134         list_initialize(&queue_head);
     134        list_initialize(&queue);
    135135        start->bfs_tag = true;
    136         list_append(&start->queue_link, &queue_head);
     136        list_append(&start->queue_link, &queue);
    137137
    138138        /* If the symbol is found, it will be stored in 'sym' */
     
    140140
    141141        /* While queue is not empty */
    142         while (!list_empty(&queue_head)) {
     142        while (!list_empty(&queue)) {
    143143                /* Pop first element from the queue */
    144                 m = list_get_instance(queue_head.next, module_t, queue_link);
     144                m = list_get_instance(list_first(&queue), module_t, queue_link);
    145145                list_remove(&m->queue_link);
    146146
     
    162162                        if (dm->bfs_tag == false) {
    163163                                dm->bfs_tag = true;
    164                                 list_append(&dm->queue_link, &queue_head);
     164                                list_append(&dm->queue_link, &queue);
    165165                        }
    166166                }
     
    168168
    169169        /* Empty the queue so that we leave it in a clean state */
    170         while (!list_empty(&queue_head))
    171                 list_remove(queue_head.next);
     170        while (!list_empty(&queue))
     171                list_remove(list_first(&queue));
    172172
    173173        if (!sym) {
  • uspace/lib/c/generic/str.c

    r15f3c3f r86ffa27f  
    544544       
    545545        str_cpy(dest + dstr_size, size - dstr_size, src);
     546}
     547
     548/** Convert space-padded ASCII to string.
     549 *
     550 * Common legacy text encoding in hardware is 7-bit ASCII fitted into
     551 * a fixed-with byte buffer (bit 7 always zero), right-padded with spaces
     552 * (ASCII 0x20). Convert space-padded ascii to string representation.
     553 *
     554 * If the text does not fit into the destination buffer, the function converts
     555 * as many characters as possible and returns EOVERFLOW.
     556 *
     557 * If the text contains non-ASCII bytes (with bit 7 set), the whole string is
     558 * converted anyway and invalid characters are replaced with question marks
     559 * (U_SPECIAL) and the function returns EIO.
     560 *
     561 * Regardless of return value upon return @a dest will always be well-formed.
     562 *
     563 * @param dest          Destination buffer
     564 * @param size          Size of destination buffer
     565 * @param src           Space-padded ASCII.
     566 * @param n             Size of the source buffer in bytes.
     567 *
     568 * @return              EOK on success, EOVERFLOW if the text does not fit
     569 *                      destination buffer, EIO if the text contains
     570 *                      non-ASCII bytes.
     571 */
     572int spascii_to_str(char *dest, size_t size, const uint8_t *src, size_t n)
     573{
     574        size_t sidx;
     575        size_t didx;
     576        size_t dlast;
     577        uint8_t byte;
     578        int rc;
     579        int result;
     580
     581        /* There must be space for a null terminator in the buffer. */
     582        assert(size > 0);
     583        result = EOK;
     584
     585        didx = 0;
     586        dlast = 0;
     587        for (sidx = 0; sidx < n; ++sidx) {
     588                byte = src[sidx];
     589                if (!ascii_check(byte)) {
     590                        byte = U_SPECIAL;
     591                        result = EIO;
     592                }
     593
     594                rc = chr_encode(byte, dest, &didx, size - 1);
     595                if (rc != EOK) {
     596                        assert(rc == EOVERFLOW);
     597                        dest[didx] = '\0';
     598                        return rc;
     599                }
     600
     601                /* Remember dest index after last non-empty character */
     602                if (byte != 0x20)
     603                        dlast = didx;
     604        }
     605
     606        /* Terminate string after last non-empty character */
     607        dest[dlast] = '\0';
     608        return result;
    546609}
    547610
  • uspace/lib/c/generic/vfs/vfs.c

    r15f3c3f r86ffa27f  
    417417}
    418418
     419/** Read entire buffer.
     420 *
     421 * In face of short reads this function continues reading until either
     422 * the entire buffer is read or no more data is available (at end of file).
     423 *
     424 * @param fildes        File descriptor
     425 * @param buf           Buffer, @a nbytes bytes long
     426 * @param nbytes        Number of bytes to read
     427 *
     428 * @return              On success, positive number of bytes read.
     429 *                      On failure, negative error code from read().
     430 */
     431ssize_t read_all(int fildes, void *buf, size_t nbyte)
     432{
     433        ssize_t cnt = 0;
     434        size_t nread = 0;
     435        uint8_t *bp = (uint8_t *) buf;
     436
     437        do {
     438                bp += cnt;
     439                nread += cnt;
     440                cnt = read(fildes, bp, nbyte - nread);
     441        } while (cnt > 0 && (nbyte - nread - cnt) > 0);
     442
     443        if (cnt < 0)
     444                return cnt;
     445
     446        return nread + cnt;
     447}
     448
     449/** Write entire buffer.
     450 *
     451 * This function fails if it cannot write exactly @a len bytes to the file.
     452 *
     453 * @param fildes        File descriptor
     454 * @param buf           Data, @a nbytes bytes long
     455 * @param nbytes        Number of bytes to write
     456 *
     457 * @return              EOK on error, return value from write() if writing
     458 *                      failed.
     459 */
     460ssize_t write_all(int fildes, const void *buf, size_t nbyte)
     461{
     462        ssize_t cnt = 0;
     463        ssize_t nwritten = 0;
     464        const uint8_t *bp = (uint8_t *) buf;
     465
     466        do {
     467                bp += cnt;
     468                nwritten += cnt;
     469                cnt = write(fildes, bp, nbyte - nwritten);
     470        } while (cnt > 0 && ((ssize_t )nbyte - nwritten - cnt) > 0);
     471
     472        if (cnt < 0)
     473                return cnt;
     474
     475        if ((ssize_t)nbyte - nwritten - cnt > 0)
     476                return EIO;
     477
     478        return nbyte;
     479}
     480
    419481int fsync(int fildes)
    420482{
  • uspace/lib/c/include/bitops.h

    r15f3c3f r86ffa27f  
    3838#include <sys/types.h>
    3939
     40/** Mask with bit @a n set. */
     41#define BIT_V(type, n) \
     42    ((type)1 << ((n) - 1))
     43
     44/** Mask with rightmost @a n bits set. */
     45#define BIT_RRANGE(type, n) \
     46    (BIT_V(type, (n) + 1) - 1)
     47
     48/** Mask with bits @a hi .. @a lo set. @a hi >= @a lo. */
     49#define BIT_RANGE(type, hi, lo) \
     50    (BIT_RRANGE(type, (hi) - (lo) + 1) << (lo))
     51
     52/** Extract range of bits @a hi .. @a lo from @a value. */
     53#define BIT_RANGE_EXTRACT(type, hi, lo, value) \
     54    (((value) >> (lo)) & BIT_RRANGE(type, (hi) - (lo) + 1))
    4055
    4156/** Return position of first non-zero bit from left (i.e. [log_2(arg)]).
  • uspace/lib/c/include/elf/elf_load.h

    r15f3c3f r86ffa27f  
    11/*
     2 * Copyright (c) 2006 Sergey Bondari
    23 * Copyright (c) 2008 Jiri Svoboda
    34 * All rights reserved.
     
    3839
    3940#include <arch/elf.h>
     41#include <elf/elf.h>
    4042#include <sys/types.h>
    4143#include <loader/pcb.h>
    4244
    43 #include "elf.h"
     45/**
     46 * ELF error return codes
     47 */
     48#define EE_OK                   0       /* No error */
     49#define EE_INVALID              1       /* Invalid ELF image */
     50#define EE_MEMORY               2       /* Cannot allocate address space */
     51#define EE_INCOMPATIBLE         3       /* ELF image is not compatible with current architecture */
     52#define EE_UNSUPPORTED          4       /* Non-supported ELF (e.g. dynamic ELFs) */
     53#define EE_LOADER               5       /* The image is actually a program loader. */
     54#define EE_IRRECOVERABLE        6
    4455
    4556typedef enum {
     
    8293} elf_ld_t;
    8394
    84 int elf_load_file(const char *file_name, size_t so_bias, eld_flags_t flags,
    85     elf_info_t *info);
    86 void elf_create_pcb(elf_info_t *info, pcb_t *pcb);
     95extern const char *elf_error(unsigned int);
     96extern int elf_load_file(const char *, size_t, eld_flags_t, elf_info_t *);
     97extern void elf_create_pcb(elf_info_t *, pcb_t *);
    8798
    8899#endif
  • uspace/lib/c/include/ipc/console.h

    r15f3c3f r86ffa27f  
    4848        CONSOLE_SET_COLOR,
    4949        CONSOLE_SET_RGB_COLOR,
    50         CONSOLE_CURSOR_VISIBILITY,
    51         CONSOLE_KCON_ENABLE
     50        CONSOLE_CURSOR_VISIBILITY
    5251} console_request_t;
    5352
  • uspace/lib/c/include/ipc/services.h

    r15f3c3f r86ffa27f  
    3838#define LIBC_SERVICES_H_
    3939
     40#include <fourcc.h>
     41
    4042typedef enum {
    41         SERVICE_NONE = 0,
    42         SERVICE_LOAD,
    43         SERVICE_VIDEO,
    44         SERVICE_VFS,
    45         SERVICE_LOC,
    46         SERVICE_DEVMAN,
    47         SERVICE_IRC,
    48         SERVICE_CLIPBOARD,
    49         SERVICE_NETWORKING,
    50         SERVICE_LO,
    51         SERVICE_NE2000,
    52         SERVICE_ETHERNET,
    53         SERVICE_NILDUMMY,
    54         SERVICE_IP,
    55         SERVICE_ARP,
    56         SERVICE_ICMP,
    57         SERVICE_UDP,
    58         SERVICE_TCP
     43        SERVICE_NONE       = 0,
     44        SERVICE_LOAD       = FOURCC('l', 'o', 'a', 'd'),
     45        SERVICE_VIDEO      = FOURCC('v', 'i', 'd', ' '),
     46        SERVICE_VFS        = FOURCC('v', 'f', 's', ' '),
     47        SERVICE_LOC        = FOURCC('l', 'o', 'c', ' '),
     48        SERVICE_DEVMAN     = FOURCC('d', 'e', 'v', 'n'),
     49        SERVICE_IRC        = FOURCC('i', 'r', 'c', ' '),
     50        SERVICE_CLIPBOARD  = FOURCC('c', 'l', 'i', 'p'),
     51        SERVICE_NETWORKING = FOURCC('n', 'e', 't', ' '),
     52        SERVICE_LO         = FOURCC('l', 'o', ' ', ' '),
     53        SERVICE_NE2000     = FOURCC('n', 'e', '2', 'k'),
     54        SERVICE_ETHERNET   = FOURCC('e', 't', 'h', ' '),
     55        SERVICE_NILDUMMY   = FOURCC('n', 'i', 'l', 'd'),
     56        SERVICE_IP         = FOURCC('i', 'p', 'v', '4'),
     57        SERVICE_ARP        = FOURCC('a', 'r', 'p', ' '),
     58        SERVICE_ICMP       = FOURCC('i', 'c', 'm', 'p'),
     59        SERVICE_UDP        = FOURCC('u', 'd', 'p', ' '),
     60        SERVICE_TCP        = FOURCC('t', 'c', 'p', ' ')
    5961} services_t;
    6062
  • uspace/lib/c/include/rtld/elf_dyn.h

    r15f3c3f r86ffa27f  
    3939#include <sys/types.h>
    4040
    41 #include <elf.h>
     41#include <elf/elf.h>
    4242#include <libarch/rtld/elf_dyn.h>
    4343
  • uspace/lib/c/include/rtld/rtld.h

    r15f3c3f r86ffa27f  
    4949
    5050        /** List of all loaded modules including rtld and the program */
    51         link_t modules_head;
     51        list_t modules;
    5252
    5353        /** Temporary hack to place each module at different address. */
  • uspace/lib/c/include/rtld/symbol.h

    r15f3c3f r86ffa27f  
    3636#define LIBC_RTLD_SYMBOL_H_
    3737
     38#include <elf/elf.h>
    3839#include <rtld/rtld.h>
    39 #include <elf.h>
    4040
    4141elf_symbol_t *symbol_bfs_find(const char *name, module_t *start, module_t **mod);
  • uspace/lib/c/include/str.h

    r15f3c3f r86ffa27f  
    4848#define STR_BOUNDS(length)  ((length) << 2)
    4949
     50/**
     51 * Maximum size of a buffer needed to a string converted from space-padded
     52 * ASCII of size @a spa_size using spascii_to_str().
     53 */
     54#define SPASCII_STR_BUFSIZE(spa_size) ((spa_size) + 1)
     55
    5056extern wchar_t str_decode(const char *str, size_t *offset, size_t sz);
    5157extern int chr_encode(const wchar_t ch, char *str, size_t *offset, size_t sz);
     
    7379extern void str_append(char *dest, size_t size, const char *src);
    7480
     81extern int spascii_to_str(char *dest, size_t size, const uint8_t *src, size_t n);
    7582extern void wstr_to_str(char *dest, size_t size, const wchar_t *src);
    7683extern char *wstr_to_astr(const wchar_t *src);
  • uspace/lib/c/include/unistd.h

    r15f3c3f r86ffa27f  
    6363extern ssize_t read(int, void *, size_t);
    6464
     65extern ssize_t read_all(int, void *, size_t);
     66extern ssize_t write_all(int, const void *, size_t);
     67
    6568extern off64_t lseek(int, off64_t, int);
    6669extern int ftruncate(int, aoff64_t);
  • uspace/lib/clui/tinput.c

    r15f3c3f r86ffa27f  
    11/*
    2  * Copyright (c) 2010 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
     29#include <sort.h>
    2930#include <stdio.h>
    3031#include <stdlib.h>
     
    4243#include <tinput.h>
    4344
     45#define LIN_TO_COL(ti, lpos) ((lpos) % ((ti)->con_cols))
     46#define LIN_TO_ROW(ti, lpos) ((lpos) / ((ti)->con_cols))
     47
    4448/** Seek direction */
    4549typedef enum {
     
    6165static void tinput_post_seek(tinput_t *, bool);
    6266
     67static void tinput_console_set_lpos(tinput_t *ti, unsigned lpos)
     68{
     69        console_set_pos(ti->console, LIN_TO_COL(ti, lpos),
     70            LIN_TO_ROW(ti, lpos));
     71}
     72
    6373/** Create a new text input field. */
    6474tinput_t *tinput_new(void)
     
    6676        tinput_t *ti;
    6777       
    68         ti = malloc(sizeof(tinput_t));
     78        ti = calloc(1, sizeof(tinput_t));
    6979        if (ti == NULL)
    7080                return NULL;
     
    7787void tinput_destroy(tinput_t *ti)
    7888{
     89        if (ti->prompt != NULL)
     90                free(ti->prompt);
    7991        free(ti);
     92}
     93
     94static void tinput_display_prompt(tinput_t *ti)
     95{
     96        tinput_console_set_lpos(ti, ti->prompt_coord);
     97
     98        console_set_style(ti->console, STYLE_EMPHASIS);
     99        printf("%s", ti->prompt);
     100        console_flush(ti->console);
     101        console_set_style(ti->console, STYLE_NORMAL);
    80102}
    81103
     
    88110        tinput_sel_get_bounds(ti, &sa, &sb);
    89111       
    90         console_set_pos(ti->console, (ti->col0 + start) % ti->con_cols,
    91             ti->row0 + (ti->col0 + start) / ti->con_cols);
     112        tinput_console_set_lpos(ti, ti->text_coord + start);
    92113        console_set_style(ti->console, STYLE_NORMAL);
    93114       
     
    134155static void tinput_position_caret(tinput_t *ti)
    135156{
    136         console_set_pos(ti->console, (ti->col0 + ti->pos) % ti->con_cols,
    137             ti->row0 + (ti->col0 + ti->pos) / ti->con_cols);
    138 }
    139 
    140 /** Update row0 in case the screen could have scrolled. */
     157        tinput_console_set_lpos(ti, ti->text_coord + ti->pos);
     158}
     159
     160/** Update text_coord, prompt_coord in case the screen could have scrolled. */
    141161static void tinput_update_origin(tinput_t *ti)
    142162{
    143         sysarg_t width = ti->col0 + ti->nc;
    144         sysarg_t rows = (width / ti->con_cols) + 1;
    145        
    146         /* Update row0 if the screen scrolled. */
    147         if (ti->row0 + rows > ti->con_rows)
    148                 ti->row0 = ti->con_rows - rows;
     163        unsigned end_coord = ti->text_coord + ti->nc;
     164        unsigned end_row = LIN_TO_ROW(ti, end_coord);
     165
     166        unsigned scroll_rows;
     167
     168        /* Update coords if the screen scrolled. */
     169        if (end_row >= ti->con_rows) {
     170                scroll_rows = end_row - ti->con_rows + 1;
     171                ti->text_coord -= ti->con_cols * scroll_rows;
     172                ti->prompt_coord -= ti->con_cols * scroll_rows;
     173        }
     174}
     175
     176static void tinput_jump_after(tinput_t *ti)
     177{
     178        tinput_console_set_lpos(ti, ti->text_coord + ti->nc);
     179        console_flush(ti->console);
     180        putchar('\n');
     181}
     182
     183static int tinput_display(tinput_t *ti)
     184{
     185        sysarg_t col0, row0;
     186       
     187        if (console_get_pos(ti->console, &col0, &row0) != EOK)
     188                return EIO;
     189       
     190        ti->prompt_coord = row0 * ti->con_cols + col0;
     191        ti->text_coord = ti->prompt_coord + str_length(ti->prompt);
     192
     193        tinput_display_prompt(ti);
     194        tinput_display_tail(ti, 0, 0);
     195        tinput_position_caret(ti);
     196
     197        return EOK;
    149198}
    150199
     
    154203                return;
    155204       
    156         sysarg_t new_width = ti->col0 + ti->nc + 1;
     205        unsigned new_width = LIN_TO_COL(ti, ti->text_coord) + ti->nc + 1;
    157206        if (new_width % ti->con_cols == 0) {
    158207                /* Advancing to new line. */
     
    185234                return;
    186235       
    187         sysarg_t new_width = ti->col0 + ti->nc + ilen;
    188         sysarg_t new_height = (new_width / ti->con_cols) + 1;
     236        unsigned new_width = LIN_TO_COL(ti, ti->text_coord) + ti->nc + ilen;
     237        unsigned new_height = (new_width / ti->con_cols) + 1;
    189238        if (new_height >= ti->con_rows) {
    190239                /* Disallow text longer than 1 page for now. */
     
    511560}
    512561
     562/** Compare two entries in array of completions. */
     563static int compl_cmp(void *va, void *vb, void *arg)
     564{
     565        const char *a = *(const char **) va;
     566        const char *b = *(const char **) vb;
     567
     568        return str_cmp(a, b);
     569}
     570
     571static size_t common_pref_len(const char *a, const char *b)
     572{
     573        size_t i;
     574        size_t a_off, b_off;
     575        wchar_t ca, cb;
     576
     577        i = 0;
     578        a_off = 0;
     579        b_off = 0;
     580
     581        while (true) {
     582                ca = str_decode(a, &a_off, STR_NO_LIMIT);
     583                cb = str_decode(b, &b_off, STR_NO_LIMIT);
     584
     585                if (ca == '\0' || cb == '\0' || ca != cb)
     586                        break;
     587                ++i;
     588        }
     589
     590        return i;
     591}
     592
     593static void tinput_text_complete(tinput_t *ti)
     594{
     595        void *state;
     596        size_t cstart;
     597        char *ctmp;
     598        char **compl;           /* Array of completions */
     599        size_t compl_len;       /* Current length of @c compl array */
     600        size_t cnum;
     601        size_t i;
     602        int rc;
     603
     604        if (ti->compl_ops == NULL)
     605                return;
     606
     607        /*
     608         * Obtain list of all possible completions (growing array).
     609         */
     610
     611        rc = (*ti->compl_ops->init)(ti->buffer, ti->pos, &cstart, &state);
     612        if (rc != EOK)
     613                return;
     614
     615        cnum = 0;
     616
     617        compl_len = 1;
     618        compl = malloc(compl_len * sizeof(char *));
     619        if (compl == NULL) {
     620                printf("Error: Out of memory.\n");
     621                return;
     622        }
     623
     624        while (true) {
     625                rc = (*ti->compl_ops->get_next)(state, &ctmp);
     626                if (rc != EOK)
     627                        break;
     628
     629                if (cnum >= compl_len) {
     630                        /* Extend array */
     631                        compl_len = 2 * compl_len;
     632                        compl = realloc(compl, compl_len * sizeof(char *));
     633                        if (compl == NULL) {
     634                                printf("Error: Out of memory.\n");
     635                                break;
     636                        }
     637                }
     638
     639                compl[cnum] = str_dup(ctmp);
     640                if (compl[cnum] == NULL) {
     641                        printf("Error: Out of memory.\n");
     642                        break;
     643                }
     644                cnum++;
     645        }
     646
     647        (*ti->compl_ops->fini)(state);
     648
     649        if (cnum > 1) {
     650                /*
     651                 * More than one match. Determine maximum common prefix.
     652                 */
     653                size_t cplen;
     654
     655                cplen = str_length(compl[0]);
     656                for (i = 1; i < cnum; i++)
     657                        cplen = min(cplen, common_pref_len(compl[0], compl[i]));
     658
     659                /* Compute how many bytes we should skip. */
     660                size_t istart = str_lsize(compl[0], ti->pos - cstart);
     661
     662                if (cplen > istart) {
     663                        /* Insert common prefix. */
     664
     665                        /* Copy remainder of common prefix. */
     666                        char *cpref = str_ndup(compl[0] + istart,
     667                            str_lsize(compl[0], cplen - istart));
     668
     669                        /* Insert it. */
     670                        tinput_insert_string(ti, cpref);
     671                        free(cpref);
     672                } else {
     673                        /* No common prefix. Sort and display all entries. */
     674
     675                        qsort(compl, cnum, sizeof(char *), compl_cmp, NULL);
     676
     677                        tinput_jump_after(ti);
     678                        for (i = 0; i < cnum; i++)
     679                                printf("%s\n", compl[i]);
     680                        tinput_display(ti);
     681                }
     682        } else if (cnum == 1) {
     683                /*
     684                 * We have exactly one match. Insert it.
     685                 */
     686
     687                /* Compute how many bytes of completion string we should skip. */
     688                size_t istart = str_lsize(compl[0], ti->pos - cstart);
     689
     690                /* Insert remainder of completion string at current position. */
     691                tinput_insert_string(ti, compl[0] + istart);
     692        }
     693
     694        for (i = 0; i < cnum; i++)
     695                free(compl[i]);
     696        free(compl);
     697}
     698
    513699/** Initialize text input field.
    514700 *
     
    521707        ti->hpos = 0;
    522708        ti->history[0] = NULL;
     709}
     710
     711/** Set prompt string.
     712 *
     713 * @param ti            Text input
     714 * @param prompt        Prompt string
     715 *
     716 * @return              EOK on success, ENOMEM if out of memory.
     717 */
     718int tinput_set_prompt(tinput_t *ti, const char *prompt)
     719{
     720        if (ti->prompt != NULL)
     721                free(ti->prompt);
     722       
     723        ti->prompt = str_dup(prompt);
     724        if (ti->prompt == NULL)
     725                return ENOMEM;
     726       
     727        return EOK;
     728}
     729
     730/** Set completion ops.
     731 *
     732 * Set pointer to completion ops structure that will be used for text
     733 * completion.
     734 */
     735void tinput_set_compl_ops(tinput_t *ti, tinput_compl_ops_t *compl_ops)
     736{
     737        ti->compl_ops = compl_ops;
    523738}
    524739
     
    539754                return EIO;
    540755       
    541         if (console_get_pos(ti->console, &ti->col0, &ti->row0) != EOK)
    542                 return EIO;
    543        
    544756        ti->pos = 0;
    545757        ti->sel_start = 0;
     
    549761        ti->exit_clui = false;
    550762       
     763        if (tinput_display(ti) != EOK)
     764                return EIO;
     765       
    551766        while (!ti->done) {
    552767                console_flush(ti->console);
     
    714929                tinput_history_seek(ti, -1);
    715930                break;
     931        case KC_TAB:
     932                tinput_text_complete(ti);
     933                break;
    716934        default:
    717935                break;
  • uspace/lib/clui/tinput.h

    r15f3c3f r86ffa27f  
    11/*
    2  * Copyright (c) 2010 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3737#define LIBCLUI_TINPUT_H_
    3838
    39 #include <stdio.h>
     39#include <adt/list.h>
    4040#include <async.h>
    4141#include <inttypes.h>
    4242#include <io/console.h>
     43#include <stdio.h>
    4344
    4445#define HISTORY_LEN     10
    4546#define INPUT_MAX_SIZE  1024
     47
     48/** Begin enumeration of text completions.
     49 *
     50 * When user requests text completion, tinput will call this function to start
     51 * text completion operation. @a *cstart should be set to the position
     52 * (character index) of the first character of the 'word' that is being
     53 * completed. The resulting text is obtained by replacing the range of text
     54 * starting at @a *cstart and ending at @a pos with the completion text.
     55 *
     56 * The function can pass information to the get_next and fini functions
     57 * via @a state. The init function allocates the state object and stores
     58 * a pointer to it to @a *state. The fini function destroys the state object.
     59 *
     60 * @param text          Current contents of edit buffer (null-terminated).
     61 * @param pos           Current caret position.
     62 * @param cstart        Output, position in text where completion begins from.
     63 * @param state         Output, pointer to a client state object.
     64 *
     65 * @return              EOK on success, negative error code on failure.
     66 */
     67typedef int (*tinput_compl_init_fn)(wchar_t *text, size_t pos, size_t *cstart,
     68    void **state);
     69
     70/** Obtain one text completion alternative.
     71 *
     72 * Upon success the function sets @a *compl to point to a string, the
     73 * completion text. The caller (Tinput) should not modify or free the text.
     74 * The pointer is only valid until the next invocation of any completion
     75 * function.
     76 *
     77 * @param state         Pointer to state object created by the init funtion.
     78 * @param compl         Output, the completion text, ownership retained.
     79 *
     80 * @return              EOK on success, negative error code on failure.
     81 */
     82typedef int (*tinput_compl_get_next_fn)(void *state, char **compl);
     83
     84
     85/** Finish enumeration of text completions.
     86 *
     87 * The function must deallocate any state information allocated by the init
     88 * function or temporary data allocated by the get_next function.
     89 *
     90 * @param state         Pointer to state object created by the init funtion.
     91 */
     92typedef void (*tinput_compl_fini_fn)(void *state);
     93
     94/** Text completion ops. */
     95typedef struct {
     96        tinput_compl_init_fn init;
     97        tinput_compl_get_next_fn get_next;
     98        tinput_compl_fini_fn fini;
     99} tinput_compl_ops_t;
    46100
    47101/** Text input field (command line).
     
    53107        console_ctrl_t *console;
    54108       
     109        /** Prompt string */
     110        char *prompt;
     111       
     112        /** Completion ops. */
     113        tinput_compl_ops_t *compl_ops;
     114       
    55115        /** Buffer holding text currently being edited */
    56116        wchar_t buffer[INPUT_MAX_SIZE + 1];
    57117       
    58         /** Screen coordinates of the top-left corner of the text field */
    59         sysarg_t col0;
    60         sysarg_t row0;
     118        /** Linear position on screen where the prompt starts */
     119        unsigned prompt_coord;
     120        /** Linear position on screen where the text field starts */
     121        unsigned text_coord;
    61122       
    62123        /** Screen dimensions */
     
    90151
    91152extern tinput_t *tinput_new(void);
     153extern int tinput_set_prompt(tinput_t *, const char *);
     154extern void tinput_set_compl_ops(tinput_t *, tinput_compl_ops_t *);
    92155extern void tinput_destroy(tinput_t *);
    93156extern int tinput_read(tinput_t *, char **);
  • uspace/lib/drv/generic/driver.c

    r15f3c3f r86ffa27f  
    314314                    " %" PRIun " was found.\n", driver->name, handle);
    315315                async_answer_0(iid, ENOENT);
     316                return;
     317        }
     318       
     319        if (fun->conn_handler != NULL) {
     320                /* Driver has a custom connection handler. */
     321                (*fun->conn_handler)(iid, icall, (void *)fun);
    316322                return;
    317323        }
     
    614620                return ENOMEM;
    615621       
    616         match_id->id = match_id_str;
     622        match_id->id = str_dup(match_id_str);
    617623        match_id->score = 90;
    618624       
  • uspace/lib/drv/include/ddf/driver.h

    r15f3c3f r86ffa27f  
    118118        /** Implementation of operations provided by this function */
    119119        ddf_dev_ops_t *ops;
     120        /** Connection handler or @c NULL to use the DDF default handler. */
     121        async_client_conn_t conn_handler;
    120122       
    121123        /** Link in the list of functions handled by the driver */
  • uspace/lib/ext2/libext2_directory.c

    r15f3c3f r86ffa27f  
    8686 * @param fs pointer to filesystem structure
    8787 * @param inode pointer to inode reference structure
     88 * @param pos position within inode to start at, 0 is the first entry
    8889 * @return EOK on success or negative error code on failure
    8990 */
    9091int ext2_directory_iterator_init(ext2_directory_iterator_t *it,
    91     ext2_filesystem_t *fs, ext2_inode_ref_t *inode_ref)
    92 {
    93         int rc;
    94         uint32_t block_id;
    95         uint32_t block_size;
    96        
     92    ext2_filesystem_t *fs, ext2_inode_ref_t *inode_ref, aoff64_t pos)
     93{       
    9794        it->inode_ref = inode_ref;
    9895        it->fs = fs;
    99        
    100         /* Get the first data block, so we can get the first entry */
    101         rc = ext2_filesystem_get_inode_data_block_index(fs, inode_ref->inode, 0,
    102             &block_id);
    103         if (rc != EOK) {
    104                 return rc;
    105         }
    106        
    107         rc = block_get(&it->current_block, fs->device, block_id, 0);
    108         if (rc != EOK) {
    109                 return rc;
    110         }
    111        
    112         block_size = ext2_superblock_get_block_size(fs->superblock);
    113        
    114         it->current_offset = 0;
    115         return ext2_directory_iterator_set(it, block_size);
     96        it->current = NULL;
     97        it->current_offset = 0;
     98        it->current_block = NULL;
     99       
     100        return ext2_directory_iterator_seek(it, pos);
    116101}
    117102
     
    124109int ext2_directory_iterator_next(ext2_directory_iterator_t *it)
    125110{
     111        uint16_t skip;
     112       
     113        assert(it->current != NULL);
     114       
     115        skip = ext2_directory_entry_ll_get_entry_length(it->current);
     116       
     117        return ext2_directory_iterator_seek(it, it->current_offset + skip);
     118}
     119
     120/**
     121 * Seek the directory iterator to the given byte offset within the inode.
     122 *
     123 * @param it pointer to iterator to initialize
     124 * @return EOK on success or negative error code on failure
     125 */
     126int ext2_directory_iterator_seek(ext2_directory_iterator_t *it, aoff64_t pos)
     127{
    126128        int rc;
    127         uint16_t skip;
     129       
    128130        uint64_t size;
    129131        aoff64_t current_block_idx;
     
    132134        uint32_t block_size;
    133135       
    134         assert(it->current != NULL);
    135        
    136         skip = ext2_directory_entry_ll_get_entry_length(it->current);
    137136        size = ext2_inode_get_size(it->fs->superblock, it->inode_ref->inode);
    138137       
     138        /* The iterator is not valid until we seek to the desired position */
     139        it->current = NULL;
     140       
    139141        /* Are we at the end? */
    140         if (it->current_offset + skip >= size) {
    141                 rc = block_put(it->current_block);
    142                 it->current_block = NULL;
    143                 it->current = NULL;
    144                 if (rc != EOK) {
    145                         return rc;
     142        if (pos >= size) {             
     143                if (it->current_block) {
     144                        rc = block_put(it->current_block);
     145                        it->current_block = NULL;
     146                        if (rc != EOK) {
     147                                return rc;
     148                        }
    146149                }
    147150               
    148                 it->current_offset += skip;
     151                it->current_offset = pos;
    149152                return EOK;
    150153        }
     
    152155        block_size = ext2_superblock_get_block_size(it->fs->superblock);
    153156        current_block_idx = it->current_offset / block_size;
    154         next_block_idx = (it->current_offset + skip) / block_size;
    155        
    156         /* If we are moving accross block boundary,
     157        next_block_idx = pos / block_size;
     158       
     159        /* If we don't have a block or are moving accross block boundary,
    157160         * we need to get another block
    158161         */
    159         if (current_block_idx != next_block_idx) {
    160                 rc = block_put(it->current_block);
    161                 it->current_block = NULL;
    162                 it->current = NULL;
    163                 if (rc != EOK) {
    164                         return rc;
     162        if (it->current_block == NULL || current_block_idx != next_block_idx) {         
     163                if (it->current_block) {
     164                        rc = block_put(it->current_block);
     165                        it->current_block = NULL;
     166                        if (rc != EOK) {
     167                                return rc;
     168                        }
    165169                }
    166170               
     
    179183        }
    180184       
    181         it->current_offset += skip;
     185        it->current_offset = pos;
    182186        return ext2_directory_iterator_set(it, block_size);
    183187}
    184188
     189/** Setup the entry at the current iterator offset.
     190 *
     191 * This function checks the validity of the directory entry,
     192 * before setting the data pointer.
     193 *
     194 * @return EOK on success or error code on failure
     195 */
    185196static int ext2_directory_iterator_set(ext2_directory_iterator_t *it,
    186197    uint32_t block_size)
  • uspace/lib/ext2/libext2_directory.h

    r15f3c3f r86ffa27f  
    7171
    7272extern int ext2_directory_iterator_init(ext2_directory_iterator_t *,
    73     ext2_filesystem_t *, ext2_inode_ref_t *);
     73    ext2_filesystem_t *, ext2_inode_ref_t *, aoff64_t);
    7474extern int ext2_directory_iterator_next(ext2_directory_iterator_t *);
     75extern int ext2_directory_iterator_seek(ext2_directory_iterator_t *, aoff64_t pos);
    7576extern int ext2_directory_iterator_fini(ext2_directory_iterator_t *);
    7677
  • uspace/lib/fs/libfs.c

    r15f3c3f r86ffa27f  
    4545#include <mem.h>
    4646#include <sys/stat.h>
     47#include <stdlib.h>
    4748
    4849#define on_error(rc, action) \
     
    6162        } while (0)
    6263
     64static fs_reg_t reg;
     65
     66static vfs_out_ops_t *vfs_out_ops = NULL;
     67static libfs_ops_t *libfs_ops = NULL;
     68
     69static void libfs_mount(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *);
     70static void libfs_unmount(libfs_ops_t *, ipc_callid_t, ipc_call_t *);
     71static void libfs_lookup(libfs_ops_t *, fs_handle_t, ipc_callid_t,
     72    ipc_call_t *);
     73static void libfs_stat(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *);
     74static void libfs_open_node(libfs_ops_t *, fs_handle_t, ipc_callid_t,
     75    ipc_call_t *);
     76
     77static void vfs_out_mounted(ipc_callid_t rid, ipc_call_t *req)
     78{
     79        service_id_t service_id = (service_id_t) IPC_GET_ARG1(*req);
     80        char *opts;
     81        int rc;
     82       
     83        /* Accept the mount options. */
     84        rc = async_data_write_accept((void **) &opts, true, 0, 0, 0, NULL);
     85        if (rc != EOK) {
     86                async_answer_0(rid, rc);
     87                return;
     88        }
     89
     90        fs_index_t index;
     91        aoff64_t size;
     92        unsigned lnkcnt;
     93        rc = vfs_out_ops->mounted(service_id, opts, &index, &size, &lnkcnt);
     94
     95        if (rc == EOK)
     96                async_answer_4(rid, EOK, index, LOWER32(size), UPPER32(size),
     97                    lnkcnt);
     98        else
     99                async_answer_0(rid, rc);
     100
     101        free(opts);
     102}
     103
     104static void vfs_out_mount(ipc_callid_t rid, ipc_call_t *req)
     105{
     106        libfs_mount(libfs_ops, reg.fs_handle, rid, req);
     107}
     108
     109static void vfs_out_unmounted(ipc_callid_t rid, ipc_call_t *req)
     110{
     111        service_id_t service_id = (service_id_t) IPC_GET_ARG1(*req);
     112        int rc;
     113
     114        rc = vfs_out_ops->unmounted(service_id);
     115
     116        async_answer_0(rid, rc);
     117}
     118
     119static void vfs_out_unmount(ipc_callid_t rid, ipc_call_t *req)
     120{
     121               
     122        libfs_unmount(libfs_ops, rid, req);
     123}
     124
     125static void vfs_out_lookup(ipc_callid_t rid, ipc_call_t *req)
     126{
     127        libfs_lookup(libfs_ops, reg.fs_handle, rid, req);
     128}
     129
     130static void vfs_out_read(ipc_callid_t rid, ipc_call_t *req)
     131{
     132        service_id_t service_id = (service_id_t) IPC_GET_ARG1(*req);
     133        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*req);
     134        aoff64_t pos = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*req),
     135            IPC_GET_ARG4(*req));
     136        size_t rbytes;
     137        int rc;
     138
     139        rc = vfs_out_ops->read(service_id, index, pos, &rbytes);
     140
     141        if (rc == EOK)
     142                async_answer_1(rid, EOK, rbytes);
     143        else
     144                async_answer_0(rid, rc);
     145}
     146
     147static void vfs_out_write(ipc_callid_t rid, ipc_call_t *req)
     148{
     149        service_id_t service_id = (service_id_t) IPC_GET_ARG1(*req);
     150        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*req);
     151        aoff64_t pos = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*req),
     152            IPC_GET_ARG4(*req));
     153        size_t wbytes;
     154        aoff64_t nsize;
     155        int rc;
     156
     157        rc = vfs_out_ops->write(service_id, index, pos, &wbytes, &nsize);
     158
     159        if (rc == EOK)
     160                async_answer_3(rid, EOK, wbytes, LOWER32(nsize), UPPER32(nsize));
     161        else
     162                async_answer_0(rid, rc);
     163}
     164
     165static void vfs_out_truncate(ipc_callid_t rid, ipc_call_t *req)
     166{
     167        service_id_t service_id = (service_id_t) IPC_GET_ARG1(*req);
     168        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*req);
     169        aoff64_t size = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*req),
     170            IPC_GET_ARG4(*req));
     171        int rc;
     172
     173        rc = vfs_out_ops->truncate(service_id, index, size);
     174
     175        async_answer_0(rid, rc);
     176}
     177
     178static void vfs_out_close(ipc_callid_t rid, ipc_call_t *req)
     179{
     180        service_id_t service_id = (service_id_t) IPC_GET_ARG1(*req);
     181        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*req);
     182        int rc;
     183
     184        rc = vfs_out_ops->close(service_id, index);
     185
     186        async_answer_0(rid, rc);
     187}
     188
     189static void vfs_out_destroy(ipc_callid_t rid, ipc_call_t *req)
     190{
     191        service_id_t service_id = (service_id_t) IPC_GET_ARG1(*req);
     192        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*req);
     193        int rc;
     194
     195        rc = vfs_out_ops->destroy(service_id, index);
     196
     197        async_answer_0(rid, rc);
     198}
     199
     200static void vfs_out_open_node(ipc_callid_t rid, ipc_call_t *req)
     201{
     202        libfs_open_node(libfs_ops, reg.fs_handle, rid, req);
     203}
     204
     205static void vfs_out_stat(ipc_callid_t rid, ipc_call_t *req)
     206{
     207        libfs_stat(libfs_ops, reg.fs_handle, rid, req);
     208}
     209
     210static void vfs_out_sync(ipc_callid_t rid, ipc_call_t *req)
     211{
     212        service_id_t service_id = (service_id_t) IPC_GET_ARG1(*req);
     213        fs_index_t index = (fs_index_t) IPC_GET_ARG2(*req);
     214        int rc;
     215
     216        rc = vfs_out_ops->sync(service_id, index);
     217
     218        async_answer_0(rid, rc);
     219}
     220
     221static void vfs_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
     222{
     223        if (iid) {
     224                /*
     225                 * This only happens for connections opened by
     226                 * IPC_M_CONNECT_ME_TO calls as opposed to callback connections
     227                 * created by IPC_M_CONNECT_TO_ME.
     228                 */
     229                async_answer_0(iid, EOK);
     230        }
     231       
     232        while (true) {
     233                ipc_call_t call;
     234                ipc_callid_t callid = async_get_call(&call);
     235               
     236                if (!IPC_GET_IMETHOD(call))
     237                        return;
     238               
     239                switch (IPC_GET_IMETHOD(call)) {
     240                case VFS_OUT_MOUNTED:
     241                        vfs_out_mounted(callid, &call);
     242                        break;
     243                case VFS_OUT_MOUNT:
     244                        vfs_out_mount(callid, &call);
     245                        break;
     246                case VFS_OUT_UNMOUNTED:
     247                        vfs_out_unmounted(callid, &call);
     248                        break;
     249                case VFS_OUT_UNMOUNT:
     250                        vfs_out_unmount(callid, &call);
     251                        break;
     252                case VFS_OUT_LOOKUP:
     253                        vfs_out_lookup(callid, &call);
     254                        break;
     255                case VFS_OUT_READ:
     256                        vfs_out_read(callid, &call);
     257                        break;
     258                case VFS_OUT_WRITE:
     259                        vfs_out_write(callid, &call);
     260                        break;
     261                case VFS_OUT_TRUNCATE:
     262                        vfs_out_truncate(callid, &call);
     263                        break;
     264                case VFS_OUT_CLOSE:
     265                        vfs_out_close(callid, &call);
     266                        break;
     267                case VFS_OUT_DESTROY:
     268                        vfs_out_destroy(callid, &call);
     269                        break;
     270                case VFS_OUT_OPEN_NODE:
     271                        vfs_out_open_node(callid, &call);
     272                        break;
     273                case VFS_OUT_STAT:
     274                        vfs_out_stat(callid, &call);
     275                        break;
     276                case VFS_OUT_SYNC:
     277                        vfs_out_sync(callid, &call);
     278                        break;
     279                default:
     280                        async_answer_0(callid, ENOTSUP);
     281                        break;
     282                }
     283        }
     284}
     285
    63286/** Register file system server.
    64287 *
     
    68291 *
    69292 * @param sess Session for communication with VFS.
    70  * @param reg  File system registration structure. It will be
    71  *             initialized by this function.
    72293 * @param info VFS info structure supplied by the file system
    73294 *             implementation.
    74  * @param conn Connection fibril for handling all calls originating in
    75  *             VFS.
     295 * @param vops Address of the vfs_out_ops_t structure.
     296 * @param lops Address of the libfs_ops_t structure.
    76297 *
    77298 * @return EOK on success or a non-zero error code on errror.
    78299 *
    79300 */
    80 int fs_register(async_sess_t *sess, fs_reg_t *reg, vfs_info_t *info,
    81     async_client_conn_t conn)
     301int fs_register(async_sess_t *sess, vfs_info_t *info, vfs_out_ops_t *vops,
     302    libfs_ops_t *lops)
    82303{
    83304        /*
     
    104325       
    105326        /*
     327         * Set VFS_OUT and libfs operations.
     328         */
     329        vfs_out_ops = vops;
     330        libfs_ops = lops;
     331
     332        /*
    106333         * Ask VFS for callback connection.
    107334         */
    108         async_connect_to_me(exch, 0, 0, 0, conn, NULL);
     335        async_connect_to_me(exch, 0, 0, 0, vfs_connection, NULL);
    109336       
    110337        /*
    111338         * Allocate piece of address space for PLB.
    112339         */
    113         reg->plb_ro = as_get_mappable_page(PLB_SIZE);
    114         if (!reg->plb_ro) {
     340        reg.plb_ro = as_get_mappable_page(PLB_SIZE);
     341        if (!reg.plb_ro) {
    115342                async_exchange_end(exch);
    116343                async_wait_for(req, NULL);
     
    121348         * Request sharing the Path Lookup Buffer with VFS.
    122349         */
    123         rc = async_share_in_start_0_0(exch, reg->plb_ro, PLB_SIZE);
     350        rc = async_share_in_start_0_0(exch, reg.plb_ro, PLB_SIZE);
    124351       
    125352        async_exchange_end(exch);
     
    134361         */
    135362        async_wait_for(req, NULL);
    136         reg->fs_handle = (int) IPC_GET_ARG1(answer);
     363        reg.fs_handle = (int) IPC_GET_ARG1(answer);
    137364       
    138365        /*
     
    140367         * the same connection fibril as well.
    141368         */
    142         async_set_client_connection(conn);
     369        async_set_client_connection(vfs_connection);
    143370       
    144371        return IPC_GET_RETVAL(answer);
     
    151378
    152379void libfs_mount(libfs_ops_t *ops, fs_handle_t fs_handle, ipc_callid_t rid,
    153     ipc_call_t *request)
    154 {
    155         service_id_t mp_service_id = (service_id_t) IPC_GET_ARG1(*request);
    156         fs_index_t mp_fs_index = (fs_index_t) IPC_GET_ARG2(*request);
    157         fs_handle_t mr_fs_handle = (fs_handle_t) IPC_GET_ARG3(*request);
    158         service_id_t mr_service_id = (service_id_t) IPC_GET_ARG4(*request);
     380    ipc_call_t *req)
     381{
     382        service_id_t mp_service_id = (service_id_t) IPC_GET_ARG1(*req);
     383        fs_index_t mp_fs_index = (fs_index_t) IPC_GET_ARG2(*req);
     384        fs_handle_t mr_fs_handle = (fs_handle_t) IPC_GET_ARG3(*req);
     385        service_id_t mr_service_id = (service_id_t) IPC_GET_ARG4(*req);
    159386       
    160387        async_sess_t *mountee_sess = async_clone_receive(EXCHANGE_PARALLEL);
     
    208435         * Do not release the FS node so that it stays in memory.
    209436         */
    210         async_answer_3(rid, rc, IPC_GET_ARG1(answer), IPC_GET_ARG2(answer),
    211             IPC_GET_ARG3(answer));
    212 }
    213 
    214 void libfs_unmount(libfs_ops_t *ops, ipc_callid_t rid, ipc_call_t *request)
    215 {
    216         service_id_t mp_service_id = (service_id_t) IPC_GET_ARG1(*request);
    217         fs_index_t mp_fs_index = (fs_index_t) IPC_GET_ARG2(*request);
     437        async_answer_4(rid, rc, IPC_GET_ARG1(answer), IPC_GET_ARG2(answer),
     438            IPC_GET_ARG3(answer), IPC_GET_ARG4(answer));
     439}
     440
     441void libfs_unmount(libfs_ops_t *ops, ipc_callid_t rid, ipc_call_t *req)
     442{
     443        service_id_t mp_service_id = (service_id_t) IPC_GET_ARG1(*req);
     444        fs_index_t mp_fs_index = (fs_index_t) IPC_GET_ARG2(*req);
    218445        fs_node_t *fn;
    219446        int res;
     
    259486}
    260487
     488static char plb_get_char(unsigned pos)
     489{
     490        return reg.plb_ro[pos % PLB_SIZE];
     491}
     492
    261493/** Lookup VFS triplet by name in the file system name space.
    262494 *
     
    273505 */
    274506void libfs_lookup(libfs_ops_t *ops, fs_handle_t fs_handle, ipc_callid_t rid,
    275     ipc_call_t *request)
    276 {
    277         unsigned int first = IPC_GET_ARG1(*request);
    278         unsigned int last = IPC_GET_ARG2(*request);
     507    ipc_call_t *req)
     508{
     509        unsigned int first = IPC_GET_ARG1(*req);
     510        unsigned int last = IPC_GET_ARG2(*req);
    279511        unsigned int next = first;
    280         service_id_t service_id = IPC_GET_ARG3(*request);
    281         int lflag = IPC_GET_ARG4(*request);
    282         fs_index_t index = IPC_GET_ARG5(*request);
     512        service_id_t service_id = IPC_GET_ARG3(*req);
     513        int lflag = IPC_GET_ARG4(*req);
     514        fs_index_t index = IPC_GET_ARG5(*req);
    283515        char component[NAME_MAX + 1];
    284516        int len;
     
    298530                async_exch_t *exch = async_exchange_begin(cur->mp_data.sess);
    299531                async_forward_slow(rid, exch, VFS_OUT_LOOKUP, next, last,
    300                     cur->mp_data.service_id, lflag, index, IPC_FF_ROUTE_FROM_ME);
     532                    cur->mp_data.service_id, lflag, index,
     533                    IPC_FF_ROUTE_FROM_ME);
    301534                async_exchange_end(exch);
    302535               
     
    306539       
    307540        /* Eat slash */
    308         if (ops->plb_get_char(next) == '/')
     541        if (plb_get_char(next) == '/')
    309542                next++;
    310543       
     
    319552                /* Collect the component */
    320553                len = 0;
    321                 while ((next <= last) && (ops->plb_get_char(next) != '/')) {
     554                while ((next <= last) && (plb_get_char(next) != '/')) {
    322555                        if (len + 1 == NAME_MAX) {
    323556                                /* Component length overflow */
     
    325558                                goto out;
    326559                        }
    327                         component[len++] = ops->plb_get_char(next);
     560                        component[len++] = plb_get_char(next);
    328561                        /* Process next character */
    329562                        next++;
     
    357590                       
    358591                        async_exch_t *exch = async_exchange_begin(tmp->mp_data.sess);
    359                         async_forward_slow(rid, exch, VFS_OUT_LOOKUP, next, last,
    360                             tmp->mp_data.service_id, lflag, index,
     592                        async_forward_slow(rid, exch, VFS_OUT_LOOKUP, next,
     593                            last, tmp->mp_data.service_id, lflag, index,
    361594                            IPC_FF_ROUTE_FROM_ME);
    362595                        async_exchange_end(exch);
     
    451684                        len = 0;
    452685                        while (next <= last) {
    453                                 if (ops->plb_get_char(next) == '/') {
     686                                if (plb_get_char(next) == '/') {
    454687                                        /* More than one component */
    455688                                        async_answer_0(rid, ENOENT);
     
    463696                                }
    464697                               
    465                                 component[len++] = ops->plb_get_char(next);
     698                                component[len++] = plb_get_char(next);
    466699                                /* Process next character */
    467700                                next++;
     
    637870        rc = ops->node_open(fn);
    638871        aoff64_t size = ops->size_get(fn);
    639         async_answer_4(rid, rc, LOWER32(size), UPPER32(size), ops->lnkcnt_get(fn),
     872        async_answer_4(rid, rc, LOWER32(size), UPPER32(size),
     873            ops->lnkcnt_get(fn),
    640874            (ops->is_file(fn) ? L_FILE : 0) | (ops->is_directory(fn) ? L_DIRECTORY : 0));
    641875       
  • uspace/lib/fs/libfs.h

    r15f3c3f r86ffa27f  
    4343
    4444typedef struct {
     45        int (* mounted)(service_id_t, const char *, fs_index_t *, aoff64_t *,
     46            unsigned *);
     47        int (* unmounted)(service_id_t);
     48        int (* read)(service_id_t, fs_index_t, aoff64_t, size_t *);
     49        int (* write)(service_id_t, fs_index_t, aoff64_t, size_t *,
     50            aoff64_t *);
     51        int (* truncate)(service_id_t, fs_index_t, aoff64_t);
     52        int (* close)(service_id_t, fs_index_t);
     53        int (* destroy)(service_id_t, fs_index_t);
     54        int (* sync)(service_id_t, fs_index_t);
     55} vfs_out_ops_t;
     56
     57typedef struct {
    4558        bool mp_active;
    4659        async_sess_t *sess;
     
    7184        int (* has_children)(bool *, fs_node_t *);
    7285        /*
    73          * The second set of methods are usually mere getters that do not return
    74          * an integer error code.
     86         * The second set of methods are usually mere getters that do not
     87         * return an integer error code.
    7588         */
    7689        fs_index_t (* index_get)(fs_node_t *);
    7790        aoff64_t (* size_get)(fs_node_t *);
    7891        unsigned int (* lnkcnt_get)(fs_node_t *);
    79         char (* plb_get_char)(unsigned pos);
    8092        bool (* is_directory)(fs_node_t *);
    8193        bool (* is_file)(fs_node_t *);
     
    88100} fs_reg_t;
    89101
    90 extern int fs_register(async_sess_t *, fs_reg_t *, vfs_info_t *,
    91     async_client_conn_t);
     102extern int fs_register(async_sess_t *, vfs_info_t *, vfs_out_ops_t *,
     103    libfs_ops_t *);
    92104
    93105extern void fs_node_initialize(fs_node_t *);
    94 
    95 extern void libfs_mount(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *);
    96 extern void libfs_unmount(libfs_ops_t *, ipc_callid_t, ipc_call_t *);
    97 extern void libfs_lookup(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *);
    98 extern void libfs_stat(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *);
    99 extern void libfs_open_node(libfs_ops_t *, fs_handle_t, ipc_callid_t,
    100     ipc_call_t *);
    101106
    102107#endif
  • uspace/lib/net/il/ip_remote.c

    r15f3c3f r86ffa27f  
    123123 *
    124124 */
    125 int ip_device_req_remote(async_sess_t *sess, device_id_t device_id)
    126 {
    127         return generic_device_req_remote(sess, NET_IP_DEVICE, device_id, 0, 0);
     125int ip_device_req_remote(async_sess_t *sess, device_id_t device_id,
     126    services_t service)
     127{
     128        return generic_device_req_remote(sess, NET_IP_DEVICE, device_id, 0,
     129            service);
    128130}
    129131
  • uspace/lib/net/include/ip_remote.h

    r15f3c3f r86ffa27f  
    4848extern int ip_received_error_msg_remote(async_sess_t *, device_id_t, packet_t *,
    4949    services_t, services_t);
    50 extern int ip_device_req_remote(async_sess_t *, device_id_t);
     50extern int ip_device_req_remote(async_sess_t *, device_id_t, services_t);
    5151extern int ip_add_route_req_remote(async_sess_t *, device_id_t, in_addr_t,
    5252    in_addr_t, in_addr_t);
  • uspace/lib/net/include/netif_skel.h

    r15f3c3f r86ffa27f  
    205205extern packet_t *netif_packet_get_1(size_t);
    206206
    207 extern int netif_module_start(sysarg_t);
     207extern int netif_module_start(void);
    208208
    209209#endif
  • uspace/lib/net/include/nil_remote.h

    r15f3c3f r86ffa27f  
    5858            packet_get_id(packet), sender, 0)
    5959
    60 #define nil_device_req(sess, device_id, mtu) \
    61         generic_device_req_remote(sess, NET_NIL_DEVICE, device_id, mtu, 0)\
     60#define nil_device_req(sess, device_id, mtu, netif_service) \
     61        generic_device_req_remote(sess, NET_NIL_DEVICE, device_id, mtu, \
     62            netif_service)
    6263
    6364extern int nil_device_state_msg(async_sess_t *, device_id_t, sysarg_t);
  • uspace/lib/net/netif/netif_skel.c

    r15f3c3f r86ffa27f  
    228228}
    229229
     230/** Register the device notification receiver,
     231 *
     232 * Register a network interface layer module as the device
     233 * notification receiver.
     234 *
     235 * @param[in] sess      Session to the network interface layer module.
     236 *
     237 * @return EOK on success.
     238 * @return ELIMIT if there is another module registered.
     239 *
     240 */
     241static int register_message(async_sess_t *sess)
     242{
     243        fibril_rwlock_write_lock(&netif_globals.lock);
     244        if (netif_globals.nil_sess != NULL) {
     245                fibril_rwlock_write_unlock(&netif_globals.lock);
     246                return ELIMIT;
     247        }
     248       
     249        netif_globals.nil_sess = sess;
     250       
     251        fibril_rwlock_write_unlock(&netif_globals.lock);
     252        return EOK;
     253}
     254
    230255/** Process the netif module messages.
    231256 *
     
    257282                return EOK;
    258283       
     284        async_sess_t *callback =
     285            async_callback_receive_start(EXCHANGE_SERIALIZE, call);
     286        if (callback)
     287                return register_message(callback);
     288       
    259289        switch (IPC_GET_IMETHOD(*call)) {
    260290        case NET_NETIF_PROBE:
     
    358388 * messages in an infinite loop.
    359389 *
    360  * @param[in] nil_service Network interface layer service.
    361  *
    362390 * @return EOK on success.
    363391 * @return Other error codes as defined for each specific module
     
    365393 *
    366394 */
    367 int netif_module_start(sysarg_t nil_service)
     395int netif_module_start(void)
    368396{
    369397        async_set_client_connection(netif_client_connection);
    370398       
    371399        netif_globals.sess = connect_to_service(SERVICE_NETWORKING);
    372         netif_globals.nil_sess = connect_to_service(nil_service);
     400        netif_globals.nil_sess = NULL;
    373401        netif_device_map_initialize(&netif_globals.device_map);
    374402       
  • uspace/lib/scsi/Makefile

    r15f3c3f r86ffa27f  
    11#
    2 # Copyright (c) 2005 Martin Decky
    3 # Copyright (c) 2007 Jakub Jermar
     2# Copyright (c) 2011 Jiri Svoboda
    43# All rights reserved.
    54#
     
    2827#
    2928
    30 USPACE_PREFIX = ../../../..
    31 BINARY = fhc
     29USPACE_PREFIX = ../..
     30EXTRA_CFLAGS = -Iinclude
     31LIBRARY = libscsi
    3232
    3333SOURCES = \
    34         fhc.c
     34        src/spc.c
    3535
    3636include $(USPACE_PREFIX)/Makefile.common
  • uspace/lib/softfloat/arch/mips32/include/functions.h

    r15f3c3f r86ffa27f  
    2727 */
    2828
    29  /** @addtogroup softfloatmips32 mips32
     29/** @addtogroup softfloatmips32 mips32
    3030 * @ingroup sfl
    3131 * @brief softfloat architecture dependent definitions
     
    7272#endif
    7373
    74 
    75  /** @}
     74/** @}
    7675 */
    77 
  • uspace/lib/usb/include/usb/classes/hub.h

    r15f3c3f r86ffa27f  
    119119     */
    120120    uint16_t hub_characteristics;
     121#define HUB_CHAR_POWER_PER_PORT_FLAG  (1 << 0)
     122#define HUB_CHAR_NO_POWER_SWITCH_FLAG (1 << 1)
    121123
    122124    /**
  • uspace/lib/usbhost/include/usb/host/endpoint.h

    r15f3c3f r86ffa27f  
    6161} endpoint_t;
    6262
    63 int endpoint_init(endpoint_t *instance, usb_address_t address,
    64     usb_endpoint_t endpoint, usb_direction_t direction,
    65     usb_transfer_type_t type, usb_speed_t speed, size_t max_packet_size);
     63endpoint_t * endpoint_get(usb_address_t address, usb_endpoint_t endpoint,
     64    usb_direction_t direction, usb_transfer_type_t type, usb_speed_t speed,
     65    size_t max_packet_size);
    6666
    6767void endpoint_destroy(endpoint_t *instance);
  • uspace/lib/usbhost/include/usb/host/usb_endpoint_manager.h

    r15f3c3f r86ffa27f  
    8282    size_t data_size)
    8383{
    84         endpoint_t *ep = malloc(sizeof(endpoint_t));
    85         if (ep == NULL)
     84        endpoint_t *ep = endpoint_get(
     85            address, endpoint, direction, type, speed, max_packet_size);
     86        if (!ep)
    8687                return ENOMEM;
    8788
    88         int ret = endpoint_init(ep, address, endpoint, direction, type, speed,
    89             max_packet_size);
    90         if (ret != EOK) {
    91                 free(ep);
    92                 return ret;
    93         }
    94 
    95         ret = usb_endpoint_manager_register_ep(instance, ep, data_size);
     89        const int ret =
     90            usb_endpoint_manager_register_ep(instance, ep, data_size);
    9691        if (ret != EOK) {
    9792                endpoint_destroy(ep);
    98                 return ret;
    9993        }
    100         return EOK;
     94        return ret;
    10195}
    10296#endif
  • uspace/lib/usbhost/src/batch.c

    r15f3c3f r86ffa27f  
    109109        assert(instance);
    110110        assert(instance->ep);
     111        assert(instance->next_step);
    111112        endpoint_release(instance->ep);
    112113        instance->next_step(instance);
     
    128129        memcpy(instance->buffer, instance->data_buffer, instance->buffer_size);
    129130
    130         usb_log_debug("Batch %p " USB_TRANSFER_BATCH_FMT " completed (%zuB): %s.\n",
     131        usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " completed (%zuB): %s.\n",
    131132            instance, USB_TRANSFER_BATCH_ARGS(*instance),
    132133            instance->transfered_size, str_error(instance->error));
     
    145146        assert(instance->callback_out);
    146147
    147         usb_log_debug("Batch %p " USB_TRANSFER_BATCH_FMT " completed: %s.\n",
     148        usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " completed: %s.\n",
    148149            instance, USB_TRANSFER_BATCH_ARGS(*instance),
    149150            str_error(instance->error));
  • uspace/lib/usbhost/src/endpoint.c

    r15f3c3f r86ffa27f  
    3939#include <usb/host/endpoint.h>
    4040
    41 int endpoint_init(endpoint_t *instance, usb_address_t address,
    42     usb_endpoint_t endpoint, usb_direction_t direction,
    43     usb_transfer_type_t type, usb_speed_t speed, size_t max_packet_size)
     41endpoint_t * endpoint_get(usb_address_t address, usb_endpoint_t endpoint,
     42    usb_direction_t direction, usb_transfer_type_t type, usb_speed_t speed,
     43    size_t max_packet_size)
    4444{
    45         assert(instance);
    46         instance->address = address;
    47         instance->endpoint = endpoint;
    48         instance->direction = direction;
    49         instance->transfer_type = type;
    50         instance->speed = speed;
    51         instance->max_packet_size = max_packet_size;
    52         instance->toggle = 0;
    53         instance->active = false;
    54         fibril_mutex_initialize(&instance->guard);
    55         fibril_condvar_initialize(&instance->avail);
    56         endpoint_clear_hc_data(instance);
    57         return EOK;
     45        endpoint_t *instance = malloc(sizeof(endpoint_t));
     46        if (instance) {
     47                instance->address = address;
     48                instance->endpoint = endpoint;
     49                instance->direction = direction;
     50                instance->transfer_type = type;
     51                instance->speed = speed;
     52                instance->max_packet_size = max_packet_size;
     53                instance->toggle = 0;
     54                instance->active = false;
     55                fibril_mutex_initialize(&instance->guard);
     56                fibril_condvar_initialize(&instance->avail);
     57                endpoint_clear_hc_data(instance);
     58        }
     59        return instance;
    5860}
    5961/*----------------------------------------------------------------------------*/
Note: See TracChangeset for help on using the changeset viewer.