Ignore:
Timestamp:
2011-02-20T15:46:48Z (14 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6bb83c7
Parents:
d81ef61c (diff), 0c00dac (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 usb/development

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/remote_usbhc.c

    rd81ef61c r50ba203  
    4040
    4141#define USB_MAX_PAYLOAD_SIZE 1020
     42#define HACK_MAX_PACKET_SIZE 8
     43#define HACK_MAX_PACKET_SIZE_INTERRUPT_IN 4
    4244
    4345static void remote_usbhc_get_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
    44 static void remote_usbhc_get_buffer(device_t *, void *, ipc_callid_t, ipc_call_t *);
    4546static void remote_usbhc_interrupt_out(device_t *, void *, ipc_callid_t, ipc_call_t *);
    4647static void remote_usbhc_interrupt_in(device_t *, void *, ipc_callid_t, ipc_call_t *);
     
    6465        remote_usbhc_get_address,
    6566
    66         remote_usbhc_get_buffer,
    67 
    6867        remote_usbhc_reserve_default_address,
    6968        remote_usbhc_release_default_address,
     
    9897typedef struct {
    9998        ipc_callid_t caller;
     99        ipc_callid_t data_caller;
    100100        void *buffer;
    101101        void *setup_packet;
     
    127127
    128128        trans->caller = caller;
     129        trans->data_caller = 0;
    129130        trans->buffer = NULL;
    130131        trans->setup_packet = NULL;
     
    155156}
    156157
    157 void remote_usbhc_get_buffer(device_t *device, void *iface,
    158     ipc_callid_t callid, ipc_call_t *call)
    159 {
    160         sysarg_t buffer_hash = DEV_IPC_GET_ARG1(*call);
    161         async_transaction_t * trans = (async_transaction_t *)buffer_hash;
    162         if (trans == NULL) {
    163                 async_answer_0(callid, ENOENT);
    164                 return;
    165         }
    166         if (trans->buffer == NULL) {
    167                 async_answer_0(callid, EINVAL);
    168                 async_transaction_destroy(trans);
    169                 return;
    170         }
    171 
    172         ipc_callid_t cid;
    173         size_t accepted_size;
    174         if (!async_data_read_receive(&cid, &accepted_size)) {
    175                 async_answer_0(callid, EINVAL);
    176                 async_transaction_destroy(trans);
    177                 return;
    178         }
    179 
    180         if (accepted_size > trans->size) {
    181                 accepted_size = trans->size;
    182         }
    183         async_data_read_finalize(cid, trans->buffer, accepted_size);
    184 
    185         async_answer_1(callid, EOK, accepted_size);
    186 
    187         async_transaction_destroy(trans);
    188 }
    189 
    190158void remote_usbhc_reserve_default_address(device_t *device, void *iface,
    191159    ipc_callid_t callid, ipc_call_t *call)
     
    197165                return;
    198166        }
    199 
    200         int rc = usb_iface->reserve_default_address(device);
     167       
     168        bool full_speed = DEV_IPC_GET_ARG1(*call);
     169       
     170        int rc = usb_iface->reserve_default_address(device, full_speed);
    201171
    202172        async_answer_0(callid, rc);
     
    227197                return;
    228198        }
     199       
     200        bool full_speed = DEV_IPC_GET_ARG1(*call);
    229201
    230202        usb_address_t address;
    231         int rc = usb_iface->request_address(device, &address);
     203        int rc = usb_iface->request_address(device, full_speed, &address);
    232204        if (rc != EOK) {
    233205                async_answer_0(callid, rc);
     
    274246
    275247static void callback_out(device_t *device,
    276     usb_transaction_outcome_t outcome, void *arg)
     248    int outcome, void *arg)
    277249{
    278250        async_transaction_t *trans = (async_transaction_t *)arg;
     
    284256
    285257static void callback_in(device_t *device,
    286     usb_transaction_outcome_t outcome, size_t actual_size, void *arg)
     258    int outcome, size_t actual_size, void *arg)
    287259{
    288260        async_transaction_t *trans = (async_transaction_t *)arg;
    289261
    290         if (outcome != USB_OUTCOME_OK) {
     262        if (outcome != EOK) {
    291263                async_answer_0(trans->caller, outcome);
     264                if (trans->data_caller) {
     265                        async_answer_0(trans->data_caller, EINTR);
     266                }
    292267                async_transaction_destroy(trans);
    293268                return;
     
    295270
    296271        trans->size = actual_size;
    297         async_answer_1(trans->caller, USB_OUTCOME_OK, (sysarg_t)trans);
     272
     273        if (trans->data_caller) {
     274                async_data_read_finalize(trans->data_caller,
     275                    trans->buffer, actual_size);
     276        }
     277
     278        async_answer_0(trans->caller, EOK);
     279
     280        async_transaction_destroy(trans);
    298281}
    299282
     
    345328        trans->size = len;
    346329
    347         int rc = transfer_func(device, target, buffer, len,
     330        int rc = transfer_func(device, target, HACK_MAX_PACKET_SIZE,
     331            buffer, len,
    348332            callback_out, trans);
    349333
     
    376360        };
    377361
     362        ipc_callid_t data_callid;
     363        if (!async_data_read_receive(&data_callid, &len)) {
     364                async_answer_0(callid, EPARTY);
     365                return;
     366        }
     367
    378368        async_transaction_t *trans = async_transaction_create(callid);
    379369        if (trans == NULL) {
     
    381371                return;
    382372        }
     373        trans->data_caller = data_callid;
    383374        trans->buffer = malloc(len);
    384375        trans->size = len;
    385376
    386         int rc = transfer_func(device, target, trans->buffer, len,
     377        int rc = transfer_func(device, target, HACK_MAX_PACKET_SIZE_INTERRUPT_IN,
     378            trans->buffer, len,
    387379            callback_in, trans);
    388380
     
    556548                .endpoint = DEV_IPC_GET_ARG2(*call)
    557549        };
     550        size_t data_buffer_len = DEV_IPC_GET_ARG3(*call);
    558551
    559552        int rc;
     
    562555        void *data_buffer = NULL;
    563556        size_t setup_packet_len = 0;
    564         size_t data_buffer_len = 0;
    565557
    566558        rc = async_data_write_accept(&setup_packet, false,
     
    570562                return;
    571563        }
    572         rc = async_data_write_accept(&data_buffer, false,
    573             1, USB_MAX_PAYLOAD_SIZE, 0, &data_buffer_len);
    574         if (rc != EOK) {
    575                 async_answer_0(callid, rc);
    576                 free(setup_packet);
    577                 return;
     564
     565        if (data_buffer_len > 0) {
     566                rc = async_data_write_accept(&data_buffer, false,
     567                    1, USB_MAX_PAYLOAD_SIZE, 0, &data_buffer_len);
     568                if (rc != EOK) {
     569                        async_answer_0(callid, rc);
     570                        free(setup_packet);
     571                        return;
     572                }
    578573        }
    579574
     
    589584        trans->size = data_buffer_len;
    590585
    591         rc = usb_iface->control_write(device, target,
     586        rc = usb_iface->control_write(device, target, HACK_MAX_PACKET_SIZE,
    592587            setup_packet, setup_packet_len,
    593588            data_buffer, data_buffer_len,
     
    612607        }
    613608
    614         size_t data_len = DEV_IPC_GET_ARG3(*call);
    615609        usb_target_t target = {
    616610                .address = DEV_IPC_GET_ARG1(*call),
     
    622616        void *setup_packet = NULL;
    623617        size_t setup_packet_len = 0;
     618        size_t data_len = 0;
    624619
    625620        rc = async_data_write_accept(&setup_packet, false,
     
    627622        if (rc != EOK) {
    628623                async_answer_0(callid, rc);
     624                return;
     625        }
     626
     627        ipc_callid_t data_callid;
     628        if (!async_data_read_receive(&data_callid, &data_len)) {
     629                async_answer_0(callid, EPARTY);
     630                free(setup_packet);
    629631                return;
    630632        }
     
    636638                return;
    637639        }
     640        trans->data_caller = data_callid;
    638641        trans->setup_packet = setup_packet;
    639642        trans->size = data_len;
     
    645648        }
    646649
    647         rc = usb_iface->control_read(device, target,
     650        rc = usb_iface->control_read(device, target, HACK_MAX_PACKET_SIZE,
    648651            setup_packet, setup_packet_len,
    649652            trans->buffer, trans->size,
Note: See TracChangeset for help on using the changeset viewer.