Changes in / [af2a76c:b8e75319] in mainline


Ignore:
Files:
4 added
5 deleted
55 edited

Legend:

Unmodified
Added
Removed
  • .bzrignore

    raf2a76c rb8e75319  
    4545uspace/app/nettest2/nettest2
    4646uspace/app/nettest3/nettest3
    47 uspace/app/nic/nic
    4847uspace/app/nterm/nterm
    4948uspace/app/ping/ping
     
    9594uspace/dist/app/nettest2
    9695uspace/dist/app/nettest3
    97 uspace/dist/app/nic
    9896uspace/dist/app/nterm
    9997uspace/dist/app/ping
  • boot/Makefile.common

    raf2a76c rb8e75319  
    190190        $(USPACE_PATH)/app/mkexfat/mkexfat \
    191191        $(USPACE_PATH)/app/mkmfs/mkmfs \
    192         $(USPACE_PATH)/app/nic/nic \
    193192        $(USPACE_PATH)/app/sbi/sbi \
    194193        $(USPACE_PATH)/app/sportdmp/sportdmp \
  • kernel/arch/amd64/Makefile.inc

    raf2a76c rb8e75319  
    3232
    3333FPU_NO_CFLAGS = -mno-sse -mno-sse2
    34 CMN1 = -m64 -mcmodel=kernel -mno-red-zone -fno-unwind-tables -fno-omit-frame-pointer
     34CMN1 = -m64 -mcmodel=large -mno-red-zone -fno-unwind-tables -fno-omit-frame-pointer
    3535GCC_CFLAGS += $(CMN1)
    3636ICC_CFLAGS += $(CMN1)
  • kernel/arch/amd64/include/arch/mm/km.h

    raf2a76c rb8e75319  
    3838#include <typedefs.h>
    3939
    40 #define KM_AMD64_IDENTITY_START         UINT64_C(0xffffffff80000000)
    41 #define KM_AMD64_IDENTITY_SIZE          UINT64_C(0x0000000080000000)
     40#define KM_AMD64_IDENTITY_START         UINT64_C(0xffff800000000000)
     41#define KM_AMD64_IDENTITY_SIZE          UINT64_C(0x0000400000000000)
    4242
    43 #define KM_AMD64_NON_IDENTITY_START     UINT64_C(0xffff800000000000)
    44 #define KM_AMD64_NON_IDENTITY_SIZE      UINT64_C(0x00007fff80000000)
     43#define KM_AMD64_NON_IDENTITY_START     UINT64_C(0xffffc00000000000)
     44#define KM_AMD64_NON_IDENTITY_SIZE      UINT64_C(0x0000400000000000)
    4545
    4646extern void km_identity_arch_init(void);
  • kernel/arch/amd64/include/arch/mm/page.h

    raf2a76c rb8e75319  
    4444#ifndef __ASM__
    4545
    46 #define KA2PA(x)  (((uintptr_t) (x)) - UINT64_C(0xffffffff80000000))
    47 #define PA2KA(x)  (((uintptr_t) (x)) + UINT64_C(0xffffffff80000000))
     46#define KA2PA(x)  (((uintptr_t) (x)) - UINT64_C(0xffff800000000000))
     47#define PA2KA(x)  (((uintptr_t) (x)) + UINT64_C(0xffff800000000000))
    4848
    4949#else /* __ASM__ */
    5050
    51 #define KA2PA(x)  ((x) - 0xffffffff80000000)
    52 #define PA2KA(x)  ((x) + 0xffffffff80000000)
     51#define KA2PA(x)  ((x) - 0xffff800000000000)
     52#define PA2KA(x)  ((x) + 0xffff800000000000)
    5353
    5454#endif /* __ASM__ */
  • kernel/arch/amd64/src/boot/multiboot.S

    raf2a76c rb8e75319  
    428428       
    429429        /* Call arch_pre_main(multiboot_eax, multiboot_ebx) */
     430        xorq %rdi, %rdi
    430431        movl multiboot_eax, %edi
     432        xorq %rsi, %rsi
    431433        movl multiboot_ebx, %esi
    432         callq arch_pre_main
    433 
     434       
     435        movabsq $arch_pre_main, %rax
     436        callq *%rax
     437       
    434438        long_status $status_main
    435439       
    436440        /* Call main_bsp() */
    437         callq main_bsp
     441        movabsq $main_bsp, %rax
     442        call *%rax
    438443       
    439444        /* Not reached */
     
    633638        .quad ptl_2_6g + (PTL_WRITABLE | PTL_PRESENT)
    634639        .quad ptl_2_7g + (PTL_WRITABLE | PTL_PRESENT)
    635         .fill 502, 8, 0
    636         /* Mapping of [0; 2G) at -2G */
    637         .quad ptl_2_0g + (PTL_WRITABLE | PTL_PRESENT)
    638         .quad ptl_2_1g + (PTL_WRITABLE | PTL_PRESENT)
    639 
     640        .fill 504, 8, 0
    640641
    641642.align 4096
     
    643644ptl_0:
    644645        .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
    645         .fill 510, 8, 0
     646        .fill 255, 8, 0
    646647        .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
     648        .fill 255, 8, 0
    647649
    648650.section K_DATA_START, "aw", @progbits
  • kernel/arch/amd64/src/boot/multiboot2.S

    raf2a76c rb8e75319  
    244244       
    245245        /* Call arch_pre_main(multiboot_eax, multiboot_ebx) */
     246        xorq %rdi, %rdi
    246247        movl multiboot_eax, %edi
     248        xorq %rsi, %rsi
    247249        movl multiboot_ebx, %esi
    248         callq arch_pre_main
     250       
     251        movabsq $arch_pre_main, %rax
     252        callq *%rax
    249253       
    250254        /* Call main_bsp() */
    251         callq main_bsp
     255        movabsq $main_bsp, %rax
     256        call *%rax
    252257       
    253258        /* Not reached */
  • kernel/arch/amd64/src/mm/km.c

    raf2a76c rb8e75319  
    4040{
    4141        config.identity_base = KM_AMD64_IDENTITY_START;
    42         config.identity_size = KM_AMD64_IDENTITY_SIZE;
     42        config.identity_size = KM_AMD64_IDENTITY_SIZE; 
    4343}
    4444
  • kernel/genarch/src/mm/page_pt.c

    raf2a76c rb8e75319  
    384384            addr - 1 < base + size - 1;
    385385            addr += ptl0_step) {
    386                 if (GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(addr))) {
    387                         ASSERT(overlaps(addr, ptl0_step,
    388                             config.identity_base, config.identity_size));
    389 
    390                         /*
    391                          * This PTL0 entry also maps the kernel identity region,
    392                          * so it is already global and initialized.
    393                          */
    394                         continue;
    395                 }
    396 
    397386                uintptr_t l1 = PA2KA(frame_alloc(frames, FRAME_LOWMEM, 0));
    398387                memsetb((void *) l1, FRAMES2SIZE(frames), 0);
  • uspace/Makefile

    raf2a76c rb8e75319  
    7777        app/nettest2 \
    7878        app/nettest3 \
    79         app/nic \
    8079        app/ping \
    8180        app/sysinfo \
  • uspace/app/mixerctl/mixerctl.c

    raf2a76c rb8e75319  
    3535#include <assert.h>
    3636#include <errno.h>
    37 #include <loc.h>
    3837#include <str_error.h>
    3938#include <str.h>
     39#include <devman.h>
    4040#include <audio_mixer_iface.h>
    4141#include <stdio.h>
    4242
    43 #define DEFAULT_SERVICE "devices/\\hw\\pci0\\00:01.0\\sb16\\control"
     43#define DEFAULT_DEVICE "/hw/pci0/00:01.0/sb16/control"
    4444
    4545/**
     
    128128int main(int argc, char *argv[])
    129129{
    130         const char *service = DEFAULT_SERVICE;
     130        const char *device = DEFAULT_DEVICE;
    131131        void (*command)(async_exch_t *, int, char*[]) = NULL;
    132132
     
    134134                command = set_level;
    135135                if (argc == 5)
    136                         service = argv[1];
     136                        device = argv[1];
    137137        }
    138138
     
    140140                command = get_level;
    141141                if (argc == 4)
    142                         service = argv[1];
     142                        device = argv[1];
    143143        }
    144144
    145145        if ((argc == 2 && command == NULL))
    146                 service = argv[1];
     146                device = argv[1];
    147147
    148148
    149         service_id_t mixer_sid;
    150         int rc = loc_service_get_id(service, &mixer_sid, 0);
    151         if (rc != EOK) {
    152                 printf("Failed to resolve service '%s': %s.\n",
    153                     service, str_error(rc));
     149        devman_handle_t mixer_handle;
     150        int ret = devman_fun_get_handle(device, &mixer_handle, 0);
     151        if (ret != EOK) {
     152                printf("Failed to get device(%s) handle: %s.\n",
     153                    device, str_error(ret));
    154154                return 1;
    155155        }
    156156
    157         async_sess_t *session = loc_service_connect(
    158             EXCHANGE_ATOMIC, mixer_sid, 0);
     157        async_sess_t *session = devman_device_connect(
     158            EXCHANGE_ATOMIC, mixer_handle, IPC_FLAG_BLOCKING);
    159159        if (!session) {
    160                 printf("Failed connecting mixer service '%s'.\n", service);
     160                printf("Failed to connect to device.\n");
    161161                return 1;
    162162        }
  • uspace/app/taskdump/Makefile

    raf2a76c rb8e75319  
    3333SOURCES = \
    3434        elf_core.c \
    35         fibrildump.c \
    3635        taskdump.c \
    3736        symtab.c
  • uspace/app/taskdump/include/symtab.h

    raf2a76c rb8e75319  
    5050extern int symtab_load(const char *file_name, symtab_t **symtab);
    5151extern void symtab_delete(symtab_t *st);
    52 extern int symtab_name_to_addr(symtab_t *st, const char *name, uintptr_t *addr);
     52extern int symtab_name_to_addr(symtab_t *st, char *name, uintptr_t *addr);
    5353extern int symtab_addr_to_name(symtab_t *symtab, uintptr_t addr, char **name,
    5454    size_t *offs);
  • uspace/app/taskdump/symtab.c

    raf2a76c rb8e75319  
    202202 * @return      EOK on success, ENOENT if no such symbol was found.
    203203 */
    204 int symtab_name_to_addr(symtab_t *st, const char *name, uintptr_t *addr)
     204int symtab_name_to_addr(symtab_t *st, char *name, uintptr_t *addr)
    205205{
    206206        size_t i;
  • uspace/app/taskdump/taskdump.c

    raf2a76c rb8e75319  
    3535#include <async.h>
    3636#include <elf/elf_linux.h>
    37 #include <fibrildump.h>
    3837#include <stdio.h>
    3938#include <stdlib.h>
     
    5352#include <elf_core.h>
    5453#include <stacktrace.h>
    55 #include <taskdump.h>
    5654
    5755#define LINE_BYTES 16
     
    7876static istate_t reg_state;
    7977
    80 static stacktrace_ops_t td_stacktrace_ops = {
    81         .read_uintptr = td_read_uintptr
    82 };
    83 
    8478int main(int argc, char *argv[])
    8579{
     
    112106        if (rc < 0)
    113107                printf("Failed dumping address space areas.\n");
    114 
    115         rc = fibrils_dump(app_symtab, sess);
    116         if (rc < 0)
    117                 printf("Failed dumping fibrils.\n");
    118108
    119109        udebug_end(sess);
     
    321311}
    322312
    323 int td_stacktrace(uintptr_t fp, uintptr_t pc)
    324 {
    325         uintptr_t nfp;
     313static int thread_dump(uintptr_t thash)
     314{
     315        istate_t istate;
     316        uintptr_t pc, fp, nfp;
    326317        stacktrace_t st;
    327318        char *sym_pc;
    328319        int rc;
    329320
     321        rc = udebug_regs_read(sess, thash, &istate);
     322        if (rc < 0) {
     323                printf("Failed reading registers (%d).\n", rc);
     324                return EIO;
     325        }
     326
     327        pc = istate_get_pc(&istate);
     328        fp = istate_get_fp(&istate);
     329
     330        /* Save register state for dumping to core file later. */
     331        reg_state = istate;
     332
     333        sym_pc = fmt_sym_address(pc);
     334        printf("Thread %p: PC = %s. FP = %p\n", (void *) thash,
     335            sym_pc, (void *) fp);
     336        free(sym_pc);
     337
    330338        st.op_arg = NULL;
    331         st.ops = &td_stacktrace_ops;
     339        st.read_uintptr = td_read_uintptr;
    332340
    333341        while (stacktrace_fp_valid(&st, fp)) {
     
    346354                fp = nfp;
    347355        }
    348 
    349         return EOK;
    350 }
    351 
    352 static int thread_dump(uintptr_t thash)
    353 {
    354         istate_t istate;
    355         uintptr_t pc, fp;
    356         char *sym_pc;
    357         int rc;
    358 
    359         rc = udebug_regs_read(sess, thash, &istate);
    360         if (rc < 0) {
    361                 printf("Failed reading registers (%d).\n", rc);
    362                 return EIO;
    363         }
    364 
    365         pc = istate_get_pc(&istate);
    366         fp = istate_get_fp(&istate);
    367 
    368         /* Save register state for dumping to core file later. */
    369         reg_state = istate;
    370 
    371         sym_pc = fmt_sym_address(pc);
    372         printf("Thread %p: PC = %s. FP = %p\n", (void *) thash,
    373             sym_pc, (void *) fp);
    374         free(sym_pc);
    375 
    376         (void) td_stacktrace(fp, pc);
    377356
    378357        return EOK;
  • uspace/app/vlaunch/vlaunch.c

    raf2a76c rb8e75319  
    200200        }
    201201       
    202         timer = fibril_timer_create(NULL);
     202        timer = fibril_timer_create();
    203203        if (!timer) {
    204204                printf("Unable to create timer.\n");
  • uspace/drv/bus/isa/isa.c

    raf2a76c rb8e75319  
    355355
    356356        /* Get the name part of the rest of the line. */
    357         str_tok(line, ":", NULL);
     357        strtok(line, ":");
    358358        return line;
    359359}
  • uspace/drv/fb/amdm37x_dispc/amdm37x_dispc.c

    raf2a76c rb8e75319  
    3434 */
    3535
    36 #include <align.h>
    3736#include <assert.h>
    3837#include <errno.h>
  • uspace/drv/fb/amdm37x_dispc/main.c

    raf2a76c rb8e75319  
    3535 */
    3636
    37 #include <ddf/driver.h>
    3837#include <ddf/log.h>
    3938#include <errno.h>
    4039#include <str_error.h>
    4140#include <stdio.h>
     41#include <ops/graph_dev.h>
    4242#include <graph.h>
    4343
     
    4646#define NAME  "amdm37x_dispc"
    4747
    48 static void graph_vsl_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    49 {
    50         visualizer_t *vsl;
     48static graph_dev_ops_t graph_vsl_dev_ops = {
     49        .connect = (connect_func) &graph_visualizer_connection
     50};
    5151
    52         vsl = (visualizer_t *) ddf_fun_data_get((ddf_fun_t *)arg);
    53         graph_visualizer_connection(vsl, iid, icall, NULL);
    54 }
     52static ddf_dev_ops_t graph_fun_ops = {
     53        .interfaces[GRAPH_DEV_IFACE] = &graph_vsl_dev_ops
     54};
    5555
    5656static int amdm37x_dispc_dev_add(ddf_dev_t *dev)
     
    7474        vis->reg_svc_handle = ddf_fun_get_handle(fun);
    7575
    76         ddf_fun_set_conn_handler(fun, graph_vsl_connection);
     76        ddf_fun_set_ops(fun, &graph_fun_ops);
    7777        /* Hw part */
    7878        amdm37x_dispc_t *dispc =
  • uspace/drv/fb/kfb/kfb.c

    raf2a76c rb8e75319  
    4040#include <task.h>
    4141#include <graph.h>
     42#include <ops/graph_dev.h>
    4243#include "port.h"
    4344#include "kfb.h"
     
    5960};
    6061
     62static graph_dev_ops_t graph_vsl_dev_ops = {
     63        .connect = (connect_func) &graph_visualizer_connection
     64};
     65
     66ddf_dev_ops_t graph_vsl_device_ops = {
     67        .interfaces[GRAPH_DEV_IFACE] = &graph_vsl_dev_ops
     68};
     69
     70static graph_dev_ops_t graph_rnd_dev_ops = {
     71        .connect = (connect_func) &graph_renderer_connection
     72};
     73
     74ddf_dev_ops_t graph_rnd_device_ops = {
     75        .interfaces[GRAPH_DEV_IFACE] = &graph_rnd_dev_ops
     76};
     77
    6178int main(int argc, char *argv[])
    6279{
  • uspace/drv/fb/kfb/port.c

    raf2a76c rb8e75319  
    207207};
    208208
    209 static void graph_vsl_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    210 {
    211         visualizer_t *vsl;
    212 
    213         vsl = (visualizer_t *) ddf_fun_data_get((ddf_fun_t *)arg);
    214         graph_visualizer_connection(vsl, iid, icall, NULL);
    215 }
    216 
    217209int port_init(ddf_dev_t *dev)
    218210{
     
    354346                return ENOMEM;
    355347        }
    356         ddf_fun_set_conn_handler(fun_vs, &graph_vsl_connection);
     348        ddf_fun_set_ops(fun_vs, &graph_vsl_device_ops);
    357349
    358350        visualizer_t *vs = ddf_fun_data_alloc(fun_vs, sizeof(visualizer_t));
  • uspace/lib/c/arch/amd64/src/stacktrace.c

    raf2a76c rb8e75319  
    5151int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev)
    5252{
    53         return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev);
     53        return (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev);
    5454}
    5555
    5656int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra)
    5757{
    58         return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
     58        return (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
    5959}
    6060
  • uspace/lib/c/arch/arm32/src/stacktrace.c

    raf2a76c rb8e75319  
    5151int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev)
    5252{
    53         return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev);
     53        return (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev);
    5454}
    5555
    5656int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra)
    5757{
    58         return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
     58        return (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
    5959}
    6060
  • uspace/lib/c/arch/ia32/src/stacktrace.c

    raf2a76c rb8e75319  
    5151int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev)
    5252{
    53         return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev);
     53        return (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev);
    5454}
    5555
    5656int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra)
    5757{
    58         return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
     58        return (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
    5959}
    6060
  • uspace/lib/c/arch/ppc32/src/stacktrace.c

    raf2a76c rb8e75319  
    5151int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev)
    5252{
    53         return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev);
     53        return (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev);
    5454}
    5555
    5656int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra)
    5757{
    58         return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
     58        return (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
    5959}
    6060
  • uspace/lib/c/arch/sparc32/src/stacktrace.c

    raf2a76c rb8e75319  
    5353{
    5454        uintptr_t bprev;
    55         int rc = (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV,
     55        int rc = (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV,
    5656            &bprev);
    5757        if (rc == EOK)
     
    6363int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra)
    6464{
    65         return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
     65        return (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
    6666}
    6767
  • uspace/lib/c/arch/sparc64/src/stacktrace.c

    raf2a76c rb8e75319  
    5555        int rc;
    5656
    57         rc = (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, &bprev);
     57        rc = (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, &bprev);
    5858        if (rc == EOK)
    5959                *prev = bprev + STACK_BIAS;
     
    6363int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra)
    6464{
    65         return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
     65        return (*st->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);
    6666}
    6767
  • uspace/lib/c/generic/fibril.c

    raf2a76c rb8e75319  
    5959static LIST_INITIALIZE(serialized_list);
    6060static LIST_INITIALIZE(manager_list);
    61 static LIST_INITIALIZE(fibril_list);
    6261
    6362/** Number of threads that are executing a manager fibril. */
     
    117116       
    118117        fibril->waits_for = NULL;
    119         list_append(&fibril->all_link, &fibril_list);
    120118       
    121119        return fibril;
     
    124122void fibril_teardown(fibril_t *fibril)
    125123{
    126         list_remove(&fibril->all_link);
    127124        tls_free(fibril->tcb);
    128125        free(fibril);
  • uspace/lib/c/generic/fibril_synch.c

    raf2a76c rb8e75319  
    448448        int rc;
    449449
    450         fibril_mutex_lock(timer->lockp);
    451 
    452         while (timer->state != fts_cleanup) {
    453                 switch (timer->state) {
    454                 case fts_not_set:
    455                 case fts_fired:
    456                         fibril_condvar_wait(&timer->cv, timer->lockp);
     450        fibril_mutex_lock(&timer->lock);
     451
     452        while (true) {
     453                while (timer->state != fts_active &&
     454                    timer->state != fts_cleanup) {
     455
     456                        if (timer->state == fts_cleanup)
     457                                break;
     458
     459                        fibril_condvar_wait(&timer->cv, &timer->lock);
     460                }
     461
     462                if (timer->state == fts_cleanup)
    457463                        break;
    458                 case fts_active:
    459                         rc = fibril_condvar_wait_timeout(&timer->cv,
    460                             timer->lockp, timer->delay);
    461                         if (rc == ETIMEOUT && timer->state == fts_active) {
    462                                 timer->state = fts_fired;
    463                                 timer->handler_running = true;
    464                                 fibril_mutex_unlock(timer->lockp);
    465                                 timer->fun(timer->arg);
    466                                 fibril_mutex_lock(timer->lockp);
    467                                 timer->handler_running = false;
    468                         }
    469                         break;
    470                 case fts_cleanup:
    471                 case fts_clean:
    472                         assert(false);
    473                         break;
     464
     465                rc = fibril_condvar_wait_timeout(&timer->cv, &timer->lock,
     466                    timer->delay);
     467                if (rc == ETIMEOUT) {
     468                        timer->state = fts_fired;
     469                        fibril_mutex_unlock(&timer->lock);
     470                        timer->fun(timer->arg);
     471                        fibril_mutex_lock(&timer->lock);
    474472                }
    475473        }
    476474
    477         /* Acknowledge timer fibril has finished cleanup. */
    478         timer->state = fts_clean;
    479         fibril_mutex_unlock(timer->lockp);
    480         free(timer);
    481 
     475        fibril_mutex_unlock(&timer->lock);
    482476        return 0;
    483477}
     
    487481 * @return              New timer on success, @c NULL if out of memory.
    488482 */
    489 fibril_timer_t *fibril_timer_create(fibril_mutex_t *lock)
     483fibril_timer_t *fibril_timer_create(void)
    490484{
    491485        fid_t fid;
     
    507501        timer->fibril = fid;
    508502        timer->state = fts_not_set;
    509         timer->lockp = (lock != NULL) ? lock : &timer->lock;
    510503
    511504        fibril_add_ready(fid);
     505
    512506        return timer;
    513507}
     
    519513void fibril_timer_destroy(fibril_timer_t *timer)
    520514{
    521         fibril_mutex_lock(timer->lockp);
    522         assert(timer->state == fts_not_set || timer->state == fts_fired);
    523 
    524         /* Request timer fibril to terminate. */
     515        fibril_mutex_lock(&timer->lock);
     516        assert(timer->state != fts_active);
    525517        timer->state = fts_cleanup;
    526518        fibril_condvar_broadcast(&timer->cv);
    527         fibril_mutex_unlock(timer->lockp);
     519        fibril_mutex_unlock(&timer->lock);
    528520}
    529521
     
    541533    fibril_timer_fun_t fun, void *arg)
    542534{
    543         fibril_mutex_lock(timer->lockp);
    544         fibril_timer_set_locked(timer, delay, fun, arg);
    545         fibril_mutex_unlock(timer->lockp);
    546 }
    547 
    548 /** Set locked timer.
    549  *
    550  * Set timer to execute a callback function after the specified
    551  * interval. Must be called when the timer is locked.
    552  *
    553  * @param timer         Timer
    554  * @param delay         Delay in microseconds
    555  * @param fun           Callback function
    556  * @param arg           Argument for @a fun
    557  */
    558 void fibril_timer_set_locked(fibril_timer_t *timer, suseconds_t delay,
    559     fibril_timer_fun_t fun, void *arg)
    560 {
    561         assert(fibril_mutex_is_locked(timer->lockp));
    562         assert(timer->state == fts_not_set || timer->state == fts_fired);
     535        fibril_mutex_lock(&timer->lock);
    563536        timer->state = fts_active;
    564537        timer->delay = delay;
     
    566539        timer->arg = arg;
    567540        fibril_condvar_broadcast(&timer->cv);
     541        fibril_mutex_unlock(&timer->lock);
    568542}
    569543
     
    583557        fibril_timer_state_t old_state;
    584558
    585         fibril_mutex_lock(timer->lockp);
    586         old_state = fibril_timer_clear_locked(timer);
    587         fibril_mutex_unlock(timer->lockp);
    588 
    589         return old_state;
    590 }
    591 
    592 /** Clear locked timer.
    593  *
    594  * Clears (cancels) timer and returns last state of the timer.
    595  * This can be one of:
    596  *    - fts_not_set     If the timer has not been set or has been cleared
    597  *    - fts_active      Timer was set but did not fire
    598  *    - fts_fired       Timer fired
    599  * Must be called when the timer is locked.
    600  *
    601  * @param timer         Timer
    602  * @return              Last timer state
    603  */
    604 fibril_timer_state_t fibril_timer_clear_locked(fibril_timer_t *timer)
    605 {
    606         fibril_timer_state_t old_state;
    607 
    608         assert(fibril_mutex_is_locked(timer->lockp));
    609 
    610         while (timer->handler_running)
    611                 fibril_condvar_wait(&timer->cv, timer->lockp);
    612 
     559        fibril_mutex_lock(&timer->lock);
    613560        old_state = timer->state;
    614561        timer->state = fts_not_set;
     
    618565        timer->arg = NULL;
    619566        fibril_condvar_broadcast(&timer->cv);
     567        fibril_mutex_unlock(&timer->lock);
    620568
    621569        return old_state;
  • uspace/lib/c/generic/inet.c

    raf2a76c rb8e75319  
    11/*
    2  * Copyright (c) 2013 Jiri Svoboda
     2 * Copyright (c) 2012 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3434#include <ipc/services.h>
    3535#include <loc.h>
    36 #include <stdlib.h>
    3736
    3837static void inet_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg);
     
    225224       
    226225        rc = inet_ev_ops->recv(&dgram);
    227         free(dgram.data);
    228226        async_answer_0(iid, rc);
    229227}
  • uspace/lib/c/generic/stacktrace.c

    raf2a76c rb8e75319  
    4242static int stacktrace_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data);
    4343
    44 static stacktrace_ops_t basic_ops = {
    45         .read_uintptr = stacktrace_read_uintptr
    46 };
    47 
    48 void stacktrace_print_generic(stacktrace_ops_t *ops, void *arg, uintptr_t fp,
    49     uintptr_t pc)
     44void stacktrace_print_fp_pc(uintptr_t fp, uintptr_t pc)
    5045{
    5146        stacktrace_t st;
    5247        uintptr_t nfp;
    53         int rc;
    5448
    55         st.op_arg = arg;
    56         st.ops = ops;
     49        st.op_arg = NULL;
     50        st.read_uintptr = stacktrace_read_uintptr;
    5751
    5852        while (stacktrace_fp_valid(&st, fp)) {
    5953                printf("%p: %p()\n", (void *) fp, (void *) pc);
    60                 rc =  stacktrace_ra_get(&st, fp, &pc);
    61                 if (rc != EOK)
    62                         break;
    63                 rc = stacktrace_fp_prev(&st, fp, &nfp);
    64                 if (rc != EOK)
    65                         break;
     54                (void) stacktrace_ra_get(&st, fp, &pc);
     55                (void) stacktrace_fp_prev(&st, fp, &nfp);
    6656                fp = nfp;
    6757        }
    68 }
    69 
    70 void stacktrace_print_fp_pc(uintptr_t fp, uintptr_t pc)
    71 {
    72         stacktrace_print_generic(&basic_ops, NULL, fp, pc);
    7358}
    7459
  • uspace/lib/c/generic/str.c

    raf2a76c rb8e75319  
    13601360}
    13611361
    1362 /** Split string by delimiters.
    1363  *
    1364  * @param s             String to be tokenized. May not be NULL.
    1365  * @param delim         String with the delimiters.
    1366  * @param next          Variable which will receive the pointer to the
    1367  *                      continuation of the string following the first
    1368  *                      occurrence of any of the delimiter characters.
    1369  *                      May be NULL.
    1370  * @return              Pointer to the prefix of @a s before the first
    1371  *                      delimiter character. NULL if no such prefix
    1372  *                      exists.
    1373  */
    1374 char *str_tok(char *s, const char *delim, char **next)
     1362char *strtok(char *s, const char *delim)
     1363{
     1364        static char *next;
     1365
     1366        return strtok_r(s, delim, &next);
     1367}
     1368
     1369char *strtok_r(char *s, const char *delim, char **next)
    13751370{
    13761371        char *start, *end;
    13771372
    1378         if (!s)
    1379                 return NULL;
    1380        
    1381         size_t len = str_size(s);
    1382         size_t cur;
    1383         size_t tmp;
    1384         wchar_t ch;
     1373        if (s == NULL)
     1374                s = *next;
    13851375
    13861376        /* Skip over leading delimiters. */
    1387         for (tmp = cur = 0;
    1388             (ch = str_decode(s, &tmp, len)) && str_chr(delim, ch); /**/)
    1389                 cur = tmp;
    1390         start = &s[cur];
     1377        while (*s && (str_chr(delim, *s) != NULL)) ++s;
     1378        start = s;
    13911379
    13921380        /* Skip over token characters. */
    1393         for (tmp = cur;
    1394             (ch = str_decode(s, &tmp, len)) && !str_chr(delim, ch); /**/)
    1395                 cur = tmp;
    1396         end = &s[cur];
    1397         if (next)
    1398                 *next = (ch ? &s[tmp] : &s[cur]);
    1399 
    1400         if (start == end)
     1381        while (*s && (str_chr(delim, *s) == NULL)) ++s;
     1382        end = s;
     1383        *next = (*s ? s + 1 : s);
     1384
     1385        if (start == end) {
    14011386                return NULL;    /* No more tokens. */
     1387        }
    14021388
    14031389        /* Overwrite delimiter with NULL terminator. */
  • uspace/lib/c/include/fibril.h

    raf2a76c rb8e75319  
    6767typedef struct fibril {
    6868        link_t link;
    69         link_t all_link;
    7069        context_t ctx;
    7170        void *stack;
  • uspace/lib/c/include/fibril_synch.h

    raf2a76c rb8e75319  
    116116        /** Timer has fired and has not been cleared since */
    117117        fts_fired,
    118         /** Timer fibril is requested to terminate */
    119         fts_cleanup,
    120         /** Timer fibril acknowledged termination */
    121         fts_clean
     118        /** Timer is being destroyed */
     119        fts_cleanup
    122120} fibril_timer_state_t;
    123121
     
    131129typedef struct {
    132130        fibril_mutex_t lock;
    133         fibril_mutex_t *lockp;
    134131        fibril_condvar_t cv;
    135132        fid_t fibril;
    136133        fibril_timer_state_t state;
    137         bool handler_running;
    138134
    139135        suseconds_t delay;
     
    164160extern void fibril_condvar_broadcast(fibril_condvar_t *);
    165161
    166 extern fibril_timer_t *fibril_timer_create(fibril_mutex_t *);
     162extern fibril_timer_t *fibril_timer_create(void);
    167163extern void fibril_timer_destroy(fibril_timer_t *);
    168164extern void fibril_timer_set(fibril_timer_t *, suseconds_t, fibril_timer_fun_t,
    169165    void *);
    170 extern void fibril_timer_set_locked(fibril_timer_t *, suseconds_t,
    171     fibril_timer_fun_t, void *);
    172166extern fibril_timer_state_t fibril_timer_clear(fibril_timer_t *);
    173 extern fibril_timer_state_t fibril_timer_clear_locked(fibril_timer_t *);
    174167
    175168#endif
  • uspace/lib/c/include/ipc/dev_iface.h

    raf2a76c rb8e75319  
    4040        /** Character device interface */
    4141        CHAR_DEV_IFACE,
     42
     43        /** Graphic device interface */
     44        GRAPH_DEV_IFACE,
    4245
    4346        /** Audio device mixer interface */
  • uspace/lib/c/include/stacktrace.h

    raf2a76c rb8e75319  
    4141
    4242typedef struct {
     43        void *op_arg;
    4344        int (*read_uintptr)(void *, uintptr_t, uintptr_t *);
    44 } stacktrace_ops_t;
    45 
    46 typedef struct {
    47         void *op_arg;
    48         stacktrace_ops_t *ops;
    4945} stacktrace_t;
    5046
    5147extern void stacktrace_print(void);
    5248extern void stacktrace_print_fp_pc(uintptr_t, uintptr_t);
    53 extern void stacktrace_print_generic(stacktrace_ops_t *, void *, uintptr_t,
    54     uintptr_t);
    5549
    5650/*
  • uspace/lib/c/include/str.h

    raf2a76c rb8e75319  
    109109extern char *str_ndup(const char *, size_t max_size);
    110110
    111 extern char *str_tok(char *, const char *, char **);
    112 
    113111extern int str_uint8_t(const char *, const char **, unsigned int, bool,
    114112    uint8_t *);
     
    134132extern unsigned long strtoul(const char *, char **, int);
    135133
     134extern char * strtok_r(char *, const char *, char **);
     135extern char * strtok(char *, const char *);
     136
    136137#endif
    137138
  • uspace/lib/drv/Makefile

    raf2a76c rb8e75319  
    4747        generic/remote_pio_window.c \
    4848        generic/remote_char_dev.c \
     49        generic/remote_graph_dev.c \
    4950        generic/remote_nic.c \
    5051        generic/remote_usb.c \
  • uspace/lib/drv/generic/dev_iface.c

    raf2a76c rb8e75319  
    4545#include "remote_led_dev.h"
    4646#include "remote_battery_dev.h"
     47#include "remote_graph_dev.h"
    4748#include "remote_nic.h"
    4849#include "remote_usb.h"
     
    6162                [PIO_WINDOW_DEV_IFACE] = &remote_pio_window_iface,
    6263                [CHAR_DEV_IFACE] = &remote_char_dev_iface,
     64                [GRAPH_DEV_IFACE] = &remote_graph_dev_iface,
    6365                [NIC_DEV_IFACE] = &remote_nic_iface,
    6466                [PCI_DEV_IFACE] = &remote_pci_iface,
  • uspace/lib/graph/graph.c

    raf2a76c rb8e75319  
    5858visualizer_t *graph_alloc_visualizer(void)
    5959{
    60         return ((visualizer_t *) malloc(sizeof(visualizer_t)));
     60        visualizer_t *vs = (visualizer_t *) malloc(sizeof(visualizer_t));
     61        if (vs == NULL) {
     62                return NULL;
     63        }
     64       
     65        return vs;
    6166}
    6267
     
    6469{
    6570        // TODO
    66         return ((renderer_t *) malloc(sizeof(renderer_t)));
     71        renderer_t *rnd = (renderer_t *) malloc(sizeof(renderer_t));
     72        if (rnd == NULL) {
     73                return NULL;
     74        }
     75
     76        return rnd;
    6777}
    6878
     
    8898int graph_register_visualizer(visualizer_t *vs)
    8999{
     100        int rc = EOK;
     101       
    90102        char node[LOC_NAME_MAXLEN + 1];
    91103        snprintf(node, LOC_NAME_MAXLEN, "%s%zu/%s%zu", NAMESPACE,
    92104            namespace_idx, VISUALIZER_NAME, visualizer_idx++);
    93        
     105
    94106        category_id_t cat;
    95         int rc = loc_category_get_id("visualizer", &cat, 0);
    96         if (rc != EOK)
     107        rc = loc_category_get_id("visualizer", &cat, 0);
     108        if (rc != EOK) {
    97109                return rc;
    98        
     110        }
     111
    99112        rc = loc_service_register(node, &vs->reg_svc_handle);
    100         if (rc != EOK)
     113        if (rc != EOK) {
    101114                return rc;
    102        
     115        }
     116
    103117        rc = loc_service_add_to_cat(vs->reg_svc_handle, cat);
    104118        if (rc != EOK) {
     
    106120                return rc;
    107121        }
    108        
     122
    109123        fibril_mutex_lock(&visualizer_list_mtx);
    110124        list_append(&vs->link, &visualizer_list);
    111125        fibril_mutex_unlock(&visualizer_list_mtx);
    112        
     126
    113127        return rc;
    114128}
     
    116130int graph_register_renderer(renderer_t *rnd)
    117131{
     132        int rc = EOK;
     133
    118134        char node[LOC_NAME_MAXLEN + 1];
    119135        snprintf(node, LOC_NAME_MAXLEN, "%s%zu/%s%zu", NAMESPACE,
    120136            namespace_idx, RENDERER_NAME, renderer_idx++);
    121        
     137
    122138        category_id_t cat;
    123         int rc = loc_category_get_id("renderer", &cat, 0);
    124         if (rc != EOK)
     139        rc = loc_category_get_id("renderer", &cat, 0);
     140        if (rc != EOK) {
    125141                return rc;
    126        
     142        }
     143
    127144        rc = loc_service_register(node, &rnd->reg_svc_handle);
    128         if (rc != EOK)
     145        if (rc != EOK) {
    129146                return rc;
    130        
     147        }
     148
    131149        rc = loc_service_add_to_cat(rnd->reg_svc_handle, cat);
    132150        if (rc != EOK) {
     
    134152                return rc;
    135153        }
    136        
     154
    137155        fibril_mutex_lock(&renderer_list_mtx);
    138156        list_append(&rnd->link, &renderer_list);
    139157        fibril_mutex_unlock(&renderer_list_mtx);
    140        
     158
    141159        return rc;
    142160}
     
    145163{
    146164        visualizer_t *vs = NULL;
    147        
     165
    148166        fibril_mutex_lock(&visualizer_list_mtx);
    149        
    150167        list_foreach(visualizer_list, link, visualizer_t, vcur) {
    151168                if (vcur->reg_svc_handle == handle) {
     
    154171                }
    155172        }
    156        
    157173        fibril_mutex_unlock(&visualizer_list_mtx);
    158        
     174
    159175        return vs;
    160176}
     
    163179{
    164180        renderer_t *rnd = NULL;
    165        
     181
    166182        fibril_mutex_lock(&renderer_list_mtx);
    167        
    168183        list_foreach(renderer_list, link, renderer_t, rcur) {
    169184                if (rcur->reg_svc_handle == handle) {
     
    172187                }
    173188        }
    174        
    175189        fibril_mutex_unlock(&renderer_list_mtx);
    176        
     190
    177191        return rnd;
    178192}
     
    180194int graph_unregister_visualizer(visualizer_t *vs)
    181195{
     196        int rc = EOK;
     197
    182198        fibril_mutex_lock(&visualizer_list_mtx);
    183         int rc = loc_service_unregister(vs->reg_svc_handle);
     199        rc = loc_service_unregister(vs->reg_svc_handle);
    184200        list_remove(&vs->link);
    185201        fibril_mutex_unlock(&visualizer_list_mtx);
    186        
     202
    187203        return rc;
    188204}
     
    190206int graph_unregister_renderer(renderer_t *rnd)
    191207{
     208        int rc = EOK;
     209
    192210        fibril_mutex_lock(&renderer_list_mtx);
    193         int rc = loc_service_unregister(rnd->reg_svc_handle);
     211        rc = loc_service_unregister(rnd->reg_svc_handle);
    194212        list_remove(&rnd->link);
    195213        fibril_mutex_unlock(&renderer_list_mtx);
    196        
     214
    197215        return rc;
    198216}
     
    207225        assert(vs->cells.data == NULL);
    208226        assert(vs->dev_ctx == NULL);
    209        
     227
    210228        free(vs);
    211229}
     
    215233        // TODO
    216234        assert(atomic_get(&rnd->ref_cnt) == 0);
    217        
     235
    218236        free(rnd);
    219237}
     
    224242        int ret = async_req_2_0(exch, VISUALIZER_MODE_CHANGE, handle, mode_idx);
    225243        async_exchange_end(exch);
    226        
     244
    227245        return ret;
    228246}
     
    233251        int ret = async_req_1_0(exch, VISUALIZER_DISCONNECT, handle);
    234252        async_exchange_end(exch);
    235        
     253
    236254        async_hangup(sess);
    237        
     255
    238256        return ret;
    239257}
     
    255273                }
    256274        }
    257        
     275
    258276        /* Driver might also deallocate resources for the current mode. */
    259277        int rc = vs->ops.yield(vs);
    260        
     278
    261279        /* Now that the driver was given a chance to deallocate resources,
    262280         * current mode can be unset. */
    263         if (vs->mode_set)
     281        if (vs->mode_set) {
    264282                vs->mode_set = false;
    265        
     283        }
     284
    266285        async_answer_0(iid, rc);
    267286}
     
    269288static void vs_enumerate_modes(visualizer_t *vs, ipc_callid_t iid, ipc_call_t *icall)
    270289{
    271         ipc_callid_t callid;
    272         size_t len;
    273        
    274         if (!async_data_read_receive(&callid, &len)) {
    275                 async_answer_0(callid, EREFUSED);
    276                 async_answer_0(iid, EREFUSED);
    277                 return;
    278         }
    279        
    280290        fibril_mutex_lock(&vs->mode_mtx);
    281291        link_t *link = list_nth(&vs->modes, IPC_GET_ARG1(*icall));
    282        
     292
    283293        if (link != NULL) {
    284294                vslmode_list_element_t *mode_elem =
    285295                    list_get_instance(link, vslmode_list_element_t, link);
    286                
    287                 int rc = async_data_read_finalize(callid, &mode_elem->mode, len);
    288                 async_answer_0(iid, rc);
     296                vslmode_t mode = mode_elem->mode;
     297                fibril_mutex_unlock(&vs->mode_mtx);
     298
     299                ipc_callid_t callid;
     300                size_t len;
     301
     302        if (!async_data_read_receive(&callid, &len)) {
     303                        async_answer_0(iid, EINVAL);
     304                        return;
     305        }
     306        int rc = async_data_read_finalize(callid, &mode, len);
     307                if (rc != EOK) {
     308                        async_answer_0(iid, ENOMEM);
     309                        return;
     310                }
     311
     312                async_answer_0(iid, EOK);
    289313        } else {
    290                 async_answer_0(callid, ENOENT);
    291314                async_answer_0(iid, ENOENT);
    292315        }
    293        
    294         fibril_mutex_unlock(&vs->mode_mtx);
    295316}
    296317
    297318static void vs_get_default_mode(visualizer_t *vs, ipc_callid_t iid, ipc_call_t *icall)
    298319{
    299         ipc_callid_t callid;
    300         size_t len;
    301        
    302         if (!async_data_read_receive(&callid, &len)) {
    303                 async_answer_0(callid, EREFUSED);
    304                 async_answer_0(iid, EREFUSED);
    305                 return;
    306         }
    307        
    308320        fibril_mutex_lock(&vs->mode_mtx);
    309321        vslmode_list_element_t *mode_elem = NULL;
    310        
    311322        list_foreach(vs->modes, link, vslmode_list_element_t, cur) {
    312323                if (cur->mode.index == vs->def_mode_idx) {
     
    315326                }
    316327        }
    317        
     328
     329        vslmode_t mode;
    318330        if (mode_elem != NULL) {
    319                 int rc = async_data_read_finalize(callid, &mode_elem->mode, len);
    320                 async_answer_0(iid, rc);
     331                mode = mode_elem->mode;
     332                fibril_mutex_unlock(&vs->mode_mtx);
     333
     334                ipc_callid_t callid;
     335                size_t len;
     336
     337                if (!async_data_read_receive(&callid, &len)) {
     338                        async_answer_0(iid, EINVAL);
     339                        return;
     340                }
     341                int rc = async_data_read_finalize(callid, &mode, len);
     342                if (rc != EOK) {
     343                        async_answer_0(iid, ENOMEM);
     344                        return;
     345                }
     346                async_answer_0(iid, EOK);
    321347        } else {
    322348                fibril_mutex_unlock(&vs->mode_mtx);
    323                 async_answer_0(callid, ENOENT);
    324349                async_answer_0(iid, ENOENT);
    325350        }
    326        
    327         fibril_mutex_unlock(&vs->mode_mtx);
    328351}
    329352
    330353static void vs_get_current_mode(visualizer_t *vs, ipc_callid_t iid, ipc_call_t *icall)
    331354{
    332         ipc_callid_t callid;
    333         size_t len;
    334        
    335         if (!async_data_read_receive(&callid, &len)) {
    336                 async_answer_0(callid, EREFUSED);
    337                 async_answer_0(iid, EREFUSED);
    338                 return;
    339         }
    340        
    341355        if (vs->mode_set) {
     356                ipc_callid_t callid;
     357                size_t len;
     358
     359                if (!async_data_read_receive(&callid, &len)) {
     360                        async_answer_0(iid, EINVAL);
     361                        return;
     362                }
    342363                int rc = async_data_read_finalize(callid, &vs->cur_mode, len);
    343                 async_answer_0(iid, rc);
     364                if (rc != EOK) {
     365                        async_answer_0(iid, ENOMEM);
     366                        return;
     367                }
     368
     369                async_answer_0(iid, EOK);
    344370        } else {
    345                 async_answer_0(callid, ENOENT);
    346371                async_answer_0(iid, ENOENT);
    347372        }
     
    350375static void vs_get_mode(visualizer_t *vs, ipc_callid_t iid, ipc_call_t *icall)
    351376{
    352         ipc_callid_t callid;
    353         size_t len;
    354        
    355         if (!async_data_read_receive(&callid, &len)) {
    356                 async_answer_0(callid, EREFUSED);
    357                 async_answer_0(iid, EREFUSED);
    358                 return;
    359         }
    360        
    361377        sysarg_t mode_idx = IPC_GET_ARG1(*icall);
    362        
     378
    363379        fibril_mutex_lock(&vs->mode_mtx);
    364380        vslmode_list_element_t *mode_elem = NULL;
    365        
    366381        list_foreach(vs->modes, link, vslmode_list_element_t, cur) {
    367382                if (cur->mode.index == mode_idx) {
     
    370385                }
    371386        }
    372        
     387
     388        vslmode_t mode;
    373389        if (mode_elem != NULL) {
    374                 int rc = async_data_read_finalize(callid, &mode_elem->mode, len);
    375                 async_answer_0(iid, rc);
     390                mode = mode_elem->mode;
     391                fibril_mutex_unlock(&vs->mode_mtx);
     392
     393                ipc_callid_t callid;
     394                size_t len;
     395
     396                if (!async_data_read_receive(&callid, &len)) {
     397                        async_answer_0(iid, EINVAL);
     398                        return;
     399                }
     400                int rc = async_data_read_finalize(callid, &mode, len);
     401                if (rc != EOK) {
     402                        async_answer_0(iid, ENOMEM);
     403                        return;
     404                }
     405                async_answer_0(iid, EOK);
    376406        } else {
    377                 async_answer_0(callid, ENOENT);
     407                fibril_mutex_unlock(&vs->mode_mtx);
    378408                async_answer_0(iid, ENOENT);
    379409        }
    380        
    381         fibril_mutex_unlock(&vs->mode_mtx);
    382410}
    383411
    384412static void vs_set_mode(visualizer_t *vs, ipc_callid_t iid, ipc_call_t *icall)
    385413{
     414        int rc = EOK;
     415
     416        /* Retrieve mode index and version. */
     417        sysarg_t mode_idx = IPC_GET_ARG1(*icall);
     418        sysarg_t mode_version = IPC_GET_ARG2(*icall);
     419
     420        /* Find mode in the list. */
     421        fibril_mutex_lock(&vs->mode_mtx);
     422        vslmode_list_element_t *mode_elem = NULL;
     423        list_foreach(vs->modes, link, vslmode_list_element_t, cur) {
     424                if (cur->mode.index == mode_idx) {
     425                        mode_elem = cur;
     426                        break;
     427                }
     428        }
     429
     430        /* Extract mode description from the list node. */
     431        vslmode_t new_mode;
     432        if (mode_elem != NULL) {
     433                new_mode = mode_elem->mode;
     434                fibril_mutex_unlock(&vs->mode_mtx);
     435        } else {
     436                fibril_mutex_unlock(&vs->mode_mtx);
     437                async_answer_0(iid, ENOENT);
     438                return;
     439        }
     440
     441        /* Check whether the mode is still up-to-date. */
     442        if (new_mode.version != mode_version) {
     443                async_answer_0(iid, EINVAL);
     444                return;
     445        }
     446
    386447        ipc_callid_t callid;
    387448        size_t size;
    388449        unsigned int flags;
    389        
     450
    390451        /* Retrieve the shared cell storage for the new mode. */
    391452        if (!async_share_out_receive(&callid, &size, &flags)) {
    392                 async_answer_0(callid, EREFUSED);
    393                 async_answer_0(iid, EREFUSED);
    394                 return;
    395         }
    396        
    397         /* Retrieve mode index and version. */
    398         sysarg_t mode_idx = IPC_GET_ARG1(*icall);
    399         sysarg_t mode_version = IPC_GET_ARG2(*icall);
    400        
    401         /* Find mode in the list. */
    402         fibril_mutex_lock(&vs->mode_mtx);
    403         vslmode_list_element_t *mode_elem = NULL;
    404        
    405         list_foreach(vs->modes, link, vslmode_list_element_t, cur) {
    406                 if (cur->mode.index == mode_idx) {
    407                         mode_elem = cur;
    408                         break;
    409                 }
    410         }
    411        
    412         if (mode_elem == NULL) {
    413                 fibril_mutex_unlock(&vs->mode_mtx);
    414                 async_answer_0(callid, ENOENT);
    415                 async_answer_0(iid, ENOENT);
    416                 return;
    417         }
    418        
    419         /* Extract mode description from the list node. */
    420         vslmode_t new_mode = mode_elem->mode;
    421         fibril_mutex_unlock(&vs->mode_mtx);
    422        
    423         /* Check whether the mode is still up-to-date. */
    424         if (new_mode.version != mode_version) {
    425                 async_answer_0(callid, EINVAL);
    426453                async_answer_0(iid, EINVAL);
    427454                return;
    428455        }
    429        
    430456        void *new_cell_storage;
    431         int rc = async_share_out_finalize(callid, &new_cell_storage);
     457        rc = async_share_out_finalize(callid, &new_cell_storage);
    432458        if ((rc != EOK) || (new_cell_storage == AS_MAP_FAILED)) {
    433459                async_answer_0(iid, ENOMEM);
    434460                return;
    435461        }
    436        
     462
    437463        /* Change device internal state. */
    438464        rc = vs->ops.change_mode(vs, new_mode);
    439        
     465
    440466        /* Device driver could not establish new mode. Rollback. */
    441467        if (rc != EOK) {
     
    444470                return;
    445471        }
    446        
    447         /*
    448          * Because resources for the new mode were successfully
    449          * claimed, it is finally possible to free resources
    450          * allocated for the old mode.
    451          */
     472
     473        /* Because resources for the new mode were successfully claimed,
     474         * it is finally possible to free resources allocated for the old mode. */
    452475        if (vs->mode_set) {
    453476                if (vs->cells.data != NULL) {
     
    456479                }
    457480        }
    458        
     481
    459482        /* Insert new mode into the visualizer. */
    460483        vs->cells.width = new_mode.screen_width;
     
    463486        vs->cur_mode = new_mode;
    464487        vs->mode_set = true;
    465        
     488
    466489        async_answer_0(iid, EOK);
    467490}
     
    476499        sysarg_t y_offset = (IPC_GET_ARG5(*icall) & 0xffffffff);
    477500#endif
    478        
     501
    479502        int rc = vs->ops.handle_damage(vs,
    480503            IPC_GET_ARG1(*icall), IPC_GET_ARG2(*icall),
    481504            IPC_GET_ARG3(*icall), IPC_GET_ARG4(*icall),
    482             x_offset, y_offset);
     505                x_offset, y_offset);
    483506        async_answer_0(iid, rc);
    484507}
     
    501524        ipc_call_t call;
    502525        ipc_callid_t callid;
    503        
     526
    504527        /* Claim the visualizer. */
    505528        if (!cas(&vs->ref_cnt, 0, 1)) {
     
    507530                return;
    508531        }
    509        
     532
    510533        /* Accept the connection. */
    511534        async_answer_0(iid, EOK);
    512        
     535
    513536        /* Establish callback session. */
    514537        callid = async_get_call(&call);
    515538        vs->notif_sess = async_callback_receive_start(EXCHANGE_SERIALIZE, &call);
    516         if (vs->notif_sess != NULL)
     539        if (vs->notif_sess != NULL) {
    517540                async_answer_0(callid, EOK);
    518         else
     541        } else {
    519542                async_answer_0(callid, ELIMIT);
    520        
     543        }
     544
    521545        /* Enter command loop. */
    522546        while (true) {
    523547                callid = async_get_call(&call);
    524                
     548
    525549                if (!IPC_GET_IMETHOD(call)) {
    526550                        async_answer_0(callid, EINVAL);
    527551                        break;
    528552                }
    529                
     553
    530554                switch (IPC_GET_IMETHOD(call)) {
    531555                case VISUALIZER_CLAIM:
     
    564588                }
    565589        }
    566        
     590
    567591terminate:
    568592        async_hangup(vs->notif_sess);
     
    575599{
    576600        // TODO
    577        
     601
    578602        ipc_call_t call;
    579603        ipc_callid_t callid;
    580        
     604
    581605        /* Accept the connection. */
    582606        atomic_inc(&rnd->ref_cnt);
    583607        async_answer_0(iid, EOK);
    584        
     608
    585609        /* Enter command loop. */
    586610        while (true) {
    587611                callid = async_get_call(&call);
    588                
     612
    589613                if (!IPC_GET_IMETHOD(call)) {
    590614                        async_answer_0(callid, EINVAL);
    591615                        break;
    592616                }
    593                
     617
    594618                switch (IPC_GET_IMETHOD(call)) {
    595619                default:
     
    598622                }
    599623        }
    600        
     624
    601625terminate:
    602626        atomic_dec(&rnd->ref_cnt);
     
    608632        visualizer_t *vs = graph_get_visualizer(IPC_GET_ARG1(*icall));
    609633        renderer_t *rnd = graph_get_renderer(IPC_GET_ARG1(*icall));
    610        
    611         if (vs != NULL)
     634
     635        if (vs != NULL) {
    612636                graph_visualizer_connection(vs, iid, icall, arg);
    613         else if (rnd != NULL)
     637        } else if (rnd != NULL) {
    614638                graph_renderer_connection(rnd, iid, icall, arg);
    615         else
     639        } else {
    616640                async_answer_0(iid, ENOENT);
     641        }
    617642}
    618643
  • uspace/srv/devman/main.c

    raf2a76c rb8e75319  
    116116               
    117117                fwd_h = dev->pfun->handle;
    118         } else {
     118        } else if (dev->state == DEVICE_USABLE) {
    119119                /* Connect to the specified function */
    120120                driver = dev->drv;
     121                assert(driver != NULL);
     122               
    121123                fwd_h = handle;
    122124        }
  • uspace/srv/fs/fat/fat_ops.c

    raf2a76c rb8e75319  
    930930        /* Parse mount options. */
    931931        char *mntopts = (char *) opts;
     932        char *saveptr;
    932933        char *opt;
    933         while ((opt = str_tok(mntopts, " ,", &mntopts)) != NULL) {
     934        while ((opt = strtok_r(mntopts, " ,", &saveptr)) != NULL) {
    934935                if (str_cmp(opt, "wtcache") == 0)
    935936                        cmode = CACHE_MODE_WT;
    936937                else if (str_cmp(opt, "nolfn") == 0)
    937938                        instance->lfn_enabled = false;
     939                mntopts = NULL;
    938940        }
    939941
  • uspace/srv/hid/compositor/compositor.c

    raf2a76c rb8e75319  
    5555#include <async.h>
    5656#include <loc.h>
     57#include <devman.h>
    5758
    5859#include <event.h>
     60#include <graph_iface.h>
    5961#include <io/keycode.h>
    6062#include <io/mode.h>
     
    11471149}
    11481150
    1149 static async_sess_t *vsl_connect(service_id_t sid, const char *svc)
     1151static async_sess_t *vsl_connect(const char *svc)
    11501152{
    11511153        int rc;
    11521154        async_sess_t *sess;
    1153 
    1154         sess = loc_service_connect(EXCHANGE_SERIALIZE, sid, 0);
    1155         if (sess == NULL) {
    1156                 printf("%s: Unable to connect to visualizer %s\n", NAME, svc);
     1155        service_id_t dsid;
     1156        devman_handle_t handle;
     1157
     1158        rc = loc_service_get_id(svc, &dsid, 0);
     1159        if (rc != EOK) {
    11571160                return NULL;
    11581161        }
    11591162
     1163        rc = devman_fun_sid_to_handle(dsid, &handle);
     1164        if (rc == EOK) {
     1165                sess = devman_device_connect(EXCHANGE_SERIALIZE, handle, 0);
     1166                if (sess == NULL) {
     1167                        printf("%s: Unable to connect to visualizer %s\n", NAME, svc);
     1168                        return NULL;
     1169                }
     1170                rc = graph_dev_connect(sess);
     1171                if (rc != EOK) {
     1172                        return NULL;
     1173                }
     1174        } else if (rc == ENOENT) {
     1175                sess = loc_service_connect(EXCHANGE_SERIALIZE, dsid, 0);
     1176                if (sess == NULL) {
     1177                        printf("%s: Unable to connect to visualizer %s\n", NAME, svc);
     1178                        return NULL;
     1179                }
     1180        } else {
     1181                return NULL;
     1182        }
     1183
    11601184        async_exch_t *exch = async_exchange_begin(sess);
    1161         rc = async_connect_to_me(exch, sid, 0, 0, vsl_notifications, NULL);
     1185        rc = async_connect_to_me(exch, dsid, 0, 0, vsl_notifications, NULL);
    11621186        async_exchange_end(exch);
    11631187
     
    11721196}
    11731197
    1174 static viewport_t *viewport_create(service_id_t sid)
     1198static viewport_t *viewport_create(const char *vsl_name)
    11751199{
    11761200        int rc;
    1177         char *vsl_name = NULL;
    1178         viewport_t *vp = NULL;
    1179         bool claimed = false;
    1180 
    1181         rc = loc_service_get_name(sid, &vsl_name);
    1182         if (rc != EOK)
    1183                 goto error;
    1184 
    1185         vp = (viewport_t *) calloc(1, sizeof(viewport_t));
    1186         if (!vp)
    1187                 goto error;
     1201
     1202        viewport_t *vp = (viewport_t *) malloc(sizeof(viewport_t));
     1203        if (!vp) {
     1204                return NULL;
     1205        }
    11881206
    11891207        link_initialize(&vp->link);
     
    11921210
    11931211        /* Establish output bidirectional connection. */
    1194         vp->dsid = sid;
    1195         vp->sess = vsl_connect(sid, vsl_name);
    1196         if (vp->sess == NULL)
    1197                 goto error;
     1212        vp->sess = vsl_connect(vsl_name);
     1213        rc = loc_service_get_id(vsl_name, &vp->dsid, 0);
     1214        if (vp->sess == NULL || rc != EOK) {
     1215                free(vp);
     1216                return NULL;
     1217        }
    11981218
    11991219        /* Claim the given visualizer. */
    12001220        rc = visualizer_claim(vp->sess, 0);
    12011221        if (rc != EOK) {
     1222                async_hangup(vp->sess);
     1223                free(vp);
    12021224                printf("%s: Unable to claim visualizer (%s)\n", NAME, str_error(rc));
    1203                 goto error;
    1204         }
    1205 
    1206         claimed = true;
     1225                return NULL;
     1226        }
    12071227
    12081228        /* Retrieve the default mode. */
    12091229        rc = visualizer_get_default_mode(vp->sess, &vp->mode);
    12101230        if (rc != EOK) {
     1231                visualizer_yield(vp->sess);
     1232                async_hangup(vp->sess);
     1233                free(vp);
    12111234                printf("%s: Unable to retrieve mode (%s)\n", NAME, str_error(rc));
    1212                 goto error;
     1235                return NULL;
    12131236        }
    12141237
     
    12171240            NULL, SURFACE_FLAG_SHARED);
    12181241        if (vp->surface == NULL) {
     1242                visualizer_yield(vp->sess);
     1243                async_hangup(vp->sess);
     1244                free(vp);
    12191245                printf("%s: Unable to create surface (%s)\n", NAME, str_error(rc));
    1220                 goto error;
     1246                return NULL;
    12211247        }
    12221248
     
    12251251                vp->mode.index, vp->mode.version, surface_direct_access(vp->surface));
    12261252        if (rc != EOK) {
     1253                visualizer_yield(vp->sess);
     1254                surface_destroy(vp->surface);
     1255                async_hangup(vp->sess);
     1256                free(vp);
    12271257                printf("%s: Unable to set mode (%s)\n", NAME, str_error(rc));
    1228                 goto error;
     1258                return NULL;
    12291259        }
    12301260
    12311261        return vp;
    1232 error:
    1233         if (claimed)
    1234                 visualizer_yield(vp->sess);
    1235         if (vp->sess != NULL)
    1236                 async_hangup(vp->sess);
    1237         free(vp);
    1238         free(vsl_name);
    1239         return NULL;
    12401262}
    12411263
     
    21682190                        continue;
    21692191               
    2170                 viewport_t *vp = viewport_create(svcs[i]);
    2171                 if (vp != NULL)
    2172                         list_append(&vp->link, &viewport_list);
     2192                char *svc_name;
     2193                rc = loc_service_get_name(svcs[i], &svc_name);
     2194                if (rc == EOK) {
     2195                        viewport_t *vp = viewport_create(svc_name);
     2196                        if (vp != NULL) {
     2197                                list_append(&vp->link, &viewport_list);
     2198                        }
     2199                }
    21732200        }
    21742201        fibril_mutex_unlock(&viewport_list_mtx);
  • uspace/srv/logger/initlvl.c

    raf2a76c rb8e75319  
    4444{
    4545        char *tmp;
    46         char *key = str_tok(setting, "=", &tmp);
    47         char *value = str_tok(tmp, "=", &tmp);
     46        char *key = strtok_r(setting, "=", &tmp);
     47        char *value = strtok_r(NULL, "=", &tmp);
    4848        if (key == NULL)
    4949                return;
     
    7676{
    7777        char *tmp;
    78         char *single_setting = str_tok(settings, " ", &tmp);
     78        char *single_setting = strtok_r(settings, " ", &tmp);
    7979        while (single_setting != NULL) {
    8080                parse_single_level_setting(single_setting);
    81                 single_setting = str_tok(tmp, " ", &tmp);
     81                single_setting = strtok_r(NULL, " ", &tmp);
    8282        }
    8383}
  • uspace/srv/net/dhcp/dhcp.c

    raf2a76c rb8e75319  
    304304                        break;
    305305                case opt_dns_server:
    306                         if (opt_len < 4 || opt_len % 4 != 0)
     306                        if (opt_len != 4)
    307307                                return EINVAL;
    308                         /* XXX Handle multiple DNS servers properly */
    309308                        inet_addr_set(dhcp_uint32_decode(&msgb[i]),
    310309                            &offer->dns_server);
     
    436435
    437436        dlink->link_id = link_id;
    438         dlink->timeout = fibril_timer_create(NULL);
     437        dlink->timeout = fibril_timer_create();
    439438        if (dlink->timeout == NULL) {
    440439                rc = ENOMEM;
  • uspace/srv/net/inetsrv/inetsrv.c

    raf2a76c rb8e75319  
    296296       
    297297        uint8_t ttl = IPC_GET_ARG3(*icall);
    298         int df = IPC_GET_ARG4(*icall);
     298        int df = IPC_GET_ARG3(*icall);
    299299       
    300300        ipc_callid_t callid;
  • uspace/srv/net/tcp/conn.c

    raf2a76c rb8e75319  
    7878                goto error;
    7979
    80         fibril_mutex_initialize(&conn->lock);
    81 
    82         conn->tw_timer = fibril_timer_create(&conn->lock);
     80        conn->tw_timer = fibril_timer_create();
    8381        if (conn->tw_timer == NULL)
    8482                goto error;
     83
     84        fibril_mutex_initialize(&conn->lock);
    8585
    8686        /* One for the user, one for not being in closed state */
     
    200200        if (atomic_predec(&conn->refcnt) == 0)
    201201                tcp_conn_free(conn);
    202 }
    203 
    204 /** Lock connection.
    205  *
    206  * Must be called before any other connection-manipulating function,
    207  * except tcp_conn_{add|del}ref(). Locks the connection including
    208  * its timers. Must not be called inside any of the connection
    209  * timer handlers.
    210  *
    211  * @param conn          Connection
    212  */
    213 void tcp_conn_lock(tcp_conn_t *conn)
    214 {
    215         fibril_mutex_lock(&conn->lock);
    216 }
    217 
    218 /** Unlock connection.
    219  *
    220  * @param conn          Connection
    221  */
    222 void tcp_conn_unlock(tcp_conn_t *conn)
    223 {
    224         fibril_mutex_unlock(&conn->lock);
    225202}
    226203
     
    12061183        log_msg(LOG_DEFAULT, LVL_DEBUG, "tw_timeout_func(%p)", conn);
    12071184
    1208         tcp_conn_lock(conn);
     1185        fibril_mutex_lock(&conn->lock);
    12091186
    12101187        if (conn->cstate == st_closed) {
    12111188                log_msg(LOG_DEFAULT, LVL_DEBUG, "Connection already closed.");
    1212                 tcp_conn_unlock(conn);
     1189                fibril_mutex_unlock(&conn->lock);
    12131190                tcp_conn_delref(conn);
    12141191                return;
     
    12191196        tcp_conn_state_set(conn, st_closed);
    12201197
    1221         tcp_conn_unlock(conn);
     1198        fibril_mutex_unlock(&conn->lock);
    12221199        tcp_conn_delref(conn);
    1223 
    1224         log_msg(LOG_DEFAULT, LVL_DEBUG, "tw_timeout_func(%p) end", conn);
    12251200}
    12261201
     
    12311206void tcp_conn_tw_timer_set(tcp_conn_t *conn)
    12321207{
    1233         log_msg(LOG_DEFAULT, LVL_DEBUG2, "tcp_conn_tw_timer_set() begin");
    12341208        tcp_conn_addref(conn);
    1235         fibril_timer_set_locked(conn->tw_timer, TIME_WAIT_TIMEOUT,
    1236             tw_timeout_func, (void *)conn);
    1237         log_msg(LOG_DEFAULT, LVL_DEBUG2, "tcp_conn_tw_timer_set() end");
     1209        fibril_timer_set(conn->tw_timer, TIME_WAIT_TIMEOUT, tw_timeout_func,
     1210            (void *)conn);
    12381211}
    12391212
     
    12441217void tcp_conn_tw_timer_clear(tcp_conn_t *conn)
    12451218{
    1246         log_msg(LOG_DEFAULT, LVL_DEBUG2, "tcp_conn_tw_timer_clear() begin");
    1247         if (fibril_timer_clear_locked(conn->tw_timer) == fts_active)
     1219        if (fibril_timer_clear(conn->tw_timer) == fts_active)
    12481220                tcp_conn_delref(conn);
    1249         log_msg(LOG_DEFAULT, LVL_DEBUG2, "tcp_conn_tw_timer_clear() end");
    12501221}
    12511222
  • uspace/srv/net/tcp/conn.h

    raf2a76c rb8e75319  
    5050extern void tcp_conn_addref(tcp_conn_t *);
    5151extern void tcp_conn_delref(tcp_conn_t *);
    52 extern void tcp_conn_lock(tcp_conn_t *);
    53 extern void tcp_conn_unlock(tcp_conn_t *);
    5452extern bool tcp_conn_got_syn(tcp_conn_t *);
    5553extern void tcp_conn_segment_arrived(tcp_conn_t *, tcp_segment_t *);
  • uspace/srv/net/tcp/iqueue.c

    raf2a76c rb8e75319  
    148148        list_remove(&iqe->link);
    149149        *seg = iqe->seg;
    150         free(iqe);
    151150
    152151        return EOK;
  • uspace/srv/net/tcp/rqueue.c

    raf2a76c rb8e75319  
    141141
    142142                tcp_as_segment_arrived(&rqe->sp, rqe->seg);
    143                 free(rqe);
    144143        }
    145144
  • uspace/srv/net/tcp/segment.c

    raf2a76c rb8e75319  
    5151void tcp_segment_delete(tcp_segment_t *seg)
    5252{
    53         free(seg->dfptr);
    5453        free(seg);
    5554}
  • uspace/srv/net/tcp/tcp.c

    raf2a76c rb8e75319  
    151151        if (rc != EOK)
    152152                log_msg(LOG_DEFAULT, LVL_ERROR, "Failed to transmit PDU.");
    153 
    154         free(pdu_raw);
    155153}
    156154
  • uspace/srv/net/tcp/tqueue.c

    raf2a76c rb8e75319  
    5959static void tcp_tqueue_timer_clear(tcp_conn_t *conn);
    6060
    61 #include <stdio.h>
    6261int tcp_tqueue_init(tcp_tqueue_t *tqueue, tcp_conn_t *conn)
    6362{
    64         printf("tcp_tqueue_init\n");
    6563        tqueue->conn = conn;
    66         tqueue->timer = fibril_timer_create(&conn->lock);
     64        tqueue->timer = fibril_timer_create();
    6765        if (tqueue->timer == NULL)
    6866                return ENOMEM;
     
    8078void tcp_tqueue_fini(tcp_tqueue_t *tqueue)
    8179{
    82         printf("tcp_tqueue_fini\n");
    8380        if (tqueue->timer != NULL) {
    8481                fibril_timer_destroy(tqueue->timer);
     
    9592        seg = tcp_segment_make_ctrl(ctrl);
    9693        tcp_tqueue_seg(conn, seg);
    97         tcp_segment_delete(seg);
    9894}
    9995
     
    216212
    217213        tcp_tqueue_seg(conn, seg);
    218         tcp_segment_delete(seg);
    219214}
    220215
     
    322317        log_msg(LOG_DEFAULT, LVL_DEBUG, "### %s: retransmit_timeout_func(%p)", conn->name, conn);
    323318
    324         tcp_conn_lock(conn);
     319        fibril_mutex_lock(&conn->lock);
    325320
    326321        if (conn->cstate == st_closed) {
    327322                log_msg(LOG_DEFAULT, LVL_DEBUG, "Connection already closed.");
    328                 tcp_conn_unlock(conn);
     323                fibril_mutex_unlock(&conn->lock);
    329324                tcp_conn_delref(conn);
    330325                return;
     
    334329        if (link == NULL) {
    335330                log_msg(LOG_DEFAULT, LVL_DEBUG, "Nothing to retransmit");
    336                 tcp_conn_unlock(conn);
     331                fibril_mutex_unlock(&conn->lock);
    337332                tcp_conn_delref(conn);
    338333                return;
     
    344339        if (rt_seg == NULL) {
    345340                log_msg(LOG_DEFAULT, LVL_ERROR, "Memory allocation failed.");
    346                 tcp_conn_unlock(conn);
     341                fibril_mutex_unlock(&conn->lock);
    347342                tcp_conn_delref(conn);
    348343                /* XXX Handle properly */
     
    356351        tcp_tqueue_timer_set(tqe->conn);
    357352
    358         tcp_conn_unlock(conn);
     353        fibril_mutex_unlock(&conn->lock);
    359354        tcp_conn_delref(conn);
    360 
    361         log_msg(LOG_DEFAULT, LVL_DEBUG, "### %s: retransmit_timeout_func(%p) end", conn->name, conn);
    362355}
    363356
     
    365358static void tcp_tqueue_timer_set(tcp_conn_t *conn)
    366359{
    367         log_msg(LOG_DEFAULT, LVL_DEBUG, "### %s: tcp_tqueue_timer_set() begin", conn->name);
     360        log_msg(LOG_DEFAULT, LVL_DEBUG, "### %s: tcp_tqueue_timer_set()", conn->name);
    368361
    369362        /* Clear first to make sure we update refcnt correctly */
     
    371364
    372365        tcp_conn_addref(conn);
    373         fibril_timer_set_locked(conn->retransmit.timer, RETRANSMIT_TIMEOUT,
     366        fibril_timer_set(conn->retransmit.timer, RETRANSMIT_TIMEOUT,
    374367            retransmit_timeout_func, (void *) conn);
    375 
    376         log_msg(LOG_DEFAULT, LVL_DEBUG, "### %s: tcp_tqueue_timer_set() end", conn->name);
    377368}
    378369
     
    380371static void tcp_tqueue_timer_clear(tcp_conn_t *conn)
    381372{
    382         log_msg(LOG_DEFAULT, LVL_DEBUG, "### %s: tcp_tqueue_timer_clear() begin", conn->name);
    383 
    384         if (fibril_timer_clear_locked(conn->retransmit.timer) == fts_active)
     373        log_msg(LOG_DEFAULT, LVL_DEBUG, "### %s: tcp_tqueue_timer_clear()", conn->name);
     374
     375        if (fibril_timer_clear(conn->retransmit.timer) == fts_active)
    385376                tcp_conn_delref(conn);
    386 
    387         log_msg(LOG_DEFAULT, LVL_DEBUG, "### %s: tcp_tqueue_timer_clear() end", conn->name);
    388377}
    389378
  • uspace/srv/net/tcp/ucall.c

    raf2a76c rb8e75319  
    9090        /* Wait for connection to be established or reset */
    9191        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_uc_open: Wait for connection.");
    92         tcp_conn_lock(nconn);
     92        fibril_mutex_lock(&nconn->lock);
    9393        while (nconn->cstate == st_listen ||
    9494            nconn->cstate == st_syn_sent ||
     
    100100                log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_uc_open: Connection was reset.");
    101101                assert(nconn->cstate == st_closed);
    102                 tcp_conn_unlock(nconn);
     102                fibril_mutex_unlock(&nconn->lock);
    103103                return TCP_ERESET;
    104104        }
    105105
    106         tcp_conn_unlock(nconn);
     106        fibril_mutex_unlock(&nconn->lock);
    107107        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_uc_open: Connection was established.");
    108108
     
    121121        log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: tcp_uc_send()", conn->name);
    122122
    123         tcp_conn_lock(conn);
     123        fibril_mutex_lock(&conn->lock);
    124124
    125125        if (conn->cstate == st_closed) {
    126                 tcp_conn_unlock(conn);
     126                fibril_mutex_unlock(&conn->lock);
    127127                return TCP_ENOTEXIST;
    128128        }
     
    135135
    136136        if (conn->snd_buf_fin) {
    137                 tcp_conn_unlock(conn);
     137                fibril_mutex_unlock(&conn->lock);
    138138                return TCP_ECLOSING;
    139139        }
     
    149149
    150150                if (conn->reset) {
    151                         tcp_conn_unlock(conn);
     151                        fibril_mutex_unlock(&conn->lock);
    152152                        return TCP_ERESET;
    153153                }
     
    165165
    166166        tcp_tqueue_new_data(conn);
    167         tcp_conn_unlock(conn);
     167        fibril_mutex_unlock(&conn->lock);
    168168
    169169        return TCP_EOK;
     
    178178        log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: tcp_uc_receive()", conn->name);
    179179
    180         tcp_conn_lock(conn);
     180        fibril_mutex_lock(&conn->lock);
    181181
    182182        if (conn->cstate == st_closed) {
    183                 tcp_conn_unlock(conn);
     183                fibril_mutex_unlock(&conn->lock);
    184184                return TCP_ENOTEXIST;
    185185        }
     
    197197                if (conn->rcv_buf_fin) {
    198198                        /* End of data, peer closed connection */
    199                         tcp_conn_unlock(conn);
     199                        fibril_mutex_unlock(&conn->lock);
    200200                        return TCP_ECLOSING;
    201201                } else {
    202202                        /* Connection was reset */
    203203                        assert(conn->reset);
    204                         tcp_conn_unlock(conn);
     204                        fibril_mutex_unlock(&conn->lock);
    205205                        return TCP_ERESET;
    206206                }
     
    227227            conn->name, xfer_size);
    228228
    229         tcp_conn_unlock(conn);
     229        fibril_mutex_unlock(&conn->lock);
    230230
    231231        return TCP_EOK;
     
    238238            conn);
    239239
    240         tcp_conn_lock(conn);
     240        fibril_mutex_lock(&conn->lock);
    241241
    242242        if (conn->cstate == st_closed) {
    243243                log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_uc_close - ENOTEXIST");
    244                 tcp_conn_unlock(conn);
     244                fibril_mutex_unlock(&conn->lock);
    245245                return TCP_ENOTEXIST;
    246246        }
     
    250250                tcp_conn_reset(conn);
    251251                tcp_conn_remove(conn);
    252                 tcp_conn_unlock(conn);
    253252                return TCP_EOK;
    254253        }
     
    256255        if (conn->snd_buf_fin) {
    257256                log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_uc_close - ECLOSING");
    258                 tcp_conn_unlock(conn);
     257                fibril_mutex_unlock(&conn->lock);
    259258                return TCP_ECLOSING;
    260259        }
     
    264263        tcp_tqueue_new_data(conn);
    265264
    266         tcp_conn_unlock(conn);
     265        fibril_mutex_unlock(&conn->lock);
    267266        return TCP_EOK;
    268267}
     
    322321        }
    323322
    324         tcp_conn_lock(conn);
     323        fibril_mutex_lock(&conn->lock);
    325324
    326325        if (conn->cstate == st_closed) {
    327326                log_msg(LOG_DEFAULT, LVL_WARN, "Connection is closed.");
    328327                tcp_unexpected_segment(sp, seg);
    329                 tcp_conn_unlock(conn);
     328                fibril_mutex_unlock(&conn->lock);
    330329                tcp_conn_delref(conn);
    331330                return;
     
    343342        tcp_conn_segment_arrived(conn, seg);
    344343
    345         tcp_conn_unlock(conn);
     344        fibril_mutex_unlock(&conn->lock);
    346345        tcp_conn_delref(conn);
    347346}
  • uspace/srv/net/udp/udp_inet.c

    raf2a76c rb8e75319  
    7171
    7272        udp_received_pdu(pdu);
    73 
    74         /* We don't want udp_pdu_delete() to free dgram->data */
    75         pdu->data = NULL;
    7673        udp_pdu_delete(pdu);
    7774
Note: See TracChangeset for help on using the changeset viewer.