pintos/src/devices/usb_storage.c File Reference

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <kernel/list.h>
#include <endian.h>
#include <debug.h>
#include "threads/malloc.h"
#include "threads/palloc.h"
#include "threads/thread.h"
#include "devices/timer.h"
#include "threads/synch.h"
#include "threads/pte.h"
#include "devices/usb.h"
#include "devices/block.h"
#include "devices/partition.h"

Go to the source code of this file.

Data Structures

struct  msc_cbw
struct  msc_csw
struct  scsi_cdb6
struct  scsi_cdb10
struct  scsi_cdb12
struct  scsi_cdb16
struct  scsi_capacity10
struct  msc_class_info
struct  msc_blk_info

Defines

#define USB_CLASS_MASS_STORAGE   0x08
#define USB_SUBCLASS_RBC   0x01
#define USB_SUBCLASS_ATAPI   0x02
#define USB_SUBCLASS_TAPE   0x03
#define USB_SUBCLASS_UFI   0x04
#define USB_SUBCLASS_SFF8070   0x05
#define USB_SUBCLASS_SCSI   0x06
#define USB_PROTO_COMPLETE   0x00
#define USB_PROTO_NO_COMPLETE   0x01
#define USB_PROTO_BULK   0x50
#define CBW_SIG_MAGIC   0x43425355
#define CBW_FL_IN   (1 << 7)
#define CBW_FL_OUT   0
#define CSW_SIG_MAGIC   0x53425355
#define CSW_STATUS_PASSED   0
#define CSW_STATUS_FAILED   1
#define CSW_STATUS_PHASE   2
#define SCSI_OP_WRITE6   0xa
#define SCSI_OP_READ6   0x8
#define SCSI_OP_TEST_READY   0x00
#define SCSI_OP_SEEK8   0x0b
#define SCSI_OP_MODE_SENSE8   0x1a
#define SCSI_OP_MODE_SELECT8   0x15
#define SCSI_OP_READ_CAPACITY10   0x25
#define SCSI_OP_READ_CAPACITY16   0x9e
#define SCSI_OP_WRITE10   0x2a
#define SCSI_OP_READ10   0x28
#define SCSI_OP_SEEK10   0x2b
#define SCSI_OP_MODE_SENSE10   0x5a
#define SCSI_OP_MODE_SELECT10   0x55
#define mci_lock(x)   lock_acquire(&(x)->lock)
#define mci_unlock(x)   lock_release(&(x)->lock)

Functions

static void * msc_attached (struct usb_iface *)
static void msc_detached (class_info)
static void msc_reset_endpoint (struct usb_endpoint *eop)
static void msc_get_geometry (struct msc_class_info *)
static void msc_io (struct msc_class_info *, block_sector_t, void *buf, bool wr)
static void msc_reset_recovery (struct msc_class_info *mci)
static void msc_bulk_reset (struct msc_class_info *mci)
void usb_storage_init (void)
static void msc_detached (class_info ci UNUSED)
static void msc_read (void *mbi_, block_sector_t sector, void *buffer)
static void msc_write (void *mbi_, block_sector_t sector, const void *buffer)

Variables

static struct usb_class storage_class
static struct list device_list
static struct block_operations msc_operations


Define Documentation

#define CBW_FL_IN   (1 << 7)

Definition at line 40 of file usb_storage.c.

Referenced by msc_get_geometry(), and msc_io().

#define CBW_FL_OUT   0

Definition at line 41 of file usb_storage.c.

Referenced by msc_io().

#define CBW_SIG_MAGIC   0x43425355

Definition at line 38 of file usb_storage.c.

Referenced by msc_get_geometry(), and msc_io().

#define CSW_SIG_MAGIC   0x53425355

Definition at line 56 of file usb_storage.c.

Referenced by msc_get_geometry(), and msc_io().

#define CSW_STATUS_FAILED   1

Definition at line 58 of file usb_storage.c.

#define CSW_STATUS_PASSED   0

Definition at line 57 of file usb_storage.c.

Referenced by msc_get_geometry(), and msc_io().

#define CSW_STATUS_PHASE   2

Definition at line 59 of file usb_storage.c.

#define mci_lock ( x   )     lock_acquire(&(x)->lock)

Definition at line 143 of file usb_storage.c.

Referenced by msc_read(), and msc_write().

#define mci_unlock ( x   )     lock_release(&(x)->lock)

Definition at line 144 of file usb_storage.c.

Referenced by msc_read(), and msc_write().

