Changes in / [84876aa4:b093a62] in mainline
- Files:
-
- 3 added
- 12 deleted
- 50 edited
Legend:
- Unmodified
- Added
- Removed
-
abi/include/abi/syscall.h
r84876aa4 rb093a62 36 36 #define _ABI_SYSCALL_H_ 37 37 38 /** System calls.39 *40 * If you are adding or removing syscalls, or changing the number of41 * their arguments, please update syscall description table42 * in @c uspace/app/trace/syscalls.c43 */44 38 typedef enum { 45 39 SYS_KIO = 0, -
kernel/generic/include/cap/cap.h
r84876aa4 rb093a62 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 76 72 /* 77 73 * Everything in kobject_t except for the atomic reference count, the capability … … 86 82 /** List of published capabilities associated with the kobject */ 87 83 list_t caps_list; 84 85 kobject_ops_t *ops; 88 86 89 87 union { … … 141 139 extern kobject_t *kobject_alloc(unsigned int); 142 140 extern void kobject_free(kobject_t *); 143 extern void kobject_initialize(kobject_t *, kobject_type_t, void *); 141 extern void kobject_initialize(kobject_t *, kobject_type_t, void *, 142 kobject_ops_t *); 144 143 extern kobject_t *kobject_get(struct task *, cap_handle_t, kobject_type_t); 145 144 extern void kobject_add_ref(kobject_t *); -
kernel/generic/include/ipc/ipc.h
r84876aa4 rb093a62 172 172 extern answerbox_t *ipc_box_0; 173 173 174 extern kobject_ops_t call_kobject_ops;175 176 174 extern void ipc_init(void); 177 175 -
kernel/generic/include/ipc/ipcrsc.h
r84876aa4 rb093a62 40 40 #include <cap/cap.h> 41 41 42 extern kobject_ops_t phone_kobject_ops;43 44 42 extern errno_t phone_alloc(task_t *, bool, cap_phone_handle_t *, kobject_t **); 45 43 extern void phone_dealloc(cap_phone_handle_t); -
kernel/generic/include/ipc/irq.h
r84876aa4 rb093a62 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;51 48 52 49 extern irq_ownership_t ipc_irq_top_half_claim(irq_t *); -
kernel/generic/include/synch/syswaitq.h
r84876aa4 rb093a62 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;43 40 44 41 extern void sys_waitq_init(void); -
kernel/generic/src/cap/cap.c
r84876aa4 rb093a62 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>89 85 90 86 #include <limits.h> … … 98 94 static slab_cache_t *cap_cache; 99 95 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_ops106 };107 96 108 97 static size_t caps_hash(const ht_link_t *item) … … 423 412 * @param type Type of the kernel object. 424 413 * @param raw Raw pointer to the encapsulated object. 425 */ 426 void kobject_initialize(kobject_t *kobj, kobject_type_t type, void *raw) 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) 427 418 { 428 419 atomic_store(&kobj->refcnt, 1); … … 433 424 kobj->type = type; 434 425 kobj->raw = raw; 426 kobj->ops = ops; 435 427 } 436 428 … … 482 474 { 483 475 if (atomic_postdec(&kobj->refcnt) == 1) { 484 KOBJECT_OP(kobj)->destroy(kobj->raw);476 kobj->ops->destroy(kobj->raw); 485 477 kobject_free(kobj); 486 478 } -
kernel/generic/src/ipc/ipc.c
r84876aa4 rb093a62 100 100 } 101 101 102 kobject_ops_t call_kobject_ops = {102 static 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 );129 kobject_initialize(kobj, KOBJECT_TYPE_CALL, call, &call_kobject_ops); 130 130 call->kobject = kobj; 131 131 -
kernel/generic/src/ipc/ipcrsc.c
r84876aa4 rb093a62 52 52 } 53 53 54 kobject_ops_t phone_kobject_ops = {54 static 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); 96 kobject_initialize(kobj, KOBJECT_TYPE_PHONE, phone, 97 &phone_kobject_ops); 97 98 phone->kobject = kobj; 98 99 -
kernel/generic/src/ipc/irq.c
r84876aa4 rb093a62 306 306 } 307 307 308 kobject_ops_t irq_kobject_ops = {308 static 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 );387 kobject_initialize(kobject, KOBJECT_TYPE_IRQ, irq, &irq_kobject_ops); 388 388 cap_publish(TASK, handle, kobject); 389 389 -
kernel/generic/src/mm/malloc.c
r84876aa4 rb093a62 187 187 void *malloc(size_t size) 188 188 { 189 if (size + _offset < size)190 return NULL;191 192 189 void *obj = mem_alloc(alignof(max_align_t), size + _offset) + _offset; 193 190 -
kernel/generic/src/synch/syswaitq.c
r84876aa4 rb093a62 54 54 } 55 55 56 kobject_ops_t waitq_kobject_ops = {56 static 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 );102 kobject_initialize(kobj, KOBJECT_TYPE_WAITQ, wq, &waitq_kobject_ops); 103 103 104 104 cap_handle_t handle; -
kernel/generic/src/udebug/udebug.c
r84876aa4 rb093a62 479 479 mutex_unlock(&THREAD->udebug.lock); 480 480 481 /* 482 * This is where we will typically block until a post-mortem debugger 483 * terminates the debugging session. 484 */ 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 485 487 udebug_stoppable_end(); 486 488 } -
meson/part/exports/config.mk.in
r84876aa4 rb093a62 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@"4 3 HELENOS_CROSS_PATH="@HELENOS_CROSS_PATH@" 5 4 HELENOS_ARCH="@HELENOS_ARCH@" -
meson/part/exports/meson.build
r84876aa4 rb093a62 62 62 63 63 conf_data = configuration_data({ 64 'HELENOS_OVERLAY_PATH' : meson.source_root() / 'uspace/overlay',65 64 'HELENOS_CROSS_PATH' : cc_path, 66 65 'HELENOS_ARCH' : cc_arch, -
meson/part/extra_targets/meson.build
r84876aa4 rb093a62 72 72 ) 73 73 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 ]) 74 run_target('doxygen', command: [ doxygen, _dox_cfg ]) 82 75 endif 83 76 -
tools/xcw/bin/helenos-cc
r84876aa4 rb093a62 35 35 36 36 XCW="$(dirname "$0")" 37 BUILD_ROOT="$(dirname "$(dirname "$(dirname "$XCW")")")"37 SRC_ROOT="$XCW/../../.." 38 38 if [ -z "$EXPORT_DIR" ]; then 39 EXPORT_DIR="$ BUILD_ROOT/export"39 EXPORT_DIR="$SRC_ROOT/build/dist" 40 40 fi 41 41 42 42 HELENOS_EXPORT_ROOT="$EXPORT_DIR" 43 43 44 source "${EXPORT_DIR}/config .sh"44 source "${EXPORT_DIR}/config/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
r84876aa4 rb093a62 33 33 34 34 XCW="$(dirname "$0")" 35 BUILD_ROOT="$(dirname "$(dirname "$(dirname "$XCW")")")"35 SRC_ROOT="$XCW/../../.." 36 36 if [ -z "$EXPORT_DIR" ]; then 37 EXPORT_DIR="$ BUILD_ROOT/export"37 EXPORT_DIR="$SRC_ROOT/build/dist" 38 38 fi 39 40 39 INCLUDE_DIR="$EXPORT_DIR/include" 41 40 LIB_DIR="$EXPORT_DIR/lib" -
tools/xcw/bin/helenos-test
r84876aa4 rb093a62 1 1 #!/bin/bash 2 2 # 3 # Copyright (c) 201 9Jiri Svoboda3 # Copyright (c) 2018 Jiri Svoboda 4 4 # All rights reserved. 5 5 # … … 33 33 34 34 XCW="$(dirname "$0")" 35 BUILD_ROOT="$(dirname "$(dirname "$(dirname "$XCW")")")"35 SRC_ROOT="$XCW/../../.." 36 36 37 cd "$ BUILD_ROOT"38 ninja image_path 37 cd "$SRC_ROOT" 38 make 39 39 tools/ew.py -
tools/xcw/demo/Makefile
r84876aa4 rb093a62 36 36 # 37 37 # cd <helenos-source-dir> 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 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 45 41 # make 46 42 # … … 48 44 CC = helenos-cc 49 45 LD = helenos-ld 50 INSTALL = install51 TEST = helenos-test52 46 CFLAGS = -std=gnu11 -Wall `helenos-pkg-config --cflags libgui libdraw libmath` \ 53 47 -D_HELENOS_SOURCE 54 48 LIBS = `helenos-pkg-config --libs libgui libdraw libmath` 55 PREFIX = `helenos-bld-config --install-dir`56 49 output = viewer 57 50 objects = viewer.o … … 63 56 rm -f $(output) $(objects) 64 57 65 install: $(output)66 mkdir -p $(PREFIX)/app67 $(INSTALL) -T $(output) $(PREFIX)/app/$(output)-xcw68 69 uninstall:70 rm -f $(PREFIX)/app/$(output)-xcw71 72 test: install73 $(TEST)74 75 58 $(output): $(objects) 76 59 $(CC) -o $@ $^ $(LIBS) -
uspace/app/bdsh/cmds/modules/ls/ls.c
r84876aa4 rb093a62 42 42 #include <vfs/vfs.h> 43 43 #include <str.h> 44 #include <cap a.h>44 #include <cap.h> 45 45 46 46 #include "ls.h" … … 106 106 } 107 107 108 cap a_spec_t capa;109 cap a_from_blocks(de->s.size, 1, &capa);110 cap a_simplify(&capa);108 cap_spec_t cap; 109 cap_from_blocks(de->s.size, 1, &cap); 110 cap_simplify(&cap); 111 111 112 112 char *rptr; 113 errno_t rc = cap a_format(&capa, &rptr);113 errno_t rc = cap_format(&cap, &rptr); 114 114 if (rc != EOK) { 115 115 return rc; -
uspace/app/df/df.c
r84876aa4 rb093a62 35 35 */ 36 36 37 #include <cap a.h>37 #include <cap.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 a_spec_t capa;127 128 cap a_from_blocks(nblocks, block_size, &capa);129 cap a_simplify(&capa);130 return cap a_format(&capa, rptr);126 cap_spec_t cap; 127 128 cap_from_blocks(nblocks, block_size, &cap); 129 cap_simplify(&cap); 130 return cap_format(&cap, rptr); 131 131 } 132 132 -
uspace/app/fdisk/fdisk.c
r84876aa4 rb093a62 34 34 */ 35 35 36 #include <cap a.h>36 #include <cap.h> 37 37 #include <errno.h> 38 38 #include <fdisk.h> … … 136 136 nchoice_t *choice = NULL; 137 137 char *svcname = NULL; 138 cap a_spec_t capa;138 cap_spec_t cap; 139 139 fdisk_dev_info_t *sdev; 140 char *scap a= NULL;140 char *scap = NULL; 141 141 char *dtext = NULL; 142 142 service_id_t svcid; … … 177 177 } 178 178 179 rc = fdisk_dev_info_capacity(info, &cap a);179 rc = fdisk_dev_info_capacity(info, &cap); 180 180 if (rc != EOK) { 181 181 printf("Error getting device capacity " … … 185 185 } 186 186 187 cap a_simplify(&capa);188 189 rc = cap a_format(&capa, &scapa);187 cap_simplify(&cap); 188 189 rc = cap_format(&cap, &scap); 190 190 if (rc != EOK) { 191 191 assert(rc == ENOMEM); … … 194 194 } 195 195 196 int ret = asprintf(&dtext, "%s (%s)", svcname, scap a);196 int ret = asprintf(&dtext, "%s (%s)", svcname, scap); 197 197 if (ret < 0) { 198 198 rc = ENOMEM; … … 203 203 free(svcname); 204 204 svcname = NULL; 205 free(scap a);206 scap a= NULL;205 free(scap); 206 scap = NULL; 207 207 208 208 rc = nchoice_add(choice, dtext, info, 0); … … 261 261 free(dtext); 262 262 free(svcname); 263 free(scap a);263 free(scap); 264 264 return rc; 265 265 } … … 432 432 errno_t rc; 433 433 fdisk_part_spec_t pspec; 434 cap a_spec_t capa;435 cap a_spec_t mcapa;434 cap_spec_t cap; 435 cap_spec_t mcap; 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 a;441 char *smcap a= NULL;440 char *scap; 441 char *smcap = 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 a);450 rc = fdisk_part_get_max_avail(dev, spc, &mcap); 451 451 if (rc != EOK) { 452 452 rc = EIO; … … 454 454 } 455 455 456 cap a_simplify(&mcapa);457 458 rc = cap a_format(&mcapa, &smcapa);456 cap_simplify(&mcap); 457 458 rc = cap_format(&mcap, &smcap); 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 a, &scapa);476 rc = tinput_read_i(tinput, smcap, &scap); 477 477 if (rc != EOK) 478 478 goto error; 479 479 480 rc = cap a_parse(scapa, &capa);480 rc = cap_parse(scap, &cap); 481 481 if (rc == EOK) 482 482 break; … … 485 485 tinput_destroy(tinput); 486 486 tinput = NULL; 487 free(smcap a);488 smcap a= NULL;487 free(smcap); 488 smcap = NULL; 489 489 490 490 if (pkind != lpk_extended) { … … 545 545 546 546 fdisk_pspec_init(&pspec); 547 pspec.capacity = cap a;547 pspec.capacity = cap; 548 548 pspec.pkind = pkind; 549 549 pspec.fstype = fstype; … … 561 561 return EOK; 562 562 error: 563 free(smcap a);563 free(smcap); 564 564 free(label); 565 565 free(mountp); … … 581 581 fdisk_part_t *part; 582 582 fdisk_part_info_t pinfo; 583 char *scap a= NULL;583 char *scap = NULL; 584 584 char *spkind = NULL; 585 585 char *sfstype = NULL; … … 596 596 } 597 597 598 cap a_simplify(&pinfo.capacity);599 600 rc = cap a_format(&pinfo.capacity, &scapa);598 cap_simplify(&pinfo.capacity); 599 600 rc = cap_format(&pinfo.capacity, &scap); 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 a, spkind, sfstype);625 scap, spkind, sfstype); 626 626 if (ret < 0) { 627 627 rc = ENOMEM; … … 630 630 631 631 } else { 632 int ret = asprintf(&sdesc, "%s, %s", scap a, spkind);632 int ret = asprintf(&sdesc, "%s, %s", scap, spkind); 633 633 if (ret < 0) { 634 634 rc = ENOMEM; … … 644 644 } 645 645 646 free(scap a);647 scap a= NULL;646 free(scap); 647 scap = NULL; 648 648 free(spkind); 649 649 spkind = NULL; … … 658 658 return EOK; 659 659 error: 660 free(scap a);660 free(scap); 661 661 free(spkind); 662 662 free(sfstype); … … 907 907 fdisk_part_t *part; 908 908 fdisk_part_info_t pinfo; 909 cap a_spec_t capa;910 cap a_spec_t mcapa;909 cap_spec_t cap; 910 cap_spec_t mcap; 911 911 fdisk_dev_flags_t dflags; 912 912 char *sltype = NULL; 913 char *sdcap a= NULL;914 char *scap a= NULL;915 char *smcap a= NULL;913 char *sdcap = NULL; 914 char *scap = NULL; 915 char *smcap = NULL; 916 916 char *sfstype = NULL; 917 917 char *svcname = NULL; … … 936 936 } 937 937 938 rc = fdisk_dev_capacity(dev, &cap a);938 rc = fdisk_dev_capacity(dev, &cap); 939 939 if (rc != EOK) { 940 940 printf("Error getting device capacity.\n"); … … 942 942 } 943 943 944 cap a_simplify(&capa);945 946 rc = cap a_format(&capa, &sdcapa);944 cap_simplify(&cap); 945 946 rc = cap_format(&cap, &sdcap); 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 a);961 free(sdcap a);962 sdcap a= NULL;960 printf("Device: %s (%s)\n", svcname, sdcap); 961 free(sdcap); 962 sdcap = NULL; 963 963 964 964 rc = fdisk_label_get_info(dev, &linfo); … … 996 996 } 997 997 998 cap a_simplify(&pinfo.capacity);999 1000 rc = cap a_format(&pinfo.capacity, &scapa);998 cap_simplify(&pinfo.capacity); 999 1000 rc = cap_format(&pinfo.capacity, &scap); 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 a);1018 printf("Entire disk: %s %s", label, scap); 1019 1019 else 1020 printf("Partition %d: %s %s", npart, label, scap a);1020 printf("Partition %d: %s %s", npart, label, scap); 1021 1021 1022 1022 if ((linfo.flags & lf_ext_supp) != 0) { … … 1037 1037 printf("\n"); 1038 1038 1039 free(scap a);1040 scap a= NULL;1039 free(scap); 1040 scap = 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 a);1049 rc = fdisk_part_get_max_avail(dev, spc_pri, &mcap); 1050 1050 if (rc != EOK) { 1051 1051 rc = EIO; … … 1053 1053 } 1054 1054 1055 cap a_simplify(&mcapa);1056 1057 rc = cap a_format(&mcapa, &smcapa);1055 cap_simplify(&mcap); 1056 1057 rc = cap_format(&mcap, &smcap); 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 a);1064 printf("Maximum free primary block: %s\n", smcap); 1065 1065 else 1066 printf("Maximum free block: %s\n", smcap a);1067 1068 free(smcap a);1069 smcap a= NULL;1070 1071 rc = fdisk_part_get_tot_avail(dev, spc_pri, &mcap a);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); 1072 1072 if (rc != EOK) { 1073 1073 rc = EIO; … … 1075 1075 } 1076 1076 1077 cap a_simplify(&mcapa);1078 1079 rc = cap a_format(&mcapa, &smcapa);1077 cap_simplify(&mcap); 1078 1079 rc = cap_format(&mcap, &smcap); 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 a);1086 printf("Total free primary space: %s\n", smcap); 1087 1087 else 1088 printf("Total free space: %s\n", smcap a);1089 1090 free(smcap a);1091 smcap a= NULL;1088 printf("Total free space: %s\n", smcap); 1089 1090 free(smcap); 1091 smcap = 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 a);1096 rc = fdisk_part_get_max_avail(dev, spc_log, &mcap); 1097 1097 if (rc != EOK) { 1098 1098 rc = EIO; … … 1100 1100 } 1101 1101 1102 cap a_simplify(&mcapa);1103 1104 rc = cap a_format(&mcapa, &smcapa);1102 cap_simplify(&mcap); 1103 1104 rc = cap_format(&mcap, &smcap); 1105 1105 if (rc != EOK) { 1106 1106 rc = ENOMEM; … … 1108 1108 } 1109 1109 1110 printf("Maximum free logical block: %s\n", smcap a);1111 free(smcap a);1112 smcap a= NULL;1113 1114 rc = fdisk_part_get_tot_avail(dev, spc_log, &mcap a);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); 1115 1115 if (rc != EOK) { 1116 1116 rc = EIO; … … 1118 1118 } 1119 1119 1120 cap a_simplify(&mcapa);1121 1122 rc = cap a_format(&mcapa, &smcapa);1120 cap_simplify(&mcap); 1121 1122 rc = cap_format(&mcap, &smcap); 1123 1123 if (rc != EOK) { 1124 1124 rc = ENOMEM; … … 1126 1126 } 1127 1127 1128 printf("Total free logical space: %s\n", smcap a);1129 free(smcap a);1130 smcap a= NULL;1128 printf("Total free logical space: %s\n", smcap); 1129 free(smcap); 1130 smcap = NULL; 1131 1131 } 1132 1132 … … 1279 1279 return EOK; 1280 1280 error: 1281 free(sdcap a);1282 free(scap a);1283 free(smcap a);1281 free(sdcap); 1282 free(scap); 1283 free(smcap); 1284 1284 free(sfstype); 1285 1285 free(svcname); -
uspace/app/sysinst/sysinst.c
r84876aa4 rb093a62 38 38 #include <block.h> 39 39 #include <byteorder.h> 40 #include <cap a.h>40 #include <cap.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 a_spec_t capa;100 cap_spec_t cap; 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 a);139 rc = fdisk_part_get_max_avail(fdev, spc_pri, &cap); 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 a;146 pspec.capacity = cap; 147 147 pspec.pkind = lpk_primary; 148 148 pspec.fstype = fs_ext4; /* Cannot be changed without modifying core.img */ -
uspace/app/trace/syscalls.c
r84876aa4 rb093a62 38 38 39 39 const sc_desc_t syscall_desc[] = { 40 /* System management syscalls. */41 40 [SYS_KIO] = { "kio", 3, V_INT_ERRNO }, 42 41 43 /* Thread and task related syscalls. */44 42 [SYS_THREAD_CREATE] = { "thread_create", 3, V_ERRNO }, 45 43 [SYS_THREAD_EXIT] = { "thread_exit", 1, V_ERRNO }, 46 44 [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 },49 45 50 46 [SYS_TASK_GET_ID] = { "task_get_id", 1, V_ERRNO }, 51 47 [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 },55 48 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. */64 49 [SYS_AS_AREA_CREATE] = { "as_area_create", 5, V_ERRNO }, 65 50 [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 },68 51 [SYS_AS_AREA_DESTROY] = { "as_area_destroy", 1, V_ERRNO }, 69 52 70 /* Page mapping related syscalls. */71 [SYS_PAGE_FIND_MAPPING] = { "page_find_mapping", 2, V_ERRNO },72 73 /* IPC related syscalls. */74 53 [SYS_IPC_CALL_ASYNC_FAST] = { "ipc_call_async_fast", 6, V_HASH }, 75 54 [SYS_IPC_CALL_ASYNC_SLOW] = { "ipc_call_async_slow", 3, V_HASH }, 55 76 56 [SYS_IPC_ANSWER_FAST] = { "ipc_answer_fast", 6, V_ERRNO }, 77 57 [SYS_IPC_ANSWER_SLOW] = { "ipc_answer_slow", 2, V_ERRNO }, … … 81 61 [SYS_IPC_POKE] = { "ipc_poke", 0, V_ERRNO }, 82 62 [SYS_IPC_HANGUP] = { "ipc_hangup", 1, V_ERRNO }, 83 [SYS_IPC_CONNECT_KBOX] = { "ipc_connect_kbox", 2, V_ERRNO },84 63 85 /* Event notification syscalls. */86 64 [SYS_IPC_EVENT_SUBSCRIBE] = { "ipc_event_subscribe", 2, V_ERRNO }, 87 65 [SYS_IPC_EVENT_UNSUBSCRIBE] = { "ipc_event_unsubscribe", 1, V_ERRNO }, 88 66 [SYS_IPC_EVENT_UNMASK] = { "ipc_event_unmask", 1, V_ERRNO }, 89 67 90 /* Permission related syscalls. */91 68 [SYS_PERM_GRANT] = { "perm_grant", 2, V_ERRNO }, 92 69 [SYS_PERM_REVOKE] = { "perm_revoke", 2, V_ERRNO }, 93 94 /* DDI related syscalls. */95 70 [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 },99 71 [SYS_IOSPACE_ENABLE] = { "iospace_enable", 1, V_ERRNO }, 100 [SYS_IOSPACE_DISABLE] = { "iospace_disable", 1, V_ERRNO },101 72 102 73 [SYS_IPC_IRQ_SUBSCRIBE] = { "ipc_irq_subscribe", 4, V_ERRNO }, 103 74 [SYS_IPC_IRQ_UNSUBSCRIBE] = { "ipc_irq_unsubscribe", 2, V_ERRNO }, 104 75 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 },108 76 [SYS_SYSINFO_GET_VAL_TYPE] = { "sysinfo_get_val_type", 2, V_INTEGER }, 109 77 [SYS_SYSINFO_GET_VALUE] = { "sysinfo_get_value", 3, V_ERRNO }, … … 111 79 [SYS_SYSINFO_GET_DATA] = { "sysinfo_get_data", 5, V_ERRNO }, 112 80 113 /* Kernel console syscalls. */114 81 [SYS_DEBUG_CONSOLE] = { "debug_console", 0, V_ERRNO }, 115 116 [SYS_KLOG] = { "klog", 5, V_ERRNO } 82 [SYS_IPC_CONNECT_KBOX] = { "ipc_connect_kbox", 1, V_ERRNO } 117 83 }; 118 84 -
uspace/app/trace/trace.c
r84876aa4 rb093a62 47 47 #include <mem.h> 48 48 #include <str.h> 49 #include <loader/loader.h> 49 50 #include <io/console.h> 50 51 #include <io/keycode.h> … … 85 86 void thread_trace_start(uintptr_t thread_hash); 86 87 87 static char *cmd_path;88 static char **cmd_args;89 90 88 static task_id_t task_id; 91 static task_wait_t task_w;89 static loader_t *task_ldr; 92 90 static bool task_wait_for; 93 91 … … 95 93 display_mask_t display_mask; 96 94 95 static errno_t program_run_fibril(void *arg); 97 96 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 } 98 110 99 111 static void cev_fibril_start(void) … … 110 122 } 111 123 112 static errno_t program_run (void)124 static errno_t program_run_fibril(void *arg) 113 125 { 114 126 errno_t rc; 115 127 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 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); 126 133 if (rc != EOK) { 127 printf("Error running program (%s)\n", str_error_name(rc)); 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; 142 } 143 144 static errno_t connect_task(task_id_t task_id) 145 { 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)); 128 165 return rc; 129 166 } 130 167 131 return EOK; 132 } 133 134 static errno_t connect_task(task_id_t task_id) 135 { 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); 168 rc = udebug_set_evmask(ksess, UDEBUG_EM_ALL); 167 169 if (rc != EOK) { 168 170 printf("udebug_set_evmask(0x%x) -> %s\n ", UDEBUG_EM_ALL, str_error_name(rc)); … … 170 172 } 171 173 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; 174 sess = ksess; 175 return 0; 181 176 } 182 177 … … 203 198 printf("\ntotal of %zu threads\n", tb_needed / sizeof(uintptr_t)); 204 199 205 return EOK;200 return 0; 206 201 } 207 202 … … 493 488 494 489 printf("Finished tracing thread [%d].\n", thread_id); 495 return EOK;490 return 0; 496 491 } 497 492 … … 507 502 } 508 503 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; 509 576 } 510 577 … … 740 807 ++argv; 741 808 task_id = strtol(*argv, &err_p, 10); 809 task_ldr = NULL; 742 810 task_wait_for = false; 743 811 if (*err_p) { … … 780 848 printf("'%s'\n", *cp++); 781 849 782 cmd_path = *argv; 783 cmd_args = argv; 850 task_ldr = preload_task(*argv, argv, &task_id); 784 851 task_wait_for = true; 785 852 … … 802 869 803 870 main_init(); 804 805 if (cmd_path != NULL)806 program_run();807 871 808 872 rc = connect_task(task_id); … … 814 878 printf("Connected to task %" PRIu64 ".\n", task_id); 815 879 880 if (task_ldr != NULL) 881 program_run(); 882 816 883 cev_fibril_start(); 817 884 trace_task(task_id); … … 820 887 printf("Waiting for task to exit.\n"); 821 888 822 rc = task_wait (&task_w, &texit, &retval);889 rc = task_wait_task_id(task_id, &texit, &retval); 823 890 if (rc != EOK) { 824 891 printf("Failed waiting for task.\n"); -
uspace/lib/c/generic/loader.c
r84876aa4 rb093a62 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 stopped350 * for debugging.351 *352 * After using this function, no further operations can be performed353 * 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 370 347 /** Cancel the loader session. 371 348 * -
uspace/lib/c/generic/task.c
r84876aa4 rb093a62 35 35 */ 36 36 37 #include <async.h>38 37 #include <task.h> 39 38 #include <loader/loader.h> … … 47 46 #include <ns.h> 48 47 #include <stdlib.h> 49 #include <udebug.h>50 48 #include <libc.h> 51 49 #include "private/ns.h" … … 96 94 * This is really just a convenience wrapper over the more complicated 97 95 * loader API. Arguments are passed as a null-terminated array of strings. 98 * A debug session is created optionally.99 96 * 100 97 * @param id If not NULL, the ID of the task is stored here on success. … … 103 100 * @param path Pathname of the binary to execute. 104 101 * @param argv Command-line arguments. 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) 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[]) 113 108 { 114 109 /* Send default files */ … … 130 125 } 131 126 132 return task_spawnvf _debug(id, wait, path, args, fd_stdin, fd_stdout,133 fd_stderr , rsess);127 return task_spawnvf(id, wait, path, args, fd_stdin, fd_stdout, 128 fd_stderr); 134 129 } 135 130 136 131 /** Create a new task by running an executable from the filesystem. 137 *138 * This is really just a convenience wrapper over the more complicated139 * 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 store143 * 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.157 132 * 158 133 * This is really just a convenience wrapper over the more complicated 159 134 * loader API. Arguments are passed as a null-terminated array of strings. 160 135 * Files are passed as null-terminated array of pointers to fdi_node_t. 161 * A debug session is created optionally.162 136 * 163 137 * @param id If not NULL, the ID of the task is stored here on success. 164 * @param wait If not NULL, setup waiting for task's return value and store .138 * @param wait If not NULL, setup waiting for task's return value and store 165 139 * @param path Pathname of the binary to execute. 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 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 { 182 151 /* Connect to a program loader. */ 183 152 loader_t *ldr = loader_connect(); … … 248 217 } 249 218 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 } 219 /* Run it. */ 220 rc = loader_run(ldr); 221 if (rc != EOK) 222 goto error; 274 223 275 224 /* Success */ 276 225 if (id != NULL) 277 226 *id = task_id; 278 if (rsess != NULL) 279 *rsess = ksess; 227 280 228 return EOK; 281 229 282 230 error: 283 if (ksess != NULL)284 async_hangup(ksess);285 231 if (wait_initialized) 286 232 task_cancel_wait(wait); … … 289 235 loader_abort(ldr); 290 236 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 execute301 * @param argv Command-line arguments302 * @param std_in File to use as stdin303 * @param std_out File to use as stdout304 * @param std_err File to use as stderr305 *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);314 237 } 315 238 -
uspace/lib/c/include/loader/loader.h
r84876aa4 rb093a62 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 *);56 55 extern void loader_abort(loader_t *); 57 56 -
uspace/lib/c/include/task.h
r84876aa4 rb093a62 36 36 #define _LIBC_TASK_H_ 37 37 38 #include <async.h>39 38 #include <stdint.h> 40 39 #include <stdarg.h> … … 57 56 extern errno_t task_spawnv(task_id_t *, task_wait_t *, const char *path, 58 57 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 **);61 58 extern errno_t task_spawnvf(task_id_t *, task_wait_t *, const char *path, 62 59 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 **);65 60 extern errno_t task_spawn(task_id_t *, task_wait_t *, const char *path, int, 66 61 va_list ap); -
uspace/lib/c/meson.build
r84876aa4 rb093a62 65 65 'generic/bd_srv.c', 66 66 'generic/perm.c', 67 'generic/cap a.c',67 'generic/cap.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 a.c',206 'test/cap.c', 207 207 'test/casting.c', 208 208 'test/double_to_str.c', -
uspace/lib/c/test/getopt.c
r84876aa4 rb093a62 278 278 "get_opt_test", 279 279 "-f", 280 "-pparam" 280 "-p", 281 "param" 281 282 }; 282 283 -
uspace/lib/c/test/main.c
r84876aa4 rb093a62 32 32 PCUT_INIT; 33 33 34 PCUT_IMPORT(cap a);34 PCUT_IMPORT(cap); 35 35 PCUT_IMPORT(casting); 36 36 PCUT_IMPORT(circ_buf); -
uspace/lib/fdisk/include/fdisk.h
r84876aa4 rb093a62 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 a_spec_t *);52 extern errno_t fdisk_dev_info_capacity(fdisk_dev_info_t *, cap_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 a_spec_t *);59 extern errno_t fdisk_dev_capacity(fdisk_dev_t *, cap_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 a_spec_t *);69 extern errno_t fdisk_part_get_tot_avail(fdisk_dev_t *, fdisk_spc_t, cap a_spec_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 *); 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
r84876aa4 rb093a62 38 38 39 39 #include <adt/list.h> 40 #include <cap a.h>40 #include <cap.h> 41 41 #include <loc.h> 42 42 #include <stdint.h> … … 126 126 link_t llog_ba; 127 127 /** Capacity */ 128 cap a_spec_t capacity;128 cap_spec_t capacity; 129 129 /** Partition kind */ 130 130 label_pkind_t pkind; … … 150 150 typedef struct { 151 151 /** Desired capacity */ 152 cap a_spec_t capacity;152 cap_spec_t capacity; 153 153 /** Partition kind */ 154 154 label_pkind_t pkind; … … 164 164 typedef struct { 165 165 /** Capacity */ 166 cap a_spec_t capacity;166 cap_spec_t capacity; 167 167 /** Partition kind */ 168 168 label_pkind_t pkind; -
uspace/lib/fdisk/src/fdisk.c
r84876aa4 rb093a62 35 35 36 36 #include <adt/list.h> 37 #include <cap a.h>37 #include <cap.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 a_spec_t *capa)221 errno_t fdisk_dev_info_capacity(fdisk_dev_info_t *info, cap_spec_t *cap) 222 222 { 223 223 vbd_disk_info_t vinfo; … … 228 228 return EIO; 229 229 230 cap a_from_blocks(vinfo.nblocks, vinfo.block_size, capa);230 cap_from_blocks(vinfo.nblocks, vinfo.block_size, cap); 231 231 return EOK; 232 232 } … … 295 295 dev->ext_part = part; 296 296 297 cap a_from_blocks(part->nblocks, dev->dinfo.block_size,297 cap_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 a_spec_t *capa)539 { 540 cap a_from_blocks(dev->dinfo.nblocks, dev->dinfo.block_size, capa);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); 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, 682 capa_spec_t *capa) 681 errno_t fdisk_part_get_max_avail(fdisk_dev_t *dev, fdisk_spc_t spc, cap_spec_t *cap) 683 682 { 684 683 errno_t rc; … … 699 698 } 700 699 701 cap a_from_blocks(nb, dev->dinfo.block_size, capa);700 cap_from_blocks(nb, dev->dinfo.block_size, cap); 702 701 return EOK; 703 702 } … … 705 704 /** Get total free space capacity. */ 706 705 errno_t fdisk_part_get_tot_avail(fdisk_dev_t *dev, fdisk_spc_t spc, 707 cap a_spec_t *capa)706 cap_spec_t *cap) 708 707 { 709 708 fdisk_free_range_t fr; … … 727 726 } while (fdisk_free_range_next(&fr)); 728 727 729 cap a_from_blocks(totb, dev->dinfo.block_size, capa);728 cap_from_blocks(totb, dev->dinfo.block_size, cap); 730 729 return EOK; 731 730 } … … 939 938 errno_t rc; 940 939 941 rc = cap a_to_blocks(&pspec->capacity, cv_nom, dev->dinfo.block_size,940 rc = cap_to_blocks(&pspec->capacity, cv_nom, dev->dinfo.block_size, 942 941 &nom_blocks); 943 942 if (rc != EOK) 944 943 return rc; 945 944 946 rc = cap a_to_blocks(&pspec->capacity, cv_min, dev->dinfo.block_size,945 rc = cap_to_blocks(&pspec->capacity, cv_min, dev->dinfo.block_size, 947 946 &min_blocks); 948 947 if (rc != EOK) 949 948 return rc; 950 949 951 rc = cap a_to_blocks(&pspec->capacity, cv_max, dev->dinfo.block_size,950 rc = cap_to_blocks(&pspec->capacity, cv_max, dev->dinfo.block_size, 952 951 &max_blocks); 953 952 if (rc != EOK) -
uspace/lib/meson.build
r84876aa4 rb093a62 37 37 'softrend', 38 38 'posix', 39 'clui',40 'pcm',41 'hound'42 39 ] 43 40 -
uspace/srv/hid/input/input.c
r84876aa4 rb093a62 66 66 #include "serial.h" 67 67 68 #define NUM_LAYOUTS 568 #define NUM_LAYOUTS 4 69 69 70 70 static layout_ops_t *layout[NUM_LAYOUTS] = { … … 72 72 &us_dvorak_ops, 73 73 &cz_ops, 74 &ar_ops, 75 &fr_azerty_ops 74 &ar_ops 76 75 }; 77 76 … … 209 208 // TODO: More elegant layout switching 210 209 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 } 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; 236 236 } 237 237 -
uspace/srv/hid/input/layout.h
r84876aa4 rb093a62 60 60 extern layout_ops_t cz_ops; 61 61 extern layout_ops_t ar_ops; 62 extern layout_ops_t fr_azerty_ops;63 62 64 63 extern layout_t *layout_create(layout_ops_t *); -
uspace/srv/hid/input/meson.build
r84876aa4 rb093a62 31 31 src = files( 32 32 'layout/cz.c', 33 'layout/fr_azerty.c',34 33 'layout/us_qwerty.c', 35 34 'layout/us_dvorak.c', -
uspace/srv/net/tcp/test/tqueue.c
r84876aa4 rb093a62 32 32 33 33 #include "../conn.h" 34 #include "../segment.h"35 34 #include "../tqueue.h" 36 35 … … 118 117 PCUT_ASSERT_EQUALS(CTL_SYN, trans_seg[0]->ctrl); 119 118 PCUT_ASSERT_EQUALS(10, trans_seg[0]->seq); 120 tcp_segment_delete(trans_seg[0]);121 119 } 122 120 … … 158 156 PCUT_ASSERT_EQUALS(CTL_FIN | CTL_ACK, trans_seg[0]->ctrl); 159 157 PCUT_ASSERT_EQUALS(10, trans_seg[0]->seq); 160 tcp_segment_delete(trans_seg[0]);161 158 } 162 159 … … 201 198 PCUT_ASSERT_EQUALS(CTL_ACK, trans_seg[0]->ctrl); 202 199 PCUT_ASSERT_EQUALS(10, trans_seg[0]->seq); 203 tcp_segment_delete(trans_seg[0]);204 200 } 205 201 … … 260 256 static void tqueue_test_transmit_seg(inet_ep2_t *epp, tcp_segment_t *seg) 261 257 { 262 trans_seg[seg_cnt++] = tcp_segment_dup(seg);258 trans_seg[seg_cnt++] = seg; 263 259 } 264 260 -
uspace/srv/net/udp/assoc.c
r84876aa4 rb093a62 40 40 #include <fibril_synch.h> 41 41 #include <inet/endpoint.h> 42 #include <inet/inet.h> 42 43 #include <io/log.h> 43 44 #include <nettl/amap.h> … … 47 48 #include "msg.h" 48 49 #include "pdu.h" 50 #include "udp_inet.h" 49 51 #include "udp_type.h" 50 52 … … 55 57 static udp_assoc_t *udp_assoc_find_ref(inet_ep2_t *); 56 58 static errno_t udp_assoc_queue_msg(udp_assoc_t *, inet_ep2_t *, udp_msg_t *); 57 static udp_assocs_dep_t *assocs_dep;58 59 59 60 /** Initialize associations. */ 60 errno_t udp_assocs_init( udp_assocs_dep_t *dep)61 errno_t udp_assocs_init(void) 61 62 { 62 63 errno_t rc; … … 68 69 } 69 70 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;81 72 } 82 73 … … 183 174 184 175 assert(assoc->deleted == false); 176 udp_assoc_delref(assoc); 185 177 assoc->deleted = true; 186 udp_assoc_delref(assoc);187 178 } 188 179 … … 253 244 errno_t udp_assoc_send(udp_assoc_t *assoc, inet_ep_t *remote, udp_msg_t *msg) 254 245 { 246 udp_pdu_t *pdu; 255 247 inet_ep2_t epp; 256 248 errno_t rc; … … 274 266 if (inet_addr_is_any(&epp.local.addr) && !assoc->nolocal) { 275 267 log_msg(LOG_DEFAULT, LVL_DEBUG, "Determine local address."); 276 rc = (*assocs_dep->get_srcaddr)(&epp.remote.addr, 0, 277 &epp.local.addr); 268 rc = inet_get_srcaddr(&epp.remote.addr, 0, &epp.local.addr); 278 269 if (rc != EOK) { 279 270 log_msg(LOG_DEFAULT, LVL_DEBUG, "Cannot determine " … … 289 280 return EINVAL; 290 281 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 291 288 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_send - transmit"); 292 rc = (*assocs_dep->transmit_msg)(&epp, msg); 289 290 rc = udp_transmit_pdu(pdu); 291 udp_pdu_delete(pdu); 293 292 294 293 if (rc != EOK) -
uspace/srv/net/udp/assoc.h
r84876aa4 rb093a62 40 40 #include "udp_type.h" 41 41 42 extern errno_t udp_assocs_init(udp_assocs_dep_t *); 43 extern void udp_assocs_fini(void); 42 extern errno_t udp_assocs_init(void); 44 43 extern udp_assoc_t *udp_assoc_new(inet_ep2_t *, udp_assoc_cb_t *, void *); 45 44 extern void udp_assoc_delete(udp_assoc_t *); -
uspace/srv/net/udp/meson.build
r84876aa4 rb093a62 28 28 29 29 deps = [ 'nettl' ] 30 31 _common_src = files( 30 src = files( 32 31 'assoc.c', 33 'cassoc.c',34 32 'msg.c', 35 33 'pdu.c', 36 )37 38 src = files(39 34 'service.c', 40 35 'udp.c', 41 36 'udp_inet.c', 42 37 ) 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
r84876aa4 rb093a62 46 46 47 47 #include "assoc.h" 48 #include "cassoc.h"49 48 #include "msg.h" 50 49 #include "service.h" … … 56 55 #define MAX_MSG_SIZE DATA_XFER_LIMIT 57 56 58 static void udp_ recv_msg_cassoc(void *, inet_ep2_t *, udp_msg_t *);57 static void udp_cassoc_recv_msg(void *, inet_ep2_t *, udp_msg_t *); 59 58 60 59 /** Callbacks to tie us to association layer */ 61 60 static udp_assoc_cb_t udp_cassoc_cb = { 62 .recv_msg = udp_ recv_msg_cassoc61 .recv_msg = udp_cassoc_recv_msg 63 62 }; 63 64 /** Add message to client receive queue. 65 * 66 * @param cassoc Client association 67 * @param epp Endpoint pair on which message was received 68 * @param msg Message 69 * 70 * @return EOK on success, ENOMEM if out of memory 71 */ 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 } 64 92 65 93 /** Send 'data' event to client. … … 80 108 } 81 109 110 /** Create client association. 111 * 112 * This effectively adds an association into a client's namespace. 113 * 114 * @param client Client 115 * @param assoc Association 116 * @param rcassoc Place to store pointer to new client association 117 * 118 * @return EOK on soccess, ENOMEM if out of memory 119 */ 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 association 149 */ 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 Client 159 * @param id Client association ID 160 * @param rcassoc Place to store pointer to client association 161 * 162 * @return EOK on success, ENOENT if no client association with the given ID 163 * 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 82 178 /** Message received on client association. 83 179 * … … 88 184 * @param msg Message 89 185 */ 90 static void udp_ recv_msg_cassoc(void *arg, inet_ep2_t *epp, udp_msg_t *msg)186 static void udp_cassoc_recv_msg(void *arg, inet_ep2_t *epp, udp_msg_t *msg) 91 187 { 92 188 udp_cassoc_t *cassoc = (udp_cassoc_t *) arg; -
uspace/srv/net/udp/udp.c
r84876aa4 rb093a62 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_msg52 };53 54 49 static errno_t udp_init(void) 55 50 { … … 58 53 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_init()"); 59 54 60 rc = udp_assocs_init( &udp_assocs_dep);55 rc = udp_assocs_init(); 61 56 if (rc != EOK) { 62 57 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed initializing associations."); -
uspace/srv/net/udp/udp_inet.c
r84876aa4 rb093a62 134 134 } 135 135 136 /** Get source address.137 *138 * @param remote Remote address139 * @param tos Type of service140 * @param local Place to store local address141 * @return EOK on success or an error code142 */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 168 136 /** 169 137 * @} -
uspace/srv/net/udp/udp_inet.h
r84876aa4 rb093a62 36 36 #define UDP_INET_H 37 37 38 #include <inet/addr.h>39 #include <stdint.h>40 38 #include "udp_type.h" 41 39 42 40 extern errno_t udp_inet_init(void); 43 41 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 *);46 42 47 43 #endif -
uspace/srv/net/udp/udp_type.h
r84876aa4 rb093a62 37 37 38 38 #include <async.h> 39 #include <errno.h>40 39 #include <fibril.h> 41 40 #include <fibril_synch.h> … … 45 44 #include <stdbool.h> 46 45 #include <stddef.h> 47 #include <stdint.h>48 46 #include <inet/addr.h> 49 47 … … 89 87 } udp_pdu_t; 90 88 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 */ 89 /** Association callbacks */ 106 90 typedef struct { 107 91 /** Message received */ -
uspace/srv/volsrv/volume.c
r84876aa4 rb093a62 367 367 if (refcount_down(&volume->refcnt)) { 368 368 /* No more references. Check if volume is persistent. */ 369 list_remove(&volume->lvolumes); 370 vol_volume_delete(volume); 369 if (!vol_volume_is_persist(volume)) { 370 list_remove(&volume->lvolumes); 371 vol_volume_delete(volume); 372 } 371 373 } 372 374 } … … 397 399 /* Volume is now persistent */ 398 400 if (volume->nvolume == NULL) { 399 /* Prevent volume from being freed */400 refcount_up(&volume->refcnt);401 402 401 /* Create volume node */ 403 402 rc = sif_trans_begin(volume->volumes->repo, &trans); … … 427 426 volume->nvolume = nvolume; 428 427 } else { 429 /* Allow volume to be freed */430 vol_volume_del_ref(volume);431 432 428 /* Update volume node */ 433 429 rc = sif_trans_begin(volume->volumes->repo, &trans);
Note:
See TracChangeset
for help on using the changeset viewer.