diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2017-01-05 16:21:55 +0100 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2017-01-07 15:52:33 +0100 |
commit | 456a3fc952d34a3e8781ca100851e6253c537109 (patch) | |
tree | 8406a3e38eb8a399a0bb155314be0ddc2d31e5a1 /utils/imxtools/scsitools/stmp_scsi.h | |
parent | 950f4bdc027cb8c83fd2145590549fdcf5522078 (diff) | |
download | rockbox-456a3fc952d34a3e8781ca100851e6253c537109.tar.gz rockbox-456a3fc952d34a3e8781ca100851e6253c537109.zip |
imxtools: various fixes for Windows
Don't use colors since the terminal doesn't support it. Also packing is broken
on MinGW so use #pragma pack when compiling for windows, this is also supported
by MSCV.
Change-Id: I635649d52ed5f2e0af46cb9ca2ec325955b2ddb2
Diffstat (limited to 'utils/imxtools/scsitools/stmp_scsi.h')
-rw-r--r-- | utils/imxtools/scsitools/stmp_scsi.h | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/utils/imxtools/scsitools/stmp_scsi.h b/utils/imxtools/scsitools/stmp_scsi.h index 56068b5d4c..e85122041f 100644 --- a/utils/imxtools/scsitools/stmp_scsi.h +++ b/utils/imxtools/scsitools/stmp_scsi.h | |||
@@ -25,6 +25,17 @@ | |||
25 | #include <stdbool.h> | 25 | #include <stdbool.h> |
26 | #include "rbscsi.h" | 26 | #include "rbscsi.h" |
27 | 27 | ||
28 | #if defined(_WIN32) || defined(__WIN32__) | ||
29 | /* Mingw has a curious behaviour: it packs only the last field, see | ||
30 | * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991 */ | ||
31 | #pragma pack(push) | ||
32 | #pragma pack(1) | ||
33 | #define RB_POP_PACK | ||
34 | #define RB_PACKED | ||
35 | #else | ||
36 | #define RB_PACKED __attribute__((packed)) | ||
37 | #endif | ||
38 | |||
28 | /** | 39 | /** |
29 | * Low-Level SCSI stuff | 40 | * Low-Level SCSI stuff |
30 | */ | 41 | */ |
@@ -57,17 +68,17 @@ struct scsi_stmp_protocol_version_t | |||
57 | { | 68 | { |
58 | uint8_t major; | 69 | uint8_t major; |
59 | uint8_t minor; | 70 | uint8_t minor; |
60 | } __attribute__((packed)); | 71 | } RB_PACKED; |
61 | 72 | ||
62 | struct scsi_stmp_rom_rev_id_t | 73 | struct scsi_stmp_rom_rev_id_t |
63 | { | 74 | { |
64 | uint16_t rev; /* big-endian */ | 75 | uint16_t rev; /* big-endian */ |
65 | } __attribute__((packed)); | 76 | } RB_PACKED; |
66 | 77 | ||
67 | struct scsi_stmp_chip_major_rev_id_t | 78 | struct scsi_stmp_chip_major_rev_id_t |
68 | { | 79 | { |
69 | uint16_t rev; /* big-endian */ | 80 | uint16_t rev; /* big-endian */ |
70 | } __attribute__((packed)); | 81 | } RB_PACKED; |
71 | 82 | ||
72 | struct scsi_stmp_logical_table_entry_t | 83 | struct scsi_stmp_logical_table_entry_t |
73 | { | 84 | { |
@@ -75,7 +86,7 @@ struct scsi_stmp_logical_table_entry_t | |||
75 | uint8_t type; | 86 | uint8_t type; |
76 | uint8_t tag; | 87 | uint8_t tag; |
77 | uint64_t size; /* big-endian */ | 88 | uint64_t size; /* big-endian */ |
78 | } __attribute__((packed)); | 89 | } RB_PACKED; |
79 | 90 | ||
80 | #define SCSI_STMP_DRIVE_TYPE_USER 0 | 91 | #define SCSI_STMP_DRIVE_TYPE_USER 0 |
81 | #define SCSI_STMP_DRIVE_TYPE_SYSTEM 1 | 92 | #define SCSI_STMP_DRIVE_TYPE_SYSTEM 1 |
@@ -87,7 +98,7 @@ struct scsi_stmp_logical_table_entry_t | |||
87 | struct scsi_stmp_logical_table_header_t | 98 | struct scsi_stmp_logical_table_header_t |
88 | { | 99 | { |
89 | uint16_t count; /* big-endian */ | 100 | uint16_t count; /* big-endian */ |
90 | } __attribute__((packed)); | 101 | } RB_PACKED; |
91 | 102 | ||
92 | #define SCSI_STMP_MEDIA_INFO_NR_DRIVES 0 /** Number of drives (obsolete) */ | 103 | #define SCSI_STMP_MEDIA_INFO_NR_DRIVES 0 /** Number of drives (obsolete) */ |
93 | #define SCSI_STMP_MEDIA_INFO_SIZE 1 /** Total size (bytes) */ | 104 | #define SCSI_STMP_MEDIA_INFO_SIZE 1 /** Total size (bytes) */ |
@@ -127,12 +138,12 @@ struct scsi_stmp_logical_table_header_t | |||
127 | struct scsi_stmp_logical_media_info_type_t | 138 | struct scsi_stmp_logical_media_info_type_t |
128 | { | 139 | { |
129 | uint8_t type; | 140 | uint8_t type; |
130 | } __attribute__((packed)); | 141 | } RB_PACKED; |
131 | 142 | ||
132 | struct scsi_stmp_logical_media_info_manufacturer_t | 143 | struct scsi_stmp_logical_media_info_manufacturer_t |
133 | { | 144 | { |
134 | uint32_t type; /* big-endian */ | 145 | uint32_t type; /* big-endian */ |
135 | } __attribute__((packed)); | 146 | } RB_PACKED; |
136 | 147 | ||
137 | #define SCSI_STMP_DRIVE_INFO_SECTOR_SIZE 0 /** Sector Size (bytes) */ | 148 | #define SCSI_STMP_DRIVE_INFO_SECTOR_SIZE 0 /** Sector Size (bytes) */ |
138 | #define SCSI_STMP_DRIVE_INFO_ERASE_SIZE 1 /** Erase Size (bytes) */ | 149 | #define SCSI_STMP_DRIVE_INFO_ERASE_SIZE 1 /** Erase Size (bytes) */ |
@@ -170,29 +181,29 @@ struct scsi_stmp_logical_media_info_manufacturer_t | |||
170 | struct scsi_stmp_logical_drive_info_sector_t | 181 | struct scsi_stmp_logical_drive_info_sector_t |
171 | { | 182 | { |
172 | uint32_t size; /* big-endian */ | 183 | uint32_t size; /* big-endian */ |
173 | } __attribute__((packed)); | 184 | } RB_PACKED; |
174 | 185 | ||
175 | struct scsi_stmp_logical_drive_info_count_t | 186 | struct scsi_stmp_logical_drive_info_count_t |
176 | { | 187 | { |
177 | uint64_t count; /* big-endian */ | 188 | uint64_t count; /* big-endian */ |
178 | } __attribute__((packed)); | 189 | } RB_PACKED; |
179 | 190 | ||
180 | struct scsi_stmp_logical_drive_info_size_t | 191 | struct scsi_stmp_logical_drive_info_size_t |
181 | { | 192 | { |
182 | uint64_t size; /* big-endian */ | 193 | uint64_t size; /* big-endian */ |
183 | } __attribute__((packed)); | 194 | } RB_PACKED; |
184 | 195 | ||
185 | struct scsi_stmp_logical_drive_info_type_t | 196 | struct scsi_stmp_logical_drive_info_type_t |
186 | { | 197 | { |
187 | uint8_t type; | 198 | uint8_t type; |
188 | } __attribute__((packed)); | 199 | } RB_PACKED; |
189 | 200 | ||
190 | struct scsi_stmp_logical_drive_info_version_t | 201 | struct scsi_stmp_logical_drive_info_version_t |
191 | { | 202 | { |
192 | uint16_t major; | 203 | uint16_t major; |
193 | uint16_t minor; | 204 | uint16_t minor; |
194 | uint16_t revision; | 205 | uint16_t revision; |
195 | } __attribute__((packed)); | 206 | } RB_PACKED; |
196 | 207 | ||
197 | struct stmp_device_t; | 208 | struct stmp_device_t; |
198 | typedef struct stmp_device_t *stmp_device_t; | 209 | typedef struct stmp_device_t *stmp_device_t; |
@@ -253,7 +264,11 @@ struct stmp_logical_media_table_t | |||
253 | { | 264 | { |
254 | struct scsi_stmp_logical_table_header_t header; | 265 | struct scsi_stmp_logical_table_header_t header; |
255 | struct scsi_stmp_logical_table_entry_t entry[]; | 266 | struct scsi_stmp_logical_table_entry_t entry[]; |
256 | }__attribute__((packed)) table; | 267 | }RB_PACKED table; |
268 | |||
269 | #ifdef RB_POP_PACK | ||
270 | #pragma pack(pop) | ||
271 | #endif | ||
257 | 272 | ||
258 | struct stmp_logical_media_info_t | 273 | struct stmp_logical_media_info_t |
259 | { | 274 | { |