Changeset 7fc092a in mainline for uspace/lib
- Timestamp:
- 2011-01-27T22:09:29Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- db7ed07
- Parents:
- 9ee87f6 (diff), 6265a2b (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:
-
- 7 added
- 3 deleted
- 64 edited
- 9 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/as.c
r9ee87f6 r7fc092a 35 35 #include <as.h> 36 36 #include <libc.h> 37 #include <errno.h> 37 38 #include <unistd.h> 38 39 #include <align.h> … … 128 129 } 129 130 131 /** Find mapping to physical address. 132 * 133 * @param address Virtual address in question (virtual). 134 * @param[out] frame Frame address (physical). 135 * @return Error code. 136 * @retval EOK No error, @p frame holds the translation. 137 * @retval ENOENT Mapping not found. 138 */ 139 int as_get_physical_mapping(void *address, uintptr_t *frame) 140 { 141 uintptr_t tmp_frame; 142 uintptr_t virt = (uintptr_t) address; 143 144 int rc = (int) __SYSCALL2(SYS_PAGE_FIND_MAPPING, 145 (sysarg_t) virt, (sysarg_t) &tmp_frame); 146 if (rc != EOK) { 147 return rc; 148 } 149 150 if (frame != NULL) { 151 *frame = tmp_frame; 152 } 153 154 return EOK; 155 } 156 130 157 /** @} 131 158 */ -
uspace/lib/c/generic/ddi.c
r9ee87f6 r7fc092a 96 96 } 97 97 98 /** Enable an interrupt.99 *100 * @param irq the interrupt.101 *102 * @return Zero on success, negative error code otherwise.103 */104 int interrupt_enable(int irq)105 {106 return __SYSCALL2(SYS_INTERRUPT_ENABLE, (sysarg_t) irq, 1);107 }108 109 /** Disable an interrupt.110 *111 * @param irq the interrupt.112 *113 * @return Zero on success, negative error code otherwise.114 */115 int interrupt_disable(int irq)116 {117 return __SYSCALL2(SYS_INTERRUPT_ENABLE, (sysarg_t) irq, 0);118 }119 120 98 /** Enable PIO for specified I/O range. 121 99 * -
uspace/lib/c/generic/devman.c
r9ee87f6 r7fc092a 79 79 } 80 80 81 if (flags & IPC_FLAG_BLOCKING) 81 if (flags & IPC_FLAG_BLOCKING) { 82 82 devman_phone_client = async_connect_me_to_blocking( 83 83 PHONE_NS, SERVICE_DEVMAN, DEVMAN_CLIENT, 0); 84 else84 } else { 85 85 devman_phone_client = async_connect_me_to(PHONE_NS, 86 86 SERVICE_DEVMAN, DEVMAN_CLIENT, 0); 87 } 87 88 88 89 fibril_mutex_unlock(&devman_phone_mutex); -
uspace/lib/c/generic/net/icmp_common.c
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libc 29 /** @addtogroup libc 30 30 * @{ 31 31 */ … … 38 38 #include <net/modules.h> 39 39 #include <net/icmp_common.h> 40 41 40 #include <ipc/services.h> 42 41 #include <ipc/icmp.h> 43 44 42 #include <sys/time.h> 45 43 #include <async.h> 46 44 47 /** Connect sto the ICMP module.45 /** Connect to the ICMP module. 48 46 * 49 * @param service The ICMP module service. Ignored parameter. 50 * @param[in] timeout The connection timeout in microseconds. No timeout if 51 * set to zero. 52 * @return The ICMP module phone on success. 53 * @return ETIMEOUT if the connection timeouted. 47 * @param[in] timeout Connection timeout in microseconds, zero 48 * for no timeout. 49 * 50 * @return ICMP module phone on success. 51 * @return ETIMEOUT if the connection timeouted. 52 * 54 53 */ 55 int icmp_connect_module(s ervices_t service, suseconds_t timeout)54 int icmp_connect_module(suseconds_t timeout) 56 55 { 57 int phone; 58 59 phone = connect_to_service_timeout(SERVICE_ICMP, timeout); 60 if (phone >= 0) 61 async_req_0_0(phone, NET_ICMP_INIT); 62 63 return phone; 56 return connect_to_service_timeout(SERVICE_ICMP, timeout); 64 57 } 65 58 -
uspace/lib/c/generic/stats.c
r9ee87f6 r7fc092a 36 36 #include <stats.h> 37 37 #include <sysinfo.h> 38 #include <assert.h>39 38 #include <errno.h> 40 39 #include <stdio.h> 41 40 #include <inttypes.h> 41 #include <malloc.h> 42 42 43 43 #define SYSINFO_STATS_MAX_PATH 64 … … 71 71 (stats_cpu_t *) sysinfo_get_data("system.cpus", &size); 72 72 73 assert((size % sizeof(stats_cpu_t)) == 0); 73 if ((size % sizeof(stats_cpu_t)) != 0) { 74 if (stats_cpus != NULL) 75 free(stats_cpus); 76 *count = 0; 77 return NULL; 78 } 74 79 75 80 *count = size / sizeof(stats_cpu_t); … … 91 96 (stats_physmem_t *) sysinfo_get_data("system.physmem", &size); 92 97 93 assert((size == sizeof(stats_physmem_t)) || (size == 0)); 98 if (size != sizeof(stats_physmem_t)) { 99 if (stats_physmem != NULL) 100 free(stats_physmem); 101 return NULL; 102 } 94 103 95 104 return stats_physmem; … … 111 120 (stats_task_t *) sysinfo_get_data("system.tasks", &size); 112 121 113 assert((size % sizeof(stats_task_t)) == 0); 122 if ((size % sizeof(stats_task_t)) != 0) { 123 if (stats_tasks != NULL) 124 free(stats_tasks); 125 *count = 0; 126 return NULL; 127 } 114 128 115 129 *count = size / sizeof(stats_task_t); … … 135 149 (stats_task_t *) sysinfo_get_data(name, &size); 136 150 137 assert((size == sizeof(stats_task_t)) || (size == 0)); 151 if (size != sizeof(stats_task_t)) { 152 if (stats_task != NULL) 153 free(stats_task); 154 return NULL; 155 } 138 156 139 157 return stats_task; … … 155 173 (stats_thread_t *) sysinfo_get_data("system.threads", &size); 156 174 157 assert((size % sizeof(stats_thread_t)) == 0); 175 if ((size % sizeof(stats_thread_t)) != 0) { 176 if (stats_threads != NULL) 177 free(stats_threads); 178 *count = 0; 179 return NULL; 180 } 158 181 159 182 *count = size / sizeof(stats_thread_t); … … 179 202 (stats_thread_t *) sysinfo_get_data(name, &size); 180 203 181 assert((size == sizeof(stats_thread_t)) || (size == 0)); 204 if (size != sizeof(stats_thread_t)) { 205 if (stats_thread != NULL) 206 free(stats_thread); 207 return NULL; 208 } 182 209 183 210 return stats_thread; … … 199 226 (stats_exc_t *) sysinfo_get_data("system.exceptions", &size); 200 227 201 assert((size % sizeof(stats_exc_t)) == 0); 228 if ((size % sizeof(stats_exc_t)) != 0) { 229 if (stats_exceptions != NULL) 230 free(stats_exceptions); 231 *count = 0; 232 return NULL; 233 } 202 234 203 235 *count = size / sizeof(stats_exc_t); … … 217 249 { 218 250 char name[SYSINFO_STATS_MAX_PATH]; 219 snprintf(name, SYSINFO_STATS_MAX_PATH, "system.exceptions s.%u", excn);251 snprintf(name, SYSINFO_STATS_MAX_PATH, "system.exceptions.%u", excn); 220 252 221 253 size_t size = 0; … … 223 255 (stats_exc_t *) sysinfo_get_data(name, &size); 224 256 225 assert((size == sizeof(stats_exc_t)) || (size == 0)); 257 if (size != sizeof(stats_exc_t)) { 258 if (stats_exception != NULL) 259 free(stats_exception); 260 return NULL; 261 } 226 262 227 263 return stats_exception; … … 243 279 (load_t *) sysinfo_get_data("system.load", &size); 244 280 245 assert((size % sizeof(load_t)) == 0); 281 if ((size % sizeof(load_t)) != 0) { 282 if (load != NULL) 283 free(load); 284 *count = 0; 285 return NULL; 286 } 246 287 247 288 *count = size / sizeof(load_t); -
uspace/lib/c/generic/sysinfo.c
r9ee87f6 r7fc092a 96 96 void *sysinfo_get_data(const char *path, size_t *size) 97 97 { 98 /* The binary data size might change during time. 99 Unfortunatelly we cannot allocate the buffer 100 and transfer the data as a single atomic operation. 98 /* 99 * The binary data size might change during time. 100 * Unfortunatelly we cannot allocate the buffer 101 * and transfer the data as a single atomic operation. 102 */ 101 103 102 Let's hope that the number of iterations is bounded 103 in common cases. */ 104 105 void *data = NULL; 106 107 while (true) { 108 /* Get the binary data size */ 109 int ret = sysinfo_get_data_size(path, size); 110 if ((ret != EOK) || (size == 0)) { 111 /* Not a binary data item 112 or an empty item */ 113 break; 114 } 115 116 data = realloc(data, *size); 117 if (data == NULL) 118 break; 119 120 /* Get the data */ 121 ret = __SYSCALL4(SYS_SYSINFO_GET_DATA, (sysarg_t) path, 122 (sysarg_t) str_size(path), (sysarg_t) data, (sysarg_t) *size); 123 if (ret == EOK) 124 return data; 125 126 if (ret != ENOMEM) { 127 /* The failure to get the data was not caused 128 by wrong buffer size */ 129 break; 130 } 104 /* Get the binary data size */ 105 int ret = sysinfo_get_data_size(path, size); 106 if ((ret != EOK) || (size == 0)) { 107 /* 108 * Not a binary data item 109 * or an empty item. 110 */ 111 *size = 0; 112 return NULL; 131 113 } 132 114 133 if (data != NULL) 134 free(data); 115 void *data = malloc(*size); 116 if (data == NULL) { 117 *size = 0; 118 return NULL; 119 } 135 120 121 /* Get the data */ 122 size_t sz; 123 ret = __SYSCALL5(SYS_SYSINFO_GET_DATA, (sysarg_t) path, 124 (sysarg_t) str_size(path), (sysarg_t) data, (sysarg_t) *size, 125 (sysarg_t) &sz); 126 if (ret == EOK) { 127 *size = sz; 128 return data; 129 } 130 131 free(data); 136 132 *size = 0; 137 133 return NULL; -
uspace/lib/c/include/adt/hash_table.h
r9ee87f6 r7fc092a 41 41 typedef unsigned long hash_count_t; 42 42 typedef unsigned long hash_index_t; 43 typedef struct hash_table hash_table_t; 44 typedef struct hash_table_operations hash_table_operations_t; 43 44 /** Set of operations for hash table. */ 45 typedef struct { 46 /** Hash function. 47 * 48 * @param key Array of keys needed to compute hash index. 49 * All keys must be passed. 50 * 51 * @return Index into hash table. 52 * 53 */ 54 hash_index_t (*hash)(unsigned long key[]); 55 56 /** Hash table item comparison function. 57 * 58 * @param key Array of keys that will be compared with item. It is 59 * not necessary to pass all keys. 60 * 61 * @return True if the keys match, false otherwise. 62 * 63 */ 64 int (*compare)(unsigned long key[], hash_count_t keys, link_t *item); 65 66 /** Hash table item removal callback. 67 * 68 * @param item Item that was removed from the hash table. 69 * 70 */ 71 void (*remove_callback)(link_t *item); 72 } hash_table_operations_t; 45 73 46 74 /** Hash table structure. */ 47 struct hash_table{75 typedef struct { 48 76 link_t *entry; 49 77 hash_count_t entries; 50 78 hash_count_t max_keys; 51 79 hash_table_operations_t *op; 52 }; 53 54 /** Set of operations for hash table. */ 55 struct hash_table_operations { 56 /** Hash function. 57 * 58 * @param key Array of keys needed to compute hash index. All keys 59 * must be passed. 60 * 61 * @return Index into hash table. 62 */ 63 hash_index_t (* hash)(unsigned long key[]); 64 65 /** Hash table item comparison function. 66 * 67 * @param key Array of keys that will be compared with item. It is 68 * not necessary to pass all keys. 69 * 70 * @return true if the keys match, false otherwise. 71 */ 72 int (*compare)(unsigned long key[], hash_count_t keys, link_t *item); 73 74 /** Hash table item removal callback. 75 * 76 * @param item Item that was removed from the hash table. 77 */ 78 void (*remove_callback)(link_t *item); 79 }; 80 } hash_table_t; 80 81 81 82 #define hash_table_get_instance(item, type, member) \ -
uspace/lib/c/include/as.h
r9ee87f6 r7fc092a 47 47 extern void *set_maxheapsize(size_t mhs); 48 48 extern void * as_get_mappable_page(size_t sz); 49 extern int as_get_physical_mapping(void *address, uintptr_t *frame); 49 50 50 51 #endif -
uspace/lib/c/include/ddi.h
r9ee87f6 r7fc092a 42 42 extern int iospace_enable(task_id_t, void *, unsigned long); 43 43 extern int pio_enable(void *, size_t, void **); 44 extern int interrupt_enable(int);45 extern int interrupt_disable(int);46 44 47 45 #endif -
uspace/lib/c/include/ipc/icmp.h
r9ee87f6 r7fc092a 33 33 /** @file 34 34 * ICMP module messages. 35 * @see icmp_ interface.h35 * @see icmp_remote.h 36 36 */ 37 37 … … 48 48 /** ICMP module messages. */ 49 49 typedef enum { 50 /** Send secho request. @see icmp_echo() */50 /** Send echo request. @see icmp_echo() */ 51 51 NET_ICMP_ECHO = NET_ICMP_FIRST, 52 52 53 53 /** 54 * Send sdestination unreachable error message.54 * Send destination unreachable error message. 55 55 * @see icmp_destination_unreachable_msg() 56 56 */ … … 58 58 59 59 /** 60 * Send ssource quench error message.60 * Send source quench error message. 61 61 * @see icmp_source_quench_msg() 62 62 */ … … 64 64 65 65 /** 66 * Send stime exceeded error message.66 * Send time exceeded error message. 67 67 * @see icmp_time_exceeded_msg() 68 68 */ … … 70 70 71 71 /** 72 * Send sparameter problem error message.72 * Send parameter problem error message. 73 73 * @see icmp_parameter_problem_msg() 74 74 */ 75 NET_ICMP_PARAMETERPROB, 76 77 /** Initializes new connection. */ 78 NET_ICMP_INIT 79 } icmp_messages; 75 NET_ICMP_PARAMETERPROB 76 } icmp_messages_t; 80 77 81 78 /** @name ICMP specific message parameters definitions */ -
uspace/lib/c/include/ipc/il.h
r9ee87f6 r7fc092a 33 33 /** @file 34 34 * Internetwork layer modules messages. 35 * @see il_ interface.h35 * @see il_remote.h 36 36 * @see ip_interface.h 37 37 */ … … 45 45 /** Internet layer modules messages. */ 46 46 typedef enum { 47 /** New device message.48 * @see ip_device_req()49 */50 NET_IL_DEVICE = NET_IL_FIRST,51 47 /** Device state changed message. 52 48 * @see il_device_state_msg() 53 49 */ 54 NET_IL_DEVICE_STATE, 50 NET_IL_DEVICE_STATE = NET_IL_FIRST, 51 55 52 /** Device MTU changed message. 56 53 * @see il_mtu_changed_msg() 57 54 */ 58 55 NET_IL_MTU_CHANGED, 59 /** Packet size message. 60 * @see il_packet_size_req() 61 */ 62 NET_IL_PACKET_SPACE, 56 63 57 /** Packet received message. 64 58 * @see il_received_msg() 65 59 */ 66 NET_IL_RECEIVED, 67 /** Packet send message. 68 * @see il_send_msg() 69 */ 70 NET_IL_SEND 60 NET_IL_RECEIVED 71 61 } il_messages; 72 62 -
uspace/lib/c/include/ipc/ip.h
r9ee87f6 r7fc092a 47 47 /** IP module messages. */ 48 48 typedef enum { 49 /** New device message. 50 * @see ip_device_req() 51 */ 52 NET_IP_DEVICE = NET_IP_FIRST, 53 49 54 /** Adds the routing entry. 50 55 * @see ip_add_route() 51 56 */ 52 NET_IP_ADD_ROUTE = NET_IP_FIRST,57 NET_IP_ADD_ROUTE, 53 58 54 59 /** Gets the actual route information. … … 65 70 * @see ip_set_default_gateway() 66 71 */ 67 NET_IP_SET_GATEWAY 72 NET_IP_SET_GATEWAY, 73 74 /** Packet size message. 75 * @see ip_packet_size_req() 76 */ 77 NET_IP_PACKET_SPACE, 78 79 /** Packet send message. 80 * @see ip_send_msg() 81 */ 82 NET_IP_SEND 68 83 } ip_messages; 69 84 -
uspace/lib/c/include/ipc/services.h
r9ee87f6 r7fc092a 54 54 SERVICE_NETWORKING, 55 55 SERVICE_LO, 56 SERVICE_ DP8390,56 SERVICE_NE2000, 57 57 SERVICE_ETHERNET, 58 58 SERVICE_NILDUMMY, -
uspace/lib/c/include/net/icmp_common.h
r9ee87f6 r7fc092a 41 41 #include <sys/time.h> 42 42 43 /** Default timeout for incoming connections in microseconds . */44 #define ICMP_CONNECT_TIMEOUT (1 * 1000 * 1000)43 /** Default timeout for incoming connections in microseconds (1 sec). */ 44 #define ICMP_CONNECT_TIMEOUT 1000000 45 45 46 extern int icmp_connect_module(s ervices_t, suseconds_t);46 extern int icmp_connect_module(suseconds_t); 47 47 48 48 #endif -
uspace/lib/drv/generic/remote_usbhc.c
r9ee87f6 r7fc092a 243 243 244 244 // FIXME - answer according to outcome 245 ipc_answer_0(trans->caller, EOK);245 ipc_answer_0(trans->caller, outcome); 246 246 247 247 free(trans); … … 254 254 255 255 // FIXME - answer according to outcome 256 ipc_answer_1(trans->caller, EOK, (sysarg_t)trans);256 ipc_answer_1(trans->caller, outcome, (sysarg_t)trans); 257 257 258 258 trans->size = actual_size; -
uspace/lib/drv/include/usb_iface.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libdrv usb 29 /** @addtogroup libdrv 30 * @addtogroup usb 30 31 * @{ 31 32 */ -
uspace/lib/drv/include/usbhc_iface.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libdrv usb 29 /** @addtogroup libdrv 30 * @addtogroup usb 30 31 * @{ 31 32 */ -
uspace/lib/net/Makefile
r9ee87f6 r7fc092a 43 43 netif/netif_skel.c \ 44 44 nil/nil_remote.c \ 45 il/il_interface.c \ 45 nil/nil_skel.c \ 46 il/il_remote.c \ 47 il/il_skel.c \ 46 48 il/ip_remote.c \ 47 49 il/ip_client.c \ … … 50 52 tl/icmp_client.c \ 51 53 tl/socket_core.c \ 52 tl/tl_interface.c \ 53 tl/tl_common.c 54 tl/tl_common.c \ 55 tl/tl_remote.c \ 56 tl/tl_skel.c 54 57 55 58 include $(USPACE_PREFIX)/Makefile.common -
uspace/lib/net/generic/protocol_map.c
r9ee87f6 r7fc092a 50 50 switch (nil) { 51 51 case SERVICE_ETHERNET: 52 case SERVICE_ DP8390:52 case SERVICE_NE2000: 53 53 switch (il) { 54 54 case SERVICE_IP: … … 76 76 switch (nil) { 77 77 case SERVICE_ETHERNET: 78 case SERVICE_ DP8390:78 case SERVICE_NE2000: 79 79 switch (protocol) { 80 80 case ETH_P_IP: … … 139 139 switch (nil) { 140 140 case SERVICE_ETHERNET: 141 case SERVICE_ DP8390:141 case SERVICE_NE2000: 142 142 return HW_ETHER; 143 143 default: -
uspace/lib/net/il/il_remote.c
r9ee87f6 r7fc092a 33 33 /** @file 34 34 * Internetwork layer module interface for the underlying network interface 35 * layer. This interface is always called by the remote modules.35 * layer. 36 36 */ 37 37 38 #include <il_ interface.h>38 #include <il_remote.h> 39 39 #include <generic.h> 40 40 #include <packet_client.h> -
uspace/lib/net/il/ip_remote.c
r9ee87f6 r7fc092a 36 36 * 37 37 * @see ip_interface.h 38 * @see il_ interface.h38 * @see il_remote.h 39 39 * 40 40 */ … … 121 121 services_t service) 122 122 { 123 return generic_device_req_remote(ip_phone, NET_I L_DEVICE, device_id, 0,123 return generic_device_req_remote(ip_phone, NET_IP_DEVICE, device_id, 0, 124 124 service); 125 125 } … … 188 188 packet_dimension_t *packet_dimension) 189 189 { 190 return generic_packet_size_req_remote(ip_phone, NET_I L_PACKET_SPACE,190 return generic_packet_size_req_remote(ip_phone, NET_IP_PACKET_SPACE, 191 191 device_id, packet_dimension); 192 192 } … … 228 228 services_t sender, services_t error) 229 229 { 230 return generic_send_msg_remote(ip_phone, NET_I L_SEND, device_id,230 return generic_send_msg_remote(ip_phone, NET_IP_SEND, device_id, 231 231 packet_get_id(packet), sender, error); 232 232 } -
uspace/lib/net/include/icmp_header.h
r9ee87f6 r7fc092a 45 45 46 46 /** ICMP header size in bytes. */ 47 #define ICMP_HEADER_SIZE sizeof(icmp_header_t) 48 49 /** Type definition of the echo specific data. 50 * @see icmp_echo 51 */ 52 typedef struct icmp_echo icmp_echo_t; 47 #define ICMP_HEADER_SIZE sizeof(icmp_header_t) 53 48 54 49 /** Echo specific data. */ 55 struct icmp_echo {50 typedef struct icmp_echo { 56 51 /** Message idintifier. */ 57 52 icmp_param_t identifier; 58 53 /** Message sequence number. */ 59 54 icmp_param_t sequence_number; 60 } __attribute__ ((packed)); 61 62 /** Type definition of the internet control message header. 63 * @see icmp_header 64 */ 65 typedef struct icmp_header icmp_header_t; 55 } __attribute__((packed)) icmp_echo_t; 66 56 67 57 /** Internet control message header. */ 68 struct icmp_header {58 typedef struct icmp_header { 69 59 /** The type of the message. */ 70 60 uint8_t type; … … 83 73 */ 84 74 uint16_t checksum; 85 75 86 76 /** Message specific data. */ 87 77 union { 88 78 /** Echo specific data. */ 89 icmp_echo_t 79 icmp_echo_t echo; 90 80 /** Proposed gateway value. */ 91 81 in_addr_t gateway; … … 107 97 } param; 108 98 } un; 109 } __attribute__ ((packed));99 } __attribute__((packed)) icmp_header_t; 110 100 111 101 #endif -
uspace/lib/net/include/icmp_remote.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libnet 29 /** @addtogroup libnet 30 30 * @{ 31 31 */ 32 32 33 #ifndef LIBNET_ICMP_ INTERFACE_H_34 #define LIBNET_ICMP_ INTERFACE_H_33 #ifndef LIBNET_ICMP_REMOTE_H_ 34 #define LIBNET_ICMP_REMOTE_H_ 35 35 36 36 #include <net/socket_codes.h> … … 54 54 extern int icmp_source_quench_msg(int, packet_t *); 55 55 extern int icmp_time_exceeded_msg(int, icmp_code_t, packet_t *); 56 extern int icmp_parameter_problem_msg(int, icmp_code_t, icmp_param_t, packet_t *); 56 extern int icmp_parameter_problem_msg(int, icmp_code_t, icmp_param_t, 57 packet_t *); 57 58 58 59 /*@}*/ -
uspace/lib/net/include/il_remote.h
r9ee87f6 r7fc092a 36 36 */ 37 37 38 #ifndef LIBNET_IL_ INTERFACE_H_39 #define LIBNET_IL_ INTERFACE_H_38 #ifndef LIBNET_IL_REMOTE_H_ 39 #define LIBNET_IL_REMOTE_H_ 40 40 41 41 #include <ipc/services.h> -
uspace/lib/net/include/il_skel.h
r9ee87f6 r7fc092a 1 1 /* 2 * Copyright (c) 20 08 Lukas Mejdrech2 * Copyright (c) 2010 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup tcp29 /** @addtogroup libnet 30 30 * @{ 31 31 */ 32 32 33 #ifndef LIBNET_IL_SKEL_H_ 34 #define LIBNET_IL_SKEL_H_ 35 33 36 /** @file 34 * TCP standalone module implementation. 35 * Contains skeleton module functions mapping. 36 * The functions are used by the module skeleton as module specific entry 37 * points. 38 * @see module.c 37 * Internetwork layer module skeleton. 38 * The skeleton has to be part of each internetwork layer module. 39 39 */ 40 40 41 #include "tcp.h"42 #include "tcp_module.h"43 44 41 #include <async.h> 45 #include <stdio.h> 46 #include <errno.h> 42 #include <fibril_synch.h> 47 43 #include <ipc/ipc.h> 48 44 #include <ipc/services.h> 49 45 50 #include < net/ip_protocols.h>51 #include <net/ modules.h>46 #include <adt/measured_strings.h> 47 #include <net/device.h> 52 48 #include <net/packet.h> 53 #include <net_interface.h>54 49 55 #include <ip_interface.h> 56 #include <tl_local.h> 50 /** Module initialization. 51 * 52 * This has to be implemented in user code. 53 * 54 * @param[in] net_phone Networking module phone. 55 * 56 * @return EOK on success. 57 * @return Other error codes as defined for each specific module 58 * initialize function. 59 * 60 */ 61 extern int il_initialize(int net_phone); 57 62 58 /** TCP module global data. */ 59 extern tcp_globals_t tcp_globals; 63 /** Process the internetwork layer module message. 64 * 65 * This has to be implemented in user code. 66 * 67 * @param[in] callid Message identifier. 68 * @param[in] call Message parameters. 69 * @param[out] answer Answer. 70 * @param[out] count Number of arguments of the answer. 71 * 72 * @return EOK on success. 73 * @return Other error codes as defined for each specific module. 74 * 75 */ 76 extern int il_module_message(ipc_callid_t callid, ipc_call_t *call, 77 ipc_call_t *answer, size_t *answer_count); 60 78 61 int tl_module_start_standalone(async_client_conn_t client_connection) 62 { 63 sysarg_t phonehash; 64 int rc; 79 extern int il_module_start(int); 65 80 66 async_set_client_connection(client_connection); 67 tcp_globals.net_phone = net_connect_module(); 68 69 rc = pm_init(); 70 if (rc != EOK) 71 return rc; 72 73 rc = tcp_initialize(client_connection); 74 if (rc != EOK) 75 goto out; 76 77 rc = ipc_connect_to_me(PHONE_NS, SERVICE_TCP, 0, 0, &phonehash); 78 if (rc != EOK) 79 goto out; 80 81 async_manager(); 82 83 out: 84 pm_destroy(); 85 return rc; 86 } 87 88 int tl_module_message_standalone(ipc_callid_t callid, ipc_call_t *call, 89 ipc_call_t *answer, size_t *count) 90 { 91 return tcp_message_standalone(callid, call, answer, count); 92 } 81 #endif 93 82 94 83 /** @} -
uspace/lib/net/include/nil_remote.h
r9ee87f6 r7fc092a 37 37 #include <net/device.h> 38 38 #include <net/packet.h> 39 #include <generic.h> 39 40 40 extern int nil_device_state_msg_remote(int, device_id_t, int); 41 extern int nil_received_msg_remote(int, device_id_t, packet_t *, services_t); 41 #define nil_bind_service(service, device_id, me, receiver) \ 42 bind_service(service, device_id, me, 0, receiver) 43 44 #define nil_packet_size_req(nil_phone, device_id, packet_dimension) \ 45 generic_packet_size_req_remote(nil_phone, NET_NIL_PACKET_SPACE, \ 46 device_id, packet_dimension) 47 48 #define nil_get_addr_req(nil_phone, device_id, address, data) \ 49 generic_get_addr_req(nil_phone, NET_NIL_ADDR, device_id, address, data) 50 51 #define nil_get_broadcast_addr_req(nil_phone, device_id, address, data) \ 52 generic_get_addr_req(nil_phone, NET_NIL_BROADCAST_ADDR, device_id, \ 53 address, data) 54 55 #define nil_send_msg(nil_phone, device_id, packet, sender) \ 56 generic_send_msg_remote(nil_phone, NET_NIL_SEND, device_id, \ 57 packet_get_id(packet), sender, 0) 58 59 #define nil_device_req(nil_phone, device_id, mtu, netif_service) \ 60 generic_device_req_remote(nil_phone, NET_NIL_DEVICE, device_id, mtu, \ 61 netif_service) 62 63 extern int nil_device_state_msg(int, device_id_t, int); 64 extern int nil_received_msg(int, device_id_t, packet_t *, services_t); 42 65 43 66 #endif -
uspace/lib/net/include/tl_remote.h
r9ee87f6 r7fc092a 35 35 */ 36 36 37 #ifndef LIBNET_TL_ INTERFACE_H_38 #define LIBNET_TL_ INTERFACE_H_37 #ifndef LIBNET_TL_REMOTE_H_ 38 #define LIBNET_TL_REMOTE_H_ 39 39 40 40 #include <async.h> … … 52 52 /*@{*/ 53 53 54 extern int tl_received_msg(int, device_id_t, packet_t *, services_t, services_t); 54 extern int tl_received_msg(int, device_id_t, packet_t *, services_t, 55 services_t); 55 56 56 57 /*@}*/ -
uspace/lib/net/include/tl_skel.h
r9ee87f6 r7fc092a 31 31 */ 32 32 33 #ifndef LIBNET_TL_ LOCAL_H_34 #define LIBNET_TL_ LOCAL_H_33 #ifndef LIBNET_TL_SKEL_H_ 34 #define LIBNET_TL_SKEL_H_ 35 35 36 /** @file 37 * Transport layer module skeleton. 38 * The skeleton has to be part of each transport layer module. 39 */ 40 41 #include <async.h> 42 #include <fibril_synch.h> 36 43 #include <ipc/ipc.h> 37 #include < async.h>44 #include <ipc/services.h> 38 45 39 /** Starts the TL module. 46 #include <adt/measured_strings.h> 47 #include <net/device.h> 48 #include <net/packet.h> 49 50 /** Module initialization. 40 51 * 41 * Initializes the client connection serving function, initializes the module, 42 * registers the module service and starts the async manager, processing IPC 43 * messages in an infinite loop. 52 * This has to be implemented in user code. 44 53 * 45 * @param[in] client_connection The client connection processing function. The 46 * module skeleton propagates its own one. 47 * @return EOK on successful module termination. 48 * @return Other error codes as defined for the module initialize 49 * function. 50 * @return Other error codes as defined for the REGISTER_ME() macro 51 * function. 54 * @param[in] net_phone Networking module phone. 55 * 56 * @return EOK on success. 57 * @return Other error codes as defined for each specific module 58 * initialize function. 59 * 52 60 */ 53 extern int tl_module_message_standalone(ipc_callid_t, ipc_call_t *, 61 extern int tl_initialize(int net_phone); 62 63 /** Per-connection module initialization. 64 * 65 * This has to be implemented in user code. 66 * 67 */ 68 extern void tl_connection(void); 69 70 /** Process the transport layer module message. 71 * 72 * This has to be implemented in user code. 73 * 74 * @param[in] callid Message identifier. 75 * @param[in] call Message parameters. 76 * @param[out] answer Answer. 77 * @param[out] count Number of arguments of the answer. 78 * 79 * @return EOK on success. 80 * @return Other error codes as defined for each specific module. 81 * 82 */ 83 extern int tl_message(ipc_callid_t, ipc_call_t *, 54 84 ipc_call_t *, size_t *); 55 85 56 /** Processes the TL module message. 57 * 58 * @param[in] callid The message identifier. 59 * @param[in] call The message parameters. 60 * @param[out] answer The message answer parameters. 61 * @param[out] answer_count The last parameter for the actual answer in the 62 * answer parameter. 63 * @return EOK on success. 64 * @return Other error codes as defined for the module's message 65 * standalone function. 66 */ 67 extern int tl_module_start_standalone(async_client_conn_t); 86 extern int tl_module_start(int); 68 87 69 88 #endif -
uspace/lib/net/netif/netif_skel.c
r9ee87f6 r7fc092a 33 33 /** @file 34 34 * Network interface module skeleton implementation. 35 * @see netif .h35 * @see netif_skel.h 36 36 */ 37 37 … … 52 52 #include <adt/measured_strings.h> 53 53 #include <net/device.h> 54 #include <nil_interface.h>55 54 #include <netif_skel.h> 55 #include <nil_remote.h> 56 56 57 57 DEVICE_MAP_IMPLEMENT(netif_device_map, netif_device_t); … … 130 130 if (result > NETIF_NULL) { 131 131 int phone = device->nil_phone; 132 nil_device_state_msg(phone, device_id, result); 132 133 fibril_rwlock_write_unlock(&netif_globals.lock); 133 nil_device_state_msg(phone, device_id, result);134 134 return EOK; 135 135 } … … 166 166 if (result > NETIF_NULL) { 167 167 int phone = device->nil_phone; 168 nil_device_state_msg(phone, device_id, result); 168 169 fibril_rwlock_write_unlock(&netif_globals.lock); 169 nil_device_state_msg(phone, device_id, result);170 170 return EOK; 171 171 } -
uspace/lib/net/nil/nil_remote.c
r9ee87f6 r7fc092a 33 33 /** @file 34 34 * Network interface layer interface implementation for remote modules. 35 * @see nil_ interface.h35 * @see nil_remote.h 36 36 */ 37 37 38 38 #include <nil_remote.h> 39 #include <nil_interface.h>40 39 #include <generic.h> 41 40 #include <net/device.h> 42 41 #include <net/packet.h> 43 42 #include <packet_client.h> 44 45 43 #include <ipc/nil.h> 46 44 47 45 /** Notify the network interface layer about the device state change. 48 46 * 49 * @param[in] nil_phone The network interface layer phone. 50 * @param[in] device_id The device identifier. 51 * @param[in] state The new device state. 52 * @return EOK on success. 53 * @return Other error codes as defined for each specific module 54 * device state function. 47 * @param[in] nil_phone Network interface layer phone. 48 * @param[in] device_id Device identifier. 49 * @param[in] state New device state. 50 * 51 * @return EOK on success. 52 * @return Other error codes as defined for each specific module 53 * device state function. 54 * 55 55 */ 56 int nil_device_state_msg _remote(int nil_phone, device_id_t device_id, int state)56 int nil_device_state_msg(int nil_phone, device_id_t device_id, int state) 57 57 { 58 58 return generic_device_state_msg_remote(nil_phone, NET_NIL_DEVICE_STATE, … … 65 65 * upper layers. 66 66 * 67 * @param[in] nil_phone The network interface layer phone. 68 * @param[in] device_id The source device identifier. 69 * @param[in] packet The received packet or the received packet queue. 70 * @param target The target service. Ignored parameter. 71 * @return EOK on success. 72 * @return Other error codes as defined for each specific module 73 * received function. 67 * @param[in] nil_phone Network interface layer phone. 68 * @param[in] device_id Source device identifier. 69 * @param[in] packet Received packet or the received packet queue. 70 * @param[in] target Target service. Ignored parameter. 71 * 72 * @return EOK on success. 73 * @return Other error codes as defined for each specific module 74 * received function. 75 * 74 76 */ 75 int nil_received_msg _remote(int nil_phone, device_id_t device_id,77 int nil_received_msg(int nil_phone, device_id_t device_id, 76 78 packet_t *packet, services_t target) 77 79 { -
uspace/lib/net/tl/icmp_remote.c
r9ee87f6 r7fc092a 33 33 /** @file 34 34 * ICMP interface implementation for remote modules. 35 * @see icmp_ interface.h35 * @see icmp_remote.h 36 36 */ 37 37 38 #include <icmp_ interface.h>38 #include <icmp_remote.h> 39 39 #include <net/modules.h> 40 40 #include <packet_client.h> -
uspace/lib/net/tl/tl_common.c
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libnet 29 /** @addtogroup libnet 30 30 * @{ 31 31 */ … … 39 39 #include <packet_client.h> 40 40 #include <packet_remote.h> 41 #include <icmp_ interface.h>41 #include <icmp_remote.h> 42 42 #include <ip_remote.h> 43 43 #include <ip_interface.h> 44 #include <tl_ interface.h>44 #include <tl_remote.h> 45 45 46 46 #include <net/socket_codes.h> -
uspace/lib/net/tl/tl_remote.c
r9ee87f6 r7fc092a 31 31 */ 32 32 33 #include <tl_ interface.h>33 #include <tl_remote.h> 34 34 #include <generic.h> 35 35 #include <packet_client.h> … … 57 57 * 58 58 */ 59 int 60 tl_received_msg(int tl_phone, device_id_t device_id, packet_t *packet, 59 int tl_received_msg(int tl_phone, device_id_t device_id, packet_t *packet, 61 60 services_t target, services_t error) 62 61 { -
uspace/lib/usb/Makefile
r9ee87f6 r7fc092a 36 36 src/class.c \ 37 37 src/debug.c \ 38 src/dp.c \ 38 39 src/drvpsync.c \ 40 src/dump.c \ 39 41 src/hcdhubd.c \ 40 42 src/hcdrv.c \ … … 45 47 src/usb.c \ 46 48 src/usbdrvreq.c \ 47 src/usbdrv.c 49 src/usbdrv.c \ 50 src/usbmem.c 48 51 49 52 include $(USPACE_PREFIX)/Makefile.common -
uspace/lib/usb/include/usb/addrkeep.h
-
Property mode
changed from
100644
to120000
r9ee87f6 r7fc092a 1 /* 2 * Copyright (c) 2010 Vojtech Horky 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * - The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** @addtogroup libusb usb 30 * @{ 31 */ 32 /** @file 33 * @brief HC driver. 34 */ 35 #ifndef LIBUSB_HCD_H_ 36 #define LIBUSB_HCD_H_ 37 38 #include <usb/usb.h> 39 #include <fibril_synch.h> 40 #include <devman.h> 41 42 /** Info about used address. */ 43 typedef struct { 44 /** Linked list member. */ 45 link_t link; 46 /** Address. */ 47 usb_address_t address; 48 /** Corresponding devman handle. */ 49 devman_handle_t devman_handle; 50 } usb_address_keeping_used_t; 51 52 /** Structure for keeping track of free and used USB addresses. */ 53 typedef struct { 54 /** Head of list of used addresses. */ 55 link_t used_addresses; 56 /** Upper bound for USB addresses. */ 57 usb_address_t max_address; 58 /** Mutex protecting used address. */ 59 fibril_mutex_t used_addresses_guard; 60 /** Condition variable for used addresses. */ 61 fibril_condvar_t used_addresses_condvar; 62 63 /** Condition variable mutex for default address. */ 64 fibril_mutex_t default_condvar_guard; 65 /** Condition variable for default address. */ 66 fibril_condvar_t default_condvar; 67 /** Whether is default address available. */ 68 bool default_available; 69 } usb_address_keeping_t; 70 71 void usb_address_keeping_init(usb_address_keeping_t *, usb_address_t); 72 73 void usb_address_keeping_reserve_default(usb_address_keeping_t *); 74 void usb_address_keeping_release_default(usb_address_keeping_t *); 75 76 usb_address_t usb_address_keeping_request(usb_address_keeping_t *); 77 int usb_address_keeping_release(usb_address_keeping_t *, usb_address_t); 78 void usb_address_keeping_devman_bind(usb_address_keeping_t *, usb_address_t, 79 devman_handle_t); 80 usb_address_t usb_address_keeping_find(usb_address_keeping_t *, 81 devman_handle_t); 82 83 84 #endif 1 hcd.h -
Property mode
changed from
-
uspace/lib/usb/include/usb/classes/classes.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/include/usb/classes/hid.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ … … 39 39 #include <driver.h> 40 40 #include <usb/classes/hidparser.h> 41 #include <usb/descriptor.h> 41 42 42 43 /** USB/HID device requests. */ … … 63 64 */ 64 65 typedef struct { 65 /** Type of class descriptor (Report or Physical). */66 uint8_t class_descriptor_type;67 /** Length of class descriptor. */68 uint16_t class_descriptor_length;69 } __attribute__ ((packed)) usb_standard_hid_ descriptor_class_item_t;66 /** Type of class-specific descriptor (Report or Physical). */ 67 uint8_t type; 68 /** Length of class-specific descriptor in bytes. */ 69 uint16_t length; 70 } __attribute__ ((packed)) usb_standard_hid_class_descriptor_info_t; 70 71 71 72 /** Standard USB HID descriptor. … … 73 74 * (See HID Specification, p.22) 74 75 * 75 * It is actually only the "header" of the descriptor, as it may have arbitrary 76 * length if more than one class descritor is provided. 76 * It is actually only the "header" of the descriptor, it does not contain 77 * the last two mandatory fields (type and length of the first class-specific 78 * descriptor). 77 79 */ 78 80 typedef struct { 79 /** Size of this descriptor in bytes. */ 81 /** Total size of this descriptor in bytes. 82 * 83 * This includes all class-specific descriptor info - type + length 84 * for each descriptor. 85 */ 80 86 uint8_t length; 81 87 /** Descriptor type (USB_DESCTYPE_HID). */ … … 85 91 /** Country code of localized hardware. */ 86 92 uint8_t country_code; 87 /** Total number of class (i.e. Report and Physical) descriptors. */ 88 uint8_t class_count; 89 /** First mandatory class descriptor info. */ 90 usb_standard_hid_descriptor_class_item_t class_descriptor; 93 /** Total number of class-specific (i.e. Report and Physical) 94 * descriptors. 95 * 96 * @note There is always only one Report descriptor. 97 */ 98 uint8_t class_desc_count; 99 /** First mandatory class descriptor (Report) info. */ 100 usb_standard_hid_class_descriptor_info_t report_desc_info; 91 101 } __attribute__ ((packed)) usb_standard_hid_descriptor_t; 92 102 103 /** 104 * 105 */ 106 typedef struct { 107 usb_standard_interface_descriptor_t iface_desc; 108 usb_standard_endpoint_descriptor_t *endpoints; 109 usb_standard_hid_descriptor_t hid_desc; 110 uint8_t *report_desc; 111 //usb_standard_hid_class_descriptor_info_t *class_desc_info; 112 //uint8_t **class_descs; 113 } usb_hid_iface_t; 114 115 /** 116 * 117 */ 118 typedef struct { 119 usb_standard_configuration_descriptor_t config_descriptor; 120 usb_hid_iface_t *interfaces; 121 } usb_hid_configuration_t; 93 122 94 123 /** … … 99 128 typedef struct { 100 129 device_t *device; 130 usb_hid_configuration_t *conf; 101 131 usb_address_t address; 102 132 usb_endpoint_t poll_endpoint; … … 104 134 } usb_hid_dev_kbd_t; 105 135 136 // TODO: more configurations! 137 106 138 #endif 107 139 /** -
uspace/lib/usb/include/usb/classes/hidparser.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ … … 38 38 #include <stdint.h> 39 39 40 /** 41 * Description of report items 42 */ 43 typedef struct { 44 45 uint8_t usage_min; 46 uint8_t usage_max; 47 uint8_t logical_min; 48 uint8_t logical_max; 49 uint8_t size; 50 uint8_t count; 51 uint8_t offset; 52 53 } usb_hid_report_item_t; 54 55 40 56 /** HID report parser structure. */ 41 57 typedef struct { 42 58 } usb_hid_report_parser_t; 59 43 60 44 61 /** HID parser callbacks for IN items. */ … … 50 67 * @param arg Custom argument. 51 68 */ 52 void (*keyboard)(const uint 16_t *key_codes, size_t count, void *arg);69 void (*keyboard)(const uint8_t *key_codes, size_t count, const uint8_t modifiers, void *arg); 53 70 } usb_hid_report_in_callbacks_t; 71 72 #define USB_HID_BOOT_KEYBOARD_NUM_LOCK 0x01 73 #define USB_HID_BOOT_KEYBOARD_CAPS_LOCK 0x02 74 #define USB_HID_BOOT_KEYBOARD_SCROLL_LOCK 0x04 75 #define USB_HID_BOOT_KEYBOARD_COMPOSE 0x08 76 #define USB_HID_BOOT_KEYBOARD_KANA 0x10 77 78 /* 79 * modifiers definitions 80 */ 81 82 int usb_hid_boot_keyboard_input_report(const uint8_t *data, size_t size, 83 const usb_hid_report_in_callbacks_t *callbacks, void *arg); 84 85 int usb_hid_boot_keyboard_output_report(uint8_t leds, uint8_t *data, size_t size); 54 86 55 87 int usb_hid_parse_report_descriptor(usb_hid_report_parser_t *parser, … … 60 92 const usb_hid_report_in_callbacks_t *callbacks, void *arg); 61 93 94 95 int usb_hid_free_report_parser(usb_hid_report_parser_t *parser); 96 62 97 #endif 63 98 /** -
uspace/lib/usb/include/usb/classes/hidut.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/include/usb/classes/hidutkbd.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/include/usb/classes/hub.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ … … 68 68 * For more information see Universal Serial Bus Specification Revision 1.1 chapter 11.16.2 69 69 */ 70 typedef struct hub_descriptor_type{70 typedef struct usb_hub_descriptor_type { 71 71 /** Number of bytes in this descriptor, including this byte */ 72 72 //uint8_t bDescLength; -
uspace/lib/usb/include/usb/debug.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ … … 35 35 #ifndef LIBUSB_DEBUG_H_ 36 36 #define LIBUSB_DEBUG_H_ 37 #include <stdio.h> 38 #include <usb/usb.h> 37 39 38 40 void usb_dprintf(const char *tag, int level, const char *format, ...); 39 41 void usb_dprintf_enable(const char *tag, int level); 40 42 43 void usb_dump_standard_descriptor(FILE *, const char *, const char *, 44 const uint8_t *, size_t); 41 45 42 46 #endif 47 /** 48 * @} 49 */ 50 -
uspace/lib/usb/include/usb/descriptor.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/include/usb/devreq.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/include/usb/dp.h
r9ee87f6 r7fc092a 1 1 /* 2 * Copyright (c) 20 09 Lukas Mejdrech2 * Copyright (c) 2011 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup arp29 /** @addtogroup libusb 30 30 * @{ 31 31 */ 32 /** @file 33 * @brief USB descriptor parser. 34 */ 35 #ifndef LIBUSB_DP_H_ 36 #define LIBUSB_DP_H_ 32 37 33 /** @file 34 * ARP module functions. 35 * The functions are used as ARP module entry points. 36 */ 38 #include <sys/types.h> 39 #include <usb/usb.h> 40 #include <usb/descriptor.h> 37 41 38 #ifndef NET_ARP_MODULE_H_ 39 #define NET_ARP_MODULE_H_ 42 typedef struct { 43 int child; 44 int parent; 45 } usb_dp_descriptor_nesting_t; 40 46 41 #include <ipc/ipc.h> 42 #include <async.h> 47 typedef struct { 48 usb_dp_descriptor_nesting_t *nesting; 49 } usb_dp_parser_t; 43 50 44 extern int arp_initialize(async_client_conn_t); 45 extern int arp_message_standalone(ipc_callid_t, ipc_call_t *, ipc_call_t *, 46 size_t *); 51 typedef struct { 52 uint8_t *data; 53 size_t size; 54 void *arg; 55 } usb_dp_parser_data_t; 56 57 uint8_t *usb_dp_get_nested_descriptor(usb_dp_parser_t *, 58 usb_dp_parser_data_t *, uint8_t *); 59 uint8_t *usb_dp_get_sibling_descriptor(usb_dp_parser_t *, 60 usb_dp_parser_data_t *, uint8_t *, uint8_t *); 47 61 48 62 #endif 49 50 /** @}63 /** 64 * @} 51 65 */ -
uspace/lib/usb/include/usb/hcd.h
-
Property mode
changed from
120000
to100644
r9ee87f6 r7fc092a 1 addrkeep.h 1 /* 2 * Copyright (c) 2010 Vojtech Horky 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * - Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * - Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * - The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** @addtogroup libusb 30 * @{ 31 */ 32 /** @file 33 * @brief HC driver. 34 */ 35 #ifndef LIBUSB_HCD_H_ 36 #define LIBUSB_HCD_H_ 37 38 #include <usb/usb.h> 39 #include <fibril_synch.h> 40 #include <devman.h> 41 42 /** Info about used address. */ 43 typedef struct { 44 /** Linked list member. */ 45 link_t link; 46 /** Address. */ 47 usb_address_t address; 48 /** Corresponding devman handle. */ 49 devman_handle_t devman_handle; 50 } usb_address_keeping_used_t; 51 52 /** Structure for keeping track of free and used USB addresses. */ 53 typedef struct { 54 /** Head of list of used addresses. */ 55 link_t used_addresses; 56 /** Upper bound for USB addresses. */ 57 usb_address_t max_address; 58 /** Mutex protecting used address. */ 59 fibril_mutex_t used_addresses_guard; 60 /** Condition variable for used addresses. */ 61 fibril_condvar_t used_addresses_condvar; 62 63 /** Condition variable mutex for default address. */ 64 fibril_mutex_t default_condvar_guard; 65 /** Condition variable for default address. */ 66 fibril_condvar_t default_condvar; 67 /** Whether is default address available. */ 68 bool default_available; 69 } usb_address_keeping_t; 70 71 void usb_address_keeping_init(usb_address_keeping_t *, usb_address_t); 72 73 void usb_address_keeping_reserve_default(usb_address_keeping_t *); 74 void usb_address_keeping_release_default(usb_address_keeping_t *); 75 76 usb_address_t usb_address_keeping_request(usb_address_keeping_t *); 77 int usb_address_keeping_release(usb_address_keeping_t *, usb_address_t); 78 void usb_address_keeping_devman_bind(usb_address_keeping_t *, usb_address_t, 79 devman_handle_t); 80 usb_address_t usb_address_keeping_find(usb_address_keeping_t *, 81 devman_handle_t); 82 83 #endif 84 /** 85 * @} 86 */ -
Property mode
changed from
-
uspace/lib/usb/include/usb/hcdhubd.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/include/usb/usb.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/include/usb/usbdrv.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/include/usb/usbmem.h
r9ee87f6 r7fc092a 1 1 /* 2 * Copyright (c) 20 09 Lukas Mejdrech2 * Copyright (c) 2010 Matus Dekanek 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup arp 30 * @{ 29 #ifndef USBMEM_H 30 #define USBMEM_H 31 32 33 // group should be changed - this is not usb specific 34 /** @addtogroup usb 35 * @{ 31 36 */ 32 33 /** @file 34 * ARP protocol header. 35 * Based on the RFC 826. 37 /** @file definitions of special memory management, used mostly in usb stack 38 * 39 * USB HCD needs traslation between physical and virtual addresses. These 40 * functions implement such functionality. For each allocated virtual address 41 * the memory manager gets also it`s physical translation and remembers it. 42 * Addresses allocated byt this manager can be therefore translated from and to 43 * physical addresses. 44 * Typical use: 45 * void * address = mman_malloc(some_size); 46 * void * physical_address = mman_getPA(address); 47 * void * the_same_address = mman_getVA(physical_address); 48 * void * null_address = mman_getPA(non_existing_address); 49 * mman_free(address); 50 * // physical_address, adress and the_same_address are no longer valid here 51 * 52 * 53 * @note Addresses allocated by this memory manager should be as well 54 * deallocated byt it. 55 * 36 56 */ 37 38 #ifndef NET_ARP_HEADER_H_39 #define NET_ARP_HEADER_H_40 57 41 58 #include <sys/types.h> 42 59 43 /** Type definition of an ARP protocol header. 44 * @see arp_header 45 */ 46 typedef struct arp_header arp_header_t;60 extern void * mman_malloc( 61 size_t size, 62 size_t alignment, 63 unsigned long max_physical_address); 47 64 48 /** ARP protocol header. */ 49 struct arp_header { 50 /** 51 * Hardware type identifier. 52 * @see hardware.h 53 */ 54 uint16_t hardware; 55 56 /** Protocol identifier. */ 57 uint16_t protocol; 58 /** Hardware address length in bytes. */ 59 uint8_t hardware_length; 60 /** Protocol address length in bytes. */ 61 uint8_t protocol_length; 62 63 /** 64 * ARP packet type. 65 * @see arp_oc.h 66 */ 67 uint16_t operation; 68 } __attribute__ ((packed)); 65 extern void * mman_getVA(void * addr); 69 66 70 #endif 67 extern void * mman_getPA(void * addr); 68 69 extern void mman_free(void * addr); 70 71 72 73 74 71 75 72 76 /** @} 73 77 */ 78 79 80 #endif /* USBMEM_H */ 81 -
uspace/lib/usb/src/addrkeep.c
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/src/class.c
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/src/debug.c
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/src/drvpsync.c
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/src/hcdhubd.c
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/src/hcdhubd_private.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/src/hcdrv.c
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/src/hidparser.c
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ … … 40 40 * @param parser Opaque HID report parser structure. 41 41 * @param data Data describing the report. 42 * @param size Size of the descriptor in bytes.43 42 * @return Error code. 44 43 */ … … 55 54 * @param parser Opaque HID report parser structure. 56 55 * @param data Data for the report. 57 * @param size Size of the data in bytes.58 56 * @param callbacks Callbacks for report actions. 59 57 * @param arg Custom argument (passed through to the callbacks). … … 66 64 int i; 67 65 68 // TODO: parse report 66 /* main parsing loop */ 67 while(0){ 68 } 69 69 70 uint16_t keys[6]; 70 71 uint8_t keys[6]; 71 72 72 73 for (i = 0; i < 6; ++i) { … … 74 75 } 75 76 76 callbacks->keyboard(keys, 6, arg); 77 77 callbacks->keyboard(keys, 6, 0, arg); 78 79 return EOK; 80 } 81 82 /** Free the HID report parser structure 83 * 84 * @param parser Opaque HID report parser structure 85 * @return Error code 86 */ 87 int usb_hid_free_report_parser(usb_hid_report_parser_t *parser) 88 { 89 78 90 return EOK; 79 91 } … … 81 93 82 94 /** 95 * Parse input report. 96 * 97 * @param data Data for report 98 * @param size Size of report 99 * @param callbacks Callbacks for report actions 100 * @param arg Custom arguments 101 * 102 * @return Error code 103 */ 104 int usb_hid_boot_keyboard_input_report(const uint8_t *data, size_t size, 105 const usb_hid_report_in_callbacks_t *callbacks, void *arg) 106 { 107 int i; 108 usb_hid_report_item_t item; 109 110 /* fill item due to the boot protocol report descriptor */ 111 // modifier keys are in the first byte 112 uint8_t modifiers = data[0]; 113 114 item.offset = 2; /* second byte is reserved */ 115 item.size = 8; 116 item.count = 6; 117 item.usage_min = 0; 118 item.usage_max = 255; 119 item.logical_min = 0; 120 item.logical_max = 255; 121 122 if(size != 8){ 123 return -1; 124 } 125 126 uint8_t keys[6]; 127 for(i=item.offset; i<item.count; i++) { 128 keys[i-2] = data[i]; 129 } 130 131 callbacks->keyboard(keys, 6, modifiers, arg); 132 return EOK; 133 } 134 135 /** 136 * Makes output report for keyboard boot protocol 137 * 138 * @param leds 139 * @param output Output report data buffer 140 * @param size Size of the output buffer 141 * @return Error code 142 */ 143 int usb_hid_boot_keyboard_output_report(uint8_t leds, uint8_t *data, size_t size) 144 { 145 if(size != 1){ 146 return -1; 147 } 148 149 /* used only first five bits, others are only padding*/ 150 *data = leds; 151 return EOK; 152 } 153 154 /** 83 155 * @} 84 156 */ -
uspace/lib/usb/src/localdrv.c
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/src/recognise.c
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ … … 39 39 #include <errno.h> 40 40 41 /** Callback for getting host controller handle. 42 * 43 * @param dev Device in question. 44 * @param[out] handle Devman handle of the host controller. 45 * @return Error code. 46 */ 41 47 static int usb_iface_get_hc_handle(device_t *dev, devman_handle_t *handle) 42 48 { … … 203 209 uint8_t cur_descr_len = current_descriptor[0]; 204 210 uint8_t cur_descr_type = current_descriptor[1]; 211 212 if (cur_descr_len == 0) { 213 return ENOENT; 214 } 205 215 206 216 position += cur_descr_len; … … 233 243 * @param matches Match ids list to add matches to. 234 244 * @param address USB address of the attached device. 245 * @param config_count Number of configurations the device has. 235 246 * @return Error code. 236 247 */ … … 338 349 /** Probe for device kind and register it in devman. 339 350 * 340 * @param hc Open phone to the host controller. 341 * @param parent Parent device. 342 * @param address Address of the (unknown) attached device. 351 * @param[in] hc Open phone to the host controller. 352 * @param[in] parent Parent device. 353 * @param[in] address Address of the (unknown) attached device. 354 * @param[out] child_handle Handle of the child device. 343 355 * @return Error code. 344 356 */ … … 346 358 usb_address_t address, devman_handle_t *child_handle) 347 359 { 360 static size_t device_name_index = 0; 361 348 362 device_t *child = NULL; 349 363 char *child_name = NULL; … … 357 371 358 372 /* 359 * TODO: some better child naming 360 */ 361 rc = asprintf(&child_name, "usb%p", child); 373 * TODO: Once the device driver framework support persistent 374 * naming etc., something more descriptive could be created. 375 */ 376 rc = asprintf(&child_name, "usbdev%02zu", device_name_index); 362 377 if (rc < 0) { 363 378 goto failure; … … 381 396 } 382 397 398 device_name_index++; 399 383 400 return EOK; 384 401 -
uspace/lib/usb/src/remotedrv.c
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/src/usb.c
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/src/usbdrv.c
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ -
uspace/lib/usb/src/usbdrvreq.c
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ … … 60 60 #define PREPARE_SETUP_PACKET(name, p_direction, p_type, p_recipient, \ 61 61 p_request, p_value, p_index, p_length) \ 62 usb_device_request_setup_packet_t setup_packet= { \62 usb_device_request_setup_packet_t name = { \ 63 63 .request_type = \ 64 64 ((p_direction) == USB_DIRECTION_IN ? 128 : 0) \ … … 188 188 * @param[in] phone Open phone to HC driver. 189 189 * @param[in] old_address Current address. 190 * @param[in] address Address to be set.190 * @param[in] new_address Address to be set. 191 191 * @return Error code. 192 192 */ -
uspace/lib/usbvirt/include/usbvirt/device.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusbvirt usb29 /** @addtogroup libusbvirt 30 30 * @{ 31 31 */ -
uspace/lib/usbvirt/include/usbvirt/hub.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusbvirt usb29 /** @addtogroup libusbvirt 30 30 * @{ 31 31 */ -
uspace/lib/usbvirt/src/callback.c
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusbvirt usb29 /** @addtogroup libusbvirt 30 30 * @{ 31 31 */ … … 160 160 return; 161 161 } 162 async_data_read_finalize(callid, buffer, receive_len); 163 } 164 165 ipc_answer_0(iid, rc); 162 if (len > receive_len) { 163 len = receive_len; 164 } 165 async_data_read_finalize(callid, buffer, len); 166 } 167 168 ipc_answer_1(iid, rc, len); 166 169 } 167 170 -
uspace/lib/usbvirt/src/ctrlpipe.c
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusbvirt usb29 /** @addtogroup libusbvirt 30 30 * @{ 31 31 */ -
uspace/lib/usbvirt/src/debug.c
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusbvirt usb29 /** @addtogroup libusbvirt 30 30 * @{ 31 31 */ -
uspace/lib/usbvirt/src/main.c
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusbvirt usb29 /** @addtogroup libusbvirt 30 30 * @{ 31 31 */ … … 183 183 /** Create necessary phones for communication with virtual HCD. 184 184 * This function wraps following calls: 185 * -# open <code>/dev/devices/\\virt\\usbhc for reading185 * -# open <code>/dev/devices/\\virt\\usbhc</code> for reading 186 186 * -# access phone of file opened in previous step 187 187 * -# create callback through just opened phone -
uspace/lib/usbvirt/src/private.h
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusbvirt usb29 /** @addtogroup libusbvirt 30 30 * @{ 31 31 */ -
uspace/lib/usbvirt/src/stdreq.c
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusbvirt usb29 /** @addtogroup libusbvirt 30 30 * @{ 31 31 */ -
uspace/lib/usbvirt/src/transaction.c
r9ee87f6 r7fc092a 27 27 */ 28 28 29 /** @addtogroup libusbvirt usb29 /** @addtogroup libusbvirt 30 30 * @{ 31 31 */
Note:
See TracChangeset
for help on using the changeset viewer.