Coverage Report

Created: 2025-07-18 06:26

/work/fu-ifwi-struct.c
Line
Count
Source (jump to first uncovered line)
1
/* auto-generated, do not modify */
2
#include "config.h"
3
4
#include "fu-ifwi-struct.h"
5
#include "fu-byte-array.h"
6
#include "fu-mem-private.h"
7
#include "fu-string.h"
8
9
#ifdef G_LOG_DOMAIN
10
  #undef G_LOG_DOMAIN
11
#endif
12
0
#define G_LOG_DOMAIN "FuStruct"
13
/* getters */
14
/**
15
 * fu_struct_ifwi_cpd_get_header_marker: (skip):
16
 **/
17
static guint32
18
fu_struct_ifwi_cpd_get_header_marker(const FuStructIfwiCpd *st)
19
30.1M
{
20
30.1M
    g_return_val_if_fail(st != NULL, 0x0);
21
30.1M
    return fu_memread_uint32(st->data + 0, G_LITTLE_ENDIAN);
22
30.1M
}
23
/**
24
 * fu_struct_ifwi_cpd_get_num_of_entries: (skip):
25
 **/
26
guint32
27
fu_struct_ifwi_cpd_get_num_of_entries(const FuStructIfwiCpd *st)
28
1.28k
{
29
1.28k
    g_return_val_if_fail(st != NULL, 0x0);
30
1.28k
    return fu_memread_uint32(st->data + 4, G_LITTLE_ENDIAN);
31
1.28k
}
32
/**
33
 * fu_struct_ifwi_cpd_get_header_version: (skip):
34
 **/
35
guint8
36
fu_struct_ifwi_cpd_get_header_version(const FuStructIfwiCpd *st)
37
1.28k
{
38
1.28k
    g_return_val_if_fail(st != NULL, 0x0);
39
1.28k
    return st->data[8];
40
1.28k
}
41
/**
42
 * fu_struct_ifwi_cpd_get_entry_version: (skip):
43
 **/
44
guint8
45
fu_struct_ifwi_cpd_get_entry_version(const FuStructIfwiCpd *st)
46
1.28k
{
47
1.28k
    g_return_val_if_fail(st != NULL, 0x0);
48
1.28k
    return st->data[9];
49
1.28k
}
50
/**
51
 * fu_struct_ifwi_cpd_get_header_length: (skip):
52
 **/
53
guint8
54
fu_struct_ifwi_cpd_get_header_length(const FuStructIfwiCpd *st)
55
1.17k
{
56
1.17k
    g_return_val_if_fail(st != NULL, 0x0);
57
1.17k
    return st->data[10];
58
1.17k
}
59
/**
60
 * fu_struct_ifwi_cpd_get_checksum: (skip):
61
 **/
62
guint8
63
fu_struct_ifwi_cpd_get_checksum(const FuStructIfwiCpd *st)
64
0
{
65
0
    g_return_val_if_fail(st != NULL, 0x0);
66
0
    return st->data[11];
67
0
}
68
/**
69
 * fu_struct_ifwi_cpd_get_partition_name: (skip):
70
 **/
71
guint32
72
fu_struct_ifwi_cpd_get_partition_name(const FuStructIfwiCpd *st)
73
1.28k
{
74
1.28k
    g_return_val_if_fail(st != NULL, 0x0);
75
1.28k
    return fu_memread_uint32(st->data + 12, G_LITTLE_ENDIAN);
76
1.28k
}
77
/**
78
 * fu_struct_ifwi_cpd_get_crc32: (skip):
79
 **/
80
guint32
81
fu_struct_ifwi_cpd_get_crc32(const FuStructIfwiCpd *st)
82
0
{
83
0
    g_return_val_if_fail(st != NULL, 0x0);
84
0
    return fu_memread_uint32(st->data + 16, G_LITTLE_ENDIAN);
85
0
}
86
87
/* setters */
88
/**
89
 * fu_struct_ifwi_cpd_set_header_marker: (skip):
90
 **/
91
static void
92
fu_struct_ifwi_cpd_set_header_marker(FuStructIfwiCpd *st, guint32 value)
93
106
{
94
106
    g_return_if_fail(st != NULL);
95
106
    fu_memwrite_uint32(st->data + 0, value, G_LITTLE_ENDIAN);
96
106
}
97
/**
98
 * fu_struct_ifwi_cpd_set_num_of_entries: (skip):
99
 **/
100
void
101
fu_struct_ifwi_cpd_set_num_of_entries(FuStructIfwiCpd *st, guint32 value)
102
106
{
103
106
    g_return_if_fail(st != NULL);
104
106
    fu_memwrite_uint32(st->data + 4, value, G_LITTLE_ENDIAN);
105
106
}
106
/**
107
 * fu_struct_ifwi_cpd_set_header_version: (skip):
108
 **/
109
void
110
fu_struct_ifwi_cpd_set_header_version(FuStructIfwiCpd *st, guint8 value)
111
106
{
112
106
    g_return_if_fail(st != NULL);
113
106
    st->data[8] = value;
114
106
}
115
/**
116
 * fu_struct_ifwi_cpd_set_entry_version: (skip):
117
 **/
118
void
119
fu_struct_ifwi_cpd_set_entry_version(FuStructIfwiCpd *st, guint8 value)
120
106
{
121
106
    g_return_if_fail(st != NULL);
122
106
    st->data[9] = value;
123
106
}
124
/**
125
 * fu_struct_ifwi_cpd_set_header_length: (skip):
126
 **/
127
void
128
fu_struct_ifwi_cpd_set_header_length(FuStructIfwiCpd *st, guint8 value)
129
106
{
130
106
    g_return_if_fail(st != NULL);
131
106
    st->data[10] = value;
132
106
}
133
/**
134
 * fu_struct_ifwi_cpd_set_checksum: (skip):
135
 **/
136
void
137
fu_struct_ifwi_cpd_set_checksum(FuStructIfwiCpd *st, guint8 value)
138
106
{
139
106
    g_return_if_fail(st != NULL);
140
106
    st->data[11] = value;
141
106
}
142
/**
143
 * fu_struct_ifwi_cpd_set_partition_name: (skip):
144
 **/
145
void
146
fu_struct_ifwi_cpd_set_partition_name(FuStructIfwiCpd *st, guint32 value)
147
106
{
148
106
    g_return_if_fail(st != NULL);
149
106
    fu_memwrite_uint32(st->data + 12, value, G_LITTLE_ENDIAN);
150
106
}
151
/**
152
 * fu_struct_ifwi_cpd_set_crc32: (skip):
153
 **/
154
void
155
fu_struct_ifwi_cpd_set_crc32(FuStructIfwiCpd *st, guint32 value)
156
106
{
157
106
    g_return_if_fail(st != NULL);
158
106
    fu_memwrite_uint32(st->data + 16, value, G_LITTLE_ENDIAN);
159
106
}
160
/**
161
 * fu_struct_ifwi_cpd_new: (skip):
162
 **/
163
FuStructIfwiCpd *
164
fu_struct_ifwi_cpd_new(void)
165
106
{
166
106
    FuStructIfwiCpd *st = g_byte_array_sized_new(20);
167
106
    fu_byte_array_set_size(st, 20, 0x0);
168
106
    fu_struct_ifwi_cpd_set_header_marker(st, 0x44504324);
169
106
    fu_struct_ifwi_cpd_set_header_length(st, 20);
170
106
    return st;
171
106
}
172
/**
173
 * fu_struct_ifwi_cpd_to_string: (skip):
174
 **/
