Changeset 06c552c in mainline for uspace/drv/ohci/batch.c


Ignore:
Timestamp:
2011-04-08T20:54:52Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
96b8f322
Parents:
344925c
Message:

Create batch memory structures.

File:
1 edited

Legend:

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

    r344925c r06c552c  
    4040#include "batch.h"
    4141#include "utils/malloc32.h"
     42#include "hw_struct/endpoint_descriptor.h"
     43#include "hw_struct/transfer_descriptor.h"
     44
     45#define OHCI_MAX_TRANSFER (8 * 1024) /* OHCI TDs can handle up to 8KB buffers */
     46
     47typedef struct ohci_batch {
     48        ed_t *ed;
     49        td_t *tds;
     50        size_t td_count;
     51} ohci_batch_t;
    4252
    4353static void batch_call_in_and_dispose(usb_transfer_batch_t *instance);
     
    6878            func_in, func_out, arg, fun, ep, NULL);
    6979
     80        ohci_batch_t *data = malloc(sizeof(ohci_batch_t));
     81        CHECK_NULL_DISPOSE_RETURN(data, "Failed to allocate batch data.\n");
     82        bzero(data, sizeof(ohci_batch_t));
     83        instance->private_data = data;
     84
     85        data->td_count =
     86            (buffer_size + OHCI_MAX_TRANSFER - 1) / OHCI_MAX_TRANSFER;
     87        if (ep->transfer_type == USB_TRANSFER_CONTROL) {
     88                data->td_count += 2;
     89        }
     90
     91        data->tds = malloc32(sizeof(td_t) * data->td_count);
     92        CHECK_NULL_DISPOSE_RETURN(data->tds,
     93            "Failed to allocate transfer descriptors.\n");
     94        bzero(data->tds, sizeof(td_t) * data->td_count);
     95
     96        data->ed = malloc32(sizeof(ed_t));
     97        CHECK_NULL_DISPOSE_RETURN(data->ed,
     98            "Failed to allocate endpoint descriptor.\n");
     99
    70100        if (buffer_size > 0) {
    71101                instance->transport_buffer = malloc32(buffer_size);
     
    81111        }
    82112
    83 
    84113        return instance;
    85114}
Note: See TracChangeset for help on using the changeset viewer.