Changeset 2bf8f8c in mainline for uspace/drv/ohci/batch.c


Ignore:
Timestamp:
2011-03-21T13:18:03Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d328172
Parents:
be7950e8
Message:

Implement batch_get

File:
1 edited

Legend:

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

    rbe7950e8 r2bf8f8c  
    3939
    4040#include "batch.h"
     41#include "utils/malloc32.h"
    4142
    4243#define DEFAULT_ERROR_COUNT 3
     
    4849    usb_speed_t speed,
    4950                char *buffer,
    50                 size_t size,
     51                size_t buffer_size,
    5152                char *setup_buffer,
    5253                size_t setup_size,
     
    5758                )
    5859{
    59         return NULL;
     60#define CHECK_NULL_DISPOSE_RETURN(ptr, message...) \
     61        if (ptr == NULL) { \
     62                usb_log_error(message); \
     63                if (instance) { \
     64                        batch_dispose(instance); \
     65                } \
     66                return NULL; \
     67        } else (void)0
     68
     69        batch_t *instance = malloc(sizeof(batch_t));
     70        CHECK_NULL_DISPOSE_RETURN(instance,
     71            "Failed to allocate batch instance.\n");
     72        batch_init(instance, target, transfer_type, speed, max_packet_size,
     73            buffer, NULL, buffer_size, NULL, setup_size, func_in,
     74            func_out, arg, fun, NULL);
     75
     76        if (buffer_size > 0) {
     77                instance->transport_buffer = malloc32(buffer_size);
     78                CHECK_NULL_DISPOSE_RETURN(instance->transport_buffer,
     79                    "Failed to allocate device accessible buffer.\n");
     80        }
     81
     82        if (setup_size > 0) {
     83                instance->setup_buffer = malloc32(setup_size);
     84                CHECK_NULL_DISPOSE_RETURN(instance->setup_buffer,
     85                    "Failed to allocate device accessible setup buffer.\n");
     86                memcpy(instance->setup_buffer, setup_buffer, setup_size);
     87        }
     88
     89
     90        return instance;
    6091}
    6192/*----------------------------------------------------------------------------*/
    6293void batch_dispose(batch_t *instance)
    6394{
     95        assert(instance);
    6496}
    6597/*----------------------------------------------------------------------------*/
    6698void batch_control_write(batch_t *instance)
    6799{
     100        assert(instance);
    68101}
    69102/*----------------------------------------------------------------------------*/
    70103void batch_control_read(batch_t *instance)
    71104{
     105        assert(instance);
    72106}
    73107/*----------------------------------------------------------------------------*/
    74108void batch_interrupt_in(batch_t *instance)
    75109{
     110        assert(instance);
    76111}
    77112/*----------------------------------------------------------------------------*/
    78113void batch_interrupt_out(batch_t *instance)
    79114{
     115        assert(instance);
    80116}
    81117/*----------------------------------------------------------------------------*/
    82118void batch_bulk_in(batch_t *instance)
    83119{
     120        assert(instance);
    84121}
    85122/*----------------------------------------------------------------------------*/
    86123void batch_bulk_out(batch_t *instance)
    87124{
     125        assert(instance);
    88126}
    89127/**
Note: See TracChangeset for help on using the changeset viewer.