pintos/src/devices/usb.c File Reference

#include "devices/usb.h"
#include "devices/usb_hub.h"
#include "threads/synch.h"
#include "threads/malloc.h"
#include "devices/timer.h"
#include <kernel/bitmap.h>
#include <string.h>
#include <stdio.h>

Go to the source code of this file.

Data Structures

struct  desc_header
struct  device_descriptor
struct  device_qualifier
struct  config_descriptor
struct  interface_descriptor
struct  endpoint_descriptor
struct  host
struct  class

Defines

#define ADDRS_PER_HOST   127
#define ADDR_DEFAULT   0
#define ADDR_FIRST   1
#define SETUP_DESC_DEVICE   1
#define SETUP_DESC_CONFIG   2
#define SETUP_DESC_STRING   3
#define SETUP_DESC_IFACE   4
#define SETUP_DESC_ENDPOINT   5
#define SETUP_DESC_DEVQUAL   6
#define SETUP_DESC_SPDCONFIG   7
#define SETUP_DESC_IFACEPWR   8
#define USB_CLASS_HUB   0x09
#define usb_lock()   lock_acquire(&usb_sys_lock)
#define usb_unlock()   lock_release(&usb_sys_lock)
#define MAX_USB_STR   128

Functions

static void usb_scan_devices (struct host *h)
static struct usb_devusb_configure_default (struct host *h)
static char * usb_get_string (struct usb_dev *d, int ndx)
static struct classusb_get_class_by_id (int id)
static void usb_setup_dev_addr (struct usb_dev *dev)
static void usb_config_dev (struct usb_dev *dev, int config_val)
static int usb_load_config (struct usb_dev *dev, int idx, void *data, int dsz)
static int usb_tx_all (struct usb_endpoint *eop, void *buf, int max_bytes, int bailout, bool in)
static void usb_attach_interfaces (struct usb_dev *dev)
static void usb_apply_class_to_interfaces (struct class *c)
static size_t wchar_to_ascii (char *dst, const char *src)
void uhci_init (void)
void ehci_init (void)
void usb_init (void)
void usb_register_host (struct usb_host *uh, host_info info)
int usb_register_class (struct usb_class *uc)
static int send_status (struct host *h, host_eop_info cfg_eop)
int usb_dev_bulk (struct usb_endpoint *eop, void *buf, int sz, int *tx)
int usb_dev_setup (struct usb_endpoint *eop, bool in, struct usb_setup_pkt *s, void *buf, int sz)

Variables

static struct list usb_dev_list
static struct list class_list
static struct list host_list
static struct lock usb_sys_lock


Define Documentation

#define ADDR_DEFAULT   0

Definition at line 12 of file usb.c.

Referenced by usb_configure_default().

#define ADDR_FIRST   1

Definition at line 13 of file usb.c.

#define ADDRS_PER_HOST   127

Definition at line 11 of file usb.c.

Referenced by usb_register_host().

#define MAX_USB_STR   128

Definition at line 587 of file usb.c.

Referenced by usb_get_string().

#define SETUP_DESC_CONFIG   2

Definition at line 18 of file usb.c.

Referenced by usb_load_config().

#define SETUP_DESC_DEVICE   1

sometimes used for ''value'

Definition at line 17 of file usb.c.

Referenced by usb_configure_default().

#define SETUP_DESC_DEVQUAL   6

Definition at line 22 of file usb.c.

#define SETUP_DESC_ENDPOINT   5

Definition at line 21 of file usb.c.

#define SETUP_DESC_IFACE   4

Definition at line 20 of file usb.c.

Referenced by usb_load_config().

#define SETUP_DESC_IFACEPWR   8

Definition at line 24 of file usb.c.

#define SETUP_DESC_SPDCONFIG   7

Definition at line 23 of file usb.c.

#define SETUP_DESC_STRING   3

Definition at line 19 of file usb.c.

Referenced by usb_get_string().

#define USB_CLASS_HUB   0x09

Definition at line 110 of file usb.c.

 
#define usb_lock (  )     lock_acquire(&usb_sys_lock)

Definition at line 132 of file usb.c.

Referenced by usb_register_class(), and usb_register_host().

 
#define usb_unlock (  )     lock_release(&usb_sys_lock)

Definition at line 133 of file usb.c.

Referenced by usb_register_class(), and usb_register_host().


Function Documentation

void ehci_init ( void   ) 

static int send_status ( struct host h,
host_eop_info  cfg_eop 
) [static]

void uhci_init ( void   ) 

static void usb_apply_class_to_interfaces ( struct class c  )  [static]

Scan all interfaces for interfaces that match class's class id Attach interfaces that match

