Changeset 75732da in mainline for uspace/lib


Ignore:
Timestamp:
2010-12-13T07:20:20Z (15 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
309dea52
Parents:
84439d7 (diff), 37f7cfe (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/ changes

Location:
uspace/lib
Files:
10 added
22 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/adt/char_map.c

    r84439d7 r75732da  
    9090        }
    9191
    92         map->items[map->next]->c = * identifier;
    93         ++ identifier;
    94         ++ map->next;
    95         if ((length > 1) || ((length == 0) && (*identifier))) {
     92        map->items[map->next]->c = *identifier;
     93        identifier++;
     94        map->next++;
     95        if ((length > 1) || ((length == 0) && *identifier)) {
    9696                map->items[map->next - 1]->value = CHAR_MAP_NULL;
    9797                return char_map_add_item(map->items[map->next - 1], identifier,
     
    142142    const int value)
    143143{
    144         if (char_map_is_valid(map) && (identifier) &&
    145             ((length) || (*identifier))) {
     144        if (char_map_is_valid(map) && identifier && (length || *identifier)) {
    146145                int index;
    147146
    148                 for (index = 0; index < map->next; ++ index) {
     147                for (index = 0; index < map->next; index++) {
    149148                        if (map->items[index]->c != *identifier)
    150149                                continue;
    151150                               
    152                         ++ identifier;
    153                         if((length > 1) || ((length == 0) && (*identifier))) {
     151                        identifier++;
     152                        if((length > 1) || ((length == 0) && *identifier)) {
    154153                                return char_map_add(map->items[index],
    155154                                    identifier, length ? length - 1 : 0, value);
     
    178177
    179178                map->magic = 0;
    180                 for (index = 0; index < map->next; ++index)
     179                for (index = 0; index < map->next; index++)
    181180                        char_map_destroy(map->items[index]);
    182181
     
    207206                return NULL;
    208207
    209         if (length || (*identifier)) {
     208        if (length || *identifier) {
    210209                int index;
    211210
    212                 for (index = 0; index < map->next; ++index) {
     211                for (index = 0; index < map->next; index++) {
    213212                        if (map->items[index]->c == *identifier) {
    214                                 ++identifier;
     213                                identifier++;
    215214                                if (length == 1)
    216215                                        return map->items[index];
  • uspace/lib/c/generic/devman.c

    r84439d7 r75732da  
    116116{
    117117        ipc_call_t answer;
    118         async_send_1(phone, DEVMAN_ADD_MATCH_ID, match_id->score, &answer);
     118        aid_t req = async_send_1(phone, DEVMAN_ADD_MATCH_ID, match_id->score, &answer);
    119119        int retval = async_data_write_start(phone, match_id->id, str_size(match_id->id));
    120         return retval; 
     120        async_wait_for(req, NULL);
     121        return retval;
    121122}
    122123
  • uspace/lib/c/include/adt/generic_field.h

    r84439d7 r75732da  
    9191                        } \
    9292                        field->items[field->next] = value; \
    93                         ++field->next; \
     93                        field->next++; \
    9494                        field->items[field->next] = NULL; \
    9595                        return field->next - 1; \
     
    108108                        int index; \
    109109                        field->magic = 0; \
    110                         for (index = 0; index < field->next; ++ index) { \
     110                        for (index = 0; index < field->next; index++) { \
    111111                                if (field->items[index]) \
    112112                                        free(field->items[index]); \
  • uspace/lib/c/include/errno.h

    r84439d7 r75732da  
    8383#define ENOTCONN        (-10057)
    8484
    85 /** The requested operation was not performed.
    86  *  Try again later.
    87  */
    88 #define TRY_AGAIN       (-11002)
     85/** The requested operation was not performed. Try again later. */
     86#define EAGAIN          (-11002)
    8987
    9088/** No data.
  • uspace/lib/c/include/ipc/dev_iface.h

    r84439d7 r75732da  
    5454        DEV_IFACE_ID(DEV_FIRST_CUSTOM_METHOD_IDX)
    5555
     56/*
     57 * The first argument is actually method (as the "real" method is used
     58 * for indexing into interfaces.
     59 */
     60
     61#define DEV_IPC_GET_ARG1(call) IPC_GET_ARG2((call))
     62#define DEV_IPC_GET_ARG2(call) IPC_GET_ARG3((call))
     63#define DEV_IPC_GET_ARG3(call) IPC_GET_ARG4((call))
     64#define DEV_IPC_GET_ARG4(call) IPC_GET_ARG5((call))
     65
    5666
    5767#endif
  • uspace/lib/c/include/ipc/vfs.h

    r84439d7 r75732da  
    3636#define LIBC_IPC_VFS_H_
    3737
     38#include <ipc/ipc.h>
    3839#include <sys/types.h>
    39 #include <ipc/ipc.h>
     40#include <bool.h>
    4041
    4142#define FS_NAME_MAXLEN  20
     
    5556        /** Unique identifier of the fs. */
    5657        char name[FS_NAME_MAXLEN + 1];
     58        bool concurrent_read_write;
     59        bool write_retains_size;
    5760} vfs_info_t;
    5861
  • uspace/lib/drv/generic/driver.c

    r84439d7 r75732da  
    381381}
    382382
     383/** Wrapper for child_device_register for devices with single match id.
     384 *
     385 * @param parent Parent device.
     386 * @param child_name Child device name.
     387 * @param child_match_id Child device match id.
     388 * @param child_match_score Child device match score.
     389 * @return Error code.
     390 */
     391int child_device_register_wrapper(device_t *parent, const char *child_name,
     392    const char *child_match_id, int child_match_score,
     393    devman_handle_t *child_handle)
     394{
     395        device_t *child = NULL;
     396        match_id_t *match_id = NULL;
     397        int rc;
     398
     399        child = create_device();
     400        if (child == NULL) {
     401                rc = ENOMEM;
     402                goto failure;
     403        }
     404
     405        child->name = child_name;
     406
     407        match_id = create_match_id();
     408        if (match_id == NULL) {
     409                rc = ENOMEM;
     410                goto failure;
     411        }
     412
     413        match_id->id = child_match_id;
     414        match_id->score = child_match_score;
     415        add_match_id(&child->match_ids, match_id);
     416
     417        rc = child_device_register(child, parent);
     418        if (EOK != rc)
     419                goto failure;
     420
     421        if (child_handle != NULL) {
     422                *child_handle = child->handle;
     423        }
     424        return EOK;
     425
     426failure:
     427        if (match_id != NULL) {
     428                match_id->id = NULL;
     429                delete_match_id(match_id);
     430        }
     431
     432        if (child != NULL) {
     433                child->name = NULL;
     434                delete_device(child);
     435        }
     436
     437        return rc;
     438}
     439
    383440int driver_main(driver_t *drv)
    384441{
  • uspace/lib/drv/generic/remote_usbhc.c

    r84439d7 r75732da  
    108108        }
    109109
    110         devman_handle_t handle = IPC_GET_ARG1(*call);
     110        devman_handle_t handle = DEV_IPC_GET_ARG1(*call);
    111111
    112112        usb_address_t address;
     
    122122    ipc_callid_t callid, ipc_call_t *call)
    123123{
    124         ipcarg_t buffer_hash = IPC_GET_ARG1(*call);
     124        ipcarg_t buffer_hash = DEV_IPC_GET_ARG1(*call);
    125125        async_transaction_t * trans = (async_transaction_t *)buffer_hash;
    126126        if (trans == NULL) {
     
    144144                accepted_size = trans->size;
    145145        }
    146         async_data_read_finalize(callid, trans->buffer, accepted_size);
     146        async_data_read_finalize(cid, trans->buffer, accepted_size);
    147147
    148148        ipc_answer_1(callid, EOK, accepted_size);
     
    211211        }
    212212
    213         usb_address_t address = (usb_address_t) IPC_GET_ARG1(*call);
    214         devman_handle_t handle = (devman_handle_t) IPC_GET_ARG2(*call);
     213        usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call);
     214        devman_handle_t handle = (devman_handle_t) DEV_IPC_GET_ARG2(*call);
    215215
    216216        int rc = usb_iface->bind_address(device, address, handle);
     
    229229        }
    230230
    231         usb_address_t address = (usb_address_t) IPC_GET_ARG1(*call);
     231        usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call);
    232232
    233233        int rc = usb_iface->release_address(device, address);
     
    275275        }
    276276
    277         size_t expected_len = IPC_GET_ARG3(*call);
     277        size_t expected_len = DEV_IPC_GET_ARG3(*call);
    278278        usb_target_t target = {
    279                 .address = IPC_GET_ARG1(*call),
    280                 .endpoint = IPC_GET_ARG2(*call)
     279                .address = DEV_IPC_GET_ARG1(*call),
     280                .endpoint = DEV_IPC_GET_ARG2(*call)
    281281        };
    282282
     
    327327        }
    328328
    329         size_t len = IPC_GET_ARG3(*call);
     329        size_t len = DEV_IPC_GET_ARG3(*call);
    330330        usb_target_t target = {
    331                 .address = IPC_GET_ARG1(*call),
    332                 .endpoint = IPC_GET_ARG2(*call)
     331                .address = DEV_IPC_GET_ARG1(*call),
     332                .endpoint = DEV_IPC_GET_ARG2(*call)
    333333        };
    334334
     
    384384
    385385        usb_target_t target = {
    386                 .address = IPC_GET_ARG1(*call),
    387                 .endpoint = IPC_GET_ARG2(*call)
     386                .address = DEV_IPC_GET_ARG1(*call),
     387                .endpoint = DEV_IPC_GET_ARG2(*call)
    388388        };
    389389
  • uspace/lib/drv/include/driver.h

    r84439d7 r75732da  
    199199
    200200int child_device_register(device_t *, device_t *);
     201int child_device_register_wrapper(device_t *, const char *, const char *, int,
     202    devman_handle_t *);
    201203
    202204
  • uspace/lib/usb/Makefile

    r84439d7 r75732da  
    3333
    3434SOURCES = \
     35        src/addrkeep.c \
     36        src/class.c \
     37        src/debug.c \
     38        src/drvpsync.c \
    3539        src/hcdhubd.c \
    3640        src/hcdrv.c \
     41        src/hidparser.c \
    3742        src/localdrv.c \
     43        src/recognise.c \
    3844        src/remotedrv.c \
    3945        src/usb.c \
     46        src/usbdrvreq.c \
    4047        src/usbdrv.c
    4148
  • uspace/lib/usb/include/usb/classes/classes.h

    r84439d7 r75732da  
    6060} usb_class_t;
    6161
     62const char *usb_str_class(usb_class_t);
    6263
    6364#endif
  • uspace/lib/usb/include/usb/classes/hid.h

    r84439d7 r75732da  
    3636#define LIBUSB_HID_H_
    3737
     38#include <usb/usb.h>
     39#include <driver.h>
     40#include <usb/classes/hidparser.h>
     41
    3842/** USB/HID device requests. */
    3943typedef enum {
     
    5458} usb_hid_protocol_t;
    5559
     60/** Part of standard USB HID descriptor specifying one class descriptor.
     61 *
     62 * (See HID Specification, p.22)
     63 */
     64typedef 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;
     70
     71/** Standard USB HID descriptor.
     72 *
     73 * (See HID Specification, p.22)
     74 *
     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.
     77 */
     78typedef struct {
     79        /** Size of this descriptor in bytes. */
     80        uint8_t length;
     81        /** Descriptor type (USB_DESCTYPE_HID). */
     82        uint8_t descriptor_type;
     83        /** HID Class Specification release. */
     84        uint16_t spec_release;
     85        /** Country code of localized hardware. */
     86        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;
     91} __attribute__ ((packed)) usb_standard_hid_descriptor_t;
     92
     93
     94/**
     95 * @brief USB/HID keyboard device type.
     96 *
     97 * Quite dummy right now.
     98 */
     99typedef struct {
     100        device_t *device;
     101        usb_address_t address;
     102        usb_endpoint_t poll_endpoint;
     103        usb_hid_report_parser_t *parser;
     104} usb_hid_dev_kbd_t;
     105
    56106#endif
    57107/**
  • uspace/lib/usb/include/usb/classes/hub.h

    r84439d7 r75732da  
    177177
    178178/** @brief hub class request codes*/
     179/// \TODO these are duplicit to standart descriptors
    179180typedef enum {
    180181    /**  */
     
    213214usb_hub_descriptor_t * usb_deserialize_hub_desriptor(void * sdescriptor);
    214215
    215 /**
    216  * @brief create hub structure instance
    217  *
    218  * @param device
    219  * @return
    220  */
    221 usb_hcd_hub_info_t * usb_create_hub_info(device_t * device);
    222216
    223217
  • uspace/lib/usb/include/usb/devreq.h

    r84439d7 r75732da  
    3838#include <ipc/ipc.h>
    3939#include <async.h>
     40#include <usb/usb.h>
     41#include <usb/descriptor.h>
    4042
    4143/** Standard device request. */
     
    8385} __attribute__ ((packed)) usb_device_request_setup_packet_t;
    8486
     87int usb_drv_req_set_address(int, usb_address_t, usb_address_t);
     88int usb_drv_req_get_device_descriptor(int, usb_address_t,
     89    usb_standard_device_descriptor_t *);
     90int usb_drv_req_get_bare_configuration_descriptor(int, usb_address_t, int,
     91    usb_standard_configuration_descriptor_t *);
     92int usb_drv_req_get_full_configuration_descriptor(int, usb_address_t, int,
     93    void *, size_t, size_t *);
     94
     95
    8596#endif
    8697/**
  • uspace/lib/usb/include/usb/hcdhubd.h

    r84439d7 r75732da  
    6565} usb_hcd_attached_device_info_t;
    6666
    67 /** Information about attached hub. */
    68 typedef struct {
    69         /** Number of ports. */
    70         size_t port_count;
    71         /** General device info. */
    72         usb_hcd_attached_device_info_t *device;
    73         /** Link to other hubs. */
    74         link_t link;
    75 } usb_hcd_hub_info_t;
    7667
    7768/** Host controller device. */
  • uspace/lib/usb/include/usb/usb.h

    r84439d7 r75732da  
    6969typedef int usb_address_t;
    7070
     71/** Default USB address. */
     72#define USB_ADDRESS_DEFAULT 0
     73/** Maximum address number in USB 1.1. */
     74#define USB11_ADDRESS_MAX 128
     75
    7176/** USB endpoint number type.
    7277 * Negative values could be used to indicate error.
  • uspace/lib/usb/include/usb/usbdrv.h

    r84439d7 r75732da  
    3636#define LIBUSB_USBDRV_H_
    3737
    38 #include "usb.h"
     38#include <usb/usb.h>
    3939#include <driver.h>
     40#include <usb/devreq.h>
     41#include <usb/descriptor.h>
    4042
    4143int usb_drv_hc_connect(device_t *, unsigned int);
     
    5456    void *, size_t, size_t *, usb_handle_t *);
    5557
     58int usb_drv_psync_interrupt_out(int, usb_target_t, void *, size_t);
     59int usb_drv_psync_interrupt_in(int, usb_target_t, void *, size_t, size_t *);
     60
     61
     62
    5663int usb_drv_async_control_write_setup(int, usb_target_t,
    5764    void *, size_t, usb_handle_t *);
     
    6067int usb_drv_async_control_write_status(int, usb_target_t,
    6168    usb_handle_t *);
     69
     70int usb_drv_psync_control_write_setup(int, usb_target_t, void *, size_t);
     71int usb_drv_psync_control_write_data(int, usb_target_t, void *, size_t);
     72int usb_drv_psync_control_write_status(int, usb_target_t);
     73
     74int usb_drv_psync_control_write(int, usb_target_t,
     75    void *, size_t, void *, size_t);
     76
    6277
    6378int usb_drv_async_control_read_setup(int, usb_target_t,
     
    6883    usb_handle_t *);
    6984
     85int usb_drv_psync_control_read_setup(int, usb_target_t, void *, size_t);
     86int usb_drv_psync_control_read_data(int, usb_target_t, void *, size_t, size_t *);
     87int usb_drv_psync_control_read_status(int, usb_target_t);
     88
     89int usb_drv_psync_control_read(int, usb_target_t,
     90    void *, size_t, void *, size_t, size_t *);
     91
     92
     93
    7094int usb_drv_async_wait_for(usb_handle_t);
     95
     96int usb_drv_create_device_match_ids(int, match_id_list_t *, usb_address_t);
     97int usb_drv_register_child_in_devman(int, device_t *, usb_address_t,
     98    devman_handle_t *);
     99
    71100
    72101#endif
  • uspace/lib/usb/src/remotedrv.c

    r84439d7 r75732da  
    300300 */
    301301static void remote_in_callback(usb_hc_device_t *hc,
    302     usb_transaction_outcome_t outcome, size_t actual_size, void *arg)
     302    size_t actual_size, usb_transaction_outcome_t outcome, void *arg)
    303303{
    304304        transfer_info_t *transfer = (transfer_info_t *) arg;
  • uspace/lib/usb/src/usbdrv.c

    r84439d7 r75732da  
    3636#include <usbhc_iface.h>
    3737#include <errno.h>
     38#include <str_error.h>
    3839
    3940/** Information about pending transaction on HC. */
     
    7172        devman_handle_t handle;
    7273
    73         rc = devman_device_get_handle("/vhc", &handle, 0);
     74        rc = devman_device_get_handle("/virt/usbhc", &handle, 0);
    7475        if (rc != EOK) {
    7576                return rc;
     
    9091{
    9192        ipcarg_t address;
    92         int rc = async_req_1_1(phone, IPC_M_USBHC_GET_ADDRESS,
     93        int rc = async_req_2_1(phone, DEV_IFACE_ID(USBHC_DEV_IFACE),
     94            IPC_M_USBHC_GET_ADDRESS,
    9395            dev->handle, &address);
    9496
    9597        if (rc != EOK) {
     98                printf("usb_drv_get_my_address over %d failed: %s\n", phone, str_error(rc));
    9699                return rc;
    97100        }
     
    107110int usb_drv_reserve_default_address(int phone)
    108111{
    109         return async_req_0_0(phone, IPC_M_USBHC_RESERVE_DEFAULT_ADDRESS);
     112        return async_req_1_0(phone, DEV_IFACE_ID(USBHC_DEV_IFACE),
     113            IPC_M_USBHC_RESERVE_DEFAULT_ADDRESS);
    110114}
    111115
     
    117121int usb_drv_release_default_address(int phone)
    118122{
    119         return async_req_0_0(phone, IPC_M_USBHC_RELEASE_DEFAULT_ADDRESS);
     123        return async_req_1_0(phone, DEV_IFACE_ID(USBHC_DEV_IFACE),
     124            IPC_M_USBHC_RELEASE_DEFAULT_ADDRESS);
    120125}
    121126
     
    128133{
    129134        ipcarg_t address;
    130         int rc = async_req_0_1(phone, IPC_M_USBHC_REQUEST_ADDRESS, &address);
     135        int rc = async_req_1_1(phone, DEV_IFACE_ID(USBHC_DEV_IFACE),
     136            IPC_M_USBHC_REQUEST_ADDRESS, &address);
    131137        if (rc != EOK) {
    132138                return rc;
     
    146152    devman_handle_t handle)
    147153{
    148         int rc = async_req_2_0(phone, IPC_M_USBHC_BIND_ADDRESS,
     154        int rc = async_req_3_0(phone, DEV_IFACE_ID(USBHC_DEV_IFACE),
     155            IPC_M_USBHC_BIND_ADDRESS,
    149156            address, handle);
    150157
     
    160167int usb_drv_release_address(int phone, usb_address_t address)
    161168{
    162         return async_req_1_0(phone, IPC_M_USBHC_RELEASE_ADDRESS, address);
     169        return async_req_2_0(phone, DEV_IFACE_ID(USBHC_DEV_IFACE),
     170            IPC_M_USBHC_RELEASE_ADDRESS, address);
    163171}
    164172
  • uspace/lib/usbvirt/src/callback.c

    r84439d7 r75732da  
    153153         * If the request was processed, we will send data back.
    154154         */
    155         if (rc == EOK) {
     155        if ((rc == EOK) && (expected_len > 0)) {
    156156                size_t receive_len;
    157157                ipc_callid_t callid;
  • uspace/lib/usbvirt/src/main.c

    r84439d7 r75732da  
    183183/** Create necessary phones for communication with virtual HCD.
    184184 * This function wraps following calls:
    185  * -# open <code>/dev/devices/\\vhc</code> for reading
     185 * -# open <code>/dev/devices/\\virt\\usbhc for reading
    186186 * -# access phone of file opened in previous step
    187187 * -# create callback through just opened phone
     
    203203        }
    204204       
    205         const char *vhc_path = "/vhc";
     205        const char *vhc_path = "/virt/usbhc";
    206206        int rc;
    207207        devman_handle_t handle;
  • uspace/lib/usbvirt/src/transaction.c

    r84439d7 r75732da  
    183183                                actual_size = size;
    184184                        }
     185                        device->lib_debug(device, 1, USBVIRT_DEBUGTAG_TRANSACTION,
     186                            "in transaction: will copy %zu bytes", actual_size);
    185187                        if (actual_size > 0) {
    186188                                memcpy(buffer, transfer->data, actual_size);
Note: See TracChangeset for help on using the changeset viewer.