summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-10-20 18:22:55 -0600
committerTom Rini <trini@konsulko.com>2022-10-31 11:02:44 -0400
commit2ff3db3a1c5ef128a4f33c22d7be8ee37fca3613 (patch)
treeb039cad266e4cb9f32200eadbaebb5f6c484e514 /include
parent606b926f9d76eaab11be2d95cfd7734644e1627c (diff)
usb: Update the test to cover reading and writing
Add test coverage for blk_write() as well. The blk_erase() is not tested for now as the USB stor interface does not support erase. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/scsi.h10
-rw-r--r--include/scsi_emul.h16
2 files changed, 22 insertions, 4 deletions
diff --git a/include/scsi.h b/include/scsi.h
index 94e1d8ccb2..9efefea99b 100644
--- a/include/scsi.h
+++ b/include/scsi.h
@@ -255,6 +255,16 @@ struct __packed scsi_read10_req {
u8 spare2[3];
};
+/** struct scsi_write10_req - data for the write10 command */
+struct __packed scsi_write10_req {
+ u8 cmd;
+ u8 lun_flags;
+ u32 lba;
+ u8 spare;
+ u16 xfer_len;
+ u8 spare2[3];
+};
+
/**
* struct scsi_plat - stores information about SCSI controller
*
diff --git a/include/scsi_emul.h b/include/scsi_emul.h
index 13c3f860b4..d439f7c00c 100644
--- a/include/scsi_emul.h
+++ b/include/scsi_emul.h
@@ -41,13 +41,20 @@ struct scsi_emul_info {
enum scsi_cmd_phase phase;
int buff_used;
int read_len;
+ int write_len;
uint seek_pos;
int alloc_len;
uint transfer_len;
};
-/* Indicates that a read is being started */
-#define SCSI_EMUL_DO_READ 1
+/**
+ * Return value from sb_scsi_emul_command() indicates that a read or write is
+ * being started
+ */
+enum {
+ SCSI_EMUL_DO_READ = 1,
+ SCSI_EMUL_DO_WRITE = 2,
+};
/**
* sb_scsi_emul_command() - Process a SCSI command
@@ -61,8 +68,9 @@ struct scsi_emul_info {
* @info: Emulation information
* @req: Request to process
* @len: Length of request in bytes
- * @return SCSI_EMUL_DO_READ if a read has started, 0 if some other operation
- * has started, -ve if there was an error
+ * @return SCSI_EMUL_DO_READ if a read has started, SCSI_EMUL_DO_WRITE if a
+ * write has started, 0 if some other operation has started, -ve if there
+ * was an error
*/
int sb_scsi_emul_command(struct scsi_emul_info *info,
const struct scsi_cmd *req, int len);