Changeset 7fc092a in mainline for uspace/lib


Ignore:
Timestamp:
2011-01-27T22:09:29Z (15 years ago)
Author:
Jan Vesely <jano.vesely@…>
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.
Message:

Changes from development branch

Location:
uspace/lib
Files:
7 added
3 deleted
64 edited
9 moved

Legend:

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

    r9ee87f6 r7fc092a  
    3535#include <as.h>
    3636#include <libc.h>
     37#include <errno.h>
    3738#include <unistd.h>
    3839#include <align.h>
     
    128129}
    129130
     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 */
     139int 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
    130157/** @}
    131158 */
  • uspace/lib/c/generic/ddi.c

    r9ee87f6 r7fc092a  
    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

    r9ee87f6 r7fc092a  
    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/generic/net/icmp_common.c

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libc 
     29/** @addtogroup libc
    3030 *  @{
    3131 */
     
    3838#include <net/modules.h>
    3939#include <net/icmp_common.h>
    40 
    4140#include <ipc/services.h>
    4241#include <ipc/icmp.h>
    43 
    4442#include <sys/time.h>
    4543#include <async.h>
    4644
    47 /** Connects to the ICMP module.
     45/** Connect to the ICMP module.
    4846 *
    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 *
    5453 */
    55 int icmp_connect_module(services_t service, suseconds_t timeout)
     54int icmp_connect_module(suseconds_t timeout)
    5655{
    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);
    6457}
    6558
  • uspace/lib/c/generic/stats.c

    r9ee87f6 r7fc092a  
    3636#include <stats.h>
    3737#include <sysinfo.h>
    38 #include <assert.h>
    3938#include <errno.h>
    4039#include <stdio.h>
    4140#include <inttypes.h>
     41#include <malloc.h>
    4242
    4343#define SYSINFO_STATS_MAX_PATH  64
     
    7171            (stats_cpu_t *) sysinfo_get_data("system.cpus", &size);
    7272       
    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        }
    7479       
    7580        *count = size / sizeof(stats_cpu_t);
     
    9196            (stats_physmem_t *) sysinfo_get_data("system.physmem", &size);
    9297       
    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        }
    94103       
    95104        return stats_physmem;
     
    111120            (stats_task_t *) sysinfo_get_data("system.tasks", &size);
    112121       
    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        }
    114128       
    115129        *count = size / sizeof(stats_task_t);
     
    135149            (stats_task_t *) sysinfo_get_data(name, &size);
    136150       
    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        }
    138156       
    139157        return stats_task;
     
    155173            (stats_thread_t *) sysinfo_get_data("system.threads", &size);
    156174       
    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        }
    158181       
    159182        *count = size / sizeof(stats_thread_t);
     
    179202            (stats_thread_t *) sysinfo_get_data(name, &size);
    180203       
    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        }
    182209       
    183210        return stats_thread;
     
    199226            (stats_exc_t *) sysinfo_get_data("system.exceptions", &size);
    200227       
    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        }
    202234       
    203235        *count = size / sizeof(stats_exc_t);
     
    217249{
    218250        char name[SYSINFO_STATS_MAX_PATH];
    219         snprintf(name, SYSINFO_STATS_MAX_PATH, "system.exceptionss.%u", excn);
     251        snprintf(name, SYSINFO_STATS_MAX_PATH, "system.exceptions.%u", excn);
    220252       
    221253        size_t size = 0;
     
    223255            (stats_exc_t *) sysinfo_get_data(name, &size);
    224256       
    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        }
    226262       
    227263        return stats_exception;
     
    243279            (load_t *) sysinfo_get_data("system.load", &size);
    244280       
    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        }
    246287       
    247288        *count = size / sizeof(load_t);
  • uspace/lib/c/generic/sysinfo.c

    r9ee87f6 r7fc092a  
    9696void *sysinfo_get_data(const char *path, size_t *size)
    9797{
    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         */
    101103       
    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;
    131113        }
    132114       
    133         if (data != NULL)
    134                 free(data);
     115        void *data = malloc(*size);
     116        if (data == NULL) {
     117                *size = 0;
     118                return NULL;
     119        }
    135120       
     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);
    136132        *size = 0;
    137133        return NULL;
  • uspace/lib/c/include/adt/hash_table.h

    r9ee87f6 r7fc092a  
    4141typedef unsigned long hash_count_t;
    4242typedef 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. */
     45typedef 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;
    4573
    4674/** Hash table structure. */
    47 struct hash_table {
     75typedef struct {
    4876        link_t *entry;
    4977        hash_count_t entries;
    5078        hash_count_t max_keys;
    5179        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;
    8081
    8182#define hash_table_get_instance(item, type, member) \
  • uspace/lib/c/include/as.h

    r9ee87f6 r7fc092a  
    4747extern void *set_maxheapsize(size_t mhs);
    4848extern void * as_get_mappable_page(size_t sz);
     49extern int as_get_physical_mapping(void *address, uintptr_t *frame);
    4950
    5051#endif
  • uspace/lib/c/include/ddi.h

    r9ee87f6 r7fc092a  
    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/icmp.h

    r9ee87f6 r7fc092a  
    3333/** @file
    3434 * ICMP module messages.
    35  * @see icmp_interface.h
     35 * @see icmp_remote.h
    3636 */
    3737
     
    4848/** ICMP module messages. */
    4949typedef enum {
    50         /** Sends echo request. @see icmp_echo() */
     50        /** Send echo request. @see icmp_echo() */
    5151        NET_ICMP_ECHO = NET_ICMP_FIRST,
    5252       
    5353        /**
    54          * Sends destination unreachable error message.
     54         * Send destination unreachable error message.
    5555         * @see icmp_destination_unreachable_msg()
    5656         */
     
    5858       
    5959        /**
    60          * Sends source quench error message.
     60         * Send source quench error message.
    6161         * @see icmp_source_quench_msg()
    6262         */
     
    6464       
    6565        /**
    66          * Sends time exceeded error message.
     66         * Send time exceeded error message.
    6767         * @see icmp_time_exceeded_msg()
    6868         */
     
    7070       
    7171        /**
    72          * Sends parameter problem error message.
     72         * Send parameter problem error message.
    7373         * @see icmp_parameter_problem_msg()
    7474         */
    75         NET_ICMP_PARAMETERPROB,
    76        
    77         /** Initializes new connection. */
    78         NET_ICMP_INIT
    79 } icmp_messages;
     75        NET_ICMP_PARAMETERPROB
     76} icmp_messages_t;
    8077
    8178/** @name ICMP specific message parameters definitions */
  • uspace/lib/c/include/ipc/il.h

    r9ee87f6 r7fc092a  
    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

    r9ee87f6 r7fc092a  
    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

    r9ee87f6 r7fc092a  
    5454        SERVICE_NETWORKING,
    5555        SERVICE_LO,
    56         SERVICE_DP8390,
     56        SERVICE_NE2000,
    5757        SERVICE_ETHERNET,
    5858        SERVICE_NILDUMMY,
  • uspace/lib/c/include/net/icmp_common.h

    r9ee87f6 r7fc092a  
    4141#include <sys/time.h>
    4242
    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
    4545
    46 extern int icmp_connect_module(services_t, suseconds_t);
     46extern int icmp_connect_module(suseconds_t);
    4747
    4848#endif
  • uspace/lib/drv/generic/remote_usbhc.c

    r9ee87f6 r7fc092a  
    243243
    244244        // FIXME - answer according to outcome
    245         ipc_answer_0(trans->caller, EOK);
     245        ipc_answer_0(trans->caller, outcome);
    246246
    247247        free(trans);
     
    254254
    255255        // 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);
    257257
    258258        trans->size = actual_size;
  • uspace/lib/drv/include/usb_iface.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libdrv usb
     29/** @addtogroup libdrv
     30 * @addtogroup usb
    3031 * @{
    3132 */
  • uspace/lib/drv/include/usbhc_iface.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libdrv usb
     29/** @addtogroup libdrv
     30 * @addtogroup usb
    3031 * @{
    3132 */
  • uspace/lib/net/Makefile

    r9ee87f6 r7fc092a  
    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

    r9ee87f6 r7fc092a  
    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

    r9ee87f6 r7fc092a  
    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

    r9ee87f6 r7fc092a  
    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/icmp_header.h

    r9ee87f6 r7fc092a  
    4545
    4646/** 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)
    5348
    5449/** Echo specific data. */
    55 struct icmp_echo {
     50typedef struct icmp_echo {
    5651        /** Message idintifier. */
    5752        icmp_param_t identifier;
    5853        /** Message sequence number. */
    5954        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;
    6656
    6757/** Internet control message header. */
    68 struct icmp_header {
     58typedef struct icmp_header {
    6959        /** The type of the message. */
    7060        uint8_t type;
     
    8373         */
    8474        uint16_t checksum;
    85 
     75       
    8676        /** Message specific data. */
    8777        union {
    8878                /** Echo specific data. */
    89                 icmp_echo_t  echo;
     79                icmp_echo_t echo;
    9080                /** Proposed gateway value. */
    9181                in_addr_t gateway;
     
    10797                } param;
    10898        } un;
    109 } __attribute__ ((packed));
     99} __attribute__((packed)) icmp_header_t;
    110100
    111101#endif
  • uspace/lib/net/include/icmp_remote.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libnet 
     29/** @addtogroup libnet
    3030 *  @{
    3131 */
    3232
    33 #ifndef LIBNET_ICMP_INTERFACE_H_
    34 #define LIBNET_ICMP_INTERFACE_H_
     33#ifndef LIBNET_ICMP_REMOTE_H_
     34#define LIBNET_ICMP_REMOTE_H_
    3535
    3636#include <net/socket_codes.h>
     
    5454extern int icmp_source_quench_msg(int, packet_t *);
    5555extern 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 *);
     56extern int icmp_parameter_problem_msg(int, icmp_code_t, icmp_param_t,
     57    packet_t *);
    5758
    5859/*@}*/
  • uspace/lib/net/include/il_remote.h

    r9ee87f6 r7fc092a  
    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

    r9ee87f6 r7fc092a  
    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

    r9ee87f6 r7fc092a  
    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

    r9ee87f6 r7fc092a  
    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

    r9ee87f6 r7fc092a  
    3131 */
    3232
    33 #ifndef LIBNET_TL_LOCAL_H_
    34 #define LIBNET_TL_LOCAL_H_
     33#ifndef LIBNET_TL_SKEL_H_
     34#define LIBNET_TL_SKEL_H_
    3535
     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>
    3643#include <ipc/ipc.h>
    37 #include <async.h>
     44#include <ipc/services.h>
    3845
    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.
    4051 *
    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.
    4453 *
    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 *
    5260 */
    53 extern int tl_module_message_standalone(ipc_callid_t, ipc_call_t *,
     61extern int tl_initialize(int net_phone);
     62
     63/** Per-connection module initialization.
     64 *
     65 * This has to be implemented in user code.
     66 *
     67 */
     68extern 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 */
     83extern int tl_message(ipc_callid_t, ipc_call_t *,
    5484    ipc_call_t *, size_t *);
    5585
    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);
     86extern int tl_module_start(int);
    6887
    6988#endif
  • uspace/lib/net/netif/netif_skel.c

    r9ee87f6 r7fc092a  
    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

    r9ee87f6 r7fc092a  
    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/icmp_remote.c

    r9ee87f6 r7fc092a  
    3333/** @file
    3434 * ICMP interface implementation for remote modules.
    35  * @see icmp_interface.h
     35 * @see icmp_remote.h
    3636 */
    3737
    38 #include <icmp_interface.h>
     38#include <icmp_remote.h>
    3939#include <net/modules.h>
    4040#include <packet_client.h>
  • uspace/lib/net/tl/tl_common.c

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libnet 
     29/** @addtogroup libnet
    3030 * @{
    3131 */
     
    3939#include <packet_client.h>
    4040#include <packet_remote.h>
    41 #include <icmp_interface.h>
     41#include <icmp_remote.h>
    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

    r9ee87f6 r7fc092a  
    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

    r9ee87f6 r7fc092a  
    3636        src/class.c \
    3737        src/debug.c \
     38        src/dp.c \
    3839        src/drvpsync.c \
     40        src/dump.c \
    3941        src/hcdhubd.c \
    4042        src/hcdrv.c \
     
    4547        src/usb.c \
    4648        src/usbdrvreq.c \
    47         src/usbdrv.c
     49        src/usbdrv.c \
     50        src/usbmem.c
    4851
    4952include $(USPACE_PREFIX)/Makefile.common
  • uspace/lib/usb/include/usb/addrkeep.h

    • Property mode changed from 100644 to 120000
    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
     1hcd.h
  • uspace/lib/usb/include/usb/classes/classes.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/include/usb/classes/hid.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
     
    3939#include <driver.h>
    4040#include <usb/classes/hidparser.h>
     41#include <usb/descriptor.h>
    4142
    4243/** USB/HID device requests. */
     
    6364 */
    6465typedef 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;
    7071
    7172/** Standard USB HID descriptor.
     
    7374 * (See HID Specification, p.22)
    7475 *
    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).
    7779 */
    7880typedef 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         */
    8086        uint8_t length;
    8187        /** Descriptor type (USB_DESCTYPE_HID). */
     
    8591        /** Country code of localized hardware. */
    8692        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;
    91101} __attribute__ ((packed)) usb_standard_hid_descriptor_t;
    92102
     103/**
     104 *
     105 */
     106typedef 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 */
     118typedef struct {
     119        usb_standard_configuration_descriptor_t config_descriptor;
     120        usb_hid_iface_t *interfaces;
     121} usb_hid_configuration_t;
    93122
    94123/**
     
    99128typedef struct {
    100129        device_t *device;
     130        usb_hid_configuration_t *conf;
    101131        usb_address_t address;
    102132        usb_endpoint_t poll_endpoint;
     
    104134} usb_hid_dev_kbd_t;
    105135
     136// TODO: more configurations!
     137
    106138#endif
    107139/**
  • uspace/lib/usb/include/usb/classes/hidparser.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
     
    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/classes/hidut.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/include/usb/classes/hidutkbd.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/include/usb/classes/hub.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
     
    6868 *      For more information see Universal Serial Bus Specification Revision 1.1 chapter 11.16.2
    6969 */
    70 typedef struct hub_descriptor_type{
     70typedef struct usb_hub_descriptor_type {
    7171    /** Number of bytes in this descriptor, including this byte */
    7272    //uint8_t bDescLength;
  • uspace/lib/usb/include/usb/debug.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
     
    3535#ifndef LIBUSB_DEBUG_H_
    3636#define LIBUSB_DEBUG_H_
     37#include <stdio.h>
     38#include <usb/usb.h>
    3739
    3840void usb_dprintf(const char *tag, int level, const char *format, ...);
    3941void usb_dprintf_enable(const char *tag, int level);
    4042
     43void usb_dump_standard_descriptor(FILE *, const char *, const char *,
     44    const uint8_t *, size_t);
    4145
    4246#endif
     47/**
     48 * @}
     49 */
     50
  • uspace/lib/usb/include/usb/descriptor.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/include/usb/devreq.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/include/usb/dp.h

    r9ee87f6 r7fc092a  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2011 Vojtech Horky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup arp
     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  * 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>
    3741
    38 #ifndef NET_ARP_MODULE_H_
    39 #define NET_ARP_MODULE_H_
     42typedef struct {
     43        int child;
     44        int parent;
     45} usb_dp_descriptor_nesting_t;
    4046
    41 #include <ipc/ipc.h>
    42 #include <async.h>
     47typedef struct {
     48        usb_dp_descriptor_nesting_t *nesting;
     49} usb_dp_parser_t;
    4350
    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 *);
     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/include/usb/hcd.h

    • Property mode changed from 120000 to 100644
    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. */
     43typedef 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. */
     53typedef 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
     71void usb_address_keeping_init(usb_address_keeping_t *, usb_address_t);
     72
     73void usb_address_keeping_reserve_default(usb_address_keeping_t *);
     74void usb_address_keeping_release_default(usb_address_keeping_t *);
     75
     76usb_address_t usb_address_keeping_request(usb_address_keeping_t *);
     77int usb_address_keeping_release(usb_address_keeping_t *, usb_address_t);
     78void usb_address_keeping_devman_bind(usb_address_keeping_t *, usb_address_t,
     79    devman_handle_t);
     80usb_address_t usb_address_keeping_find(usb_address_keeping_t *,
     81    devman_handle_t);
     82
     83#endif
     84/**
     85 * @}
     86 */
  • uspace/lib/usb/include/usb/hcdhubd.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/include/usb/usb.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/include/usb/usbdrv.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/include/usb/usbmem.h

    r9ee87f6 r7fc092a  
    11/*
    2  * Copyright (c) 2009 Lukas Mejdrech
     2 * Copyright (c) 2010 Matus Dekanek
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    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 * @{
    3136 */
    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 *
    3656 */
    37 
    38 #ifndef NET_ARP_HEADER_H_
    39 #define NET_ARP_HEADER_H_
    4057
    4158#include <sys/types.h>
    4259
    43 /** Type definition of an ARP protocol header.
    44  * @see arp_header
    45  */
    46 typedef struct arp_header arp_header_t;
     60extern void * mman_malloc(
     61                size_t size,
     62                size_t alignment,
     63                unsigned long max_physical_address);
    4764
    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));
     65extern void * mman_getVA(void * addr);
    6966
    70 #endif
     67extern void * mman_getPA(void * addr);
     68
     69extern void mman_free(void * addr);
     70
     71
     72
     73
     74
    7175
    7276/** @}
    7377 */
     78
     79
     80#endif  /* USBMEM_H */
     81
  • uspace/lib/usb/src/addrkeep.c

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/src/class.c

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/src/debug.c

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/src/drvpsync.c

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/src/hcdhubd.c

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/src/hcdhubd_private.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/src/hcdrv.c

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/src/hidparser.c

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
     
    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/localdrv.c

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/src/recognise.c

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
     
    3939#include <errno.h>
    4040
     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 */
    4147static int usb_iface_get_hc_handle(device_t *dev, devman_handle_t *handle)
    4248{
     
    203209                uint8_t cur_descr_len = current_descriptor[0];
    204210                uint8_t cur_descr_type = current_descriptor[1];
     211
     212                if (cur_descr_len == 0) {
     213                        return ENOENT;
     214                }
    205215               
    206216                position += cur_descr_len;
     
    233243 * @param matches Match ids list to add matches to.
    234244 * @param address USB address of the attached device.
     245 * @param config_count Number of configurations the device has.
    235246 * @return Error code.
    236247 */
     
    338349/** Probe for device kind and register it in devman.
    339350 *
    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.
    343355 * @return Error code.
    344356 */
     
    346358    usb_address_t address, devman_handle_t *child_handle)
    347359{
     360        static size_t device_name_index = 0;
     361
    348362        device_t *child = NULL;
    349363        char *child_name = NULL;
     
    357371
    358372        /*
    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);
    362377        if (rc < 0) {
    363378                goto failure;
     
    381396        }
    382397       
     398        device_name_index++;
     399
    383400        return EOK;
    384401
  • uspace/lib/usb/src/remotedrv.c

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/src/usb.c

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/src/usbdrv.c

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
  • uspace/lib/usb/src/usbdrvreq.c

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusb usb
     29/** @addtogroup libusb
    3030 * @{
    3131 */
     
    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) \
     
    188188 * @param[in] phone Open phone to HC driver.
    189189 * @param[in] old_address Current address.
    190  * @param[in] address Address to be set.
     190 * @param[in] new_address Address to be set.
    191191 * @return Error code.
    192192 */
  • uspace/lib/usbvirt/include/usbvirt/device.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusbvirt usb
     29/** @addtogroup libusbvirt
    3030 * @{
    3131 */
  • uspace/lib/usbvirt/include/usbvirt/hub.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusbvirt usb
     29/** @addtogroup libusbvirt
    3030 * @{
    3131 */
  • uspace/lib/usbvirt/src/callback.c

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusbvirt usb
     29/** @addtogroup libusbvirt
    3030 * @{
    3131 */
     
    160160                        return;
    161161                }
    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);
    166169}
    167170
  • uspace/lib/usbvirt/src/ctrlpipe.c

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusbvirt usb
     29/** @addtogroup libusbvirt
    3030 * @{
    3131 */
  • uspace/lib/usbvirt/src/debug.c

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusbvirt usb
     29/** @addtogroup libusbvirt
    3030 * @{
    3131 */
  • uspace/lib/usbvirt/src/main.c

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusbvirt usb
     29/** @addtogroup libusbvirt
    3030 * @{
    3131 */
     
    183183/** Create necessary phones for communication with virtual HCD.
    184184 * This function wraps following calls:
    185  * -# open <code>/dev/devices/\\virt\\usbhc for reading
     185 * -# open <code>/dev/devices/\\virt\\usbhc</code> for reading
    186186 * -# access phone of file opened in previous step
    187187 * -# create callback through just opened phone
  • uspace/lib/usbvirt/src/private.h

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusbvirt usb
     29/** @addtogroup libusbvirt
    3030 * @{
    3131 */
  • uspace/lib/usbvirt/src/stdreq.c

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusbvirt usb
     29/** @addtogroup libusbvirt
    3030 * @{
    3131 */
  • uspace/lib/usbvirt/src/transaction.c

    r9ee87f6 r7fc092a  
    2727 */
    2828
    29 /** @addtogroup libusbvirt usb
     29/** @addtogroup libusbvirt
    3030 * @{
    3131 */
Note: See TracChangeset for help on using the changeset viewer.