Coverage Report

Created: 2025-11-24 06:59

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