1/* $FreeBSD: head/sys/dev/usb/storage/ustorage_fs.c 190181 2009-03-20 21:50:54Z thompsa $ */ |
2/*- 3 * Copyright (C) 2003-2005 Alan Stern 4 * Copyright (C) 2008 Hans Petter Selasky 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: --- 44 unchanged lines hidden (view full) --- 54 55SYSCTL_NODE(_hw_usb2, OID_AUTO, ustorage_fs, CTLFLAG_RW, 0, "USB ustorage_fs"); 56SYSCTL_INT(_hw_usb2_ustorage_fs, OID_AUTO, debug, CTLFLAG_RW, 57 &ustorage_fs_debug, 0, "ustorage_fs debug level"); 58#endif 59 60/* Define some limits */ 61 |
62#ifndef USTORAGE_FS_BULK_SIZE 63#define USTORAGE_FS_BULK_SIZE (1UL << 17) /* bytes */ 64#endif |
65 |
66#define USTORAGE_FS_MAX_LUN 8 /* units */ 67 |
68/* 69 * The SCSI ID string must be exactly 28 characters long 70 * exluding the terminating zero. 71 */ 72#ifndef USTORAGE_FS_ID_STRING 73#define USTORAGE_FS_ID_STRING \ 74 "FreeBSD " /* 8 */ \ 75 "File-Stor Gadget" /* 16 */ \ --- 58 unchanged lines hidden (view full) --- 134#define CSWSTATUS_FAILED 0x1 135#define CSWSTATUS_PHASE 0x2 136} __packed ustorage_fs_bbb_csw_t; 137 138#define USTORAGE_FS_BBB_CSW_SIZE 13 139 140struct ustorage_fs_lun { 141 |
142 uint8_t *memory_image; |
143 144 uint32_t num_sectors; 145 uint32_t sense_data; 146 uint32_t sense_data_info; 147 uint32_t unit_attention_data; 148 149 uint8_t read_only:1; 150 uint8_t prevent_medium_removal:1; --- 1217 unchanged lines hidden (view full) --- 1368 (len > currlun->num_sectors) || 1369 (lba >= currlun->num_sectors)) { 1370 currlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; 1371 return (1); 1372 } 1373 file_offset = lba; 1374 file_offset <<= 9; 1375 |
1376 sc->sc_transfer.data_ptr = currlun->memory_image + file_offset; |
1377 1378 return (0); 1379} 1380 1381/*------------------------------------------------------------------------* 1382 * ustorage_fs_write - write data to disk 1383 * 1384 * Return values: --- 47 unchanged lines hidden (view full) --- 1432 (len > currlun->num_sectors) || 1433 (lba >= currlun->num_sectors)) { 1434 currlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; 1435 return (1); 1436 } 1437 file_offset = lba; 1438 file_offset <<= 9; 1439 |
1440 sc->sc_transfer.data_ptr = currlun->memory_image + file_offset; |
1441 1442 return (0); 1443} 1444 1445/*------------------------------------------------------------------------* 1446 * ustorage_fs_min_len 1447 * 1448 * Return values: --- 474 unchanged lines hidden --- |