175
static gchar *
176
fu_struct_ifwi_cpd_to_string(const FuStructIfwiCpd *st)
177
0
{
178
0
    g_autoptr(GString) str = g_string_new("FuStructIfwiCpd:\n");
179
0
    g_return_val_if_fail(st != NULL, NULL);
180
0
    g_string_append_printf(str, "  num_of_entries: 0x%x\n",
181
0
                           (guint) fu_struct_ifwi_cpd_get_num_of_entries(st));
182
0
    g_string_append_printf(str, "  header_version: 0x%x\n",
183
0
                           (guint) fu_struct_ifwi_cpd_get_header_version(st));
184
0
    g_string_append_printf(str, "  entry_version: 0x%x\n",
185
0
                           (guint) fu_struct_ifwi_cpd_get_entry_version(st));
186
0
    g_string_append_printf(str, "  header_length: 0x%x\n",
187
0
                           (guint) fu_struct_ifwi_cpd_get_header_length(st));
188
0
    g_string_append_printf(str, "  checksum: 0x%x\n",
189
0
                           (guint) fu_struct_ifwi_cpd_get_checksum(st));
190
0
    g_string_append_printf(str, "  partition_name: 0x%x\n",
191
0
                           (guint) fu_struct_ifwi_cpd_get_partition_name(st));
192
0
    g_string_append_printf(str, "  crc32: 0x%x\n",
193
0
                           (guint) fu_struct_ifwi_cpd_get_crc32(st));
194
0
    if (str->len > 0)
195
0
        g_string_set_size(str, str->len - 1);
196
0
    return g_string_free(g_steal_pointer(&str), FALSE);
197
0
}
198
static gboolean
199
fu_struct_ifwi_cpd_validate_internal(FuStructIfwiCpd *st, GError **error)
200
15.0M
{
201
15.0M
    g_return_val_if_fail(st != NULL, FALSE);
202
15.0M
    if (fu_struct_ifwi_cpd_get_header_marker(st) != 0x44504324) {
203
15.0M
        g_set_error(error,
204
15.0M
                    FWUPD_ERROR,
205
15.0M
                    FWUPD_ERROR_INVALID_DATA,
206
15.0M
                    "constant FuStructIfwiCpd.header_marker was not valid, "
207
15.0M
                    "expected 0x%x and got 0x%x",
208
15.0M
                    (guint) 0x44504324,
209
15.0M
                    (guint) fu_struct_ifwi_cpd_get_header_marker(st));
210
15.0M
        return FALSE;
211
15.0M
    }
212
2.57k
    return TRUE;
213
15.0M
}
214
/**
215
 * fu_struct_ifwi_cpd_validate_stream: (skip):
216
 **/
217
gboolean
218
fu_struct_ifwi_cpd_validate_stream(GInputStream *stream, gsize offset, GError **error)
219
15.0M
{
220
15.0M
    g_autoptr(GByteArray) st = NULL;
221
15.0M
    g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE);
222
15.0M
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
223
15.0M
    st = fu_input_stream_read_byte_array(stream, offset, 20, NULL, error);
224
15.0M
    if (st == NULL) {
225
0
        g_prefix_error(error, "FuStructIfwiCpd failed read of 0x%x: ", (guint) 20);
226
0
        return FALSE;
227
0
    }
228
15.0M
    if (st->len != 20) {
229
4.94k
        g_set_error(error,
230
4.94k
                    FWUPD_ERROR,
231
4.94k
                    FWUPD_ERROR_INVALID_DATA,
232
4.94k
                    "FuStructIfwiCpd requested 0x%x and got 0x%x",
233
4.94k
                    (guint) 20,
234
4.94k
                    (guint) st->len);
235
4.94k
        return FALSE;
236
4.94k
    }
237
15.0M
    return fu_struct_ifwi_cpd_validate_internal(st, error);
238
15.0M
}
239
static gboolean
240
fu_struct_ifwi_cpd_parse_internal(FuStructIfwiCpd *st, GError **error)
241
1.28k
{
242
1.28k
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
243
0
        g_autofree gchar *str = fu_struct_ifwi_cpd_to_string(st);
244
0
        g_debug("%s", str);
245
0
    }
246
1.28k
    if (!fu_struct_ifwi_cpd_validate_internal(st, error))
247
0
        return FALSE;
248
1.28k
    return TRUE;
249
1.28k
}
250
/**
251
 * fu_struct_ifwi_cpd_parse_stream: (skip):
252
 **/
253
FuStructIfwiCpd *
254
fu_struct_ifwi_cpd_parse_stream(GInputStream *stream, gsize offset, GError **error)
255
1.28k
{
256
1.28k
    g_autoptr(GByteArray) st = NULL;
257
1.28k
    st = fu_input_stream_read_byte_array(stream, offset, 20, NULL, error);
258
1.28k
    if (st == NULL) {
259
0
        g_prefix_error(error, "FuStructIfwiCpd failed read of 0x%x: ", (guint) 20);
260
0
        return NULL;
261
0
    }
262
1.28k
    if (st->len != 20) {
263
0
        g_set_error(error,
264
0
                    FWUPD_ERROR,
265
0
                    FWUPD_ERROR_INVALID_DATA,
266
0
                    "FuStructIfwiCpd requested 0x%x and got 0x%x",
267
0
                    (guint) 20,
268
0
                    (guint) st->len);
269
0
        return NULL;
270
0
    }
271
1.28k
    if (!fu_struct_ifwi_cpd_parse_internal(st, error))
272
0
        return NULL;
273
1.28k
    return g_steal_pointer(&st);
274
1.28k
}
275
/* getters */
276
/**
277
 * fu_struct_ifwi_cpd_entry_get_name: (skip):
278
 **/
279
gchar *
280
fu_struct_ifwi_cpd_entry_get_name(const FuStructIfwiCpdEntry *st)
281
46.4k
{
282
46.4k
    g_return_val_if_fail(st != NULL, NULL);
283
46.4k
    return fu_memstrsafe(st->data, st->len, 0, 12, NULL);
284
46.4k
}
285
/**
286
 * fu_struct_ifwi_cpd_entry_get_offset: (skip):
287
 **/
288
guint32
289
fu_struct_ifwi_cpd_entry_get_offset(const FuStructIfwiCpdEntry *st)
290
46.4k
{
291
46.4k
    g_return_val_if_fail(st != NULL, 0x0);
292
46.4k
    return fu_memread_uint32(st->data + 12, G_LITTLE_ENDIAN);
293
46.4k
}
294
/**
295
 * fu_struct_ifwi_cpd_entry_get_length: (skip):
296
 **/
297
guint32
298
fu_struct_ifwi_cpd_entry_get_length(const FuStructIfwiCpdEntry *st)
299
47.3k
{
300
47.3k
    g_return_val_if_fail(st != NULL, 0x0);
301
47.3k
    return fu_memread_uint32(st->data + 16, G_LITTLE_ENDIAN);
302
47.3k
}
303
304
/* setters */
305
/**
306
 * fu_struct_ifwi_cpd_entry_set_name: (skip):
307
 **/
308
gboolean
309
fu_struct_ifwi_cpd_entry_set_name(FuStructIfwiCpdEntry *st, const gchar *value, GError **error)
310
0
{
311
0
    gsize len;
312
0
    g_return_val_if_fail(st != NULL, FALSE);
313
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
314
0
    if (value == NULL) {
315
0
        memset(st->data + 0, 0x0, 12);
316
0
        return TRUE;
317
0
    }
318
0
    len = strlen(value);
319
0
    if (len > 12) {
320
0
        g_set_error(error,
321
0
                    FWUPD_ERROR,
322
0
                    FWUPD_ERROR_INVALID_DATA,
323
0
                    "string '%s' (0x%x bytes) does not fit in FuStructIfwiCpdEntry.name (0x%x bytes)",
324
0
                    value, (guint) len, (guint) 12);
325
0
        return FALSE;
326
0
    }
327
0
    return fu_memcpy_safe(st->data, st->len, 0, (const guint8 *)value, len, 0x0, len, error);
328
0
}
329
/**
330
 * fu_struct_ifwi_cpd_entry_set_offset: (skip):
331
 **/
332
void
333
fu_struct_ifwi_cpd_entry_set_offset(FuStructIfwiCpdEntry *st, guint32 value)
334
0
{
335
0
    g_return_if_fail(st != NULL);
336
0
    fu_memwrite_uint32(st->data + 12, value, G_LITTLE_ENDIAN);
337
0
}
338
/**
339
 * fu_struct_ifwi_cpd_entry_set_length: (skip):
340
 **/
341
void
342
fu_struct_ifwi_cpd_entry_set_length(FuStructIfwiCpdEntry *st, guint32 value)
343
0
{
344
0
    g_return_if_fail(st != NULL);
345
0
    fu_memwrite_uint32(st->data + 16, value, G_LITTLE_ENDIAN);
346
0
}
347
/**
348
 * fu_struct_ifwi_cpd_entry_new: (skip):
349
 **/
350
FuStructIfwiCpdEntry *
351
fu_struct_ifwi_cpd_entry_new(void)
352
0
{
353
0
    FuStructIfwiCpdEntry *st = g_byte_array_sized_new(24);
354
0
    fu_byte_array_set_size(st, 24, 0x0);
355
0
    return st;
356
0
}
357
/**
358
 * fu_struct_ifwi_cpd_entry_to_string: (skip):
359
 **/
