blob: 86c9379ca9e739fd267f26f162c1e29846d5ab89 [file] [log] [blame]
Simon Glass1377d442022-09-21 16:21:36 +02001/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Emulation of enough SCSI commands to find and read from a unit
4 *
5 * Copyright 2022 Google LLC
6 * Written by Simon Glass <sjg@chromium.org>
7 *
8 * implementations of SCSI functions required so that CONFIG_SCSI can be enabled
9 * for sandbox
10 */
11
12#ifndef __scsi_emul_h
13#define __scsi_emul_h
14
15/**
16 * struct scsi_emul_info - information for emulating a SCSI device
17 *
Simon Glass0c12d9d2022-09-21 16:21:38 +020018 * @vendor: Vendor name
19 * @product: Product name
Simon Glassa3718f12022-09-21 16:21:39 +020020 * @block_size: Block size of device in bytes (normally 512)
Simon Glass0c12d9d2022-09-21 16:21:38 +020021 *
Simon Glass1377d442022-09-21 16:21:36 +020022 * @phase: Current SCSI phase
23 * @buff_used: Number of bytes ready to transfer back to host
24 * @read_len: Number of bytes of data left in the current read command
25 * @alloc_len: Allocation length from the last incoming command
26 * @transfer_len: Transfer length from CBW header
Simon Glassfc7a7ed2022-09-21 16:21:37 +020027 * @buff: Data buffer for outgoing data
Simon Glass1377d442022-09-21 16:21:36 +020028 */
29struct scsi_emul_info {
Simon Glassfc7a7ed2022-09-21 16:21:37 +020030 /* provided by the caller: */
31 void *buff;
Simon Glass0c12d9d2022-09-21 16:21:38 +020032 const char *vendor;
33 const char *product;
Simon Glassa3718f12022-09-21 16:21:39 +020034 int block_size;
Simon Glassfc7a7ed2022-09-21 16:21:37 +020035
36 /* state maintained by the emulator: */
Simon Glass1377d442022-09-21 16:21:36 +020037 enum scsi_cmd_phase phase;
38 int buff_used;
39 int read_len;
40 int alloc_len;
41 uint transfer_len;
42};
43
44#endif