Coverage Report

Created: 2025-07-01 07:09

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