360
static gchar *
361
fu_struct_ifwi_cpd_entry_to_string(const FuStructIfwiCpdEntry *st)
362
0
{
363
0
    g_autoptr(GString) str = g_string_new("FuStructIfwiCpdEntry:\n");
364
0
    g_return_val_if_fail(st != NULL, NULL);
365
0
    {
366
0
        g_autofree gchar *tmp = fu_struct_ifwi_cpd_entry_get_name(st);
367
0
        if (tmp != NULL)
368
0
            g_string_append_printf(str, "  name: %s\n", tmp);
369
0
    }
370
0
    g_string_append_printf(str, "  offset: 0x%x\n",
371
0
                           (guint) fu_struct_ifwi_cpd_entry_get_offset(st));
372
0
    g_string_append_printf(str, "  length: 0x%x\n",
373
0
                           (guint) fu_struct_ifwi_cpd_entry_get_length(st));
374
0
    if (str->len > 0)
375
0
        g_string_set_size(str, str->len - 1);
376
0
    return g_string_free(g_steal_pointer(&str), FALSE);
377
0
}
378
static gboolean
379
fu_struct_ifwi_cpd_entry_validate_internal(FuStructIfwiCpdEntry *st, GError **error)
380
46.4k
{
381
46.4k
    g_return_val_if_fail(st != NULL, FALSE);
382
46.4k
    return TRUE;
383
46.4k
}
384
static gboolean
385
fu_struct_ifwi_cpd_entry_parse_internal(FuStructIfwiCpdEntry *st, GError **error)
386
46.4k
{
387
46.4k
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
388
0
        g_autofree gchar *str = fu_struct_ifwi_cpd_entry_to_string(st);
389
0
        g_debug("%s", str);
390
0
    }
391
46.4k
    if (!fu_struct_ifwi_cpd_entry_validate_internal(st, error))
392
0
        return FALSE;
393
46.4k
    return TRUE;
394
46.4k
}
395
/**
396
 * fu_struct_ifwi_cpd_entry_parse_stream: (skip):
397
 **/
398
FuStructIfwiCpdEntry *
399
fu_struct_ifwi_cpd_entry_parse_stream(GInputStream *stream, gsize offset, GError **error)
400
46.7k
{
401
46.7k
    g_autoptr(GByteArray) st = NULL;
402
46.7k
    st = fu_input_stream_read_byte_array(stream, offset, 24, NULL, error);
403
46.7k
    if (st == NULL) {
404
243
        g_prefix_error(error, "FuStructIfwiCpdEntry failed read of 0x%x: ", (guint) 24);
405
243
        return NULL;
406
243
    }
407
46.4k
    if (st->len != 24) {
408
87
        g_set_error(error,
409
87
                    FWUPD_ERROR,
410
87
                    FWUPD_ERROR_INVALID_DATA,
411
87
                    "FuStructIfwiCpdEntry requested 0x%x and got 0x%x",
412
87
                    (guint) 24,
413
87
                    (guint) st->len);
414
87
        return NULL;
415
87
    }
416
46.4k
    if (!fu_struct_ifwi_cpd_entry_parse_internal(st, error))
417
0
        return NULL;
418
46.4k
    return g_steal_pointer(&st);
419
46.4k
}
420
/* getters */
421
/**
422
 * fu_struct_ifwi_cpd_manifest_get_header_type: (skip):
423
 **/
424
guint32
425
fu_struct_ifwi_cpd_manifest_get_header_type(const FuStructIfwiCpdManifest *st)
426
0
{
427
0
    g_return_val_if_fail(st != NULL, 0x0);
428
0
    return fu_memread_uint32(st->data + 0, G_LITTLE_ENDIAN);
429
0
}
430
/**
431
 * fu_struct_ifwi_cpd_manifest_get_header_length: (skip):
432
 **/
433
guint32
434
fu_struct_ifwi_cpd_manifest_get_header_length(const FuStructIfwiCpdManifest *st)
435
514
{
436
514
    g_return_val_if_fail(st != NULL, 0x0);
437
514
    return fu_memread_uint32(st->data + 4, G_LITTLE_ENDIAN);
438
514
}
439
/**
440
 * fu_struct_ifwi_cpd_manifest_get_header_version: (skip):
441
 **/
442
guint32
443
fu_struct_ifwi_cpd_manifest_get_header_version(const FuStructIfwiCpdManifest *st)
444
0
{
445
0
    g_return_val_if_fail(st != NULL, 0x0);
446
0
    return fu_memread_uint32(st->data + 8, G_LITTLE_ENDIAN);
447
0
}
448
/**
449
 * fu_struct_ifwi_cpd_manifest_get_flags: (skip):
450
 **/
451
guint32
452
fu_struct_ifwi_cpd_manifest_get_flags(const FuStructIfwiCpdManifest *st)
453
0
{
454
0
    g_return_val_if_fail(st != NULL, 0x0);
455
0
    return fu_memread_uint32(st->data + 12, G_LITTLE_ENDIAN);
456
0
}
457
/**
458
 * fu_struct_ifwi_cpd_manifest_get_vendor: (skip):
459
 **/
460
guint32
461
fu_struct_ifwi_cpd_manifest_get_vendor(const FuStructIfwiCpdManifest *st)
462
0
{
463
0
    g_return_val_if_fail(st != NULL, 0x0);
464
0
    return fu_memread_uint32(st->data + 16, G_LITTLE_ENDIAN);
465
0
}
466
/**
467
 * fu_struct_ifwi_cpd_manifest_get_date: (skip):
468
 **/
469
guint32
470
fu_struct_ifwi_cpd_manifest_get_date(const FuStructIfwiCpdManifest *st)
471
0
{
472
0
    g_return_val_if_fail(st != NULL, 0x0);
473
0
    return fu_memread_uint32(st->data + 20, G_LITTLE_ENDIAN);
474
0
}
475
/**
476
 * fu_struct_ifwi_cpd_manifest_get_size: (skip):
477
 **/
478
guint32
479
fu_struct_ifwi_cpd_manifest_get_size(const FuStructIfwiCpdManifest *st)
480
655
{
481
655
    g_return_val_if_fail(st != NULL, 0x0);
482
655
    return fu_memread_uint32(st->data + 24, G_LITTLE_ENDIAN);
483
655
}
484
/**
485
 * fu_struct_ifwi_cpd_manifest_get_id: (skip):
486
 **/
487
guint32
488
fu_struct_ifwi_cpd_manifest_get_id(const FuStructIfwiCpdManifest *st)
489
0
{
490
0
    g_return_val_if_fail(st != NULL, 0x0);
491
0
    return fu_memread_uint32(st->data + 28, G_LITTLE_ENDIAN);
492
0
}
493
/**
494
 * fu_struct_ifwi_cpd_manifest_get_rsvd: (skip):
495
 **/
496
guint32
497
fu_struct_ifwi_cpd_manifest_get_rsvd(const FuStructIfwiCpdManifest *st)
498
0
{
499
0
    g_return_val_if_fail(st != NULL, 0x0);
500
0
    return fu_memread_uint32(st->data + 32, G_LITTLE_ENDIAN);
501
0
}
502
/**
503
 * fu_struct_ifwi_cpd_manifest_get_version: (skip):
504
 **/
505
guint64
506
fu_struct_ifwi_cpd_manifest_get_version(const FuStructIfwiCpdManifest *st)
507
655
{
508
655
    g_return_val_if_fail(st != NULL, 0x0);
509
655
    return fu_memread_uint64(st->data + 36, G_LITTLE_ENDIAN);
510
655
}
511
/**
512
 * fu_struct_ifwi_cpd_manifest_get_svn: (skip):
513
 **/
514
guint32
515
fu_struct_ifwi_cpd_manifest_get_svn(const FuStructIfwiCpdManifest *st)
516
0
{
517
0
    g_return_val_if_fail(st != NULL, 0x0);
518
0
    return fu_memread_uint32(st->data + 44, G_LITTLE_ENDIAN);
519
0
}
520
521
/* setters */
522
/**
523
 * fu_struct_ifwi_cpd_manifest_set_header_type: (skip):
524
 **/
