1 /* 2 * Copyright 2008, Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Michael Lotz <mmlr@mlotz.ch> 7 */ 8 #ifndef _USB_DISK_H_ 9 #define _USB_DISK_H_ 10 11 12 #include <lock.h> 13 #include <USB3.h> 14 #include <usb/USB_massbulk.h> 15 16 17 #define REQUEST_MASS_STORAGE_RESET 0xff 18 #define REQUEST_GET_MAX_LUN 0xfe 19 #define MAX_LOGICAL_UNIT_NUMBER 15 20 #define ATAPI_COMMAND_LENGTH 12 21 22 #define SYNC_SUPPORT_RELOAD 5 23 24 typedef struct device_lun_s device_lun; 25 26 // holds common information about an attached device (pointed to by luns) 27 typedef struct disk_device_s { 28 usb_device device; 29 uint32 device_number; 30 bool removed; 31 uint32 open_count; 32 mutex lock; 33 void * link; 34 35 // device state 36 usb_pipe bulk_in; 37 usb_pipe bulk_out; 38 usb_pipe interrupt; 39 uint8 interface; 40 uint32 current_tag; 41 uint8 sync_support; 42 bool tur_supported; 43 bool is_atapi; 44 bool is_ufi; 45 46 // used to store callback information 47 sem_id notify; 48 status_t status; 49 size_t actual_length; 50 51 // used to store interrupt result 52 unsigned char interruptBuffer[2]; 53 sem_id interruptLock; 54 55 // logical units of this device 56 uint8 lun_count; 57 device_lun **luns; 58 } disk_device; 59 60 61 // represents a logical unit on the pointed to device - this gets published 62 struct device_lun_s { 63 disk_device *device; 64 char name[32]; 65 uint8 logical_unit_number; 66 bool should_sync; 67 68 // device information through read capacity/inquiry 69 bool media_present; 70 bool media_changed; 71 uint64 block_count; 72 uint32 block_size; 73 uint32 physical_block_size; 74 uint8 device_type; 75 bool removable; 76 bool write_protected; 77 78 char vendor_name[8]; 79 char product_name[16]; 80 char product_revision[4]; 81 }; 82 83 84 typedef struct interrupt_status_wrapper_s { 85 uint8 status; 86 uint8 misc; 87 } _PACKED interrupt_status_wrapper; 88 89 90 #endif // _USB_DISK_H_ 91