Changeset 84876aa4 in mainline
- Timestamp:
- 2019-11-15T13:46:34Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ecb7828
- Parents:
- b093a62 (diff), d548fc0 (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:
-
- 9 added
- 50 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
abi/include/abi/syscall.h
rb093a62 r84876aa4 36 36 #define _ABI_SYSCALL_H_ 37 37 38 /** System calls. 39 * 40 * If you are adding or removing syscalls, or changing the number of 41 * their arguments, please update syscall description table 42 * in @c uspace/app/trace/syscalls.c 43 */ 38 44 typedef enum { 39 45 SYS_KIO = 0, -
kernel/generic/include/cap/cap.h
rb093a62 r84876aa4 70 70 } kobject_ops_t; 71 71 72 extern kobject_ops_t *kobject_ops[]; 73 74 #define KOBJECT_OP(k) kobject_ops[(k)->type] 75 72 76 /* 73 77 * Everything in kobject_t except for the atomic reference count, the capability … … 82 86 /** List of published capabilities associated with the kobject */ 83 87 list_t caps_list; 84 85 kobject_ops_t *ops;86 88 87 89 union { … … 139 141 extern kobject_t *kobject_alloc(unsigned int); 140 142 extern void kobject_free(kobject_t *); 141 extern void kobject_initialize(kobject_t *, kobject_type_t, void *, 142 kobject_ops_t *); 143 extern void kobject_initialize(kobject_t *, kobject_type_t, void *); 143 144 extern kobject_t *kobject_get(struct task *, cap_handle_t, kobject_type_t); 144 145 extern void kobject_add_ref(kobject_t *); -
kernel/generic/include/ipc/ipc.h
rb093a62 r84876aa4 172 172 extern answerbox_t *ipc_box_0; 173 173 174 extern kobject_ops_t call_kobject_ops; 175 174 176 extern void ipc_init(void); 175 177 -
kernel/generic/include/ipc/ipcrsc.h
rb093a62 r84876aa4 40 40 #include <cap/cap.h> 41 41 42 extern kobject_ops_t phone_kobject_ops; 43 42 44 extern errno_t phone_alloc(task_t *, bool, cap_phone_handle_t *, kobject_t **); 43 45 extern void phone_dealloc(cap_phone_handle_t); -
kernel/generic/include/ipc/irq.h
rb093a62 r84876aa4 46 46 #include <typedefs.h> 47 47 #include <adt/list.h> 48 #include <cap/cap.h> 49 50 extern kobject_ops_t irq_kobject_ops; 48 51 49 52 extern irq_ownership_t ipc_irq_top_half_claim(irq_t *); -
kernel/generic/include/synch/syswaitq.h
rb093a62 r84876aa4 38 38 #include <typedefs.h> 39 39 #include <abi/cap.h> 40 #include <cap/cap.h> 41 42 extern kobject_ops_t waitq_kobject_ops; 40 43 41 44 extern void sys_waitq_init(void); -
kernel/generic/src/cap/cap.c
rb093a62 r84876aa4 83 83 #include <mm/slab.h> 84 84 #include <adt/list.h> 85 #include <synch/syswaitq.h> 86 #include <ipc/ipcrsc.h> 87 #include <ipc/ipc.h> 88 #include <ipc/irq.h> 85 89 86 90 #include <limits.h> … … 94 98 static slab_cache_t *cap_cache; 95 99 static slab_cache_t *kobject_cache; 100 101 kobject_ops_t *kobject_ops[KOBJECT_TYPE_MAX] = { 102 [KOBJECT_TYPE_CALL] = &call_kobject_ops, 103 [KOBJECT_TYPE_IRQ] = &irq_kobject_ops, 104 [KOBJECT_TYPE_PHONE] = &phone_kobject_ops, 105 [KOBJECT_TYPE_WAITQ] = &waitq_kobject_ops 106 }; 96 107 97 108 static size_t caps_hash(const ht_link_t *item) … … 412 423 * @param type Type of the kernel object. 413 424 * @param raw Raw pointer to the encapsulated object. 414 * @param ops Pointer to kernel object operations for the respective type. 415 */ 416 void kobject_initialize(kobject_t *kobj, kobject_type_t type, void *raw, 417 kobject_ops_t *ops) 425 */ 426 void kobject_initialize(kobject_t *kobj, kobject_type_t type, void *raw) 418 427 { 419 428 atomic_store(&kobj->refcnt, 1); … … 424 433 kobj->type = type; 425 434 kobj->raw = raw; 426 kobj->ops = ops;427 435 } 428 436 … … 474 482 { 475 483 if (atomic_postdec(&kobj->refcnt) == 1) { 476 kobj->ops->destroy(kobj->raw);484 KOBJECT_OP(kobj)->destroy(kobj->raw); 477 485 kobject_free(kobj); 478 486 } -
kernel/generic/src/ipc/ipc.c
rb093a62 r84876aa4 100 100 } 101 101 102 statickobject_ops_t call_kobject_ops = {102 kobject_ops_t call_kobject_ops = { 103 103 .destroy = call_destroy 104 104 }; … … 127 127 128 128 _ipc_call_init(call); 129 kobject_initialize(kobj, KOBJECT_TYPE_CALL, call , &call_kobject_ops);129 kobject_initialize(kobj, KOBJECT_TYPE_CALL, call); 130 130 call->kobject = kobj; 131 131 -
kernel/generic/src/ipc/ipcrsc.c
rb093a62 r84876aa4 52 52 } 53 53 54 statickobject_ops_t phone_kobject_ops = {54 kobject_ops_t phone_kobject_ops = { 55 55 .destroy = phone_destroy 56 56 }; … … 94 94 phone->hangup_call = hcall; 95 95 96 kobject_initialize(kobj, KOBJECT_TYPE_PHONE, phone, 97 &phone_kobject_ops); 96 kobject_initialize(kobj, KOBJECT_TYPE_PHONE, phone); 98 97 phone->kobject = kobj; 99 98 -
kernel/generic/src/ipc/irq.c
rb093a62 r84876aa4 306 306 } 307 307 308 statickobject_ops_t irq_kobject_ops = {308 kobject_ops_t irq_kobject_ops = { 309 309 .destroy = irq_destroy 310 310 }; … … 385 385 irq_spinlock_unlock(&irq_uspace_hash_table_lock, true); 386 386 387 kobject_initialize(kobject, KOBJECT_TYPE_IRQ, irq , &irq_kobject_ops);387 kobject_initialize(kobject, KOBJECT_TYPE_IRQ, irq); 388 388 cap_publish(TASK, handle, kobject); 389 389 -
kernel/generic/src/mm/malloc.c
rb093a62 r84876aa4 187 187 void *malloc(size_t size) 188 188 { 189 if (size + _offset < size) 190 return NULL; 191 189 192 void *obj = mem_alloc(alignof(max_align_t), size + _offset) + _offset; 190 193 -
kernel/generic/src/synch/syswaitq.c
rb093a62 r84876aa4 54 54 } 55 55 56 statickobject_ops_t waitq_kobject_ops = {56 kobject_ops_t waitq_kobject_ops = { 57 57 .destroy = waitq_destroy 58 58 }; … … 100 100 return (sys_errno_t) ENOMEM; 101 101 } 102 kobject_initialize(kobj, KOBJECT_TYPE_WAITQ, wq , &waitq_kobject_ops);102 kobject_initialize(kobj, KOBJECT_TYPE_WAITQ, wq); 103 103 104 104 cap_handle_t handle; -
kernel/generic/src/udebug/udebug.c
rb093a62 r84876aa4 479 479 mutex_unlock(&THREAD->udebug.lock); 480 480 481 /* Make sure the debugging session is over before proceeding. */ 482 mutex_lock(&THREAD->udebug.lock); 483 while (THREAD->udebug.active) 484 condvar_wait(&THREAD->udebug.active_cv, &THREAD->udebug.lock); 485 mutex_unlock(&THREAD->udebug.lock); 486 481 /* 482 * This is where we will typically block until a post-mortem debugger 483 * terminates the debugging session. 484 */ 487 485 udebug_stoppable_end(); 488 486 } -
meson/part/exports/config.mk.in
rb093a62 r84876aa4 1 1 # Generated from config.mk.in using Meson. Do not modify. 2 2 # Do not forget to set HELENOS_EXPORT_ROOT when using the file. 3 HELENOS_OVERLAY_PATH="@HELENOS_OVERLAY_PATH@" 3 4 HELENOS_CROSS_PATH="@HELENOS_CROSS_PATH@" 4 5 HELENOS_ARCH="@HELENOS_ARCH@" -
meson/part/exports/meson.build
rb093a62 r84876aa4 62 62 63 63 conf_data = configuration_data({ 64 'HELENOS_OVERLAY_PATH' : meson.source_root() / 'uspace/overlay', 64 65 'HELENOS_CROSS_PATH' : cc_path, 65 66 'HELENOS_ARCH' : cc_arch, -
meson/part/extra_targets/meson.build
rb093a62 r84876aa4 72 72 ) 73 73 74 run_target('doxygen', command: [ doxygen, _dox_cfg ]) 74 run_target('doxygen', command: [ 75 sh, 76 '-c', 'cd $1 && $2 $3', 77 '--', 78 meson.source_root() / 'doxygen', 79 doxygen.path(), 80 _dox_cfg, 81 ]) 75 82 endif 76 83 -
tools/xcw/bin/helenos-cc
rb093a62 r84876aa4 35 35 36 36 XCW="$(dirname "$0")" 37 SRC_ROOT="$XCW/../../.."37 BUILD_ROOT="$(dirname "$(dirname "$(dirname "$XCW")")")" 38 38 if [ -z "$EXPORT_DIR" ]; then 39 EXPORT_DIR="$ SRC_ROOT/build/dist"39 EXPORT_DIR="$BUILD_ROOT/export" 40 40 fi 41 41 42 42 HELENOS_EXPORT_ROOT="$EXPORT_DIR" 43 43 44 source "${EXPORT_DIR}/config /config.sh"44 source "${EXPORT_DIR}/config.sh" 45 45 46 46 # CC is a compilation driver, so we should check which stage of compilation -
tools/xcw/bin/helenos-pkg-config
rb093a62 r84876aa4 33 33 34 34 XCW="$(dirname "$0")" 35 SRC_ROOT="$XCW/../../.."35 BUILD_ROOT="$(dirname "$(dirname "$(dirname "$XCW")")")" 36 36 if [ -z "$EXPORT_DIR" ]; then 37 EXPORT_DIR="$ SRC_ROOT/build/dist"37 EXPORT_DIR="$BUILD_ROOT/export" 38 38 fi 39 39 40 INCLUDE_DIR="$EXPORT_DIR/include" 40 41 LIB_DIR="$EXPORT_DIR/lib" -
tools/xcw/bin/helenos-test
rb093a62 r84876aa4 1 1 #!/bin/bash 2 2 # 3 # Copyright (c) 201 8Jiri Svoboda3 # Copyright (c) 2019 Jiri Svoboda 4 4 # All rights reserved. 5 5 # … … 33 33 34 34 XCW="$(dirname "$0")" 35 SRC_ROOT="$XCW/../../.."35 BUILD_ROOT="$(dirname "$(dirname "$(dirname "$XCW")")")" 36 36 37 cd "$ SRC_ROOT"38 make 37 cd "$BUILD_ROOT" 38 ninja image_path 39 39 tools/ew.py -
tools/xcw/demo/Makefile
rb093a62 r84876aa4 36 36 # 37 37 # cd <helenos-source-dir> 38 # make distclean && make -j 4 PROFILE=amd64 39 # cd <helenos-source-dir>/tools/xcw/demo 40 # export PATH=$PATH:<helenos-source-dir>/tools/xcw/bin 38 # mkdir build 39 # cd build 40 # ../configure.sh 41 # ninja 42 # ../tools/export.sh export 43 # cd ../tools/xcw/demo 44 # export PATH=$PATH:<helenos-source-dir>/build/tools/xcw/bin 41 45 # make 42 46 # … … 44 48 CC = helenos-cc 45 49 LD = helenos-ld 50 INSTALL = install 51 TEST = helenos-test 46 52 CFLAGS = -std=gnu11 -Wall `helenos-pkg-config --cflags libgui libdraw libmath` \ 47 53 -D_HELENOS_SOURCE 48 54 LIBS = `helenos-pkg-config --libs libgui libdraw libmath` 55 PREFIX = `helenos-bld-config --install-dir` 49 56 output = viewer 50 57 objects = viewer.o … … 56 63 rm -f $(output) $(objects) 57 64 65 install: $(output) 66 mkdir -p $(PREFIX)/app 67 $(INSTALL) -T $(output) $(PREFIX)/app/$(output)-xcw 68 69 uninstall: 70 rm -f $(PREFIX)/app/$(output)-xcw 71 72 test: install 73 $(TEST) 74 58 75 $(output): $(objects) 59 76 $(CC) -o $@ $^ $(LIBS) -
uspace/app/bdsh/cmds/modules/ls/ls.c
rb093a62 r84876aa4 42 42 #include <vfs/vfs.h> 43 43 #include <str.h> 44 #include <cap .h>44 #include <capa.h> 45 45 46 46 #include "ls.h" … … 106 106 } 107 107 108 cap _spec_t cap;109 cap _from_blocks(de->s.size, 1, &cap);110 cap _simplify(&cap);108 capa_spec_t capa; 109 capa_from_blocks(de->s.size, 1, &capa); 110 capa_simplify(&capa); 111 111 112 112 char *rptr; 113 errno_t rc = cap _format(&cap, &rptr);113 errno_t rc = capa_format(&capa, &rptr); 114 114 if (rc != EOK) { 115 115 return rc; -
uspace/app/df/df.c
rb093a62 r84876aa4 35 35 */ 36 36 37 #include <cap .h>37 #include <capa.h> 38 38 #include <stdbool.h> 39 39 #include <stdio.h> … … 124 124 static errno_t size_to_human_readable(uint64_t nblocks, size_t block_size, char **rptr) 125 125 { 126 cap _spec_t cap;127 128 cap _from_blocks(nblocks, block_size, &cap);129 cap _simplify(&cap);130 return cap _format(&cap, rptr);126 capa_spec_t capa; 127 128 capa_from_blocks(nblocks, block_size, &capa); 129 capa_simplify(&capa); 130 return capa_format(&capa, rptr); 131 131 } 132 132 -
uspace/app/fdisk/fdisk.c
rb093a62 r84876aa4 34 34 */ 35 35 36 #include <cap .h>36 #include <capa.h> 37 37 #include <errno.h> 38 38 #include <fdisk.h> … … 136 136 nchoice_t *choice = NULL; 137 137 char *svcname = NULL; 138 cap _spec_t cap;138 capa_spec_t capa; 139 139 fdisk_dev_info_t *sdev; 140 char *scap = NULL;140 char *scapa = NULL; 141 141 char *dtext = NULL; 142 142 service_id_t svcid; … … 177 177 } 178 178 179 rc = fdisk_dev_info_capacity(info, &cap );179 rc = fdisk_dev_info_capacity(info, &capa); 180 180 if (rc != EOK) { 181 181 printf("Error getting device capacity " … … 185 185 } 186 186 187 cap _simplify(&cap);188 189 rc = cap _format(&cap, &scap);187 capa_simplify(&capa); 188 189 rc = capa_format(&capa, &scapa); 190 190 if (rc != EOK) { 191 191 assert(rc == ENOMEM); … … 194 194 } 195 195 196 int ret = asprintf(&dtext, "%s (%s)", svcname, scap );196 int ret = asprintf(&dtext, "%s (%s)", svcname, scapa); 197 197 if (ret < 0) { 198 198 rc = ENOMEM; … … 203 203 free(svcname); 204 204 svcname = NULL; 205 free(scap );206 scap = NULL;205 free(scapa); 206 scapa = NULL; 207 207 208 208 rc = nchoice_add(choice, dtext, info, 0); … … 261 261 free(dtext); 262 262 free(svcname); 263 free(scap );263 free(scapa); 264 264 return rc; 265 265 } … … 432 432 errno_t rc; 433 433 fdisk_part_spec_t pspec; 434 cap _spec_t cap;435 cap _spec_t mcap;434 capa_spec_t capa; 435 capa_spec_t mcapa; 436 436 vol_label_supp_t vlsupp; 437 437 vol_fstype_t fstype = 0; 438 438 tinput_t *tinput = NULL; 439 439 fdisk_spc_t spc; 440 char *scap ;441 char *smcap = NULL;440 char *scapa; 441 char *smcapa = NULL; 442 442 char *label = NULL; 443 443 char *mountp = NULL; … … 448 448 spc = spc_pri; 449 449 450 rc = fdisk_part_get_max_avail(dev, spc, &mcap );450 rc = fdisk_part_get_max_avail(dev, spc, &mcapa); 451 451 if (rc != EOK) { 452 452 rc = EIO; … … 454 454 } 455 455 456 cap _simplify(&mcap);457 458 rc = cap _format(&mcap, &smcap);456 capa_simplify(&mcapa); 457 458 rc = capa_format(&mcapa, &smcapa); 459 459 if (rc != EOK) { 460 460 rc = ENOMEM; … … 474 474 while (true) { 475 475 printf("Enter capacity of new partition.\n"); 476 rc = tinput_read_i(tinput, smcap , &scap);476 rc = tinput_read_i(tinput, smcapa, &scapa); 477 477 if (rc != EOK) 478 478 goto error; 479 479 480 rc = cap _parse(scap, &cap);480 rc = capa_parse(scapa, &capa); 481 481 if (rc == EOK) 482 482 break; … … 485 485 tinput_destroy(tinput); 486 486 tinput = NULL; 487 free(smcap );488 smcap = NULL;487 free(smcapa); 488 smcapa = NULL; 489 489 490 490 if (pkind != lpk_extended) { … … 545 545 546 546 fdisk_pspec_init(&pspec); 547 pspec.capacity = cap ;547 pspec.capacity = capa; 548 548 pspec.pkind = pkind; 549 549 pspec.fstype = fstype; … … 561 561 return EOK; 562 562 error: 563 free(smcap );563 free(smcapa); 564 564 free(label); 565 565 free(mountp); … … 581 581 fdisk_part_t *part; 582 582 fdisk_part_info_t pinfo; 583 char *scap = NULL;583 char *scapa = NULL; 584 584 char *spkind = NULL; 585 585 char *sfstype = NULL; … … 596 596 } 597 597 598 cap _simplify(&pinfo.capacity);599 600 rc = cap _format(&pinfo.capacity, &scap);598 capa_simplify(&pinfo.capacity); 599 600 rc = capa_format(&pinfo.capacity, &scapa); 601 601 if (rc != EOK) { 602 602 printf("Out of memory.\n"); … … 623 623 624 624 int ret = asprintf(&sdesc, "%s %s, %s, %s", label, 625 scap , spkind, sfstype);625 scapa, spkind, sfstype); 626 626 if (ret < 0) { 627 627 rc = ENOMEM; … … 630 630 631 631 } else { 632 int ret = asprintf(&sdesc, "%s, %s", scap , spkind);632 int ret = asprintf(&sdesc, "%s, %s", scapa, spkind); 633 633 if (ret < 0) { 634 634 rc = ENOMEM; … … 644 644 } 645 645 646 free(scap );647 scap = NULL;646 free(scapa); 647 scapa = NULL; 648 648 free(spkind); 649 649 spkind = NULL; … … 658 658 return EOK; 659 659 error: 660 free(scap );660 free(scapa); 661 661 free(spkind); 662 662 free(sfstype); … … 907 907 fdisk_part_t *part; 908 908 fdisk_part_info_t pinfo; 909 cap _spec_t cap;910 cap _spec_t mcap;909 capa_spec_t capa; 910 capa_spec_t mcapa; 911 911 fdisk_dev_flags_t dflags; 912 912 char *sltype = NULL; 913 char *sdcap = NULL;914 char *scap = NULL;915 char *smcap = NULL;913 char *sdcapa = NULL; 914 char *scapa = NULL; 915 char *smcapa = NULL; 916 916 char *sfstype = NULL; 917 917 char *svcname = NULL; … … 936 936 } 937 937 938 rc = fdisk_dev_capacity(dev, &cap );938 rc = fdisk_dev_capacity(dev, &capa); 939 939 if (rc != EOK) { 940 940 printf("Error getting device capacity.\n"); … … 942 942 } 943 943 944 cap _simplify(&cap);945 946 rc = cap _format(&cap, &sdcap);944 capa_simplify(&capa); 945 946 rc = capa_format(&capa, &sdcapa); 947 947 if (rc != EOK) { 948 948 printf("Out of memory.\n"); … … 958 958 fdisk_dev_get_flags(dev, &dflags); 959 959 960 printf("Device: %s (%s)\n", svcname, sdcap );961 free(sdcap );962 sdcap = NULL;960 printf("Device: %s (%s)\n", svcname, sdcapa); 961 free(sdcapa); 962 sdcapa = NULL; 963 963 964 964 rc = fdisk_label_get_info(dev, &linfo); … … 996 996 } 997 997 998 cap _simplify(&pinfo.capacity);999 1000 rc = cap _format(&pinfo.capacity, &scap);998 capa_simplify(&pinfo.capacity); 999 1000 rc = capa_format(&pinfo.capacity, &scapa); 1001 1001 if (rc != EOK) { 1002 1002 printf("Out of memory.\n"); … … 1016 1016 1017 1017 if (linfo.ltype == lt_none) 1018 printf("Entire disk: %s %s", label, scap );1018 printf("Entire disk: %s %s", label, scapa); 1019 1019 else 1020 printf("Partition %d: %s %s", npart, label, scap );1020 printf("Partition %d: %s %s", npart, label, scapa); 1021 1021 1022 1022 if ((linfo.flags & lf_ext_supp) != 0) { … … 1037 1037 printf("\n"); 1038 1038 1039 free(scap );1040 scap = NULL;1039 free(scapa); 1040 scapa = NULL; 1041 1041 free(sfstype); 1042 1042 sfstype = NULL; … … 1047 1047 /* Display available space */ 1048 1048 if ((linfo.flags & lf_can_create_pri) != 0) { 1049 rc = fdisk_part_get_max_avail(dev, spc_pri, &mcap );1049 rc = fdisk_part_get_max_avail(dev, spc_pri, &mcapa); 1050 1050 if (rc != EOK) { 1051 1051 rc = EIO; … … 1053 1053 } 1054 1054 1055 cap _simplify(&mcap);1056 1057 rc = cap _format(&mcap, &smcap);1055 capa_simplify(&mcapa); 1056 1057 rc = capa_format(&mcapa, &smcapa); 1058 1058 if (rc != EOK) { 1059 1059 rc = ENOMEM; … … 1062 1062 1063 1063 if ((linfo.flags & lf_ext_supp) != 0) 1064 printf("Maximum free primary block: %s\n", smcap );1064 printf("Maximum free primary block: %s\n", smcapa); 1065 1065 else 1066 printf("Maximum free block: %s\n", smcap );1067 1068 free(smcap );1069 smcap = NULL;1070 1071 rc = fdisk_part_get_tot_avail(dev, spc_pri, &mcap );1066 printf("Maximum free block: %s\n", smcapa); 1067 1068 free(smcapa); 1069 smcapa = NULL; 1070 1071 rc = fdisk_part_get_tot_avail(dev, spc_pri, &mcapa); 1072 1072 if (rc != EOK) { 1073 1073 rc = EIO; … … 1075 1075 } 1076 1076 1077 cap _simplify(&mcap);1078 1079 rc = cap _format(&mcap, &smcap);1077 capa_simplify(&mcapa); 1078 1079 rc = capa_format(&mcapa, &smcapa); 1080 1080 if (rc != EOK) { 1081 1081 rc = ENOMEM; … … 1084 1084 1085 1085 if ((linfo.flags & lf_ext_supp) != 0) 1086 printf("Total free primary space: %s\n", smcap );1086 printf("Total free primary space: %s\n", smcapa); 1087 1087 else 1088 printf("Total free space: %s\n", smcap );1089 1090 free(smcap );1091 smcap = NULL;1088 printf("Total free space: %s\n", smcapa); 1089 1090 free(smcapa); 1091 smcapa = NULL; 1092 1092 } 1093 1093 1094 1094 /* Display available space */ 1095 1095 if ((linfo.flags & lf_can_create_log) != 0) { 1096 rc = fdisk_part_get_max_avail(dev, spc_log, &mcap );1096 rc = fdisk_part_get_max_avail(dev, spc_log, &mcapa); 1097 1097 if (rc != EOK) { 1098 1098 rc = EIO; … … 1100 1100 } 1101 1101 1102 cap _simplify(&mcap);1103 1104 rc = cap _format(&mcap, &smcap);1102 capa_simplify(&mcapa); 1103 1104 rc = capa_format(&mcapa, &smcapa); 1105 1105 if (rc != EOK) { 1106 1106 rc = ENOMEM; … … 1108 1108 } 1109 1109 1110 printf("Maximum free logical block: %s\n", smcap );1111 free(smcap );1112 smcap = NULL;1113 1114 rc = fdisk_part_get_tot_avail(dev, spc_log, &mcap );1110 printf("Maximum free logical block: %s\n", smcapa); 1111 free(smcapa); 1112 smcapa = NULL; 1113 1114 rc = fdisk_part_get_tot_avail(dev, spc_log, &mcapa); 1115 1115 if (rc != EOK) { 1116 1116 rc = EIO; … … 1118 1118 } 1119 1119 1120 cap _simplify(&mcap);1121 1122 rc = cap _format(&mcap, &smcap);1120 capa_simplify(&mcapa); 1121 1122 rc = capa_format(&mcapa, &smcapa); 1123 1123 if (rc != EOK) { 1124 1124 rc = ENOMEM; … … 1126 1126 } 1127 1127 1128 printf("Total free logical space: %s\n", smcap );1129 free(smcap );1130 smcap = NULL;1128 printf("Total free logical space: %s\n", smcapa); 1129 free(smcapa); 1130 smcapa = NULL; 1131 1131 } 1132 1132 … … 1279 1279 return EOK; 1280 1280 error: 1281 free(sdcap );1282 free(scap );1283 free(smcap );1281 free(sdcapa); 1282 free(scapa); 1283 free(smcapa); 1284 1284 free(sfstype); 1285 1285 free(svcname); -
uspace/app/sysinst/sysinst.c
rb093a62 r84876aa4 38 38 #include <block.h> 39 39 #include <byteorder.h> 40 #include <cap .h>40 #include <capa.h> 41 41 #include <errno.h> 42 42 #include <fdisk.h> … … 98 98 fdisk_part_spec_t pspec; 99 99 fdisk_part_info_t pinfo; 100 cap _spec_t cap;100 capa_spec_t capa; 101 101 service_id_t sid; 102 102 errno_t rc; … … 137 137 printf("sysinst_label_dev(): create partition\n"); 138 138 139 rc = fdisk_part_get_max_avail(fdev, spc_pri, &cap );139 rc = fdisk_part_get_max_avail(fdev, spc_pri, &capa); 140 140 if (rc != EOK) { 141 141 printf("Error getting available capacity: %s.\n", str_error(rc)); … … 144 144 145 145 fdisk_pspec_init(&pspec); 146 pspec.capacity = cap ;146 pspec.capacity = capa; 147 147 pspec.pkind = lpk_primary; 148 148 pspec.fstype = fs_ext4; /* Cannot be changed without modifying core.img */ -
uspace/app/trace/syscalls.c
rb093a62 r84876aa4 38 38 39 39 const sc_desc_t syscall_desc[] = { 40 /* System management syscalls. */ 40 41 [SYS_KIO] = { "kio", 3, V_INT_ERRNO }, 41 42 43 /* Thread and task related syscalls. */ 42 44 [SYS_THREAD_CREATE] = { "thread_create", 3, V_ERRNO }, 43 45 [SYS_THREAD_EXIT] = { "thread_exit", 1, V_ERRNO }, 44 46 [SYS_THREAD_GET_ID] = { "thread_get_id", 1, V_ERRNO }, 47 [SYS_THREAD_USLEEP] = { "thread_usleep", 1, V_ERRNO }, 48 [SYS_THREAD_UDELAY] = { "thread_udelay", 1, V_ERRNO }, 45 49 46 50 [SYS_TASK_GET_ID] = { "task_get_id", 1, V_ERRNO }, 47 51 [SYS_TASK_SET_NAME] = { "task_set_name", 2, V_ERRNO }, 52 [SYS_TASK_KILL] = { "task_kill", 1, V_ERRNO }, 53 [SYS_TASK_EXIT] = { "task_exit", 1, V_ERRNO }, 54 [SYS_PROGRAM_SPAWN_LOADER] = { "program_spawn_loader", 2, V_ERRNO }, 48 55 56 /* Synchronization related syscalls. */ 57 [SYS_WAITQ_CREATE] = { "waitq_create", 1, V_ERRNO }, 58 [SYS_WAITQ_SLEEP] = { "waitq_sleep", 3, V_ERRNO }, 59 [SYS_WAITQ_WAKEUP] = { "waitq_wakeup", 1, V_ERRNO }, 60 [SYS_WAITQ_DESTROY] = { "waitq_destroy", 1, V_ERRNO }, 61 [SYS_SMC_COHERENCE] = { "smc_coherence", 2, V_ERRNO }, 62 63 /* Address space related syscalls. */ 49 64 [SYS_AS_AREA_CREATE] = { "as_area_create", 5, V_ERRNO }, 50 65 [SYS_AS_AREA_RESIZE] = { "as_area_resize", 3, V_ERRNO }, 66 [SYS_AS_AREA_CHANGE_FLAGS] = { "as_area_change_flags", 2, V_ERRNO }, 67 [SYS_AS_AREA_GET_INFO] = { "as_area_get_info", 2, V_ERRNO }, 51 68 [SYS_AS_AREA_DESTROY] = { "as_area_destroy", 1, V_ERRNO }, 52 69 70 /* Page mapping related syscalls. */ 71 [SYS_PAGE_FIND_MAPPING] = { "page_find_mapping", 2, V_ERRNO }, 72 73 /* IPC related syscalls. */ 53 74 [SYS_IPC_CALL_ASYNC_FAST] = { "ipc_call_async_fast", 6, V_HASH }, 54 75 [SYS_IPC_CALL_ASYNC_SLOW] = { "ipc_call_async_slow", 3, V_HASH }, 55 56 76 [SYS_IPC_ANSWER_FAST] = { "ipc_answer_fast", 6, V_ERRNO }, 57 77 [SYS_IPC_ANSWER_SLOW] = { "ipc_answer_slow", 2, V_ERRNO }, … … 61 81 [SYS_IPC_POKE] = { "ipc_poke", 0, V_ERRNO }, 62 82 [SYS_IPC_HANGUP] = { "ipc_hangup", 1, V_ERRNO }, 83 [SYS_IPC_CONNECT_KBOX] = { "ipc_connect_kbox", 2, V_ERRNO }, 63 84 85 /* Event notification syscalls. */ 64 86 [SYS_IPC_EVENT_SUBSCRIBE] = { "ipc_event_subscribe", 2, V_ERRNO }, 65 87 [SYS_IPC_EVENT_UNSUBSCRIBE] = { "ipc_event_unsubscribe", 1, V_ERRNO }, 66 88 [SYS_IPC_EVENT_UNMASK] = { "ipc_event_unmask", 1, V_ERRNO }, 67 89 90 /* Permission related syscalls. */ 68 91 [SYS_PERM_GRANT] = { "perm_grant", 2, V_ERRNO }, 69 92 [SYS_PERM_REVOKE] = { "perm_revoke", 2, V_ERRNO }, 93 94 /* DDI related syscalls. */ 70 95 [SYS_PHYSMEM_MAP] = { "physmem_map", 4, V_ERRNO }, 96 [SYS_PHYSMEM_UNMAP] = { "physmem_unmap", 1, V_ERRNO }, 97 [SYS_DMAMEM_MAP] = { "dmamem_map", 6, V_ERRNO }, 98 [SYS_DMAMEM_UNMAP] = { "dmamem_unmap", 3, V_ERRNO }, 71 99 [SYS_IOSPACE_ENABLE] = { "iospace_enable", 1, V_ERRNO }, 100 [SYS_IOSPACE_DISABLE] = { "iospace_disable", 1, V_ERRNO }, 72 101 73 102 [SYS_IPC_IRQ_SUBSCRIBE] = { "ipc_irq_subscribe", 4, V_ERRNO }, 74 103 [SYS_IPC_IRQ_UNSUBSCRIBE] = { "ipc_irq_unsubscribe", 2, V_ERRNO }, 75 104 105 /* Sysinfo syscalls. */ 106 [SYS_SYSINFO_GET_KEYS_SIZE] = { "sysinfo_get_keys_size", 3, V_ERRNO }, 107 [SYS_SYSINFO_GET_KEYS] = { "sysinfo_get_keys", 5, V_ERRNO }, 76 108 [SYS_SYSINFO_GET_VAL_TYPE] = { "sysinfo_get_val_type", 2, V_INTEGER }, 77 109 [SYS_SYSINFO_GET_VALUE] = { "sysinfo_get_value", 3, V_ERRNO }, … … 79 111 [SYS_SYSINFO_GET_DATA] = { "sysinfo_get_data", 5, V_ERRNO }, 80 112 113 /* Kernel console syscalls. */ 81 114 [SYS_DEBUG_CONSOLE] = { "debug_console", 0, V_ERRNO }, 82 [SYS_IPC_CONNECT_KBOX] = { "ipc_connect_kbox", 1, V_ERRNO } 115 116 [SYS_KLOG] = { "klog", 5, V_ERRNO } 83 117 }; 84 118 -
uspace/app/trace/trace.c
rb093a62 r84876aa4 47 47 #include <mem.h> 48 48 #include <str.h> 49 #include <loader/loader.h>50 49 #include <io/console.h> 51 50 #include <io/keycode.h> … … 86 85 void thread_trace_start(uintptr_t thread_hash); 87 86 87 static char *cmd_path; 88 static char **cmd_args; 89 88 90 static task_id_t task_id; 89 static loader_t *task_ldr;91 static task_wait_t task_w; 90 92 static bool task_wait_for; 91 93 … … 93 95 display_mask_t display_mask; 94 96 95 static errno_t program_run_fibril(void *arg);96 97 static errno_t cev_fibril(void *arg); 97 98 static void program_run(void)99 {100 fid_t fid;101 102 fid = fibril_create(program_run_fibril, NULL);103 if (fid == 0) {104 printf("Error creating fibril\n");105 exit(1);106 }107 108 fibril_add_ready(fid);109 }110 98 111 99 static void cev_fibril_start(void) … … 122 110 } 123 111 124 static errno_t program_run_fibril(void *arg) 125 { 126 errno_t rc; 127 128 /* 129 * This must be done in background as it will block until 130 * we let the task reply to this call. 131 */ 132 rc = loader_run(task_ldr); 112 static errno_t program_run(void) 113 { 114 errno_t rc; 115 116 rc = task_spawnv_debug(&task_id, &task_w, cmd_path, 117 (const char *const *)cmd_args, &sess); 118 119 if (rc == ENOTSUP) { 120 printf("You do not have userspace debugging support " 121 "compiled in the kernel.\n"); 122 printf("Compile kernel with 'Support for userspace debuggers' " 123 "(CONFIG_UDEBUG) enabled.\n"); 124 } 125 133 126 if (rc != EOK) { 134 printf("Error running program\n"); 135 exit(1); 136 } 137 138 task_ldr = NULL; 139 140 printf("program_run_fibril exiting\n"); 141 return 0; 127 printf("Error running program (%s)\n", str_error_name(rc)); 128 return rc; 129 } 130 131 return EOK; 142 132 } 143 133 144 134 static errno_t connect_task(task_id_t task_id) 145 135 { 146 async_sess_t *ksess = async_connect_kbox(task_id); 147 148 if (!ksess) { 149 if (errno == ENOTSUP) { 150 printf("You do not have userspace debugging support " 151 "compiled in the kernel.\n"); 152 printf("Compile kernel with 'Support for userspace debuggers' " 153 "(CONFIG_UDEBUG) enabled.\n"); 154 return errno; 155 } 156 157 printf("Error connecting\n"); 158 printf("ipc_connect_task(%" PRIu64 ") -> %s ", task_id, str_error_name(errno)); 159 return errno; 160 } 161 162 errno_t rc = udebug_begin(ksess); 163 if (rc != EOK) { 164 printf("udebug_begin() -> %s\n", str_error_name(rc)); 165 return rc; 166 } 167 168 rc = udebug_set_evmask(ksess, UDEBUG_EM_ALL); 136 errno_t rc; 137 bool debug_started = false; 138 bool wait_set_up = false; 139 140 if (sess == NULL) { 141 sess = async_connect_kbox(task_id); 142 if (sess == NULL) { 143 printf("Error connecting to task %" PRIu64 ".\n", 144 task_id); 145 rc = EIO; 146 goto error; 147 } 148 149 rc = udebug_begin(sess); 150 if (rc != EOK) { 151 printf("Error starting debug session.\n"); 152 goto error; 153 } 154 155 debug_started = true; 156 157 rc = task_setup_wait(task_id, &task_w); 158 if (rc != EOK) { 159 printf("Error setting up wait for task termination.\n"); 160 goto error; 161 } 162 163 wait_set_up = true; 164 } 165 166 rc = udebug_set_evmask(sess, UDEBUG_EM_ALL); 169 167 if (rc != EOK) { 170 168 printf("udebug_set_evmask(0x%x) -> %s\n ", UDEBUG_EM_ALL, str_error_name(rc)); … … 172 170 } 173 171 174 sess = ksess; 175 return 0; 172 return EOK; 173 error: 174 if (wait_set_up) 175 task_cancel_wait(&task_w); 176 if (debug_started) 177 udebug_end(sess); 178 if (sess != NULL) 179 async_hangup(sess); 180 return rc; 176 181 } 177 182 … … 198 203 printf("\ntotal of %zu threads\n", tb_needed / sizeof(uintptr_t)); 199 204 200 return 0;205 return EOK; 201 206 } 202 207 … … 488 493 489 494 printf("Finished tracing thread [%d].\n", thread_id); 490 return 0;495 return EOK; 491 496 } 492 497 … … 502 507 } 503 508 fibril_add_ready(fid); 504 }505 506 static loader_t *preload_task(const char *path, char **argv,507 task_id_t *task_id)508 {509 loader_t *ldr;510 errno_t rc;511 512 /* Spawn a program loader */513 ldr = loader_connect();514 if (ldr == NULL)515 return NULL;516 517 /* Get task ID. */518 rc = loader_get_task_id(ldr, task_id);519 if (rc != EOK)520 goto error;521 522 /* Send program. */523 rc = loader_set_program_path(ldr, path);524 if (rc != EOK)525 goto error;526 527 /* Send arguments */528 rc = loader_set_args(ldr, (const char **) argv);529 if (rc != EOK)530 goto error;531 532 /* Send default files */533 int fd_root;534 int fd_stdin;535 int fd_stdout;536 int fd_stderr;537 538 fd_root = vfs_root();539 if (fd_root >= 0) {540 rc = loader_add_inbox(ldr, "root", fd_root);541 vfs_put(fd_root);542 if (rc != EOK)543 goto error;544 }545 546 if ((stdin != NULL) && (vfs_fhandle(stdin, &fd_stdin) == EOK)) {547 rc = loader_add_inbox(ldr, "stdin", fd_stdin);548 if (rc != EOK)549 goto error;550 }551 552 if ((stdout != NULL) && (vfs_fhandle(stdout, &fd_stdout) == EOK)) {553 rc = loader_add_inbox(ldr, "stdout", fd_stdout);554 if (rc != EOK)555 goto error;556 }557 558 if ((stderr != NULL) && (vfs_fhandle(stderr, &fd_stderr) == EOK)) {559 rc = loader_add_inbox(ldr, "stderr", fd_stderr);560 if (rc != EOK)561 goto error;562 }563 564 /* Load the program. */565 rc = loader_load_program(ldr);566 if (rc != EOK)567 goto error;568 569 /* Success */570 return ldr;571 572 /* Error exit */573 error:574 loader_abort(ldr);575 return NULL;576 509 } 577 510 … … 807 740 ++argv; 808 741 task_id = strtol(*argv, &err_p, 10); 809 task_ldr = NULL;810 742 task_wait_for = false; 811 743 if (*err_p) { … … 848 780 printf("'%s'\n", *cp++); 849 781 850 task_ldr = preload_task(*argv, argv, &task_id); 782 cmd_path = *argv; 783 cmd_args = argv; 851 784 task_wait_for = true; 852 785 … … 869 802 870 803 main_init(); 804 805 if (cmd_path != NULL) 806 program_run(); 871 807 872 808 rc = connect_task(task_id); … … 878 814 printf("Connected to task %" PRIu64 ".\n", task_id); 879 815 880 if (task_ldr != NULL)881 program_run();882 883 816 cev_fibril_start(); 884 817 trace_task(task_id); … … 887 820 printf("Waiting for task to exit.\n"); 888 821 889 rc = task_wait _task_id(task_id, &texit, &retval);822 rc = task_wait(&task_w, &texit, &retval); 890 823 if (rc != EOK) { 891 824 printf("Failed waiting for task.\n"); -
uspace/lib/c/generic/capa.c
rb093a62 r84876aa4 34 34 */ 35 35 36 #include <cap .h>36 #include <capa.h> 37 37 #include <errno.h> 38 38 #include <imath.h> … … 43 43 enum { 44 44 /** Simplified capacity maximum integer digits */ 45 scap _max_idig = 3,45 scapa_max_idig = 3, 46 46 /** Simplified capacity maximum significant digits */ 47 scap _max_sdig = 447 scapa_max_sdig = 4 48 48 }; 49 49 … … 60 60 }; 61 61 62 void cap _from_blocks(uint64_t nblocks, size_t block_size, cap_spec_t *cap)62 void capa_from_blocks(uint64_t nblocks, size_t block_size, capa_spec_t *capa) 63 63 { 64 64 uint64_t tsize; 65 65 66 66 tsize = nblocks * block_size; 67 cap ->m = tsize;68 cap ->dp = 0;69 cap ->cunit = cu_byte;67 capa->m = tsize; 68 capa->dp = 0; 69 capa->cunit = cu_byte; 70 70 } 71 71 … … 81 81 * and @c cv_max gives the maximum value. 82 82 */ 83 errno_t cap _to_blocks(cap_spec_t *cap, cap_vsel_t cvsel, size_t block_size,83 errno_t capa_to_blocks(capa_spec_t *capa, capa_vsel_t cvsel, size_t block_size, 84 84 uint64_t *rblocks) 85 85 { … … 92 92 errno_t rc; 93 93 94 exp = cap ->cunit * 3 - cap->dp;94 exp = capa->cunit * 3 - capa->dp; 95 95 if (exp < 0) { 96 96 rc = ipow10_u64(-exp, &f); 97 97 if (rc != EOK) 98 98 return ERANGE; 99 bytes = (cap ->m + (f / 2)) / f;100 if (bytes * f - (f / 2) != cap ->m)99 bytes = (capa->m + (f / 2)) / f; 100 if (bytes * f - (f / 2) != capa->m) 101 101 return ERANGE; 102 102 } else { … … 118 118 } 119 119 120 bytes = cap ->m * f + adj;121 if ((bytes - adj) / f != cap ->m)120 bytes = capa->m * f + adj; 121 if ((bytes - adj) / f != capa->m) 122 122 return ERANGE; 123 123 } … … 138 138 * digits and at most two fractional digits, e.g abc.xy <unit>. 139 139 */ 140 void cap _simplify(cap_spec_t *cap)140 void capa_simplify(capa_spec_t *capa) 141 141 { 142 142 uint64_t div; … … 146 146 errno_t rc; 147 147 148 /* Change units so that we have at most @c scap _max_idig integer digits */149 rc = ipow10_u64(scap _max_idig, &maxv);148 /* Change units so that we have at most @c scapa_max_idig integer digits */ 149 rc = ipow10_u64(scapa_max_idig, &maxv); 150 150 assert(rc == EOK); 151 151 152 rc = ipow10_u64(cap ->dp, &div);152 rc = ipow10_u64(capa->dp, &div); 153 153 assert(rc == EOK); 154 154 155 while (cap->m / div >= maxv) { 156 ++cap->cunit; 157 cap->dp += 3; 155 /* Change units until we have no more than scapa_max_idig integer digits */ 156 while (capa->m / div >= maxv) { 157 ++capa->cunit; 158 capa->dp += 3; 158 159 div = div * 1000; 159 160 } 160 161 161 /* Round the number so that we have at most @c scap _max_sdig significant digits */162 sdig = 1 + ilog10_u64(cap ->m); /* number of significant digits */163 if (sdig > scap _max_sdig) {162 /* Round the number so that we have at most @c scapa_max_sdig significant digits */ 163 sdig = 1 + ilog10_u64(capa->m); /* number of significant digits */ 164 if (sdig > scapa_max_sdig) { 164 165 /* Number of digits to remove */ 165 rdig = sdig - scap _max_sdig;166 if (rdig > cap ->dp)167 rdig = cap ->dp;166 rdig = sdig - scapa_max_sdig; 167 if (rdig > capa->dp) 168 rdig = capa->dp; 168 169 169 170 rc = ipow10_u64(rdig, &div); 170 171 assert(rc == EOK); 171 172 172 cap->m = (cap->m + (div / 2)) / div; 173 cap->dp -= rdig; 174 } 175 } 176 177 errno_t cap_format(cap_spec_t *cap, char **rstr) 173 /* Division with rounding */ 174 capa->m = (capa->m + (div / 2)) / div; 175 capa->dp -= rdig; 176 } 177 178 /* 179 * If we rounded up from something like 999.95 to 1000.0,, we still 180 * have more than scapa_max_idig integer digits and need to change 181 * units once more. 182 */ 183 rc = ipow10_u64(capa->dp, &div); 184 assert(rc == EOK); 185 186 if (capa->m / div >= 1000) { 187 ++capa->cunit; 188 capa->dp += 3; 189 190 /* 191 * We now have one more significant digit than we want 192 * so round to one less digits 193 */ 194 capa->m = (capa->m + 5) / 10; 195 --capa->dp; 196 } 197 } 198 199 errno_t capa_format(capa_spec_t *capa, char **rstr) 178 200 { 179 201 errno_t rc; … … 186 208 sunit = NULL; 187 209 188 assert(cap ->cunit < CU_LIMIT);189 190 rc = ipow10_u64(cap ->dp, &div);210 assert(capa->cunit < CU_LIMIT); 211 212 rc = ipow10_u64(capa->dp, &div); 191 213 if (rc != EOK) 192 214 return rc; 193 215 194 ipart = cap ->m / div;195 fpart = cap ->m % div;196 197 sunit = cu_str[cap ->cunit];198 if (cap ->dp > 0) {216 ipart = capa->m / div; 217 fpart = capa->m % div; 218 219 sunit = cu_str[capa->cunit]; 220 if (capa->dp > 0) { 199 221 ret = asprintf(rstr, "%" PRIu64 ".%0*" PRIu64 " %s", ipart, 200 (int)cap ->dp, fpart, sunit);222 (int)capa->dp, fpart, sunit); 201 223 } else { 202 224 ret = asprintf(rstr, "%" PRIu64 " %s", ipart, sunit); 203 225 } 226 204 227 if (ret < 0) 205 228 return ENOMEM; … … 208 231 } 209 232 210 static errno_t cap _digit_val(char c, int *val)233 static errno_t capa_digit_val(char c, int *val) 211 234 { 212 235 switch (c) { … … 248 271 } 249 272 250 errno_t cap _parse(const char *str, cap_spec_t *cap)273 errno_t capa_parse(const char *str, capa_spec_t *capa) 251 274 { 252 275 const char *eptr; … … 260 283 261 284 eptr = str; 262 while (cap _digit_val(*eptr, &d) == EOK) {285 while (capa_digit_val(*eptr, &d) == EOK) { 263 286 m = m * 10 + d; 264 287 ++eptr; … … 268 291 ++eptr; 269 292 dp = 0; 270 while (cap _digit_val(*eptr, &d) == EOK) {293 while (capa_digit_val(*eptr, &d) == EOK) { 271 294 m = m * 10 + d; 272 295 ++dp; … … 281 304 282 305 if (*eptr == '\0') { 283 cap ->cunit = cu_byte;306 capa->cunit = cu_byte; 284 307 } else { 285 308 for (i = 0; i < CU_LIMIT; i++) { … … 296 319 return EINVAL; 297 320 found: 298 cap ->cunit = i;299 } 300 301 cap ->m = m;302 cap ->dp = dp;321 capa->cunit = i; 322 } 323 324 capa->m = m; 325 capa->dp = dp; 303 326 return EOK; 304 327 } -
uspace/lib/c/generic/loader.c
rb093a62 r84876aa4 345 345 } 346 346 347 /** Instruct loader to execute the program and do not wait for reply. 348 * 349 * This function does not block even if the loaded task is stopped 350 * for debugging. 351 * 352 * After using this function, no further operations can be performed 353 * on the loader structure and it is deallocated. 354 * 355 * @param ldr Loader connection structure. 356 * 357 * @return Zero on success or an error code. 358 * 359 */ 360 void loader_run_nowait(loader_t *ldr) 361 { 362 async_exch_t *exch = async_exchange_begin(ldr->sess); 363 async_msg_0(exch, LOADER_RUN); 364 async_exchange_end(exch); 365 366 async_hangup(ldr->sess); 367 free(ldr); 368 } 369 347 370 /** Cancel the loader session. 348 371 * -
uspace/lib/c/generic/task.c
rb093a62 r84876aa4 35 35 */ 36 36 37 #include <async.h> 37 38 #include <task.h> 38 39 #include <loader/loader.h> … … 46 47 #include <ns.h> 47 48 #include <stdlib.h> 49 #include <udebug.h> 48 50 #include <libc.h> 49 51 #include "private/ns.h" … … 94 96 * This is really just a convenience wrapper over the more complicated 95 97 * loader API. Arguments are passed as a null-terminated array of strings. 98 * A debug session is created optionally. 96 99 * 97 100 * @param id If not NULL, the ID of the task is stored here on success. … … 100 103 * @param path Pathname of the binary to execute. 101 104 * @param argv Command-line arguments. 102 * 103 * @return Zero on success or an error code. 104 * 105 */ 106 errno_t task_spawnv(task_id_t *id, task_wait_t *wait, const char *path, 107 const char *const args[]) 105 * @param rsess Place to store pointer to debug session or @c NULL 106 * not to start a debug session 107 * 108 * @return Zero on success or an error code. 109 * 110 */ 111 errno_t task_spawnv_debug(task_id_t *id, task_wait_t *wait, const char *path, 112 const char *const args[], async_sess_t **rsess) 108 113 { 109 114 /* Send default files */ … … 125 130 } 126 131 127 return task_spawnvf (id, wait, path, args, fd_stdin, fd_stdout,128 fd_stderr );132 return task_spawnvf_debug(id, wait, path, args, fd_stdin, fd_stdout, 133 fd_stderr, rsess); 129 134 } 130 135 131 136 /** Create a new task by running an executable from the filesystem. 137 * 138 * This is really just a convenience wrapper over the more complicated 139 * loader API. Arguments are passed as a null-terminated array of strings. 140 * 141 * @param id If not NULL, the ID of the task is stored here on success. 142 * @param wait If not NULL, setup waiting for task's return value and store 143 * the information necessary for waiting here on success. 144 * @param path Pathname of the binary to execute. 145 * @param argv Command-line arguments. 146 * 147 * @return Zero on success or an error code. 148 * 149 */ 150 errno_t task_spawnv(task_id_t *id, task_wait_t *wait, const char *path, 151 const char *const args[]) 152 { 153 return task_spawnv_debug(id, wait, path, args, NULL); 154 } 155 156 /** Create a new task by loading an executable from the filesystem. 132 157 * 133 158 * This is really just a convenience wrapper over the more complicated 134 159 * loader API. Arguments are passed as a null-terminated array of strings. 135 160 * Files are passed as null-terminated array of pointers to fdi_node_t. 161 * A debug session is created optionally. 136 162 * 137 163 * @param id If not NULL, the ID of the task is stored here on success. 138 * @param wait If not NULL, setup waiting for task's return value and store 164 * @param wait If not NULL, setup waiting for task's return value and store. 139 165 * @param path Pathname of the binary to execute. 140 * @param argv Command-line arguments. 141 * @param std_in File to use as stdin. 142 * @param std_out File to use as stdout. 143 * @param std_err File to use as stderr. 144 * 145 * @return Zero on success or an error code. 146 * 147 */ 148 errno_t task_spawnvf(task_id_t *id, task_wait_t *wait, const char *path, 149 const char *const args[], int fd_stdin, int fd_stdout, int fd_stderr) 150 { 166 * @param argv Command-line arguments 167 * @param std_in File to use as stdin 168 * @param std_out File to use as stdout 169 * @param std_err File to use as stderr 170 * @param rsess Place to store pointer to debug session or @c NULL 171 * not to start a debug session 172 * 173 * @return Zero on success or an error code 174 * 175 */ 176 errno_t task_spawnvf_debug(task_id_t *id, task_wait_t *wait, 177 const char *path, const char *const args[], int fd_stdin, int fd_stdout, 178 int fd_stderr, async_sess_t **rsess) 179 { 180 async_sess_t *ksess = NULL; 181 151 182 /* Connect to a program loader. */ 152 183 loader_t *ldr = loader_connect(); … … 217 248 } 218 249 219 /* Run it. */ 220 rc = loader_run(ldr); 221 if (rc != EOK) 222 goto error; 250 /* Start a debug session if requested */ 251 if (rsess != NULL) { 252 ksess = async_connect_kbox(task_id); 253 if (ksess == NULL) { 254 /* Most likely debugging support is not compiled in */ 255 rc = ENOTSUP; 256 goto error; 257 } 258 259 rc = udebug_begin(ksess); 260 if (rc != EOK) 261 goto error; 262 263 /* 264 * Run it, not waiting for response. It would never come 265 * as the loader is stopped. 266 */ 267 loader_run_nowait(ldr); 268 } else { 269 /* Run it. */ 270 rc = loader_run(ldr); 271 if (rc != EOK) 272 goto error; 273 } 223 274 224 275 /* Success */ 225 276 if (id != NULL) 226 277 *id = task_id; 227 278 if (rsess != NULL) 279 *rsess = ksess; 228 280 return EOK; 229 281 230 282 error: 283 if (ksess != NULL) 284 async_hangup(ksess); 231 285 if (wait_initialized) 232 286 task_cancel_wait(wait); … … 235 289 loader_abort(ldr); 236 290 return rc; 291 } 292 293 /** Create a new task by running an executable from the filesystem. 294 * 295 * Arguments are passed as a null-terminated array of strings. 296 * Files are passed as null-terminated array of pointers to fdi_node_t. 297 * 298 * @param id If not NULL, the ID of the task is stored here on success. 299 * @param wait If not NULL, setup waiting for task's return value and store. 300 * @param path Pathname of the binary to execute 301 * @param argv Command-line arguments 302 * @param std_in File to use as stdin 303 * @param std_out File to use as stdout 304 * @param std_err File to use as stderr 305 * 306 * @return Zero on success or an error code. 307 * 308 */ 309 errno_t task_spawnvf(task_id_t *id, task_wait_t *wait, const char *path, 310 const char *const args[], int fd_stdin, int fd_stdout, int fd_stderr) 311 { 312 return task_spawnvf_debug(id, wait, path, args, fd_stdin, fd_stdout, 313 fd_stderr, NULL); 237 314 } 238 315 -
uspace/lib/c/include/capa.h
rb093a62 r84876aa4 34 34 */ 35 35 36 #ifndef _LIBC_CAP _H_37 #define _LIBC_CAP _H_36 #ifndef _LIBC_CAPA_H_ 37 #define _LIBC_CAPA_H_ 38 38 39 39 #include <adt/list.h> … … 55 55 cu_zbyte, 56 56 cu_ybyte 57 } cap _unit_t;57 } capa_unit_t; 58 58 59 59 /** Which of values within the precision of the capacity */ … … 65 65 /** The maximum value */ 66 66 cv_max 67 } cap _vsel_t;67 } capa_vsel_t; 68 68 69 69 #define CU_LIMIT (cu_ybyte + 1) … … 87 87 unsigned dp; 88 88 /** Capacity unit */ 89 cap _unit_t cunit;90 } cap _spec_t;89 capa_unit_t cunit; 90 } capa_spec_t; 91 91 92 extern errno_t cap _format(cap_spec_t *, char **);93 extern errno_t cap _parse(const char *, cap_spec_t *);94 extern void cap _simplify(cap_spec_t *);95 extern void cap _from_blocks(uint64_t, size_t, cap_spec_t *);96 extern errno_t cap _to_blocks(cap_spec_t *, cap_vsel_t, size_t, uint64_t *);92 extern errno_t capa_format(capa_spec_t *, char **); 93 extern errno_t capa_parse(const char *, capa_spec_t *); 94 extern void capa_simplify(capa_spec_t *); 95 extern void capa_from_blocks(uint64_t, size_t, capa_spec_t *); 96 extern errno_t capa_to_blocks(capa_spec_t *, capa_vsel_t, size_t, uint64_t *); 97 97 98 98 #endif -
uspace/lib/c/include/loader/loader.h
rb093a62 r84876aa4 53 53 extern errno_t loader_load_program(loader_t *); 54 54 extern errno_t loader_run(loader_t *); 55 extern void loader_run_nowait(loader_t *); 55 56 extern void loader_abort(loader_t *); 56 57 -
uspace/lib/c/include/task.h
rb093a62 r84876aa4 36 36 #define _LIBC_TASK_H_ 37 37 38 #include <async.h> 38 39 #include <stdint.h> 39 40 #include <stdarg.h> … … 56 57 extern errno_t task_spawnv(task_id_t *, task_wait_t *, const char *path, 57 58 const char *const []); 59 extern errno_t task_spawnv_debug(task_id_t *, task_wait_t *, const char *path, 60 const char *const [], async_sess_t **); 58 61 extern errno_t task_spawnvf(task_id_t *, task_wait_t *, const char *path, 59 62 const char *const [], int, int, int); 63 extern errno_t task_spawnvf_debug(task_id_t *, task_wait_t *, const char *path, 64 const char *const [], int, int, int, async_sess_t **); 60 65 extern errno_t task_spawn(task_id_t *, task_wait_t *, const char *path, int, 61 66 va_list ap); -
uspace/lib/c/meson.build
rb093a62 r84876aa4 65 65 'generic/bd_srv.c', 66 66 'generic/perm.c', 67 'generic/cap .c',67 'generic/capa.c', 68 68 'generic/clipboard.c', 69 69 'generic/config.c', … … 204 204 'test/adt/circ_buf.c', 205 205 'test/adt/odict.c', 206 'test/cap .c',206 'test/capa.c', 207 207 'test/casting.c', 208 208 'test/double_to_str.c', -
uspace/lib/c/test/capa.c
rb093a62 r84876aa4 28 28 29 29 #include <pcut/pcut.h> 30 #include <cap .h>30 #include <capa.h> 31 31 32 32 PCUT_INIT; 33 33 34 PCUT_TEST_SUITE(cap );35 36 PCUT_TEST(cap _format)34 PCUT_TEST_SUITE(capa); 35 36 PCUT_TEST(capa_format) 37 37 { 38 38 int block_size = 4; … … 86 86 }; 87 87 88 cap _spec_t cap;88 capa_spec_t capa; 89 89 char *str; 90 90 errno_t rc; … … 93 93 for (i = 0; i < input_size; i++) { 94 94 for (x = 0; x < block_size; x++) { 95 cap _from_blocks(input[i], block[x], &cap);96 cap _simplify(&cap);97 98 rc = cap _format(&cap, &str);95 capa_from_blocks(input[i], block[x], &capa); 96 capa_simplify(&capa); 97 98 rc = capa_format(&capa, &str); 99 99 100 100 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 102 102 free(str); 103 103 104 cap _from_blocks(block[x], input[i], &cap);105 cap _simplify(&cap);106 107 rc = cap _format(&cap, &str);104 capa_from_blocks(block[x], input[i], &capa); 105 capa_simplify(&capa); 106 107 rc = capa_format(&capa, &str); 108 108 109 109 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 114 114 } 115 115 116 PCUT_TEST(cap _format_rounding)116 PCUT_TEST(capa_format_rounding) 117 117 { 118 118 int input_size = 8; … … 139 139 }; 140 140 141 cap _spec_t cap;141 capa_spec_t capa; 142 142 char *str; 143 143 errno_t rc; … … 145 145 int i; 146 146 for (i = 0; i < input_size; i++) { 147 cap _from_blocks(input[i], 1, &cap);148 cap _simplify(&cap);149 150 rc = cap _format(&cap, &str);147 capa_from_blocks(input[i], 1, &capa); 148 capa_simplify(&capa); 149 150 rc = capa_format(&capa, &str); 151 151 152 152 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 154 154 free(str); 155 155 156 cap _from_blocks(1, input[i], &cap);157 cap _simplify(&cap);158 159 rc = cap _format(&cap, &str);156 capa_from_blocks(1, input[i], &capa); 157 capa_simplify(&capa); 158 159 rc = capa_format(&capa, &str); 160 160 161 161 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 165 165 } 166 166 167 PCUT_TEST(cap _parse)167 PCUT_TEST(capa_parse) 168 168 { 169 169 int input_size = 4; … … 196 196 }; 197 197 198 cap _spec_t cap;198 capa_spec_t capa; 199 199 errno_t rc; 200 200 int i; 201 201 202 202 for (i = 0; i < input_size; i++) { 203 rc = cap _parse(input[i], &cap);204 205 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 206 PCUT_ASSERT_INT_EQUALS(out_cunit[i], cap .cunit);207 PCUT_ASSERT_INT_EQUALS(out_dp[i], cap .dp);208 PCUT_ASSERT_INT_EQUALS(out_m[i], cap .m);209 } 210 } 211 212 PCUT_TEST(cap _to_blocks)203 rc = capa_parse(input[i], &capa); 204 205 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 206 PCUT_ASSERT_INT_EQUALS(out_cunit[i], capa.cunit); 207 PCUT_ASSERT_INT_EQUALS(out_dp[i], capa.dp); 208 PCUT_ASSERT_INT_EQUALS(out_m[i], capa.m); 209 } 210 } 211 212 PCUT_TEST(capa_to_blocks) 213 213 { 214 214 int input_size = 0; … … 261 261 }; 262 262 263 cap _spec_t cap;263 capa_spec_t capa; 264 264 errno_t rc; 265 265 int i; … … 267 267 268 268 for (i = 0; i < input_size; i++) { 269 cap .m = input_m[i];270 cap .dp = input_dp[i];271 cap .cunit = cu_kbyte;272 273 rc = cap _to_blocks(&cap, cv_nom, block[i], &ret);269 capa.m = input_m[i]; 270 capa.dp = input_dp[i]; 271 capa.cunit = cu_kbyte; 272 273 rc = capa_to_blocks(&capa, cv_nom, block[i], &ret); 274 274 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 275 275 PCUT_ASSERT_INT_EQUALS(out_nom[i], ret); 276 276 277 rc = cap _to_blocks(&cap, cv_min, block[i], &ret);277 rc = capa_to_blocks(&capa, cv_min, block[i], &ret); 278 278 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 279 279 PCUT_ASSERT_INT_EQUALS(out_min[i], ret); 280 280 281 rc = cap _to_blocks(&cap, cv_max, block[i], &ret);281 rc = capa_to_blocks(&capa, cv_max, block[i], &ret); 282 282 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 283 283 PCUT_ASSERT_INT_EQUALS(out_max[i], ret); … … 285 285 } 286 286 287 PCUT_EXPORT(cap );287 PCUT_EXPORT(capa); -
uspace/lib/c/test/getopt.c
rb093a62 r84876aa4 278 278 "get_opt_test", 279 279 "-f", 280 "-p", 281 "param" 280 "-pparam" 282 281 }; 283 282 -
uspace/lib/c/test/main.c
rb093a62 r84876aa4 32 32 PCUT_INIT; 33 33 34 PCUT_IMPORT(cap );34 PCUT_IMPORT(capa); 35 35 PCUT_IMPORT(casting); 36 36 PCUT_IMPORT(circ_buf); -
uspace/lib/fdisk/include/fdisk.h
rb093a62 r84876aa4 50 50 extern errno_t fdisk_dev_info_get_svcname(fdisk_dev_info_t *, char **); 51 51 extern void fdisk_dev_info_get_svcid(fdisk_dev_info_t *, service_id_t *); 52 extern errno_t fdisk_dev_info_capacity(fdisk_dev_info_t *, cap _spec_t *);52 extern errno_t fdisk_dev_info_capacity(fdisk_dev_info_t *, capa_spec_t *); 53 53 54 54 extern errno_t fdisk_dev_open(fdisk_t *, service_id_t, fdisk_dev_t **); … … 57 57 extern void fdisk_dev_get_flags(fdisk_dev_t *, fdisk_dev_flags_t *); 58 58 extern errno_t fdisk_dev_get_svcname(fdisk_dev_t *, char **); 59 extern errno_t fdisk_dev_capacity(fdisk_dev_t *, cap _spec_t *);59 extern errno_t fdisk_dev_capacity(fdisk_dev_t *, capa_spec_t *); 60 60 61 61 extern errno_t fdisk_label_get_info(fdisk_dev_t *, fdisk_label_info_t *); … … 66 66 extern fdisk_part_t *fdisk_part_next(fdisk_part_t *); 67 67 extern errno_t fdisk_part_get_info(fdisk_part_t *, fdisk_part_info_t *); 68 extern errno_t fdisk_part_get_max_avail(fdisk_dev_t *, fdisk_spc_t, cap _spec_t *);69 extern errno_t fdisk_part_get_tot_avail(fdisk_dev_t *, fdisk_spc_t, cap _spec_t *);68 extern errno_t fdisk_part_get_max_avail(fdisk_dev_t *, fdisk_spc_t, capa_spec_t *); 69 extern errno_t fdisk_part_get_tot_avail(fdisk_dev_t *, fdisk_spc_t, capa_spec_t *); 70 70 extern errno_t fdisk_part_create(fdisk_dev_t *, fdisk_part_spec_t *, 71 71 fdisk_part_t **); -
uspace/lib/fdisk/include/types/fdisk.h
rb093a62 r84876aa4 38 38 39 39 #include <adt/list.h> 40 #include <cap .h>40 #include <capa.h> 41 41 #include <loc.h> 42 42 #include <stdint.h> … … 126 126 link_t llog_ba; 127 127 /** Capacity */ 128 cap _spec_t capacity;128 capa_spec_t capacity; 129 129 /** Partition kind */ 130 130 label_pkind_t pkind; … … 150 150 typedef struct { 151 151 /** Desired capacity */ 152 cap _spec_t capacity;152 capa_spec_t capacity; 153 153 /** Partition kind */ 154 154 label_pkind_t pkind; … … 164 164 typedef struct { 165 165 /** Capacity */ 166 cap _spec_t capacity;166 capa_spec_t capacity; 167 167 /** Partition kind */ 168 168 label_pkind_t pkind; -
uspace/lib/fdisk/src/fdisk.c
rb093a62 r84876aa4 35 35 36 36 #include <adt/list.h> 37 #include <cap .h>37 #include <capa.h> 38 38 #include <errno.h> 39 39 #include <fdisk.h> … … 219 219 } 220 220 221 errno_t fdisk_dev_info_capacity(fdisk_dev_info_t *info, cap _spec_t *cap)221 errno_t fdisk_dev_info_capacity(fdisk_dev_info_t *info, capa_spec_t *capa) 222 222 { 223 223 vbd_disk_info_t vinfo; … … 228 228 return EIO; 229 229 230 cap _from_blocks(vinfo.nblocks, vinfo.block_size, cap);230 capa_from_blocks(vinfo.nblocks, vinfo.block_size, capa); 231 231 return EOK; 232 232 } … … 295 295 dev->ext_part = part; 296 296 297 cap _from_blocks(part->nblocks, dev->dinfo.block_size,297 capa_from_blocks(part->nblocks, dev->dinfo.block_size, 298 298 &part->capacity); 299 299 part->part_id = partid; … … 536 536 } 537 537 538 errno_t fdisk_dev_capacity(fdisk_dev_t *dev, cap _spec_t *cap)539 { 540 cap _from_blocks(dev->dinfo.nblocks, dev->dinfo.block_size, cap);538 errno_t fdisk_dev_capacity(fdisk_dev_t *dev, capa_spec_t *capa) 539 { 540 capa_from_blocks(dev->dinfo.nblocks, dev->dinfo.block_size, capa); 541 541 return EOK; 542 542 } … … 679 679 680 680 /** Get size of largest free block. */ 681 errno_t fdisk_part_get_max_avail(fdisk_dev_t *dev, fdisk_spc_t spc, cap_spec_t *cap) 681 errno_t fdisk_part_get_max_avail(fdisk_dev_t *dev, fdisk_spc_t spc, 682 capa_spec_t *capa) 682 683 { 683 684 errno_t rc; … … 698 699 } 699 700 700 cap _from_blocks(nb, dev->dinfo.block_size, cap);701 capa_from_blocks(nb, dev->dinfo.block_size, capa); 701 702 return EOK; 702 703 } … … 704 705 /** Get total free space capacity. */ 705 706 errno_t fdisk_part_get_tot_avail(fdisk_dev_t *dev, fdisk_spc_t spc, 706 cap _spec_t *cap)707 capa_spec_t *capa) 707 708 { 708 709 fdisk_free_range_t fr; … … 726 727 } while (fdisk_free_range_next(&fr)); 727 728 728 cap _from_blocks(totb, dev->dinfo.block_size, cap);729 capa_from_blocks(totb, dev->dinfo.block_size, capa); 729 730 return EOK; 730 731 } … … 938 939 errno_t rc; 939 940 940 rc = cap _to_blocks(&pspec->capacity, cv_nom, dev->dinfo.block_size,941 rc = capa_to_blocks(&pspec->capacity, cv_nom, dev->dinfo.block_size, 941 942 &nom_blocks); 942 943 if (rc != EOK) 943 944 return rc; 944 945 945 rc = cap _to_blocks(&pspec->capacity, cv_min, dev->dinfo.block_size,946 rc = capa_to_blocks(&pspec->capacity, cv_min, dev->dinfo.block_size, 946 947 &min_blocks); 947 948 if (rc != EOK) 948 949 return rc; 949 950 950 rc = cap _to_blocks(&pspec->capacity, cv_max, dev->dinfo.block_size,951 rc = capa_to_blocks(&pspec->capacity, cv_max, dev->dinfo.block_size, 951 952 &max_blocks); 952 953 if (rc != EOK) -
uspace/lib/meson.build
rb093a62 r84876aa4 37 37 'softrend', 38 38 'posix', 39 'clui', 40 'pcm', 41 'hound' 39 42 ] 40 43 -
uspace/srv/hid/input/input.c
rb093a62 r84876aa4 66 66 #include "serial.h" 67 67 68 #define NUM_LAYOUTS 468 #define NUM_LAYOUTS 5 69 69 70 70 static layout_ops_t *layout[NUM_LAYOUTS] = { … … 72 72 &us_dvorak_ops, 73 73 &cz_ops, 74 &ar_ops 74 &ar_ops, 75 &fr_azerty_ops 75 76 }; 76 77 … … 208 209 // TODO: More elegant layout switching 209 210 210 if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) && 211 (key == KC_F1)) { 212 layout_destroy(kdev->active_layout); 213 kdev->active_layout = layout_create(layout[0]); 214 return; 215 } 216 217 if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) && 218 (key == KC_F2)) { 219 layout_destroy(kdev->active_layout); 220 kdev->active_layout = layout_create(layout[1]); 221 return; 222 } 223 224 if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) && 225 (key == KC_F3)) { 226 layout_destroy(kdev->active_layout); 227 kdev->active_layout = layout_create(layout[2]); 228 return; 229 } 230 231 if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) && 232 (key == KC_F4)) { 233 layout_destroy(kdev->active_layout); 234 kdev->active_layout = layout_create(layout[3]); 235 return; 211 if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL)) { 212 switch (key) { 213 case KC_F1: 214 layout_destroy(kdev->active_layout); 215 kdev->active_layout = layout_create(layout[0]); 216 break; 217 case KC_F2: 218 layout_destroy(kdev->active_layout); 219 kdev->active_layout = layout_create(layout[1]); 220 break; 221 case KC_F3: 222 layout_destroy(kdev->active_layout); 223 kdev->active_layout = layout_create(layout[2]); 224 break; 225 case KC_F4: 226 layout_destroy(kdev->active_layout); 227 kdev->active_layout = layout_create(layout[3]); 228 break; 229 case KC_F5: 230 layout_destroy(kdev->active_layout); 231 kdev->active_layout = layout_create(layout[4]); 232 break; 233 default: // default: is here to avoid compiler warning about unhandled cases 234 break; 235 } 236 236 } 237 237 -
uspace/srv/hid/input/layout.h
rb093a62 r84876aa4 60 60 extern layout_ops_t cz_ops; 61 61 extern layout_ops_t ar_ops; 62 extern layout_ops_t fr_azerty_ops; 62 63 63 64 extern layout_t *layout_create(layout_ops_t *); -
uspace/srv/hid/input/meson.build
rb093a62 r84876aa4 31 31 src = files( 32 32 'layout/cz.c', 33 'layout/fr_azerty.c', 33 34 'layout/us_qwerty.c', 34 35 'layout/us_dvorak.c', -
uspace/srv/net/tcp/test/tqueue.c
rb093a62 r84876aa4 32 32 33 33 #include "../conn.h" 34 #include "../segment.h" 34 35 #include "../tqueue.h" 35 36 … … 117 118 PCUT_ASSERT_EQUALS(CTL_SYN, trans_seg[0]->ctrl); 118 119 PCUT_ASSERT_EQUALS(10, trans_seg[0]->seq); 120 tcp_segment_delete(trans_seg[0]); 119 121 } 120 122 … … 156 158 PCUT_ASSERT_EQUALS(CTL_FIN | CTL_ACK, trans_seg[0]->ctrl); 157 159 PCUT_ASSERT_EQUALS(10, trans_seg[0]->seq); 160 tcp_segment_delete(trans_seg[0]); 158 161 } 159 162 … … 198 201 PCUT_ASSERT_EQUALS(CTL_ACK, trans_seg[0]->ctrl); 199 202 PCUT_ASSERT_EQUALS(10, trans_seg[0]->seq); 203 tcp_segment_delete(trans_seg[0]); 200 204 } 201 205 … … 256 260 static void tqueue_test_transmit_seg(inet_ep2_t *epp, tcp_segment_t *seg) 257 261 { 258 trans_seg[seg_cnt++] = seg;262 trans_seg[seg_cnt++] = tcp_segment_dup(seg); 259 263 } 260 264 -
uspace/srv/net/udp/assoc.c
rb093a62 r84876aa4 40 40 #include <fibril_synch.h> 41 41 #include <inet/endpoint.h> 42 #include <inet/inet.h>43 42 #include <io/log.h> 44 43 #include <nettl/amap.h> … … 48 47 #include "msg.h" 49 48 #include "pdu.h" 50 #include "udp_inet.h"51 49 #include "udp_type.h" 52 50 … … 57 55 static udp_assoc_t *udp_assoc_find_ref(inet_ep2_t *); 58 56 static errno_t udp_assoc_queue_msg(udp_assoc_t *, inet_ep2_t *, udp_msg_t *); 57 static udp_assocs_dep_t *assocs_dep; 59 58 60 59 /** Initialize associations. */ 61 errno_t udp_assocs_init( void)60 errno_t udp_assocs_init(udp_assocs_dep_t *dep) 62 61 { 63 62 errno_t rc; … … 69 68 } 70 69 70 assocs_dep = dep; 71 71 return EOK; 72 } 73 74 /** Finalize associations. */ 75 void udp_assocs_fini(void) 76 { 77 assert(list_empty(&assoc_list)); 78 79 amap_destroy(amap); 80 amap = NULL; 72 81 } 73 82 … … 174 183 175 184 assert(assoc->deleted == false); 185 assoc->deleted = true; 176 186 udp_assoc_delref(assoc); 177 assoc->deleted = true;178 187 } 179 188 … … 244 253 errno_t udp_assoc_send(udp_assoc_t *assoc, inet_ep_t *remote, udp_msg_t *msg) 245 254 { 246 udp_pdu_t *pdu;247 255 inet_ep2_t epp; 248 256 errno_t rc; … … 266 274 if (inet_addr_is_any(&epp.local.addr) && !assoc->nolocal) { 267 275 log_msg(LOG_DEFAULT, LVL_DEBUG, "Determine local address."); 268 rc = inet_get_srcaddr(&epp.remote.addr, 0, &epp.local.addr); 276 rc = (*assocs_dep->get_srcaddr)(&epp.remote.addr, 0, 277 &epp.local.addr); 269 278 if (rc != EOK) { 270 279 log_msg(LOG_DEFAULT, LVL_DEBUG, "Cannot determine " … … 280 289 return EINVAL; 281 290 282 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_send - encode pdu");283 284 rc = udp_pdu_encode(&epp, msg, &pdu);285 if (rc != EOK)286 return ENOMEM;287 288 291 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_send - transmit"); 289 290 rc = udp_transmit_pdu(pdu); 291 udp_pdu_delete(pdu); 292 rc = (*assocs_dep->transmit_msg)(&epp, msg); 292 293 293 294 if (rc != EOK) -
uspace/srv/net/udp/assoc.h
rb093a62 r84876aa4 40 40 #include "udp_type.h" 41 41 42 extern errno_t udp_assocs_init(void); 42 extern errno_t udp_assocs_init(udp_assocs_dep_t *); 43 extern void udp_assocs_fini(void); 43 44 extern udp_assoc_t *udp_assoc_new(inet_ep2_t *, udp_assoc_cb_t *, void *); 44 45 extern void udp_assoc_delete(udp_assoc_t *); -
uspace/srv/net/udp/meson.build
rb093a62 r84876aa4 28 28 29 29 deps = [ 'nettl' ] 30 src = files( 30 31 _common_src = files( 31 32 'assoc.c', 33 'cassoc.c', 32 34 'msg.c', 33 35 'pdu.c', 36 ) 37 38 src = files( 34 39 'service.c', 35 40 'udp.c', 36 41 'udp_inet.c', 37 42 ) 43 44 test_src = files( 45 'test/assoc.c', 46 'test/msg.c', 47 'test/main.c', 48 'test/pdu.c', 49 ) 50 51 src = [ _common_src, src ] 52 test_src = [ _common_src, test_src ] -
uspace/srv/net/udp/service.c
rb093a62 r84876aa4 46 46 47 47 #include "assoc.h" 48 #include "cassoc.h" 48 49 #include "msg.h" 49 50 #include "service.h" … … 55 56 #define MAX_MSG_SIZE DATA_XFER_LIMIT 56 57 57 static void udp_ cassoc_recv_msg(void *, inet_ep2_t *, udp_msg_t *);58 static void udp_recv_msg_cassoc(void *, inet_ep2_t *, udp_msg_t *); 58 59 59 60 /** Callbacks to tie us to association layer */ 60 61 static udp_assoc_cb_t udp_cassoc_cb = { 61 .recv_msg = udp_ cassoc_recv_msg62 .recv_msg = udp_recv_msg_cassoc 62 63 }; 63 64 /** Add message to client receive queue.65 *66 * @param cassoc Client association67 * @param epp Endpoint pair on which message was received68 * @param msg Message69 *70 * @return EOK on success, ENOMEM if out of memory71 */72 static errno_t udp_cassoc_queue_msg(udp_cassoc_t *cassoc, inet_ep2_t *epp,73 udp_msg_t *msg)74 {75 udp_crcv_queue_entry_t *rqe;76 77 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_cassoc_queue_msg(%p, %p, %p)",78 cassoc, epp, msg);79 80 rqe = calloc(1, sizeof(udp_crcv_queue_entry_t));81 if (rqe == NULL)82 return ENOMEM;83 84 link_initialize(&rqe->link);85 rqe->epp = *epp;86 rqe->msg = msg;87 rqe->cassoc = cassoc;88 89 list_append(&rqe->link, &cassoc->client->crcv_queue);90 return EOK;91 }92 64 93 65 /** Send 'data' event to client. … … 108 80 } 109 81 110 /** Create client association.111 *112 * This effectively adds an association into a client's namespace.113 *114 * @param client Client115 * @param assoc Association116 * @param rcassoc Place to store pointer to new client association117 *118 * @return EOK on soccess, ENOMEM if out of memory119 */120 static errno_t udp_cassoc_create(udp_client_t *client, udp_assoc_t *assoc,121 udp_cassoc_t **rcassoc)122 {123 udp_cassoc_t *cassoc;124 sysarg_t id;125 126 cassoc = calloc(1, sizeof(udp_cassoc_t));127 if (cassoc == NULL)128 return ENOMEM;129 130 /* Allocate new ID */131 id = 0;132 list_foreach (client->cassoc, lclient, udp_cassoc_t, cassoc) {133 if (cassoc->id >= id)134 id = cassoc->id + 1;135 }136 137 cassoc->id = id;138 cassoc->client = client;139 cassoc->assoc = assoc;140 141 list_append(&cassoc->lclient, &client->cassoc);142 *rcassoc = cassoc;143 return EOK;144 }145 146 /** Destroy client association.147 *148 * @param cassoc Client association149 */150 static void udp_cassoc_destroy(udp_cassoc_t *cassoc)151 {152 list_remove(&cassoc->lclient);153 free(cassoc);154 }155 156 /** Get client association by ID.157 *158 * @param client Client159 * @param id Client association ID160 * @param rcassoc Place to store pointer to client association161 *162 * @return EOK on success, ENOENT if no client association with the given ID163 * is found.164 */165 static errno_t udp_cassoc_get(udp_client_t *client, sysarg_t id,166 udp_cassoc_t **rcassoc)167 {168 list_foreach (client->cassoc, lclient, udp_cassoc_t, cassoc) {169 if (cassoc->id == id) {170 *rcassoc = cassoc;171 return EOK;172 }173 }174 175 return ENOENT;176 }177 178 82 /** Message received on client association. 179 83 * … … 184 88 * @param msg Message 185 89 */ 186 static void udp_ cassoc_recv_msg(void *arg, inet_ep2_t *epp, udp_msg_t *msg)90 static void udp_recv_msg_cassoc(void *arg, inet_ep2_t *epp, udp_msg_t *msg) 187 91 { 188 92 udp_cassoc_t *cassoc = (udp_cassoc_t *) arg; -
uspace/srv/net/udp/udp.c
rb093a62 r84876aa4 47 47 #define NAME "udp" 48 48 49 static udp_assocs_dep_t udp_assocs_dep = { 50 .get_srcaddr = udp_get_srcaddr, 51 .transmit_msg = udp_transmit_msg 52 }; 53 49 54 static errno_t udp_init(void) 50 55 { … … 53 58 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_init()"); 54 59 55 rc = udp_assocs_init( );60 rc = udp_assocs_init(&udp_assocs_dep); 56 61 if (rc != EOK) { 57 62 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed initializing associations."); -
uspace/srv/net/udp/udp_inet.c
rb093a62 r84876aa4 134 134 } 135 135 136 /** Get source address. 137 * 138 * @param remote Remote address 139 * @param tos Type of service 140 * @param local Place to store local address 141 * @return EOK on success or an error code 142 */ 143 errno_t udp_get_srcaddr(inet_addr_t *remote, uint8_t tos, inet_addr_t *local) 144 { 145 return inet_get_srcaddr(remote, tos, local); 146 } 147 148 /** Transmit message over network layer. */ 149 errno_t udp_transmit_msg(inet_ep2_t *epp, udp_msg_t *msg) 150 { 151 udp_pdu_t *pdu; 152 errno_t rc; 153 154 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_transmit_msg()"); 155 156 rc = udp_pdu_encode(epp, msg, &pdu); 157 if (rc != EOK) { 158 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed encoding PDU"); 159 return rc; 160 } 161 162 rc = udp_transmit_pdu(pdu); 163 udp_pdu_delete(pdu); 164 165 return rc; 166 } 167 136 168 /** 137 169 * @} -
uspace/srv/net/udp/udp_inet.h
rb093a62 r84876aa4 36 36 #define UDP_INET_H 37 37 38 #include <inet/addr.h> 39 #include <stdint.h> 38 40 #include "udp_type.h" 39 41 40 42 extern errno_t udp_inet_init(void); 41 43 extern errno_t udp_transmit_pdu(udp_pdu_t *); 44 extern errno_t udp_get_srcaddr(inet_addr_t *, uint8_t, inet_addr_t *); 45 extern errno_t udp_transmit_msg(inet_ep2_t *, udp_msg_t *); 42 46 43 47 #endif -
uspace/srv/net/udp/udp_type.h
rb093a62 r84876aa4 37 37 38 38 #include <async.h> 39 #include <errno.h> 39 40 #include <fibril.h> 40 41 #include <fibril_synch.h> … … 44 45 #include <stdbool.h> 45 46 #include <stddef.h> 47 #include <stdint.h> 46 48 #include <inet/addr.h> 47 49 … … 87 89 } udp_pdu_t; 88 90 89 /** Association callbacks */ 91 /** Functions needed by associations module. 92 * 93 * Functions that need to be provided by the caller so that the associations 94 * module can function. 95 */ 96 typedef struct { 97 errno_t (*get_srcaddr)(inet_addr_t *, uint8_t, inet_addr_t *); 98 errno_t (*transmit_msg)(inet_ep2_t *, udp_msg_t *); 99 } udp_assocs_dep_t; 100 101 /** Association callbacks. 102 * 103 * Callbacks for a particular association, to notify caller of events 104 * on the association. 105 */ 90 106 typedef struct { 91 107 /** Message received */ -
uspace/srv/volsrv/volume.c
rb093a62 r84876aa4 367 367 if (refcount_down(&volume->refcnt)) { 368 368 /* No more references. Check if volume is persistent. */ 369 if (!vol_volume_is_persist(volume)) { 370 list_remove(&volume->lvolumes); 371 vol_volume_delete(volume); 372 } 369 list_remove(&volume->lvolumes); 370 vol_volume_delete(volume); 373 371 } 374 372 } … … 399 397 /* Volume is now persistent */ 400 398 if (volume->nvolume == NULL) { 399 /* Prevent volume from being freed */ 400 refcount_up(&volume->refcnt); 401 401 402 /* Create volume node */ 402 403 rc = sif_trans_begin(volume->volumes->repo, &trans); … … 426 427 volume->nvolume = nvolume; 427 428 } else { 429 /* Allow volume to be freed */ 430 vol_volume_del_ref(volume); 431 428 432 /* Update volume node */ 429 433 rc = sif_trans_begin(volume->volumes->repo, &trans);
Note:
See TracChangeset
for help on using the changeset viewer.