2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (C) 2009-2012 Semihalf
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include <sys/ioccom.h>
35 #include <sys/types.h>
39 #define MAX_ECC_BYTES 512
40 #define MAX_BAD_BLOCKS 512
41 #define DEV_MODEL_STR_SIZE 21
42 #define MAN_STR_SIZE 13
43 #define FILENAME_SIZE 20
45 #define MAX_CHIPS (MAX_SIM_DEV*MAX_CTRL_CS)
47 #define NANDSIM_OUTPUT_NONE 0x0
48 #define NANDSIM_OUTPUT_CONSOLE 0x1
49 #define NANDSIM_OUTPUT_RAM 0x2
50 #define NANDSIM_OUTPUT_FILE 0x3
52 struct sim_ctrl_chip {
57 #define NANDSIM_BASE 'A'
64 #define NANDSIM_SIM_PARAM _IOW(NANDSIM_BASE, 1, struct sim_param)
72 char filename[FILENAME_SIZE];
73 uint16_t ecc_layout[MAX_ECC_BYTES];
75 #define NANDSIM_CREATE_CTRL _IOW(NANDSIM_BASE, 2, struct sim_ctrl)
76 #define NANDSIM_DESTROY_CTRL _IOW(NANDSIM_BASE, 3, int)
84 char device_model[DEV_MODEL_STR_SIZE];
85 char manufacturer[MAN_STR_SIZE];
86 uint8_t col_addr_cycles;
87 uint8_t row_addr_cycles;
93 uint32_t blks_per_lun;
101 uint32_t error_ratio;
103 uint32_t bad_block_map[MAX_BAD_BLOCKS];
107 #define NANDSIM_CREATE_CHIP _IOW(NANDSIM_BASE, 3, struct sim_chip)
109 struct sim_chip_destroy {
113 #define NANDSIM_DESTROY_CHIP _IOW(NANDSIM_BASE, 4, struct sim_chip_destroy)
115 #define NANDSIM_START_CTRL _IOW(NANDSIM_BASE, 5, int)
116 #define NANDSIM_STOP_CTRL _IOW(NANDSIM_BASE, 6, int)
117 #define NANDSIM_RESTART_CTRL _IOW(NANDSIM_BASE, 7, int)
119 #define NANDSIM_STATUS_CTRL _IOWR(NANDSIM_BASE, 8, struct sim_ctrl)
120 #define NANDSIM_STATUS_CHIP _IOWR(NANDSIM_BASE, 9, struct sim_chip)
128 #define SIM_MOD_LOG_LEVEL 0
129 #define SIM_MOD_ERASE_TIME 1
130 #define SIM_MOD_PROG_TIME 2
131 #define SIM_MOD_READ_TIME 3
132 #define SIM_MOD_CCS_TIME 4
133 #define SIM_MOD_ERROR_RATIO 5
135 #define NANDSIM_MODIFY _IOW(NANDSIM_BASE, 10, struct sim_mod)
136 #define NANDSIM_FREEZE _IOW(NANDSIM_BASE, 11, struct sim_ctrl_chip)
146 #define NANDSIM_INJECT_ERROR _IOW(NANDSIM_BASE, 20, struct sim_error)
148 #define NANDSIM_GOOD_BLOCK 0
149 #define NANDSIM_BAD_BLOCK 1
150 struct sim_block_state {
157 #define NANDSIM_SET_BLOCK_STATE _IOW(NANDSIM_BASE, 21, struct sim_block_state)
158 #define NANDSIM_GET_BLOCK_STATE _IOWR(NANDSIM_BASE, 22, struct sim_block_state)
165 #define NANDSIM_PRINT_LOG _IOWR(NANDSIM_BASE, 23, struct sim_log)
174 #define NANDSIM_DUMP _IOWR(NANDSIM_BASE, 24, struct sim_dump)
175 #define NANDSIM_RESTORE _IOWR(NANDSIM_BASE, 25, struct sim_dump)
177 #endif /* _NANDSIM_H_ */