1 // Copyright (C) 2014 Michael McMaster <michael@codesrc.com>
3 // This file is part of SCSI2SD.
5 // SCSI2SD is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // SCSI2SD is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with SCSI2SD. If not, see <http://www.gnu.org/licenses/>.
24 /* Common type definitions shared between the firmware and config tools
26 The configuration data is now stored on the SD card, occupying the
42 #define S2S_MAX_TARGETS 7
43 #define S2S_CFG_SIZE (S2S_MAX_TARGETS * sizeof(S2S_TargetCfg) + sizeof(S2S_BoardCfg))
47 S2S_CFG_TARGET_ID_BITS
= 0x07,
48 S2S_CFG_TARGET_ENABLED
= 0x80
49 } S2S_CFG_TARGET_FLAGS
;
53 S2S_CFG_ENABLE_UNIT_ATTENTION
= 1,
54 S2S_CFG_ENABLE_PARITY
= 2,
55 S2S_CFG_ENABLE_SCSI2
= 4,
56 S2S_CFG_DISABLE_GLITCH
= 8,
57 S2S_CFG_ENABLE_CACHE
= 16,
58 S2S_CFG_ENABLE_DISCONNECT
= 32,
59 S2S_CFG_ENABLE_SEL_LATCH
= 64,
60 S2S_CFG_MAP_LUNS_TO_IDS
= 128
65 S2S_CFG_ENABLE_TERMINATOR
= 1
81 S2S_CFG_QUIRKS_NONE
= 0,
82 S2S_CFG_QUIRKS_APPLE
= 1,
83 S2S_CFG_QUIRKS_OMTI
= 2,
84 S2S_CFG_QUIRKS_XEBEC
= 4
89 S2S_CFG_SPEED_NoLimit
,
90 S2S_CFG_SPEED_ASYNC_15
,
91 S2S_CFG_SPEED_ASYNC_33
,
92 S2S_CFG_SPEED_ASYNC_50
,
94 S2S_CFG_SPEED_SYNC_10
,
98 typedef struct __attribute__((packed
))
100 // bits 7 -> 3 = S2S_CFG_TARGET_FLAGS
101 // bits 2 -> 0 = target SCSI ID.
104 uint8_t deviceType
; // S2S_CFG_TYPE
105 uint8_t flagsDEPRECATED
; // S2S_CFG_FLAGS, removed in v4.5
106 uint8_t deviceTypeModifier
; // Used in INQUIRY response.
108 uint32_t sdSectorStart
;
109 uint32_t scsiSectors
;
111 uint16_t bytesPerSector
;
113 // Max allowed by legacy IBM-PC bios is 6 bits (63)
114 uint16_t sectorsPerTrack
;
116 // MS-Dos up to 7.10 will crash on >= 256 heads.
117 uint16_t headsPerCylinder
;
125 uint16_t quirks
; // S2S_CFG_QUIRKS
127 uint8_t reserved
[64]; // Pad out to 128 bytes for main section.
130 typedef struct __attribute__((packed
))
132 char magic
[4]; // 'BCFG'
133 uint8_t flags
; // S2S_CFG_FLAGS
134 uint8_t startupDelay
; // Seconds.
135 uint8_t selectionDelay
; // milliseconds. 255 = auto
136 uint8_t flags6
; // S2S_CFG_FLAGS6
140 uint8_t reserved
[119]; // Pad out to 128 bytes
145 S2S_CMD_NONE
, // Invalid
148 // uint8_t S2S_CFG_PING
154 // uint8_t S2S_CFG_WRITEFLASH
155 // uint8_t[256] flashData
156 // uint8_t flashArray
163 // uint8_t S2S_CFG_READFLASH
164 // uint8_t flashArray
167 // 256 bytes of flash
171 // uint8_t S2S_CFG_REBOOT
176 // uint8_t S2S_CFG_INFO
183 // uint8_t S2S_CFG_SCSITEST
186 // uint8_t result code (0 = passed)
190 // uint8_t S2S_CFG_DEVINFO
192 // uint16_t protocol version (MSB)
193 // uint16_t firmware version (MSB)
194 // uint32_t SD capacity(MSB)
198 // uint8_t S2S_CFG_SD_WRITE
199 // uint32_t Sector Number (MSB)
206 // uint8_t S2S_CFG_SD_READ
207 // uint32_t Sector Number (MSB)
213 // uint8_t S2S_CFG_DEBUG
231 #include <type_traits>
233 std::is_pod
<S2S_TargetCfg
>::value
, "Misuse of TargetConfig struct"
236 sizeof(S2S_TargetCfg
) == 128,
237 "TargetConfig struct size mismatch"
241 std::is_pod
<S2S_BoardCfg
>::value
, "Misuse of BoardConfig struct"
244 sizeof(S2S_BoardCfg
) == 128,
245 "BoardConfig struct size mismatch"