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