Deleted Added
full compact
ustorage_fs.c (190174) ustorage_fs.c (190181)
1/* $FreeBSD: head/sys/dev/usb/storage/ustorage_fs.c 190174 2009-03-20 19:04:31Z thompsa $ */
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
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#define USTORAGE_FS_BULK_SIZE (1UL << 17)
63#define USTORAGE_FS_MAX_LUN 8
62#ifndef USTORAGE_FS_BULK_SIZE
63#define USTORAGE_FS_BULK_SIZE (1UL << 17) /* bytes */
64#endif
64
65
66#define USTORAGE_FS_MAX_LUN 8 /* units */
67
65/*
66 * The SCSI ID string must be exactly 28 characters long
67 * exluding the terminating zero.
68 */
69#ifndef USTORAGE_FS_ID_STRING
70#define USTORAGE_FS_ID_STRING \
71 "FreeBSD " /* 8 */ \
72 "File-Stor Gadget" /* 16 */ \

--- 58 unchanged lines hidden (view full) ---

131#define CSWSTATUS_FAILED 0x1
132#define CSWSTATUS_PHASE 0x2
133} __packed ustorage_fs_bbb_csw_t;
134
135#define USTORAGE_FS_BBB_CSW_SIZE 13
136
137struct ustorage_fs_lun {
138
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
139 void *memory_image;
142 uint8_t *memory_image;
140
141 uint32_t num_sectors;
142 uint32_t sense_data;
143 uint32_t sense_data_info;
144 uint32_t unit_attention_data;
145
146 uint8_t read_only:1;
147 uint8_t prevent_medium_removal:1;

--- 1217 unchanged lines hidden (view full) ---

1365 (len > currlun->num_sectors) ||
1366 (lba >= currlun->num_sectors)) {
1367 currlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
1368 return (1);
1369 }
1370 file_offset = lba;
1371 file_offset <<= 9;
1372
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
1373 sc->sc_transfer.data_ptr =
1374 USB_ADD_BYTES(currlun->memory_image, (uint32_t)file_offset);
1376 sc->sc_transfer.data_ptr = currlun->memory_image + file_offset;
1375
1376 return (0);
1377}
1378
1379/*------------------------------------------------------------------------*
1380 * ustorage_fs_write - write data to disk
1381 *
1382 * Return values:

--- 47 unchanged lines hidden (view full) ---

1430 (len > currlun->num_sectors) ||
1431 (lba >= currlun->num_sectors)) {
1432 currlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
1433 return (1);
1434 }
1435 file_offset = lba;
1436 file_offset <<= 9;
1437
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
1438 sc->sc_transfer.data_ptr =
1439 USB_ADD_BYTES(currlun->memory_image, (uint32_t)file_offset);
1440 sc->sc_transfer.data_ptr = currlun->memory_image + file_offset;
1440
1441 return (0);
1442}
1443
1444/*------------------------------------------------------------------------*
1445 * ustorage_fs_min_len
1446 *
1447 * Return values:

--- 474 unchanged lines hidden ---
1441
1442 return (0);
1443}
1444
1445/*------------------------------------------------------------------------*
1446 * ustorage_fs_min_len
1447 *
1448 * Return values:

--- 474 unchanged lines hidden ---