usb_disk: extract specs into a public header.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2014, Haiku Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _USB_MSC_H
|
||||
#define _USB_MSC_H
|
||||
|
||||
|
||||
// (Partial) USB Class Definitions for Mass Storage Devices (MSC), version 1.0
|
||||
// Reference: http://www.usb.org/developers/devclass_docs/usbmassbulk_10.pdf
|
||||
|
||||
|
||||
#define USB_MASS_STORAGE_DEVICE_CLASS 0x08
|
||||
|
||||
#define CBW_SIGNATURE 0x43425355
|
||||
#define CBW_DATA_OUTPUT 0x00
|
||||
#define CBW_DATA_INPUT 0x80
|
||||
|
||||
#define CSW_SIGNATURE 0x53425355
|
||||
#define CSW_STATUS_COMMAND_PASSED 0x00
|
||||
#define CSW_STATUS_COMMAND_FAILED 0x01
|
||||
#define CSW_STATUS_PHASE_ERROR 0x02
|
||||
|
||||
#define REQUEST_MASS_STORAGE_RESET 0xff
|
||||
#define REQUEST_GET_MAX_LUN 0xfe
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32 signature;
|
||||
uint32 tag;
|
||||
uint32 data_transfer_length;
|
||||
uint8 flags;
|
||||
uint8 lun;
|
||||
uint8 command_block_length;
|
||||
uint8 command_block[16];
|
||||
} _PACKED command_block_wrapper;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32 signature;
|
||||
uint32 tag;
|
||||
uint32 data_residue;
|
||||
uint8 status;
|
||||
} _PACKED command_status_wrapper;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -709,7 +709,7 @@ usb_disk_device_added(usb_device newDevice, void **cookie)
|
||||
if (interface == NULL)
|
||||
continue;
|
||||
|
||||
if (interface->descr->interface_class == 0x08 /* mass storage */
|
||||
if (interface->descr->interface_class == USB_MASS_STORAGE_DEVICE_CLASS
|
||||
&& (interface->descr->interface_subclass == 0x06 /* SCSI */
|
||||
|| interface->descr->interface_subclass == 0x02 /* ATAPI */
|
||||
|| interface->descr->interface_subclass == 0x05 /* ATAPI */)
|
||||
|
||||
@@ -5,27 +5,18 @@
|
||||
* Authors:
|
||||
* Michael Lotz <mmlr@mlotz.ch>
|
||||
*/
|
||||
|
||||
#ifndef _USB_DISK_H_
|
||||
#define _USB_DISK_H_
|
||||
|
||||
|
||||
#include <lock.h>
|
||||
#include <USB3.h>
|
||||
#include <usb/USB_massbulk.h>
|
||||
|
||||
|
||||
#define REQUEST_MASS_STORAGE_RESET 0xff
|
||||
#define REQUEST_GET_MAX_LUN 0xfe
|
||||
#define MAX_LOGICAL_UNIT_NUMBER 15
|
||||
#define ATAPI_COMMAND_LENGTH 12
|
||||
|
||||
#define CBW_SIGNATURE 0x43425355
|
||||
#define CBW_DATA_OUTPUT 0x00
|
||||
#define CBW_DATA_INPUT 0x80
|
||||
|
||||
#define CSW_SIGNATURE 0x53425355
|
||||
#define CSW_STATUS_COMMAND_PASSED 0x00
|
||||
#define CSW_STATUS_COMMAND_FAILED 0x01
|
||||
#define CSW_STATUS_PHASE_ERROR 0x02
|
||||
|
||||
#define SYNC_SUPPORT_RELOAD 5
|
||||
|
||||
typedef struct device_lun_s device_lun;
|
||||
@@ -81,22 +72,4 @@ struct device_lun_s {
|
||||
};
|
||||
|
||||
|
||||
typedef struct command_block_wrapper_s {
|
||||
uint32 signature;
|
||||
uint32 tag;
|
||||
uint32 data_transfer_length;
|
||||
uint8 flags;
|
||||
uint8 lun;
|
||||
uint8 command_block_length;
|
||||
uint8 command_block[16];
|
||||
} _PACKED command_block_wrapper;
|
||||
|
||||
|
||||
typedef struct command_status_wrapper_s {
|
||||
uint32 signature;
|
||||
uint32 tag;
|
||||
uint32 data_residue;
|
||||
uint8 status;
|
||||
} _PACKED command_status_wrapper;
|
||||
|
||||
#endif // _USB_DISK_H_
|
||||
|
||||
Reference in New Issue
Block a user