525
void
526
fu_struct_ifwi_cpd_manifest_set_header_type(FuStructIfwiCpdManifest *st, guint32 value)
527
0
{
528
0
    g_return_if_fail(st != NULL);
529
0
    fu_memwrite_uint32(st->data + 0, value, G_LITTLE_ENDIAN);
530
0
}
531
/**
532
 * fu_struct_ifwi_cpd_manifest_set_header_length: (skip):
533
 **/
534
void
535
fu_struct_ifwi_cpd_manifest_set_header_length(FuStructIfwiCpdManifest *st, guint32 value)
536
0
{
537
0
    g_return_if_fail(st != NULL);
538
0
    fu_memwrite_uint32(st->data + 4, value, G_LITTLE_ENDIAN);
539
0
}
540
/**
541
 * fu_struct_ifwi_cpd_manifest_set_header_version: (skip):
542
 **/
543
void
544
fu_struct_ifwi_cpd_manifest_set_header_version(FuStructIfwiCpdManifest *st, guint32 value)
545
0
{
546
0
    g_return_if_fail(st != NULL);
547
0
    fu_memwrite_uint32(st->data + 8, value, G_LITTLE_ENDIAN);
548
0
}
549
/**
550
 * fu_struct_ifwi_cpd_manifest_set_flags: (skip):
551
 **/
552
void
553
fu_struct_ifwi_cpd_manifest_set_flags(FuStructIfwiCpdManifest *st, guint32 value)
554
0
{
555
0
    g_return_if_fail(st != NULL);
556
0
    fu_memwrite_uint32(st->data + 12, value, G_LITTLE_ENDIAN);
557
0
}
558
/**
559
 * fu_struct_ifwi_cpd_manifest_set_vendor: (skip):
560
 **/
561
void
562
fu_struct_ifwi_cpd_manifest_set_vendor(FuStructIfwiCpdManifest *st, guint32 value)
563
0
{
564
0
    g_return_if_fail(st != NULL);
565
0
    fu_memwrite_uint32(st->data + 16, value, G_LITTLE_ENDIAN);
566
0
}
567
/**
568
 * fu_struct_ifwi_cpd_manifest_set_date: (skip):
569
 **/
570
void
571
fu_struct_ifwi_cpd_manifest_set_date(FuStructIfwiCpdManifest *st, guint32 value)
572
0
{
573
0
    g_return_if_fail(st != NULL);
574
0
    fu_memwrite_uint32(st->data + 20, value, G_LITTLE_ENDIAN);
575
0
}
576
/**
577
 * fu_struct_ifwi_cpd_manifest_set_size: (skip):
578
 **/
579
void
580
fu_struct_ifwi_cpd_manifest_set_size(FuStructIfwiCpdManifest *st, guint32 value)
581
0
{
582
0
    g_return_if_fail(st != NULL);
583
0
    fu_memwrite_uint32(st->data + 24, value, G_LITTLE_ENDIAN);
584
0
}
585
/**
586
 * fu_struct_ifwi_cpd_manifest_set_id: (skip):
587
 **/
588
void
589
fu_struct_ifwi_cpd_manifest_set_id(FuStructIfwiCpdManifest *st, guint32 value)
590
0
{
591
0
    g_return_if_fail(st != NULL);
592
0
    fu_memwrite_uint32(st->data + 28, value, G_LITTLE_ENDIAN);
593
0
}
594
/**
595
 * fu_struct_ifwi_cpd_manifest_set_rsvd: (skip):
596
 **/
597
void
598
fu_struct_ifwi_cpd_manifest_set_rsvd(FuStructIfwiCpdManifest *st, guint32 value)
599
0
{
600
0
    g_return_if_fail(st != NULL);
601
0
    fu_memwrite_uint32(st->data + 32, value, G_LITTLE_ENDIAN);
602
0
}
603
/**
604
 * fu_struct_ifwi_cpd_manifest_set_version: (skip):
605
 **/
606
void
607
fu_struct_ifwi_cpd_manifest_set_version(FuStructIfwiCpdManifest *st, guint64 value)
608
0
{
609
0
    g_return_if_fail(st != NULL);
610
0
    fu_memwrite_uint64(st->data + 36, value, G_LITTLE_ENDIAN);
611
0
}
612
/**
613
 * fu_struct_ifwi_cpd_manifest_set_svn: (skip):
614
 **/
615
void
616
fu_struct_ifwi_cpd_manifest_set_svn(FuStructIfwiCpdManifest *st, guint32 value)
617
0
{
618
0
    g_return_if_fail(st != NULL);
619
0
    fu_memwrite_uint32(st->data + 44, value, G_LITTLE_ENDIAN);
620
0
}
621
/**
622
 * fu_struct_ifwi_cpd_manifest_new: (skip):
623
 **/
624
FuStructIfwiCpdManifest *
625
fu_struct_ifwi_cpd_manifest_new(void)
626
0
{
627
0
    FuStructIfwiCpdManifest *st = g_byte_array_sized_new(48);
628
0
    fu_byte_array_set_size(st, 48, 0x0);
629
0
    return st;
630
0
}
631
/**
632
 * fu_struct_ifwi_cpd_manifest_to_string: (skip):
633
 **/
634
static gchar *
635
fu_struct_ifwi_cpd_manifest_to_string(const FuStructIfwiCpdManifest *st)
636
0
{
637
0
    g_autoptr(GString) str = g_string_new("FuStructIfwiCpdManifest:\n");
638
0
    g_return_val_if_fail(st != NULL, NULL);
639
0
    g_string_append_printf(str, "  header_type: 0x%x\n",
640
0
                           (guint) fu_struct_ifwi_cpd_manifest_get_header_type(st));
641
0
    g_string_append_printf(str, "  header_length: 0x%x\n",
642
0
                           (guint) fu_struct_ifwi_cpd_manifest_get_header_length(st));
643
0
    g_string_append_printf(str, "  header_version: 0x%x\n",
644
0
                           (guint) fu_struct_ifwi_cpd_manifest_get_header_version(st));
645
0
    g_string_append_printf(str, "  flags: 0x%x\n",
646
0
                           (guint) fu_struct_ifwi_cpd_manifest_get_flags(st));
647
0
    g_string_append_printf(str, "  vendor: 0x%x\n",
648
0
                           (guint) fu_struct_ifwi_cpd_manifest_get_vendor(st));
649
0
    g_string_append_printf(str, "  date: 0x%x\n",
650
0
                           (guint) fu_struct_ifwi_cpd_manifest_get_date(st));
651
0
    g_string_append_printf(str, "  size: 0x%x\n",
652
0
                           (guint) fu_struct_ifwi_cpd_manifest_get_size(st));
653
0
    g_string_append_printf(str, "  id: 0x%x\n",
654
0
                           (guint) fu_struct_ifwi_cpd_manifest_get_id(st));
655
0
    g_string_append_printf(str, "  rsvd: 0x%x\n",
656
0
                           (guint) fu_struct_ifwi_cpd_manifest_get_rsvd(st));
657
0
    g_string_append_printf(str, "  version: 0x%x\n",
658
0
                           (guint) fu_struct_ifwi_cpd_manifest_get_version(st));
659
0
    g_string_append_printf(str, "  svn: 0x%x\n",
660
0
                           (guint) fu_struct_ifwi_cpd_manifest_get_svn(st));
661
0
    if (str->len > 0)
662
0
        g_string_set_size(str, str->len - 1);
663
0
    return g_string_free(g_steal_pointer(&str), FALSE);
664
0
}
665
static gboolean
666
fu_struct_ifwi_cpd_manifest_validate_internal(FuStructIfwiCpdManifest *st, GError **error)
667
655
{
668
655
    g_return_val_if_fail(st != NULL, FALSE);
669
655
    return TRUE;
670
655
}
671
static gboolean
672
fu_struct_ifwi_cpd_manifest_parse_internal(FuStructIfwiCpdManifest *st, GError **error)
673
655
{
674
655
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
675
0
        g_autofree gchar *str = fu_struct_ifwi_cpd_manifest_to_string(st);
676
0
        g_debug("%s", str);
677
0
    }
678
655
    if (!fu_struct_ifwi_cpd_manifest_validate_internal(st, error))
679
0
        return FALSE;
680
655
    return TRUE;
681
655
}
682
/**
683
 * fu_struct_ifwi_cpd_manifest_parse_stream: (skip):
684
 **/
