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 MAX_LOGICAL_UNIT_NUMBER 15 18 #define ATAPI_COMMAND_LENGTH 12 19 20 #define SYNC_SUPPORT_RELOAD 5 21 22 typedef struct device_lun_s device_lun; 23 24 // holds common information about an attached device (pointed to by luns) 25 typedef struct disk_device_s { 26 usb_device device; 27 uint32 device_number; 28 bool removed; 29 uint32 open_count; 30 mutex lock; 31 void * link; 32 33 // device state 34 usb_pipe bulk_in; 35 usb_pipe bulk_out; 36 uint8 interface; 37 uint32 current_tag; 38 uint8 sync_support; 39 bool tur_supported; 40 bool is_atapi; 41 42 // used to store callback information 43 sem_id notify; 44 status_t status; 45 size_t actual_length; 46 47 // logical units of this device 48 uint8 lun_count; 49 device_lun **luns; 50 } disk_device; 51 52 53 // represents a logical unit on the pointed to device - this gets published 54 struct device_lun_s { 55 disk_device *device; 56 char name[32]; 57 uint8 logical_unit_number; 58 bool should_sync; 59 60 // device information through read capacity/inquiry 61 bool media_present; 62 bool media_changed; 63 uint32 block_count; 64 uint32 block_size; 65 uint8 device_type; 66 bool removable; 67 bool write_protected; 68 69 char vendor_name[8]; 70 char product_name[16]; 71 char product_revision[4]; 72 }; 73 74 75 #endif // _USB_DISK_H_ 76