Changeset 0a9ea4a in mainline for uspace/lib


Ignore:
Timestamp:
2011-01-14T14:28:57Z (15 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
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.
Message:

Merge development into lelian/hidd

Location:
uspace/lib
Files:
5 added
4 deleted
18 edited
7 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/ddi.c

    r45019865 r0a9ea4a  
    9696}
    9797
    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 
    12098/** Enable PIO for specified I/O range.
    12199 *
  • uspace/lib/c/generic/devman.c

    r45019865 r0a9ea4a  
    7979                }
    8080               
    81                 if (flags & IPC_FLAG_BLOCKING)
     81                if (flags & IPC_FLAG_BLOCKING) {
    8282                        devman_phone_client = async_connect_me_to_blocking(
    8383                            PHONE_NS, SERVICE_DEVMAN, DEVMAN_CLIENT, 0);
    84                 else
     84                } else {
    8585                        devman_phone_client = async_connect_me_to(PHONE_NS,
    8686                            SERVICE_DEVMAN, DEVMAN_CLIENT, 0);
     87                }
    8788               
    8889                fibril_mutex_unlock(&devman_phone_mutex);
  • uspace/lib/c/include/ddi.h

    r45019865 r0a9ea4a  
    4242extern int iospace_enable(task_id_t, void *, unsigned long);
    4343extern int pio_enable(void *, size_t, void **);
    44 extern int interrupt_enable(int);
    45 extern int interrupt_disable(int);
    4644
    4745#endif
  • uspace/lib/c/include/ipc/il.h

    r45019865 r0a9ea4a  
    3333/** @file
    3434 * Internetwork layer modules messages.
    35  * @see il_interface.h
     35 * @see il_remote.h
    3636 * @see ip_interface.h
    3737 */
     
    4545/** Internet layer modules messages. */
    4646typedef enum {
    47         /** New device message.
    48          * @see ip_device_req()
    49          */
    50         NET_IL_DEVICE = NET_IL_FIRST,
    5147        /** Device state changed message.
    5248         * @see il_device_state_msg()
    5349         */
    54         NET_IL_DEVICE_STATE,
     50        NET_IL_DEVICE_STATE = NET_IL_FIRST,
     51       
    5552        /** Device MTU changed message.
    5653         * @see il_mtu_changed_msg()
    5754         */
    5855        NET_IL_MTU_CHANGED,
    59         /** Packet size message.
    60          * @see il_packet_size_req()
    61          */
    62         NET_IL_PACKET_SPACE,
     56       
    6357        /** Packet received message.
    6458         * @see il_received_msg()
    6559         */
    66         NET_IL_RECEIVED,
    67         /** Packet send message.
    68          * @see il_send_msg()
    69          */
    70         NET_IL_SEND
     60        NET_IL_RECEIVED
    7161} il_messages;
    7262
  • uspace/lib/c/include/ipc/ip.h

    r45019865 r0a9ea4a  
    4747/** IP module messages. */
    4848typedef enum {
     49        /** New device message.
     50         * @see ip_device_req()
     51         */
     52        NET_IP_DEVICE = NET_IP_FIRST,
     53       
    4954        /** Adds the routing entry.
    5055         * @see ip_add_route()
    5156         */
    52         NET_IP_ADD_ROUTE = NET_IP_FIRST,
     57        NET_IP_ADD_ROUTE,
    5358       
    5459        /** Gets the actual route information.
     
    6570         * @see ip_set_default_gateway()
    6671         */
    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
    6883} ip_messages;
    6984
  • uspace/lib/c/include/ipc/services.h

    r45019865 r0a9ea4a  
    5454        SERVICE_NETWORKING,
    5555        SERVICE_LO,
    56         SERVICE_DP8390,
     56        SERVICE_NE2000,
    5757        SERVICE_ETHERNET,
    5858        SERVICE_NILDUMMY,
  • uspace/lib/net/Makefile

    r45019865 r0a9ea4a  
    4343        netif/netif_skel.c \
    4444        nil/nil_remote.c \
    45         il/il_interface.c \
     45        nil/nil_skel.c \
     46        il/il_remote.c \
     47        il/il_skel.c \
    4648        il/ip_remote.c \
    4749        il/ip_client.c \
     
    5052        tl/icmp_client.c \
    5153        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
    5457
    5558include $(USPACE_PREFIX)/Makefile.common
  • uspace/lib/net/generic/protocol_map.c

    r45019865 r0a9ea4a  
    5050        switch (nil) {
    5151        case SERVICE_ETHERNET:
    52         case SERVICE_DP8390:
     52        case SERVICE_NE2000:
    5353                switch (il) {
    5454                case SERVICE_IP:
     
    7676        switch (nil) {
    7777        case SERVICE_ETHERNET:
    78         case SERVICE_DP8390:
     78        case SERVICE_NE2000:
    7979                switch (protocol) {
    8080                case ETH_P_IP:
     
    139139        switch (nil) {
    140140        case SERVICE_ETHERNET:
    141         case SERVICE_DP8390:
     141        case SERVICE_NE2000:
    142142                return HW_ETHER;
    143143        default:
  • uspace/lib/net/il/il_remote.c

    r45019865 r0a9ea4a  
    3333/** @file
    3434 * Internetwork layer module interface for the underlying network interface
    35  * layer. This interface is always called by the remote modules.
     35 * layer.
    3636 */
    3737
    38 #include <il_interface.h>
     38#include <il_remote.h>
    3939#include <generic.h>
    4040#include <packet_client.h>
  • uspace/lib/net/il/ip_remote.c

    r45019865 r0a9ea4a  
    3636 *
    3737 * @see ip_interface.h
    38  * @see il_interface.h
     38 * @see il_remote.h
    3939 *
    4040 */
     
    121121    services_t service)
    122122{
    123         return generic_device_req_remote(ip_phone, NET_IL_DEVICE, device_id, 0,
     123        return generic_device_req_remote(ip_phone, NET_IP_DEVICE, device_id, 0,
    124124            service);
    125125}
     
    188188    packet_dimension_t *packet_dimension)
    189189{
    190         return generic_packet_size_req_remote(ip_phone, NET_IL_PACKET_SPACE,
     190        return generic_packet_size_req_remote(ip_phone, NET_IP_PACKET_SPACE,
    191191            device_id, packet_dimension);
    192192}
     
    228228    services_t sender, services_t error)
    229229{
    230         return generic_send_msg_remote(ip_phone, NET_IL_SEND, device_id,
     230        return generic_send_msg_remote(ip_phone, NET_IP_SEND, device_id,
    231231            packet_get_id(packet), sender, error);
    232232}
  • uspace/lib/net/include/il_remote.h

    r45019865 r0a9ea4a  
    3636 */
    3737
    38 #ifndef LIBNET_IL_INTERFACE_H_
    39 #define LIBNET_IL_INTERFACE_H_
     38#ifndef LIBNET_IL_REMOTE_H_
     39#define LIBNET_IL_REMOTE_H_
    4040
    4141#include <ipc/services.h>
  • uspace/lib/net/include/il_skel.h

    r45019865 r0a9ea4a  
    11/*
    2  * Copyright (c) 2008 Lukas Mejdrech
     2 * Copyright (c) 2010 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup tcp
     29/** @addtogroup libnet
    3030 * @{
    3131 */
    3232
     33#ifndef LIBNET_IL_SKEL_H_
     34#define LIBNET_IL_SKEL_H_
     35
    3336/** @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.
    3939 */
    4040
    41 #include "tcp.h"
    42 #include "tcp_module.h"
    43 
    4441#include <async.h>
    45 #include <stdio.h>
    46 #include <errno.h>
     42#include <fibril_synch.h>
    4743#include <ipc/ipc.h>
    4844#include <ipc/services.h>
    4945
    50 #include <net/ip_protocols.h>
    51 #include <net/modules.h>
     46#include <adt/measured_strings.h>
     47#include <net/device.h>
    5248#include <net/packet.h>
    53 #include <net_interface.h>
    5449
    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 */
     61extern int il_initialize(int net_phone);
    5762
    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 */
     76extern int il_module_message(ipc_callid_t callid, ipc_call_t *call,
     77    ipc_call_t *answer, size_t *answer_count);
    6078
    61 int tl_module_start_standalone(async_client_conn_t client_connection)
    62 {
    63         sysarg_t phonehash;
    64         int rc;
     79extern int il_module_start(int);
    6580
    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
    9382
    9483/** @}
  • uspace/lib/net/include/nil_remote.h

    r45019865 r0a9ea4a  
    3737#include <net/device.h>
    3838#include <net/packet.h>
     39#include <generic.h>
    3940
    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
     63extern int nil_device_state_msg(int, device_id_t, int);
     64extern int nil_received_msg(int, device_id_t, packet_t *, services_t);
    4265
    4366#endif
  • uspace/lib/net/include/tl_remote.h

    r45019865 r0a9ea4a  
    3535 */
    3636
    37 #ifndef LIBNET_TL_INTERFACE_H_
    38 #define LIBNET_TL_INTERFACE_H_
     37#ifndef LIBNET_TL_REMOTE_H_
     38#define LIBNET_TL_REMOTE_H_
    3939
    4040#include <async.h>
     
    5252/*@{*/
    5353
    54 extern int tl_received_msg(int, device_id_t, packet_t *, services_t, services_t);
     54extern int tl_received_msg(int, device_id_t, packet_t *, services_t,
     55    services_t);
    5556
    5657/*@}*/
  • uspace/lib/net/include/tl_skel.h

    r45019865 r0a9ea4a  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2010 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup eth
     29/** @addtogroup libnet
    3030 * @{
    3131 */
    3232
     33#ifndef LIBNET_TL_SKEL_H_
     34#define LIBNET_TL_SKEL_H_
     35
    3336/** @file
    34  *  Ethernet module stub.
    35  *  @see module.c
     37 * Transport layer module skeleton.
     38 * The skeleton has to be part of each transport layer module.
    3639 */
    3740
    38 #include "eth.h"
    39 
    4041#include <async.h>
    41 #include <stdio.h>
    42 #include <errno.h>
    43 
     42#include <fibril_synch.h>
    4443#include <ipc/ipc.h>
    4544#include <ipc/services.h>
    4645
    47 #include <net/modules.h>
    48 #include <net_interface.h>
     46#include <adt/measured_strings.h>
     47#include <net/device.h>
    4948#include <net/packet.h>
    50 #include <nil_local.h>
    5149
    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 */
     61extern int tl_initialize(int net_phone);
    5962
    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 */
     76extern int tl_module_message(ipc_callid_t, ipc_call_t *,
     77    ipc_call_t *, size_t *);
    6778
    68         rc = ipc_connect_to_me(PHONE_NS, SERVICE_ETHERNET, 0, 0, &phonehash);
    69         if (rc != EOK)
    70                 goto out;
    71        
    72         async_manager();
     79extern int tl_module_start(int);
    7380
    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
    8482
    8583/** @}
  • uspace/lib/net/netif/netif_skel.c

    r45019865 r0a9ea4a  
    3333/** @file
    3434 * Network interface module skeleton implementation.
    35  * @see netif.h
     35 * @see netif_skel.h
    3636 */
    3737
     
    5252#include <adt/measured_strings.h>
    5353#include <net/device.h>
    54 #include <nil_interface.h>
    5554#include <netif_skel.h>
     55#include <nil_remote.h>
    5656
    5757DEVICE_MAP_IMPLEMENT(netif_device_map, netif_device_t);
     
    130130        if (result > NETIF_NULL) {
    131131                int phone = device->nil_phone;
     132                nil_device_state_msg(phone, device_id, result);
    132133                fibril_rwlock_write_unlock(&netif_globals.lock);
    133                 nil_device_state_msg(phone, device_id, result);
    134134                return EOK;
    135135        }
     
    166166        if (result > NETIF_NULL) {
    167167                int phone = device->nil_phone;
     168                nil_device_state_msg(phone, device_id, result);
    168169                fibril_rwlock_write_unlock(&netif_globals.lock);
    169                 nil_device_state_msg(phone, device_id, result);
    170170                return EOK;
    171171        }
  • uspace/lib/net/nil/nil_remote.c

    r45019865 r0a9ea4a  
    3333/** @file
    3434 * Network interface layer interface implementation for remote modules.
    35  * @see nil_interface.h
     35 * @see nil_remote.h
    3636 */
    3737
    3838#include <nil_remote.h>
    39 #include <nil_interface.h>
    4039#include <generic.h>
    4140#include <net/device.h>
    4241#include <net/packet.h>
    4342#include <packet_client.h>
    44 
    4543#include <ipc/nil.h>
    4644
    4745/** Notify the network interface layer about the device state change.
    4846 *
    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 *
    5555 */
    56 int nil_device_state_msg_remote(int nil_phone, device_id_t device_id, int state)
     56int nil_device_state_msg(int nil_phone, device_id_t device_id, int state)
    5757{
    5858        return generic_device_state_msg_remote(nil_phone, NET_NIL_DEVICE_STATE,
     
    6565 * upper layers.
    6666 *
    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 *
    7476 */
    75 int nil_received_msg_remote(int nil_phone, device_id_t device_id,
     77int nil_received_msg(int nil_phone, device_id_t device_id,
    7678    packet_t *packet, services_t target)
    7779{
  • uspace/lib/net/tl/tl_common.c

    r45019865 r0a9ea4a  
    4242#include <ip_remote.h>
    4343#include <ip_interface.h>
    44 #include <tl_interface.h>
     44#include <tl_remote.h>
    4545
    4646#include <net/socket_codes.h>
  • uspace/lib/net/tl/tl_remote.c

    r45019865 r0a9ea4a  
    3131 */
    3232
    33 #include <tl_interface.h>
     33#include <tl_remote.h>
    3434#include <generic.h>
    3535#include <packet_client.h>
     
    5757 *
    5858 */
    59 int
    60 tl_received_msg(int tl_phone, device_id_t device_id, packet_t *packet,
     59int tl_received_msg(int tl_phone, device_id_t device_id, packet_t *packet,
    6160    services_t target, services_t error)
    6261{
  • uspace/lib/usb/Makefile

    r45019865 r0a9ea4a  
    3636        src/class.c \
    3737        src/debug.c \
     38        src/dp.c \
    3839        src/drvpsync.c \
    3940        src/hcdhubd.c \
  • uspace/lib/usb/include/usb/classes/hidparser.h

    r45019865 r0a9ea4a  
    3838#include <stdint.h>
    3939
     40/**
     41 * Description of report items
     42 */
     43typedef 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
    4056/** HID report parser structure. */
    4157typedef struct {
    4258} usb_hid_report_parser_t;
     59
    4360
    4461/** HID parser callbacks for IN items. */
     
    5067         * @param arg Custom argument.
    5168         */
    52         void (*keyboard)(const uint16_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);
    5370} 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
     82int 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
     85int usb_hid_boot_keyboard_output_report(uint8_t leds, uint8_t *data, size_t size);
    5486
    5587int usb_hid_parse_report_descriptor(usb_hid_report_parser_t *parser,
     
    6092    const usb_hid_report_in_callbacks_t *callbacks, void *arg);
    6193
     94
     95int usb_hid_free_report_parser(usb_hid_report_parser_t *parser);
     96
    6297#endif
    6398/**
  • uspace/lib/usb/include/usb/dp.h

    r45019865 r0a9ea4a  
    11/*
    2  * Copyright (c) 2008 Lukas Mejdrech
     2 * Copyright (c) 2011 Vojtech Horky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup icmp
     29/** @addtogroup libusb
    3030 * @{
    3131 */
     32/** @file
     33 * @brief USB descriptor parser.
     34 */
     35#ifndef LIBUSB_DP_H_
     36#define LIBUSB_DP_H_
    3237
    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>
    3741
    38 #ifndef NET_ICMP_MODULE_H_
    39 #define NET_ICMP_MODULE_H_
     42typedef struct {
     43        int child;
     44        int parent;
     45} usb_dp_descriptor_nesting_t;
    4046
    41 #include <async.h>
    42 #include <ipc/ipc.h>
     47typedef struct {
     48        usb_dp_descriptor_nesting_t *nesting;
     49} usb_dp_parser_t;
    4350
    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 *);
     51typedef struct {
     52        uint8_t *data;
     53        size_t size;
     54        void *arg;
     55} usb_dp_parser_data_t;
     56
     57uint8_t *usb_dp_get_nested_descriptor(usb_dp_parser_t *,
     58    usb_dp_parser_data_t *, uint8_t *);
     59uint8_t *usb_dp_get_sibling_descriptor(usb_dp_parser_t *,
     60    usb_dp_parser_data_t *, uint8_t *, uint8_t *);
    4761
    4862#endif
    49 
    50 /** @}
     63/**
     64 * @}
    5165 */
  • uspace/lib/usb/src/hidparser.c

    r45019865 r0a9ea4a  
    4040 * @param parser Opaque HID report parser structure.
    4141 * @param data Data describing the report.
    42  * @param size Size of the descriptor in bytes.
    4342 * @return Error code.
    4443 */
     
    5554 * @param parser Opaque HID report parser structure.
    5655 * @param data Data for the report.
    57  * @param size Size of the data in bytes.
    5856 * @param callbacks Callbacks for report actions.
    5957 * @param arg Custom argument (passed through to the callbacks).
     
    6664        int i;
    6765       
    68         // TODO: parse report
     66        /* main parsing loop */
     67        while(0){
     68        }
    6969       
    70         uint16_t keys[6];
     70       
     71        uint8_t keys[6];
    7172       
    7273        for (i = 0; i < 6; ++i) {
     
    7475        }
    7576       
    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 */
     87int usb_hid_free_report_parser(usb_hid_report_parser_t *parser)
     88{
     89
    7890        return EOK;
    7991}
     
    8193
    8294/**
     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 */
     104int 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 */
     143int 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/**
    83155 * @}
    84156 */
  • uspace/lib/usb/src/recognise.c

    r45019865 r0a9ea4a  
    346346    usb_address_t address, devman_handle_t *child_handle)
    347347{
     348        static size_t device_name_index = 0;
     349
    348350        device_t *child = NULL;
    349351        char *child_name = NULL;
     
    357359
    358360        /*
    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);
    362365        if (rc < 0) {
    363366                goto failure;
     
    381384        }
    382385       
     386        device_name_index++;
     387
    383388        return EOK;
    384389
  • uspace/lib/usb/src/usbdrvreq.c

    r45019865 r0a9ea4a  
    6060#define PREPARE_SETUP_PACKET(name, p_direction, p_type, p_recipient, \
    6161    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 = { \
    6363                .request_type = \
    6464                        ((p_direction) == USB_DIRECTION_IN ? 128 : 0) \
Note: See TracChangeset for help on using the changeset viewer.