685
FuStructIfwiCpdManifest *
686
fu_struct_ifwi_cpd_manifest_parse_stream(GInputStream *stream, gsize offset, GError **error)
687
655
{
688
655
    g_autoptr(GByteArray) st = NULL;
689
655
    st = fu_input_stream_read_byte_array(stream, offset, 48, NULL, error);
690
655
    if (st == NULL) {
691
0
        g_prefix_error(error, "FuStructIfwiCpdManifest failed read of 0x%x: ", (guint) 48);
692
0
        return NULL;
693
0
    }
694
655
    if (st->len != 48) {
695
0
        g_set_error(error,
696
0
                    FWUPD_ERROR,
697
0
                    FWUPD_ERROR_INVALID_DATA,
698
0
                    "FuStructIfwiCpdManifest requested 0x%x and got 0x%x",
699
0
                    (guint) 48,
700
0
                    (guint) st->len);
701
0
        return NULL;
702
0
    }
703
655
    if (!fu_struct_ifwi_cpd_manifest_parse_internal(st, error))
704
0
        return NULL;
705
655
    return g_steal_pointer(&st);
706
655
}
707
/* getters */
708
/**
709
 * fu_struct_ifwi_cpd_manifest_ext_get_extension_type: (skip):
710
 **/
711
guint32
712
fu_struct_ifwi_cpd_manifest_ext_get_extension_type(const FuStructIfwiCpdManifestExt *st)
713
1.28k
{
714
1.28k
    g_return_val_if_fail(st != NULL, 0x0);
715
1.28k
    return fu_memread_uint32(st->data + 0, G_LITTLE_ENDIAN);
716
1.28k
}
717
/**
718
 * fu_struct_ifwi_cpd_manifest_ext_get_extension_length: (skip):
719
 **/
720
guint32
721
fu_struct_ifwi_cpd_manifest_ext_get_extension_length(const FuStructIfwiCpdManifestExt *st)
722
1.24k
{
723
1.24k
    g_return_val_if_fail(st != NULL, 0x0);
724
1.24k
    return fu_memread_uint32(st->data + 4, G_LITTLE_ENDIAN);
725
1.24k
}
726
727
/* setters */
728
/**
729
 * fu_struct_ifwi_cpd_manifest_ext_set_extension_type: (skip):
730
 **/
731
void
732
fu_struct_ifwi_cpd_manifest_ext_set_extension_type(FuStructIfwiCpdManifestExt *st, guint32 value)
733
0
{
734
0
    g_return_if_fail(st != NULL);
735
0
    fu_memwrite_uint32(st->data + 0, value, G_LITTLE_ENDIAN);
736
0
}
737
/**
738
 * fu_struct_ifwi_cpd_manifest_ext_set_extension_length: (skip):
739
 **/
740
void
741
fu_struct_ifwi_cpd_manifest_ext_set_extension_length(FuStructIfwiCpdManifestExt *st, guint32 value)
742
0
{
743
0
    g_return_if_fail(st != NULL);
744
0
    fu_memwrite_uint32(st->data + 4, value, G_LITTLE_ENDIAN);
745
0
}
746
/**
747
 * fu_struct_ifwi_cpd_manifest_ext_new: (skip):
748
 **/
749
FuStructIfwiCpdManifestExt *
750
fu_struct_ifwi_cpd_manifest_ext_new(void)
751
0
{
752
0
    FuStructIfwiCpdManifestExt *st = g_byte_array_sized_new(8);
753
0
    fu_byte_array_set_size(st, 8, 0x0);
754
0
    return st;
755
0
}
756
/**
757
 * fu_struct_ifwi_cpd_manifest_ext_to_string: (skip):
758
 **/
759
static gchar *
760
fu_struct_ifwi_cpd_manifest_ext_to_string(const FuStructIfwiCpdManifestExt *st)
761
0
{
762
0
    g_autoptr(GString) str = g_string_new("FuStructIfwiCpdManifestExt:\n");
763
0
    g_return_val_if_fail(st != NULL, NULL);
764
0
    g_string_append_printf(str, "  extension_type: 0x%x\n",
765
0
                           (guint) fu_struct_ifwi_cpd_manifest_ext_get_extension_type(st));
766
0
    g_string_append_printf(str, "  extension_length: 0x%x\n",
767
0
                           (guint) fu_struct_ifwi_cpd_manifest_ext_get_extension_length(st));
768
0
    if (str->len > 0)
769
0
        g_string_set_size(str, str->len - 1);
770
0
    return g_string_free(g_steal_pointer(&str), FALSE);
771
0
}
772
static gboolean
773
fu_struct_ifwi_cpd_manifest_ext_validate_internal(FuStructIfwiCpdManifestExt *st, GError **error)
774
1.28k
{
775
1.28k
    g_return_val_if_fail(st != NULL, FALSE);
776
1.28k
    return TRUE;
777
1.28k
}
778
static gboolean
779
fu_struct_ifwi_cpd_manifest_ext_parse_internal(FuStructIfwiCpdManifestExt *st, GError **error)
780
1.28k
{
781
1.28k
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
782
0
        g_autofree gchar *str = fu_struct_ifwi_cpd_manifest_ext_to_string(st);
783
0
        g_debug("%s", str);
784
0
    }
785
1.28k
    if (!fu_struct_ifwi_cpd_manifest_ext_validate_internal(st, error))
786
0
        return FALSE;
787
1.28k
    return TRUE;
788
1.28k
}
789
/**
790
 * fu_struct_ifwi_cpd_manifest_ext_parse_stream: (skip):
791
 **/
792
FuStructIfwiCpdManifestExt *
793
fu_struct_ifwi_cpd_manifest_ext_parse_stream(GInputStream *stream, gsize offset, GError **error)
794
1.30k
{
795
1.30k
    g_autoptr(GByteArray) st = NULL;
796
1.30k
    st = fu_input_stream_read_byte_array(stream, offset, 8, NULL, error);
797
1.30k
    if (st == NULL) {
798
0
        g_prefix_error(error, "FuStructIfwiCpdManifestExt failed read of 0x%x: ", (guint) 8);
799
0
        return NULL;
800
0
    }
801
1.30k
    if (st->len != 8) {
802
17
        g_set_error(error,
803
17
                    FWUPD_ERROR,
804
17
                    FWUPD_ERROR_INVALID_DATA,
805
17
                    "FuStructIfwiCpdManifestExt requested 0x%x and got 0x%x",
806
17
                    (guint) 8,
807
17
                    (guint) st->len);
808
17
        return NULL;
809
17
    }
810
1.28k
    if (!fu_struct_ifwi_cpd_manifest_ext_parse_internal(st, error))
811
0
        return NULL;
812
1.28k
    return g_steal_pointer(&st);
813
1.28k
}
814
/* getters */
815
/**
816
 * fu_struct_ifwi_fpt_get_header_marker: (skip):
817
 **/
818
static guint32
819
fu_struct_ifwi_fpt_get_header_marker(const FuStructIfwiFpt *st)
820
16.3M
{
821
16.3M
    g_return_val_if_fail(st != NULL, 0x0);
822
16.3M
    return fu_memread_uint32(st->data + 0, G_LITTLE_ENDIAN);
823
16.3M
}
824
/**
825
 * fu_struct_ifwi_fpt_get_num_of_entries: (skip):
826
 **/
827
guint32
828
fu_struct_ifwi_fpt_get_num_of_entries(const FuStructIfwiFpt *st)
829
474
{
830
474
    g_return_val_if_fail(st != NULL, 0x0);
831
474
    return fu_memread_uint32(st->data + 4, G_LITTLE_ENDIAN);
832
474
}
833
/**
834
 * fu_struct_ifwi_fpt_get_header_version: (skip):
835
 **/
836
guint8
837
fu_struct_ifwi_fpt_get_header_version(const FuStructIfwiFpt *st)
838
441
{
839
441
    g_return_val_if_fail(st != NULL, 0x0);
840
441
    return st->data[8];
841
441
}
842
/**
843
 * fu_struct_ifwi_fpt_get_entry_version: (skip):
844
 **/
845
static guint8
846
fu_struct_ifwi_fpt_get_entry_version(const FuStructIfwiFpt *st)
847
2.07k
{
848
2.07k
    g_return_val_if_fail(st != NULL, 0x0);
849
2.07k
    return st->data[9];
850
2.07k
}
851
/**
852
 * fu_struct_ifwi_fpt_get_header_length: (skip):
853
 **/
