Changes in / [36b16bc:7a2f7ecd] in mainline
- Files:
-
- 3 added
- 1 deleted
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
HelenOS.config
r36b16bc r7a2f7ecd 70 70 @ "pentium4" Pentium 4 71 71 @ "pentium3" Pentium 3 72 @ "i486" i486 72 73 @ "core" Core Solo/Duo 73 74 @ "athlon_xp" Athlon XP -
boot/Makefile.common
r36b16bc r7a2f7ecd 143 143 $(USPACE_PATH)/app/blkdump/blkdump \ 144 144 $(USPACE_PATH)/app/bnchmark/bnchmark \ 145 $(USPACE_PATH)/app/devctl/devctl \ 145 146 $(USPACE_PATH)/app/dltest/dltest \ 146 147 $(USPACE_PATH)/app/dltest2/dltest2 \ -
kernel/arch/ia32/Makefile.inc
r36b16bc r7a2f7ecd 64 64 endif 65 65 66 ifeq ($(PROCESSOR),i486) 67 CMN2 = -march=i486 68 endif 69 66 70 ifeq ($(PROCESSOR),core) 67 71 CMN2 = -march=prescott -
kernel/arch/ia32/include/asm.h
r36b16bc r7a2f7ecd 311 311 } 312 312 313 #ifndef PROCESSOR_i486 313 314 /** Write to MSR */ 314 315 NO_TRACE static inline void write_msr(uint32_t msr, uint64_t value) … … 335 336 return ((uint64_t) dx << 32) | ax; 336 337 } 338 #endif 337 339 338 340 -
kernel/arch/ia32/include/atomic.h
r36b16bc r7a2f7ecd 121 121 asm volatile ( 122 122 "0:\n" 123 #ifndef PROCESSOR_i486 123 124 "pause\n" /* Pentium 4's HT love this instruction */ 125 #endif 124 126 "mov %[count], %[tmp]\n" 125 127 "testl %[tmp], %[tmp]\n" -
kernel/arch/ia32/include/cycle.h
r36b16bc r7a2f7ecd 40 40 NO_TRACE static inline uint64_t get_cycle(void) 41 41 { 42 #ifdef PROCESSOR_i486 43 return 0; 44 #else 42 45 uint64_t v; 43 46 … … 48 51 49 52 return v; 53 #endif 50 54 } 51 55 -
kernel/arch/ia32/src/asm.S
r36b16bc r7a2f7ecd 405 405 xorl %eax, %eax 406 406 cmpl $(GDT_SELECTOR(KTEXT_DES)), ISTATE_OFFSET_CS(%esp) 407 #ifdef PROCESSOR_i486 408 jz 0f 409 movl %eax, %ebp 410 0: 411 #else 407 412 cmovnzl %eax, %ebp 413 #endif 408 414 409 415 movl %ebp, ISTATE_OFFSET_EBP_FRAME(%esp) -
kernel/arch/ia32/src/boot/boot.S
r36b16bc r7a2f7ecd 97 97 pm_status $status_prot 98 98 99 movl $(INTEL_CPUID_LEVEL), %eax100 cpuid101 cmp $0x0, %eax /* any function > 0? */102 jbe pse_unsupported103 104 movl $(INTEL_CPUID_STANDARD), %eax105 cpuid106 bt $(INTEL_PSE), %edx107 jc pse_supported108 109 pse_unsupported:110 111 pm_error $err_pse112 113 pse_supported:114 115 99 #include "vesa_prot.inc" 116 100 … … 140 124 jmp hlt0 141 125 126 /** Calculate unmapped address of the end of the kernel. */ 127 calc_end_of_kernel: 128 movl $hardcoded_load_address, %edi 129 andl $0x7fffffff, %edi 130 movl (%edi), %esi 131 andl $0x7fffffff, %esi 132 133 movl $hardcoded_ktext_size, %edi 134 andl $0x7fffffff, %edi 135 addl (%edi), %esi 136 andl $0x7fffffff, %esi 137 138 movl $hardcoded_kdata_size, %edi 139 andl $0x7fffffff, %edi 140 addl (%edi), %esi 141 andl $0x7fffffff, %esi 142 movl %esi, end_of_kernel 143 ret 144 145 /** Find free 2M (+4k for alignment) region where to store page tables */ 146 find_mem_for_pt: 147 /* Check if multiboot info is present */ 148 cmpl $0x2BADB002, grub_eax 149 je check_multiboot_map 150 ret 151 check_multiboot_map: 152 /* Copy address of the multiboot info to ebx */ 153 movl grub_ebx, %ebx 154 /* Check if memory map flag is present */ 155 movl (%ebx), %edx 156 andl $(1 << 6), %edx 157 jnz use_multiboot_map 158 ret 159 use_multiboot_map: 160 /* Copy address of the memory map to edx */ 161 movl 48(%ebx), %edx 162 movl %edx, %ecx 163 addl 44(%ebx), %ecx 164 /* Find a free region at least 2M in size */ 165 check_memmap_loop: 166 /* Is this a free region? */ 167 cmp $1, 20(%edx) 168 jnz next_region 169 /* Check size */ 170 cmp $0, 16(%edx) 171 jnz next_region 172 cmpl $(2 * 1024 * 1024 + 4 * 1024), 12(%edx) 173 jbe next_region 174 cmp $0, 8(%edx) 175 jz found_region 176 next_region: 177 cmp %ecx, %edx 178 jbe next_region_do 179 ret 180 next_region_do: 181 addl (%edx), %edx 182 addl $4, %edx 183 jmp check_memmap_loop 184 found_region: 185 /* Use end of the found region */ 186 mov 4(%edx), %ecx 187 add 12(%edx), %ecx 188 sub $(2 * 1024 * 1024), %ecx 189 mov %ecx, free_area 190 ret 191 192 142 193 /** Setup mapping for the kernel. 143 194 * … … 148 199 .global map_kernel 149 200 map_kernel: 201 /* Paging features */ 150 202 movl %cr4, %ecx 151 orl $(1 << 4), %ecx /* PSE on */152 203 andl $(~(1 << 5)), %ecx /* PAE off */ 153 204 movl %ecx, %cr4 154 205 206 call calc_end_of_kernel 207 call find_mem_for_pt 208 mov end_of_kernel, %esi 209 mov free_area, %ecx 210 cmpl %esi, %ecx 211 jbe use_end_of_kernel 212 mov %ecx, %esi 213 /* Align address down to 4k */ 214 andl $(~4095), %esi 215 use_end_of_kernel: 216 217 /* Align address to 4k */ 218 addl $4095, %esi 219 andl $(~4095), %esi 220 221 /* Allocate space for page tables*/ 222 movl %esi, pt_loc 223 movl $ballocs, %edi 224 andl $0x7fffffff, %edi 225 movl %esi, (%edi) 226 addl $4, %edi 227 movl $(2*1024*1024), (%edi) 228 229 /* Fill page tables */ 230 xorl %ecx, %ecx 231 xorl %ebx, %ebx 232 233 floop_pt: 234 movl $((1 << 1) | (1 << 0)), %eax 235 orl %ebx, %eax 236 movl %eax, (%esi, %ecx, 4) 237 addl $(4 * 1024), %ebx 238 239 incl %ecx 240 cmpl $(512 * 1024), %ecx 241 jl floop_pt 242 243 /* Fill page directory */ 155 244 movl $(page_directory + 0), %esi 156 245 movl $(page_directory + 2048), %edi 157 246 xorl %ecx, %ecx 158 xorl %ebx, %ebx247 movl pt_loc, %ebx 159 248 160 249 floop: 161 movl $((1 << 7) | (1 <<1) | (1 << 0)), %eax250 movl $((1 << 1) | (1 << 0)), %eax 162 251 orl %ebx, %eax 163 252 /* Mapping 0x00000000 + %ecx * 4M => 0x00000000 + %ecx * 4M */ … … 165 254 /* Mapping 0x80000000 + %ecx * 4M => 0x00000000 + %ecx * 4M */ 166 255 movl %eax, (%edi, %ecx, 4) 167 addl $(4 * 1024 * 1024), %ebx256 addl $(4 * 1024), %ebx 168 257 169 258 incl %ecx … … 523 612 524 613 grub_ebx: 614 .long 0 615 616 pt_loc: 617 .long 0 618 end_of_kernel: 619 .long 0 620 free_area: 525 621 .long 0 526 622 -
kernel/arch/ia32/src/cpu/cpu.c
r36b16bc r7a2f7ecd 118 118 ); 119 119 } 120 120 121 #ifndef PROCESSOR_i486 121 122 if (CPU->arch.fi.bits.sep) { 122 123 /* Setup fast SYSENTER/SYSEXIT syscalls */ 123 124 syscall_setup_cpu(); 124 125 } 126 #endif 125 127 } 126 128 -
kernel/arch/ia32/src/proc/scheduler.c
r36b16bc r7a2f7ecd 60 60 uintptr_t kstk = (uintptr_t) &THREAD->kstack[STACK_SIZE]; 61 61 62 #ifndef PROCESSOR_i486 62 63 if (CPU->arch.fi.bits.sep) { 63 64 /* Set kernel stack for CP3 -> CPL0 switch via SYSENTER */ 64 65 write_msr(IA32_MSR_SYSENTER_ESP, kstk - sizeof(istate_t)); 65 66 } 67 #endif 66 68 67 69 /* Set kernel stack for CPL3 -> CPL0 switch via interrupt */ -
kernel/arch/ia32/src/syscall.c
r36b16bc r7a2f7ecd 39 39 #include <arch/pm.h> 40 40 41 #ifndef PROCESSOR_i486 41 42 /** Enable & setup support for SYSENTER/SYSEXIT */ 42 43 void syscall_setup_cpu(void) … … 49 50 write_msr(IA32_MSR_SYSENTER_EIP, (uint32_t) sysenter_handler); 50 51 } 52 #endif 51 53 52 54 /** @} -
kernel/generic/include/ipc/event.h
r36b16bc r7a2f7ecd 41 41 #include <ipc/ipc.h> 42 42 43 typedef struct task task_t;43 struct task; 44 44 45 45 typedef void (*event_callback_t)(void *); … … 63 63 64 64 extern void event_init(void); 65 extern void event_task_init( task_t*);65 extern void event_task_init(struct task *); 66 66 extern void event_cleanup_answerbox(answerbox_t *); 67 67 extern void event_set_unmask_callback(event_type_t, event_callback_t); 68 extern void event_task_set_unmask_callback( task_t*, event_task_type_t,68 extern void event_task_set_unmask_callback(struct task *, event_task_type_t, 69 69 event_callback_t); 70 70 … … 97 97 extern int event_notify(event_type_t, bool, sysarg_t, sysarg_t, sysarg_t, 98 98 sysarg_t, sysarg_t); 99 extern int event_task_notify( task_t*, event_task_type_t, bool, sysarg_t, sysarg_t,99 extern int event_task_notify(struct task *, event_task_type_t, bool, sysarg_t, sysarg_t, 100 100 sysarg_t, sysarg_t, sysarg_t); 101 101 -
uspace/Makefile
r36b16bc r7a2f7ecd 37 37 app/blkdump \ 38 38 app/bnchmark \ 39 app/devctl \ 39 40 app/edit \ 40 41 app/ext2info \ -
uspace/app/lsusb/main.c
r36b16bc r7a2f7ecd 81 81 } 82 82 char path[MAX_PATH_LENGTH]; 83 rc = devman_ get_device_path(dev_handle, path, MAX_PATH_LENGTH);83 rc = devman_fun_get_path(dev_handle, path, MAX_PATH_LENGTH); 84 84 if (rc != EOK) { 85 85 continue; … … 120 120 } 121 121 char path[MAX_PATH_LENGTH]; 122 rc = devman_ get_device_path(hc_handle, path, MAX_PATH_LENGTH);122 rc = devman_fun_get_path(hc_handle, path, MAX_PATH_LENGTH); 123 123 if (rc != EOK) { 124 124 printf(NAME ": Error resolving path of HC with SID %" -
uspace/app/mkbd/main.c
r36b16bc r7a2f7ecd 240 240 241 241 char path[MAX_PATH_LENGTH]; 242 rc = devman_ get_device_path(dev_handle, path, MAX_PATH_LENGTH);242 rc = devman_fun_get_path(dev_handle, path, MAX_PATH_LENGTH); 243 243 if (rc != EOK) { 244 244 return ENOMEM; -
uspace/app/tester/hw/serial/serial1.c
r36b16bc r7a2f7ecd 72 72 73 73 devman_handle_t handle; 74 int res = devman_ device_get_handle("/hw/pci0/00:01.0/com1/a", &handle,74 int res = devman_fun_get_handle("/hw/pci0/00:01.0/com1/a", &handle, 75 75 IPC_FLAG_BLOCKING); 76 76 if (res != EOK) -
uspace/lib/c/arch/ia32/Makefile.common
r36b16bc r7a2f7ecd 28 28 29 29 CLANG_ARCH = i386 30 ifeq ($(PROCESSOR),i486) 31 GCC_CFLAGS += -march=i486 -fno-omit-frame-pointer 32 else 30 33 GCC_CFLAGS += -march=pentium -fno-omit-frame-pointer 34 endif 31 35 32 36 ENDIANESS = LE -
uspace/lib/c/arch/ia32/Makefile.inc
r36b16bc r7a2f7ecd 28 28 29 29 ARCH_SOURCES = \ 30 arch/$(UARCH)/src/entry. s\30 arch/$(UARCH)/src/entry.S \ 31 31 arch/$(UARCH)/src/entryjmp.s \ 32 32 arch/$(UARCH)/src/thread_entry.s \ -
uspace/lib/c/generic/devman.c
r36b16bc r7a2f7ecd 1 1 /* 2 2 * Copyright (c) 2007 Josef Cejka 3 * Copyright (c) 20 09Jiri Svoboda3 * Copyright (c) 2011 Jiri Svoboda 4 4 * Copyright (c) 2010 Lenka Trochtova 5 5 * All rights reserved. … … 342 342 } 343 343 344 int devman_ device_get_handle(const char *pathname, devman_handle_t *handle,344 int devman_fun_get_handle(const char *pathname, devman_handle_t *handle, 345 345 unsigned int flags) 346 346 { … … 383 383 } 384 384 385 int devman_get_device_path(devman_handle_t handle, char *path, size_t path_size) 385 static int devman_get_str_internal(sysarg_t method, sysarg_t arg1, char *buf, 386 size_t buf_size) 387 { 388 async_exch_t *exch; 389 ipc_call_t dreply; 390 size_t act_size; 391 sysarg_t dretval; 392 393 exch = devman_exchange_begin_blocking(LOC_PORT_CONSUMER); 394 395 ipc_call_t answer; 396 aid_t req = async_send_1(exch, method, arg1, &answer); 397 aid_t dreq = async_data_read(exch, buf, buf_size - 1, &dreply); 398 async_wait_for(dreq, &dretval); 399 400 devman_exchange_end(exch); 401 402 if (dretval != EOK) { 403 async_wait_for(req, NULL); 404 return dretval; 405 } 406 407 sysarg_t retval; 408 async_wait_for(req, &retval); 409 410 if (retval != EOK) 411 return retval; 412 413 act_size = IPC_GET_ARG2(dreply); 414 assert(act_size <= buf_size - 1); 415 buf[act_size] = '\0'; 416 417 return EOK; 418 } 419 420 int devman_fun_get_path(devman_handle_t handle, char *buf, size_t buf_size) 421 { 422 return devman_get_str_internal(DEVMAN_FUN_GET_PATH, handle, buf, 423 buf_size); 424 } 425 426 int devman_fun_get_name(devman_handle_t handle, char *buf, size_t buf_size) 427 { 428 return devman_get_str_internal(DEVMAN_FUN_GET_NAME, handle, buf, 429 buf_size); 430 } 431 432 static int devman_get_handles_once(sysarg_t method, sysarg_t arg1, 433 devman_handle_t *handle_buf, size_t buf_size, size_t *act_size) 434 { 435 async_exch_t *exch = devman_exchange_begin_blocking(DEVMAN_CLIENT); 436 437 ipc_call_t answer; 438 aid_t req = async_send_1(exch, method, arg1, &answer); 439 int rc = async_data_read_start(exch, handle_buf, buf_size); 440 441 devman_exchange_end(exch); 442 443 if (rc != EOK) { 444 async_wait_for(req, NULL); 445 return rc; 446 } 447 448 sysarg_t retval; 449 async_wait_for(req, &retval); 450 451 if (retval != EOK) { 452 return retval; 453 } 454 455 *act_size = IPC_GET_ARG1(answer); 456 return EOK; 457 } 458 459 /** Get list of handles. 460 * 461 * Returns an allocated array of handles. 462 * 463 * @param method IPC method 464 * @param arg1 IPC argument 1 465 * @param data Place to store pointer to array of handles 466 * @param count Place to store number of handles 467 * @return EOK on success or negative error code 468 */ 469 static int devman_get_handles_internal(sysarg_t method, sysarg_t arg1, 470 devman_handle_t **data, size_t *count) 471 { 472 devman_handle_t *handles; 473 size_t act_size; 474 size_t alloc_size; 475 int rc; 476 477 *data = NULL; 478 act_size = 0; /* silence warning */ 479 480 rc = devman_get_handles_once(method, arg1, NULL, 0, 481 &act_size); 482 if (rc != EOK) 483 return rc; 484 485 alloc_size = act_size; 486 handles = malloc(alloc_size); 487 if (handles == NULL) 488 return ENOMEM; 489 490 while (true) { 491 rc = devman_get_handles_once(method, arg1, handles, alloc_size, 492 &act_size); 493 if (rc != EOK) 494 return rc; 495 496 if (act_size <= alloc_size) 497 break; 498 499 alloc_size *= 2; 500 free(handles); 501 502 handles = malloc(alloc_size); 503 if (handles == NULL) 504 return ENOMEM; 505 } 506 507 *count = act_size / sizeof(devman_handle_t); 508 *data = handles; 509 return EOK; 510 } 511 512 int devman_fun_get_child(devman_handle_t funh, devman_handle_t *devh) 386 513 { 387 514 async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT); … … 389 516 return ENOMEM; 390 517 391 ipc_call_t answer; 392 aid_t req = async_send_1(exch, DEVMAN_DEVICE_GET_DEVICE_PATH, 393 handle, &answer); 394 395 ipc_call_t data_request_call; 396 aid_t data_request = async_data_read(exch, path, path_size, 397 &data_request_call); 398 399 devman_exchange_end(exch); 400 401 if (data_request == 0) { 402 async_wait_for(req, NULL); 403 return ENOMEM; 404 } 405 406 sysarg_t data_request_rc; 407 async_wait_for(data_request, &data_request_rc); 408 409 sysarg_t opening_request_rc; 410 async_wait_for(req, &opening_request_rc); 411 412 if (data_request_rc != EOK) { 413 /* Prefer the return code of the opening request. */ 414 if (opening_request_rc != EOK) 415 return (int) opening_request_rc; 416 else 417 return (int) data_request_rc; 418 } 419 420 if (opening_request_rc != EOK) 421 return (int) opening_request_rc; 422 423 /* To be on the safe-side. */ 424 path[path_size - 1] = 0; 425 size_t transferred_size = IPC_GET_ARG2(data_request_call); 426 if (transferred_size >= path_size) 427 return ELIMIT; 428 429 /* Terminate the string (trailing 0 not send over IPC). */ 430 path[transferred_size] = 0; 431 return EOK; 518 sysarg_t retval = async_req_1_1(exch, DEVMAN_FUN_GET_CHILD, 519 funh, devh); 520 521 devman_exchange_end(exch); 522 return (int) retval; 523 } 524 525 int devman_dev_get_functions(devman_handle_t devh, devman_handle_t **funcs, 526 size_t *count) 527 { 528 return devman_get_handles_internal(DEVMAN_DEV_GET_FUNCTIONS, 529 devh, funcs, count); 432 530 } 433 531 -
uspace/lib/c/generic/io/printf_core.c
r36b16bc r7a2f7ecd 206 206 } 207 207 208 return (int) (counter + 1);208 return (int) (counter); 209 209 } 210 210 … … 244 244 } 245 245 246 return (int) (counter + 1);246 return (int) (counter); 247 247 } 248 248 -
uspace/lib/c/include/devman.h
r36b16bc r7a2f7ecd 56 56 unsigned int); 57 57 58 extern int devman_ device_get_handle(const char *, devman_handle_t *,58 extern int devman_fun_get_handle(const char *, devman_handle_t *, 59 59 unsigned int); 60 extern int devman_get_device_path(devman_handle_t, char *, size_t); 60 extern int devman_fun_get_child(devman_handle_t, devman_handle_t *); 61 extern int devman_dev_get_functions(devman_handle_t, devman_handle_t **, 62 size_t *); 63 extern int devman_fun_get_name(devman_handle_t, char *, size_t); 64 extern int devman_fun_get_path(devman_handle_t, char *, size_t); 61 65 62 66 extern int devman_add_device_to_category(devman_handle_t, const char *); -
uspace/lib/c/include/ipc/devman.h
r36b16bc r7a2f7ecd 149 149 typedef enum { 150 150 DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD, 151 DEVMAN_DEVICE_GET_DEVICE_PATH, 151 DEVMAN_DEV_GET_FUNCTIONS, 152 DEVMAN_FUN_GET_CHILD, 153 DEVMAN_FUN_GET_NAME, 154 DEVMAN_FUN_GET_PATH, 152 155 DEVMAN_FUN_SID_TO_HANDLE 153 156 } client_to_devman_t; -
uspace/lib/usb/src/resolve.c
r36b16bc r7a2f7ecd 152 152 if (str_length(func_start) > 0) { 153 153 char tmp_path[MAX_DEVICE_PATH ]; 154 rc = devman_ get_device_path(dev_handle,154 rc = devman_fun_get_path(dev_handle, 155 155 tmp_path, MAX_DEVICE_PATH); 156 156 if (rc != EOK) { … … 173 173 174 174 /* First try to get the device handle. */ 175 rc = devman_ device_get_handle(path, &dev_handle, 0);175 rc = devman_fun_get_handle(path, &dev_handle, 0); 176 176 if (rc != EOK) { 177 177 free(path); … … 184 184 /* Get device handle first. */ 185 185 devman_handle_t tmp_handle; 186 rc = devman_ device_get_handle(path, &tmp_handle, 0);186 rc = devman_fun_get_handle(path, &tmp_handle, 0); 187 187 if (rc != EOK) { 188 188 free(path); -
uspace/lib/usbvirt/src/device.c
r36b16bc r7a2f7ecd 87 87 88 88 devman_handle_t handle; 89 int rc = devman_ device_get_handle(vhc_path, &handle, 0);89 int rc = devman_fun_get_handle(vhc_path, &handle, 0); 90 90 if (rc != EOK) 91 91 return rc; -
uspace/srv/devman/devman.c
r36b16bc r7a2f7ecd 920 920 } 921 921 922 /** Get list of device functions. */ 923 int dev_get_functions(dev_tree_t *tree, dev_node_t *dev, 924 devman_handle_t *hdl_buf, size_t buf_size, size_t *act_size) 925 { 926 size_t act_cnt; 927 size_t buf_cnt; 928 929 assert(fibril_rwlock_is_locked(&tree->rwlock)); 930 931 buf_cnt = buf_size / sizeof(devman_handle_t); 932 933 act_cnt = list_count(&dev->functions); 934 *act_size = act_cnt * sizeof(devman_handle_t); 935 936 if (buf_size % sizeof(devman_handle_t) != 0) 937 return EINVAL; 938 939 size_t pos = 0; 940 list_foreach(dev->functions, item) { 941 fun_node_t *fun = 942 list_get_instance(item, fun_node_t, dev_functions); 943 944 if (pos < buf_cnt) 945 hdl_buf[pos] = fun->handle; 946 pos++; 947 } 948 949 return EOK; 950 } 951 952 922 953 /* Function nodes */ 923 954 … … 1145 1176 char *rel_path = path; 1146 1177 char *next_path_elem = NULL; 1147 bool cont = true;1178 bool cont = (rel_path[1] != '\0'); 1148 1179 1149 1180 while (cont && fun != NULL) { -
uspace/srv/devman/devman.h
r36b16bc r7a2f7ecd 253 253 extern dev_node_t *find_dev_node(dev_tree_t *tree, devman_handle_t handle); 254 254 extern dev_node_t *find_dev_function(dev_node_t *, const char *); 255 extern int dev_get_functions(dev_tree_t *tree, dev_node_t *, devman_handle_t *, 256 size_t, size_t *); 255 257 256 258 extern fun_node_t *create_fun_node(void); -
uspace/srv/devman/main.c
r36b16bc r7a2f7ecd 497 497 } 498 498 499 /** Find device path by its handle. */ 500 static void devman_get_device_path_by_handle(ipc_callid_t iid, 501 ipc_call_t *icall) 499 /** Get device name. */ 500 static void devman_fun_get_name(ipc_callid_t iid, ipc_call_t *icall) 502 501 { 503 502 devman_handle_t handle = IPC_GET_ARG1(*icall); … … 523 522 } 524 523 524 size_t sent_length = str_size(fun->name); 525 if (sent_length > data_len) { 526 sent_length = data_len; 527 } 528 529 async_data_read_finalize(data_callid, fun->name, sent_length); 530 async_answer_0(iid, EOK); 531 532 free(buffer); 533 } 534 535 536 /** Get device path. */ 537 static void devman_fun_get_path(ipc_callid_t iid, ipc_call_t *icall) 538 { 539 devman_handle_t handle = IPC_GET_ARG1(*icall); 540 541 fun_node_t *fun = find_fun_node(&device_tree, handle); 542 if (fun == NULL) { 543 async_answer_0(iid, ENOMEM); 544 return; 545 } 546 547 ipc_callid_t data_callid; 548 size_t data_len; 549 if (!async_data_read_receive(&data_callid, &data_len)) { 550 async_answer_0(iid, EINVAL); 551 return; 552 } 553 554 void *buffer = malloc(data_len); 555 if (buffer == NULL) { 556 async_answer_0(data_callid, ENOMEM); 557 async_answer_0(iid, ENOMEM); 558 return; 559 } 560 525 561 size_t sent_length = str_size(fun->pathname); 526 562 if (sent_length > data_len) { … … 532 568 533 569 free(buffer); 570 } 571 572 static void devman_dev_get_functions(ipc_callid_t iid, ipc_call_t *icall) 573 { 574 ipc_callid_t callid; 575 size_t size; 576 size_t act_size; 577 int rc; 578 579 if (!async_data_read_receive(&callid, &size)) { 580 async_answer_0(callid, EREFUSED); 581 async_answer_0(iid, EREFUSED); 582 return; 583 } 584 585 fibril_rwlock_read_lock(&device_tree.rwlock); 586 587 dev_node_t *dev = find_dev_node_no_lock(&device_tree, 588 IPC_GET_ARG1(*icall)); 589 if (dev == NULL) { 590 fibril_rwlock_read_unlock(&device_tree.rwlock); 591 async_answer_0(callid, ENOENT); 592 async_answer_0(iid, ENOENT); 593 return; 594 } 595 596 devman_handle_t *hdl_buf = (devman_handle_t *) malloc(size); 597 if (hdl_buf == NULL) { 598 fibril_rwlock_read_unlock(&device_tree.rwlock); 599 async_answer_0(callid, ENOMEM); 600 async_answer_0(iid, ENOMEM); 601 return; 602 } 603 604 rc = dev_get_functions(&device_tree, dev, hdl_buf, size, &act_size); 605 if (rc != EOK) { 606 fibril_rwlock_read_unlock(&device_tree.rwlock); 607 async_answer_0(callid, rc); 608 async_answer_0(iid, rc); 609 return; 610 } 611 612 fibril_rwlock_read_unlock(&device_tree.rwlock); 613 614 sysarg_t retval = async_data_read_finalize(callid, hdl_buf, size); 615 free(hdl_buf); 616 617 async_answer_1(iid, retval, act_size); 618 } 619 620 621 /** Get handle for child device of a function. */ 622 static void devman_fun_get_child(ipc_callid_t iid, ipc_call_t *icall) 623 { 624 fun_node_t *fun; 625 626 fibril_rwlock_read_lock(&device_tree.rwlock); 627 628 fun = find_fun_node(&device_tree, IPC_GET_ARG1(*icall)); 629 if (fun == NULL) { 630 fibril_rwlock_read_unlock(&device_tree.rwlock); 631 async_answer_0(iid, ENOENT); 632 return; 633 } 634 635 if (fun->child == NULL) { 636 fibril_rwlock_read_unlock(&device_tree.rwlock); 637 async_answer_0(iid, ENOENT); 638 return; 639 } 640 641 async_answer_1(iid, EOK, fun->child->handle); 642 643 fibril_rwlock_read_unlock(&device_tree.rwlock); 534 644 } 535 645 … … 566 676 devman_function_get_handle(callid, &call); 567 677 break; 568 case DEVMAN_DEVICE_GET_DEVICE_PATH: 569 devman_get_device_path_by_handle(callid, &call); 678 case DEVMAN_DEV_GET_FUNCTIONS: 679 devman_dev_get_functions(callid, &call); 680 break; 681 case DEVMAN_FUN_GET_CHILD: 682 devman_fun_get_child(callid, &call); 683 break; 684 case DEVMAN_FUN_GET_NAME: 685 devman_fun_get_name(callid, &call); 686 break; 687 case DEVMAN_FUN_GET_PATH: 688 devman_fun_get_path(callid, &call); 570 689 break; 571 690 case DEVMAN_FUN_SID_TO_HANDLE:
Note:
See TracChangeset
for help on using the changeset viewer.