Changeset 0a9ea4a in mainline for uspace/lib
- Timestamp:
- 2011-01-14T14:28:57Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1d7a74e, 6336b6e
- Parents:
- 45019865 (diff), 2f60e57d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/lib
- Files:
-
- 5 added
- 4 deleted
- 18 edited
- 7 moved
-
c/generic/ddi.c (modified) (1 diff)
-
c/generic/devman.c (modified) (1 diff)
-
c/include/ddi.h (modified) (1 diff)
-
c/include/ipc/il.h (modified) (2 diffs)
-
c/include/ipc/ip.h (modified) (2 diffs)
-
c/include/ipc/services.h (modified) (1 diff)
-
net/Makefile (modified) (2 diffs)
-
net/generic/protocol_map.c (modified) (3 diffs)
-
net/il/il_remote.c (moved) (moved from uspace/lib/net/il/il_interface.c ) (1 diff)
-
net/il/il_skel.c (added)
-
net/il/ip_remote.c (modified) (4 diffs)
-
net/include/il_local.h (deleted)
-
net/include/il_remote.h (moved) (moved from uspace/lib/net/include/il_interface.h ) (1 diff)
-
net/include/il_skel.h (moved) (moved from uspace/srv/net/tl/tcp/tcp_module.c ) (2 diffs)
-
net/include/nil_interface.h (deleted)
-
net/include/nil_local.h (deleted)
-
net/include/nil_remote.h (modified) (1 diff)
-
net/include/nil_skel.h (added)
-
net/include/tl_local.h (deleted)
-
net/include/tl_remote.h (moved) (moved from uspace/lib/net/include/tl_interface.h ) (2 diffs)
-
net/include/tl_skel.h (moved) (moved from uspace/srv/net/nil/eth/eth_module.c ) (2 diffs)
-
net/netif/netif_skel.c (modified) (4 diffs)
-
net/nil/nil_remote.c (modified) (2 diffs)
-
net/nil/nil_skel.c (added)
-
net/tl/tl_common.c (modified) (1 diff)
-
net/tl/tl_remote.c (moved) (moved from uspace/lib/net/tl/tl_interface.c ) (2 diffs)
-
net/tl/tl_skel.c (added)
-
usb/Makefile (modified) (1 diff)
-
usb/include/usb/classes/hidparser.h (modified) (3 diffs)
-
usb/include/usb/dp.h (moved) (moved from uspace/srv/net/tl/icmp/icmp_module.h ) (2 diffs)
-
usb/src/dp.c (added)
-
usb/src/hidparser.c (modified) (5 diffs)
-
usb/src/recognise.c (modified) (3 diffs)
-
usb/src/usbdrvreq.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/ddi.c
r45019865 r0a9ea4a 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
r45019865 r0a9ea4a 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/include/ddi.h
r45019865 r0a9ea4a 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/il.h
r45019865 r0a9ea4a 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
r45019865 r0a9ea4a 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
r45019865 r0a9ea4a 54 54 SERVICE_NETWORKING, 55 55 SERVICE_LO, 56 SERVICE_ DP8390,56 SERVICE_NE2000, 57 57 SERVICE_ETHERNET, 58 58 SERVICE_NILDUMMY, -
uspace/lib/net/Makefile
r45019865 r0a9ea4a 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
r45019865 r0a9ea4a 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
r45019865 r0a9ea4a 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
r45019865 r0a9ea4a 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/il_remote.h
r45019865 r0a9ea4a 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
r45019865 r0a9ea4a 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
r45019865 r0a9ea4a 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
r45019865 r0a9ea4a 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
r45019865 r0a9ea4a 1 1 /* 2 * Copyright (c) 20 09 Lukas Mejdrech2 * Copyright (c) 2010 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup eth29 /** @addtogroup libnet 30 30 * @{ 31 31 */ 32 32 33 #ifndef LIBNET_TL_SKEL_H_ 34 #define LIBNET_TL_SKEL_H_ 35 33 36 /** @file 34 * Ethernet module stub.35 * @see module.c37 * Transport layer module skeleton. 38 * The skeleton has to be part of each transport layer module. 36 39 */ 37 40 38 #include "eth.h"39 40 41 #include <async.h> 41 #include <stdio.h> 42 #include <errno.h> 43 42 #include <fibril_synch.h> 44 43 #include <ipc/ipc.h> 45 44 #include <ipc/services.h> 46 45 47 #include < net/modules.h>48 #include <net _interface.h>46 #include <adt/measured_strings.h> 47 #include <net/device.h> 49 48 #include <net/packet.h> 50 #include <nil_local.h>51 49 52 int nil_module_start_standalone(async_client_conn_t client_connection) 53 { 54 sysarg_t phonehash; 55 int rc; 56 57 async_set_client_connection(client_connection); 58 int net_phone = net_connect_module(); 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 tl_initialize(int net_phone); 59 62 60 rc = pm_init(); 61 if (rc != EOK) 62 return rc; 63 64 rc = nil_initialize(net_phone); 65 if (rc != EOK) 66 goto out; 63 /** Process the transport 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 tl_module_message(ipc_callid_t, ipc_call_t *, 77 ipc_call_t *, size_t *); 67 78 68 rc = ipc_connect_to_me(PHONE_NS, SERVICE_ETHERNET, 0, 0, &phonehash); 69 if (rc != EOK) 70 goto out; 71 72 async_manager(); 79 extern int tl_module_start(int); 73 80 74 out: 75 pm_destroy(); 76 return rc; 77 } 78 79 int nil_module_message_standalone(const char *name, ipc_callid_t callid, 80 ipc_call_t *call, ipc_call_t *answer, size_t *count) 81 { 82 return nil_message_standalone(name, callid, call, answer, count); 83 } 81 #endif 84 82 85 83 /** @} -
uspace/lib/net/netif/netif_skel.c
r45019865 r0a9ea4a 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
r45019865 r0a9ea4a 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/tl_common.c
r45019865 r0a9ea4a 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
r45019865 r0a9ea4a 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
r45019865 r0a9ea4a 36 36 src/class.c \ 37 37 src/debug.c \ 38 src/dp.c \ 38 39 src/drvpsync.c \ 39 40 src/hcdhubd.c \ -
uspace/lib/usb/include/usb/classes/hidparser.h
r45019865 r0a9ea4a 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/dp.h
r45019865 r0a9ea4a 1 1 /* 2 * Copyright (c) 20 08 Lukas Mejdrech2 * Copyright (c) 2011 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup icmp29 /** @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 * ICMP module functions. 35 * The functions are used as ICMP module entry points. 36 */ 38 #include <sys/types.h> 39 #include <usb/usb.h> 40 #include <usb/descriptor.h> 37 41 38 #ifndef NET_ICMP_MODULE_H_ 39 #define NET_ICMP_MODULE_H_ 42 typedef struct { 43 int child; 44 int parent; 45 } usb_dp_descriptor_nesting_t; 40 46 41 #include <async.h> 42 #include <ipc/ipc.h> 47 typedef struct { 48 usb_dp_descriptor_nesting_t *nesting; 49 } usb_dp_parser_t; 43 50 44 extern int icmp_initialize(async_client_conn_t); 45 extern int icmp_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/src/hidparser.c
r45019865 r0a9ea4a 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/recognise.c
r45019865 r0a9ea4a 346 346 usb_address_t address, devman_handle_t *child_handle) 347 347 { 348 static size_t device_name_index = 0; 349 348 350 device_t *child = NULL; 349 351 char *child_name = NULL; … … 357 359 358 360 /* 359 * TODO: some better child naming 360 */ 361 rc = asprintf(&child_name, "usb%p", child); 361 * TODO: Once the device driver framework support persistent 362 * naming etc., something more descriptive could be created. 363 */ 364 rc = asprintf(&child_name, "usbdev%02zu", device_name_index); 362 365 if (rc < 0) { 363 366 goto failure; … … 381 384 } 382 385 386 device_name_index++; 387 383 388 return EOK; 384 389 -
uspace/lib/usb/src/usbdrvreq.c
r45019865 r0a9ea4a 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) \
Note:
See TracChangeset
for help on using the changeset viewer.