854
guint8
855
fu_struct_ifwi_fpt_get_header_length(const FuStructIfwiFpt *st)
856
429
{
857
429
    g_return_val_if_fail(st != NULL, 0x0);
858
429
    return st->data[10];
859
429
}
860
/**
861
 * fu_struct_ifwi_fpt_get_flags: (skip):
862
 **/
863
guint8
864
fu_struct_ifwi_fpt_get_flags(const FuStructIfwiFpt *st)
865
0
{
866
0
    g_return_val_if_fail(st != NULL, 0x0);
867
0
    return st->data[11];
868
0
}
869
/**
870
 * fu_struct_ifwi_fpt_get_ticks_to_add: (skip):
871
 **/
872
guint16
873
fu_struct_ifwi_fpt_get_ticks_to_add(const FuStructIfwiFpt *st)
874
0
{
875
0
    g_return_val_if_fail(st != NULL, 0x0);
876
0
    return fu_memread_uint16(st->data + 12, G_LITTLE_ENDIAN);
877
0
}
878
/**
879
 * fu_struct_ifwi_fpt_get_tokens_to_add: (skip):
880
 **/
881
guint16
882
fu_struct_ifwi_fpt_get_tokens_to_add(const FuStructIfwiFpt *st)
883
0
{
884
0
    g_return_val_if_fail(st != NULL, 0x0);
885
0
    return fu_memread_uint16(st->data + 14, G_LITTLE_ENDIAN);
886
0
}
887
/**
888
 * fu_struct_ifwi_fpt_get_uma_size: (skip):
889
 **/
890
guint32
891
fu_struct_ifwi_fpt_get_uma_size(const FuStructIfwiFpt *st)
892
0
{
893
0
    g_return_val_if_fail(st != NULL, 0x0);
894
0
    return fu_memread_uint32(st->data + 16, G_LITTLE_ENDIAN);
895
0
}
896
/**
897
 * fu_struct_ifwi_fpt_get_crc32: (skip):
898
 **/
899
guint32
900
fu_struct_ifwi_fpt_get_crc32(const FuStructIfwiFpt *st)
901
0
{
902
0
    g_return_val_if_fail(st != NULL, 0x0);
903
0
    return fu_memread_uint32(st->data + 20, G_LITTLE_ENDIAN);
904
0
}
905
/**
906
 * fu_struct_ifwi_fpt_get_fitc_major: (skip):
907
 **/
908
guint16
909
fu_struct_ifwi_fpt_get_fitc_major(const FuStructIfwiFpt *st)
910
0
{
911
0
    g_return_val_if_fail(st != NULL, 0x0);
912
0
    return fu_memread_uint16(st->data + 24, G_LITTLE_ENDIAN);
913
0
}
914
/**
915
 * fu_struct_ifwi_fpt_get_fitc_minor: (skip):
916
 **/
917
guint16
918
fu_struct_ifwi_fpt_get_fitc_minor(const FuStructIfwiFpt *st)
919
0
{
920
0
    g_return_val_if_fail(st != NULL, 0x0);
921
0
    return fu_memread_uint16(st->data + 26, G_LITTLE_ENDIAN);
922
0
}
923
/**
924
 * fu_struct_ifwi_fpt_get_fitc_hotfix: (skip):
925
 **/
926
guint16
927
fu_struct_ifwi_fpt_get_fitc_hotfix(const FuStructIfwiFpt *st)
928
0
{
929
0
    g_return_val_if_fail(st != NULL, 0x0);
930
0
    return fu_memread_uint16(st->data + 28, G_LITTLE_ENDIAN);
931
0
}
932
/**
933
 * fu_struct_ifwi_fpt_get_fitc_build: (skip):
934
 **/
935
guint16
936
fu_struct_ifwi_fpt_get_fitc_build(const FuStructIfwiFpt *st)
937
0
{
938
0
    g_return_val_if_fail(st != NULL, 0x0);
939
0
    return fu_memread_uint16(st->data + 30, G_LITTLE_ENDIAN);
940
0
}
941
942
/* setters */
943
/**
944
 * fu_struct_ifwi_fpt_set_header_marker: (skip):
945
 **/
946
static void
947
fu_struct_ifwi_fpt_set_header_marker(FuStructIfwiFpt *st, guint32 value)
948
71
{
949
71
    g_return_if_fail(st != NULL);
950
71
    fu_memwrite_uint32(st->data + 0, value, G_LITTLE_ENDIAN);
951
71
}
952
/**
953
 * fu_struct_ifwi_fpt_set_num_of_entries: (skip):
954
 **/
955
void
956
fu_struct_ifwi_fpt_set_num_of_entries(FuStructIfwiFpt *st, guint32 value)
957
4
{
958
4
    g_return_if_fail(st != NULL);
959
4
    fu_memwrite_uint32(st->data + 4, value, G_LITTLE_ENDIAN);
960
4
}
961
/**
962
 * fu_struct_ifwi_fpt_set_header_version: (skip):
963
 **/
964
void
965
fu_struct_ifwi_fpt_set_header_version(FuStructIfwiFpt *st, guint8 value)
966
71
{
967
71
    g_return_if_fail(st != NULL);
968
71
    st->data[8] = value;
969
71
}
970
/**
971
 * fu_struct_ifwi_fpt_set_entry_version: (skip):
972
 **/
973
static void
974
fu_struct_ifwi_fpt_set_entry_version(FuStructIfwiFpt *st, guint8 value)
975
71
{
976
71
    g_return_if_fail(st != NULL);
977
71
    st->data[9] = value;
978
71
}
979
/**
980
 * fu_struct_ifwi_fpt_set_header_length: (skip):
981
 **/
982
void
983
fu_struct_ifwi_fpt_set_header_length(FuStructIfwiFpt *st, guint8 value)
984
71
{
985
71
    g_return_if_fail(st != NULL);
986
71
    st->data[10] = value;
987
71
}
988
/**
989
 * fu_struct_ifwi_fpt_set_flags: (skip):
990
 **/
991
void
992
fu_struct_ifwi_fpt_set_flags(FuStructIfwiFpt *st, guint8 value)
993
0
{
994
0
    g_return_if_fail(st != NULL);
995
0
    st->data[11] = value;
996
0
}
997
/**
998
 * fu_struct_ifwi_fpt_set_ticks_to_add: (skip):
999
 **/
1000
void
1001
fu_struct_ifwi_fpt_set_ticks_to_add(FuStructIfwiFpt *st, guint16 value)
1002
0
{
1003
0
    g_return_if_fail(st != NULL);
1004
0
    fu_memwrite_uint16(st->data + 12, value, G_LITTLE_ENDIAN);
1005
0
}
1006
/**
1007
 * fu_struct_ifwi_fpt_set_tokens_to_add: (skip):
1008
 **/
1009
void
1010
fu_struct_ifwi_fpt_set_tokens_to_add(FuStructIfwiFpt *st, guint16 value)
1011
0
{
1012
0
    g_return_if_fail(st != NULL);
1013
0
    fu_memwrite_uint16(st->data + 14, value, G_LITTLE_ENDIAN);
1014
0
}
1015
/**
1016
 * fu_struct_ifwi_fpt_set_uma_size: (skip):
1017
 **/
1018
void
1019
fu_struct_ifwi_fpt_set_uma_size(FuStructIfwiFpt *st, guint32 value)
1020
0
{
1021
0
    g_return_if_fail(st != NULL);
1022
0
    fu_memwrite_uint32(st->data + 16, value, G_LITTLE_ENDIAN);
1023
0
}
1024
/**
1025
 * fu_struct_ifwi_fpt_set_crc32: (skip):
1026
 **/
1027
void
1028
fu_struct_ifwi_fpt_set_crc32(FuStructIfwiFpt *st, guint32 value)
1029
0
{
1030
0
    g_return_if_fail(st != NULL);
1031
0
    fu_memwrite_uint32(st->data + 20, value, G_LITTLE_ENDIAN);
1032
0
}
1033
/**
1034
 * fu_struct_ifwi_fpt_set_fitc_major: (skip):
1035
 **/
1036
void
1037
fu_struct_ifwi_fpt_set_fitc_major(FuStructIfwiFpt *st, guint16 value)
1038
0
{
1039
0
    g_return_if_fail(st != NULL);
1040
0
    fu_memwrite_uint16(st->data + 24, value, G_LITTLE_ENDIAN);
1041
0
}
1042
/**
1043
 * fu_struct_ifwi_fpt_set_fitc_minor: (skip):
1044
 **/