Definition at line 688 of file usb.c.

References usb_iface::c_info, usb_iface::class, usb_iface::class_id, usb_iface::class_peers, usb_dev::interfaces, list_begin(), list_end(), list_entry, list_next(), list_push_back(), NULL, usb_iface::peers, and usb_dev_list.

Referenced by usb_register_class().

static void usb_attach_interfaces ( struct usb_dev dev  )  [static]

static void usb_config_dev ( struct usb_dev dev,
int  config_val 
) [static]

static struct usb_dev * usb_configure_default ( struct host h  )  [static, read]

Definition at line 255 of file usb.c.

References ADDR_DEFAULT, usb_iface::c_info, usb_dev::cfg_eop, usb_iface::class, usb_iface::class_id, usb_host::create_dev_channel, usb_host::create_eop, usb_dev::default_iface, usb_iface::dev, host::dev, device_descriptor::dev_class, device_descriptor::dev_proto, device_descriptor::dev_subclass, device_descriptor::device_id, usb_dev::device_id, usb_setup_pkt::direction, usb_endpoint::eop, usb_dev::h_cfg_eop, usb_dev::h_dev, usb_endpoint::h_eop, usb_dev::host, usb_endpoint::iface, usb_iface::iface_num, usb_dev::ignore_device, usb_setup_pkt::index, host::info, usb_dev::interfaces, usb_setup_pkt::length, list_init(), malloc(), device_descriptor::manufacturer, usb_dev::manufacturer, usb_endpoint::max_pkt, device_descriptor::max_pktsz, memset(), NULL, device_descriptor::num_configs, printf(), device_descriptor::product, usb_dev::product, device_descriptor::product_id, usb_dev::product_id, usb_iface::proto, usb_setup_pkt::recipient, usb_host::remove_dev_channel, usb_host::remove_eop, REQ_STD_GET_DESC, usb_setup_pkt::request, send_status(), SETUP_DESC_DEVICE, usb_iface::subclass_id, usb_host::tx_pkt, usb_setup_pkt::type, usb_config_dev(), usb_get_string(), USB_HOST_ERR_NONE, usb_load_config(), usb_setup_dev_addr(), USB_SETUP_RECIP_DEV, USB_SETUP_TYPE_STD, device_descriptor::usb_spec, USB_TOKEN_IN, USB_TOKEN_SETUP, usb_dev::usb_version, USB_VERSION_1_0, USB_VERSION_1_1, usb_setup_pkt::value, device_descriptor::vendor_id, and usb_dev::vendor_id.

Referenced by usb_scan_devices().

int usb_dev_bulk ( struct usb_endpoint eop,
void *  buf,
int  sz,
int *  tx 
)

int usb_dev_setup ( struct usb_endpoint eop,
bool  in,
struct usb_setup_pkt s,
void *  buf,
int  sz 
)

static struct class * usb_get_class_by_id ( int  id  )  [static, read]

static char * usb_get_string ( struct usb_dev d,
int  ndx 
) [static]

void usb_init ( void   ) 

Definition at line 153 of file usb.c.

References class_list, ehci_init(), host_list, list_init(), lock_init(), printf(), uhci_init(), usb_dev_list, usb_hub_init(), and usb_sys_lock.

Referenced by main().

static int usb_load_config ( struct usb_dev dev,
int  idx,
void *  data,
int  dsz 
) [static]

int usb_register_class ( struct usb_class uc  ) 

void usb_register_host ( struct usb_host uh,
host_info  info 
)

static void usb_scan_devices ( struct host h  )  [static]

static void usb_setup_dev_addr ( struct usb_dev dev  )  [static]

static int usb_tx_all ( struct usb_endpoint eop,
void *  buf,
int  max_bytes,
int  bailout,
bool  in 
) [static]

static size_t wchar_to_ascii ( char *  dst,
const char *  src 
) [static]

convert a wchar string to ascii in place

Definition at line 769 of file usb.c.

Referenced by usb_get_string().


Variable Documentation

struct list class_list [static]

Definition at line 128 of file usb.c.

Referenced by usb_get_class_by_id(), usb_init(), and usb_register_class().

struct list host_list [static]

Definition at line 129 of file usb.c.

Referenced by usb_init(), and usb_register_host().

struct list usb_dev_list [static]

Definition at line 127 of file usb.c.

Referenced by usb_apply_class_to_interfaces(), usb_init(), and usb_scan_devices().

struct lock usb_sys_lock [static]

Definition at line 130 of file usb.c.

Referenced by usb_init().


Generated on Mon Jan 10 16:43:58 2011 for Pintos by  doxygen 1.5.6