Changes in / [af2a76c:b8e75319] in mainline
- Files:
-
- 4 added
- 5 deleted
- 55 edited
Legend:
- Unmodified
- Added
- Removed
-
.bzrignore
raf2a76c rb8e75319 45 45 uspace/app/nettest2/nettest2 46 46 uspace/app/nettest3/nettest3 47 uspace/app/nic/nic48 47 uspace/app/nterm/nterm 49 48 uspace/app/ping/ping … … 95 94 uspace/dist/app/nettest2 96 95 uspace/dist/app/nettest3 97 uspace/dist/app/nic98 96 uspace/dist/app/nterm 99 97 uspace/dist/app/ping -
boot/Makefile.common
raf2a76c rb8e75319 190 190 $(USPACE_PATH)/app/mkexfat/mkexfat \ 191 191 $(USPACE_PATH)/app/mkmfs/mkmfs \ 192 $(USPACE_PATH)/app/nic/nic \193 192 $(USPACE_PATH)/app/sbi/sbi \ 194 193 $(USPACE_PATH)/app/sportdmp/sportdmp \ -
kernel/arch/amd64/Makefile.inc
raf2a76c rb8e75319 32 32 33 33 FPU_NO_CFLAGS = -mno-sse -mno-sse2 34 CMN1 = -m64 -mcmodel= kernel-mno-red-zone -fno-unwind-tables -fno-omit-frame-pointer34 CMN1 = -m64 -mcmodel=large -mno-red-zone -fno-unwind-tables -fno-omit-frame-pointer 35 35 GCC_CFLAGS += $(CMN1) 36 36 ICC_CFLAGS += $(CMN1) -
kernel/arch/amd64/include/arch/mm/km.h
raf2a76c rb8e75319 38 38 #include <typedefs.h> 39 39 40 #define KM_AMD64_IDENTITY_START UINT64_C(0xffff ffff80000000)41 #define KM_AMD64_IDENTITY_SIZE UINT64_C(0x0000 000080000000)40 #define KM_AMD64_IDENTITY_START UINT64_C(0xffff800000000000) 41 #define KM_AMD64_IDENTITY_SIZE UINT64_C(0x0000400000000000) 42 42 43 #define KM_AMD64_NON_IDENTITY_START UINT64_C(0xffff 800000000000)44 #define KM_AMD64_NON_IDENTITY_SIZE UINT64_C(0x0000 7fff80000000)43 #define KM_AMD64_NON_IDENTITY_START UINT64_C(0xffffc00000000000) 44 #define KM_AMD64_NON_IDENTITY_SIZE UINT64_C(0x0000400000000000) 45 45 46 46 extern void km_identity_arch_init(void); -
kernel/arch/amd64/include/arch/mm/page.h
raf2a76c rb8e75319 44 44 #ifndef __ASM__ 45 45 46 #define KA2PA(x) (((uintptr_t) (x)) - UINT64_C(0xffff ffff80000000))47 #define PA2KA(x) (((uintptr_t) (x)) + UINT64_C(0xffff ffff80000000))46 #define KA2PA(x) (((uintptr_t) (x)) - UINT64_C(0xffff800000000000)) 47 #define PA2KA(x) (((uintptr_t) (x)) + UINT64_C(0xffff800000000000)) 48 48 49 49 #else /* __ASM__ */ 50 50 51 #define KA2PA(x) ((x) - 0xffff ffff80000000)52 #define PA2KA(x) ((x) + 0xffff ffff80000000)51 #define KA2PA(x) ((x) - 0xffff800000000000) 52 #define PA2KA(x) ((x) + 0xffff800000000000) 53 53 54 54 #endif /* __ASM__ */ -
kernel/arch/amd64/src/boot/multiboot.S
raf2a76c rb8e75319 428 428 429 429 /* Call arch_pre_main(multiboot_eax, multiboot_ebx) */ 430 xorq %rdi, %rdi 430 431 movl multiboot_eax, %edi 432 xorq %rsi, %rsi 431 433 movl multiboot_ebx, %esi 432 callq arch_pre_main 433 434 435 movabsq $arch_pre_main, %rax 436 callq *%rax 437 434 438 long_status $status_main 435 439 436 440 /* Call main_bsp() */ 437 callq main_bsp 441 movabsq $main_bsp, %rax 442 call *%rax 438 443 439 444 /* Not reached */ … … 633 638 .quad ptl_2_6g + (PTL_WRITABLE | PTL_PRESENT) 634 639 .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 640 641 641 642 .align 4096 … … 643 644 ptl_0: 644 645 .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT) 645 .fill 510, 8, 0646 .fill 255, 8, 0 646 647 .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT) 648 .fill 255, 8, 0 647 649 648 650 .section K_DATA_START, "aw", @progbits -
kernel/arch/amd64/src/boot/multiboot2.S
raf2a76c rb8e75319 244 244 245 245 /* Call arch_pre_main(multiboot_eax, multiboot_ebx) */ 246 xorq %rdi, %rdi 246 247 movl multiboot_eax, %edi 248 xorq %rsi, %rsi 247 249 movl multiboot_ebx, %esi 248 callq arch_pre_main 250 251 movabsq $arch_pre_main, %rax 252 callq *%rax 249 253 250 254 /* Call main_bsp() */ 251 callq main_bsp 255 movabsq $main_bsp, %rax 256 call *%rax 252 257 253 258 /* Not reached */ -
kernel/arch/amd64/src/mm/km.c
raf2a76c rb8e75319 40 40 { 41 41 config.identity_base = KM_AMD64_IDENTITY_START; 42 config.identity_size = KM_AMD64_IDENTITY_SIZE; 42 config.identity_size = KM_AMD64_IDENTITY_SIZE; 43 43 } 44 44 -
kernel/genarch/src/mm/page_pt.c
raf2a76c rb8e75319 384 384 addr - 1 < base + size - 1; 385 385 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 397 386 uintptr_t l1 = PA2KA(frame_alloc(frames, FRAME_LOWMEM, 0)); 398 387 memsetb((void *) l1, FRAMES2SIZE(frames), 0); -
uspace/Makefile
raf2a76c rb8e75319 77 77 app/nettest2 \ 78 78 app/nettest3 \ 79 app/nic \80 79 app/ping \ 81 80 app/sysinfo \ -
uspace/app/mixerctl/mixerctl.c
raf2a76c rb8e75319 35 35 #include <assert.h> 36 36 #include <errno.h> 37 #include <loc.h>38 37 #include <str_error.h> 39 38 #include <str.h> 39 #include <devman.h> 40 40 #include <audio_mixer_iface.h> 41 41 #include <stdio.h> 42 42 43 #define DEFAULT_ SERVICE "devices/\\hw\\pci0\\00:01.0\\sb16\\control"43 #define DEFAULT_DEVICE "/hw/pci0/00:01.0/sb16/control" 44 44 45 45 /** … … 128 128 int main(int argc, char *argv[]) 129 129 { 130 const char * service = DEFAULT_SERVICE;130 const char *device = DEFAULT_DEVICE; 131 131 void (*command)(async_exch_t *, int, char*[]) = NULL; 132 132 … … 134 134 command = set_level; 135 135 if (argc == 5) 136 service = argv[1];136 device = argv[1]; 137 137 } 138 138 … … 140 140 command = get_level; 141 141 if (argc == 4) 142 service = argv[1];142 device = argv[1]; 143 143 } 144 144 145 145 if ((argc == 2 && command == NULL)) 146 service = argv[1];146 device = argv[1]; 147 147 148 148 149 service_id_t mixer_sid;150 int r c = loc_service_get_id(service, &mixer_sid, 0);151 if (r c!= 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)); 154 154 return 1; 155 155 } 156 156 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); 159 159 if (!session) { 160 printf("Failed connecting mixer service '%s'.\n", service);160 printf("Failed to connect to device.\n"); 161 161 return 1; 162 162 } -
uspace/app/taskdump/Makefile
raf2a76c rb8e75319 33 33 SOURCES = \ 34 34 elf_core.c \ 35 fibrildump.c \36 35 taskdump.c \ 37 36 symtab.c -
uspace/app/taskdump/include/symtab.h
raf2a76c rb8e75319 50 50 extern int symtab_load(const char *file_name, symtab_t **symtab); 51 51 extern void symtab_delete(symtab_t *st); 52 extern int symtab_name_to_addr(symtab_t *st, c onst char *name, uintptr_t *addr);52 extern int symtab_name_to_addr(symtab_t *st, char *name, uintptr_t *addr); 53 53 extern int symtab_addr_to_name(symtab_t *symtab, uintptr_t addr, char **name, 54 54 size_t *offs); -
uspace/app/taskdump/symtab.c
raf2a76c rb8e75319 202 202 * @return EOK on success, ENOENT if no such symbol was found. 203 203 */ 204 int symtab_name_to_addr(symtab_t *st, c onst char *name, uintptr_t *addr)204 int symtab_name_to_addr(symtab_t *st, char *name, uintptr_t *addr) 205 205 { 206 206 size_t i; -
uspace/app/taskdump/taskdump.c
raf2a76c rb8e75319 35 35 #include <async.h> 36 36 #include <elf/elf_linux.h> 37 #include <fibrildump.h>38 37 #include <stdio.h> 39 38 #include <stdlib.h> … … 53 52 #include <elf_core.h> 54 53 #include <stacktrace.h> 55 #include <taskdump.h>56 54 57 55 #define LINE_BYTES 16 … … 78 76 static istate_t reg_state; 79 77 80 static stacktrace_ops_t td_stacktrace_ops = {81 .read_uintptr = td_read_uintptr82 };83 84 78 int main(int argc, char *argv[]) 85 79 { … … 112 106 if (rc < 0) 113 107 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");118 108 119 109 udebug_end(sess); … … 321 311 } 322 312 323 int td_stacktrace(uintptr_t fp, uintptr_t pc) 324 { 325 uintptr_t nfp; 313 static int thread_dump(uintptr_t thash) 314 { 315 istate_t istate; 316 uintptr_t pc, fp, nfp; 326 317 stacktrace_t st; 327 318 char *sym_pc; 328 319 int rc; 329 320 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 330 338 st.op_arg = NULL; 331 st. ops = &td_stacktrace_ops;339 st.read_uintptr = td_read_uintptr; 332 340 333 341 while (stacktrace_fp_valid(&st, fp)) { … … 346 354 fp = nfp; 347 355 } 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);377 356 378 357 return EOK; -
uspace/app/vlaunch/vlaunch.c
raf2a76c rb8e75319 200 200 } 201 201 202 timer = fibril_timer_create( NULL);202 timer = fibril_timer_create(); 203 203 if (!timer) { 204 204 printf("Unable to create timer.\n"); -
uspace/drv/bus/isa/isa.c
raf2a76c rb8e75319 355 355 356 356 /* Get the name part of the rest of the line. */ 357 str _tok(line, ":", NULL);357 strtok(line, ":"); 358 358 return line; 359 359 } -
uspace/drv/fb/amdm37x_dispc/amdm37x_dispc.c
raf2a76c rb8e75319 34 34 */ 35 35 36 #include <align.h>37 36 #include <assert.h> 38 37 #include <errno.h> -
uspace/drv/fb/amdm37x_dispc/main.c
raf2a76c rb8e75319 35 35 */ 36 36 37 #include <ddf/driver.h>38 37 #include <ddf/log.h> 39 38 #include <errno.h> 40 39 #include <str_error.h> 41 40 #include <stdio.h> 41 #include <ops/graph_dev.h> 42 42 #include <graph.h> 43 43 … … 46 46 #define NAME "amdm37x_dispc" 47 47 48 static void graph_vsl_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)49 { 50 visualizer_t *vsl;48 static graph_dev_ops_t graph_vsl_dev_ops = { 49 .connect = (connect_func) &graph_visualizer_connection 50 }; 51 51 52 vsl = (visualizer_t *) ddf_fun_data_get((ddf_fun_t *)arg); 53 graph_visualizer_connection(vsl, iid, icall, NULL);54 } 52 static ddf_dev_ops_t graph_fun_ops = { 53 .interfaces[GRAPH_DEV_IFACE] = &graph_vsl_dev_ops 54 }; 55 55 56 56 static int amdm37x_dispc_dev_add(ddf_dev_t *dev) … … 74 74 vis->reg_svc_handle = ddf_fun_get_handle(fun); 75 75 76 ddf_fun_set_ conn_handler(fun, graph_vsl_connection);76 ddf_fun_set_ops(fun, &graph_fun_ops); 77 77 /* Hw part */ 78 78 amdm37x_dispc_t *dispc = -
uspace/drv/fb/kfb/kfb.c
raf2a76c rb8e75319 40 40 #include <task.h> 41 41 #include <graph.h> 42 #include <ops/graph_dev.h> 42 43 #include "port.h" 43 44 #include "kfb.h" … … 59 60 }; 60 61 62 static graph_dev_ops_t graph_vsl_dev_ops = { 63 .connect = (connect_func) &graph_visualizer_connection 64 }; 65 66 ddf_dev_ops_t graph_vsl_device_ops = { 67 .interfaces[GRAPH_DEV_IFACE] = &graph_vsl_dev_ops 68 }; 69 70 static graph_dev_ops_t graph_rnd_dev_ops = { 71 .connect = (connect_func) &graph_renderer_connection 72 }; 73 74 ddf_dev_ops_t graph_rnd_device_ops = { 75 .interfaces[GRAPH_DEV_IFACE] = &graph_rnd_dev_ops 76 }; 77 61 78 int main(int argc, char *argv[]) 62 79 { -
uspace/drv/fb/kfb/port.c
raf2a76c rb8e75319 207 207 }; 208 208 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 217 209 int port_init(ddf_dev_t *dev) 218 210 { … … 354 346 return ENOMEM; 355 347 } 356 ddf_fun_set_ conn_handler(fun_vs, &graph_vsl_connection);348 ddf_fun_set_ops(fun_vs, &graph_vsl_device_ops); 357 349 358 350 visualizer_t *vs = ddf_fun_data_alloc(fun_vs, sizeof(visualizer_t)); -
uspace/lib/c/arch/amd64/src/stacktrace.c
raf2a76c rb8e75319 51 51 int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev) 52 52 { 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); 54 54 } 55 55 56 56 int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra) 57 57 { 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); 59 59 } 60 60 -
uspace/lib/c/arch/arm32/src/stacktrace.c
raf2a76c rb8e75319 51 51 int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev) 52 52 { 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); 54 54 } 55 55 56 56 int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra) 57 57 { 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); 59 59 } 60 60 -
uspace/lib/c/arch/ia32/src/stacktrace.c
raf2a76c rb8e75319 51 51 int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev) 52 52 { 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); 54 54 } 55 55 56 56 int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra) 57 57 { 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); 59 59 } 60 60 -
uspace/lib/c/arch/ppc32/src/stacktrace.c
raf2a76c rb8e75319 51 51 int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev) 52 52 { 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); 54 54 } 55 55 56 56 int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra) 57 57 { 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); 59 59 } 60 60 -
uspace/lib/c/arch/sparc32/src/stacktrace.c
raf2a76c rb8e75319 53 53 { 54 54 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, 56 56 &bprev); 57 57 if (rc == EOK) … … 63 63 int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra) 64 64 { 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); 66 66 } 67 67 -
uspace/lib/c/arch/sparc64/src/stacktrace.c
raf2a76c rb8e75319 55 55 int rc; 56 56 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); 58 58 if (rc == EOK) 59 59 *prev = bprev + STACK_BIAS; … … 63 63 int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra) 64 64 { 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); 66 66 } 67 67 -
uspace/lib/c/generic/fibril.c
raf2a76c rb8e75319 59 59 static LIST_INITIALIZE(serialized_list); 60 60 static LIST_INITIALIZE(manager_list); 61 static LIST_INITIALIZE(fibril_list);62 61 63 62 /** Number of threads that are executing a manager fibril. */ … … 117 116 118 117 fibril->waits_for = NULL; 119 list_append(&fibril->all_link, &fibril_list);120 118 121 119 return fibril; … … 124 122 void fibril_teardown(fibril_t *fibril) 125 123 { 126 list_remove(&fibril->all_link);127 124 tls_free(fibril->tcb); 128 125 free(fibril); -
uspace/lib/c/generic/fibril_synch.c
raf2a76c rb8e75319 448 448 int rc; 449 449 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) 457 463 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); 474 472 } 475 473 } 476 474 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); 482 476 return 0; 483 477 } … … 487 481 * @return New timer on success, @c NULL if out of memory. 488 482 */ 489 fibril_timer_t *fibril_timer_create( fibril_mutex_t *lock)483 fibril_timer_t *fibril_timer_create(void) 490 484 { 491 485 fid_t fid; … … 507 501 timer->fibril = fid; 508 502 timer->state = fts_not_set; 509 timer->lockp = (lock != NULL) ? lock : &timer->lock;510 503 511 504 fibril_add_ready(fid); 505 512 506 return timer; 513 507 } … … 519 513 void fibril_timer_destroy(fibril_timer_t *timer) 520 514 { 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); 525 517 timer->state = fts_cleanup; 526 518 fibril_condvar_broadcast(&timer->cv); 527 fibril_mutex_unlock( timer->lockp);519 fibril_mutex_unlock(&timer->lock); 528 520 } 529 521 … … 541 533 fibril_timer_fun_t fun, void *arg) 542 534 { 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); 563 536 timer->state = fts_active; 564 537 timer->delay = delay; … … 566 539 timer->arg = arg; 567 540 fibril_condvar_broadcast(&timer->cv); 541 fibril_mutex_unlock(&timer->lock); 568 542 } 569 543 … … 583 557 fibril_timer_state_t old_state; 584 558 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); 613 560 old_state = timer->state; 614 561 timer->state = fts_not_set; … … 618 565 timer->arg = NULL; 619 566 fibril_condvar_broadcast(&timer->cv); 567 fibril_mutex_unlock(&timer->lock); 620 568 621 569 return old_state; -
uspace/lib/c/generic/inet.c
raf2a76c rb8e75319 1 1 /* 2 * Copyright (c) 201 3Jiri Svoboda2 * Copyright (c) 2012 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 34 34 #include <ipc/services.h> 35 35 #include <loc.h> 36 #include <stdlib.h>37 36 38 37 static void inet_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg); … … 225 224 226 225 rc = inet_ev_ops->recv(&dgram); 227 free(dgram.data);228 226 async_answer_0(iid, rc); 229 227 } -
uspace/lib/c/generic/stacktrace.c
raf2a76c rb8e75319 42 42 static int stacktrace_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data); 43 43 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) 44 void stacktrace_print_fp_pc(uintptr_t fp, uintptr_t pc) 50 45 { 51 46 stacktrace_t st; 52 47 uintptr_t nfp; 53 int rc;54 48 55 st.op_arg = arg;56 st. ops = ops;49 st.op_arg = NULL; 50 st.read_uintptr = stacktrace_read_uintptr; 57 51 58 52 while (stacktrace_fp_valid(&st, fp)) { 59 53 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); 66 56 fp = nfp; 67 57 } 68 }69 70 void stacktrace_print_fp_pc(uintptr_t fp, uintptr_t pc)71 {72 stacktrace_print_generic(&basic_ops, NULL, fp, pc);73 58 } 74 59 -
uspace/lib/c/generic/str.c
raf2a76c rb8e75319 1360 1360 } 1361 1361 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) 1362 char *strtok(char *s, const char *delim) 1363 { 1364 static char *next; 1365 1366 return strtok_r(s, delim, &next); 1367 } 1368 1369 char *strtok_r(char *s, const char *delim, char **next) 1375 1370 { 1376 1371 char *start, *end; 1377 1372 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; 1385 1375 1386 1376 /* 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; 1391 1379 1392 1380 /* 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) { 1401 1386 return NULL; /* No more tokens. */ 1387 } 1402 1388 1403 1389 /* Overwrite delimiter with NULL terminator. */ -
uspace/lib/c/include/fibril.h
raf2a76c rb8e75319 67 67 typedef struct fibril { 68 68 link_t link; 69 link_t all_link;70 69 context_t ctx; 71 70 void *stack; -
uspace/lib/c/include/fibril_synch.h
raf2a76c rb8e75319 116 116 /** Timer has fired and has not been cleared since */ 117 117 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 122 120 } fibril_timer_state_t; 123 121 … … 131 129 typedef struct { 132 130 fibril_mutex_t lock; 133 fibril_mutex_t *lockp;134 131 fibril_condvar_t cv; 135 132 fid_t fibril; 136 133 fibril_timer_state_t state; 137 bool handler_running;138 134 139 135 suseconds_t delay; … … 164 160 extern void fibril_condvar_broadcast(fibril_condvar_t *); 165 161 166 extern fibril_timer_t *fibril_timer_create( fibril_mutex_t *);162 extern fibril_timer_t *fibril_timer_create(void); 167 163 extern void fibril_timer_destroy(fibril_timer_t *); 168 164 extern void fibril_timer_set(fibril_timer_t *, suseconds_t, fibril_timer_fun_t, 169 165 void *); 170 extern void fibril_timer_set_locked(fibril_timer_t *, suseconds_t,171 fibril_timer_fun_t, void *);172 166 extern fibril_timer_state_t fibril_timer_clear(fibril_timer_t *); 173 extern fibril_timer_state_t fibril_timer_clear_locked(fibril_timer_t *);174 167 175 168 #endif -
uspace/lib/c/include/ipc/dev_iface.h
raf2a76c rb8e75319 40 40 /** Character device interface */ 41 41 CHAR_DEV_IFACE, 42 43 /** Graphic device interface */ 44 GRAPH_DEV_IFACE, 42 45 43 46 /** Audio device mixer interface */ -
uspace/lib/c/include/stacktrace.h
raf2a76c rb8e75319 41 41 42 42 typedef struct { 43 void *op_arg; 43 44 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;49 45 } stacktrace_t; 50 46 51 47 extern void stacktrace_print(void); 52 48 extern void stacktrace_print_fp_pc(uintptr_t, uintptr_t); 53 extern void stacktrace_print_generic(stacktrace_ops_t *, void *, uintptr_t,54 uintptr_t);55 49 56 50 /* -
uspace/lib/c/include/str.h
raf2a76c rb8e75319 109 109 extern char *str_ndup(const char *, size_t max_size); 110 110 111 extern char *str_tok(char *, const char *, char **);112 113 111 extern int str_uint8_t(const char *, const char **, unsigned int, bool, 114 112 uint8_t *); … … 134 132 extern unsigned long strtoul(const char *, char **, int); 135 133 134 extern char * strtok_r(char *, const char *, char **); 135 extern char * strtok(char *, const char *); 136 136 137 #endif 137 138 -
uspace/lib/drv/Makefile
raf2a76c rb8e75319 47 47 generic/remote_pio_window.c \ 48 48 generic/remote_char_dev.c \ 49 generic/remote_graph_dev.c \ 49 50 generic/remote_nic.c \ 50 51 generic/remote_usb.c \ -
uspace/lib/drv/generic/dev_iface.c
raf2a76c rb8e75319 45 45 #include "remote_led_dev.h" 46 46 #include "remote_battery_dev.h" 47 #include "remote_graph_dev.h" 47 48 #include "remote_nic.h" 48 49 #include "remote_usb.h" … … 61 62 [PIO_WINDOW_DEV_IFACE] = &remote_pio_window_iface, 62 63 [CHAR_DEV_IFACE] = &remote_char_dev_iface, 64 [GRAPH_DEV_IFACE] = &remote_graph_dev_iface, 63 65 [NIC_DEV_IFACE] = &remote_nic_iface, 64 66 [PCI_DEV_IFACE] = &remote_pci_iface, -
uspace/lib/graph/graph.c
raf2a76c rb8e75319 58 58 visualizer_t *graph_alloc_visualizer(void) 59 59 { 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; 61 66 } 62 67 … … 64 69 { 65 70 // 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; 67 77 } 68 78 … … 88 98 int graph_register_visualizer(visualizer_t *vs) 89 99 { 100 int rc = EOK; 101 90 102 char node[LOC_NAME_MAXLEN + 1]; 91 103 snprintf(node, LOC_NAME_MAXLEN, "%s%zu/%s%zu", NAMESPACE, 92 104 namespace_idx, VISUALIZER_NAME, visualizer_idx++); 93 105 94 106 category_id_t cat; 95 intrc = loc_category_get_id("visualizer", &cat, 0);96 if (rc != EOK) 107 rc = loc_category_get_id("visualizer", &cat, 0); 108 if (rc != EOK) { 97 109 return rc; 98 110 } 111 99 112 rc = loc_service_register(node, &vs->reg_svc_handle); 100 if (rc != EOK) 113 if (rc != EOK) { 101 114 return rc; 102 115 } 116 103 117 rc = loc_service_add_to_cat(vs->reg_svc_handle, cat); 104 118 if (rc != EOK) { … … 106 120 return rc; 107 121 } 108 122 109 123 fibril_mutex_lock(&visualizer_list_mtx); 110 124 list_append(&vs->link, &visualizer_list); 111 125 fibril_mutex_unlock(&visualizer_list_mtx); 112 126 113 127 return rc; 114 128 } … … 116 130 int graph_register_renderer(renderer_t *rnd) 117 131 { 132 int rc = EOK; 133 118 134 char node[LOC_NAME_MAXLEN + 1]; 119 135 snprintf(node, LOC_NAME_MAXLEN, "%s%zu/%s%zu", NAMESPACE, 120 136 namespace_idx, RENDERER_NAME, renderer_idx++); 121 137 122 138 category_id_t cat; 123 intrc = loc_category_get_id("renderer", &cat, 0);124 if (rc != EOK) 139 rc = loc_category_get_id("renderer", &cat, 0); 140 if (rc != EOK) { 125 141 return rc; 126 142 } 143 127 144 rc = loc_service_register(node, &rnd->reg_svc_handle); 128 if (rc != EOK) 145 if (rc != EOK) { 129 146 return rc; 130 147 } 148 131 149 rc = loc_service_add_to_cat(rnd->reg_svc_handle, cat); 132 150 if (rc != EOK) { … … 134 152 return rc; 135 153 } 136 154 137 155 fibril_mutex_lock(&renderer_list_mtx); 138 156 list_append(&rnd->link, &renderer_list); 139 157 fibril_mutex_unlock(&renderer_list_mtx); 140 158 141 159 return rc; 142 160 } … … 145 163 { 146 164 visualizer_t *vs = NULL; 147 165 148 166 fibril_mutex_lock(&visualizer_list_mtx); 149 150 167 list_foreach(visualizer_list, link, visualizer_t, vcur) { 151 168 if (vcur->reg_svc_handle == handle) { … … 154 171 } 155 172 } 156 157 173 fibril_mutex_unlock(&visualizer_list_mtx); 158 174 159 175 return vs; 160 176 } … … 163 179 { 164 180 renderer_t *rnd = NULL; 165 181 166 182 fibril_mutex_lock(&renderer_list_mtx); 167 168 183 list_foreach(renderer_list, link, renderer_t, rcur) { 169 184 if (rcur->reg_svc_handle == handle) { … … 172 187 } 173 188 } 174 175 189 fibril_mutex_unlock(&renderer_list_mtx); 176 190 177 191 return rnd; 178 192 } … … 180 194 int graph_unregister_visualizer(visualizer_t *vs) 181 195 { 196 int rc = EOK; 197 182 198 fibril_mutex_lock(&visualizer_list_mtx); 183 intrc = loc_service_unregister(vs->reg_svc_handle);199 rc = loc_service_unregister(vs->reg_svc_handle); 184 200 list_remove(&vs->link); 185 201 fibril_mutex_unlock(&visualizer_list_mtx); 186 202 187 203 return rc; 188 204 } … … 190 206 int graph_unregister_renderer(renderer_t *rnd) 191 207 { 208 int rc = EOK; 209 192 210 fibril_mutex_lock(&renderer_list_mtx); 193 intrc = loc_service_unregister(rnd->reg_svc_handle);211 rc = loc_service_unregister(rnd->reg_svc_handle); 194 212 list_remove(&rnd->link); 195 213 fibril_mutex_unlock(&renderer_list_mtx); 196 214 197 215 return rc; 198 216 } … … 207 225 assert(vs->cells.data == NULL); 208 226 assert(vs->dev_ctx == NULL); 209 227 210 228 free(vs); 211 229 } … … 215 233 // TODO 216 234 assert(atomic_get(&rnd->ref_cnt) == 0); 217 235 218 236 free(rnd); 219 237 } … … 224 242 int ret = async_req_2_0(exch, VISUALIZER_MODE_CHANGE, handle, mode_idx); 225 243 async_exchange_end(exch); 226 244 227 245 return ret; 228 246 } … … 233 251 int ret = async_req_1_0(exch, VISUALIZER_DISCONNECT, handle); 234 252 async_exchange_end(exch); 235 253 236 254 async_hangup(sess); 237 255 238 256 return ret; 239 257 } … … 255 273 } 256 274 } 257 275 258 276 /* Driver might also deallocate resources for the current mode. */ 259 277 int rc = vs->ops.yield(vs); 260 278 261 279 /* Now that the driver was given a chance to deallocate resources, 262 280 * current mode can be unset. */ 263 if (vs->mode_set) 281 if (vs->mode_set) { 264 282 vs->mode_set = false; 265 283 } 284 266 285 async_answer_0(iid, rc); 267 286 } … … 269 288 static void vs_enumerate_modes(visualizer_t *vs, ipc_callid_t iid, ipc_call_t *icall) 270 289 { 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 280 290 fibril_mutex_lock(&vs->mode_mtx); 281 291 link_t *link = list_nth(&vs->modes, IPC_GET_ARG1(*icall)); 282 292 283 293 if (link != NULL) { 284 294 vslmode_list_element_t *mode_elem = 285 295 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); 289 313 } else { 290 async_answer_0(callid, ENOENT);291 314 async_answer_0(iid, ENOENT); 292 315 } 293 294 fibril_mutex_unlock(&vs->mode_mtx);295 316 } 296 317 297 318 static void vs_get_default_mode(visualizer_t *vs, ipc_callid_t iid, ipc_call_t *icall) 298 319 { 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 308 320 fibril_mutex_lock(&vs->mode_mtx); 309 321 vslmode_list_element_t *mode_elem = NULL; 310 311 322 list_foreach(vs->modes, link, vslmode_list_element_t, cur) { 312 323 if (cur->mode.index == vs->def_mode_idx) { … … 315 326 } 316 327 } 317 328 329 vslmode_t mode; 318 330 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); 321 347 } else { 322 348 fibril_mutex_unlock(&vs->mode_mtx); 323 async_answer_0(callid, ENOENT);324 349 async_answer_0(iid, ENOENT); 325 350 } 326 327 fibril_mutex_unlock(&vs->mode_mtx);328 351 } 329 352 330 353 static void vs_get_current_mode(visualizer_t *vs, ipc_callid_t iid, ipc_call_t *icall) 331 354 { 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 341 355 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 } 342 363 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); 344 370 } else { 345 async_answer_0(callid, ENOENT);346 371 async_answer_0(iid, ENOENT); 347 372 } … … 350 375 static void vs_get_mode(visualizer_t *vs, ipc_callid_t iid, ipc_call_t *icall) 351 376 { 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 361 377 sysarg_t mode_idx = IPC_GET_ARG1(*icall); 362 378 363 379 fibril_mutex_lock(&vs->mode_mtx); 364 380 vslmode_list_element_t *mode_elem = NULL; 365 366 381 list_foreach(vs->modes, link, vslmode_list_element_t, cur) { 367 382 if (cur->mode.index == mode_idx) { … … 370 385 } 371 386 } 372 387 388 vslmode_t mode; 373 389 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); 376 406 } else { 377 async_answer_0(callid, ENOENT);407 fibril_mutex_unlock(&vs->mode_mtx); 378 408 async_answer_0(iid, ENOENT); 379 409 } 380 381 fibril_mutex_unlock(&vs->mode_mtx);382 410 } 383 411 384 412 static void vs_set_mode(visualizer_t *vs, ipc_callid_t iid, ipc_call_t *icall) 385 413 { 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 386 447 ipc_callid_t callid; 387 448 size_t size; 388 449 unsigned int flags; 389 450 390 451 /* Retrieve the shared cell storage for the new mode. */ 391 452 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);426 453 async_answer_0(iid, EINVAL); 427 454 return; 428 455 } 429 430 456 void *new_cell_storage; 431 intrc = async_share_out_finalize(callid, &new_cell_storage);457 rc = async_share_out_finalize(callid, &new_cell_storage); 432 458 if ((rc != EOK) || (new_cell_storage == AS_MAP_FAILED)) { 433 459 async_answer_0(iid, ENOMEM); 434 460 return; 435 461 } 436 462 437 463 /* Change device internal state. */ 438 464 rc = vs->ops.change_mode(vs, new_mode); 439 465 440 466 /* Device driver could not establish new mode. Rollback. */ 441 467 if (rc != EOK) { … … 444 470 return; 445 471 } 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. */ 452 475 if (vs->mode_set) { 453 476 if (vs->cells.data != NULL) { … … 456 479 } 457 480 } 458 481 459 482 /* Insert new mode into the visualizer. */ 460 483 vs->cells.width = new_mode.screen_width; … … 463 486 vs->cur_mode = new_mode; 464 487 vs->mode_set = true; 465 488 466 489 async_answer_0(iid, EOK); 467 490 } … … 476 499 sysarg_t y_offset = (IPC_GET_ARG5(*icall) & 0xffffffff); 477 500 #endif 478 501 479 502 int rc = vs->ops.handle_damage(vs, 480 503 IPC_GET_ARG1(*icall), IPC_GET_ARG2(*icall), 481 504 IPC_GET_ARG3(*icall), IPC_GET_ARG4(*icall), 482 505 x_offset, y_offset); 483 506 async_answer_0(iid, rc); 484 507 } … … 501 524 ipc_call_t call; 502 525 ipc_callid_t callid; 503 526 504 527 /* Claim the visualizer. */ 505 528 if (!cas(&vs->ref_cnt, 0, 1)) { … … 507 530 return; 508 531 } 509 532 510 533 /* Accept the connection. */ 511 534 async_answer_0(iid, EOK); 512 535 513 536 /* Establish callback session. */ 514 537 callid = async_get_call(&call); 515 538 vs->notif_sess = async_callback_receive_start(EXCHANGE_SERIALIZE, &call); 516 if (vs->notif_sess != NULL) 539 if (vs->notif_sess != NULL) { 517 540 async_answer_0(callid, EOK); 518 else541 } else { 519 542 async_answer_0(callid, ELIMIT); 520 543 } 544 521 545 /* Enter command loop. */ 522 546 while (true) { 523 547 callid = async_get_call(&call); 524 548 525 549 if (!IPC_GET_IMETHOD(call)) { 526 550 async_answer_0(callid, EINVAL); 527 551 break; 528 552 } 529 553 530 554 switch (IPC_GET_IMETHOD(call)) { 531 555 case VISUALIZER_CLAIM: … … 564 588 } 565 589 } 566 590 567 591 terminate: 568 592 async_hangup(vs->notif_sess); … … 575 599 { 576 600 // TODO 577 601 578 602 ipc_call_t call; 579 603 ipc_callid_t callid; 580 604 581 605 /* Accept the connection. */ 582 606 atomic_inc(&rnd->ref_cnt); 583 607 async_answer_0(iid, EOK); 584 608 585 609 /* Enter command loop. */ 586 610 while (true) { 587 611 callid = async_get_call(&call); 588 612 589 613 if (!IPC_GET_IMETHOD(call)) { 590 614 async_answer_0(callid, EINVAL); 591 615 break; 592 616 } 593 617 594 618 switch (IPC_GET_IMETHOD(call)) { 595 619 default: … … 598 622 } 599 623 } 600 624 601 625 terminate: 602 626 atomic_dec(&rnd->ref_cnt); … … 608 632 visualizer_t *vs = graph_get_visualizer(IPC_GET_ARG1(*icall)); 609 633 renderer_t *rnd = graph_get_renderer(IPC_GET_ARG1(*icall)); 610 611 if (vs != NULL) 634 635 if (vs != NULL) { 612 636 graph_visualizer_connection(vs, iid, icall, arg); 613 else if (rnd != NULL)637 } else if (rnd != NULL) { 614 638 graph_renderer_connection(rnd, iid, icall, arg); 615 else639 } else { 616 640 async_answer_0(iid, ENOENT); 641 } 617 642 } 618 643 -
uspace/srv/devman/main.c
raf2a76c rb8e75319 116 116 117 117 fwd_h = dev->pfun->handle; 118 } else {118 } else if (dev->state == DEVICE_USABLE) { 119 119 /* Connect to the specified function */ 120 120 driver = dev->drv; 121 assert(driver != NULL); 122 121 123 fwd_h = handle; 122 124 } -
uspace/srv/fs/fat/fat_ops.c
raf2a76c rb8e75319 930 930 /* Parse mount options. */ 931 931 char *mntopts = (char *) opts; 932 char *saveptr; 932 933 char *opt; 933 while ((opt = str _tok(mntopts, " ,", &mntopts)) != NULL) {934 while ((opt = strtok_r(mntopts, " ,", &saveptr)) != NULL) { 934 935 if (str_cmp(opt, "wtcache") == 0) 935 936 cmode = CACHE_MODE_WT; 936 937 else if (str_cmp(opt, "nolfn") == 0) 937 938 instance->lfn_enabled = false; 939 mntopts = NULL; 938 940 } 939 941 -
uspace/srv/hid/compositor/compositor.c
raf2a76c rb8e75319 55 55 #include <async.h> 56 56 #include <loc.h> 57 #include <devman.h> 57 58 58 59 #include <event.h> 60 #include <graph_iface.h> 59 61 #include <io/keycode.h> 60 62 #include <io/mode.h> … … 1147 1149 } 1148 1150 1149 static async_sess_t *vsl_connect( service_id_t sid,const char *svc)1151 static async_sess_t *vsl_connect(const char *svc) 1150 1152 { 1151 1153 int rc; 1152 1154 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) { 1157 1160 return NULL; 1158 1161 } 1159 1162 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 1160 1184 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); 1162 1186 async_exchange_end(exch); 1163 1187 … … 1172 1196 } 1173 1197 1174 static viewport_t *viewport_create( service_id_t sid)1198 static viewport_t *viewport_create(const char *vsl_name) 1175 1199 { 1176 1200 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 } 1188 1206 1189 1207 link_initialize(&vp->link); … … 1192 1210 1193 1211 /* 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 } 1198 1218 1199 1219 /* Claim the given visualizer. */ 1200 1220 rc = visualizer_claim(vp->sess, 0); 1201 1221 if (rc != EOK) { 1222 async_hangup(vp->sess); 1223 free(vp); 1202 1224 printf("%s: Unable to claim visualizer (%s)\n", NAME, str_error(rc)); 1203 goto error; 1204 } 1205 1206 claimed = true; 1225 return NULL; 1226 } 1207 1227 1208 1228 /* Retrieve the default mode. */ 1209 1229 rc = visualizer_get_default_mode(vp->sess, &vp->mode); 1210 1230 if (rc != EOK) { 1231 visualizer_yield(vp->sess); 1232 async_hangup(vp->sess); 1233 free(vp); 1211 1234 printf("%s: Unable to retrieve mode (%s)\n", NAME, str_error(rc)); 1212 goto error;1235 return NULL; 1213 1236 } 1214 1237 … … 1217 1240 NULL, SURFACE_FLAG_SHARED); 1218 1241 if (vp->surface == NULL) { 1242 visualizer_yield(vp->sess); 1243 async_hangup(vp->sess); 1244 free(vp); 1219 1245 printf("%s: Unable to create surface (%s)\n", NAME, str_error(rc)); 1220 goto error;1246 return NULL; 1221 1247 } 1222 1248 … … 1225 1251 vp->mode.index, vp->mode.version, surface_direct_access(vp->surface)); 1226 1252 if (rc != EOK) { 1253 visualizer_yield(vp->sess); 1254 surface_destroy(vp->surface); 1255 async_hangup(vp->sess); 1256 free(vp); 1227 1257 printf("%s: Unable to set mode (%s)\n", NAME, str_error(rc)); 1228 goto error;1258 return NULL; 1229 1259 } 1230 1260 1231 1261 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;1240 1262 } 1241 1263 … … 2168 2190 continue; 2169 2191 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 } 2173 2200 } 2174 2201 fibril_mutex_unlock(&viewport_list_mtx); -
uspace/srv/logger/initlvl.c
raf2a76c rb8e75319 44 44 { 45 45 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); 48 48 if (key == NULL) 49 49 return; … … 76 76 { 77 77 char *tmp; 78 char *single_setting = str _tok(settings, " ", &tmp);78 char *single_setting = strtok_r(settings, " ", &tmp); 79 79 while (single_setting != NULL) { 80 80 parse_single_level_setting(single_setting); 81 single_setting = str _tok(tmp, " ", &tmp);81 single_setting = strtok_r(NULL, " ", &tmp); 82 82 } 83 83 } -
uspace/srv/net/dhcp/dhcp.c
raf2a76c rb8e75319 304 304 break; 305 305 case opt_dns_server: 306 if (opt_len < 4 || opt_len % 4 != 0)306 if (opt_len != 4) 307 307 return EINVAL; 308 /* XXX Handle multiple DNS servers properly */309 308 inet_addr_set(dhcp_uint32_decode(&msgb[i]), 310 309 &offer->dns_server); … … 436 435 437 436 dlink->link_id = link_id; 438 dlink->timeout = fibril_timer_create( NULL);437 dlink->timeout = fibril_timer_create(); 439 438 if (dlink->timeout == NULL) { 440 439 rc = ENOMEM; -
uspace/srv/net/inetsrv/inetsrv.c
raf2a76c rb8e75319 296 296 297 297 uint8_t ttl = IPC_GET_ARG3(*icall); 298 int df = IPC_GET_ARG 4(*icall);298 int df = IPC_GET_ARG3(*icall); 299 299 300 300 ipc_callid_t callid; -
uspace/srv/net/tcp/conn.c
raf2a76c rb8e75319 78 78 goto error; 79 79 80 fibril_mutex_initialize(&conn->lock); 81 82 conn->tw_timer = fibril_timer_create(&conn->lock); 80 conn->tw_timer = fibril_timer_create(); 83 81 if (conn->tw_timer == NULL) 84 82 goto error; 83 84 fibril_mutex_initialize(&conn->lock); 85 85 86 86 /* One for the user, one for not being in closed state */ … … 200 200 if (atomic_predec(&conn->refcnt) == 0) 201 201 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 including208 * its timers. Must not be called inside any of the connection209 * timer handlers.210 *211 * @param conn Connection212 */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 Connection221 */222 void tcp_conn_unlock(tcp_conn_t *conn)223 {224 fibril_mutex_unlock(&conn->lock);225 202 } 226 203 … … 1206 1183 log_msg(LOG_DEFAULT, LVL_DEBUG, "tw_timeout_func(%p)", conn); 1207 1184 1208 tcp_conn_lock(conn);1185 fibril_mutex_lock(&conn->lock); 1209 1186 1210 1187 if (conn->cstate == st_closed) { 1211 1188 log_msg(LOG_DEFAULT, LVL_DEBUG, "Connection already closed."); 1212 tcp_conn_unlock(conn);1189 fibril_mutex_unlock(&conn->lock); 1213 1190 tcp_conn_delref(conn); 1214 1191 return; … … 1219 1196 tcp_conn_state_set(conn, st_closed); 1220 1197 1221 tcp_conn_unlock(conn);1198 fibril_mutex_unlock(&conn->lock); 1222 1199 tcp_conn_delref(conn); 1223 1224 log_msg(LOG_DEFAULT, LVL_DEBUG, "tw_timeout_func(%p) end", conn);1225 1200 } 1226 1201 … … 1231 1206 void tcp_conn_tw_timer_set(tcp_conn_t *conn) 1232 1207 { 1233 log_msg(LOG_DEFAULT, LVL_DEBUG2, "tcp_conn_tw_timer_set() begin");1234 1208 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); 1238 1211 } 1239 1212 … … 1244 1217 void tcp_conn_tw_timer_clear(tcp_conn_t *conn) 1245 1218 { 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) 1248 1220 tcp_conn_delref(conn); 1249 log_msg(LOG_DEFAULT, LVL_DEBUG2, "tcp_conn_tw_timer_clear() end");1250 1221 } 1251 1222 -
uspace/srv/net/tcp/conn.h
raf2a76c rb8e75319 50 50 extern void tcp_conn_addref(tcp_conn_t *); 51 51 extern 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 *);54 52 extern bool tcp_conn_got_syn(tcp_conn_t *); 55 53 extern void tcp_conn_segment_arrived(tcp_conn_t *, tcp_segment_t *); -
uspace/srv/net/tcp/iqueue.c
raf2a76c rb8e75319 148 148 list_remove(&iqe->link); 149 149 *seg = iqe->seg; 150 free(iqe);151 150 152 151 return EOK; -
uspace/srv/net/tcp/rqueue.c
raf2a76c rb8e75319 141 141 142 142 tcp_as_segment_arrived(&rqe->sp, rqe->seg); 143 free(rqe);144 143 } 145 144 -
uspace/srv/net/tcp/segment.c
raf2a76c rb8e75319 51 51 void tcp_segment_delete(tcp_segment_t *seg) 52 52 { 53 free(seg->dfptr);54 53 free(seg); 55 54 } -
uspace/srv/net/tcp/tcp.c
raf2a76c rb8e75319 151 151 if (rc != EOK) 152 152 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed to transmit PDU."); 153 154 free(pdu_raw);155 153 } 156 154 -
uspace/srv/net/tcp/tqueue.c
raf2a76c rb8e75319 59 59 static void tcp_tqueue_timer_clear(tcp_conn_t *conn); 60 60 61 #include <stdio.h>62 61 int tcp_tqueue_init(tcp_tqueue_t *tqueue, tcp_conn_t *conn) 63 62 { 64 printf("tcp_tqueue_init\n");65 63 tqueue->conn = conn; 66 tqueue->timer = fibril_timer_create( &conn->lock);64 tqueue->timer = fibril_timer_create(); 67 65 if (tqueue->timer == NULL) 68 66 return ENOMEM; … … 80 78 void tcp_tqueue_fini(tcp_tqueue_t *tqueue) 81 79 { 82 printf("tcp_tqueue_fini\n");83 80 if (tqueue->timer != NULL) { 84 81 fibril_timer_destroy(tqueue->timer); … … 95 92 seg = tcp_segment_make_ctrl(ctrl); 96 93 tcp_tqueue_seg(conn, seg); 97 tcp_segment_delete(seg);98 94 } 99 95 … … 216 212 217 213 tcp_tqueue_seg(conn, seg); 218 tcp_segment_delete(seg);219 214 } 220 215 … … 322 317 log_msg(LOG_DEFAULT, LVL_DEBUG, "### %s: retransmit_timeout_func(%p)", conn->name, conn); 323 318 324 tcp_conn_lock(conn);319 fibril_mutex_lock(&conn->lock); 325 320 326 321 if (conn->cstate == st_closed) { 327 322 log_msg(LOG_DEFAULT, LVL_DEBUG, "Connection already closed."); 328 tcp_conn_unlock(conn);323 fibril_mutex_unlock(&conn->lock); 329 324 tcp_conn_delref(conn); 330 325 return; … … 334 329 if (link == NULL) { 335 330 log_msg(LOG_DEFAULT, LVL_DEBUG, "Nothing to retransmit"); 336 tcp_conn_unlock(conn);331 fibril_mutex_unlock(&conn->lock); 337 332 tcp_conn_delref(conn); 338 333 return; … … 344 339 if (rt_seg == NULL) { 345 340 log_msg(LOG_DEFAULT, LVL_ERROR, "Memory allocation failed."); 346 tcp_conn_unlock(conn);341 fibril_mutex_unlock(&conn->lock); 347 342 tcp_conn_delref(conn); 348 343 /* XXX Handle properly */ … … 356 351 tcp_tqueue_timer_set(tqe->conn); 357 352 358 tcp_conn_unlock(conn);353 fibril_mutex_unlock(&conn->lock); 359 354 tcp_conn_delref(conn); 360 361 log_msg(LOG_DEFAULT, LVL_DEBUG, "### %s: retransmit_timeout_func(%p) end", conn->name, conn);362 355 } 363 356 … … 365 358 static void tcp_tqueue_timer_set(tcp_conn_t *conn) 366 359 { 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); 368 361 369 362 /* Clear first to make sure we update refcnt correctly */ … … 371 364 372 365 tcp_conn_addref(conn); 373 fibril_timer_set _locked(conn->retransmit.timer, RETRANSMIT_TIMEOUT,366 fibril_timer_set(conn->retransmit.timer, RETRANSMIT_TIMEOUT, 374 367 retransmit_timeout_func, (void *) conn); 375 376 log_msg(LOG_DEFAULT, LVL_DEBUG, "### %s: tcp_tqueue_timer_set() end", conn->name);377 368 } 378 369 … … 380 371 static void tcp_tqueue_timer_clear(tcp_conn_t *conn) 381 372 { 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) 385 376 tcp_conn_delref(conn); 386 387 log_msg(LOG_DEFAULT, LVL_DEBUG, "### %s: tcp_tqueue_timer_clear() end", conn->name);388 377 } 389 378 -
uspace/srv/net/tcp/ucall.c
raf2a76c rb8e75319 90 90 /* Wait for connection to be established or reset */ 91 91 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_uc_open: Wait for connection."); 92 tcp_conn_lock(nconn);92 fibril_mutex_lock(&nconn->lock); 93 93 while (nconn->cstate == st_listen || 94 94 nconn->cstate == st_syn_sent || … … 100 100 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_uc_open: Connection was reset."); 101 101 assert(nconn->cstate == st_closed); 102 tcp_conn_unlock(nconn);102 fibril_mutex_unlock(&nconn->lock); 103 103 return TCP_ERESET; 104 104 } 105 105 106 tcp_conn_unlock(nconn);106 fibril_mutex_unlock(&nconn->lock); 107 107 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_uc_open: Connection was established."); 108 108 … … 121 121 log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: tcp_uc_send()", conn->name); 122 122 123 tcp_conn_lock(conn);123 fibril_mutex_lock(&conn->lock); 124 124 125 125 if (conn->cstate == st_closed) { 126 tcp_conn_unlock(conn);126 fibril_mutex_unlock(&conn->lock); 127 127 return TCP_ENOTEXIST; 128 128 } … … 135 135 136 136 if (conn->snd_buf_fin) { 137 tcp_conn_unlock(conn);137 fibril_mutex_unlock(&conn->lock); 138 138 return TCP_ECLOSING; 139 139 } … … 149 149 150 150 if (conn->reset) { 151 tcp_conn_unlock(conn);151 fibril_mutex_unlock(&conn->lock); 152 152 return TCP_ERESET; 153 153 } … … 165 165 166 166 tcp_tqueue_new_data(conn); 167 tcp_conn_unlock(conn);167 fibril_mutex_unlock(&conn->lock); 168 168 169 169 return TCP_EOK; … … 178 178 log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: tcp_uc_receive()", conn->name); 179 179 180 tcp_conn_lock(conn);180 fibril_mutex_lock(&conn->lock); 181 181 182 182 if (conn->cstate == st_closed) { 183 tcp_conn_unlock(conn);183 fibril_mutex_unlock(&conn->lock); 184 184 return TCP_ENOTEXIST; 185 185 } … … 197 197 if (conn->rcv_buf_fin) { 198 198 /* End of data, peer closed connection */ 199 tcp_conn_unlock(conn);199 fibril_mutex_unlock(&conn->lock); 200 200 return TCP_ECLOSING; 201 201 } else { 202 202 /* Connection was reset */ 203 203 assert(conn->reset); 204 tcp_conn_unlock(conn);204 fibril_mutex_unlock(&conn->lock); 205 205 return TCP_ERESET; 206 206 } … … 227 227 conn->name, xfer_size); 228 228 229 tcp_conn_unlock(conn);229 fibril_mutex_unlock(&conn->lock); 230 230 231 231 return TCP_EOK; … … 238 238 conn); 239 239 240 tcp_conn_lock(conn);240 fibril_mutex_lock(&conn->lock); 241 241 242 242 if (conn->cstate == st_closed) { 243 243 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_uc_close - ENOTEXIST"); 244 tcp_conn_unlock(conn);244 fibril_mutex_unlock(&conn->lock); 245 245 return TCP_ENOTEXIST; 246 246 } … … 250 250 tcp_conn_reset(conn); 251 251 tcp_conn_remove(conn); 252 tcp_conn_unlock(conn);253 252 return TCP_EOK; 254 253 } … … 256 255 if (conn->snd_buf_fin) { 257 256 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_uc_close - ECLOSING"); 258 tcp_conn_unlock(conn);257 fibril_mutex_unlock(&conn->lock); 259 258 return TCP_ECLOSING; 260 259 } … … 264 263 tcp_tqueue_new_data(conn); 265 264 266 tcp_conn_unlock(conn);265 fibril_mutex_unlock(&conn->lock); 267 266 return TCP_EOK; 268 267 } … … 322 321 } 323 322 324 tcp_conn_lock(conn);323 fibril_mutex_lock(&conn->lock); 325 324 326 325 if (conn->cstate == st_closed) { 327 326 log_msg(LOG_DEFAULT, LVL_WARN, "Connection is closed."); 328 327 tcp_unexpected_segment(sp, seg); 329 tcp_conn_unlock(conn);328 fibril_mutex_unlock(&conn->lock); 330 329 tcp_conn_delref(conn); 331 330 return; … … 343 342 tcp_conn_segment_arrived(conn, seg); 344 343 345 tcp_conn_unlock(conn);344 fibril_mutex_unlock(&conn->lock); 346 345 tcp_conn_delref(conn); 347 346 } -
uspace/srv/net/udp/udp_inet.c
raf2a76c rb8e75319 71 71 72 72 udp_received_pdu(pdu); 73 74 /* We don't want udp_pdu_delete() to free dgram->data */75 pdu->data = NULL;76 73 udp_pdu_delete(pdu); 77 74
Note:
See TracChangeset
for help on using the changeset viewer.