aboutsummaryrefslogtreecommitdiff
path: root/include/scsi_emul.h
diff options
context:
space:
mode:
authorSimon Glass2022-09-21 16:21:45 +0200
committerSimon Glass2022-09-25 13:59:38 -0600
commit02cea1145a5ad49e400bd100b907ad763db16863 (patch)
treec4c0bec672b962e0c0bd787b0dc38011066aa77b /include/scsi_emul.h
parent5eff9d9c36e9e2b2437743d989f25376b981700a (diff)
sandbox: scsi: Move request-handling code to scsi_emul
Move this code into the emulator file so it can be used by multiple drivers. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/scsi_emul.h')
-rw-r--r--include/scsi_emul.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/include/scsi_emul.h b/include/scsi_emul.h
index 3c52398e3ff..13c3f860b40 100644
--- a/include/scsi_emul.h
+++ b/include/scsi_emul.h
@@ -19,6 +19,7 @@
* @product: Product name
* @block_size: Block size of device in bytes (normally 512)
* @file_size: Size of the backing file for this emulator, in bytes
+ * @seek_block: Seek position for file (block number)
*
* @phase: Current SCSI phase
* @buff_used: Number of bytes ready to transfer back to host
@@ -34,13 +35,36 @@ struct scsi_emul_info {
const char *product;
int block_size;
loff_t file_size;
+ int seek_block;
/* state maintained by the emulator: */
enum scsi_cmd_phase phase;
int buff_used;
int read_len;
+ uint seek_pos;
int alloc_len;
uint transfer_len;
};
+/* Indicates that a read is being started */
+#define SCSI_EMUL_DO_READ 1
+
+/**
+ * sb_scsi_emul_command() - Process a SCSI command
+ *
+ * This sets up the response in info->buff and updates various other values
+ * in info.
+ *
+ * If SCSI_EMUL_DO_READ is returned then the caller should set up so that the
+ * backing file can be read, or return an error status if there is no file.
+ *
+ * @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
+ */
+int sb_scsi_emul_command(struct scsi_emul_info *info,
+ const struct scsi_cmd *req, int len);
+
#endif