Changeset 8d6c1f1 in mainline for uspace/lib
- Timestamp:
- 2011-06-07T21:31:35Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 75608143
- Parents:
- ff4f073 (diff), eb522e8 (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:
-
- 90 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/Makefile
rff4f073 r8d6c1f1 76 76 generic/str.c \ 77 77 generic/str_error.c \ 78 generic/l18n/langs.c \ 78 79 generic/fibril.c \ 79 80 generic/fibril_synch.c \ -
uspace/lib/c/generic/adt/hash_table.c
rff4f073 r8d6c1f1 54 54 * 55 55 */ 56 inthash_table_create(hash_table_t *h, hash_count_t m, hash_count_t max_keys,56 bool hash_table_create(hash_table_t *h, hash_count_t m, hash_count_t max_keys, 57 57 hash_table_operations_t *op) 58 58 { -
uspace/lib/c/generic/as.c
rff4f073 r8d6c1f1 35 35 #include <as.h> 36 36 #include <libc.h> 37 #include <errno.h> 37 38 #include <unistd.h> 38 39 #include <align.h> … … 114 115 } 115 116 117 /** Find mapping to physical address. 118 * 119 * @param address Virtual address in question (virtual). 120 * @param[out] frame Frame address (physical). 121 * @return Error code. 122 * @retval EOK No error, @p frame holds the translation. 123 * @retval ENOENT Mapping not found. 124 */ 125 int as_get_physical_mapping(void *address, uintptr_t *frame) 126 { 127 uintptr_t tmp_frame; 128 uintptr_t virt = (uintptr_t) address; 129 130 int rc = (int) __SYSCALL2(SYS_PAGE_FIND_MAPPING, 131 (sysarg_t) virt, (sysarg_t) &tmp_frame); 132 if (rc != EOK) { 133 return rc; 134 } 135 136 if (frame != NULL) { 137 *frame = tmp_frame; 138 } 139 140 return EOK; 141 } 142 116 143 /** @} 117 144 */ -
uspace/lib/c/generic/async.c
rff4f073 r8d6c1f1 1569 1569 } 1570 1570 1571 /** Start IPC_M_DATA_READ using the async framework. 1572 * 1573 * @param phoneid Phone that will be used to contact the receiving side. 1574 * @param dst Address of the beginning of the destination buffer. 1575 * @param size Size of the destination buffer (in bytes). 1576 * @param dataptr Storage of call data (arg 2 holds actual data size). 1577 * @return Hash of the sent message or 0 on error. 1578 */ 1579 aid_t async_data_read(int phoneid, void *dst, size_t size, ipc_call_t *dataptr) 1580 { 1581 return async_send_2(phoneid, IPC_M_DATA_READ, (sysarg_t) dst, 1582 (sysarg_t) size, dataptr); 1583 } 1584 1571 1585 /** Wrapper for IPC_M_DATA_READ calls using the async framework. 1572 1586 * -
uspace/lib/c/generic/devman.c
rff4f073 r8d6c1f1 374 374 } 375 375 376 int devman_get_device_path(devman_handle_t handle, char *path, size_t path_size) 377 { 378 int phone = devman_get_phone(DEVMAN_CLIENT, 0); 379 380 if (phone < 0) 381 return phone; 382 383 async_serialize_start(); 384 385 ipc_call_t answer; 386 aid_t req = async_send_1(phone, DEVMAN_DEVICE_GET_DEVICE_PATH, 387 handle, &answer); 388 389 ipc_call_t data_request_call; 390 aid_t data_request = async_data_read(phone, path, path_size, 391 &data_request_call); 392 if (data_request == 0) { 393 async_wait_for(req, NULL); 394 async_serialize_end(); 395 return ENOMEM; 396 } 397 398 sysarg_t data_request_rc; 399 sysarg_t opening_request_rc; 400 async_wait_for(data_request, &data_request_rc); 401 async_wait_for(req, &opening_request_rc); 402 403 async_serialize_end(); 404 405 if (data_request_rc != EOK) { 406 /* Prefer the return code of the opening request. */ 407 if (opening_request_rc != EOK) { 408 return (int) opening_request_rc; 409 } else { 410 return (int) data_request_rc; 411 } 412 } 413 if (opening_request_rc != EOK) { 414 return (int) opening_request_rc; 415 } 416 417 /* To be on the safe-side. */ 418 path[path_size - 1] = 0; 419 420 size_t transferred_size = IPC_GET_ARG2(data_request_call); 421 422 if (transferred_size >= path_size) { 423 return ELIMIT; 424 } 425 426 /* Terminate the string (trailing 0 not send over IPC). */ 427 path[transferred_size] = 0; 428 429 return EOK; 430 } 431 376 432 377 433 /** @} -
uspace/lib/c/generic/str_error.c
rff4f073 r8d6c1f1 33 33 */ 34 34 35 #include <errno.h> 35 36 #include <str_error.h> 36 37 #include <stdio.h> … … 63 64 static fibril_local char noerr[NOERR_LEN]; 64 65 65 const char *str_error(const int e rrno)66 const char *str_error(const int e) 66 67 { 67 if ((e rrno <= 0) && (errno>= MIN_ERRNO))68 return err_desc[-e rrno];68 if ((e <= 0) && (e >= MIN_ERRNO)) 69 return err_desc[-e]; 69 70 70 snprintf(noerr, NOERR_LEN, "Unkown error code %d", errno); 71 /* Ad hoc descriptions of error codes interesting for USB. */ 72 switch (e) { 73 case EBADCHECKSUM: 74 return "Bad checksum"; 75 case ESTALL: 76 return "Operation stalled"; 77 case EAGAIN: 78 return "Resource temporarily unavailable"; 79 case EEMPTY: 80 return "Resource is empty"; 81 default: 82 break; 83 } 84 85 snprintf(noerr, NOERR_LEN, "Unkown error code %d", e); 71 86 return noerr; 72 87 } -
uspace/lib/c/generic/time.c
rff4f073 r8d6c1f1 207 207 } 208 208 209 void udelay(useconds_t time) 210 { 211 (void) __SYSCALL1(SYS_THREAD_UDELAY, (sysarg_t) time); 212 } 213 214 209 215 /** Wait unconditionally for specified number of seconds 210 216 * -
uspace/lib/c/include/adt/hash_table.h
rff4f073 r8d6c1f1 38 38 #include <adt/list.h> 39 39 #include <unistd.h> 40 #include <bool.h> 40 41 41 42 typedef unsigned long hash_count_t; … … 83 84 list_get_instance((item), type, member) 84 85 85 extern inthash_table_create(hash_table_t *, hash_count_t, hash_count_t,86 extern bool hash_table_create(hash_table_t *, hash_count_t, hash_count_t, 86 87 hash_table_operations_t *); 87 88 extern void hash_table_insert(hash_table_t *, unsigned long [], link_t *); -
uspace/lib/c/include/as.h
rff4f073 r8d6c1f1 60 60 extern void *set_maxheapsize(size_t); 61 61 extern void *as_get_mappable_page(size_t); 62 extern int as_get_physical_mapping(void *, uintptr_t *); 62 63 63 64 #endif -
uspace/lib/c/include/async.h
rff4f073 r8d6c1f1 340 340 (arg4), (answer)) 341 341 342 extern aid_t async_data_read(int, void *, size_t, ipc_call_t *); 342 343 #define async_data_read_start(p, buf, len) \ 343 344 async_data_read_start_generic((p), (buf), (len), IPC_XF_NONE) -
uspace/lib/c/include/devman.h
rff4f073 r8d6c1f1 55 55 extern int devman_device_get_handle_by_class(const char *, const char *, 56 56 devman_handle_t *, unsigned int); 57 extern int devman_get_device_path(devman_handle_t, char *, size_t); 57 58 58 59 extern int devman_add_device_to_class(devman_handle_t, const char *); -
uspace/lib/c/include/errno.h
rff4f073 r8d6c1f1 56 56 #define EMLINK (-266) 57 57 58 /** Bad checksum. */ 59 #define EBADCHECKSUM (-300) 60 61 /** USB: stalled operation. */ 62 #define ESTALL (-301) 63 64 /** Empty resource (no data). */ 65 #define EEMPTY (-302) 66 67 /** Negative acknowledgment. */ 68 #define ENAK (-303) 69 58 70 /** An API function is called while another blocking function is in progress. */ 59 71 #define EINPROGRESS (-10036) -
uspace/lib/c/include/ipc/dev_iface.h
rff4f073 r8d6c1f1 37 37 HW_RES_DEV_IFACE = 0, 38 38 CHAR_DEV_IFACE, 39 40 /** Interface provided by any PCI device. */ 41 PCI_DEV_IFACE, 42 43 /** Interface provided by any USB device. */ 44 USB_DEV_IFACE, 45 /** Interface provided by USB host controller. */ 46 USBHC_DEV_IFACE, 47 /** Interface provided by USB HID devices. */ 48 USBHID_DEV_IFACE, 49 39 50 DEV_IFACE_MAX 40 51 } dev_inferface_idx_t; … … 48 59 DEV_IFACE_ID(DEV_FIRST_CUSTOM_METHOD_IDX) 49 60 61 /* 62 * The first argument is actually method (as the "real" method is used 63 * for indexing into interfaces. 64 */ 65 66 #define DEV_IPC_GET_ARG1(call) IPC_GET_ARG2((call)) 67 #define DEV_IPC_GET_ARG2(call) IPC_GET_ARG3((call)) 68 #define DEV_IPC_GET_ARG3(call) IPC_GET_ARG4((call)) 69 #define DEV_IPC_GET_ARG4(call) IPC_GET_ARG5((call)) 70 50 71 51 72 #endif -
uspace/lib/c/include/ipc/devman.h
rff4f073 r8d6c1f1 149 149 typedef enum { 150 150 DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD, 151 DEVMAN_DEVICE_GET_HANDLE_BY_CLASS 151 DEVMAN_DEVICE_GET_HANDLE_BY_CLASS, 152 DEVMAN_DEVICE_GET_DEVICE_PATH 152 153 } client_to_devman_t; 153 154 -
uspace/lib/c/include/ipc/kbd.h
rff4f073 r8d6c1f1 39 39 40 40 #include <ipc/common.h> 41 #include <ipc/dev_iface.h> 41 42 42 43 typedef enum { 43 KBD_YIELD = IPC_FIRST_USER_METHOD,44 KBD_YIELD = DEV_FIRST_CUSTOM_METHOD, 44 45 KBD_RECLAIM 45 46 } kbd_request_t; -
uspace/lib/c/include/sys/time.h
rff4f073 r8d6c1f1 62 62 extern int gettimeofday(struct timeval *tv, struct timezone *tz); 63 63 64 extern void udelay(useconds_t); 65 64 66 #endif 65 67 -
uspace/lib/drv/Makefile
rff4f073 r8d6c1f1 29 29 30 30 USPACE_PREFIX = ../.. 31 EXTRA_CFLAGS = -Iinclude 31 EXTRA_CFLAGS = -Iinclude -I$(LIBUSB_PREFIX)/include 32 32 LIBRARY = libdrv 33 33 … … 35 35 generic/driver.c \ 36 36 generic/dev_iface.c \ 37 generic/remote_char_dev.c \ 37 38 generic/log.c \ 38 39 generic/remote_hw_res.c \ 39 generic/remote_char_dev.c 40 generic/remote_usb.c \ 41 generic/remote_pci.c \ 42 generic/remote_usbhc.c \ 43 generic/remote_usbhid.c 40 44 41 45 include $(USPACE_PREFIX)/Makefile.common -
uspace/lib/drv/generic/dev_iface.c
rff4f073 r8d6c1f1 41 41 #include "remote_hw_res.h" 42 42 #include "remote_char_dev.h" 43 #include "remote_usb.h" 44 #include "remote_usbhc.h" 45 #include "remote_usbhid.h" 46 #include "remote_pci.h" 47 48 #include <stdio.h> 43 49 44 50 static iface_dipatch_table_t remote_ifaces = { 45 51 .ifaces = { 46 52 &remote_hw_res_iface, 47 &remote_char_dev_iface 53 &remote_char_dev_iface, 54 &remote_pci_iface, 55 &remote_usb_iface, 56 &remote_usbhc_iface, 57 &remote_usbhid_iface 48 58 } 49 59 }; … … 52 62 { 53 63 assert(is_valid_iface_idx(idx)); 64 54 65 return remote_ifaces.ifaces[idx]; 55 66 } -
uspace/lib/drv/generic/driver.c
rff4f073 r8d6c1f1 405 405 /* The interface has not such method */ 406 406 printf("%s: driver_connection_gen error - " 407 "invalid interface method.", driver->name); 407 "invalid interface method " 408 "(index %" PRIun ").\n", 409 driver->name, iface_method_idx); 408 410 async_answer_0(callid, ENOTSUP); 409 411 break;
Note:
See TracChangeset
for help on using the changeset viewer.