Coverage Report

Created: 2025-11-11 06:44

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