USB Request Management
[USB Stack]

Collaboration diagram for USB Request Management:

Data Structures

struct  usb_request
 A USB request. More...

Enumerations

enum  usb_request_flag { USB_REQ_SHORT_PKT }
 

Flag bits for indicating that a request needs special treatment.

More...

Functions

void usb_req_init (struct usb_request *req)
 Initialize a USB request.
static void usb_req_add_buffer (struct usb_request *req, struct buffer *buf)
 Add a buffer to a USB request.
struct usb_requestusb_req_alloc (void)
 Allocate and initialize a USB request structure.
void usb_req_free (struct usb_request *req)
 Free a USB request structure.
void usb_init (void)
 Initialize the USB core subsystem.
static struct bufferusb_req_get_first_buffer (struct usb_request *req)
 Return the first buffer associated with req.

Detailed Description

A USB request contains a list of buffers, each representing a contiguous region of memory used for holding data to be sent or received in a USB transfer. Each request may have a callback associated with it, which is called when all the buffers have been transferred or cancelled. The submitter may use usb_request::context to hold arbitrary data associated with the request.

Before a USB request can be (re)used, it must be initialized by calling usb_req_init(). Requests freshly allocated by usb_req_alloc() have already been initialized, so there's no need to call usb_req_init() afterwards.


Enumeration Type Documentation

Flag bits for indicating that a request needs special treatment.

Enumerator:
USB_REQ_SHORT_PKT 

Last packet must be short.

Setting this flag indicates that the last packet sent from this buffer must be short. If this buffer ends on an endpoint boundary, the UDC driver will send a zero-length packet to terminate the transfer.

Definition at line 60 of file request.h.


Function Documentation

void usb_init ( void   ) 

Initialize the USB core subsystem.

This function will initialize the USB request pool.

Definition at line 99 of file request.c.

References cpu_sram_pool, and mem_pool_init_physmem().

Referenced by main().

static void usb_req_add_buffer ( struct usb_request req,
struct buffer buf 
) [inline, static]

Add a buffer to a USB request.

This will add the buffer buf to the end of the buffer list associated with the USB request req.

Parameters:
req The USB request
buf The buffer to be associated with req

Definition at line 124 of file request.h.

References usb_request::buf_list, buffer::node, and slist_insert_tail().

struct usb_request* usb_req_alloc ( void   )  [read]

Allocate and initialize a USB request structure.

Returns:
A pointer to the newly allocated USB request, or NULL if the pool is exhausted.

Definition at line 73 of file request.c.

References mem_pool_alloc(), and usb_req_init().

Referenced by msc_submit_write_data_req().

void usb_req_free ( struct usb_request req  ) 

Free a USB request structure.

Parameters:
req The request to be released back to the pool.

Definition at line 89 of file request.c.

References mem_pool_free().

Referenced by msc_submit_write_data_req().

static struct buffer* usb_req_get_first_buffer ( struct usb_request req  )  [static, read]

Return the first buffer associated with req.

Definition at line 142 of file request.h.

References usb_request::buf_list, buffer::node, and slist_peek_head.

void usb_req_init ( struct usb_request req  ) 

Initialize a USB request.

This initializes a USB request and makes sure that it doesn't have any special flags set, and that it doesn't have any other buffers associated with it.

Parameters:
req The USB request to be initialized.

Definition at line 60 of file request.c.

References usb_request::buf_list, usb_request::bytes_xfered, usb_request::flags, and slist_init().

Referenced by usb_req_alloc().

Generated on Thu Apr 29 14:10:36 2010 for xplain-bc by  doxygen 1.6.3