Changeset da68871a in mainline for uspace/lib
- Timestamp:
- 2012-08-08T08:46:22Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 30c0826
- Parents:
- bc216a0 (diff), 1d01cca (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. - Location:
- uspace/lib
- Files:
-
- 5 added
- 45 edited
-
c/Makefile (modified) (1 diff)
-
c/arch/abs32le/_link.ld.in (modified) (1 diff)
-
c/arch/amd64/_link.ld.in (modified) (1 diff)
-
c/arch/amd64/include/elf_linux.h (modified) (2 diffs)
-
c/arch/arm32/_link.ld.in (modified) (1 diff)
-
c/arch/arm32/src/fibril.S (modified) (2 diffs)
-
c/arch/arm32/src/stacktrace_asm.S (modified) (1 diff)
-
c/arch/arm32/src/thread_entry.s (modified) (1 diff)
-
c/arch/ia32/_link.ld.in (modified) (4 diffs)
-
c/arch/ia64/Makefile.common (modified) (1 diff)
-
c/arch/ia64/_link.ld.in (modified) (1 diff)
-
c/arch/mips32/Makefile.common (modified) (1 diff)
-
c/arch/mips32/_link.ld.in (modified) (1 diff)
-
c/arch/mips32eb/Makefile.common (modified) (1 diff)
-
c/arch/mips64/Makefile.common (modified) (1 diff)
-
c/arch/mips64/_link.ld.in (modified) (1 diff)
-
c/arch/ppc32/_link.ld.in (modified) (1 diff)
-
c/arch/sparc64/_link.ld.in (modified) (1 diff)
-
c/generic/device/ahci.c (added)
-
c/generic/malloc.c (modified) (9 diffs)
-
c/generic/str.c (modified) (5 diffs)
-
c/include/device/ahci.h (added)
-
c/include/ipc/dev_iface.h (modified) (1 diff)
-
c/include/str.h (modified) (1 diff)
-
clui/tinput.c (modified) (1 diff)
-
drv/Makefile (modified) (1 diff)
-
drv/generic/dev_iface.c (modified) (2 diffs)
-
drv/generic/remote_ahci.c (added)
-
drv/generic/remote_usb.c (modified) (8 diffs)
-
drv/generic/remote_usbhc.c (modified) (15 diffs)
-
drv/include/ahci_iface.h (added)
-
drv/include/remote_ahci.h (added)
-
usbdev/include/usb/dev/usb_device_connection.h (modified) (6 diffs)
-
usbdev/src/devdrv.c (modified) (6 diffs)
-
usbdev/src/pipes.c (modified) (10 diffs)
-
usbdev/src/pipesinit.c (modified) (4 diffs)
-
usbdev/src/request.c (modified) (8 diffs)
-
usbhid/include/usb/hid/hid_report_items.h (modified) (7 diffs)
-
usbhid/include/usb/hid/hidpath.h (modified) (4 diffs)
-
usbhid/include/usb/hid/hidtypes.h (modified) (8 diffs)
-
usbhid/include/usb/hid/request.h (modified) (2 diffs)
-
usbhid/src/hiddescriptor.c (modified) (13 diffs)
-
usbhid/src/hidparser.c (modified) (11 diffs)
-
usbhid/src/hidpath.c (modified) (11 diffs)
-
usbhid/src/hidreport.c (modified) (6 diffs)
-
usbhid/src/hidreq.c (modified) (7 diffs)
-
usbhost/src/endpoint.c (modified) (7 diffs)
-
usbhost/src/usb_device_manager.c (modified) (6 diffs)
-
usbhost/src/usb_endpoint_manager.c (modified) (11 diffs)
-
usbhost/src/usb_transfer_batch.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/Makefile
rbc216a0 rda68871a 71 71 generic/device/nic.c \ 72 72 generic/device/pci.c \ 73 generic/device/ahci.c \ 73 74 generic/elf/elf_load.c \ 74 75 generic/event.c \ -
uspace/lib/c/arch/abs32le/_link.ld.in
rbc216a0 rda68871a 14 14 SECTIONS { 15 15 #ifdef LOADER 16 . = 0x70001000 + SIZEOF_HEADERS; 17 16 18 .interp : { 17 19 *(.interp); 18 } :interp 19 20 . = 0x70001000 + SIZEOF_HEADERS; 20 } :interp :text 21 21 #else 22 22 . = 0x1000 + SIZEOF_HEADERS; 23 23 #endif 24 25 /* Make sure the code is aligned reasonably */ 26 . = ALIGN(., 16); 27 24 28 .text : { 25 29 *(.text .text.*); -
uspace/lib/c/arch/amd64/_link.ld.in
rbc216a0 rda68871a 15 15 SECTIONS { 16 16 #ifdef LOADER 17 . = 0x70001000 + SIZEOF_HEADERS; 18 17 19 .interp : { 18 20 *(.interp); 19 } :interp 20 21 . = 0x70001000 + SIZEOF_HEADERS; 21 } :interp :text 22 22 #else 23 23 . = 0x1000 + SIZEOF_HEADERS; 24 24 #endif 25 26 /* Make sure the code is aligned reasonably */ 27 . = ALIGN(., 16); 28 25 29 .init : { 26 30 *(.init); -
uspace/lib/c/arch/amd64/include/elf_linux.h
rbc216a0 rda68871a 66 66 uint64_t rsp; 67 67 uint64_t ss; 68 69 /* 70 * The following registers need to be part of elf_regs_t. 71 * Unfortunately, we don't have any information about them in our 72 * istate_t. 73 */ 74 uint64_t unused_fs_base; 75 uint64_t unused_gs_base; 76 uint64_t unused_ds; 77 uint64_t unused_es; 78 uint64_t unused_fs; 79 uint64_t unused_gs; 68 80 } elf_regs_t; 69 81 … … 91 103 elf_regs->rsp = istate->rsp; 92 104 elf_regs->ss = istate->ss; 105 106 /* 107 * Reset the registers for which there is not enough info in istate_t. 108 */ 109 elf_regs->unused_fs_base = 0; 110 elf_regs->unused_gs_base = 0; 111 elf_regs->unused_ds = 0; 112 elf_regs->unused_es = 0; 113 elf_regs->unused_fs = 0; 114 elf_regs->unused_gs = 0; 93 115 } 94 116 -
uspace/lib/c/arch/arm32/_link.ld.in
rbc216a0 rda68871a 14 14 SECTIONS { 15 15 #ifdef LOADER 16 . = 0x70001000 + SIZEOF_HEADERS; 17 16 18 .interp : { 17 19 *(.interp); 18 } :interp 19 20 . = 0x70001000 + SIZEOF_HEADERS; 20 } :interp :text 21 21 #else 22 22 . = 0x1000 + SIZEOF_HEADERS; 23 23 #endif 24 25 /* Make sure the code is aligned reasonably */ 26 . = ALIGN(., 8); 27 24 28 .init : { 25 29 *(.init); -
uspace/lib/c/arch/arm32/src/fibril.S
rbc216a0 rda68871a 35 35 stmia r0!, {sp, lr} 36 36 stmia r0!, {r4-r11} 37 37 38 38 # return 1 39 39 mov r0, #1 … … 43 43 ldmia r0!, {sp, lr} 44 44 ldmia r0!, {r4-r11} 45 46 # return 045 46 # return 0 47 47 mov r0, #0 48 48 mov pc, lr -
uspace/lib/c/arch/arm32/src/stacktrace_asm.S
rbc216a0 rda68871a 41 41 42 42 stacktrace_pc_get: 43 mov r0, lr 43 mov r0, lr 44 44 mov pc, lr -
uspace/lib/c/arch/arm32/src/thread_entry.s
rbc216a0 rda68871a 42 42 push {fp, ip, lr, pc} 43 43 sub fp, ip, #4 44 45 b __thread_main44 45 b __thread_main -
uspace/lib/c/arch/ia32/_link.ld.in
rbc216a0 rda68871a 19 19 20 20 SECTIONS { 21 #if defined(LOADER) || defined(DLEXE)22 .interp : {23 *(.interp);24 } :interp25 #endif26 21 #ifdef LOADER 27 22 . = 0x70001000 + SIZEOF_HEADERS; … … 29 24 . = 0x1000 + SIZEOF_HEADERS; 30 25 #endif 26 27 #if defined(LOADER) || defined(DLEXE) 28 .interp : { 29 *(.interp); 30 } :interp :text 31 #endif 32 33 /* Make sure the code is aligned reasonably */ 34 . = ALIGN(., 16); 35 31 36 .init : { 32 37 *(.init); … … 37 42 *(.rodata .rodata.*); 38 43 } :text 39 44 40 45 #if defined(SHLIB) || defined(DLEXE) 41 46 .rel.plt : { … … 80 85 #if defined(SHLIB) || defined(DLEXE) 81 86 .data.rel : { 82 *(.data.rel .data.rel.*);87 *(.data.rel .data.rel.*); 83 88 } :data 84 89 85 90 .got : { 86 *(.got);91 *(.got); 87 92 } :data 93 88 94 .got.plt : { 89 *(.got.plt);95 *(.got.plt); 90 96 } :data 91 97 #endif -
uspace/lib/c/arch/ia64/Makefile.common
rbc216a0 rda68871a 27 27 # 28 28 29 GCC_CFLAGS += -fno-unwind-tables 29 # 30 # FIXME: 31 # 32 # The -fno-selective-scheduling and -fno-selective-scheduling2 options 33 # should be removed as soon as a bug in GCC concerning unchecked 34 # speculative loads is fixed. 35 # 36 # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53975 for reference. 37 # 38 39 GCC_CFLAGS += -fno-unwind-tables -fno-selective-scheduling -fno-selective-scheduling2 30 40 31 41 ENDIANESS = LE -
uspace/lib/c/arch/ia64/_link.ld.in
rbc216a0 rda68871a 14 14 SECTIONS { 15 15 #ifdef LOADER 16 . = 0x800000000 + SIZEOF_HEADERS; 17 16 18 .interp : { 17 19 *(.interp); 18 } :interp 19 20 . = 0x800000000 + SIZEOF_HEADERS; 20 } :interp :text 21 21 #else 22 22 . = 0x4000 + SIZEOF_HEADERS; 23 23 #endif 24 /* 25 * XXX This is just a work around. Problem: .init section does not 26 * have the proper alignment. 27 */ 24 25 /* Make sure the code is aligned reasonably */ 28 26 . = ALIGN(., 16); 29 27 30 28 .init : { 31 29 *(.init); -
uspace/lib/c/arch/mips32/Makefile.common
rbc216a0 rda68871a 27 27 # 28 28 29 GCC_CFLAGS += -m ips3 -mabi=3229 GCC_CFLAGS += -msoft-float -mips3 -mabi=32 30 30 31 31 ENDIANESS = LE -
uspace/lib/c/arch/mips32/_link.ld.in
rbc216a0 rda68871a 14 14 SECTIONS { 15 15 #ifdef LOADER 16 . = 0x70004000 + SIZEOF_HEADERS; 17 16 18 .interp : { 17 19 *(.interp); 18 } :interp 19 20 . = 0x70004000 + SIZEOF_HEADERS; 20 } :interp :text 21 21 #else 22 22 . = 0x4000 + SIZEOF_HEADERS; 23 23 #endif 24 25 /* Make sure the code is aligned reasonably */ 26 . = ALIGN(., 16); 27 24 28 .init : { 25 29 *(.init); -
uspace/lib/c/arch/mips32eb/Makefile.common
rbc216a0 rda68871a 27 27 # 28 28 29 GCC_CFLAGS += -m ips3 -mabi=3229 GCC_CFLAGS += -msoft-float -mips3 -mabi=32 30 30 31 31 ENDIANESS = BE -
uspace/lib/c/arch/mips64/Makefile.common
rbc216a0 rda68871a 27 27 # 28 28 29 GCC_CFLAGS += -m ips3 -mabi=6429 GCC_CFLAGS += -msoft-float -mips3 -mabi=64 30 30 AFLAGS = -64 31 31 -
uspace/lib/c/arch/mips64/_link.ld.in
rbc216a0 rda68871a 15 15 SECTIONS { 16 16 #ifdef LOADER 17 . = 0x70004000 + SIZEOF_HEADERS; 18 17 19 .interp : { 18 20 *(.interp); 19 } :interp 20 21 . = 0x70004000 + SIZEOF_HEADERS; 21 } :interp :text 22 22 #else 23 23 . = 0x4000 + SIZEOF_HEADERS; 24 24 #endif 25 26 /* Make sure the code is aligned reasonably */ 27 . = ALIGN(., 16); 28 25 29 .init : { 26 30 *(.init); -
uspace/lib/c/arch/ppc32/_link.ld.in
rbc216a0 rda68871a 15 15 SECTIONS { 16 16 #ifdef LOADER 17 . = 0x70001000 + SIZEOF_HEADERS; 18 17 19 .interp : { 18 20 *(.interp); 19 } :interp 20 21 . = 0x70001000 + SIZEOF_HEADERS; 21 } :interp :text 22 22 #else 23 23 . = 0x1000 + SIZEOF_HEADERS; 24 24 #endif 25 26 /* Make sure the code is aligned reasonably */ 27 . = ALIGN(., 4); 28 25 29 .init : { 26 30 *(.init); -
uspace/lib/c/arch/sparc64/_link.ld.in
rbc216a0 rda68871a 14 14 SECTIONS { 15 15 #ifdef LOADER 16 . = 0x70004000 + SIZEOF_HEADERS; 17 16 18 .interp : { 17 19 *(.interp); 18 } :interp 19 20 . = 0x70004000 + SIZEOF_HEADERS; 20 } :interp :text 21 21 #else 22 22 . = 0x4000 + SIZEOF_HEADERS; 23 23 #endif 24 25 /* Make sure the code is aligned reasonably */ 26 . = ALIGN(., 16); 27 24 28 .init : { 25 29 *(.init); -
uspace/lib/c/generic/malloc.c
rbc216a0 rda68871a 109 109 (((uintptr_t) (area)->end) - sizeof(heap_block_foot_t)) 110 110 111 #define AREA_LAST_BLOCK_HEAD(area) \ 112 ((uintptr_t) BLOCK_HEAD(((heap_block_foot_t *) AREA_LAST_BLOCK_FOOT(area)))) 113 111 114 /** Get header in heap block. 112 115 * … … 346 349 return false; 347 350 348 /* Add new free block */ 349 size_t net_size = (size_t) (end - area->end); 350 if (net_size > 0) 351 block_init(area->end, net_size, true, area); 351 heap_block_head_t *last_head = 352 (heap_block_head_t *) AREA_LAST_BLOCK_HEAD(area); 353 354 if (last_head->free) { 355 /* Add the new space to the last block. */ 356 size_t net_size = (size_t) (end - area->end) + last_head->size; 357 malloc_assert(net_size > 0); 358 block_init(last_head, net_size, true, area); 359 } else { 360 /* Add new free block */ 361 size_t net_size = (size_t) (end - area->end); 362 if (net_size > 0) 363 block_init(area->end, net_size, true, area); 364 } 352 365 353 366 /* Update heap area parameters */ … … 355 368 356 369 return true; 357 }358 359 /** Try to enlarge any of the heap areas360 *361 * Should be called only inside the critical section.362 *363 * @param size Gross size of item to allocate (bytes).364 *365 */366 static bool heap_grow(size_t size)367 {368 if (size == 0)369 return true;370 371 /* First try to enlarge some existing area */372 for (heap_area_t *area = first_heap_area; area != NULL;373 area = area->next) {374 if (area_grow(area, size))375 return true;376 }377 378 /* Eventually try to create a new area */379 return area_create(AREA_OVERHEAD(size));380 370 } 381 371 … … 661 651 } 662 652 653 /** Try to enlarge any of the heap areas. 654 * 655 * If successful, allocate block of the given size in the area. 656 * Should be called only inside the critical section. 657 * 658 * @param size Gross size of item to allocate (bytes). 659 * @param align Memory address alignment. 660 * 661 * @return Allocated block. 662 * @return NULL on failure. 663 * 664 */ 665 static void *heap_grow_and_alloc(size_t size, size_t align) 666 { 667 if (size == 0) 668 return NULL; 669 670 /* First try to enlarge some existing area */ 671 for (heap_area_t *area = first_heap_area; area != NULL; 672 area = area->next) { 673 674 if (area_grow(area, size + align)) { 675 heap_block_head_t *first = 676 (heap_block_head_t *) AREA_LAST_BLOCK_HEAD(area); 677 678 void *addr = 679 malloc_area(area, first, NULL, size, align); 680 malloc_assert(addr != NULL); 681 return addr; 682 } 683 } 684 685 /* Eventually try to create a new area */ 686 if (area_create(AREA_OVERHEAD(size + align))) { 687 heap_block_head_t *first = 688 (heap_block_head_t *) AREA_FIRST_BLOCK_HEAD(last_heap_area); 689 690 void *addr = 691 malloc_area(last_heap_area, first, NULL, size, align); 692 malloc_assert(addr != NULL); 693 return addr; 694 } 695 696 return NULL; 697 } 698 663 699 /** Allocate a memory block 664 700 * … … 679 715 680 716 size_t falign = lcm(align, BASE_ALIGN); 681 size_t real_size = GROSS_SIZE(ALIGN_UP(size, falign)); 682 683 bool retry = false; 684 heap_block_head_t *split; 685 686 loop: 717 718 /* Check for integer overflow. */ 719 if (falign < align) 720 return NULL; 721 722 /* 723 * The size of the allocated block needs to be naturally 724 * aligned, because the footer structure also needs to reside 725 * on a naturally aligned address in order to avoid unaligned 726 * memory accesses. 727 */ 728 size_t gross_size = GROSS_SIZE(ALIGN_UP(size, BASE_ALIGN)); 687 729 688 730 /* Try the next fit approach */ 689 split = next_fit;731 heap_block_head_t *split = next_fit; 690 732 691 733 if (split != NULL) { 692 void *addr = malloc_area(split->area, split, NULL, real_size,734 void *addr = malloc_area(split->area, split, NULL, gross_size, 693 735 falign); 694 736 … … 703 745 AREA_FIRST_BLOCK_HEAD(area); 704 746 705 void *addr = malloc_area(area, first, split, real_size,747 void *addr = malloc_area(area, first, split, gross_size, 706 748 falign); 707 749 … … 710 752 } 711 753 712 if (!retry) { 713 /* Try to grow the heap space */ 714 if (heap_grow(real_size)) { 715 retry = true; 716 goto loop; 717 } 718 } 719 720 return NULL; 754 /* Finally, try to grow heap space and allocate in the new area. */ 755 return heap_grow_and_alloc(gross_size, falign); 721 756 } 722 757 … … 731 766 void *calloc(const size_t nmemb, const size_t size) 732 767 { 768 // FIXME: Check for overflow 769 733 770 void *block = malloc(nmemb * size); 734 771 if (block == NULL) … … 870 907 if (addr == NULL) 871 908 return; 872 909 873 910 futex_down(&malloc_futex); 874 911 -
uspace/lib/c/generic/str.c
rbc216a0 rda68871a 428 428 * 429 429 * Do a char-by-char comparison of two NULL-terminated strings. 430 * The strings are considered equal iff they consist of the same 431 * characters on the minimum of their lengths. 430 * The strings are considered equal iff their length is equal 431 * and both strings consist of the same sequence of characters. 432 * 433 * A string S1 is less than another string S2 if it has a character with 434 * lower value at the first character position where the strings differ. 435 * If the strings differ in length, the shorter one is treated as if 436 * padded by characters with a value of zero. 432 437 * 433 438 * @param s1 First string to compare. 434 439 * @param s2 Second string to compare. 435 440 * 436 * @return 0 if the strings are equal, -1 if first is smaller,437 * 1 if second smaller.441 * @return 0 if the strings are equal, -1 if the first is less than the second, 442 * 1 if the second is less than the first. 438 443 * 439 444 */ … … 466 471 * 467 472 * Do a char-by-char comparison of two NULL-terminated strings. 468 * The strings are considered equal iff they consist of the same 469 * characters on the minimum of their lengths and the length limit. 473 * The strings are considered equal iff 474 * min(str_length(s1), max_len) == min(str_length(s2), max_len) 475 * and both strings consist of the same sequence of characters, 476 * up to max_len characters. 477 * 478 * A string S1 is less than another string S2 if it has a character with 479 * lower value at the first character position where the strings differ. 480 * If the strings differ in length, the shorter one is treated as if 481 * padded by characters with a value of zero. Only the first max_len 482 * characters are considered. 470 483 * 471 484 * @param s1 First string to compare. … … 473 486 * @param max_len Maximum number of characters to consider. 474 487 * 475 * @return 0 if the strings are equal, -1 if first is smaller,476 * 1 if second smaller.488 * @return 0 if the strings are equal, -1 if the first is less than the second, 489 * 1 if the second is less than the first. 477 490 * 478 491 */ … … 508 521 return 0; 509 522 523 } 524 525 /** Test whether p is a prefix of s. 526 * 527 * Do a char-by-char comparison of two NULL-terminated strings 528 * and determine if p is a prefix of s. 529 * 530 * @param s The string in which to look 531 * @param p The string to check if it is a prefix of s 532 * 533 * @return true iff p is prefix of s else false 534 * 535 */ 536 bool str_test_prefix(const char *s, const char *p) 537 { 538 wchar_t c1 = 0; 539 wchar_t c2 = 0; 540 541 size_t off1 = 0; 542 size_t off2 = 0; 543 544 while (true) { 545 c1 = str_decode(s, &off1, STR_NO_LIMIT); 546 c2 = str_decode(p, &off2, STR_NO_LIMIT); 547 548 if (c2 == 0) 549 return true; 550 551 if (c1 != c2) 552 return false; 553 554 if (c1 == 0) 555 break; 556 } 557 558 return false; 510 559 } 511 560 … … 1085 1134 c = (c >= 'a' ? c - 'a' + 10 : (c >= 'A' ? c - 'A' + 10 : 1086 1135 (c <= '9' ? c - '0' : 0xff))); 1087 if (c > base) {1136 if (c >= base) { 1088 1137 break; 1089 1138 } -
uspace/lib/c/include/ipc/dev_iface.h
rbc216a0 rda68871a 51 51 /** Interface provided by USB HID devices. */ 52 52 USBHID_DEV_IFACE, 53 /** Interface provided by AHCI devices. */ 54 AHCI_DEV_IFACE, 53 55 54 56 DEV_IFACE_MAX -
uspace/lib/c/include/str.h
rbc216a0 rda68871a 79 79 extern int str_lcmp(const char *s1, const char *s2, size_t max_len); 80 80 81 extern bool str_test_prefix(const char *s, const char *p); 82 81 83 extern void str_cpy(char *dest, size_t size, const char *src); 82 84 extern void str_ncpy(char *dest, size_t size, const char *src, size_t n); -
uspace/lib/clui/tinput.c
rbc216a0 rda68871a 601 601 602 602 unsigned int cols = max(1, (ti->con_cols + 1) / (max_length + 1)); 603 unsigned int col_width = ti->con_cols / cols; 603 unsigned int padding = 0; 604 if ((cols * max_length) + (cols - 1) < ti->con_cols) { 605 padding = ti->con_cols - (cols * max_length) - (cols - 1); 606 } 607 unsigned int col_width = max_length + padding / cols; 604 608 unsigned int rows = cnum / cols + ((cnum % cols) != 0); 605 609 -
uspace/lib/drv/Makefile
rbc216a0 rda68871a 44 44 generic/remote_pci.c \ 45 45 generic/remote_usbhc.c \ 46 generic/remote_usbhid.c 46 generic/remote_usbhid.c \ 47 generic/remote_ahci.c 47 48 48 49 include $(USPACE_PREFIX)/Makefile.common -
uspace/lib/drv/generic/dev_iface.c
rbc216a0 rda68871a 46 46 #include "remote_usbhid.h" 47 47 #include "remote_pci.h" 48 #include "remote_ahci.h" 48 49 49 50 static iface_dipatch_table_t remote_ifaces = { … … 55 56 &remote_usb_iface, 56 57 &remote_usbhc_iface, 57 &remote_usbhid_iface 58 &remote_usbhid_iface, 59 &remote_ahci_iface 58 60 } 59 61 }; -
uspace/lib/drv/generic/remote_usb.c
rbc216a0 rda68871a 56 56 { 57 57 if (!exch) 58 return E INVAL;58 return EBADMEM; 59 59 sysarg_t addr; 60 60 const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE), … … 65 65 return ret; 66 66 } 67 /*----------------------------------------------------------------------------*/ 67 68 68 /** Tell interface number given device can use. 69 69 * @param[in] exch IPC communication exchange … … 75 75 { 76 76 if (!exch) 77 return E INVAL;77 return EBADMEM; 78 78 sysarg_t iface_no; 79 79 const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE), … … 83 83 return ret; 84 84 } 85 /*----------------------------------------------------------------------------*/ 85 86 86 /** Tell devman handle of device host controller. 87 87 * @param[in] exch IPC communication exchange … … 92 92 { 93 93 if (!exch) 94 return E INVAL;94 return EBADMEM; 95 95 devman_handle_t h; 96 96 const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE), … … 121 121 }; 122 122 123 /*----------------------------------------------------------------------------*/ 123 124 124 void remote_usb_get_my_address(ddf_fun_t *fun, void *iface, 125 125 ipc_callid_t callid, ipc_call_t *call) … … 140 140 } 141 141 } 142 /*----------------------------------------------------------------------------*/ 142 143 143 void remote_usb_get_my_interface(ddf_fun_t *fun, void *iface, 144 144 ipc_callid_t callid, ipc_call_t *call) … … 159 159 } 160 160 } 161 /*----------------------------------------------------------------------------*/ 161 162 162 void remote_usb_get_hc_handle(ddf_fun_t *fun, void *iface, 163 163 ipc_callid_t callid, ipc_call_t *call) -
uspace/lib/drv/generic/remote_usbhc.c
rbc216a0 rda68871a 165 165 { 166 166 if (!exch || !address) 167 return E INVAL;167 return EBADMEM; 168 168 sysarg_t new_address; 169 169 const int ret = async_req_4_1(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), … … 173 173 return ret; 174 174 } 175 /*----------------------------------------------------------------------------*/ 175 176 176 int usbhc_bind_address(async_exch_t *exch, usb_address_t address, 177 177 devman_handle_t handle) 178 178 { 179 179 if (!exch) 180 return E INVAL;180 return EBADMEM; 181 181 return async_req_3_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 182 182 IPC_M_USBHC_BIND_ADDRESS, address, handle); 183 183 } 184 /*----------------------------------------------------------------------------*/ 184 185 185 int usbhc_get_handle(async_exch_t *exch, usb_address_t address, 186 186 devman_handle_t *handle) 187 187 { 188 188 if (!exch) 189 return E INVAL;189 return EBADMEM; 190 190 sysarg_t h; 191 191 const int ret = async_req_2_1(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), … … 195 195 return ret; 196 196 } 197 /*----------------------------------------------------------------------------*/ 197 198 198 int usbhc_release_address(async_exch_t *exch, usb_address_t address) 199 199 { 200 200 if (!exch) 201 return E INVAL;201 return EBADMEM; 202 202 return async_req_2_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 203 203 IPC_M_USBHC_RELEASE_ADDRESS, address); 204 204 } 205 /*----------------------------------------------------------------------------*/ 205 206 206 int usbhc_register_endpoint(async_exch_t *exch, usb_address_t address, 207 207 usb_endpoint_t endpoint, usb_transfer_type_t type, … … 209 209 { 210 210 if (!exch) 211 return E INVAL;211 return EBADMEM; 212 212 const usb_target_t target = 213 213 {{ .address = address, .endpoint = endpoint }}; … … 220 220 #undef _PACK2 221 221 } 222 /*----------------------------------------------------------------------------*/ 222 223 223 int usbhc_unregister_endpoint(async_exch_t *exch, usb_address_t address, 224 224 usb_endpoint_t endpoint, usb_direction_t direction) 225 225 { 226 226 if (!exch) 227 return E INVAL;227 return EBADMEM; 228 228 return async_req_4_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 229 229 IPC_M_USBHC_UNREGISTER_ENDPOINT, address, endpoint, direction); 230 230 } 231 /*----------------------------------------------------------------------------*/ 231 232 232 int usbhc_read(async_exch_t *exch, usb_address_t address, 233 233 usb_endpoint_t endpoint, uint64_t setup, void *data, size_t size, 234 234 size_t *rec_size) 235 235 { 236 if (!exch) 237 return EBADMEM; 238 236 239 if (size == 0 && setup == 0) 237 240 return EOK; 238 241 239 if (!exch)240 return EINVAL;241 242 const usb_target_t target = 242 243 {{ .address = address, .endpoint = endpoint }}; … … 284 285 return EOK; 285 286 } 286 /*----------------------------------------------------------------------------*/ 287 287 288 int usbhc_write(async_exch_t *exch, usb_address_t address, 288 289 usb_endpoint_t endpoint, uint64_t setup, const void *data, size_t size) 289 290 { 291 if (!exch) 292 return EBADMEM; 293 290 294 if (size == 0 && setup == 0) 291 295 return EOK; 292 296 293 if (!exch)294 return EINVAL;295 297 const usb_target_t target = 296 298 {{ .address = address, .endpoint = endpoint }}; … … 319 321 return (int) opening_request_rc; 320 322 } 321 /*----------------------------------------------------------------------------*/ 323 322 324 323 325 static void remote_usbhc_request_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); … … 384 386 return trans; 385 387 } 386 /*----------------------------------------------------------------------------*/ 388 387 389 void remote_usbhc_request_address(ddf_fun_t *fun, void *iface, 388 390 ipc_callid_t callid, ipc_call_t *call) … … 406 408 } 407 409 } 408 /*----------------------------------------------------------------------------*/ 410 409 411 void remote_usbhc_bind_address(ddf_fun_t *fun, void *iface, 410 412 ipc_callid_t callid, ipc_call_t *call) … … 423 425 async_answer_0(callid, ret); 424 426 } 425 /*----------------------------------------------------------------------------*/ 427 426 428 void remote_usbhc_get_handle(ddf_fun_t *fun, void *iface, 427 429 ipc_callid_t callid, ipc_call_t *call) … … 444 446 } 445 447 } 446 /*----------------------------------------------------------------------------*/ 448 447 449 void remote_usbhc_release_address(ddf_fun_t *fun, void *iface, 448 450 ipc_callid_t callid, ipc_call_t *call) … … 460 462 async_answer_0(callid, ret); 461 463 } 462 /*----------------------------------------------------------------------------*/ 464 463 465 static void callback_out(ddf_fun_t *fun, 464 466 int outcome, void *arg) … … 470 472 async_transaction_destroy(trans); 471 473 } 472 /*----------------------------------------------------------------------------*/ 474 473 475 static void callback_in(ddf_fun_t *fun, 474 476 int outcome, size_t actual_size, void *arg) … … 494 496 async_transaction_destroy(trans); 495 497 } 496 /*----------------------------------------------------------------------------*/ 498 497 499 void remote_usbhc_register_endpoint(ddf_fun_t *fun, void *iface, 498 500 ipc_callid_t callid, ipc_call_t *call) … … 594 596 } 595 597 } 596 /*----------------------------------------------------------------------------*/ 598 597 599 void remote_usbhc_write( 598 600 ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call) -
uspace/lib/usbdev/include/usb/dev/usb_device_connection.h
rbc216a0 rda68871a 72 72 return EOK; 73 73 } 74 /*----------------------------------------------------------------------------*/ 74 75 75 /** Register endpoint on the device. 76 76 * @param instance device connection structure to use. … … 91 91 instance->address, ep, type, direction, packet_size, interval); 92 92 } 93 /*----------------------------------------------------------------------------*/ 93 94 94 /** Unregister endpoint on the device. 95 95 * @param instance device connection structure … … 105 105 instance->address, ep, dir); 106 106 } 107 /*----------------------------------------------------------------------------*/ 107 108 108 /** Get data from the device. 109 109 * @param[in] instance device connection structure to use. … … 122 122 instance->address, ep, setup, data, size, rsize); 123 123 } 124 /*----------------------------------------------------------------------------*/ 124 125 125 /** Send data to the device. 126 126 * @param instance device connection structure to use. … … 138 138 instance->address, ep, setup, data, size); 139 139 } 140 /*----------------------------------------------------------------------------*/ 140 141 141 /** Wrapper for read calls with no setup stage. 142 142 * @param[in] instance device connection structure. … … 153 153 return usb_device_control_read(instance, ep, 0, data, size, real_size); 154 154 } 155 /*----------------------------------------------------------------------------*/ 155 156 156 /** Wrapper for write calls with no setup stage. 157 157 * @param instance device connection structure. -
uspace/lib/usbdev/src/devdrv.c
rbc216a0 rda68871a 74 74 return ddf_driver_main(&generic_driver); 75 75 } 76 /*----------------------------------------------------------------------------*/ 76 77 77 /** Count number of pipes the driver expects. 78 78 * … … 87 87 return count; 88 88 } 89 /*----------------------------------------------------------------------------*/ 89 90 90 /** Callback when a new device is supposed to be controlled by this driver. 91 91 * … … 124 124 return rc; 125 125 } 126 /*----------------------------------------------------------------------------*/ 126 127 127 /** Callback when a device is supposed to be removed from the system. 128 128 * … … 146 146 return EOK; 147 147 } 148 /*----------------------------------------------------------------------------*/ 148 149 149 /** Callback when a device was removed from the system. 150 150 * … … 167 167 return ret; 168 168 } 169 /*----------------------------------------------------------------------------*/ 169 170 170 /** Destroy existing pipes of a USB device. 171 171 * … … 178 178 dev->pipes_count = 0; 179 179 } 180 /*----------------------------------------------------------------------------*/ 180 181 181 /** Change interface setting of a device. 182 182 * This function selects new alternate setting of an interface by issuing -
uspace/lib/usbdev/src/pipes.c
rbc216a0 rda68871a 54 54 return usb_hc_connection_open(pipe->wire->hc_connection); 55 55 } 56 /*----------------------------------------------------------------------------*/ 56 57 57 /** Terminate a long transfer on a pipe. 58 58 * @param pipe Pipe where to end the long transfer. … … 67 67 return usb_hc_connection_close(pipe->wire->hc_connection); 68 68 } 69 /*----------------------------------------------------------------------------*/ 69 70 70 /** Try to clear endpoint halt of default control pipe. 71 71 * … … 85 85 pipe->auto_reset_halt = true; 86 86 } 87 /*----------------------------------------------------------------------------*/ 87 88 88 /** Request a control read transfer on an endpoint pipe. 89 89 * … … 135 135 return rc; 136 136 } 137 /*----------------------------------------------------------------------------*/ 137 138 138 /** Request a control write transfer on an endpoint pipe. 139 139 * … … 182 182 return rc; 183 183 } 184 /*----------------------------------------------------------------------------*/ 184 185 185 /** Request a read (in) transfer on an endpoint pipe. 186 186 * … … 227 227 return rc; 228 228 } 229 /*----------------------------------------------------------------------------*/ 229 230 230 /** Request a write (out) transfer on an endpoint pipe. 231 231 * … … 259 259 pipe->endpoint_no, buffer, size); 260 260 } 261 /*----------------------------------------------------------------------------*/ 261 262 262 /** Initialize USB endpoint pipe. 263 263 * … … 287 287 return EOK; 288 288 } 289 /*----------------------------------------------------------------------------*/ 289 290 290 /** Initialize USB endpoint pipe as the default zero control pipe. 291 291 * … … 307 307 return rc; 308 308 } 309 /*----------------------------------------------------------------------------*/ 309 310 310 /** Register endpoint with the host controller. 311 311 * … … 323 323 pipe->direction, pipe->max_packet_size, interval); 324 324 } 325 /*----------------------------------------------------------------------------*/ 325 326 326 /** Revert endpoint registration with the host controller. 327 327 * -
uspace/lib/usbdev/src/pipesinit.c
rbc216a0 rda68871a 154 154 usb_endpoint_mapping_t *mapping, size_t mapping_count, 155 155 usb_standard_interface_descriptor_t *interface, 156 usb_standard_endpoint_descriptor_t *endpoint ,156 usb_standard_endpoint_descriptor_t *endpoint_desc, 157 157 usb_device_connection_t *wire) 158 158 { … … 163 163 164 164 /* Actual endpoint number is in bits 0..3 */ 165 const usb_endpoint_t ep_no = endpoint ->endpoint_address & 0x0F;165 const usb_endpoint_t ep_no = endpoint_desc->endpoint_address & 0x0F; 166 166 167 167 const usb_endpoint_description_t description = { 168 168 /* Endpoint direction is set by bit 7 */ 169 .direction = (endpoint ->endpoint_address & 128)169 .direction = (endpoint_desc->endpoint_address & 128) 170 170 ? USB_DIRECTION_IN : USB_DIRECTION_OUT, 171 171 /* Transfer type is in bits 0..2 and 172 172 * the enum values corresponds 1:1 */ 173 .transfer_type = endpoint ->attributes & 3,173 .transfer_type = endpoint_desc->attributes & 3, 174 174 175 175 /* Get interface characteristics. */ … … 194 194 195 195 int rc = usb_pipe_initialize(&ep_mapping->pipe, wire, 196 ep_no, description.transfer_type, endpoint->max_packet_size, 196 ep_no, description.transfer_type, 197 uint16_usb2host(endpoint_desc->max_packet_size), 197 198 description.direction); 198 199 if (rc != EOK) { … … 201 202 202 203 ep_mapping->present = true; 203 ep_mapping->descriptor = endpoint ;204 ep_mapping->descriptor = endpoint_desc; 204 205 ep_mapping->interface = interface; 205 206 -
uspace/lib/usbdev/src/request.c
rbc216a0 rda68871a 114 114 * (in native endianness). 115 115 * @param actual_data_size Actual size of transfered data 116 * (in native endianness).116 * (in native endianness). 117 117 * @return Error code. 118 118 * @retval EBADMEM @p pipe is NULL. … … 147 147 | (request_type << 5) | recipient, 148 148 .request = request, 149 .value = value,150 .index = index,151 .length = (uint16_t) data_size,149 .value = uint16_host2usb(value), 150 .index = uint16_host2usb(index), 151 .length = uint16_host2usb(data_size), 152 152 }; 153 153 … … 375 375 usb_standard_device_descriptor_t descriptor_tmp; 376 376 int rc = usb_request_get_descriptor(pipe, 377 USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE, 377 USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE, 378 378 USB_DESCTYPE_DEVICE, 0, 0, 379 379 &descriptor_tmp, sizeof(descriptor_tmp), … … 435 435 /* Everything is okay, copy the descriptor. */ 436 436 memcpy(descriptor, &descriptor_tmp, sizeof(descriptor_tmp)); 437 438 437 return EOK; 439 438 } … … 495 494 return ENOENT; 496 495 } 497 if (bare_config.total_length < sizeof(bare_config)) { 496 497 const size_t total_length = uint16_usb2host(bare_config.total_length); 498 if (total_length < sizeof(bare_config)) { 498 499 return ELIMIT; 499 500 } 500 501 501 void *buffer = malloc( bare_config.total_length);502 void *buffer = malloc(total_length); 502 503 if (buffer == NULL) { 503 504 return ENOMEM; … … 506 507 size_t transferred = 0; 507 508 rc = usb_request_get_full_configuration_descriptor(pipe, index, 508 buffer, bare_config.total_length, &transferred);509 buffer, total_length, &transferred); 509 510 if (rc != EOK) { 510 511 free(buffer); … … 512 513 } 513 514 514 if (transferred != bare_config.total_length) {515 if (transferred != total_length) { 515 516 free(buffer); 516 517 return ELIMIT; … … 522 523 523 524 if (descriptor_size != NULL) { 524 *descriptor_size = bare_config.total_length;525 *descriptor_size = total_length; 525 526 } 526 527 -
uspace/lib/usbhid/include/usb/hid/hid_report_items.h
rbc216a0 rda68871a 38 38 #include <stdint.h> 39 39 40 /*---------------------------------------------------------------------------*/ 40 41 41 /* 42 42 * Item prefix … … 56 56 #define USB_HID_ITEM_IS_LONG(data) (data == 0xFE) 57 57 58 /*---------------------------------------------------------------------------*/ 58 59 59 /* 60 60 * Extended usage macros … … 70 70 #define USB_HID_EXTENDED_USAGE(usage) (usage & 0xFFFF) 71 71 72 /*---------------------------------------------------------------------------*/ 72 73 73 /* 74 74 * Input/Output/Feature Item flags … … 142 142 #define USB_HID_ITEM_FLAG_BUFFERED(flags) ((flags & 0x100) == 0x100) 143 143 144 /*---------------------------------------------------------------------------*/ 144 145 145 146 146 /* MAIN ITEMS */ … … 185 185 #define USB_HID_REPORT_TAG_END_COLLECTION 0xC 186 186 187 /*---------------------------------------------------------------------------*/ 187 188 188 189 189 /* GLOBAL ITEMS */ … … 272 272 #define USB_HID_REPORT_TAG_POP 0xB 273 273 274 /*---------------------------------------------------------------------------*/ 274 275 275 276 276 /* LOCAL ITEMS */ … … 347 347 #define USB_HID_REPORT_TAG_DELIMITER 0xA 348 348 349 /*---------------------------------------------------------------------------*/ 349 350 350 351 351 #endif -
uspace/lib/usbhid/include/usb/hid/hidpath.h
rbc216a0 rda68871a 41 41 42 42 43 /*---------------------------------------------------------------------------*/ 43 44 44 /* 45 45 * Flags of usage paths comparison modes. … … 73 73 #define USB_HID_PATH_COMPARE_ANYWHERE 8 74 74 75 /*----------------------------------------------------------------------------*/ 75 76 76 /** 77 77 * Item of usage path structure. Last item of linked list describes one item … … 93 93 94 94 95 /*---------------------------------------------------------------------------*/ 95 96 96 /** 97 97 * USB HID usage path structure. … … 112 112 } usb_hid_report_path_t; 113 113 114 /*---------------------------------------------------------------------------*/ 114 115 115 usb_hid_report_path_t *usb_hid_report_path(void); 116 116 -
uspace/lib/usbhid/include/usb/hid/hidtypes.h
rbc216a0 rda68871a 39 39 #include <adt/list.h> 40 40 41 /*---------------------------------------------------------------------------*/ 41 42 42 43 43 /** … … 69 69 (((x) < 0 ) ? ((1 << (size)) + (x)) : (x)) 70 70 71 /*---------------------------------------------------------------------------*/ 71 72 72 73 73 /** … … 86 86 } usb_hid_report_type_t; 87 87 88 /*---------------------------------------------------------------------------*/ 88 89 89 90 90 /** … … 111 111 112 112 } usb_hid_report_t; 113 /*---------------------------------------------------------------------------*/ 113 114 114 115 115 /** … … 135 135 link_t reports_link; 136 136 } usb_hid_report_description_t; 137 /*---------------------------------------------------------------------------*/ 137 138 138 139 139 /** … … 202 202 } usb_hid_report_field_t; 203 203 204 /*---------------------------------------------------------------------------*/ 204 205 205 206 206 /** … … 287 287 int in_delimiter; 288 288 } usb_hid_report_item_t; 289 /*---------------------------------------------------------------------------*/ 289 290 290 /** 291 291 * Enum of the keyboard modifiers … … 314 314 USB_HID_MOD_RGUI 315 315 }; 316 /*---------------------------------------------------------------------------*/ 316 317 317 318 318 -
uspace/lib/usbhid/include/usb/hid/request.h
rbc216a0 rda68871a 42 42 #include <usb/dev/pipes.h> 43 43 44 /*----------------------------------------------------------------------------*/ 44 45 45 46 46 int usbhid_req_set_report(usb_pipe_t *ctrl_pipe, int iface_no, … … 61 61 int usbhid_req_get_idle(usb_pipe_t *ctrl_pipe, int iface_no, uint8_t *duration); 62 62 63 /*----------------------------------------------------------------------------*/ 63 64 64 65 65 #endif /* USB_KBD_HIDREQ_H_ */ -
uspace/lib/usbhid/src/hiddescriptor.c
rbc216a0 rda68871a 41 41 #include <assert.h> 42 42 43 /*---------------------------------------------------------------------------*/ 43 44 44 /* 45 45 * Constants defining current parsing mode for correct parsing of the set of … … 61 61 #define INSIDE_DELIMITER_SET 2 62 62 63 /*---------------------------------------------------------------------------*/ 63 64 64 65 65 /** The new report item flag. Used to determine when the item is completly … … 78 78 #define USB_HID_UNKNOWN_TAG -99 79 79 80 /*---------------------------------------------------------------------------*/ 80 81 81 /** 82 82 * Checks if given collection path is already present in report structure and … … 124 124 } 125 125 126 /*---------------------------------------------------------------------------*/ 126 127 127 /** 128 128 * Initialize the report descriptor parser structure … … 147 147 } 148 148 149 /*---------------------------------------------------------------------------*/ 149 150 150 151 151 /** … … 314 314 return EOK; 315 315 } 316 /*---------------------------------------------------------------------------*/ 316 317 317 /** 318 318 * Finds description of report with given report_id and of given type in … … 348 348 return NULL; 349 349 } 350 /*---------------------------------------------------------------------------*/ 350 351 351 352 352 /** Parse HID report descriptor. … … 536 536 } 537 537 538 /*---------------------------------------------------------------------------*/ 538 539 539 540 540 /** … … 871 871 return EOK; 872 872 } 873 /*---------------------------------------------------------------------------*/ 873 874 874 875 875 /** … … 892 892 return result; 893 893 } 894 /*---------------------------------------------------------------------------*/ 894 895 895 896 896 /** … … 941 941 942 942 } 943 /*---------------------------------------------------------------------------*/ 943 944 944 945 945 /** … … 972 972 } 973 973 } 974 /*---------------------------------------------------------------------------*/ 974 975 975 976 976 … … 1022 1022 return; 1023 1023 } 1024 /*---------------------------------------------------------------------------*/ 1024 1025 1025 1026 1026 /** -
uspace/lib/usbhid/src/hidparser.c
rbc216a0 rda68871a 41 41 #include <assert.h> 42 42 43 /*---------------------------------------------------------------------------*/ 43 44 44 /* 45 45 * Data translation private functions … … 52 52 int32_t value); 53 53 54 /*---------------------------------------------------------------------------*/ 54 55 55 56 56 static int usb_pow(int a, int b) … … 68 68 } 69 69 } 70 /*---------------------------------------------------------------------------*/ 70 71 71 72 72 /** Returns size of report of specified report id and type in items … … 117 117 } 118 118 } 119 /*---------------------------------------------------------------------------*/ 119 120 120 121 121 /** Parse and act upon a HID report. … … 192 192 } 193 193 194 /*---------------------------------------------------------------------------*/ 194 195 195 /** 196 196 * Translate data from the report as specified in report descriptor item … … 274 274 } 275 275 276 /*---------------------------------------------------------------------------*/ 276 277 277 /* OUTPUT API */ 278 278 … … 431 431 } 432 432 433 /*---------------------------------------------------------------------------*/ 433 434 434 /** 435 435 * Translate given data for putting them into the outoput report … … 476 476 } 477 477 478 /*---------------------------------------------------------------------------*/ 478 479 479 /** 480 480 * Clones given state table … … 497 497 } 498 498 499 /*---------------------------------------------------------------------------*/ 499 500 500 /** 501 501 * Function for sequence walking through the report. Returns next field in the … … 552 552 } 553 553 554 /*---------------------------------------------------------------------------*/ 554 555 555 /** 556 556 * Returns next report_id of report of specified type. If zero is given than … … 600 600 } 601 601 602 /*---------------------------------------------------------------------------*/ 602 603 603 /** 604 604 * Reset all local items in given state table -
uspace/lib/usbhid/src/hidpath.c
rbc216a0 rda68871a 41 41 #include <assert.h> 42 42 43 /*---------------------------------------------------------------------------*/ 43 44 44 /** 45 45 * Compares two usages if they are same or not or one of the usages is not … … 63 63 ((page1 == page2) || (page1 == 0) || (page2 == 0)) 64 64 65 /*---------------------------------------------------------------------------*/ 65 66 66 /** 67 67 * Appends one item (couple of usage_path and usage) into the usage path … … 93 93 } 94 94 95 /*---------------------------------------------------------------------------*/ 95 96 96 /** 97 97 * Removes last item from the usage path structure … … 114 114 } 115 115 116 /*---------------------------------------------------------------------------*/ 116 117 117 /** 118 118 * Nulls last item of the usage path structure. … … 133 133 } 134 134 135 /*---------------------------------------------------------------------------*/ 135 136 136 /** 137 137 * Modifies last item of usage path structure by given usage page or usage … … 164 164 } 165 165 166 /*---------------------------------------------------------------------------*/ 166 167 167 /** 168 168 * … … 188 188 } 189 189 190 /*---------------------------------------------------------------------------*/ 190 191 191 /** 192 192 * Compares two usage paths structures … … 354 354 } 355 355 356 /*---------------------------------------------------------------------------*/ 356 357 357 /** 358 358 * Allocates and initializes new usage path structure. … … 376 376 } 377 377 378 /*---------------------------------------------------------------------------*/ 378 379 379 /** 380 380 * Releases given usage path structure. … … 395 395 } 396 396 397 /*---------------------------------------------------------------------------*/ 397 398 398 /** 399 399 * Clone content of given usage path to the new one … … 441 441 } 442 442 443 /*---------------------------------------------------------------------------*/ 443 444 444 /** 445 445 * Sets report id in usage path structure -
uspace/lib/usbhid/src/hidreport.c
rbc216a0 rda68871a 50 50 #include <usb/hid/hidreport.h> 51 51 52 static int usb_hid_get_report_descriptor(usb_device_t *dev, 52 static int usb_hid_get_report_descriptor(usb_device_t *dev, 53 53 uint8_t **report_desc, size_t *size) 54 54 { … … 69 69 * First nested descriptor of the configuration descriptor. 70 70 */ 71 const uint8_t *d = 72 usb_dp_get_nested_descriptor(&parser, &parser_data, 71 const uint8_t *d = 72 usb_dp_get_nested_descriptor(&parser, &parser_data, 73 73 dev->descriptors.configuration); 74 74 … … 78 78 int i = 0; 79 79 while (d != NULL && i < dev->interface_no) { 80 d = usb_dp_get_sibling_descriptor(&parser, &parser_data, 80 d = usb_dp_get_sibling_descriptor(&parser, &parser_data, 81 81 dev->descriptors.configuration, d); 82 82 ++i; … … 99 99 */ 100 100 while (d != NULL && *(d + 1) != USB_DESCTYPE_HID) { 101 d = usb_dp_get_sibling_descriptor(&parser, &parser_data, 101 d = usb_dp_get_sibling_descriptor(&parser, &parser_data, 102 102 iface_desc, d); 103 103 } … … 114 114 } 115 115 116 usb_standard_hid_descriptor_t *hid_desc = 116 usb_standard_hid_descriptor_t *hid_desc = 117 117 (usb_standard_hid_descriptor_t *)d; 118 118 119 uint16_t length = hid_desc->report_desc_info.length;119 uint16_t length = uint16_usb2host(hid_desc->report_desc_info.length); 120 120 size_t actual_size = 0; 121 121 … … 161 161 } 162 162 163 /*----------------------------------------------------------------------------*/ 163 164 164 165 165 int usb_hid_process_report_descriptor(usb_device_t *dev, -
uspace/lib/usbhid/src/hidreq.c
rbc216a0 rda68871a 45 45 #include <usb/hid/request.h> 46 46 47 /*----------------------------------------------------------------------------*/ 47 48 48 /** 49 49 * Send Set Report request to the HID device. … … 97 97 } 98 98 99 /*----------------------------------------------------------------------------*/ 99 100 100 /** 101 101 * Send Set Protocol request to the HID device. … … 145 145 } 146 146 147 /*----------------------------------------------------------------------------*/ 147 148 148 /** 149 149 * Send Set Idle request to the HID device. … … 195 195 } 196 196 197 /*----------------------------------------------------------------------------*/ 197 198 198 /** 199 199 * Send Get Report request to the HID device. … … 251 251 } 252 252 253 /*----------------------------------------------------------------------------*/ 253 254 254 /** 255 255 * Send Get Protocol request to the HID device. … … 310 310 } 311 311 312 /*----------------------------------------------------------------------------*/ 312 313 313 /** 314 314 * Send Get Idle request to the HID device. … … 373 373 } 374 374 375 /*----------------------------------------------------------------------------*/ 375 376 376 377 377 /** -
uspace/lib/usbhost/src/endpoint.c
rbc216a0 rda68871a 72 72 return instance; 73 73 } 74 /*----------------------------------------------------------------------------*/ 74 75 75 /** Properly dispose of endpoint_t structure. 76 76 * @param instance endpoint_t structure. … … 84 84 free(instance); 85 85 } 86 /*----------------------------------------------------------------------------*/ 86 87 87 /** Set device specific data and hooks. 88 88 * @param instance endpoint_t structure. … … 101 101 fibril_mutex_unlock(&instance->guard); 102 102 } 103 /*----------------------------------------------------------------------------*/ 103 104 104 /** Clear device specific data and hooks. 105 105 * @param instance endpoint_t structure. … … 115 115 fibril_mutex_unlock(&instance->guard); 116 116 } 117 /*----------------------------------------------------------------------------*/ 117 118 118 /** Mark the endpoint as active and block access for further fibrils. 119 119 * @param instance endpoint_t structure. … … 128 128 fibril_mutex_unlock(&instance->guard); 129 129 } 130 /*----------------------------------------------------------------------------*/ 130 131 131 /** Mark the endpoint as inactive and allow access for further fibrils. 132 132 * @param instance endpoint_t structure. … … 140 140 fibril_condvar_signal(&instance->avail); 141 141 } 142 /*----------------------------------------------------------------------------*/ 142 143 143 /** Get the value of toggle bit. 144 144 * @param instance endpoint_t structure. … … 156 156 return ret; 157 157 } 158 /*----------------------------------------------------------------------------*/ 158 159 159 /** Set the value of toggle bit. 160 160 * @param instance endpoint_t structure. -
uspace/lib/usbhost/src/usb_device_manager.c
rbc216a0 rda68871a 61 61 return new_address; 62 62 } 63 /*----------------------------------------------------------------------------*/ 63 64 64 /** Initialize device manager structure. 65 65 * … … 82 82 fibril_mutex_initialize(&instance->guard); 83 83 } 84 /*----------------------------------------------------------------------------*/ 84 85 85 /** Request USB address. 86 86 * @param instance usb_device_manager … … 124 124 return EOK; 125 125 } 126 /*----------------------------------------------------------------------------*/ 126 127 127 /** Bind USB address to devman handle. 128 128 * … … 156 156 return EOK; 157 157 } 158 /*----------------------------------------------------------------------------*/ 158 159 159 /** Release used USB address. 160 160 * … … 182 182 return EOK; 183 183 } 184 /*----------------------------------------------------------------------------*/ 184 185 185 /** Find USB address associated with the device. 186 186 * … … 205 205 return ENOENT; 206 206 } 207 /*----------------------------------------------------------------------------*/ 207 208 208 /** Find devman handle and speed assigned to USB address. 209 209 * -
uspace/lib/usbhost/src/usb_endpoint_manager.c
rbc216a0 rda68871a 61 61 && (address == ep->address); 62 62 } 63 /*----------------------------------------------------------------------------*/ 63 64 64 /** Get list that holds endpoints for given address. 65 65 * @param instance usb_endpoint_manager structure, non-null. … … 73 73 return &instance->endpoint_lists[addr % ENDPOINT_LIST_COUNT]; 74 74 } 75 /*----------------------------------------------------------------------------*/ 75 76 76 /** Internal search function, works on locked structure. 77 77 * @param instance usb_endpoint_manager structure, non-null. … … 97 97 return NULL; 98 98 } 99 /*----------------------------------------------------------------------------*/ 99 100 100 /** Calculate bandwidth that needs to be reserved for communication with EP. 101 101 * Calculation follows USB 1.1 specification. … … 145 145 } 146 146 } 147 /*----------------------------------------------------------------------------*/ 147 148 148 /** Initialize to default state. 149 149 * You need to provide valid bw_count function if you plan to use … … 168 168 return EOK; 169 169 } 170 /*----------------------------------------------------------------------------*/ 170 171 171 /** Check setup packet data for signs of toggle reset. 172 172 * … … 227 227 } 228 228 } 229 /*----------------------------------------------------------------------------*/ 229 230 230 /** Register endpoint structure. 231 231 * Checks for duplicates. … … 262 262 return EOK; 263 263 } 264 /*----------------------------------------------------------------------------*/ 264 265 265 /** Unregister endpoint structure. 266 266 * Checks for duplicates. … … 286 286 return EOK; 287 287 } 288 /*----------------------------------------------------------------------------*/ 288 289 289 /** Find endpoint_t representing the given communication route. 290 290 * @param instance usb_endpoint_manager, non-null. … … 301 301 return ep; 302 302 } 303 /*----------------------------------------------------------------------------*/ 303 304 304 /** Create and register new endpoint_t structure. 305 305 * @param instance usb_endpoint_manager structure, non-null. … … 364 364 return EOK; 365 365 } 366 /*----------------------------------------------------------------------------*/ 366 367 367 /** Unregister and destroy endpoint_t structure representing given route. 368 368 * @param instance usb_endpoint_manager structure, non-null. … … 395 395 return EOK; 396 396 } 397 /*----------------------------------------------------------------------------*/ 397 398 398 /** Unregister and destroy all endpoints using given address. 399 399 * @param instance usb_endpoint_manager structure, non-null. -
uspace/lib/usbhost/src/usb_transfer_batch.c
rbc216a0 rda68871a 96 96 return instance; 97 97 } 98 /*----------------------------------------------------------------------------*/ 98 99 99 /** Correctly dispose all used data structures. 100 100 * … … 116 116 free(instance); 117 117 } 118 /*----------------------------------------------------------------------------*/ 118 119 119 /** Prepare data and call the right callback. 120 120 *
Note:
See TracChangeset
for help on using the changeset viewer.
