36
36
extern "C" {
37
37
#endif
38
38
39
- #ifndef __packed
40
- #define __packed __attribute__((__packed__))
39
+ #if defined(__IAR_SYSTEMS_ICC__ )
40
+ #define STRUCT_PACKED __packed struct
41
+ #else
42
+ #define STRUCT_PACKED struct __attribute__((__packed__))
41
43
#endif
42
44
43
45
struct flash_area ;
@@ -136,12 +138,12 @@ struct flash_area;
136
138
*/
137
139
#define IMAGE_TLV_ANY 0xffff /* Used to iterate over all TLV */
138
140
139
- struct image_version {
141
+ STRUCT_PACKED image_version {
140
142
uint8_t iv_major ;
141
143
uint8_t iv_minor ;
142
144
uint16_t iv_revision ;
143
145
uint32_t iv_build_num ;
144
- } __packed ;
146
+ };
145
147
146
148
struct image_dependency {
147
149
uint8_t image_id ; /* Image index (from 0) */
@@ -154,7 +156,7 @@ struct image_dependency {
154
156
};
155
157
156
158
/** Image header. All fields are in little endian byte order. */
157
- struct image_header {
159
+ STRUCT_PACKED image_header {
158
160
uint32_t ih_magic ;
159
161
uint32_t ih_load_addr ;
160
162
uint16_t ih_hdr_size ; /* Size of image header (bytes). */
@@ -163,19 +165,19 @@ struct image_header {
163
165
uint32_t ih_flags ; /* IMAGE_F_[...]. */
164
166
struct image_version ih_ver ;
165
167
uint32_t _pad1 ;
166
- } __packed ;
168
+ };
167
169
168
170
/** Image TLV header. All fields in little endian. */
169
- struct image_tlv_info {
171
+ STRUCT_PACKED image_tlv_info {
170
172
uint16_t it_magic ;
171
173
uint16_t it_tlv_tot ; /* size of TLV area (including tlv_info header) */
172
- } __packed ;
174
+ };
173
175
174
176
/** Image trailer TLV format. All fields in little endian. */
175
- struct image_tlv {
177
+ STRUCT_PACKED image_tlv {
176
178
uint16_t it_type ; /* IMAGE_TLV_[...]. */
177
179
uint16_t it_len ; /* Data length (not including TLV header). */
178
- } __packed ;
180
+ };
179
181
180
182
#define ENCRYPTIONFLAGS (IMAGE_F_ENCRYPTED_AES128 | IMAGE_F_ENCRYPTED_AES256)
181
183
#define IS_ENCRYPTED (hdr ) (((hdr)->ih_flags & IMAGE_F_ENCRYPTED_AES128) \
0 commit comments