Changes in / [1c6f4ff:fec47d4] in mainline


Ignore:
Location:
uspace/drv
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/batch.c

    r1c6f4ff rfec47d4  
    8080 * transaction and callback.
    8181 */
    82 usb_transfer_batch_t * batch_get(ddf_fun_t *fun, endpoint_t *ep,
    83     char *buffer, size_t buffer_size, char* setup_buffer, size_t setup_size,
     82usb_transfer_batch_t * batch_get(ddf_fun_t *fun, usb_target_t target,
     83    usb_transfer_type_t transfer_type, size_t max_packet_size,
     84    usb_speed_t speed, char *buffer, size_t buffer_size,
     85    char* setup_buffer, size_t setup_size,
    8486    usbhc_iface_transfer_in_callback_t func_in,
    85     usbhc_iface_transfer_out_callback_t func_out, void *arg)
    86 {
    87         assert(ep);
     87    usbhc_iface_transfer_out_callback_t func_out, void *arg, endpoint_t *ep
     88    )
     89{
    8890        assert(func_in == NULL || func_out == NULL);
    8991        assert(func_in != NULL || func_out != NULL);
     
    101103        CHECK_NULL_DISPOSE_RETURN(instance,
    102104            "Failed to allocate batch instance.\n");
    103         usb_target_t target =
    104             { .address = ep->address, .endpoint = ep->endpoint };
    105105        usb_transfer_batch_init(instance, target,
    106             ep->transfer_type, ep->speed, ep->max_packet_size,
     106            transfer_type, speed, max_packet_size,
    107107            buffer, NULL, buffer_size, NULL, setup_size, func_in,
    108108            func_out, arg, fun, ep, NULL);
     
    115115        instance->private_data = data;
    116116
    117         data->transfers =
    118             (buffer_size + ep->max_packet_size - 1) / ep->max_packet_size;
    119         if (ep->transfer_type == USB_TRANSFER_CONTROL) {
     117        data->transfers = (buffer_size + max_packet_size - 1) / max_packet_size;
     118        if (transfer_type == USB_TRANSFER_CONTROL) {
    120119                data->transfers += 2;
    121120        }
     
    179178                            instance, i, data->tds[i].status);
    180179                        td_print_status(&data->tds[i]);
    181                         assert(instance->ep != NULL);
    182 
    183                         endpoint_toggle_set(instance->ep,
    184                             td_toggle(&data->tds[i]));
     180                        if (instance->ep != NULL)
     181                                endpoint_toggle_set(instance->ep,
     182                                    td_toggle(&data->tds[i]));
    185183                        if (i > 0)
    186184                                goto substract_ret;
  • uspace/drv/uhci-hcd/batch.h

    r1c6f4ff rfec47d4  
    4444
    4545usb_transfer_batch_t * batch_get(
    46     ddf_fun_t *fun, endpoint_t *ep, char *buffer, size_t size,
    47     char *setup_buffer, size_t setup_size,
     46    ddf_fun_t *fun,
     47                usb_target_t target,
     48    usb_transfer_type_t transfer_type,
     49                size_t max_packet_size,
     50    usb_speed_t speed,
     51                char *buffer,
     52                size_t size,
     53                char *setup_buffer,
     54                size_t setup_size,
    4855    usbhc_iface_transfer_in_callback_t func_in,
    4956    usbhc_iface_transfer_out_callback_t func_out,
    50     void *arg);
     57                void *arg,
     58                endpoint_t *ep
     59                );
    5160
    5261void batch_dispose(usb_transfer_batch_t *instance);
  • uspace/drv/uhci-hcd/iface.c

    r1c6f4ff rfec47d4  
    4141#include "hc.h"
    4242
    43 static inline int setup_batch(
    44     ddf_fun_t *fun, usb_target_t target, usb_direction_t direction,
    45     void *data, size_t size, void * setup_data, size_t setup_size,
    46     usbhc_iface_transfer_in_callback_t in,
    47     usbhc_iface_transfer_out_callback_t out, void *arg, const char* name,
    48     hc_t **hc, usb_transfer_batch_t **batch)
    49 {
    50         assert(hc);
    51         assert(batch);
    52         assert(fun);
    53         *hc = fun_to_hc(fun);
    54         assert(*hc);
    55 
    56         size_t res_bw;
    57         endpoint_t *ep = usb_endpoint_manager_get_ep(&(*hc)->ep_manager,
    58             target.address, target.endpoint, direction, &res_bw);
    59         if (ep == NULL) {
    60                 usb_log_error("Endpoint(%d:%d) not registered for %s.\n",
    61                     target.address, target.endpoint, name);
    62                 return ENOENT;
    63         }
    64 
    65         const size_t bw = bandwidth_count_usb11(
    66             ep->speed, ep->transfer_type, size, ep->max_packet_size);
    67         if (res_bw < bw) {
    68                 usb_log_error("Endpoint(%d:%d) %s needs %zu bw "
    69                     "but only %zu is reserved.\n",
    70                     name, target.address, target.endpoint, bw, res_bw);
    71                 return ENOSPC;
    72         }
    73         usb_log_debug("%s %d:%d %zu(%zu).\n",
    74             name, target.address, target.endpoint, size, ep->max_packet_size);
    75 
    76         assert(ep->speed ==
    77             usb_device_keeper_get_speed(&(*hc)->manager, target.address));
    78 //      assert(ep->max_packet_size == max_packet_size);
    79 //      assert(ep->transfer_type == USB_TRANSFER_CONTROL);
    80 
    81         *batch =
    82             batch_get(fun, ep, data, size, setup_data, setup_size,
    83                 in, out, arg);
    84         if (!batch)
    85                 return ENOMEM;
    86         return EOK;
    87 }
    88 
    89 
    9043/** Reserve default address interface function
    9144 *
     
    262215    size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg)
    263216{
    264         usb_transfer_batch_t *batch = NULL;
    265         hc_t *hc = NULL;
    266         int ret = setup_batch(fun, target, USB_DIRECTION_OUT, data, size,
    267             NULL, 0, NULL, callback, arg, "Interrupt OUT", &hc, &batch);
    268         if (ret != EOK)
    269                 return ret;
     217        assert(fun);
     218        hc_t *hc = fun_to_hc(fun);
     219        assert(hc);
     220
     221        usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n",
     222            target.address, target.endpoint, size, max_packet_size);
     223
     224        size_t res_bw;
     225        endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,
     226            target.address, target.endpoint, USB_DIRECTION_OUT, &res_bw);
     227        if (ep == NULL) {
     228                usb_log_error("Endpoint(%d:%d) not registered for INT OUT.\n",
     229                        target.address, target.endpoint);
     230                return ENOENT;
     231        }
     232        const size_t bw = bandwidth_count_usb11(ep->speed, ep->transfer_type,
     233            size, ep->max_packet_size);
     234        if (res_bw < bw)
     235        {
     236                usb_log_error("Endpoint(%d:%d) INT IN needs %zu bw "
     237                    "but only %zu is reserved.\n",
     238                    target.address, target.endpoint, bw, res_bw);
     239                return ENOENT;
     240        }
     241        assert(ep->speed ==
     242            usb_device_keeper_get_speed(&hc->manager, target.address));
     243        assert(ep->max_packet_size == max_packet_size);
     244        assert(ep->transfer_type == USB_TRANSFER_INTERRUPT);
     245
     246        usb_transfer_batch_t *batch =
     247            batch_get(fun, target, ep->transfer_type, ep->max_packet_size,
     248                ep->speed, data, size, NULL, 0, NULL, callback, arg, ep);
     249        if (!batch)
     250                return ENOMEM;
    270251        batch_interrupt_out(batch);
    271         ret = hc_schedule(hc, batch);
     252        const int ret = hc_schedule(hc, batch);
    272253        if (ret != EOK) {
    273254                batch_dispose(batch);
     
    291272    size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg)
    292273{
    293         usb_transfer_batch_t *batch = NULL;
    294         hc_t *hc = NULL;
    295         int ret = setup_batch(fun, target, USB_DIRECTION_IN, data, size,
    296             NULL, 0, callback, NULL, arg, "Interrupt IN", &hc, &batch);
    297         if (ret != EOK)
    298                 return ret;
     274        assert(fun);
     275        hc_t *hc = fun_to_hc(fun);
     276        assert(hc);
     277
     278        usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n",
     279            target.address, target.endpoint, size, max_packet_size);
     280
     281        size_t res_bw;
     282        endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,
     283            target.address, target.endpoint, USB_DIRECTION_IN, &res_bw);
     284        if (ep == NULL) {
     285                usb_log_error("Endpoint(%d:%d) not registered for INT IN.\n",
     286                    target.address, target.endpoint);
     287                return ENOENT;
     288        }
     289        const size_t bw = bandwidth_count_usb11(ep->speed, ep->transfer_type,
     290            size, ep->max_packet_size);
     291        if (res_bw < bw)
     292        {
     293                usb_log_error("Endpoint(%d:%d) INT IN needs %zu bw "
     294                    "but only %zu bw is reserved.\n",
     295                    target.address, target.endpoint, bw, res_bw);
     296                return ENOENT;
     297        }
     298
     299        assert(ep->speed ==
     300            usb_device_keeper_get_speed(&hc->manager, target.address));
     301        assert(ep->max_packet_size == max_packet_size);
     302        assert(ep->transfer_type == USB_TRANSFER_INTERRUPT);
     303
     304        usb_transfer_batch_t *batch =
     305            batch_get(fun, target, ep->transfer_type, ep->max_packet_size,
     306                ep->speed, data, size, NULL, 0, callback, NULL, arg, ep);
     307        if (!batch)
     308                return ENOMEM;
    299309        batch_interrupt_in(batch);
    300         ret = hc_schedule(hc, batch);
     310        const int ret = hc_schedule(hc, batch);
    301311        if (ret != EOK) {
    302312                batch_dispose(batch);
     
    320330    size_t size, usbhc_iface_transfer_out_callback_t callback, void *arg)
    321331{
    322         usb_transfer_batch_t *batch = NULL;
    323         hc_t *hc = NULL;
    324         int ret = setup_batch(fun, target, USB_DIRECTION_OUT, data, size,
    325             NULL, 0, NULL, callback, arg, "Bulk OUT", &hc, &batch);
    326         if (ret != EOK)
    327                 return ret;
     332        assert(fun);
     333        hc_t *hc = fun_to_hc(fun);
     334        assert(hc);
     335
     336        usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n",
     337            target.address, target.endpoint, size, max_packet_size);
     338
     339        endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,
     340            target.address, target.endpoint, USB_DIRECTION_OUT, NULL);
     341        if (ep == NULL) {
     342                usb_log_error("Endpoint(%d:%d) not registered for BULK OUT.\n",
     343                        target.address, target.endpoint);
     344                return ENOENT;
     345        }
     346        assert(ep->speed ==
     347            usb_device_keeper_get_speed(&hc->manager, target.address));
     348        assert(ep->max_packet_size == max_packet_size);
     349        assert(ep->transfer_type == USB_TRANSFER_BULK);
     350
     351        usb_transfer_batch_t *batch =
     352            batch_get(fun, target, ep->transfer_type, ep->max_packet_size,
     353                ep->speed, data, size, NULL, 0, NULL, callback, arg, ep);
     354        if (!batch)
     355                return ENOMEM;
    328356        batch_bulk_out(batch);
    329         ret = hc_schedule(hc, batch);
     357        const int ret = hc_schedule(hc, batch);
    330358        if (ret != EOK) {
    331359                batch_dispose(batch);
     
    349377    size_t size, usbhc_iface_transfer_in_callback_t callback, void *arg)
    350378{
    351         usb_transfer_batch_t *batch = NULL;
    352         hc_t *hc = NULL;
    353         int ret = setup_batch(fun, target, USB_DIRECTION_IN, data, size,
    354             NULL, 0, callback, NULL, arg, "Bulk IN", &hc, &batch);
    355         if (ret != EOK)
    356                 return ret;
     379        assert(fun);
     380        hc_t *hc = fun_to_hc(fun);
     381        assert(hc);
     382        usb_log_debug("Bulk IN %d:%d %zu(%zu).\n",
     383            target.address, target.endpoint, size, max_packet_size);
     384
     385        endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,
     386            target.address, target.endpoint, USB_DIRECTION_IN, NULL);
     387        if (ep == NULL) {
     388                usb_log_error("Endpoint(%d:%d) not registered for BULK IN.\n",
     389                        target.address, target.endpoint);
     390                return ENOENT;
     391        }
     392        assert(ep->speed ==
     393            usb_device_keeper_get_speed(&hc->manager, target.address));
     394        assert(ep->max_packet_size == max_packet_size);
     395        assert(ep->transfer_type == USB_TRANSFER_BULK);
     396
     397        usb_transfer_batch_t *batch =
     398            batch_get(fun, target, ep->transfer_type, ep->max_packet_size,
     399                ep->speed, data, size, NULL, 0, callback, NULL, arg, ep);
     400        if (!batch)
     401                return ENOMEM;
    357402        batch_bulk_in(batch);
    358         ret = hc_schedule(hc, batch);
     403        const int ret = hc_schedule(hc, batch);
    359404        if (ret != EOK) {
    360405                batch_dispose(batch);
     
    381426    usbhc_iface_transfer_out_callback_t callback, void *arg)
    382427{
    383         usb_transfer_batch_t *batch = NULL;
    384         hc_t *hc = NULL;
    385         int ret = setup_batch(fun, target, USB_DIRECTION_BOTH, data, size,
    386             setup_data, setup_size, NULL, callback, arg, "Control WRITE",
    387             &hc, &batch);
    388         if (ret != EOK)
    389                 return ret;
     428        assert(fun);
     429        hc_t *hc = fun_to_hc(fun);
     430        assert(hc);
     431        usb_speed_t speed =
     432            usb_device_keeper_get_speed(&hc->manager, target.address);
     433        usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n",
     434            speed, target.address, target.endpoint, size, max_packet_size);
     435        endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,
     436            target.address, target.endpoint, USB_DIRECTION_BOTH, NULL);
     437        if (ep == NULL) {
     438                usb_log_warning("Endpoint(%d:%d) not registered for CONTROL.\n",
     439                        target.address, target.endpoint);
     440        }
     441
     442        if (setup_size != 8)
     443                return EINVAL;
     444
     445        usb_transfer_batch_t *batch =
     446            batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, speed,
     447                data, size, setup_data, setup_size, NULL, callback, arg, ep);
     448        if (!batch)
     449                return ENOMEM;
    390450        usb_device_keeper_reset_if_need(&hc->manager, target, setup_data);
    391451        batch_control_write(batch);
    392         ret = hc_schedule(hc, batch);
     452        const int ret = hc_schedule(hc, batch);
    393453        if (ret != EOK) {
    394454                batch_dispose(batch);
     
    415475    usbhc_iface_transfer_in_callback_t callback, void *arg)
    416476{
    417         usb_transfer_batch_t *batch = NULL;
    418         hc_t *hc = NULL;
    419         int ret = setup_batch(fun, target, USB_DIRECTION_BOTH, data, size,
    420             setup_data, setup_size, callback, NULL, arg, "Control READ",
    421             &hc, &batch);
    422         if (ret != EOK)
    423                 return ret;
     477        assert(fun);
     478        hc_t *hc = fun_to_hc(fun);
     479        assert(hc);
     480        usb_speed_t speed =
     481            usb_device_keeper_get_speed(&hc->manager, target.address);
     482
     483        usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n",
     484            speed, target.address, target.endpoint, size, max_packet_size);
     485        endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,
     486            target.address, target.endpoint, USB_DIRECTION_BOTH, NULL);
     487        if (ep == NULL) {
     488                usb_log_warning("Endpoint(%d:%d) not registered for CONTROL.\n",
     489                        target.address, target.endpoint);
     490        }
     491        usb_transfer_batch_t *batch =
     492            batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, speed,
     493                data, size, setup_data, setup_size, callback, NULL, arg, ep);
     494        if (!batch)
     495                return ENOMEM;
    424496        batch_control_read(batch);
    425         ret = hc_schedule(hc, batch);
     497        const int ret = hc_schedule(hc, batch);
    426498        if (ret != EOK) {
    427499                batch_dispose(batch);
  • uspace/drv/uhci-rhd/root_hub.h

    r1c6f4ff rfec47d4  
    4040
    4141#define UHCI_ROOT_HUB_PORT_COUNT 2
    42 #define ROOT_HUB_WAIT_USEC 250000 /* 250 miliseconds */
     42#define ROOT_HUB_WAIT_USEC 5000000 /* 5 seconds */
    4343
    4444typedef struct root_hub {
Note: See TracChangeset for help on using the changeset viewer.