Changeset 50206e9 in mainline


Ignore:
Timestamp:
2018-01-31T17:02:48Z (6 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

Location:
uspace/lib/usbdev
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/include/usb/dev/pipes.h

    r98893ede r50206e9  
    115115    const void *, size_t);
    116116
     117void *usb_pipe_alloc_buffer(usb_pipe_t *, size_t);
     118void usb_pipe_free_buffer(usb_pipe_t *, void *);
    117119#endif
    118120/**
  • 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.