1045
void
1046
fu_struct_ifwi_fpt_set_fitc_minor(FuStructIfwiFpt *st, guint16 value)
1047
0
{
1048
0
    g_return_if_fail(st != NULL);
1049
0
    fu_memwrite_uint16(st->data + 26, value, G_LITTLE_ENDIAN);
1050
0
}
1051
/**
1052
 * fu_struct_ifwi_fpt_set_fitc_hotfix: (skip):
1053
 **/
1054
void
1055
fu_struct_ifwi_fpt_set_fitc_hotfix(FuStructIfwiFpt *st, guint16 value)
1056
0
{
1057
0
    g_return_if_fail(st != NULL);
1058
0
    fu_memwrite_uint16(st->data + 28, value, G_LITTLE_ENDIAN);
1059
0
}
1060
/**
1061
 * fu_struct_ifwi_fpt_set_fitc_build: (skip):
1062
 **/
1063
void
1064
fu_struct_ifwi_fpt_set_fitc_build(FuStructIfwiFpt *st, guint16 value)
1065
0
{
1066
0
    g_return_if_fail(st != NULL);
1067
0
    fu_memwrite_uint16(st->data + 30, value, G_LITTLE_ENDIAN);
1068
0
}
1069
/**
1070
 * fu_struct_ifwi_fpt_new: (skip):
1071
 **/
1072
FuStructIfwiFpt *
1073
fu_struct_ifwi_fpt_new(void)
1074
71
{
1075
71
    FuStructIfwiFpt *st = g_byte_array_sized_new(32);
1076
71
    fu_byte_array_set_size(st, 32, 0x0);
1077
71
    fu_struct_ifwi_fpt_set_header_marker(st, 0x54504624);
1078
71
    fu_struct_ifwi_fpt_set_header_version(st, 0x20);
1079
71
    fu_struct_ifwi_fpt_set_entry_version(st, 0x10);
1080
71
    fu_struct_ifwi_fpt_set_header_length(st, 32);
1081
71
    return st;
1082
71
}
1083
/**
1084
 * fu_struct_ifwi_fpt_to_string: (skip):
1085
 **/
1086
static gchar *
1087
fu_struct_ifwi_fpt_to_string(const FuStructIfwiFpt *st)
1088
0
{
1089
0
    g_autoptr(GString) str = g_string_new("FuStructIfwiFpt:\n");
1090
0
    g_return_val_if_fail(st != NULL, NULL);
1091
0
    g_string_append_printf(str, "  num_of_entries: 0x%x\n",
1092
0
                           (guint) fu_struct_ifwi_fpt_get_num_of_entries(st));
1093
0
    g_string_append_printf(str, "  header_version: 0x%x\n",
1094
0
                           (guint) fu_struct_ifwi_fpt_get_header_version(st));
1095
0
    g_string_append_printf(str, "  header_length: 0x%x\n",
1096
0
                           (guint) fu_struct_ifwi_fpt_get_header_length(st));
1097
0
    g_string_append_printf(str, "  flags: 0x%x\n",
1098
0
                           (guint) fu_struct_ifwi_fpt_get_flags(st));
1099
0
    g_string_append_printf(str, "  ticks_to_add: 0x%x\n",
1100
0
                           (guint) fu_struct_ifwi_fpt_get_ticks_to_add(st));
1101
0
    g_string_append_printf(str, "  tokens_to_add: 0x%x\n",
1102
0
                           (guint) fu_struct_ifwi_fpt_get_tokens_to_add(st));
1103
0
    g_string_append_printf(str, "  uma_size: 0x%x\n",
1104
0
                           (guint) fu_struct_ifwi_fpt_get_uma_size(st));
1105
0
    g_string_append_printf(str, "  crc32: 0x%x\n",
1106
0
                           (guint) fu_struct_ifwi_fpt_get_crc32(st));
1107
0
    g_string_append_printf(str, "  fitc_major: 0x%x\n",
1108
0
                           (guint) fu_struct_ifwi_fpt_get_fitc_major(st));
1109
0
    g_string_append_printf(str, "  fitc_minor: 0x%x\n",
1110
0
                           (guint) fu_struct_ifwi_fpt_get_fitc_minor(st));
1111
0
    g_string_append_printf(str, "  fitc_hotfix: 0x%x\n",
1112
0
                           (guint) fu_struct_ifwi_fpt_get_fitc_hotfix(st));
1113
0
    g_string_append_printf(str, "  fitc_build: 0x%x\n",
1114
0
                           (guint) fu_struct_ifwi_fpt_get_fitc_build(st));
1115
0
    if (str->len > 0)
1116
0
        g_string_set_size(str, str->len - 1);
1117
0
    return g_string_free(g_steal_pointer(&str), FALSE);
1118
0
}
1119
static gboolean
1120
fu_struct_ifwi_fpt_validate_internal(FuStructIfwiFpt *st, GError **error)
1121
8.18M
{
1122
8.18M
    g_return_val_if_fail(st != NULL, FALSE);
1123
8.18M
    if (fu_struct_ifwi_fpt_get_header_marker(st) != 0x54504624) {
1124
8.18M
        g_set_error(error,
1125
8.18M
                    FWUPD_ERROR,
1126
8.18M
                    FWUPD_ERROR_INVALID_DATA,
1127
8.18M
                    "constant FuStructIfwiFpt.header_marker was not valid, "
1128
8.18M
                    "expected 0x%x and got 0x%x",
1129
8.18M
                    (guint) 0x54504624,
1130
8.18M
                    (guint) fu_struct_ifwi_fpt_get_header_marker(st));
1131
8.18M
        return FALSE;
1132
8.18M
    }
1133
2.07k
    if (fu_struct_ifwi_fpt_get_entry_version(st) != 0x10) {
1134
1.12k
        g_set_error_literal(error,
1135
1.12k
                            FWUPD_ERROR,
1136
1.12k
                            FWUPD_ERROR_INVALID_DATA,
1137
1.12k
                            "constant FuStructIfwiFpt.entry_version was not valid");
1138
1.12k
        return FALSE;
1139
1.12k
    }
1140
948
    return TRUE;
1141
2.07k
}
1142
/**
1143
 * fu_struct_ifwi_fpt_validate_stream: (skip):
1144
 **/
1145
gboolean
1146
fu_struct_ifwi_fpt_validate_stream(GInputStream *stream, gsize offset, GError **error)
1147
8.18M
{
1148
8.18M
    g_autoptr(GByteArray) st = NULL;
1149
8.18M
    g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE);
1150
8.18M
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
1151
8.18M
    st = fu_input_stream_read_byte_array(stream, offset, 32, NULL, error);
1152
8.18M
    if (st == NULL) {
1153
0
        g_prefix_error(error, "FuStructIfwiFpt failed read of 0x%x: ", (guint) 32);
1154
0
        return FALSE;
1155
0
    }
1156
8.18M
    if (st->len != 32) {
1157
4.47k
        g_set_error(error,
1158
4.47k
                    FWUPD_ERROR,
1159
4.47k
                    FWUPD_ERROR_INVALID_DATA,
1160
4.47k
                    "FuStructIfwiFpt requested 0x%x and got 0x%x",
1161
4.47k
                    (guint) 32,
1162
4.47k
                    (guint) st->len);
1163
4.47k
        return FALSE;
1164
4.47k
    }
1165
8.18M
    return fu_struct_ifwi_fpt_validate_internal(st, error);
1166
8.18M
}
1167
static gboolean
1168
fu_struct_ifwi_fpt_parse_internal(FuStructIfwiFpt *st, GError **error)
1169
474
{
1170
474
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
1171
0
        g_autofree gchar *str = fu_struct_ifwi_fpt_to_string(st);
1172
0
        g_debug("%s", str);
1173
0
    }
1174
474
    if (!fu_struct_ifwi_fpt_validate_internal(st, error))
1175
0
        return FALSE;
1176
474
    return TRUE;
1177
474
}
1178
/**
1179
 * fu_struct_ifwi_fpt_parse_stream: (skip):
1180
 **/