#define SCSI_OP_MODE_SELECT10   0x55

Definition at line 126 of file usb_storage.c.

#define SCSI_OP_MODE_SELECT8   0x15

Definition at line 119 of file usb_storage.c.

#define SCSI_OP_MODE_SENSE10   0x5a

Definition at line 125 of file usb_storage.c.

#define SCSI_OP_MODE_SENSE8   0x1a

Definition at line 118 of file usb_storage.c.

#define SCSI_OP_READ10   0x28

Definition at line 123 of file usb_storage.c.

Referenced by msc_io().

#define SCSI_OP_READ6   0x8

Definition at line 115 of file usb_storage.c.

#define SCSI_OP_READ_CAPACITY10   0x25

Definition at line 120 of file usb_storage.c.

Referenced by msc_get_geometry().

#define SCSI_OP_READ_CAPACITY16   0x9e

Definition at line 121 of file usb_storage.c.

#define SCSI_OP_SEEK10   0x2b

Definition at line 124 of file usb_storage.c.

#define SCSI_OP_SEEK8   0x0b

Definition at line 117 of file usb_storage.c.

#define SCSI_OP_TEST_READY   0x00

Definition at line 116 of file usb_storage.c.

#define SCSI_OP_WRITE10   0x2a

Definition at line 122 of file usb_storage.c.

Referenced by msc_io().

#define SCSI_OP_WRITE6   0xa

Definition at line 114 of file usb_storage.c.

#define USB_CLASS_MASS_STORAGE   0x08

2927736889830424757 USB mass storage driver - just like the one Elvis used!

Definition at line 23 of file usb_storage.c.

#define USB_PROTO_BULK   0x50

Definition at line 34 of file usb_storage.c.

#define USB_PROTO_COMPLETE   0x00

Definition at line 32 of file usb_storage.c.

#define USB_PROTO_NO_COMPLETE   0x01

Definition at line 33 of file usb_storage.c.

#define USB_SUBCLASS_ATAPI   0x02

Definition at line 26 of file usb_storage.c.

#define USB_SUBCLASS_RBC   0x01

Definition at line 25 of file usb_storage.c.

#define USB_SUBCLASS_SCSI   0x06

Definition at line 30 of file usb_storage.c.

Referenced by msc_attached().

#define USB_SUBCLASS_SFF8070   0x05

Definition at line 29 of file usb_storage.c.

#define USB_SUBCLASS_TAPE   0x03

Definition at line 27 of file usb_storage.c.

#define USB_SUBCLASS_UFI   0x04

Definition at line 28 of file usb_storage.c.


Function Documentation

static class_info msc_attached ( struct usb_iface ui  )  [static]

static void msc_bulk_reset ( struct msc_class_info mci  )  [static]

static void msc_detached ( class_info ci  UNUSED  )  [static]

Definition at line 253 of file usb_storage.c.

References PANIC.

static void msc_detached ( class_info   )  [static]

static void msc_get_geometry ( struct msc_class_info mci  )  [static]

static void msc_io ( struct msc_class_info mci,
block_sector_t  bn,
void *  buf,
bool  wr 
) [static]

static void msc_read ( void *  mbi_,
block_sector_t  sector,
void *  buffer 
) [static]

Definition at line 259 of file usb_storage.c.

References msc_blk_info::mci, mci_lock, mci_unlock, and msc_io().

static void msc_reset_endpoint ( struct usb_endpoint eop  )  [static]

static void msc_reset_recovery ( struct msc_class_info mci  )  [static]

Definition at line 422 of file usb_storage.c.

References msc_class_info::eop_in, msc_class_info::eop_out, msc_bulk_reset(), and msc_reset_endpoint().

Referenced by msc_io().

static void msc_write ( void *  mbi_,
block_sector_t  sector,
const void *  buffer 
) [static]

Definition at line 269 of file usb_storage.c.

References msc_blk_info::mci, mci_lock, mci_unlock, and msc_io().

void usb_storage_init ( void   ) 


Variable Documentation

struct list device_list [static]

Definition at line 171 of file usb_storage.c.

Referenced by msc_attached(), and usb_storage_init().

static struct block_operations msc_operations [static, read]

Initial value:

Definition at line 172 of file usb_storage.c.

Referenced by msc_attached().

struct usb_class storage_class [static]

Initial value:

 {
  .attached = msc_attached,
  .detached = msc_detached,
  .name = "Mass Storage",
  .class_id = USB_CLASS_MASS_STORAGE
}

Definition at line 136 of file usb_storage.c.


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