Changeset 50206e9 in mainline for uspace/lib/usbdev/src/pipes.c


Ignore:
Timestamp:
2018-01-31T17:02:48Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4e17d54
Parents:
98893ede
Message:

libusb: add buffer allocation routines

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/src/pipes.c

    r98893ede r50206e9  
    3636#include <usb/dev/request.h>
    3737#include <usb/usb.h>
     38#include <usb/dma_buffer.h>
    3839
    3940#include <assert.h>
     
    161162}
    162163
     164/**
     165 * Allocate a buffer for data transmission, that satisfies the constraints
     166 * imposed by the host controller.
     167 *
     168 * @param[in] pipe Pipe for which the buffer is allocated
     169 * @param[in] size Size of the required buffer
     170 */
     171void *usb_pipe_alloc_buffer(usb_pipe_t *pipe, size_t size)
     172{
     173        // FIXME: Do not use the default policy, but the one required by HC.
     174
     175        dma_buffer_t buf;
     176        if (dma_buffer_alloc(&buf, size))
     177                return NULL;
     178
     179        return buf.virt;
     180}
     181
     182void usb_pipe_free_buffer(usb_pipe_t *pipe, void *buffer)
     183{
     184        dma_buffer_t buf;
     185        buf.virt = buffer;
     186        dma_buffer_free(&buf);
     187}
     188
    163189/** Request a read (in) transfer on an endpoint pipe.
    164190 *
Note: See TracChangeset for help on using the changeset viewer.