1181
FuStructIfwiFpt *
1182
fu_struct_ifwi_fpt_parse_stream(GInputStream *stream, gsize offset, GError **error)
1183
474
{
1184
474
    g_autoptr(GByteArray) st = NULL;
1185
474
    st = fu_input_stream_read_byte_array(stream, offset, 32, NULL, error);
1186
474
    if (st == NULL) {
1187
0
        g_prefix_error(error, "FuStructIfwiFpt failed read of 0x%x: ", (guint) 32);
1188
0
        return NULL;
1189
0
    }
1190
474
    if (st->len != 32) {
1191
0
        g_set_error(error,
1192
0
                    FWUPD_ERROR,
1193
0
                    FWUPD_ERROR_INVALID_DATA,
1194
0
                    "FuStructIfwiFpt requested 0x%x and got 0x%x",
1195
0
                    (guint) 32,
1196
0
                    (guint) st->len);
1197
0
        return NULL;
1198
0
    }
1199
474
    if (!fu_struct_ifwi_fpt_parse_internal(st, error))
1200
0
        return NULL;
1201
474
    return g_steal_pointer(&st);
1202
474
}
1203
/* getters */
1204
/**
1205
 * fu_struct_ifwi_fpt_entry_get_partition_name: (skip):
1206
 **/
1207
guint32
1208
fu_struct_ifwi_fpt_entry_get_partition_name(const FuStructIfwiFptEntry *st)
1209
3.27k
{
1210
3.27k
    g_return_val_if_fail(st != NULL, 0x0);
1211
3.27k
    return fu_memread_uint32(st->data + 0, G_LITTLE_ENDIAN);
1212
3.27k
}
1213
/**
1214
 * fu_struct_ifwi_fpt_entry_get_offset: (skip):
1215
 **/
1216
guint32
1217
fu_struct_ifwi_fpt_entry_get_offset(const FuStructIfwiFptEntry *st)
1218
1.82k
{
1219
1.82k
    g_return_val_if_fail(st != NULL, 0x0);
1220
1.82k
    return fu_memread_uint32(st->data + 8, G_LITTLE_ENDIAN);
1221
1.82k
}
1222
/**
1223
 * fu_struct_ifwi_fpt_entry_get_length: (skip):
1224
 **/
1225
guint32
1226
fu_struct_ifwi_fpt_entry_get_length(const FuStructIfwiFptEntry *st)
1227
3.27k
{
1228
3.27k
    g_return_val_if_fail(st != NULL, 0x0);
1229
3.27k
    return fu_memread_uint32(st->data + 12, G_LITTLE_ENDIAN);
1230
3.27k
}
1231
/**
1232
 * fu_struct_ifwi_fpt_entry_get_partition_type: (skip):
1233
 **/
1234
guint32
1235
fu_struct_ifwi_fpt_entry_get_partition_type(const FuStructIfwiFptEntry *st)
1236
0
{
1237
0
    g_return_val_if_fail(st != NULL, 0x0);
1238
0
    return fu_memread_uint32(st->data + 28, G_LITTLE_ENDIAN);
1239
0
}
1240
1241
/* setters */
1242
/**
1243
 * fu_struct_ifwi_fpt_entry_set_partition_name: (skip):
1244
 **/
1245
void
1246
fu_struct_ifwi_fpt_entry_set_partition_name(FuStructIfwiFptEntry *st, guint32 value)
1247
0
{
1248
0
    g_return_if_fail(st != NULL);
1249
0
    fu_memwrite_uint32(st->data + 0, value, G_LITTLE_ENDIAN);
1250
0
}
1251
/**
1252
 * fu_struct_ifwi_fpt_entry_set_offset: (skip):
1253
 **/
1254
void
1255
fu_struct_ifwi_fpt_entry_set_offset(FuStructIfwiFptEntry *st, guint32 value)
1256
0
{
1257
0
    g_return_if_fail(st != NULL);
1258
0
    fu_memwrite_uint32(st->data + 8, value, G_LITTLE_ENDIAN);
1259
0
}
1260
/**
1261
 * fu_struct_ifwi_fpt_entry_set_length: (skip):
1262
 **/
1263
void
1264
fu_struct_ifwi_fpt_entry_set_length(FuStructIfwiFptEntry *st, guint32 value)
1265
0
{
1266
0
    g_return_if_fail(st != NULL);
1267
0
    fu_memwrite_uint32(st->data + 12, value, G_LITTLE_ENDIAN);
1268
0
}
1269
/**
1270
 * fu_struct_ifwi_fpt_entry_set_partition_type: (skip):
1271
 **/
1272
void
1273
fu_struct_ifwi_fpt_entry_set_partition_type(FuStructIfwiFptEntry *st, guint32 value)
1274
0
{
1275
0
    g_return_if_fail(st != NULL);
1276
0
    fu_memwrite_uint32(st->data + 28, value, G_LITTLE_ENDIAN);
1277
0
}
1278
/**
1279
 * fu_struct_ifwi_fpt_entry_new: (skip):
1280
 **/
1281
FuStructIfwiFptEntry *
1282
fu_struct_ifwi_fpt_entry_new(void)
1283
0
{
1284
0
    FuStructIfwiFptEntry *st = g_byte_array_sized_new(32);
1285
0
    fu_byte_array_set_size(st, 32, 0x0);
1286
0
    return st;
1287
0
}
1288
/**
1289
 * fu_struct_ifwi_fpt_entry_to_string: (skip):
1290
 **/
1291
static gchar *
1292
fu_struct_ifwi_fpt_entry_to_string(const FuStructIfwiFptEntry *st)
1293
0
{
1294
0
    g_autoptr(GString) str = g_string_new("FuStructIfwiFptEntry:\n");
1295
0
    g_return_val_if_fail(st != NULL, NULL);
1296
0
    g_string_append_printf(str, "  partition_name: 0x%x\n",
1297
0
                           (guint) fu_struct_ifwi_fpt_entry_get_partition_name(st));
1298
0
    g_string_append_printf(str, "  offset: 0x%x\n",
1299
0
                           (guint) fu_struct_ifwi_fpt_entry_get_offset(st));
1300
0
    g_string_append_printf(str, "  length: 0x%x\n",
1301
0
                           (guint) fu_struct_ifwi_fpt_entry_get_length(st));
1302
0
    g_string_append_printf(str, "  partition_type: 0x%x\n",
1303
0
                           (guint) fu_struct_ifwi_fpt_entry_get_partition_type(st));
1304
0
    if (str->len > 0)
1305
0
        g_string_set_size(str, str->len - 1);
1306
0
    return g_string_free(g_steal_pointer(&str), FALSE);
1307
0
}
1308
static gboolean
1309
fu_struct_ifwi_fpt_entry_validate_internal(FuStructIfwiFptEntry *st, GError **error)
1310
3.27k
{
1311
3.27k
    g_return_val_if_fail(st != NULL, FALSE);
1312
3.27k
    return TRUE;
1313
3.27k
}
1314
static gboolean
1315
fu_struct_ifwi_fpt_entry_parse_internal(FuStructIfwiFptEntry *st, GError **error)
1316
3.27k
{
1317
3.27k
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
1318
0
        g_autofree gchar *str = fu_struct_ifwi_fpt_entry_to_string(st);
1319
0
        g_debug("%s", str);
1320
0
    }
1321
3.27k
    if (!fu_struct_ifwi_fpt_entry_validate_internal(st, error))
1322
0
        return FALSE;
1323
3.27k
    return TRUE;
1324
3.27k
}
1325
/**
1326
 * fu_struct_ifwi_fpt_entry_parse_stream: (skip):
1327
 **/
1328
FuStructIfwiFptEntry *
1329
fu_struct_ifwi_fpt_entry_parse_stream(GInputStream *stream, gsize offset, GError **error)
1330
3.43k
{
1331
3.43k
    g_autoptr(GByteArray) st = NULL;
1332
3.43k
    st = fu_input_stream_read_byte_array(stream, offset, 32, NULL, error);
1333
3.43k
    if (st == NULL) {
1334
120
        g_prefix_error(error, "FuStructIfwiFptEntry failed read of 0x%x: ", (guint) 32);
1335
120
        return NULL;
1336
120
    }
1337
3.31k
    if (st->len != 32) {
1338
44
        g_set_error(error,
1339
44
                    FWUPD_ERROR,
1340
44
                    FWUPD_ERROR_INVALID_DATA,
1341
44
                    "FuStructIfwiFptEntry requested 0x%x and got 0x%x",
1342
44
                    (guint) 32,
1343
44
                    (guint) st->len);
1344
44
        return NULL;
1345
44
    }
1346
3.27k
    if (!fu_struct_ifwi_fpt_entry_parse_internal(st, error))
1347
0
        return NULL;
1348
3.27k
    return g_steal_pointer(&st);
1349
3.27k
}