Changeset ab6fdad3 in mainline for uspace/drv/ohci/root_hub.c


Ignore:
Timestamp:
2011-04-15T15:24:32Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6b082a1b
Parents:
a13ed97 (diff), cbdb6457 (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:

Development branch changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/ohci/root_hub.c

    ra13ed97 rab6fdad3  
    198198static int process_ctrl_request(rh_t *instance, usb_transfer_batch_t *request);
    199199
    200 
     200static int process_interrupt(rh_t *instance, usb_transfer_batch_t * request,
     201    void * change_buffer, size_t buffe_size);
     202
     203static bool is_zeros(void * buffer, size_t size);
    201204
    202205
     
    213216        // set port power mode to no-power-switching
    214217        instance->registers->rh_desc_a |= RHDA_NPS_FLAG;
    215 
     218        instance->unfinished_interrupt_transfer = NULL;
    216219        usb_log_info("OHCI root hub with %d ports.\n", instance->port_count);
    217220        return EOK;
     
    233236                usb_log_info("Root hub got CONTROL packet\n");
    234237                opResult = process_ctrl_request(instance, request);
     238                usb_transfer_batch_finish_error(request, opResult);
    235239        } else if (request->ep->transfer_type == USB_TRANSFER_INTERRUPT) {
    236240                usb_log_info("Root hub got INTERRUPT packet\n");
    237241                void * buffer;
     242                size_t buffer_size;
    238243                create_interrupt_mask(instance, &buffer,
    239                         &(request->transfered_size));
    240                 memcpy(request->data_buffer, buffer,
    241                         request->transfered_size);
     244                        &buffer_size);
     245                if(is_zeros(buffer,buffer_size)){
     246                        usb_log_debug("no changes..");
     247                        instance->unfinished_interrupt_transfer=
     248                            request;
     249                        //will be finished later
     250                }else{
     251                        usb_log_debug("processing changes..");
     252                        process_interrupt(instance, request,
     253                            buffer, buffer_size);
     254                }
     255                free(buffer);
    242256                opResult = EOK;
    243257        } else {
    244258                opResult = EINVAL;
    245         }
    246         usb_transfer_batch_finish_error(request, opResult);
     259                usb_transfer_batch_finish_error(request, opResult);
     260        }
    247261        return EOK;
    248262}
     
    252266
    253267void rh_interrupt(rh_t *instance) {
    254         usb_log_info("Whoa whoa wait, I`m not supposed to receive any "
    255                 "interrupts, am I?\n");
    256         /* TODO: implement? */
     268        //usb_log_info("Whoa whoa wait, I`m not supposed to receive any "
     269        //      "interrupts, am I?\n");
     270        if(!instance->unfinished_interrupt_transfer){
     271                return;
     272        }
     273        size_t size;
     274        void * buffer;
     275        create_interrupt_mask(instance, &buffer,
     276                        &size);
     277        process_interrupt(instance,instance->unfinished_interrupt_transfer,
     278            buffer,size);
     279        free(buffer);
    257280}
    258281/*----------------------------------------------------------------------------*/
     
    859882        return opResult;
    860883}
     884/*----------------------------------------------------------------------------*/
     885
     886/**
     887 * process hanging interrupt request
     888 *
     889 * If an interrupt transfer has been received and there was no change,
     890 * the driver stores the transfer information and waits for change to occcur.
     891 * This routine is called when that happens and it finalizes the interrupt
     892 * transfer.
     893 *
     894 * @param instance hub instance
     895 * @param request batch request to be processed
     896 * @param change_buffer chages on hub
     897 * @param buffer_size size of change buffer
     898 *
     899 * @return
     900 */
     901static int process_interrupt(rh_t *instance, usb_transfer_batch_t * request,
     902    void * change_buffer, size_t buffe_size){
     903        create_interrupt_mask(instance, &change_buffer,
     904            &(request->transfered_size));
     905        memcpy(request->data_buffer, change_buffer,request->transfered_size);
     906        instance->unfinished_interrupt_transfer = NULL;
     907        usb_transfer_batch_finish_error(request, EOK);
     908        return EOK;
     909}
     910
     911/*----------------------------------------------------------------------------*/
     912
     913/**
     914 * return whether the buffer is full of zeros
     915 *
     916 * Convenience function.
     917 * @param buffer
     918 * @param size
     919 * @return
     920 */
     921static bool is_zeros(void * buffer, size_t size){
     922        if(!buffer) return true;
     923        if(!size) return true;
     924        size_t i;
     925        for(i=0;i<size;++i){
     926                if(((char*)buffer)[i])
     927                        return false;
     928        }
     929        return true;
     930}
    861931
    862932/**
Note: See TracChangeset for help on using the changeset viewer.