#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.
#define CBW_FL_IN (1 << 7) |
#define CBW_FL_OUT 0 |
#define CBW_SIG_MAGIC 0x43425355 |
#define CSW_SIG_MAGIC 0x53425355 |
#define CSW_STATUS_FAILED 1 |
Definition at line 58 of file usb_storage.c.
#define CSW_STATUS_PASSED 0 |
#define CSW_STATUS_PHASE 2 |
Definition at line 59 of file usb_storage.c.
#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 |
#define SCSI_OP_READ6 0x8 |
Definition at line 115 of file usb_storage.c.
#define SCSI_OP_READ_CAPACITY10 0x25 |
#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 |
#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 |
#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.
static class_info msc_attached | ( | struct usb_iface * | ui | ) | [static] |
Definition at line 185 of file usb_storage.c.
References ASSERT, usb_endpoint::attr, msc_class_info::blk_count, msc_class_info::blk_size, BLOCK_RAW, block_register(), msc_class_info::bounce_buffer, device_list, usb_endpoint::direction, DIV_ROUND_UP, usb_iface::endpoints, msc_class_info::eop_in, msc_class_info::eop_out, list_begin(), list_end(), list_entry, list_next(), list_push_back(), msc_class_info::lock, lock_init(), malloc(), msc_blk_info::mci, msc_get_geometry(), msc_operations, name, NULL, PAL_ASSERT, palloc_get_multiple(), partition_scan(), usb_endpoint::peers, msc_class_info::peers, PGSIZE, printf(), msc_class_info::refs, msc_class_info::retrying, snprintf(), usb_iface::subclass_id, msc_class_info::ui, USB_EOP_ATTR_BULK, and USB_SUBCLASS_SCSI.
static void msc_bulk_reset | ( | struct msc_class_info * | mci | ) | [static] |
Definition at line 429 of file usb_storage.c.
References usb_dev::cfg_eop, usb_iface::dev, usb_setup_pkt::direction, usb_iface::iface_num, usb_setup_pkt::index, usb_setup_pkt::length, NULL, usb_setup_pkt::recipient, usb_setup_pkt::request, usb_setup_pkt::type, msc_class_info::ui, usb_dev_setup(), USB_SETUP_RECIP_DEV, USB_SETUP_TYPE_CLASS, and usb_setup_pkt::value.
Referenced by msc_reset_recovery().
static void msc_detached | ( | class_info ci | UNUSED | ) | [static] |
static void msc_detached | ( | class_info | ) | [static] |
static void msc_get_geometry | ( | struct msc_class_info * | mci | ) | [static] |
Definition at line 285 of file usb_storage.c.
References ASSERT, be32_to_machine, msc_class_info::blk_count, msc_class_info::blk_size, scsi_capacity10::block_len, scsi_capacity10::blocks, buf, msc_cbw::cb, msc_cbw::cb_len, CBW_FL_IN, CBW_SIG_MAGIC, CSW_SIG_MAGIC, CSW_STATUS_PASSED, msc_class_info::eop_in, msc_class_info::eop_out, msc_cbw::flags, msc_cbw::lun, memset(), msc_reset_endpoint(), scsi_cdb10::op, PANIC, SCSI_OP_READ_CAPACITY10, msc_csw::sig, msc_cbw::sig, msc_csw::status, msc_class_info::tag, msc_cbw::tag, msc_cbw::tx_len, and usb_dev_bulk().
Referenced by msc_attached().
static void msc_io | ( | struct msc_class_info * | mci, | |
block_sector_t | bn, | |||
void * | buf, | |||
bool | wr | |||
) | [static] |
Definition at line 332 of file usb_storage.c.
References ASSERT, msc_class_info::blk_size, msc_class_info::bounce_buffer, msc_cbw::cb, msc_cbw::cb_len, CBW_FL_IN, CBW_FL_OUT, CBW_SIG_MAGIC, CSW_SIG_MAGIC, CSW_STATUS_PASSED, msc_class_info::eop_in, msc_class_info::eop_out, msc_cbw::flags, scsi_cdb10::lba, scsi_cdb10::len, msc_cbw::lun, machine_to_be16, machine_to_be24, memcpy(), memset(), msc_reset_endpoint(), msc_reset_recovery(), scsi_cdb10::op, PANIC, printf(), msc_class_info::retrying, SCSI_OP_READ10, SCSI_OP_WRITE10, msc_csw::sig, msc_cbw::sig, msc_csw::status, msc_class_info::tag, msc_cbw::tag, msc_cbw::tx_len, and usb_dev_bulk().
Referenced by msc_read(), and msc_write().
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] |
Definition at line 407 of file usb_storage.c.
References usb_setup_pkt::direction, usb_endpoint::eop, usb_setup_pkt::index, usb_setup_pkt::length, NULL, usb_setup_pkt::recipient, REQ_STD_CLR_FEAT, usb_setup_pkt::request, usb_setup_pkt::type, usb_dev_setup(), USB_SETUP_RECIP_ENDPT, USB_SETUP_TYPE_STD, and usb_setup_pkt::value.
Referenced by msc_get_geometry(), msc_io(), and msc_reset_recovery().
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 | ) |
struct list device_list [static] |
static struct block_operations msc_operations [static, read] |
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.