Changeset 86ffa27f in mainline for uspace/lib
- Timestamp:
- 2011-08-07T11:21:44Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cc574511
- Parents:
- 15f3c3f (diff), e8067c0 (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:
-
- 39 added
- 1 deleted
- 45 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/block/libblock.c
r15f3c3f r86ffa27f 258 258 static hash_index_t cache_hash(unsigned long *key) 259 259 { 260 return *key& (CACHE_BUCKETS - 1);260 return MERGE_LOUP32(key[0], key[1]) & (CACHE_BUCKETS - 1); 261 261 } 262 262 … … 264 264 { 265 265 block_t *b = hash_table_get_instance(item, block_t, hash_link); 266 return b->lba == *key;266 return b->lba == MERGE_LOUP32(key[0], key[1]); 267 267 } 268 268 … … 305 305 cache->blocks_cluster = cache->lblock_size / devcon->pblock_size; 306 306 307 if (!hash_table_create(&cache->block_hash, CACHE_BUCKETS, 1,307 if (!hash_table_create(&cache->block_hash, CACHE_BUCKETS, 2, 308 308 &cache_ops)) { 309 309 free(cache); … … 344 344 } 345 345 346 unsigned long key = b->lba; 347 hash_table_remove(&cache->block_hash, &key, 1); 346 unsigned long key[2] = { 347 LOWER32(b->lba), 348 UPPER32(b->lba) 349 }; 350 hash_table_remove(&cache->block_hash, key, 2); 348 351 349 352 free(b->data); … … 398 401 block_t *b; 399 402 link_t *l; 400 unsigned long key = ba; 403 unsigned long key[2] = { 404 LOWER32(ba), 405 UPPER32(ba) 406 }; 407 401 408 int rc; 402 409 … … 413 420 414 421 fibril_mutex_lock(&cache->lock); 415 l = hash_table_find(&cache->block_hash, &key);422 l = hash_table_find(&cache->block_hash, key); 416 423 if (l) { 417 424 found: … … 451 458 * Try to recycle a block from the free list. 452 459 */ 453 unsigned long temp_key;454 460 recycle: 455 461 if (list_empty(&cache->free_list)) { … … 499 505 goto retry; 500 506 } 501 l = hash_table_find(&cache->block_hash, &key);507 l = hash_table_find(&cache->block_hash, key); 502 508 if (l) { 503 509 /* … … 522 528 */ 523 529 list_remove(&b->free_link); 524 temp_key = b->lba; 525 hash_table_remove(&cache->block_hash, &temp_key, 1); 530 unsigned long temp_key[2] = { 531 LOWER32(b->lba), 532 UPPER32(b->lba) 533 }; 534 hash_table_remove(&cache->block_hash, temp_key, 2); 526 535 } 527 536 … … 531 540 b->lba = ba; 532 541 b->pba = ba_ltop(devcon, b->lba); 533 hash_table_insert(&cache->block_hash, &key, &b->hash_link);542 hash_table_insert(&cache->block_hash, key, &b->hash_link); 534 543 535 544 /* … … 643 652 * Take the block out of the cache and free it. 644 653 */ 645 unsigned long key = block->lba; 646 hash_table_remove(&cache->block_hash, &key, 1); 654 unsigned long key[2] = { 655 LOWER32(block->lba), 656 UPPER32(block->lba) 657 }; 658 hash_table_remove(&cache->block_hash, key, 2); 647 659 fibril_mutex_unlock(&block->lock); 648 660 free(block->data); -
uspace/lib/c/Makefile
r15f3c3f r86ffa27f 59 59 -include arch/$(UARCH)/Makefile.inc 60 60 61 EXTRA_CFLAGS += -I../../srv/loader/include62 63 61 GENERIC_SOURCES = \ 64 62 generic/libc.c \ … … 70 68 generic/device/hw_res.c \ 71 69 generic/device/char_dev.c \ 70 generic/elf/elf_load.c \ 72 71 generic/event.c \ 73 72 generic/errno.c \ … … 134 133 generic/dlfcn.c \ 135 134 generic/rtld/rtld.c \ 136 generic/rtld/elf_load.c \137 135 generic/rtld/dynamic.c \ 138 136 generic/rtld/module.c \ -
uspace/lib/c/arch/abs32le/include/elf_linux.h
r15f3c3f r86ffa27f 1 1 /* 2 * Copyright (c) 2011 Vojtech Horky2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup drvusbmast29 /** @addtogroup libcabs32le 30 30 * @{ 31 31 */ 32 32 /** @file 33 * SCSI related structures.34 33 */ 35 34 36 #ifndef USB_USBMAST_SCSI_H_37 #define USB_USBMAST_SCSI_H_35 #ifndef LIBC_abs32le_ELF_LINUX_H_ 36 #define LBIC_abs32le_ELF_LINUX_H_ 38 37 38 #include <libarch/istate.h> 39 39 #include <sys/types.h> 40 #include <usb/usb.h>41 40 42 41 typedef struct { 43 uint8_t op_code;44 uint8_t lun_evpd; 45 uint8_t page_code; 46 uint16_t alloc_length; 47 uint8_t ctrl;48 } __attribute__((packed)) scsi_cmd_inquiry_t;42 } elf_regs_t; 43 44 static inline void istate_to_elf_regs(istate_t *istate, elf_regs_t *elf_regs) 45 { 46 (void) istate; (void) elf_regs; 47 } 49 48 50 49 #endif 51 50 52 /** 53 * @} 51 /** @} 54 52 */ -
uspace/lib/c/arch/mips32/Makefile.common
r15f3c3f r86ffa27f 27 27 # 28 28 29 GCC_CFLAGS += -mips3 29 GCC_CFLAGS += -mips3 -mabi=32 30 30 31 31 ENDIANESS = LE -
uspace/lib/c/arch/mips32/include/atomic.h
r15f3c3f r86ffa27f 31 31 */ 32 32 /** @file 33 * @ingroup libcmips32 eb33 * @ingroup libcmips32 34 34 */ 35 35 -
uspace/lib/c/arch/mips32/include/fibril.h
r15f3c3f r86ffa27f 27 27 */ 28 28 29 /** @addtogroup libcmips32 29 /** @addtogroup libcmips32 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @ingroup libcmips32 eb33 * @ingroup libcmips32 34 34 */ 35 35 -
uspace/lib/c/arch/mips32/include/thread.h
r15f3c3f r86ffa27f 27 27 */ 28 28 29 /** @addtogroup libcmips32 29 /** @addtogroup libcmips32 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @ingroup libcmips32 eb33 * @ingroup libcmips32 34 34 */ 35 35 -
uspace/lib/c/arch/mips32/include/tls.h
r15f3c3f r86ffa27f 27 27 */ 28 28 29 /** @addtogroup libcmips32 29 /** @addtogroup libcmips32 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @ingroup libcmips32 eb33 * @ingroup libcmips32 34 34 */ 35 35 -
uspace/lib/c/arch/mips32/include/types.h
r15f3c3f r86ffa27f 31 31 */ 32 32 /** @file 33 * @ingroup libcmips32 eb33 * @ingroup libcmips32 34 34 */ 35 35 -
uspace/lib/c/arch/mips32/src/syscall.c
r15f3c3f r86ffa27f 27 27 */ 28 28 29 29 /** @addtogroup libcmips32 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @ingroup libcmips32 eb33 * @ingroup libcmips32 34 34 */ 35 35 … … 64 64 } 65 65 66 66 /** @} 67 67 */ 68 -
uspace/lib/c/arch/mips32/src/tls.c
r15f3c3f r86ffa27f 27 27 */ 28 28 29 /** @addtogroup libcmips32 29 /** @addtogroup libcmips32 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @ingroup libcmips32 eb33 * @ingroup libcmips32 34 34 */ 35 35 -
uspace/lib/c/arch/mips32eb/Makefile.common
r15f3c3f r86ffa27f 27 27 # 28 28 29 GCC_CFLAGS += -mips3 29 GCC_CFLAGS += -mips3 -mabi=32 30 30 31 31 ENDIANESS = BE -
uspace/lib/c/generic/elf/elf_load.c
r15f3c3f r86ffa27f 29 29 */ 30 30 31 /** @addtogroup generic 31 /** @addtogroup generic 32 32 * @{ 33 33 */ … … 49 49 #include <assert.h> 50 50 #include <as.h> 51 #include <elf/elf.h> 51 52 #include <unistd.h> 52 53 #include <fcntl.h> … … 55 56 #include <entry_point.h> 56 57 57 #include "elf.h" 58 #include "elf_load.h" 58 #include <elf/elf_load.h> 59 59 60 60 #define DPRINTF(...) … … 74 74 static int load_segment(elf_ld_t *elf, elf_segment_header_t *entry); 75 75 76 /** Read until the buffer is read in its entirety. */77 static int my_read(int fd, void *buf, size_t len)78 {79 int cnt = 0;80 do {81 buf += cnt;82 len -= cnt;83 cnt = read(fd, buf, len);84 } while ((cnt > 0) && ((len - cnt) > 0));85 86 return cnt;87 }88 89 76 /** Load ELF binary from a file. 90 77 * … … 160 147 int i, rc; 161 148 162 rc = my_read(elf->fd, header, sizeof(elf_header_t));163 if (rc < 0) {149 rc = read_all(elf->fd, header, sizeof(elf_header_t)); 150 if (rc != sizeof(elf_header_t)) { 164 151 DPRINTF("Read error.\n"); 165 152 return EE_INVALID; … … 222 209 + i * sizeof(elf_segment_header_t), SEEK_SET); 223 210 224 rc = my_read(elf->fd, &segment_hdr,211 rc = read_all(elf->fd, &segment_hdr, 225 212 sizeof(elf_segment_header_t)); 226 if (rc < 0) {213 if (rc != sizeof(elf_segment_header_t)) { 227 214 DPRINTF("Read error.\n"); 228 215 return EE_INVALID; … … 244 231 + i * sizeof(elf_section_header_t), SEEK_SET); 245 232 246 rc = my_read(elf->fd, §ion_hdr,233 rc = read_all(elf->fd, §ion_hdr, 247 234 sizeof(elf_section_header_t)); 248 if (rc < 0) {235 if (rc != sizeof(elf_section_header_t)) { 249 236 DPRINTF("Read error.\n"); 250 237 return EE_INVALID; … … 334 321 uintptr_t seg_addr; 335 322 size_t mem_sz; 336 int rc;323 ssize_t rc; 337 324 338 325 bias = elf->bias; … … 412 399 if (now > left) now = left; 413 400 414 rc = my_read(elf->fd, dp, now);415 416 if (rc < 0) {401 rc = read_all(elf->fd, dp, now); 402 403 if (rc != (ssize_t) now) { 417 404 DPRINTF("Read error.\n"); 418 405 return EE_INVALID; -
uspace/lib/c/generic/io/console.c
r15f3c3f r86ffa27f 76 76 bool console_kcon(void) 77 77 { 78 #if 079 78 return __SYSCALL0(SYS_DEBUG_ACTIVATE_CONSOLE); 80 #endif81 82 return false;83 79 } 84 80 -
uspace/lib/c/generic/io/io.c
r15f3c3f r86ffa27f 594 594 } 595 595 596 buf+= now;596 data += now; 597 597 stream->buf_head += now; 598 598 buf_free -= now; 599 599 bytes_left -= now; 600 600 total_written += now; 601 stream->buf_state = _bs_write; 601 602 602 603 if (buf_free == 0) { … … 606 607 } 607 608 } 608 609 if (total_written > 0)610 stream->buf_state = _bs_write;611 609 612 610 if (need_flush) … … 714 712 off64_t ftell(FILE *stream) 715 713 { 714 _fflushbuf(stream); 716 715 return lseek(stream->fd, 0, SEEK_CUR); 717 716 } -
uspace/lib/c/generic/rtld/module.c
r15f3c3f r86ffa27f 35 35 */ 36 36 37 #include <adt/list.h> 38 #include <elf/elf_load.h> 39 #include <fcntl.h> 40 #include <loader/pcb.h> 37 41 #include <stdio.h> 38 42 #include <stdlib.h> 39 43 #include <unistd.h> 40 #include <fcntl.h>41 #include <adt/list.h>42 #include <loader/pcb.h>43 44 44 45 #include <rtld/rtld.h> … … 47 48 #include <rtld/rtld_arch.h> 48 49 #include <rtld/module.h> 49 #include <elf_load.h>50 50 51 51 /** (Eagerly) process all relocation tables in a module. … … 93 93 module_t *module_find(const char *name) 94 94 { 95 link_t *head = &runtime_env->modules_head;96 97 link_t *cur;98 95 module_t *m; 99 96 const char *p, *soname; … … 110 107 111 108 /* Traverse list of all modules. Not extremely fast, but simple */ 112 DPRINTF("head = %p\n", head); 113 for (cur = head->next; cur != head; cur = cur->next) { 109 list_foreach(runtime_env->modules, cur) { 114 110 DPRINTF("cur = %p\n", cur); 115 111 m = list_get_instance(cur, module_t, modules_link); … … 177 173 178 174 /* Insert into the list of loaded modules */ 179 list_append(&m->modules_link, &runtime_env->modules _head);175 list_append(&m->modules_link, &runtime_env->modules); 180 176 181 177 return m; … … 249 245 void modules_process_relocs(module_t *start) 250 246 { 251 link_t *head = &runtime_env->modules_head; 252 253 link_t *cur; 254 module_t *m; 255 256 for (cur = head->next; cur != head; cur = cur->next) { 247 module_t *m; 248 249 list_foreach(runtime_env->modules, cur) { 257 250 m = list_get_instance(cur, module_t, modules_link); 258 251 … … 268 261 void modules_untag(void) 269 262 { 270 link_t *head = &runtime_env->modules_head; 271 272 link_t *cur; 273 module_t *m; 274 275 for (cur = head->next; cur != head; cur = cur->next) { 263 module_t *m; 264 265 list_foreach(runtime_env->modules, cur) { 276 266 m = list_get_instance(cur, module_t, modules_link); 277 267 m->bfs_tag = false; -
uspace/lib/c/generic/rtld/rtld.c
r15f3c3f r86ffa27f 44 44 { 45 45 runtime_env = &rt_env_static; 46 list_initialize(&runtime_env->modules _head);46 list_initialize(&runtime_env->modules); 47 47 runtime_env->next_bias = 0x2000000; 48 48 runtime_env->program = NULL; -
uspace/lib/c/generic/rtld/symbol.c
r15f3c3f r86ffa27f 38 38 #include <stdlib.h> 39 39 40 #include <elf/elf.h> 40 41 #include <rtld/rtld.h> 41 42 #include <rtld/rtld_debug.h> 42 43 #include <rtld/symbol.h> 43 #include <elf.h>44 44 45 45 /* … … 118 118 module_t *m, *dm; 119 119 elf_symbol_t *sym, *s; 120 li nk_t queue_head;120 list_t queue; 121 121 size_t i; 122 122 … … 132 132 133 133 /* Insert root (the program) into the queue and tag it */ 134 list_initialize(&queue _head);134 list_initialize(&queue); 135 135 start->bfs_tag = true; 136 list_append(&start->queue_link, &queue _head);136 list_append(&start->queue_link, &queue); 137 137 138 138 /* If the symbol is found, it will be stored in 'sym' */ … … 140 140 141 141 /* While queue is not empty */ 142 while (!list_empty(&queue _head)) {142 while (!list_empty(&queue)) { 143 143 /* Pop first element from the queue */ 144 m = list_get_instance( queue_head.next, module_t, queue_link);144 m = list_get_instance(list_first(&queue), module_t, queue_link); 145 145 list_remove(&m->queue_link); 146 146 … … 162 162 if (dm->bfs_tag == false) { 163 163 dm->bfs_tag = true; 164 list_append(&dm->queue_link, &queue _head);164 list_append(&dm->queue_link, &queue); 165 165 } 166 166 } … … 168 168 169 169 /* Empty the queue so that we leave it in a clean state */ 170 while (!list_empty(&queue _head))171 list_remove( queue_head.next);170 while (!list_empty(&queue)) 171 list_remove(list_first(&queue)); 172 172 173 173 if (!sym) { -
uspace/lib/c/generic/str.c
r15f3c3f r86ffa27f 544 544 545 545 str_cpy(dest + dstr_size, size - dstr_size, src); 546 } 547 548 /** Convert space-padded ASCII to string. 549 * 550 * Common legacy text encoding in hardware is 7-bit ASCII fitted into 551 * a fixed-with byte buffer (bit 7 always zero), right-padded with spaces 552 * (ASCII 0x20). Convert space-padded ascii to string representation. 553 * 554 * If the text does not fit into the destination buffer, the function converts 555 * as many characters as possible and returns EOVERFLOW. 556 * 557 * If the text contains non-ASCII bytes (with bit 7 set), the whole string is 558 * converted anyway and invalid characters are replaced with question marks 559 * (U_SPECIAL) and the function returns EIO. 560 * 561 * Regardless of return value upon return @a dest will always be well-formed. 562 * 563 * @param dest Destination buffer 564 * @param size Size of destination buffer 565 * @param src Space-padded ASCII. 566 * @param n Size of the source buffer in bytes. 567 * 568 * @return EOK on success, EOVERFLOW if the text does not fit 569 * destination buffer, EIO if the text contains 570 * non-ASCII bytes. 571 */ 572 int spascii_to_str(char *dest, size_t size, const uint8_t *src, size_t n) 573 { 574 size_t sidx; 575 size_t didx; 576 size_t dlast; 577 uint8_t byte; 578 int rc; 579 int result; 580 581 /* There must be space for a null terminator in the buffer. */ 582 assert(size > 0); 583 result = EOK; 584 585 didx = 0; 586 dlast = 0; 587 for (sidx = 0; sidx < n; ++sidx) { 588 byte = src[sidx]; 589 if (!ascii_check(byte)) { 590 byte = U_SPECIAL; 591 result = EIO; 592 } 593 594 rc = chr_encode(byte, dest, &didx, size - 1); 595 if (rc != EOK) { 596 assert(rc == EOVERFLOW); 597 dest[didx] = '\0'; 598 return rc; 599 } 600 601 /* Remember dest index after last non-empty character */ 602 if (byte != 0x20) 603 dlast = didx; 604 } 605 606 /* Terminate string after last non-empty character */ 607 dest[dlast] = '\0'; 608 return result; 546 609 } 547 610 -
uspace/lib/c/generic/vfs/vfs.c
r15f3c3f r86ffa27f 417 417 } 418 418 419 /** Read entire buffer. 420 * 421 * In face of short reads this function continues reading until either 422 * the entire buffer is read or no more data is available (at end of file). 423 * 424 * @param fildes File descriptor 425 * @param buf Buffer, @a nbytes bytes long 426 * @param nbytes Number of bytes to read 427 * 428 * @return On success, positive number of bytes read. 429 * On failure, negative error code from read(). 430 */ 431 ssize_t read_all(int fildes, void *buf, size_t nbyte) 432 { 433 ssize_t cnt = 0; 434 size_t nread = 0; 435 uint8_t *bp = (uint8_t *) buf; 436 437 do { 438 bp += cnt; 439 nread += cnt; 440 cnt = read(fildes, bp, nbyte - nread); 441 } while (cnt > 0 && (nbyte - nread - cnt) > 0); 442 443 if (cnt < 0) 444 return cnt; 445 446 return nread + cnt; 447 } 448 449 /** Write entire buffer. 450 * 451 * This function fails if it cannot write exactly @a len bytes to the file. 452 * 453 * @param fildes File descriptor 454 * @param buf Data, @a nbytes bytes long 455 * @param nbytes Number of bytes to write 456 * 457 * @return EOK on error, return value from write() if writing 458 * failed. 459 */ 460 ssize_t write_all(int fildes, const void *buf, size_t nbyte) 461 { 462 ssize_t cnt = 0; 463 ssize_t nwritten = 0; 464 const uint8_t *bp = (uint8_t *) buf; 465 466 do { 467 bp += cnt; 468 nwritten += cnt; 469 cnt = write(fildes, bp, nbyte - nwritten); 470 } while (cnt > 0 && ((ssize_t )nbyte - nwritten - cnt) > 0); 471 472 if (cnt < 0) 473 return cnt; 474 475 if ((ssize_t)nbyte - nwritten - cnt > 0) 476 return EIO; 477 478 return nbyte; 479 } 480 419 481 int fsync(int fildes) 420 482 { -
uspace/lib/c/include/bitops.h
r15f3c3f r86ffa27f 38 38 #include <sys/types.h> 39 39 40 /** Mask with bit @a n set. */ 41 #define BIT_V(type, n) \ 42 ((type)1 << ((n) - 1)) 43 44 /** Mask with rightmost @a n bits set. */ 45 #define BIT_RRANGE(type, n) \ 46 (BIT_V(type, (n) + 1) - 1) 47 48 /** Mask with bits @a hi .. @a lo set. @a hi >= @a lo. */ 49 #define BIT_RANGE(type, hi, lo) \ 50 (BIT_RRANGE(type, (hi) - (lo) + 1) << (lo)) 51 52 /** Extract range of bits @a hi .. @a lo from @a value. */ 53 #define BIT_RANGE_EXTRACT(type, hi, lo, value) \ 54 (((value) >> (lo)) & BIT_RRANGE(type, (hi) - (lo) + 1)) 40 55 41 56 /** Return position of first non-zero bit from left (i.e. [log_2(arg)]). -
uspace/lib/c/include/elf/elf_load.h
r15f3c3f r86ffa27f 1 1 /* 2 * Copyright (c) 2006 Sergey Bondari 2 3 * Copyright (c) 2008 Jiri Svoboda 3 4 * All rights reserved. … … 38 39 39 40 #include <arch/elf.h> 41 #include <elf/elf.h> 40 42 #include <sys/types.h> 41 43 #include <loader/pcb.h> 42 44 43 #include "elf.h" 45 /** 46 * ELF error return codes 47 */ 48 #define EE_OK 0 /* No error */ 49 #define EE_INVALID 1 /* Invalid ELF image */ 50 #define EE_MEMORY 2 /* Cannot allocate address space */ 51 #define EE_INCOMPATIBLE 3 /* ELF image is not compatible with current architecture */ 52 #define EE_UNSUPPORTED 4 /* Non-supported ELF (e.g. dynamic ELFs) */ 53 #define EE_LOADER 5 /* The image is actually a program loader. */ 54 #define EE_IRRECOVERABLE 6 44 55 45 56 typedef enum { … … 82 93 } elf_ld_t; 83 94 84 int elf_load_file(const char *file_name, size_t so_bias, eld_flags_t flags, 85 elf_info_t *info);86 void elf_create_pcb(elf_info_t *info, pcb_t *pcb);95 extern const char *elf_error(unsigned int); 96 extern int elf_load_file(const char *, size_t, eld_flags_t, elf_info_t *); 97 extern void elf_create_pcb(elf_info_t *, pcb_t *); 87 98 88 99 #endif -
uspace/lib/c/include/ipc/console.h
r15f3c3f r86ffa27f 48 48 CONSOLE_SET_COLOR, 49 49 CONSOLE_SET_RGB_COLOR, 50 CONSOLE_CURSOR_VISIBILITY, 51 CONSOLE_KCON_ENABLE 50 CONSOLE_CURSOR_VISIBILITY 52 51 } console_request_t; 53 52 -
uspace/lib/c/include/ipc/services.h
r15f3c3f r86ffa27f 38 38 #define LIBC_SERVICES_H_ 39 39 40 #include <fourcc.h> 41 40 42 typedef enum { 41 SERVICE_NONE = 0,42 SERVICE_LOAD ,43 SERVICE_VIDEO ,44 SERVICE_VFS ,45 SERVICE_LOC ,46 SERVICE_DEVMAN ,47 SERVICE_IRC ,48 SERVICE_CLIPBOARD ,49 SERVICE_NETWORKING ,50 SERVICE_LO ,51 SERVICE_NE2000 ,52 SERVICE_ETHERNET ,53 SERVICE_NILDUMMY ,54 SERVICE_IP ,55 SERVICE_ARP ,56 SERVICE_ICMP ,57 SERVICE_UDP ,58 SERVICE_TCP 43 SERVICE_NONE = 0, 44 SERVICE_LOAD = FOURCC('l', 'o', 'a', 'd'), 45 SERVICE_VIDEO = FOURCC('v', 'i', 'd', ' '), 46 SERVICE_VFS = FOURCC('v', 'f', 's', ' '), 47 SERVICE_LOC = FOURCC('l', 'o', 'c', ' '), 48 SERVICE_DEVMAN = FOURCC('d', 'e', 'v', 'n'), 49 SERVICE_IRC = FOURCC('i', 'r', 'c', ' '), 50 SERVICE_CLIPBOARD = FOURCC('c', 'l', 'i', 'p'), 51 SERVICE_NETWORKING = FOURCC('n', 'e', 't', ' '), 52 SERVICE_LO = FOURCC('l', 'o', ' ', ' '), 53 SERVICE_NE2000 = FOURCC('n', 'e', '2', 'k'), 54 SERVICE_ETHERNET = FOURCC('e', 't', 'h', ' '), 55 SERVICE_NILDUMMY = FOURCC('n', 'i', 'l', 'd'), 56 SERVICE_IP = FOURCC('i', 'p', 'v', '4'), 57 SERVICE_ARP = FOURCC('a', 'r', 'p', ' '), 58 SERVICE_ICMP = FOURCC('i', 'c', 'm', 'p'), 59 SERVICE_UDP = FOURCC('u', 'd', 'p', ' '), 60 SERVICE_TCP = FOURCC('t', 'c', 'p', ' ') 59 61 } services_t; 60 62 -
uspace/lib/c/include/rtld/elf_dyn.h
r15f3c3f r86ffa27f 39 39 #include <sys/types.h> 40 40 41 #include <elf .h>41 #include <elf/elf.h> 42 42 #include <libarch/rtld/elf_dyn.h> 43 43 -
uspace/lib/c/include/rtld/rtld.h
r15f3c3f r86ffa27f 49 49 50 50 /** List of all loaded modules including rtld and the program */ 51 li nk_t modules_head;51 list_t modules; 52 52 53 53 /** Temporary hack to place each module at different address. */ -
uspace/lib/c/include/rtld/symbol.h
r15f3c3f r86ffa27f 36 36 #define LIBC_RTLD_SYMBOL_H_ 37 37 38 #include <elf/elf.h> 38 39 #include <rtld/rtld.h> 39 #include <elf.h>40 40 41 41 elf_symbol_t *symbol_bfs_find(const char *name, module_t *start, module_t **mod); -
uspace/lib/c/include/str.h
r15f3c3f r86ffa27f 48 48 #define STR_BOUNDS(length) ((length) << 2) 49 49 50 /** 51 * Maximum size of a buffer needed to a string converted from space-padded 52 * ASCII of size @a spa_size using spascii_to_str(). 53 */ 54 #define SPASCII_STR_BUFSIZE(spa_size) ((spa_size) + 1) 55 50 56 extern wchar_t str_decode(const char *str, size_t *offset, size_t sz); 51 57 extern int chr_encode(const wchar_t ch, char *str, size_t *offset, size_t sz); … … 73 79 extern void str_append(char *dest, size_t size, const char *src); 74 80 81 extern int spascii_to_str(char *dest, size_t size, const uint8_t *src, size_t n); 75 82 extern void wstr_to_str(char *dest, size_t size, const wchar_t *src); 76 83 extern char *wstr_to_astr(const wchar_t *src); -
uspace/lib/c/include/unistd.h
r15f3c3f r86ffa27f 63 63 extern ssize_t read(int, void *, size_t); 64 64 65 extern ssize_t read_all(int, void *, size_t); 66 extern ssize_t write_all(int, const void *, size_t); 67 65 68 extern off64_t lseek(int, off64_t, int); 66 69 extern int ftruncate(int, aoff64_t); -
uspace/lib/clui/tinput.c
r15f3c3f r86ffa27f 1 1 /* 2 * Copyright (c) 201 0Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 #include <sort.h> 29 30 #include <stdio.h> 30 31 #include <stdlib.h> … … 42 43 #include <tinput.h> 43 44 45 #define LIN_TO_COL(ti, lpos) ((lpos) % ((ti)->con_cols)) 46 #define LIN_TO_ROW(ti, lpos) ((lpos) / ((ti)->con_cols)) 47 44 48 /** Seek direction */ 45 49 typedef enum { … … 61 65 static void tinput_post_seek(tinput_t *, bool); 62 66 67 static void tinput_console_set_lpos(tinput_t *ti, unsigned lpos) 68 { 69 console_set_pos(ti->console, LIN_TO_COL(ti, lpos), 70 LIN_TO_ROW(ti, lpos)); 71 } 72 63 73 /** Create a new text input field. */ 64 74 tinput_t *tinput_new(void) … … 66 76 tinput_t *ti; 67 77 68 ti = malloc(sizeof(tinput_t));78 ti = calloc(1, sizeof(tinput_t)); 69 79 if (ti == NULL) 70 80 return NULL; … … 77 87 void tinput_destroy(tinput_t *ti) 78 88 { 89 if (ti->prompt != NULL) 90 free(ti->prompt); 79 91 free(ti); 92 } 93 94 static void tinput_display_prompt(tinput_t *ti) 95 { 96 tinput_console_set_lpos(ti, ti->prompt_coord); 97 98 console_set_style(ti->console, STYLE_EMPHASIS); 99 printf("%s", ti->prompt); 100 console_flush(ti->console); 101 console_set_style(ti->console, STYLE_NORMAL); 80 102 } 81 103 … … 88 110 tinput_sel_get_bounds(ti, &sa, &sb); 89 111 90 console_set_pos(ti->console, (ti->col0 + start) % ti->con_cols, 91 ti->row0 + (ti->col0 + start) / ti->con_cols); 112 tinput_console_set_lpos(ti, ti->text_coord + start); 92 113 console_set_style(ti->console, STYLE_NORMAL); 93 114 … … 134 155 static void tinput_position_caret(tinput_t *ti) 135 156 { 136 console_set_pos(ti->console, (ti->col0 + ti->pos) % ti->con_cols, 137 ti->row0 + (ti->col0 + ti->pos) / ti->con_cols); 138 } 139 140 /** Update row0 in case the screen could have scrolled. */ 157 tinput_console_set_lpos(ti, ti->text_coord + ti->pos); 158 } 159 160 /** Update text_coord, prompt_coord in case the screen could have scrolled. */ 141 161 static void tinput_update_origin(tinput_t *ti) 142 162 { 143 sysarg_t width = ti->col0 + ti->nc; 144 sysarg_t rows = (width / ti->con_cols) + 1; 145 146 /* Update row0 if the screen scrolled. */ 147 if (ti->row0 + rows > ti->con_rows) 148 ti->row0 = ti->con_rows - rows; 163 unsigned end_coord = ti->text_coord + ti->nc; 164 unsigned end_row = LIN_TO_ROW(ti, end_coord); 165 166 unsigned scroll_rows; 167 168 /* Update coords if the screen scrolled. */ 169 if (end_row >= ti->con_rows) { 170 scroll_rows = end_row - ti->con_rows + 1; 171 ti->text_coord -= ti->con_cols * scroll_rows; 172 ti->prompt_coord -= ti->con_cols * scroll_rows; 173 } 174 } 175 176 static void tinput_jump_after(tinput_t *ti) 177 { 178 tinput_console_set_lpos(ti, ti->text_coord + ti->nc); 179 console_flush(ti->console); 180 putchar('\n'); 181 } 182 183 static int tinput_display(tinput_t *ti) 184 { 185 sysarg_t col0, row0; 186 187 if (console_get_pos(ti->console, &col0, &row0) != EOK) 188 return EIO; 189 190 ti->prompt_coord = row0 * ti->con_cols + col0; 191 ti->text_coord = ti->prompt_coord + str_length(ti->prompt); 192 193 tinput_display_prompt(ti); 194 tinput_display_tail(ti, 0, 0); 195 tinput_position_caret(ti); 196 197 return EOK; 149 198 } 150 199 … … 154 203 return; 155 204 156 sysarg_t new_width = ti->col0+ ti->nc + 1;205 unsigned new_width = LIN_TO_COL(ti, ti->text_coord) + ti->nc + 1; 157 206 if (new_width % ti->con_cols == 0) { 158 207 /* Advancing to new line. */ … … 185 234 return; 186 235 187 sysarg_t new_width = ti->col0+ ti->nc + ilen;188 sysarg_tnew_height = (new_width / ti->con_cols) + 1;236 unsigned new_width = LIN_TO_COL(ti, ti->text_coord) + ti->nc + ilen; 237 unsigned new_height = (new_width / ti->con_cols) + 1; 189 238 if (new_height >= ti->con_rows) { 190 239 /* Disallow text longer than 1 page for now. */ … … 511 560 } 512 561 562 /** Compare two entries in array of completions. */ 563 static int compl_cmp(void *va, void *vb, void *arg) 564 { 565 const char *a = *(const char **) va; 566 const char *b = *(const char **) vb; 567 568 return str_cmp(a, b); 569 } 570 571 static size_t common_pref_len(const char *a, const char *b) 572 { 573 size_t i; 574 size_t a_off, b_off; 575 wchar_t ca, cb; 576 577 i = 0; 578 a_off = 0; 579 b_off = 0; 580 581 while (true) { 582 ca = str_decode(a, &a_off, STR_NO_LIMIT); 583 cb = str_decode(b, &b_off, STR_NO_LIMIT); 584 585 if (ca == '\0' || cb == '\0' || ca != cb) 586 break; 587 ++i; 588 } 589 590 return i; 591 } 592 593 static void tinput_text_complete(tinput_t *ti) 594 { 595 void *state; 596 size_t cstart; 597 char *ctmp; 598 char **compl; /* Array of completions */ 599 size_t compl_len; /* Current length of @c compl array */ 600 size_t cnum; 601 size_t i; 602 int rc; 603 604 if (ti->compl_ops == NULL) 605 return; 606 607 /* 608 * Obtain list of all possible completions (growing array). 609 */ 610 611 rc = (*ti->compl_ops->init)(ti->buffer, ti->pos, &cstart, &state); 612 if (rc != EOK) 613 return; 614 615 cnum = 0; 616 617 compl_len = 1; 618 compl = malloc(compl_len * sizeof(char *)); 619 if (compl == NULL) { 620 printf("Error: Out of memory.\n"); 621 return; 622 } 623 624 while (true) { 625 rc = (*ti->compl_ops->get_next)(state, &ctmp); 626 if (rc != EOK) 627 break; 628 629 if (cnum >= compl_len) { 630 /* Extend array */ 631 compl_len = 2 * compl_len; 632 compl = realloc(compl, compl_len * sizeof(char *)); 633 if (compl == NULL) { 634 printf("Error: Out of memory.\n"); 635 break; 636 } 637 } 638 639 compl[cnum] = str_dup(ctmp); 640 if (compl[cnum] == NULL) { 641 printf("Error: Out of memory.\n"); 642 break; 643 } 644 cnum++; 645 } 646 647 (*ti->compl_ops->fini)(state); 648 649 if (cnum > 1) { 650 /* 651 * More than one match. Determine maximum common prefix. 652 */ 653 size_t cplen; 654 655 cplen = str_length(compl[0]); 656 for (i = 1; i < cnum; i++) 657 cplen = min(cplen, common_pref_len(compl[0], compl[i])); 658 659 /* Compute how many bytes we should skip. */ 660 size_t istart = str_lsize(compl[0], ti->pos - cstart); 661 662 if (cplen > istart) { 663 /* Insert common prefix. */ 664 665 /* Copy remainder of common prefix. */ 666 char *cpref = str_ndup(compl[0] + istart, 667 str_lsize(compl[0], cplen - istart)); 668 669 /* Insert it. */ 670 tinput_insert_string(ti, cpref); 671 free(cpref); 672 } else { 673 /* No common prefix. Sort and display all entries. */ 674 675 qsort(compl, cnum, sizeof(char *), compl_cmp, NULL); 676 677 tinput_jump_after(ti); 678 for (i = 0; i < cnum; i++) 679 printf("%s\n", compl[i]); 680 tinput_display(ti); 681 } 682 } else if (cnum == 1) { 683 /* 684 * We have exactly one match. Insert it. 685 */ 686 687 /* Compute how many bytes of completion string we should skip. */ 688 size_t istart = str_lsize(compl[0], ti->pos - cstart); 689 690 /* Insert remainder of completion string at current position. */ 691 tinput_insert_string(ti, compl[0] + istart); 692 } 693 694 for (i = 0; i < cnum; i++) 695 free(compl[i]); 696 free(compl); 697 } 698 513 699 /** Initialize text input field. 514 700 * … … 521 707 ti->hpos = 0; 522 708 ti->history[0] = NULL; 709 } 710 711 /** Set prompt string. 712 * 713 * @param ti Text input 714 * @param prompt Prompt string 715 * 716 * @return EOK on success, ENOMEM if out of memory. 717 */ 718 int tinput_set_prompt(tinput_t *ti, const char *prompt) 719 { 720 if (ti->prompt != NULL) 721 free(ti->prompt); 722 723 ti->prompt = str_dup(prompt); 724 if (ti->prompt == NULL) 725 return ENOMEM; 726 727 return EOK; 728 } 729 730 /** Set completion ops. 731 * 732 * Set pointer to completion ops structure that will be used for text 733 * completion. 734 */ 735 void tinput_set_compl_ops(tinput_t *ti, tinput_compl_ops_t *compl_ops) 736 { 737 ti->compl_ops = compl_ops; 523 738 } 524 739 … … 539 754 return EIO; 540 755 541 if (console_get_pos(ti->console, &ti->col0, &ti->row0) != EOK)542 return EIO;543 544 756 ti->pos = 0; 545 757 ti->sel_start = 0; … … 549 761 ti->exit_clui = false; 550 762 763 if (tinput_display(ti) != EOK) 764 return EIO; 765 551 766 while (!ti->done) { 552 767 console_flush(ti->console); … … 714 929 tinput_history_seek(ti, -1); 715 930 break; 931 case KC_TAB: 932 tinput_text_complete(ti); 933 break; 716 934 default: 717 935 break; -
uspace/lib/clui/tinput.h
r15f3c3f r86ffa27f 1 1 /* 2 * Copyright (c) 201 0Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 37 37 #define LIBCLUI_TINPUT_H_ 38 38 39 #include < stdio.h>39 #include <adt/list.h> 40 40 #include <async.h> 41 41 #include <inttypes.h> 42 42 #include <io/console.h> 43 #include <stdio.h> 43 44 44 45 #define HISTORY_LEN 10 45 46 #define INPUT_MAX_SIZE 1024 47 48 /** Begin enumeration of text completions. 49 * 50 * When user requests text completion, tinput will call this function to start 51 * text completion operation. @a *cstart should be set to the position 52 * (character index) of the first character of the 'word' that is being 53 * completed. The resulting text is obtained by replacing the range of text 54 * starting at @a *cstart and ending at @a pos with the completion text. 55 * 56 * The function can pass information to the get_next and fini functions 57 * via @a state. The init function allocates the state object and stores 58 * a pointer to it to @a *state. The fini function destroys the state object. 59 * 60 * @param text Current contents of edit buffer (null-terminated). 61 * @param pos Current caret position. 62 * @param cstart Output, position in text where completion begins from. 63 * @param state Output, pointer to a client state object. 64 * 65 * @return EOK on success, negative error code on failure. 66 */ 67 typedef int (*tinput_compl_init_fn)(wchar_t *text, size_t pos, size_t *cstart, 68 void **state); 69 70 /** Obtain one text completion alternative. 71 * 72 * Upon success the function sets @a *compl to point to a string, the 73 * completion text. The caller (Tinput) should not modify or free the text. 74 * The pointer is only valid until the next invocation of any completion 75 * function. 76 * 77 * @param state Pointer to state object created by the init funtion. 78 * @param compl Output, the completion text, ownership retained. 79 * 80 * @return EOK on success, negative error code on failure. 81 */ 82 typedef int (*tinput_compl_get_next_fn)(void *state, char **compl); 83 84 85 /** Finish enumeration of text completions. 86 * 87 * The function must deallocate any state information allocated by the init 88 * function or temporary data allocated by the get_next function. 89 * 90 * @param state Pointer to state object created by the init funtion. 91 */ 92 typedef void (*tinput_compl_fini_fn)(void *state); 93 94 /** Text completion ops. */ 95 typedef struct { 96 tinput_compl_init_fn init; 97 tinput_compl_get_next_fn get_next; 98 tinput_compl_fini_fn fini; 99 } tinput_compl_ops_t; 46 100 47 101 /** Text input field (command line). … … 53 107 console_ctrl_t *console; 54 108 109 /** Prompt string */ 110 char *prompt; 111 112 /** Completion ops. */ 113 tinput_compl_ops_t *compl_ops; 114 55 115 /** Buffer holding text currently being edited */ 56 116 wchar_t buffer[INPUT_MAX_SIZE + 1]; 57 117 58 /** Screen coordinates of the top-left corner of the text field */ 59 sysarg_t col0; 60 sysarg_t row0; 118 /** Linear position on screen where the prompt starts */ 119 unsigned prompt_coord; 120 /** Linear position on screen where the text field starts */ 121 unsigned text_coord; 61 122 62 123 /** Screen dimensions */ … … 90 151 91 152 extern tinput_t *tinput_new(void); 153 extern int tinput_set_prompt(tinput_t *, const char *); 154 extern void tinput_set_compl_ops(tinput_t *, tinput_compl_ops_t *); 92 155 extern void tinput_destroy(tinput_t *); 93 156 extern int tinput_read(tinput_t *, char **); -
uspace/lib/drv/generic/driver.c
r15f3c3f r86ffa27f 314 314 " %" PRIun " was found.\n", driver->name, handle); 315 315 async_answer_0(iid, ENOENT); 316 return; 317 } 318 319 if (fun->conn_handler != NULL) { 320 /* Driver has a custom connection handler. */ 321 (*fun->conn_handler)(iid, icall, (void *)fun); 316 322 return; 317 323 } … … 614 620 return ENOMEM; 615 621 616 match_id->id = match_id_str;622 match_id->id = str_dup(match_id_str); 617 623 match_id->score = 90; 618 624 -
uspace/lib/drv/include/ddf/driver.h
r15f3c3f r86ffa27f 118 118 /** Implementation of operations provided by this function */ 119 119 ddf_dev_ops_t *ops; 120 /** Connection handler or @c NULL to use the DDF default handler. */ 121 async_client_conn_t conn_handler; 120 122 121 123 /** Link in the list of functions handled by the driver */ -
uspace/lib/ext2/libext2_directory.c
r15f3c3f r86ffa27f 86 86 * @param fs pointer to filesystem structure 87 87 * @param inode pointer to inode reference structure 88 * @param pos position within inode to start at, 0 is the first entry 88 89 * @return EOK on success or negative error code on failure 89 90 */ 90 91 int ext2_directory_iterator_init(ext2_directory_iterator_t *it, 91 ext2_filesystem_t *fs, ext2_inode_ref_t *inode_ref) 92 { 93 int rc; 94 uint32_t block_id; 95 uint32_t block_size; 96 92 ext2_filesystem_t *fs, ext2_inode_ref_t *inode_ref, aoff64_t pos) 93 { 97 94 it->inode_ref = inode_ref; 98 95 it->fs = fs; 99 100 /* Get the first data block, so we can get the first entry */ 101 rc = ext2_filesystem_get_inode_data_block_index(fs, inode_ref->inode, 0, 102 &block_id); 103 if (rc != EOK) { 104 return rc; 105 } 106 107 rc = block_get(&it->current_block, fs->device, block_id, 0); 108 if (rc != EOK) { 109 return rc; 110 } 111 112 block_size = ext2_superblock_get_block_size(fs->superblock); 113 114 it->current_offset = 0; 115 return ext2_directory_iterator_set(it, block_size); 96 it->current = NULL; 97 it->current_offset = 0; 98 it->current_block = NULL; 99 100 return ext2_directory_iterator_seek(it, pos); 116 101 } 117 102 … … 124 109 int ext2_directory_iterator_next(ext2_directory_iterator_t *it) 125 110 { 111 uint16_t skip; 112 113 assert(it->current != NULL); 114 115 skip = ext2_directory_entry_ll_get_entry_length(it->current); 116 117 return ext2_directory_iterator_seek(it, it->current_offset + skip); 118 } 119 120 /** 121 * Seek the directory iterator to the given byte offset within the inode. 122 * 123 * @param it pointer to iterator to initialize 124 * @return EOK on success or negative error code on failure 125 */ 126 int ext2_directory_iterator_seek(ext2_directory_iterator_t *it, aoff64_t pos) 127 { 126 128 int rc; 127 uint16_t skip;129 128 130 uint64_t size; 129 131 aoff64_t current_block_idx; … … 132 134 uint32_t block_size; 133 135 134 assert(it->current != NULL);135 136 skip = ext2_directory_entry_ll_get_entry_length(it->current);137 136 size = ext2_inode_get_size(it->fs->superblock, it->inode_ref->inode); 138 137 138 /* The iterator is not valid until we seek to the desired position */ 139 it->current = NULL; 140 139 141 /* Are we at the end? */ 140 if (it->current_offset + skip >= size) { 141 rc = block_put(it->current_block); 142 it->current_block = NULL; 143 it->current = NULL; 144 if (rc != EOK) { 145 return rc; 142 if (pos >= size) { 143 if (it->current_block) { 144 rc = block_put(it->current_block); 145 it->current_block = NULL; 146 if (rc != EOK) { 147 return rc; 148 } 146 149 } 147 150 148 it->current_offset += skip;151 it->current_offset = pos; 149 152 return EOK; 150 153 } … … 152 155 block_size = ext2_superblock_get_block_size(it->fs->superblock); 153 156 current_block_idx = it->current_offset / block_size; 154 next_block_idx = (it->current_offset + skip)/ block_size;155 156 /* If we are moving accross block boundary,157 next_block_idx = pos / block_size; 158 159 /* If we don't have a block or are moving accross block boundary, 157 160 * we need to get another block 158 161 */ 159 if (current_block_idx != next_block_idx) { 160 rc = block_put(it->current_block); 161 it->current_block = NULL; 162 it->current = NULL; 163 if (rc != EOK) { 164 return rc; 162 if (it->current_block == NULL || current_block_idx != next_block_idx) { 163 if (it->current_block) { 164 rc = block_put(it->current_block); 165 it->current_block = NULL; 166 if (rc != EOK) { 167 return rc; 168 } 165 169 } 166 170 … … 179 183 } 180 184 181 it->current_offset += skip;185 it->current_offset = pos; 182 186 return ext2_directory_iterator_set(it, block_size); 183 187 } 184 188 189 /** Setup the entry at the current iterator offset. 190 * 191 * This function checks the validity of the directory entry, 192 * before setting the data pointer. 193 * 194 * @return EOK on success or error code on failure 195 */ 185 196 static int ext2_directory_iterator_set(ext2_directory_iterator_t *it, 186 197 uint32_t block_size) -
uspace/lib/ext2/libext2_directory.h
r15f3c3f r86ffa27f 71 71 72 72 extern int ext2_directory_iterator_init(ext2_directory_iterator_t *, 73 ext2_filesystem_t *, ext2_inode_ref_t * );73 ext2_filesystem_t *, ext2_inode_ref_t *, aoff64_t); 74 74 extern int ext2_directory_iterator_next(ext2_directory_iterator_t *); 75 extern int ext2_directory_iterator_seek(ext2_directory_iterator_t *, aoff64_t pos); 75 76 extern int ext2_directory_iterator_fini(ext2_directory_iterator_t *); 76 77 -
uspace/lib/fs/libfs.c
r15f3c3f r86ffa27f 45 45 #include <mem.h> 46 46 #include <sys/stat.h> 47 #include <stdlib.h> 47 48 48 49 #define on_error(rc, action) \ … … 61 62 } while (0) 62 63 64 static fs_reg_t reg; 65 66 static vfs_out_ops_t *vfs_out_ops = NULL; 67 static libfs_ops_t *libfs_ops = NULL; 68 69 static void libfs_mount(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *); 70 static void libfs_unmount(libfs_ops_t *, ipc_callid_t, ipc_call_t *); 71 static void libfs_lookup(libfs_ops_t *, fs_handle_t, ipc_callid_t, 72 ipc_call_t *); 73 static void libfs_stat(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *); 74 static void libfs_open_node(libfs_ops_t *, fs_handle_t, ipc_callid_t, 75 ipc_call_t *); 76 77 static void vfs_out_mounted(ipc_callid_t rid, ipc_call_t *req) 78 { 79 service_id_t service_id = (service_id_t) IPC_GET_ARG1(*req); 80 char *opts; 81 int rc; 82 83 /* Accept the mount options. */ 84 rc = async_data_write_accept((void **) &opts, true, 0, 0, 0, NULL); 85 if (rc != EOK) { 86 async_answer_0(rid, rc); 87 return; 88 } 89 90 fs_index_t index; 91 aoff64_t size; 92 unsigned lnkcnt; 93 rc = vfs_out_ops->mounted(service_id, opts, &index, &size, &lnkcnt); 94 95 if (rc == EOK) 96 async_answer_4(rid, EOK, index, LOWER32(size), UPPER32(size), 97 lnkcnt); 98 else 99 async_answer_0(rid, rc); 100 101 free(opts); 102 } 103 104 static void vfs_out_mount(ipc_callid_t rid, ipc_call_t *req) 105 { 106 libfs_mount(libfs_ops, reg.fs_handle, rid, req); 107 } 108 109 static void vfs_out_unmounted(ipc_callid_t rid, ipc_call_t *req) 110 { 111 service_id_t service_id = (service_id_t) IPC_GET_ARG1(*req); 112 int rc; 113 114 rc = vfs_out_ops->unmounted(service_id); 115 116 async_answer_0(rid, rc); 117 } 118 119 static void vfs_out_unmount(ipc_callid_t rid, ipc_call_t *req) 120 { 121 122 libfs_unmount(libfs_ops, rid, req); 123 } 124 125 static void vfs_out_lookup(ipc_callid_t rid, ipc_call_t *req) 126 { 127 libfs_lookup(libfs_ops, reg.fs_handle, rid, req); 128 } 129 130 static void vfs_out_read(ipc_callid_t rid, ipc_call_t *req) 131 { 132 service_id_t service_id = (service_id_t) IPC_GET_ARG1(*req); 133 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*req); 134 aoff64_t pos = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*req), 135 IPC_GET_ARG4(*req)); 136 size_t rbytes; 137 int rc; 138 139 rc = vfs_out_ops->read(service_id, index, pos, &rbytes); 140 141 if (rc == EOK) 142 async_answer_1(rid, EOK, rbytes); 143 else 144 async_answer_0(rid, rc); 145 } 146 147 static void vfs_out_write(ipc_callid_t rid, ipc_call_t *req) 148 { 149 service_id_t service_id = (service_id_t) IPC_GET_ARG1(*req); 150 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*req); 151 aoff64_t pos = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*req), 152 IPC_GET_ARG4(*req)); 153 size_t wbytes; 154 aoff64_t nsize; 155 int rc; 156 157 rc = vfs_out_ops->write(service_id, index, pos, &wbytes, &nsize); 158 159 if (rc == EOK) 160 async_answer_3(rid, EOK, wbytes, LOWER32(nsize), UPPER32(nsize)); 161 else 162 async_answer_0(rid, rc); 163 } 164 165 static void vfs_out_truncate(ipc_callid_t rid, ipc_call_t *req) 166 { 167 service_id_t service_id = (service_id_t) IPC_GET_ARG1(*req); 168 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*req); 169 aoff64_t size = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*req), 170 IPC_GET_ARG4(*req)); 171 int rc; 172 173 rc = vfs_out_ops->truncate(service_id, index, size); 174 175 async_answer_0(rid, rc); 176 } 177 178 static void vfs_out_close(ipc_callid_t rid, ipc_call_t *req) 179 { 180 service_id_t service_id = (service_id_t) IPC_GET_ARG1(*req); 181 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*req); 182 int rc; 183 184 rc = vfs_out_ops->close(service_id, index); 185 186 async_answer_0(rid, rc); 187 } 188 189 static void vfs_out_destroy(ipc_callid_t rid, ipc_call_t *req) 190 { 191 service_id_t service_id = (service_id_t) IPC_GET_ARG1(*req); 192 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*req); 193 int rc; 194 195 rc = vfs_out_ops->destroy(service_id, index); 196 197 async_answer_0(rid, rc); 198 } 199 200 static void vfs_out_open_node(ipc_callid_t rid, ipc_call_t *req) 201 { 202 libfs_open_node(libfs_ops, reg.fs_handle, rid, req); 203 } 204 205 static void vfs_out_stat(ipc_callid_t rid, ipc_call_t *req) 206 { 207 libfs_stat(libfs_ops, reg.fs_handle, rid, req); 208 } 209 210 static void vfs_out_sync(ipc_callid_t rid, ipc_call_t *req) 211 { 212 service_id_t service_id = (service_id_t) IPC_GET_ARG1(*req); 213 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*req); 214 int rc; 215 216 rc = vfs_out_ops->sync(service_id, index); 217 218 async_answer_0(rid, rc); 219 } 220 221 static void vfs_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 222 { 223 if (iid) { 224 /* 225 * This only happens for connections opened by 226 * IPC_M_CONNECT_ME_TO calls as opposed to callback connections 227 * created by IPC_M_CONNECT_TO_ME. 228 */ 229 async_answer_0(iid, EOK); 230 } 231 232 while (true) { 233 ipc_call_t call; 234 ipc_callid_t callid = async_get_call(&call); 235 236 if (!IPC_GET_IMETHOD(call)) 237 return; 238 239 switch (IPC_GET_IMETHOD(call)) { 240 case VFS_OUT_MOUNTED: 241 vfs_out_mounted(callid, &call); 242 break; 243 case VFS_OUT_MOUNT: 244 vfs_out_mount(callid, &call); 245 break; 246 case VFS_OUT_UNMOUNTED: 247 vfs_out_unmounted(callid, &call); 248 break; 249 case VFS_OUT_UNMOUNT: 250 vfs_out_unmount(callid, &call); 251 break; 252 case VFS_OUT_LOOKUP: 253 vfs_out_lookup(callid, &call); 254 break; 255 case VFS_OUT_READ: 256 vfs_out_read(callid, &call); 257 break; 258 case VFS_OUT_WRITE: 259 vfs_out_write(callid, &call); 260 break; 261 case VFS_OUT_TRUNCATE: 262 vfs_out_truncate(callid, &call); 263 break; 264 case VFS_OUT_CLOSE: 265 vfs_out_close(callid, &call); 266 break; 267 case VFS_OUT_DESTROY: 268 vfs_out_destroy(callid, &call); 269 break; 270 case VFS_OUT_OPEN_NODE: 271 vfs_out_open_node(callid, &call); 272 break; 273 case VFS_OUT_STAT: 274 vfs_out_stat(callid, &call); 275 break; 276 case VFS_OUT_SYNC: 277 vfs_out_sync(callid, &call); 278 break; 279 default: 280 async_answer_0(callid, ENOTSUP); 281 break; 282 } 283 } 284 } 285 63 286 /** Register file system server. 64 287 * … … 68 291 * 69 292 * @param sess Session for communication with VFS. 70 * @param reg File system registration structure. It will be71 * initialized by this function.72 293 * @param info VFS info structure supplied by the file system 73 294 * implementation. 74 * @param conn Connection fibril for handling all calls originating in75 * VFS.295 * @param vops Address of the vfs_out_ops_t structure. 296 * @param lops Address of the libfs_ops_t structure. 76 297 * 77 298 * @return EOK on success or a non-zero error code on errror. 78 299 * 79 300 */ 80 int fs_register(async_sess_t *sess, fs_reg_t *reg, vfs_info_t *info,81 async_client_conn_t conn)301 int fs_register(async_sess_t *sess, vfs_info_t *info, vfs_out_ops_t *vops, 302 libfs_ops_t *lops) 82 303 { 83 304 /* … … 104 325 105 326 /* 327 * Set VFS_OUT and libfs operations. 328 */ 329 vfs_out_ops = vops; 330 libfs_ops = lops; 331 332 /* 106 333 * Ask VFS for callback connection. 107 334 */ 108 async_connect_to_me(exch, 0, 0, 0, conn, NULL);335 async_connect_to_me(exch, 0, 0, 0, vfs_connection, NULL); 109 336 110 337 /* 111 338 * Allocate piece of address space for PLB. 112 339 */ 113 reg ->plb_ro = as_get_mappable_page(PLB_SIZE);114 if (!reg ->plb_ro) {340 reg.plb_ro = as_get_mappable_page(PLB_SIZE); 341 if (!reg.plb_ro) { 115 342 async_exchange_end(exch); 116 343 async_wait_for(req, NULL); … … 121 348 * Request sharing the Path Lookup Buffer with VFS. 122 349 */ 123 rc = async_share_in_start_0_0(exch, reg ->plb_ro, PLB_SIZE);350 rc = async_share_in_start_0_0(exch, reg.plb_ro, PLB_SIZE); 124 351 125 352 async_exchange_end(exch); … … 134 361 */ 135 362 async_wait_for(req, NULL); 136 reg ->fs_handle = (int) IPC_GET_ARG1(answer);363 reg.fs_handle = (int) IPC_GET_ARG1(answer); 137 364 138 365 /* … … 140 367 * the same connection fibril as well. 141 368 */ 142 async_set_client_connection( conn);369 async_set_client_connection(vfs_connection); 143 370 144 371 return IPC_GET_RETVAL(answer); … … 151 378 152 379 void libfs_mount(libfs_ops_t *ops, fs_handle_t fs_handle, ipc_callid_t rid, 153 ipc_call_t *req uest)154 { 155 service_id_t mp_service_id = (service_id_t) IPC_GET_ARG1(*req uest);156 fs_index_t mp_fs_index = (fs_index_t) IPC_GET_ARG2(*req uest);157 fs_handle_t mr_fs_handle = (fs_handle_t) IPC_GET_ARG3(*req uest);158 service_id_t mr_service_id = (service_id_t) IPC_GET_ARG4(*req uest);380 ipc_call_t *req) 381 { 382 service_id_t mp_service_id = (service_id_t) IPC_GET_ARG1(*req); 383 fs_index_t mp_fs_index = (fs_index_t) IPC_GET_ARG2(*req); 384 fs_handle_t mr_fs_handle = (fs_handle_t) IPC_GET_ARG3(*req); 385 service_id_t mr_service_id = (service_id_t) IPC_GET_ARG4(*req); 159 386 160 387 async_sess_t *mountee_sess = async_clone_receive(EXCHANGE_PARALLEL); … … 208 435 * Do not release the FS node so that it stays in memory. 209 436 */ 210 async_answer_ 3(rid, rc, IPC_GET_ARG1(answer), IPC_GET_ARG2(answer),211 IPC_GET_ARG3(answer) );212 } 213 214 void libfs_unmount(libfs_ops_t *ops, ipc_callid_t rid, ipc_call_t *req uest)215 { 216 service_id_t mp_service_id = (service_id_t) IPC_GET_ARG1(*req uest);217 fs_index_t mp_fs_index = (fs_index_t) IPC_GET_ARG2(*req uest);437 async_answer_4(rid, rc, IPC_GET_ARG1(answer), IPC_GET_ARG2(answer), 438 IPC_GET_ARG3(answer), IPC_GET_ARG4(answer)); 439 } 440 441 void libfs_unmount(libfs_ops_t *ops, ipc_callid_t rid, ipc_call_t *req) 442 { 443 service_id_t mp_service_id = (service_id_t) IPC_GET_ARG1(*req); 444 fs_index_t mp_fs_index = (fs_index_t) IPC_GET_ARG2(*req); 218 445 fs_node_t *fn; 219 446 int res; … … 259 486 } 260 487 488 static char plb_get_char(unsigned pos) 489 { 490 return reg.plb_ro[pos % PLB_SIZE]; 491 } 492 261 493 /** Lookup VFS triplet by name in the file system name space. 262 494 * … … 273 505 */ 274 506 void libfs_lookup(libfs_ops_t *ops, fs_handle_t fs_handle, ipc_callid_t rid, 275 ipc_call_t *req uest)276 { 277 unsigned int first = IPC_GET_ARG1(*req uest);278 unsigned int last = IPC_GET_ARG2(*req uest);507 ipc_call_t *req) 508 { 509 unsigned int first = IPC_GET_ARG1(*req); 510 unsigned int last = IPC_GET_ARG2(*req); 279 511 unsigned int next = first; 280 service_id_t service_id = IPC_GET_ARG3(*req uest);281 int lflag = IPC_GET_ARG4(*req uest);282 fs_index_t index = IPC_GET_ARG5(*req uest);512 service_id_t service_id = IPC_GET_ARG3(*req); 513 int lflag = IPC_GET_ARG4(*req); 514 fs_index_t index = IPC_GET_ARG5(*req); 283 515 char component[NAME_MAX + 1]; 284 516 int len; … … 298 530 async_exch_t *exch = async_exchange_begin(cur->mp_data.sess); 299 531 async_forward_slow(rid, exch, VFS_OUT_LOOKUP, next, last, 300 cur->mp_data.service_id, lflag, index, IPC_FF_ROUTE_FROM_ME); 532 cur->mp_data.service_id, lflag, index, 533 IPC_FF_ROUTE_FROM_ME); 301 534 async_exchange_end(exch); 302 535 … … 306 539 307 540 /* Eat slash */ 308 if ( ops->plb_get_char(next) == '/')541 if (plb_get_char(next) == '/') 309 542 next++; 310 543 … … 319 552 /* Collect the component */ 320 553 len = 0; 321 while ((next <= last) && ( ops->plb_get_char(next) != '/')) {554 while ((next <= last) && (plb_get_char(next) != '/')) { 322 555 if (len + 1 == NAME_MAX) { 323 556 /* Component length overflow */ … … 325 558 goto out; 326 559 } 327 component[len++] = ops->plb_get_char(next);560 component[len++] = plb_get_char(next); 328 561 /* Process next character */ 329 562 next++; … … 357 590 358 591 async_exch_t *exch = async_exchange_begin(tmp->mp_data.sess); 359 async_forward_slow(rid, exch, VFS_OUT_LOOKUP, next, last,360 tmp->mp_data.service_id, lflag, index,592 async_forward_slow(rid, exch, VFS_OUT_LOOKUP, next, 593 last, tmp->mp_data.service_id, lflag, index, 361 594 IPC_FF_ROUTE_FROM_ME); 362 595 async_exchange_end(exch); … … 451 684 len = 0; 452 685 while (next <= last) { 453 if ( ops->plb_get_char(next) == '/') {686 if (plb_get_char(next) == '/') { 454 687 /* More than one component */ 455 688 async_answer_0(rid, ENOENT); … … 463 696 } 464 697 465 component[len++] = ops->plb_get_char(next);698 component[len++] = plb_get_char(next); 466 699 /* Process next character */ 467 700 next++; … … 637 870 rc = ops->node_open(fn); 638 871 aoff64_t size = ops->size_get(fn); 639 async_answer_4(rid, rc, LOWER32(size), UPPER32(size), ops->lnkcnt_get(fn), 872 async_answer_4(rid, rc, LOWER32(size), UPPER32(size), 873 ops->lnkcnt_get(fn), 640 874 (ops->is_file(fn) ? L_FILE : 0) | (ops->is_directory(fn) ? L_DIRECTORY : 0)); 641 875 -
uspace/lib/fs/libfs.h
r15f3c3f r86ffa27f 43 43 44 44 typedef struct { 45 int (* mounted)(service_id_t, const char *, fs_index_t *, aoff64_t *, 46 unsigned *); 47 int (* unmounted)(service_id_t); 48 int (* read)(service_id_t, fs_index_t, aoff64_t, size_t *); 49 int (* write)(service_id_t, fs_index_t, aoff64_t, size_t *, 50 aoff64_t *); 51 int (* truncate)(service_id_t, fs_index_t, aoff64_t); 52 int (* close)(service_id_t, fs_index_t); 53 int (* destroy)(service_id_t, fs_index_t); 54 int (* sync)(service_id_t, fs_index_t); 55 } vfs_out_ops_t; 56 57 typedef struct { 45 58 bool mp_active; 46 59 async_sess_t *sess; … … 71 84 int (* has_children)(bool *, fs_node_t *); 72 85 /* 73 * The second set of methods are usually mere getters that do not return74 * an integer error code.86 * The second set of methods are usually mere getters that do not 87 * return an integer error code. 75 88 */ 76 89 fs_index_t (* index_get)(fs_node_t *); 77 90 aoff64_t (* size_get)(fs_node_t *); 78 91 unsigned int (* lnkcnt_get)(fs_node_t *); 79 char (* plb_get_char)(unsigned pos);80 92 bool (* is_directory)(fs_node_t *); 81 93 bool (* is_file)(fs_node_t *); … … 88 100 } fs_reg_t; 89 101 90 extern int fs_register(async_sess_t *, fs_reg_t *, vfs_info_t *,91 async_client_conn_t);102 extern int fs_register(async_sess_t *, vfs_info_t *, vfs_out_ops_t *, 103 libfs_ops_t *); 92 104 93 105 extern void fs_node_initialize(fs_node_t *); 94 95 extern void libfs_mount(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *);96 extern void libfs_unmount(libfs_ops_t *, ipc_callid_t, ipc_call_t *);97 extern void libfs_lookup(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *);98 extern void libfs_stat(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *);99 extern void libfs_open_node(libfs_ops_t *, fs_handle_t, ipc_callid_t,100 ipc_call_t *);101 106 102 107 #endif -
uspace/lib/net/il/ip_remote.c
r15f3c3f r86ffa27f 123 123 * 124 124 */ 125 int ip_device_req_remote(async_sess_t *sess, device_id_t device_id) 126 { 127 return generic_device_req_remote(sess, NET_IP_DEVICE, device_id, 0, 0); 125 int ip_device_req_remote(async_sess_t *sess, device_id_t device_id, 126 services_t service) 127 { 128 return generic_device_req_remote(sess, NET_IP_DEVICE, device_id, 0, 129 service); 128 130 } 129 131 -
uspace/lib/net/include/ip_remote.h
r15f3c3f r86ffa27f 48 48 extern int ip_received_error_msg_remote(async_sess_t *, device_id_t, packet_t *, 49 49 services_t, services_t); 50 extern int ip_device_req_remote(async_sess_t *, device_id_t );50 extern int ip_device_req_remote(async_sess_t *, device_id_t, services_t); 51 51 extern int ip_add_route_req_remote(async_sess_t *, device_id_t, in_addr_t, 52 52 in_addr_t, in_addr_t); -
uspace/lib/net/include/netif_skel.h
r15f3c3f r86ffa27f 205 205 extern packet_t *netif_packet_get_1(size_t); 206 206 207 extern int netif_module_start( sysarg_t);207 extern int netif_module_start(void); 208 208 209 209 #endif -
uspace/lib/net/include/nil_remote.h
r15f3c3f r86ffa27f 58 58 packet_get_id(packet), sender, 0) 59 59 60 #define nil_device_req(sess, device_id, mtu) \ 61 generic_device_req_remote(sess, NET_NIL_DEVICE, device_id, mtu, 0)\ 60 #define nil_device_req(sess, device_id, mtu, netif_service) \ 61 generic_device_req_remote(sess, NET_NIL_DEVICE, device_id, mtu, \ 62 netif_service) 62 63 63 64 extern int nil_device_state_msg(async_sess_t *, device_id_t, sysarg_t); -
uspace/lib/net/netif/netif_skel.c
r15f3c3f r86ffa27f 228 228 } 229 229 230 /** Register the device notification receiver, 231 * 232 * Register a network interface layer module as the device 233 * notification receiver. 234 * 235 * @param[in] sess Session to the network interface layer module. 236 * 237 * @return EOK on success. 238 * @return ELIMIT if there is another module registered. 239 * 240 */ 241 static int register_message(async_sess_t *sess) 242 { 243 fibril_rwlock_write_lock(&netif_globals.lock); 244 if (netif_globals.nil_sess != NULL) { 245 fibril_rwlock_write_unlock(&netif_globals.lock); 246 return ELIMIT; 247 } 248 249 netif_globals.nil_sess = sess; 250 251 fibril_rwlock_write_unlock(&netif_globals.lock); 252 return EOK; 253 } 254 230 255 /** Process the netif module messages. 231 256 * … … 257 282 return EOK; 258 283 284 async_sess_t *callback = 285 async_callback_receive_start(EXCHANGE_SERIALIZE, call); 286 if (callback) 287 return register_message(callback); 288 259 289 switch (IPC_GET_IMETHOD(*call)) { 260 290 case NET_NETIF_PROBE: … … 358 388 * messages in an infinite loop. 359 389 * 360 * @param[in] nil_service Network interface layer service.361 *362 390 * @return EOK on success. 363 391 * @return Other error codes as defined for each specific module … … 365 393 * 366 394 */ 367 int netif_module_start( sysarg_t nil_service)395 int netif_module_start(void) 368 396 { 369 397 async_set_client_connection(netif_client_connection); 370 398 371 399 netif_globals.sess = connect_to_service(SERVICE_NETWORKING); 372 netif_globals.nil_sess = connect_to_service(nil_service);400 netif_globals.nil_sess = NULL; 373 401 netif_device_map_initialize(&netif_globals.device_map); 374 402 -
uspace/lib/scsi/Makefile
r15f3c3f r86ffa27f 1 1 # 2 # Copyright (c) 2005 Martin Decky 3 # Copyright (c) 2007 Jakub Jermar 2 # Copyright (c) 2011 Jiri Svoboda 4 3 # All rights reserved. 5 4 # … … 28 27 # 29 28 30 USPACE_PREFIX = ../../../.. 31 BINARY = fhc 29 USPACE_PREFIX = ../.. 30 EXTRA_CFLAGS = -Iinclude 31 LIBRARY = libscsi 32 32 33 33 SOURCES = \ 34 fhc.c34 src/spc.c 35 35 36 36 include $(USPACE_PREFIX)/Makefile.common -
uspace/lib/softfloat/arch/mips32/include/functions.h
r15f3c3f r86ffa27f 27 27 */ 28 28 29 /** @addtogroup softfloatmips32 mips32 29 /** @addtogroup softfloatmips32 mips32 30 30 * @ingroup sfl 31 31 * @brief softfloat architecture dependent definitions … … 72 72 #endif 73 73 74 75 /** @} 74 /** @} 76 75 */ 77 -
uspace/lib/usb/include/usb/classes/hub.h
r15f3c3f r86ffa27f 119 119 */ 120 120 uint16_t hub_characteristics; 121 #define HUB_CHAR_POWER_PER_PORT_FLAG (1 << 0) 122 #define HUB_CHAR_NO_POWER_SWITCH_FLAG (1 << 1) 121 123 122 124 /** -
uspace/lib/usbhost/include/usb/host/endpoint.h
r15f3c3f r86ffa27f 61 61 } endpoint_t; 62 62 63 int endpoint_init(endpoint_t *instance, usb_address_t address,64 usb_ endpoint_t endpoint, usb_direction_t direction,65 usb_transfer_type_t type, usb_speed_t speed,size_t max_packet_size);63 endpoint_t * endpoint_get(usb_address_t address, usb_endpoint_t endpoint, 64 usb_direction_t direction, usb_transfer_type_t type, usb_speed_t speed, 65 size_t max_packet_size); 66 66 67 67 void endpoint_destroy(endpoint_t *instance); -
uspace/lib/usbhost/include/usb/host/usb_endpoint_manager.h
r15f3c3f r86ffa27f 82 82 size_t data_size) 83 83 { 84 endpoint_t *ep = malloc(sizeof(endpoint_t)); 85 if (ep == NULL) 84 endpoint_t *ep = endpoint_get( 85 address, endpoint, direction, type, speed, max_packet_size); 86 if (!ep) 86 87 return ENOMEM; 87 88 88 int ret = endpoint_init(ep, address, endpoint, direction, type, speed, 89 max_packet_size); 90 if (ret != EOK) { 91 free(ep); 92 return ret; 93 } 94 95 ret = usb_endpoint_manager_register_ep(instance, ep, data_size); 89 const int ret = 90 usb_endpoint_manager_register_ep(instance, ep, data_size); 96 91 if (ret != EOK) { 97 92 endpoint_destroy(ep); 98 return ret;99 93 } 100 return EOK;94 return ret; 101 95 } 102 96 #endif -
uspace/lib/usbhost/src/batch.c
r15f3c3f r86ffa27f 109 109 assert(instance); 110 110 assert(instance->ep); 111 assert(instance->next_step); 111 112 endpoint_release(instance->ep); 112 113 instance->next_step(instance); … … 128 129 memcpy(instance->buffer, instance->data_buffer, instance->buffer_size); 129 130 130 usb_log_debug ("Batch %p " USB_TRANSFER_BATCH_FMT " completed (%zuB): %s.\n",131 usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " completed (%zuB): %s.\n", 131 132 instance, USB_TRANSFER_BATCH_ARGS(*instance), 132 133 instance->transfered_size, str_error(instance->error)); … … 145 146 assert(instance->callback_out); 146 147 147 usb_log_debug ("Batch %p " USB_TRANSFER_BATCH_FMT " completed: %s.\n",148 usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT " completed: %s.\n", 148 149 instance, USB_TRANSFER_BATCH_ARGS(*instance), 149 150 str_error(instance->error)); -
uspace/lib/usbhost/src/endpoint.c
r15f3c3f r86ffa27f 39 39 #include <usb/host/endpoint.h> 40 40 41 int endpoint_init(endpoint_t *instance, usb_address_t address,42 usb_ endpoint_t endpoint, usb_direction_t direction,43 usb_transfer_type_t type, usb_speed_t speed,size_t max_packet_size)41 endpoint_t * endpoint_get(usb_address_t address, usb_endpoint_t endpoint, 42 usb_direction_t direction, usb_transfer_type_t type, usb_speed_t speed, 43 size_t max_packet_size) 44 44 { 45 assert(instance); 46 instance->address = address; 47 instance->endpoint = endpoint; 48 instance->direction = direction; 49 instance->transfer_type = type; 50 instance->speed = speed; 51 instance->max_packet_size = max_packet_size; 52 instance->toggle = 0; 53 instance->active = false; 54 fibril_mutex_initialize(&instance->guard); 55 fibril_condvar_initialize(&instance->avail); 56 endpoint_clear_hc_data(instance); 57 return EOK; 45 endpoint_t *instance = malloc(sizeof(endpoint_t)); 46 if (instance) { 47 instance->address = address; 48 instance->endpoint = endpoint; 49 instance->direction = direction; 50 instance->transfer_type = type; 51 instance->speed = speed; 52 instance->max_packet_size = max_packet_size; 53 instance->toggle = 0; 54 instance->active = false; 55 fibril_mutex_initialize(&instance->guard); 56 fibril_condvar_initialize(&instance->avail); 57 endpoint_clear_hc_data(instance); 58 } 59 return instance; 58 60 } 59 61 /*----------------------------------------------------------------------------*/
Note:
See TracChangeset
for help on using the changeset viewer.