Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 365e29e2 in mainline


Ignore:
Timestamp:
2011-09-14T19:25:06Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
bdd8ad2f
Parents:
56e9fb0
Message:

usb: Use new target packing scheme for IPC.

Location:
uspace/lib
Files:
3 edited

Legend:

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

    r56e9fb0 r365e29e2  
    238238        }
    239239
    240         usb_target_t target = {
    241                 {.address = DEV_IPC_GET_ARG1(*call),
    242                 .endpoint = DEV_IPC_GET_ARG2(*call) }
    243         };
    244         size_t data_buffer_len = DEV_IPC_GET_ARG3(*call);
     240        const usb_target_t target = { .packed = DEV_IPC_GET_ARG1(*call) };
     241        size_t data_buffer_len = DEV_IPC_GET_ARG2(*call);
    245242
    246243        int rc;
     
    302299        }
    303300
    304         usb_target_t target = {{
    305                 .address = DEV_IPC_GET_ARG1(*call),
    306                 .endpoint = DEV_IPC_GET_ARG2(*call)
    307         }};
     301        const usb_target_t target = { .packed = DEV_IPC_GET_ARG1(*call) };
    308302
    309303        int rc;
     
    379373        type var = (type) DEV_IPC_GET_ARG##arg_no(*call) % (1 << 8)
    380374
    381         _INIT_FROM_HIGH_DATA2(usb_address_t, address, 1);
    382         _INIT_FROM_LOW_DATA2(usb_endpoint_t, endpoint, 1);
     375        const usb_target_t target = { .packed = DEV_IPC_GET_ARG1(*call) };
    383376
    384377        _INIT_FROM_HIGH_DATA3(usb_speed_t, speed, 2);
     
    395388#undef _INIT_FROM_LOW_DATA3
    396389
    397         int rc = usb_iface->register_endpoint(fun, address, speed, endpoint,
     390        int rc = usb_iface->register_endpoint(fun, target.address,
     391            speed, target.endpoint,
    398392            transfer_type, direction, max_packet_size, interval);
    399393
     
    436430        }
    437431
    438         const usb_target_t target = {{
    439                 .address = DEV_IPC_GET_ARG1(*call),
    440                 .endpoint = DEV_IPC_GET_ARG2(*call)
    441         }};
    442 
     432        const usb_target_t target = { .packed = DEV_IPC_GET_ARG1(*call) };
    443433
    444434        async_transaction_t *trans = async_transaction_create(callid);
     
    484474        }
    485475
    486         const usb_target_t target = {{
    487                 .address = DEV_IPC_GET_ARG1(*call),
    488                 .endpoint = DEV_IPC_GET_ARG2(*call)
    489         }};
    490 
     476        const usb_target_t target = { .packed = DEV_IPC_GET_ARG1(*call) };
    491477
    492478        async_transaction_t *trans = async_transaction_create(callid);
  • uspace/lib/usbdev/src/pipesinit.c

    r56e9fb0 r365e29e2  
    486486                return EBADF;
    487487       
     488        const usb_target_t target =
     489            {{ .address = pipe->wire->address, .endpoint = pipe->endpoint_no }};
    488490#define _PACK2(high, low) (((high) << 16) + (low))
    489491#define _PACK3(high, middle, low) (((((high) << 8) + (middle)) << 8) + (low))
     
    491493        async_exch_t *exch = async_exchange_begin(hc_connection->hc_sess);
    492494        int rc = async_req_4_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    493             IPC_M_USBHC_REGISTER_ENDPOINT,
    494             _PACK2(pipe->wire->address, pipe->endpoint_no),
     495            IPC_M_USBHC_REGISTER_ENDPOINT, target.packed,
    495496            _PACK3(speed, pipe->transfer_type, pipe->direction),
    496497            _PACK2(pipe->max_packet_size, interval));
  • uspace/lib/usbdev/src/pipesio.c

    r56e9fb0 r365e29e2  
    6565    void *buffer, size_t size, size_t *size_transfered)
    6666{
    67         /*
    68          * Get corresponding IPC method.
    69          * In future, replace with static array of mappings
    70          * transfer type -> method.
    71          */
    72         usbhc_iface_funcs_t ipc_method;
    73         switch (pipe->transfer_type) {
    74                 case USB_TRANSFER_INTERRUPT:
    75                 case USB_TRANSFER_BULK:
    76                         ipc_method = IPC_M_USBHC_DATA_READ;
    77                         break;
    78                 default:
    79                         return ENOTSUP;
    80         }
     67        /* Only interrupt and bulk transfers are supported */
     68        if (pipe->transfer_type != USB_TRANSFER_INTERRUPT &&
     69            pipe->transfer_type != USB_TRANSFER_BULK)
     70            return ENOTSUP;
     71
     72        const usb_target_t target =
     73            {{ .address = pipe->wire->address, .endpoint = pipe->endpoint_no }};
    8174       
    8275        /* Ensure serialization over the phone. */
     
    8780         * Make call identifying target USB device and type of transfer.
    8881         */
    89         aid_t opening_request = async_send_3(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    90             ipc_method, pipe->wire->address, pipe->endpoint_no, NULL);
     82        aid_t opening_request = async_send_2(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
     83            IPC_M_USBHC_DATA_READ, target.packed, NULL);
    9184       
    9285        if (opening_request == 0) {
     
    211204    void *buffer, size_t size)
    212205{
    213         /*
    214          * Get corresponding IPC method.
    215          * In future, replace with static array of mappings
    216          * transfer type -> method.
    217          */
    218         usbhc_iface_funcs_t ipc_method;
    219         switch (pipe->transfer_type) {
    220                 case USB_TRANSFER_INTERRUPT:
    221                 case USB_TRANSFER_BULK:
    222                         ipc_method = IPC_M_USBHC_DATA_WRITE;
    223                         break;
    224                 default:
    225                         return ENOTSUP;
    226         }
     206        /* Only interrupt and bulk transfers are supported */
     207        if (pipe->transfer_type != USB_TRANSFER_INTERRUPT &&
     208            pipe->transfer_type != USB_TRANSFER_BULK)
     209            return ENOTSUP;
     210
     211        const usb_target_t target =
     212            {{ .address = pipe->wire->address, .endpoint = pipe->endpoint_no }};
    227213
    228214        /* Ensure serialization over the phone. */
     
    233219         * Make call identifying target USB device and type of transfer.
    234220         */
    235         aid_t opening_request = async_send_3(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    236             ipc_method, pipe->wire->address, pipe->endpoint_no, NULL);
     221        aid_t opening_request = async_send_2(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
     222            IPC_M_USBHC_DATA_WRITE, target.packed, NULL);
    237223       
    238224        if (opening_request == 0) {
     
    348334        pipe_start_transaction(pipe);
    349335
     336        const usb_target_t target =
     337            {{ .address = pipe->wire->address, .endpoint = pipe->endpoint_no }};
     338
    350339        /*
    351340         * Make call identifying target USB device and control transfer type.
    352341         */
    353342        async_exch_t *exch = async_exchange_begin(pipe->hc_sess);
    354         aid_t opening_request = async_send_3(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    355             IPC_M_USBHC_CONTROL_READ, pipe->wire->address, pipe->endpoint_no,
    356             NULL);
     343        aid_t opening_request = async_send_2(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
     344            IPC_M_USBHC_CONTROL_READ, target.packed, NULL);
    357345       
    358346        if (opening_request == 0) {
     
    494482        pipe_start_transaction(pipe);
    495483
     484        const usb_target_t target =
     485            {{ .address = pipe->wire->address, .endpoint = pipe->endpoint_no }};
     486
    496487        /*
    497488         * Make call identifying target USB device and control transfer type.
    498489         */
    499490        async_exch_t *exch = async_exchange_begin(pipe->hc_sess);
    500         aid_t opening_request = async_send_4(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    501             IPC_M_USBHC_CONTROL_WRITE, pipe->wire->address, pipe->endpoint_no,
     491        aid_t opening_request = async_send_3(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
     492            IPC_M_USBHC_CONTROL_WRITE, target.packed,
    502493            data_buffer_size, NULL);
    503494       
Note: See TracChangeset for help on using the changeset viewer.