Simon Glass | 1377d44 | 2022-09-21 16:21:36 +0200 | [diff] [blame] | 1 | /* 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 Glass | 0c12d9d | 2022-09-21 16:21:38 +0200 | [diff] [blame] | 18 | * @vendor: Vendor name |
| 19 | * @product: Product name |
Simon Glass | a3718f1 | 2022-09-21 16:21:39 +0200 | [diff] [blame] | 20 | * @block_size: Block size of device in bytes (normally 512) |
Simon Glass | f148ad1 | 2022-09-21 16:21:40 +0200 | [diff] [blame^] | 21 | * @file_size: Size of the backing file for this emulator, in bytes |
Simon Glass | 0c12d9d | 2022-09-21 16:21:38 +0200 | [diff] [blame] | 22 | * |
Simon Glass | 1377d44 | 2022-09-21 16:21:36 +0200 | [diff] [blame] | 23 | * @phase: Current SCSI phase |
| 24 | * @buff_used: Number of bytes ready to transfer back to host |
| 25 | * @read_len: Number of bytes of data left in the current read command |
| 26 | * @alloc_len: Allocation length from the last incoming command |
| 27 | * @transfer_len: Transfer length from CBW header |
Simon Glass | fc7a7ed | 2022-09-21 16:21:37 +0200 | [diff] [blame] | 28 | * @buff: Data buffer for outgoing data |
Simon Glass | 1377d44 | 2022-09-21 16:21:36 +0200 | [diff] [blame] | 29 | */ |
| 30 | struct scsi_emul_info { |
Simon Glass | fc7a7ed | 2022-09-21 16:21:37 +0200 | [diff] [blame] | 31 | /* provided by the caller: */ |
| 32 | void *buff; |
Simon Glass | 0c12d9d | 2022-09-21 16:21:38 +0200 | [diff] [blame] | 33 | const char *vendor; |
| 34 | const char *product; |
Simon Glass | a3718f1 | 2022-09-21 16:21:39 +0200 | [diff] [blame] | 35 | int block_size; |
Simon Glass | f148ad1 | 2022-09-21 16:21:40 +0200 | [diff] [blame^] | 36 | loff_t file_size; |
Simon Glass | fc7a7ed | 2022-09-21 16:21:37 +0200 | [diff] [blame] | 37 | |
| 38 | /* state maintained by the emulator: */ |
Simon Glass | 1377d44 | 2022-09-21 16:21:36 +0200 | [diff] [blame] | 39 | enum scsi_cmd_phase phase; |
| 40 | int buff_used; |
| 41 | int read_len; |
| 42 | int alloc_len; |
| 43 | uint transfer_len; |
| 44 | }; |
| 45 | |
| 46 | #endif |