Changeset b828907 in mainline for uspace/lib


Ignore:
Timestamp:
2012-07-20T20:29:54Z (13 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
34bc2fe
Parents:
4cdac68 (diff), 6de2d766 (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 with mainline

Location:
uspace/lib
Files:
5 added
24 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/Makefile

    r4cdac68 rb828907  
    7171        generic/device/nic.c \
    7272        generic/device/pci.c \
     73        generic/device/ahci.c \
    7374        generic/elf/elf_load.c \
    7475        generic/event.c \
  • uspace/lib/c/include/ipc/dev_iface.h

    r4cdac68 rb828907  
    5151        /** Interface provided by USB HID devices. */
    5252        USBHID_DEV_IFACE,
     53        /** Interface provided by AHCI devices. */
     54        AHCI_DEV_IFACE,
    5355
    5456        DEV_IFACE_MAX
  • uspace/lib/drv/Makefile

    r4cdac68 rb828907  
    4444        generic/remote_pci.c \
    4545        generic/remote_usbhc.c \
    46         generic/remote_usbhid.c
     46        generic/remote_usbhid.c \
     47        generic/remote_ahci.c
    4748
    4849include $(USPACE_PREFIX)/Makefile.common
  • uspace/lib/drv/generic/dev_iface.c

    r4cdac68 rb828907  
    4646#include "remote_usbhid.h"
    4747#include "remote_pci.h"
     48#include "remote_ahci.h"
    4849
    4950static iface_dipatch_table_t remote_ifaces = {
     
    5556                &remote_usb_iface,
    5657                &remote_usbhc_iface,
    57                 &remote_usbhid_iface
     58                &remote_usbhid_iface,
     59                &remote_ahci_iface
    5860        }
    5961};
  • uspace/lib/drv/generic/remote_usb.c

    r4cdac68 rb828907  
    5656{
    5757        if (!exch)
    58                 return EINVAL;
     58                return EBADMEM;
    5959        sysarg_t addr;
    6060        const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
     
    6565        return ret;
    6666}
    67 /*----------------------------------------------------------------------------*/
     67
    6868/** Tell interface number given device can use.
    6969 * @param[in] exch IPC communication exchange
     
    7575{
    7676        if (!exch)
    77                 return EINVAL;
     77                return EBADMEM;
    7878        sysarg_t iface_no;
    7979        const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
     
    8383        return ret;
    8484}
    85 /*----------------------------------------------------------------------------*/
     85
    8686/** Tell devman handle of device host controller.
    8787 * @param[in] exch IPC communication exchange
     
    9292{
    9393        if (!exch)
    94                 return EINVAL;
     94                return EBADMEM;
    9595        devman_handle_t h;
    9696        const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
     
    121121};
    122122
    123 /*----------------------------------------------------------------------------*/
     123
    124124void remote_usb_get_my_address(ddf_fun_t *fun, void *iface,
    125125    ipc_callid_t callid, ipc_call_t *call)
     
    140140        }
    141141}
    142 /*----------------------------------------------------------------------------*/
     142
    143143void remote_usb_get_my_interface(ddf_fun_t *fun, void *iface,
    144144    ipc_callid_t callid, ipc_call_t *call)
     
    159159        }
    160160}
    161 /*----------------------------------------------------------------------------*/
     161
    162162void remote_usb_get_hc_handle(ddf_fun_t *fun, void *iface,
    163163    ipc_callid_t callid, ipc_call_t *call)
  • uspace/lib/drv/generic/remote_usbhc.c

    r4cdac68 rb828907  
    165165{
    166166        if (!exch || !address)
    167                 return EINVAL;
     167                return EBADMEM;
    168168        sysarg_t new_address;
    169169        const int ret = async_req_4_1(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
     
    173173        return ret;
    174174}
    175 /*----------------------------------------------------------------------------*/
     175
    176176int usbhc_bind_address(async_exch_t *exch, usb_address_t address,
    177177    devman_handle_t handle)
    178178{
    179179        if (!exch)
    180                 return EINVAL;
     180                return EBADMEM;
    181181        return async_req_3_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    182182            IPC_M_USBHC_BIND_ADDRESS, address, handle);
    183183}
    184 /*----------------------------------------------------------------------------*/
     184
    185185int usbhc_get_handle(async_exch_t *exch, usb_address_t address,
    186186    devman_handle_t *handle)
    187187{
    188188        if (!exch)
    189                 return EINVAL;
     189                return EBADMEM;
    190190        sysarg_t h;
    191191        const int ret = async_req_2_1(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
     
    195195        return ret;
    196196}
    197 /*----------------------------------------------------------------------------*/
     197
    198198int usbhc_release_address(async_exch_t *exch, usb_address_t address)
    199199{
    200200        if (!exch)
    201                 return EINVAL;
     201                return EBADMEM;
    202202        return async_req_2_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    203203            IPC_M_USBHC_RELEASE_ADDRESS, address);
    204204}
    205 /*----------------------------------------------------------------------------*/
     205
    206206int usbhc_register_endpoint(async_exch_t *exch, usb_address_t address,
    207207    usb_endpoint_t endpoint, usb_transfer_type_t type,
     
    209209{
    210210        if (!exch)
    211                 return EINVAL;
     211                return EBADMEM;
    212212        const usb_target_t target =
    213213            {{ .address = address, .endpoint = endpoint }};
     
    220220#undef _PACK2
    221221}
    222 /*----------------------------------------------------------------------------*/
     222
    223223int usbhc_unregister_endpoint(async_exch_t *exch, usb_address_t address,
    224224    usb_endpoint_t endpoint, usb_direction_t direction)
    225225{
    226226        if (!exch)
    227                 return EINVAL;
     227                return EBADMEM;
    228228        return async_req_4_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    229229            IPC_M_USBHC_UNREGISTER_ENDPOINT, address, endpoint, direction);
    230230}
    231 /*----------------------------------------------------------------------------*/
     231
    232232int usbhc_read(async_exch_t *exch, usb_address_t address,
    233233    usb_endpoint_t endpoint, uint64_t setup, void *data, size_t size,
    234234    size_t *rec_size)
    235235{
     236        if (!exch)
     237                return EBADMEM;
     238
    236239        if (size == 0 && setup == 0)
    237240                return EOK;
    238241
    239         if (!exch)
    240                 return EINVAL;
    241242        const usb_target_t target =
    242243            {{ .address = address, .endpoint = endpoint }};
     
    284285        return EOK;
    285286}
    286 /*----------------------------------------------------------------------------*/
     287
    287288int usbhc_write(async_exch_t *exch, usb_address_t address,
    288289    usb_endpoint_t endpoint, uint64_t setup, const void *data, size_t size)
    289290{
     291        if (!exch)
     292                return EBADMEM;
     293
    290294        if (size == 0 && setup == 0)
    291295                return EOK;
    292296
    293         if (!exch)
    294                 return EINVAL;
    295297        const usb_target_t target =
    296298            {{ .address = address, .endpoint = endpoint }};
     
    319321        return (int) opening_request_rc;
    320322}
    321 /*----------------------------------------------------------------------------*/
     323
    322324
    323325static void remote_usbhc_request_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     
    384386        return trans;
    385387}
    386 /*----------------------------------------------------------------------------*/
     388
    387389void remote_usbhc_request_address(ddf_fun_t *fun, void *iface,
    388390    ipc_callid_t callid, ipc_call_t *call)
     
    406408        }
    407409}
    408 /*----------------------------------------------------------------------------*/
     410
    409411void remote_usbhc_bind_address(ddf_fun_t *fun, void *iface,
    410412    ipc_callid_t callid, ipc_call_t *call)
     
    423425        async_answer_0(callid, ret);
    424426}
    425 /*----------------------------------------------------------------------------*/
     427
    426428void remote_usbhc_get_handle(ddf_fun_t *fun, void *iface,
    427429    ipc_callid_t callid, ipc_call_t *call)
     
    444446        }
    445447}
    446 /*----------------------------------------------------------------------------*/
     448
    447449void remote_usbhc_release_address(ddf_fun_t *fun, void *iface,
    448450    ipc_callid_t callid, ipc_call_t *call)
     
    460462        async_answer_0(callid, ret);
    461463}
    462 /*----------------------------------------------------------------------------*/
     464
    463465static void callback_out(ddf_fun_t *fun,
    464466    int outcome, void *arg)
     
    470472        async_transaction_destroy(trans);
    471473}
    472 /*----------------------------------------------------------------------------*/
     474
    473475static void callback_in(ddf_fun_t *fun,
    474476    int outcome, size_t actual_size, void *arg)
     
    494496        async_transaction_destroy(trans);
    495497}
    496 /*----------------------------------------------------------------------------*/
     498
    497499void remote_usbhc_register_endpoint(ddf_fun_t *fun, void *iface,
    498500    ipc_callid_t callid, ipc_call_t *call)
     
    594596        }
    595597}
    596 /*----------------------------------------------------------------------------*/
     598
    597599void remote_usbhc_write(
    598600    ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
  • uspace/lib/usbdev/include/usb/dev/usb_device_connection.h

    r4cdac68 rb828907  
    7272        return EOK;
    7373}
    74 /*----------------------------------------------------------------------------*/
     74
    7575/** Register endpoint on the device.
    7676 * @param instance device connection structure to use.
     
    9191            instance->address, ep, type, direction, packet_size, interval);
    9292}
    93 /*----------------------------------------------------------------------------*/
     93
    9494/** Unregister endpoint on the device.
    9595 * @param instance device connection structure
     
    105105            instance->address, ep, dir);
    106106}
    107 /*----------------------------------------------------------------------------*/
     107
    108108/** Get data from the device.
    109109 * @param[in] instance device connection structure to use.
     
    122122            instance->address, ep, setup, data, size, rsize);
    123123}
    124 /*----------------------------------------------------------------------------*/
     124
    125125/** Send data to the device.
    126126 * @param instance device connection structure to use.
     
    138138            instance->address, ep, setup, data, size);
    139139}
    140 /*----------------------------------------------------------------------------*/
     140
    141141/** Wrapper for read calls with no setup stage.
    142142 * @param[in] instance device connection structure.
     
    153153        return usb_device_control_read(instance, ep, 0, data, size, real_size);
    154154}
    155 /*----------------------------------------------------------------------------*/
     155
    156156/** Wrapper for write calls with no setup stage.
    157157 * @param instance device connection structure.
  • uspace/lib/usbdev/src/devdrv.c

    r4cdac68 rb828907  
    7474        return ddf_driver_main(&generic_driver);
    7575}
    76 /*----------------------------------------------------------------------------*/
     76
    7777/** Count number of pipes the driver expects.
    7878 *
     
    8787        return count;
    8888}
    89 /*----------------------------------------------------------------------------*/
     89
    9090/** Callback when a new device is supposed to be controlled by this driver.
    9191 *
     
    124124        return rc;
    125125}
    126 /*----------------------------------------------------------------------------*/
     126
    127127/** Callback when a device is supposed to be removed from the system.
    128128 *
     
    146146        return EOK;
    147147}
    148 /*----------------------------------------------------------------------------*/
     148
    149149/** Callback when a device was removed from the system.
    150150 *
     
    167167        return ret;
    168168}
    169 /*----------------------------------------------------------------------------*/
     169
    170170/** Destroy existing pipes of a USB device.
    171171 *
     
    178178        dev->pipes_count = 0;
    179179}
    180 /*----------------------------------------------------------------------------*/
     180
    181181/** Change interface setting of a device.
    182182 * This function selects new alternate setting of an interface by issuing
  • uspace/lib/usbdev/src/pipes.c

    r4cdac68 rb828907  
    5454        return usb_hc_connection_open(pipe->wire->hc_connection);
    5555}
    56 /*----------------------------------------------------------------------------*/
     56
    5757/** Terminate a long transfer on a pipe.
    5858 * @param pipe Pipe where to end the long transfer.
     
    6767        return usb_hc_connection_close(pipe->wire->hc_connection);
    6868}
    69 /*----------------------------------------------------------------------------*/
     69
    7070/** Try to clear endpoint halt of default control pipe.
    7171 *
     
    8585        pipe->auto_reset_halt = true;
    8686}
    87 /*----------------------------------------------------------------------------*/
     87
    8888/** Request a control read transfer on an endpoint pipe.
    8989 *
     
    135135        return rc;
    136136}
    137 /*----------------------------------------------------------------------------*/
     137
    138138/** Request a control write transfer on an endpoint pipe.
    139139 *
     
    182182        return rc;
    183183}
    184 /*----------------------------------------------------------------------------*/
     184
    185185/** Request a read (in) transfer on an endpoint pipe.
    186186 *
     
    227227        return rc;
    228228}
    229 /*----------------------------------------------------------------------------*/
     229
    230230/** Request a write (out) transfer on an endpoint pipe.
    231231 *
     
    259259            pipe->endpoint_no, buffer, size);
    260260}
    261 /*----------------------------------------------------------------------------*/
     261
    262262/** Initialize USB endpoint pipe.
    263263 *
     
    287287        return EOK;
    288288}
    289 /*----------------------------------------------------------------------------*/
     289
    290290/** Initialize USB endpoint pipe as the default zero control pipe.
    291291 *
     
    307307        return rc;
    308308}
    309 /*----------------------------------------------------------------------------*/
     309
    310310/** Register endpoint with the host controller.
    311311 *
     
    323323           pipe->direction, pipe->max_packet_size, interval);
    324324}
    325 /*----------------------------------------------------------------------------*/
     325
    326326/** Revert endpoint registration with the host controller.
    327327 *
  • uspace/lib/usbdev/src/pipesinit.c

    r4cdac68 rb828907  
    154154    usb_endpoint_mapping_t *mapping, size_t mapping_count,
    155155    usb_standard_interface_descriptor_t *interface,
    156     usb_standard_endpoint_descriptor_t *endpoint,
     156    usb_standard_endpoint_descriptor_t *endpoint_desc,
    157157    usb_device_connection_t *wire)
    158158{
     
    163163
    164164        /* Actual endpoint number is in bits 0..3 */
    165         const usb_endpoint_t ep_no = endpoint->endpoint_address & 0x0F;
     165        const usb_endpoint_t ep_no = endpoint_desc->endpoint_address & 0x0F;
    166166
    167167        const usb_endpoint_description_t description = {
    168168                /* Endpoint direction is set by bit 7 */
    169                 .direction = (endpoint->endpoint_address & 128)
     169                .direction = (endpoint_desc->endpoint_address & 128)
    170170                    ? USB_DIRECTION_IN : USB_DIRECTION_OUT,
    171171                /* Transfer type is in bits 0..2 and
    172172                 * the enum values corresponds 1:1 */
    173                 .transfer_type = endpoint->attributes & 3,
     173                .transfer_type = endpoint_desc->attributes & 3,
    174174
    175175                /* Get interface characteristics. */
     
    194194
    195195        int rc = usb_pipe_initialize(&ep_mapping->pipe, wire,
    196             ep_no, description.transfer_type, endpoint->max_packet_size,
     196            ep_no, description.transfer_type,
     197            uint16_usb2host(endpoint_desc->max_packet_size),
    197198            description.direction);
    198199        if (rc != EOK) {
     
    201202
    202203        ep_mapping->present = true;
    203         ep_mapping->descriptor = endpoint;
     204        ep_mapping->descriptor = endpoint_desc;
    204205        ep_mapping->interface = interface;
    205206
  • uspace/lib/usbdev/src/request.c

    r4cdac68 rb828907  
    114114  *     (in native endianness).
    115115  * @param actual_data_size Actual size of transfered data
    116   *     (in native endianness).
     116  *        (in native endianness).
    117117  * @return Error code.
    118118  * @retval EBADMEM @p pipe is NULL.
     
    147147                    | (request_type << 5) | recipient,
    148148                .request = request,
    149                 .value = value,
    150                 .index = index,
    151                 .length = (uint16_t) data_size,
     149                .value = uint16_host2usb(value),
     150                .index = uint16_host2usb(index),
     151                .length = uint16_host2usb(data_size),
    152152        };
    153153
     
    375375        usb_standard_device_descriptor_t descriptor_tmp;
    376376        int rc = usb_request_get_descriptor(pipe,
    377             USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE, 
     377            USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE,
    378378            USB_DESCTYPE_DEVICE, 0, 0,
    379379            &descriptor_tmp, sizeof(descriptor_tmp),
     
    435435        /* Everything is okay, copy the descriptor. */
    436436        memcpy(descriptor, &descriptor_tmp, sizeof(descriptor_tmp));
    437 
    438437        return EOK;
    439438}
     
    495494                return ENOENT;
    496495        }
    497         if (bare_config.total_length < sizeof(bare_config)) {
     496
     497        const size_t total_length = uint16_usb2host(bare_config.total_length);
     498        if (total_length < sizeof(bare_config)) {
    498499                return ELIMIT;
    499500        }
    500501
    501         void *buffer = malloc(bare_config.total_length);
     502        void *buffer = malloc(total_length);
    502503        if (buffer == NULL) {
    503504                return ENOMEM;
     
    506507        size_t transferred = 0;
    507508        rc = usb_request_get_full_configuration_descriptor(pipe, index,
    508             buffer, bare_config.total_length, &transferred);
     509            buffer, total_length, &transferred);
    509510        if (rc != EOK) {
    510511                free(buffer);
     
    512513        }
    513514
    514         if (transferred != bare_config.total_length) {
     515        if (transferred != total_length) {
    515516                free(buffer);
    516517                return ELIMIT;
     
    522523
    523524        if (descriptor_size != NULL) {
    524                 *descriptor_size = bare_config.total_length;
     525                *descriptor_size = total_length;
    525526        }
    526527
  • uspace/lib/usbhid/include/usb/hid/hid_report_items.h

    r4cdac68 rb828907  
    3838#include <stdint.h>
    3939
    40 /*---------------------------------------------------------------------------*/
     40
    4141/*
    4242 * Item prefix
     
    5656#define USB_HID_ITEM_IS_LONG(data)      (data == 0xFE)
    5757
    58 /*---------------------------------------------------------------------------*/
     58
    5959/*
    6060 * Extended usage macros
     
    7070#define USB_HID_EXTENDED_USAGE(usage)           (usage & 0xFFFF)
    7171
    72 /*---------------------------------------------------------------------------*/
     72
    7373/*
    7474 * Input/Output/Feature Item flags
     
    142142#define USB_HID_ITEM_FLAG_BUFFERED(flags)       ((flags & 0x100) == 0x100)
    143143
    144 /*---------------------------------------------------------------------------*/
     144
    145145
    146146/* MAIN ITEMS */
     
    185185#define USB_HID_REPORT_TAG_END_COLLECTION       0xC
    186186
    187 /*---------------------------------------------------------------------------*/
     187
    188188
    189189/* GLOBAL ITEMS */
     
    272272#define USB_HID_REPORT_TAG_POP                  0xB
    273273
    274 /*---------------------------------------------------------------------------*/
     274
    275275
    276276/* LOCAL ITEMS */
     
    347347#define USB_HID_REPORT_TAG_DELIMITER            0xA
    348348
    349 /*---------------------------------------------------------------------------*/
     349
    350350
    351351#endif
  • uspace/lib/usbhid/include/usb/hid/hidpath.h

    r4cdac68 rb828907  
    4141
    4242
    43 /*---------------------------------------------------------------------------*/
     43
    4444/*
    4545 * Flags of usage paths comparison modes.
     
    7373#define USB_HID_PATH_COMPARE_ANYWHERE           8
    7474
    75 /*----------------------------------------------------------------------------*/
     75
    7676/**
    7777 * Item of usage path structure. Last item of linked list describes one item
     
    9393
    9494
    95 /*---------------------------------------------------------------------------*/
     95
    9696/**
    9797 * USB HID usage path structure.
     
    112112} usb_hid_report_path_t;
    113113
    114 /*---------------------------------------------------------------------------*/
     114
    115115usb_hid_report_path_t *usb_hid_report_path(void);
    116116
  • uspace/lib/usbhid/include/usb/hid/hidtypes.h

    r4cdac68 rb828907  
    3939#include <adt/list.h>
    4040
    41 /*---------------------------------------------------------------------------*/
     41
    4242
    4343/**
     
    6969        (((x) < 0 ) ? ((1 << (size)) + (x)) : (x))
    7070
    71 /*---------------------------------------------------------------------------*/
     71
    7272
    7373/**
     
    8686} usb_hid_report_type_t;
    8787
    88 /*---------------------------------------------------------------------------*/
     88
    8989
    9090/**
     
    111111       
    112112} usb_hid_report_t;
    113 /*---------------------------------------------------------------------------*/
     113
    114114
    115115/**
     
    135135        link_t reports_link;
    136136} usb_hid_report_description_t;
    137 /*---------------------------------------------------------------------------*/
     137
    138138
    139139/**
     
    202202} usb_hid_report_field_t;
    203203
    204 /*---------------------------------------------------------------------------*/
     204
    205205
    206206/**
     
    287287        int in_delimiter;
    288288} usb_hid_report_item_t;
    289 /*---------------------------------------------------------------------------*/
     289
    290290/**
    291291 * Enum of the keyboard modifiers
     
    314314        USB_HID_MOD_RGUI
    315315};
    316 /*---------------------------------------------------------------------------*/
     316
    317317
    318318
  • uspace/lib/usbhid/include/usb/hid/request.h

    r4cdac68 rb828907  
    4242#include <usb/dev/pipes.h>
    4343
    44 /*----------------------------------------------------------------------------*/
     44
    4545
    4646int usbhid_req_set_report(usb_pipe_t *ctrl_pipe, int iface_no,
     
    6161int usbhid_req_get_idle(usb_pipe_t *ctrl_pipe, int iface_no, uint8_t *duration);
    6262
    63 /*----------------------------------------------------------------------------*/
     63
    6464
    6565#endif /* USB_KBD_HIDREQ_H_ */
  • uspace/lib/usbhid/src/hiddescriptor.c

    r4cdac68 rb828907  
    4141#include <assert.h>
    4242
    43 /*---------------------------------------------------------------------------*/
     43
    4444/*
    4545 * Constants defining current parsing mode for correct parsing of the set of
     
    6161#define INSIDE_DELIMITER_SET    2
    6262
    63 /*---------------------------------------------------------------------------*/
     63
    6464       
    6565/** The new report item flag. Used to determine when the item is completly
     
    7878#define USB_HID_UNKNOWN_TAG             -99
    7979
    80 /*---------------------------------------------------------------------------*/
     80
    8181/**
    8282 * Checks if given collection path is already present in report structure and
     
    124124}
    125125
    126 /*---------------------------------------------------------------------------*/
     126
    127127/**
    128128 * Initialize the report descriptor parser structure
     
    147147}
    148148
    149 /*---------------------------------------------------------------------------*/
     149
    150150
    151151/**
     
    314314        return EOK;
    315315}
    316 /*---------------------------------------------------------------------------*/
     316
    317317/**
    318318 * Finds description of report with given report_id and of given type in
     
    348348        return NULL;
    349349}
    350 /*---------------------------------------------------------------------------*/
     350
    351351
    352352/** Parse HID report descriptor.
     
    536536}
    537537
    538 /*---------------------------------------------------------------------------*/
     538
    539539
    540540/**
     
    871871        return EOK;
    872872}
    873 /*---------------------------------------------------------------------------*/
     873
    874874
    875875/**
     
    892892        return result;
    893893}
    894 /*---------------------------------------------------------------------------*/
     894
    895895
    896896/**
     
    941941
    942942}
    943 /*---------------------------------------------------------------------------*/
     943
    944944
    945945/**
     
    972972        }
    973973}
    974 /*---------------------------------------------------------------------------*/
     974
    975975
    976976
     
    10221022        return;
    10231023}
    1024 /*---------------------------------------------------------------------------*/
     1024
    10251025
    10261026/**
  • uspace/lib/usbhid/src/hidparser.c

    r4cdac68 rb828907  
    4141#include <assert.h>
    4242
    43 /*---------------------------------------------------------------------------*/
     43
    4444/*
    4545 * Data translation private functions
     
    5252        int32_t value);
    5353
    54 /*---------------------------------------------------------------------------*/
     54
    5555
    5656static int usb_pow(int a, int b)
     
    6868        }
    6969}
    70 /*---------------------------------------------------------------------------*/
     70
    7171
    7272/** Returns size of report of specified report id and type in items
     
    117117        }
    118118}
    119 /*---------------------------------------------------------------------------*/
     119
    120120
    121121/** Parse and act upon a HID report.
     
    192192}
    193193
    194 /*---------------------------------------------------------------------------*/
     194
    195195/**
    196196 * Translate data from the report as specified in report descriptor item
     
    274274}
    275275
    276 /*---------------------------------------------------------------------------*/
     276
    277277/* OUTPUT API */
    278278
     
    431431}
    432432
    433 /*---------------------------------------------------------------------------*/
     433
    434434/**
    435435 * Translate given data for putting them into the outoput report
     
    476476}
    477477
    478 /*---------------------------------------------------------------------------*/
     478
    479479/**
    480480 * Clones given state table
     
    497497}
    498498
    499 /*---------------------------------------------------------------------------*/
     499
    500500/**
    501501 * Function for sequence walking through the report. Returns next field in the
     
    552552}
    553553
    554 /*---------------------------------------------------------------------------*/
     554
    555555/**
    556556 * Returns next report_id of report of specified type. If zero is given than
     
    600600}
    601601
    602 /*---------------------------------------------------------------------------*/
     602
    603603/**
    604604 * Reset all local items in given state table
  • uspace/lib/usbhid/src/hidpath.c

    r4cdac68 rb828907  
    4141#include <assert.h>
    4242
    43 /*---------------------------------------------------------------------------*/
     43
    4444/**
    4545 * Compares two usages if they are same or not or one of the usages is not
     
    6363        ((page1 == page2) || (page1 == 0) || (page2 == 0))
    6464
    65 /*---------------------------------------------------------------------------*/
     65
    6666/**
    6767 * Appends one item (couple of usage_path and usage) into the usage path
     
    9393}
    9494
    95 /*---------------------------------------------------------------------------*/
     95
    9696/**
    9797 * Removes last item from the usage path structure
     
    114114}
    115115
    116 /*---------------------------------------------------------------------------*/
     116
    117117/**
    118118 * Nulls last item of the usage path structure.
     
    133133}
    134134
    135 /*---------------------------------------------------------------------------*/
     135
    136136/**
    137137 * Modifies last item of usage path structure by given usage page or usage
     
    164164}
    165165
    166 /*---------------------------------------------------------------------------*/
     166
    167167/**
    168168 *
     
    188188}
    189189
    190 /*---------------------------------------------------------------------------*/
     190
    191191/**
    192192 * Compares two usage paths structures
     
    354354}
    355355
    356 /*---------------------------------------------------------------------------*/
     356
    357357/**
    358358 * Allocates and initializes new usage path structure.
     
    376376}
    377377
    378 /*---------------------------------------------------------------------------*/
     378
    379379/**
    380380 * Releases given usage path structure.
     
    395395}
    396396
    397 /*---------------------------------------------------------------------------*/
     397
    398398/**
    399399 * Clone content of given usage path to the new one
     
    441441}
    442442
    443 /*---------------------------------------------------------------------------*/
     443
    444444/**
    445445 * Sets report id in usage path structure
  • uspace/lib/usbhid/src/hidreport.c

    r4cdac68 rb828907  
    5050#include <usb/hid/hidreport.h>
    5151
    52 static int usb_hid_get_report_descriptor(usb_device_t *dev, 
     52static int usb_hid_get_report_descriptor(usb_device_t *dev,
    5353    uint8_t **report_desc, size_t *size)
    5454{
     
    6969         * First nested descriptor of the configuration descriptor.
    7070         */
    71         const uint8_t *d = 
    72             usb_dp_get_nested_descriptor(&parser, &parser_data, 
     71        const uint8_t *d =
     72            usb_dp_get_nested_descriptor(&parser, &parser_data,
    7373            dev->descriptors.configuration);
    7474       
     
    7878        int i = 0;
    7979        while (d != NULL && i < dev->interface_no) {
    80                 d = usb_dp_get_sibling_descriptor(&parser, &parser_data, 
     80                d = usb_dp_get_sibling_descriptor(&parser, &parser_data,
    8181                    dev->descriptors.configuration, d);
    8282                ++i;
     
    9999         */
    100100        while (d != NULL && *(d + 1) != USB_DESCTYPE_HID) {
    101                 d = usb_dp_get_sibling_descriptor(&parser, &parser_data, 
     101                d = usb_dp_get_sibling_descriptor(&parser, &parser_data,
    102102                    iface_desc, d);
    103103        }
     
    114114        }
    115115       
    116         usb_standard_hid_descriptor_t *hid_desc = 
     116        usb_standard_hid_descriptor_t *hid_desc =
    117117            (usb_standard_hid_descriptor_t *)d;
    118118       
    119         uint16_t length =  hid_desc->report_desc_info.length;
     119        uint16_t length = uint16_usb2host(hid_desc->report_desc_info.length);
    120120        size_t actual_size = 0;
    121121
     
    161161}
    162162
    163 /*----------------------------------------------------------------------------*/
     163
    164164
    165165int usb_hid_process_report_descriptor(usb_device_t *dev,
  • uspace/lib/usbhid/src/hidreq.c

    r4cdac68 rb828907  
    4545#include <usb/hid/request.h>
    4646
    47 /*----------------------------------------------------------------------------*/
     47
    4848/**
    4949 * Send Set Report request to the HID device.
     
    9797}
    9898
    99 /*----------------------------------------------------------------------------*/
     99
    100100/**
    101101 * Send Set Protocol request to the HID device.
     
    145145}
    146146
    147 /*----------------------------------------------------------------------------*/
     147
    148148/**
    149149 * Send Set Idle request to the HID device.
     
    195195}
    196196
    197 /*----------------------------------------------------------------------------*/
     197
    198198/**
    199199 * Send Get Report request to the HID device.
     
    251251}
    252252
    253 /*----------------------------------------------------------------------------*/
     253
    254254/**
    255255 * Send Get Protocol request to the HID device.
     
    310310}
    311311
    312 /*----------------------------------------------------------------------------*/
     312
    313313/**
    314314 * Send Get Idle request to the HID device.
     
    373373}
    374374
    375 /*----------------------------------------------------------------------------*/
     375
    376376
    377377/**
  • uspace/lib/usbhost/src/endpoint.c

    r4cdac68 rb828907  
    7272        return instance;
    7373}
    74 /*----------------------------------------------------------------------------*/
     74
    7575/** Properly dispose of endpoint_t structure.
    7676 * @param instance endpoint_t structure.
     
    8484        free(instance);
    8585}
    86 /*----------------------------------------------------------------------------*/
     86
    8787/** Set device specific data and hooks.
    8888 * @param instance endpoint_t structure.
     
    101101        fibril_mutex_unlock(&instance->guard);
    102102}
    103 /*----------------------------------------------------------------------------*/
     103
    104104/** Clear device specific data and hooks.
    105105 * @param instance endpoint_t structure.
     
    115115        fibril_mutex_unlock(&instance->guard);
    116116}
    117 /*----------------------------------------------------------------------------*/
     117
    118118/** Mark the endpoint as active and block access for further fibrils.
    119119 * @param instance endpoint_t structure.
     
    128128        fibril_mutex_unlock(&instance->guard);
    129129}
    130 /*----------------------------------------------------------------------------*/
     130
    131131/** Mark the endpoint as inactive and allow access for further fibrils.
    132132 * @param instance endpoint_t structure.
     
    140140        fibril_condvar_signal(&instance->avail);
    141141}
    142 /*----------------------------------------------------------------------------*/
     142
    143143/** Get the value of toggle bit.
    144144 * @param instance endpoint_t structure.
     
    156156        return ret;
    157157}
    158 /*----------------------------------------------------------------------------*/
     158
    159159/** Set the value of toggle bit.
    160160 * @param instance endpoint_t structure.
  • uspace/lib/usbhost/src/usb_device_manager.c

    r4cdac68 rb828907  
    6161        return new_address;
    6262}
    63 /*----------------------------------------------------------------------------*/
     63
    6464/** Initialize device manager structure.
    6565 *
     
    8282        fibril_mutex_initialize(&instance->guard);
    8383}
    84 /*----------------------------------------------------------------------------*/
     84
    8585/** Request USB address.
    8686 * @param instance usb_device_manager
     
    124124        return EOK;
    125125}
    126 /*----------------------------------------------------------------------------*/
     126
    127127/** Bind USB address to devman handle.
    128128 *
     
    156156        return EOK;
    157157}
    158 /*----------------------------------------------------------------------------*/
     158
    159159/** Release used USB address.
    160160 *
     
    182182        return EOK;
    183183}
    184 /*----------------------------------------------------------------------------*/
     184
    185185/** Find USB address associated with the device.
    186186 *
     
    205205        return ENOENT;
    206206}
    207 /*----------------------------------------------------------------------------*/
     207
    208208/** Find devman handle and speed assigned to USB address.
    209209 *
  • uspace/lib/usbhost/src/usb_endpoint_manager.c

    r4cdac68 rb828907  
    6161            && (address == ep->address);
    6262}
    63 /*----------------------------------------------------------------------------*/
     63
    6464/** Get list that holds endpoints for given address.
    6565 * @param instance usb_endpoint_manager structure, non-null.
     
    7373        return &instance->endpoint_lists[addr % ENDPOINT_LIST_COUNT];
    7474}
    75 /*----------------------------------------------------------------------------*/
     75
    7676/** Internal search function, works on locked structure.
    7777 * @param instance usb_endpoint_manager structure, non-null.
     
    9797        return NULL;
    9898}
    99 /*----------------------------------------------------------------------------*/
     99
    100100/** Calculate bandwidth that needs to be reserved for communication with EP.
    101101 * Calculation follows USB 1.1 specification.
     
    145145        }
    146146}
    147 /*----------------------------------------------------------------------------*/
     147
    148148/** Initialize to default state.
    149149 * You need to provide valid bw_count function if you plan to use
     
    168168        return EOK;
    169169}
    170 /*----------------------------------------------------------------------------*/
     170
    171171/** Check setup packet data for signs of toggle reset.
    172172 *
     
    227227        }
    228228}
    229 /*----------------------------------------------------------------------------*/
     229
    230230/** Register endpoint structure.
    231231 * Checks for duplicates.
     
    262262        return EOK;
    263263}
    264 /*----------------------------------------------------------------------------*/
     264
    265265/** Unregister endpoint structure.
    266266 * Checks for duplicates.
     
    286286        return EOK;
    287287}
    288 /*----------------------------------------------------------------------------*/
     288
    289289/** Find endpoint_t representing the given communication route.
    290290 * @param instance usb_endpoint_manager, non-null.
     
    301301        return ep;
    302302}
    303 /*----------------------------------------------------------------------------*/
     303
    304304/** Create and register new endpoint_t structure.
    305305 * @param instance usb_endpoint_manager structure, non-null.
     
    364364        return EOK;
    365365}
    366 /*----------------------------------------------------------------------------*/
     366
    367367/** Unregister and destroy endpoint_t structure representing given route.
    368368 * @param instance usb_endpoint_manager structure, non-null.
     
    395395        return EOK;
    396396}
    397 /*----------------------------------------------------------------------------*/
     397
    398398/** Unregister and destroy all endpoints using given address.
    399399 * @param instance usb_endpoint_manager structure, non-null.
  • uspace/lib/usbhost/src/usb_transfer_batch.c

    r4cdac68 rb828907  
    9696        return instance;
    9797}
    98 /*----------------------------------------------------------------------------*/
     98
    9999/** Correctly dispose all used data structures.
    100100 *
     
    116116        free(instance);
    117117}
    118 /*----------------------------------------------------------------------------*/
     118
    119119/** Prepare data and call the right callback.
    120120 *
Note: See TracChangeset for help on using the changeset viewer.