Coverage Report

Created: 2026-01-09 07:21

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/fu-acpi-phat-struct.c
Line
Count
Source
1
/*
2
 * This file is auto-generated, do not modify!
3
 *
4
 * SPDX-License-Identifier: LGPL-2.1-or-later
5
 */
6
7
#include "config.h"
8
9
#include <glib.h>
10
11
#include "fu-acpi-phat-struct.h"
12
#include "fu-byte-array.h"
13
#include "fu-mem-private.h"
14
#include "fu-string.h"
15
16
#ifdef G_LOG_DOMAIN
17
  #undef G_LOG_DOMAIN
18
#endif
19
0
#define G_LOG_DOMAIN "FuStruct"
20
/**
21
 * fu_struct_acpi_phat_hdr_ref: (skip):
22
 **/
23
FuStructAcpiPhatHdr *
24
fu_struct_acpi_phat_hdr_ref(FuStructAcpiPhatHdr *st)
25
0
{
26
0
    g_return_val_if_fail(st != NULL, NULL);
27
0
    st->refcount++;
28
0
    return st;
29
0
}
30
/**
31
 * fu_struct_acpi_phat_hdr_unref: (skip):
32
 **/
33
void
34
fu_struct_acpi_phat_hdr_unref(FuStructAcpiPhatHdr *st)
35
155k
{
36
155k
    g_return_if_fail(st != NULL);
37
155k
    if (st->refcount == 0) {
38
0
        g_critical("FuStructAcpiPhatHdr refcount already zero");
39
0
        return;
40
0
    }
41
155k
    if (--st->refcount > 0)
42
0
        return;
43
155k
    if (st->buf != NULL)
44
155k
        g_byte_array_unref(st->buf);
45
155k
    g_free(st);
46
155k
}
47
/**
48
 * fu_struct_acpi_phat_hdr_new_internal: (skip):
49
 **/
50
static FuStructAcpiPhatHdr *
51
fu_struct_acpi_phat_hdr_new_internal(void)
52
155k
{
53
155k
    FuStructAcpiPhatHdr *st = g_new0(FuStructAcpiPhatHdr, 1);
54
155k
    st->refcount = 1;
55
155k
    return st;
56
155k
}
57
58
/* getters */
59
/**
60
 * fu_struct_acpi_phat_hdr_get_magic: (skip):
61
 **/
62
static gchar *
63
fu_struct_acpi_phat_hdr_get_magic(const FuStructAcpiPhatHdr *st)
64
152k
{
65
152k
    g_return_val_if_fail(st != NULL, NULL);
66
152k
    return fu_memstrsafe(st->buf->data, st->buf->len, 0, 4, NULL);
67
152k
}
68
69
/* setters */
70
static gboolean
71
fu_struct_acpi_phat_hdr_validate_internal(FuStructAcpiPhatHdr *st, GError **error)
72
154k
{
73
154k
    g_return_val_if_fail(st != NULL, FALSE);
74
154k
    if (strncmp((const gchar *) (st->buf->data + 0), "PHAT", 4) != 0) {
75
152k
        g_autofree gchar *str = fu_struct_acpi_phat_hdr_get_magic(st);
76
152k
        g_set_error(error,
77
152k
                    FWUPD_ERROR,
78
152k
                    FWUPD_ERROR_INVALID_DATA,
79
152k
                    "constant FuStructAcpiPhatHdr.magic was not valid, "
80
152k
                    "expected 'PHAT' and got '%s'",
81
152k
                    str);
82
152k
        return FALSE;
83
152k
    }
84
2.15k
    return TRUE;
85
154k
}
86
/**
87
 * fu_struct_acpi_phat_hdr_validate_stream: (skip):
88
 **/
89
gboolean
90
fu_struct_acpi_phat_hdr_validate_stream(GInputStream *stream, gsize offset, GError **error)
91
155k
{
92
155k
    g_autoptr(FuStructAcpiPhatHdr) st = fu_struct_acpi_phat_hdr_new_internal();
93
155k
    g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE);
94
155k
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
95
155k
    st->buf = fu_input_stream_read_byte_array(stream, offset, 4, NULL, error);
96
155k
    if (st->buf == NULL) {
97
0
        g_prefix_error(error, "FuStructAcpiPhatHdr failed read of 0x%x: ", (guint) 4);
98
0
        return FALSE;
99
0
    }
100
155k
    if (st->buf->len != 4) {
101
412
        g_set_error(error,
102
412
                    FWUPD_ERROR,
103
412
                    FWUPD_ERROR_INVALID_DATA,
104
412
                    "FuStructAcpiPhatHdr requested 0x%x and got 0x%x",
105
412
                    (guint) 4,
106
412
                    (guint) st->buf->len);
107
412
        return FALSE;
108
412
    }
109
154k
    return fu_struct_acpi_phat_hdr_validate_internal(st, error);
110
155k
}
111
/**
112
 * fu_struct_acpi_phat_health_record_ref: (skip):
113
 **/
114
FuStructAcpiPhatHealthRecord *
115
fu_struct_acpi_phat_health_record_ref(FuStructAcpiPhatHealthRecord *st)
116
0
{
117
0
    g_return_val_if_fail(st != NULL, NULL);
118
0
    st->refcount++;
119
0
    return st;
120
0
}
121
/**
122
 * fu_struct_acpi_phat_health_record_unref: (skip):
123
 **/
124
void
125
fu_struct_acpi_phat_health_record_unref(FuStructAcpiPhatHealthRecord *st)
126
2.80k
{
127
2.80k
    g_return_if_fail(st != NULL);
128
2.80k
    if (st->refcount == 0) {
129
0
        g_critical("FuStructAcpiPhatHealthRecord refcount already zero");
130
0
        return;
131
0
    }
132
2.80k
    if (--st->refcount > 0)
133
0
        return;
134
2.80k
    if (st->buf != NULL)
135
2.03k
        g_byte_array_unref(st->buf);
136
2.80k
    g_free(st);
137
2.80k
}
138
/**
139
 * fu_struct_acpi_phat_health_record_new_internal: (skip):
140
 **/
141
static FuStructAcpiPhatHealthRecord *
142
fu_struct_acpi_phat_health_record_new_internal(void)
143
2.80k
{
144
2.80k
    FuStructAcpiPhatHealthRecord *st = g_new0(FuStructAcpiPhatHealthRecord, 1);
145
2.80k
    st->refcount = 1;
146
2.80k
    return st;
147
2.80k
}
148
149
/* getters */
150
/**
151
 * fu_struct_acpi_phat_health_record_get_signature: (skip):
152
 **/
153
guint16
154
fu_struct_acpi_phat_health_record_get_signature(const FuStructAcpiPhatHealthRecord *st)
155
0
{
156
0
    g_return_val_if_fail(st != NULL, 0x0);
157
0
    return fu_memread_uint16(st->buf->data + 0, G_LITTLE_ENDIAN);
158
0
}
159
/**
160
 * fu_struct_acpi_phat_health_record_get_rcdlen: (skip):
161
 **/
162
guint16
163
fu_struct_acpi_phat_health_record_get_rcdlen(const FuStructAcpiPhatHealthRecord *st)
164
2.00k
{
165
2.00k
    g_return_val_if_fail(st != NULL, 0x0);
166
2.00k
    return fu_memread_uint16(st->buf->data + 2, G_LITTLE_ENDIAN);
167
2.00k
}
168
/**
169
 * fu_struct_acpi_phat_health_record_get_version: (skip):
170
 **/
171
guint8
172
fu_struct_acpi_phat_health_record_get_version(const FuStructAcpiPhatHealthRecord *st)
173
0
{
174
0
    g_return_val_if_fail(st != NULL, 0x0);
175
0
    return st->buf->data[4];
176
0
}
177
/**
178
 * fu_struct_acpi_phat_health_record_get_flags: (skip):
179
 **/
180
guint8
181
fu_struct_acpi_phat_health_record_get_flags(const FuStructAcpiPhatHealthRecord *st)
182
2.00k
{
183
2.00k
    g_return_val_if_fail(st != NULL, 0x0);
184
2.00k
    return st->buf->data[7];
185
2.00k
}
186
/**
187
 * fu_struct_acpi_phat_health_record_get_device_signature: (skip):
188
 **/
189
const fwupd_guid_t *
190
fu_struct_acpi_phat_health_record_get_device_signature(const FuStructAcpiPhatHealthRecord *st)
191
2.00k
{
192
2.00k
    g_return_val_if_fail(st != NULL, NULL);
193
2.00k
    return (const fwupd_guid_t *) (st->buf->data + 8);
194
2.00k
}
195
/**
196
 * fu_struct_acpi_phat_health_record_get_device_specific_data: (skip):
197
 **/
198
guint32
199
fu_struct_acpi_phat_health_record_get_device_specific_data(const FuStructAcpiPhatHealthRecord *st)
200
2.00k
{
201
2.00k
    g_return_val_if_fail(st != NULL, 0x0);
202
2.00k
    return fu_memread_uint32(st->buf->data + 24, G_LITTLE_ENDIAN);
203
2.00k
}
204
205
/* setters */
206
/**
207
 * fu_struct_acpi_phat_health_record_set_signature: (skip):
208
 **/
209
void
210
fu_struct_acpi_phat_health_record_set_signature(FuStructAcpiPhatHealthRecord *st, guint16 value)
211
770
{
212
770
    g_return_if_fail(st != NULL);
213
770
    fu_memwrite_uint16(st->buf->data + 0, value, G_LITTLE_ENDIAN);
214
770
}
215
/**
216
 * fu_struct_acpi_phat_health_record_set_rcdlen: (skip):
217
 **/
218
void
219
fu_struct_acpi_phat_health_record_set_rcdlen(FuStructAcpiPhatHealthRecord *st, guint16 value)
220
770
{
221
770
    g_return_if_fail(st != NULL);
222
770
    fu_memwrite_uint16(st->buf->data + 2, value, G_LITTLE_ENDIAN);
223
770
}
224
/**
225
 * fu_struct_acpi_phat_health_record_set_version: (skip):
226
 **/
227
void
228
fu_struct_acpi_phat_health_record_set_version(FuStructAcpiPhatHealthRecord *st, guint8 value)
229
770
{
230
770
    g_return_if_fail(st != NULL);
231
770
    st->buf->data[4] = value;
232
770
}
233
/**
234
 * fu_struct_acpi_phat_health_record_set_flags: (skip):
235
 **/
236
void
237
fu_struct_acpi_phat_health_record_set_flags(FuStructAcpiPhatHealthRecord *st, guint8 value)
238
770
{
239
770
    g_return_if_fail(st != NULL);
240
770
    st->buf->data[7] = value;
241
770
}
242
/**
243
 * fu_struct_acpi_phat_health_record_set_device_signature: (skip):
244
 **/
245
void
246
fu_struct_acpi_phat_health_record_set_device_signature(FuStructAcpiPhatHealthRecord *st, const fwupd_guid_t *value)
247
770
{
248
770
    g_return_if_fail(st != NULL);
249
770
    g_return_if_fail(value != NULL);
250
770
    memcpy(st->buf->data + 8, value, sizeof(*value)); /* nocheck:blocked */
251
770
}
252
/**
253
 * fu_struct_acpi_phat_health_record_set_device_specific_data: (skip):
254
 **/
255
void
256
fu_struct_acpi_phat_health_record_set_device_specific_data(FuStructAcpiPhatHealthRecord *st, guint32 value)
257
0
{
258
0
    g_return_if_fail(st != NULL);
259
0
    fu_memwrite_uint32(st->buf->data + 24, value, G_LITTLE_ENDIAN);
260
0
}
261
/**
262
 * fu_struct_acpi_phat_health_record_new: (skip):
263
 **/
264
FuStructAcpiPhatHealthRecord *
265
fu_struct_acpi_phat_health_record_new(void)
266
770
{
267
770
    FuStructAcpiPhatHealthRecord *st = fu_struct_acpi_phat_health_record_new_internal();
268
770
    st->buf = g_byte_array_sized_new(28);
269
770
    fu_byte_array_set_size(st->buf, 28, 0x0);
270
770
    fu_struct_acpi_phat_health_record_set_signature(st, 0x1);
271
770
    return st;
272
770
}
273
/**
274
 * fu_struct_acpi_phat_health_record_to_string: (skip):
275
 **/
276
static gchar *
277
fu_struct_acpi_phat_health_record_to_string(const FuStructAcpiPhatHealthRecord *st)
278
0
{
279
0
    g_autoptr(GString) str = g_string_new("FuStructAcpiPhatHealthRecord:\n");
280
0
    g_return_val_if_fail(st != NULL, NULL);
281
0
    g_string_append_printf(str, "  signature: 0x%x\n",
282
0
                           (guint) fu_struct_acpi_phat_health_record_get_signature(st));
283
0
    g_string_append_printf(str, "  rcdlen: 0x%x\n",
284
0
                           (guint) fu_struct_acpi_phat_health_record_get_rcdlen(st));
285
0
    g_string_append_printf(str, "  version: 0x%x\n",
286
0
                           (guint) fu_struct_acpi_phat_health_record_get_version(st));
287
0
    g_string_append_printf(str, "  flags: 0x%x\n",
288
0
                           (guint) fu_struct_acpi_phat_health_record_get_flags(st));
289
0
    {
290
0
        g_autofree gchar *tmp = fwupd_guid_to_string(fu_struct_acpi_phat_health_record_get_device_signature(st), FWUPD_GUID_FLAG_MIXED_ENDIAN);
291
0
        g_string_append_printf(str, "  device_signature: %s\n", tmp);
292
0
    }
293
0
    g_string_append_printf(str, "  device_specific_data: 0x%x\n",
294
0
                           (guint) fu_struct_acpi_phat_health_record_get_device_specific_data(st));
295
0
    if (str->len > 0)
296
0
        g_string_set_size(str, str->len - 1);
297
0
    return g_string_free(g_steal_pointer(&str), FALSE);
298
0
}
299
static gboolean
300
fu_struct_acpi_phat_health_record_validate_internal(FuStructAcpiPhatHealthRecord *st, GError **error)
301
2.00k
{
302
2.00k
    g_return_val_if_fail(st != NULL, FALSE);
303
2.00k
    return TRUE;
304
2.00k
}
305
static gboolean
306
fu_struct_acpi_phat_health_record_parse_internal(FuStructAcpiPhatHealthRecord *st, GError **error)
307
2.00k
{
308
2.00k
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
309
0
        g_autofree gchar *str = fu_struct_acpi_phat_health_record_to_string(st);
310
0
        g_debug("%s", str);
311
0
    }
312
2.00k
    if (!fu_struct_acpi_phat_health_record_validate_internal(st, error))
313
0
        return FALSE;
314
2.00k
    return TRUE;
315
2.00k
}
316
/**
317
 * fu_struct_acpi_phat_health_record_parse_stream: (skip):
318
 **/
319
FuStructAcpiPhatHealthRecord *
320
fu_struct_acpi_phat_health_record_parse_stream(GInputStream *stream, gsize offset, GError **error)
321
2.03k
{
322
2.03k
    g_autoptr(FuStructAcpiPhatHealthRecord) st = fu_struct_acpi_phat_health_record_new_internal();
323
2.03k
    st->buf = fu_input_stream_read_byte_array(stream, offset, 28, NULL, error);
324
2.03k
    if (st->buf == NULL) {
325
0
        g_prefix_error(error, "FuStructAcpiPhatHealthRecord failed read of 0x%x: ", (guint) 28);
326
0
        return NULL;
327
0
    }
328
2.03k
    if (st->buf->len != 28) {
329
32
        g_set_error(error,
330
32
                    FWUPD_ERROR,
331
32
                    FWUPD_ERROR_INVALID_DATA,
332
32
                    "FuStructAcpiPhatHealthRecord requested 0x%x and got 0x%x",
333
32
                    (guint) 28,
334
32
                    (guint) st->buf->len);
335
32
        return NULL;
336
32
    }
337
2.00k
    if (!fu_struct_acpi_phat_health_record_parse_internal(st, error))
338
0
        return NULL;
339
2.00k
    return g_steal_pointer(&st);
340
2.00k
}
341
/**
342
 * fu_struct_acpi_phat_version_element_ref: (skip):
343
 **/
344
FuStructAcpiPhatVersionElement *
345
fu_struct_acpi_phat_version_element_ref(FuStructAcpiPhatVersionElement *st)
346
0
{
347
0
    g_return_val_if_fail(st != NULL, NULL);
348
0
    st->refcount++;
349
0
    return st;
350
0
}
351
/**
352
 * fu_struct_acpi_phat_version_element_unref: (skip):
353
 **/
354
void
355
fu_struct_acpi_phat_version_element_unref(FuStructAcpiPhatVersionElement *st)
356
33.7k
{
357
33.7k
    g_return_if_fail(st != NULL);
358
33.7k
    if (st->refcount == 0) {
359
0
        g_critical("FuStructAcpiPhatVersionElement refcount already zero");
360
0
        return;
361
0
    }
362
33.7k
    if (--st->refcount > 0)
363
0
        return;
364
33.7k
    if (st->buf != NULL)
365
30.4k
        g_byte_array_unref(st->buf);
366
33.7k
    g_free(st);
367
33.7k
}
368
/**
369
 * fu_struct_acpi_phat_version_element_new_internal: (skip):
370
 **/
371
static FuStructAcpiPhatVersionElement *
372
fu_struct_acpi_phat_version_element_new_internal(void)
373
33.7k
{
374
33.7k
    FuStructAcpiPhatVersionElement *st = g_new0(FuStructAcpiPhatVersionElement, 1);
375
33.7k
    st->refcount = 1;
376
33.7k
    return st;
377
33.7k
}
378
379
/* getters */
380
/**
381
 * fu_struct_acpi_phat_version_element_get_component_id: (skip):
382
 **/
383
const fwupd_guid_t *
384
fu_struct_acpi_phat_version_element_get_component_id(const FuStructAcpiPhatVersionElement *st)
385
30.4k
{
386
30.4k
    g_return_val_if_fail(st != NULL, NULL);
387
30.4k
    return (const fwupd_guid_t *) (st->buf->data + 0);
388
30.4k
}
389
/**
390
 * fu_struct_acpi_phat_version_element_get_version_value: (skip):
391
 **/
392
guint64
393
fu_struct_acpi_phat_version_element_get_version_value(const FuStructAcpiPhatVersionElement *st)
394
30.4k
{
395
30.4k
    g_return_val_if_fail(st != NULL, 0x0);
396
30.4k
    return fu_memread_uint64(st->buf->data + 16, G_LITTLE_ENDIAN);
397
30.4k
}
398
/**
399
 * fu_struct_acpi_phat_version_element_get_producer_id: (skip):
400
 **/
401
gchar *
402
fu_struct_acpi_phat_version_element_get_producer_id(const FuStructAcpiPhatVersionElement *st)
403
30.4k
{
404
30.4k
    g_return_val_if_fail(st != NULL, NULL);
405
30.4k
    return fu_memstrsafe(st->buf->data, st->buf->len, 24, 4, NULL);
406
30.4k
}
407
408
/* setters */
409
/**
410
 * fu_struct_acpi_phat_version_element_set_component_id: (skip):
411
 **/
412
void
413
fu_struct_acpi_phat_version_element_set_component_id(FuStructAcpiPhatVersionElement *st, const fwupd_guid_t *value)
414
3.38k
{
415
3.38k
    g_return_if_fail(st != NULL);
416
3.38k
    g_return_if_fail(value != NULL);
417
3.38k
    memcpy(st->buf->data + 0, value, sizeof(*value)); /* nocheck:blocked */
418
3.38k
}
419
/**
420
 * fu_struct_acpi_phat_version_element_set_version_value: (skip):
421
 **/
422
void
423
fu_struct_acpi_phat_version_element_set_version_value(FuStructAcpiPhatVersionElement *st, guint64 value)
424
3.38k
{
425
3.38k
    g_return_if_fail(st != NULL);
426
3.38k
    fu_memwrite_uint64(st->buf->data + 16, value, G_LITTLE_ENDIAN);
427
3.38k
}
428
/**
429
 * fu_struct_acpi_phat_version_element_set_producer_id: (skip):
430
 **/
431
gboolean
432
fu_struct_acpi_phat_version_element_set_producer_id(FuStructAcpiPhatVersionElement *st, const gchar *value, GError **error)
433
3.38k
{
434
3.38k
    gsize len;
435
3.38k
    g_return_val_if_fail(st != NULL, FALSE);
436
3.38k
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
437
3.38k
    if (value == NULL) {
438
2.29k
        memset(st->buf->data + 24, 0x0, 4);
439
2.29k
        return TRUE;
440
2.29k
    }
441
1.08k
    len = strlen(value);
442
1.08k
    if (len > 4) {
443
0
        g_set_error(error,
444
0
                    FWUPD_ERROR,
445
0
                    FWUPD_ERROR_INVALID_DATA,
446
0
                    "string '%s' (0x%x bytes) does not fit in FuStructAcpiPhatVersionElement.producer_id (0x%x bytes)",
447
0
                    value, (guint) len, (guint) 4);
448
0
        return FALSE;
449
0
    }
450
1.08k
    return fu_memcpy_safe(st->buf->data, st->buf->len, 24, (const guint8 *)value, len, 0x0, len, error);
451
1.08k
}
452
/**
453
 * fu_struct_acpi_phat_version_element_new: (skip):
454
 **/
455
FuStructAcpiPhatVersionElement *
456
fu_struct_acpi_phat_version_element_new(void)
457
3.38k
{
458
3.38k
    FuStructAcpiPhatVersionElement *st = fu_struct_acpi_phat_version_element_new_internal();
459
3.38k
    st->buf = g_byte_array_sized_new(28);
460
3.38k
    fu_byte_array_set_size(st->buf, 28, 0x0);
461
3.38k
    return st;
462
3.38k
}
463
/**
464
 * fu_struct_acpi_phat_version_element_to_string: (skip):
465
 **/
466
static gchar *
467
fu_struct_acpi_phat_version_element_to_string(const FuStructAcpiPhatVersionElement *st)
468
0
{
469
0
    g_autoptr(GString) str = g_string_new("FuStructAcpiPhatVersionElement:\n");
470
0
    g_return_val_if_fail(st != NULL, NULL);
471
0
    {
472
0
        g_autofree gchar *tmp = fwupd_guid_to_string(fu_struct_acpi_phat_version_element_get_component_id(st), FWUPD_GUID_FLAG_MIXED_ENDIAN);
473
0
        g_string_append_printf(str, "  component_id: %s\n", tmp);
474
0
    }
475
0
    g_string_append_printf(str, "  version_value: 0x%x\n",
476
0
                           (guint) fu_struct_acpi_phat_version_element_get_version_value(st));
477
0
    {
478
0
        g_autofree gchar *tmp = fu_struct_acpi_phat_version_element_get_producer_id(st);
479
0
        if (tmp != NULL)
480
0
            g_string_append_printf(str, "  producer_id: %s\n", tmp);
481
0
    }
482
0
    if (str->len > 0)
483
0
        g_string_set_size(str, str->len - 1);
484
0
    return g_string_free(g_steal_pointer(&str), FALSE);
485
0
}
486
static gboolean
487
fu_struct_acpi_phat_version_element_validate_internal(FuStructAcpiPhatVersionElement *st, GError **error)
488
30.4k
{
489
30.4k
    g_return_val_if_fail(st != NULL, FALSE);
490
30.4k
    return TRUE;
491
30.4k
}
492
static gboolean
493
fu_struct_acpi_phat_version_element_parse_internal(FuStructAcpiPhatVersionElement *st, GError **error)
494
30.4k
{
495
30.4k
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
496
0
        g_autofree gchar *str = fu_struct_acpi_phat_version_element_to_string(st);
497
0
        g_debug("%s", str);
498
0
    }
499
30.4k
    if (!fu_struct_acpi_phat_version_element_validate_internal(st, error))
500
0
        return FALSE;
501
30.4k
    return TRUE;
502
30.4k
}
503
/**
504
 * fu_struct_acpi_phat_version_element_parse_stream: (skip):
505
 **/
506
FuStructAcpiPhatVersionElement *
507
fu_struct_acpi_phat_version_element_parse_stream(GInputStream *stream, gsize offset, GError **error)
508
30.4k
{
509
30.4k
    g_autoptr(FuStructAcpiPhatVersionElement) st = fu_struct_acpi_phat_version_element_new_internal();
510
30.4k
    st->buf = fu_input_stream_read_byte_array(stream, offset, 28, NULL, error);
511
30.4k
    if (st->buf == NULL) {
512
0
        g_prefix_error(error, "FuStructAcpiPhatVersionElement failed read of 0x%x: ", (guint) 28);
513
0
        return NULL;
514
0
    }
515
30.4k
    if (st->buf->len != 28) {
516
0
        g_set_error(error,
517
0
                    FWUPD_ERROR,
518
0
                    FWUPD_ERROR_INVALID_DATA,
519
0
                    "FuStructAcpiPhatVersionElement requested 0x%x and got 0x%x",
520
0
                    (guint) 28,
521
0
                    (guint) st->buf->len);
522
0
        return NULL;
523
0
    }
524
30.4k
    if (!fu_struct_acpi_phat_version_element_parse_internal(st, error))
525
0
        return NULL;
526
30.4k
    return g_steal_pointer(&st);
527
30.4k
}
528
/**
529
 * fu_struct_acpi_phat_version_record_ref: (skip):
530
 **/
531
FuStructAcpiPhatVersionRecord *
532
fu_struct_acpi_phat_version_record_ref(FuStructAcpiPhatVersionRecord *st)
533
0
{
534
0
    g_return_val_if_fail(st != NULL, NULL);
535
0
    st->refcount++;
536
0
    return st;
537
0
}
538
/**
539
 * fu_struct_acpi_phat_version_record_unref: (skip):
540
 **/
541
void
542
fu_struct_acpi_phat_version_record_unref(FuStructAcpiPhatVersionRecord *st)
543
29.0k
{
544
29.0k
    g_return_if_fail(st != NULL);
545
29.0k
    if (st->refcount == 0) {
546
0
        g_critical("FuStructAcpiPhatVersionRecord refcount already zero");
547
0
        return;
548
0
    }
549
29.0k
    if (--st->refcount > 0)
550
0
        return;
551
29.0k
    if (st->buf != NULL)
552
22.0k
        g_byte_array_unref(st->buf);
553
29.0k
    g_free(st);
554
29.0k
}
555
/**
556
 * fu_struct_acpi_phat_version_record_new_internal: (skip):
557
 **/
558
static FuStructAcpiPhatVersionRecord *
559
fu_struct_acpi_phat_version_record_new_internal(void)
560
29.0k
{
561
29.0k
    FuStructAcpiPhatVersionRecord *st = g_new0(FuStructAcpiPhatVersionRecord, 1);
562
29.0k
    st->refcount = 1;
563
29.0k
    return st;
564
29.0k
}
565
566
/* getters */
567
/**
568
 * fu_struct_acpi_phat_version_record_get_signature: (skip):
569
 **/
570
guint16
571
fu_struct_acpi_phat_version_record_get_signature(const FuStructAcpiPhatVersionRecord *st)
572
0
{
573
0
    g_return_val_if_fail(st != NULL, 0x0);
574
0
    return fu_memread_uint16(st->buf->data + 0, G_LITTLE_ENDIAN);
575
0
}
576
/**
577
 * fu_struct_acpi_phat_version_record_get_rcdlen: (skip):
578
 **/
579
guint16
580
fu_struct_acpi_phat_version_record_get_rcdlen(const FuStructAcpiPhatVersionRecord *st)
581
0
{
582
0
    g_return_val_if_fail(st != NULL, 0x0);
583
0
    return fu_memread_uint16(st->buf->data + 2, G_LITTLE_ENDIAN);
584
0
}
585
/**
586
 * fu_struct_acpi_phat_version_record_get_version: (skip):
587
 **/
588
guint8
589
fu_struct_acpi_phat_version_record_get_version(const FuStructAcpiPhatVersionRecord *st)
590
0
{
591
0
    g_return_val_if_fail(st != NULL, 0x0);
592
0
    return st->buf->data[4];
593
0
}
594
/**
595
 * fu_struct_acpi_phat_version_record_get_record_count: (skip):
596
 **/
597
guint32
598
fu_struct_acpi_phat_version_record_get_record_count(const FuStructAcpiPhatVersionRecord *st)
599
21.9k
{
600
21.9k
    g_return_val_if_fail(st != NULL, 0x0);
601
21.9k
    return fu_memread_uint32(st->buf->data + 8, G_LITTLE_ENDIAN);
602
21.9k
}
603
604
/* setters */
605
/**
606
 * fu_struct_acpi_phat_version_record_set_signature: (skip):
607
 **/
608
void
609
fu_struct_acpi_phat_version_record_set_signature(FuStructAcpiPhatVersionRecord *st, guint16 value)
610
7.03k
{
611
7.03k
    g_return_if_fail(st != NULL);
612
7.03k
    fu_memwrite_uint16(st->buf->data + 0, value, G_LITTLE_ENDIAN);
613
7.03k
}
614
/**
615
 * fu_struct_acpi_phat_version_record_set_rcdlen: (skip):
616
 **/
617
void
618
fu_struct_acpi_phat_version_record_set_rcdlen(FuStructAcpiPhatVersionRecord *st, guint16 value)
619
7.03k
{
620
7.03k
    g_return_if_fail(st != NULL);
621
7.03k
    fu_memwrite_uint16(st->buf->data + 2, value, G_LITTLE_ENDIAN);
622
7.03k
}
623
/**
624
 * fu_struct_acpi_phat_version_record_set_version: (skip):
625
 **/
626
void
627
fu_struct_acpi_phat_version_record_set_version(FuStructAcpiPhatVersionRecord *st, guint8 value)
628
7.03k
{
629
7.03k
    g_return_if_fail(st != NULL);
630
7.03k
    st->buf->data[4] = value;
631
7.03k
}
632
/**
633
 * fu_struct_acpi_phat_version_record_set_record_count: (skip):
634
 **/
635
void
636
fu_struct_acpi_phat_version_record_set_record_count(FuStructAcpiPhatVersionRecord *st, guint32 value)
637
7.03k
{
638
7.03k
    g_return_if_fail(st != NULL);
639
7.03k
    fu_memwrite_uint32(st->buf->data + 8, value, G_LITTLE_ENDIAN);
640
7.03k
}
641
/**
642
 * fu_struct_acpi_phat_version_record_new: (skip):
643
 **/
644
FuStructAcpiPhatVersionRecord *
645
fu_struct_acpi_phat_version_record_new(void)
646
7.03k
{
647
7.03k
    FuStructAcpiPhatVersionRecord *st = fu_struct_acpi_phat_version_record_new_internal();
648
7.03k
    st->buf = g_byte_array_sized_new(12);
649
7.03k
    fu_byte_array_set_size(st->buf, 12, 0x0);
650
7.03k
    fu_struct_acpi_phat_version_record_set_signature(st, 0x0);
651
7.03k
    return st;
652
7.03k
}
653
/**
654
 * fu_struct_acpi_phat_version_record_to_string: (skip):
655
 **/
656
static gchar *
657
fu_struct_acpi_phat_version_record_to_string(const FuStructAcpiPhatVersionRecord *st)
658
0
{
659
0
    g_autoptr(GString) str = g_string_new("FuStructAcpiPhatVersionRecord:\n");
660
0
    g_return_val_if_fail(st != NULL, NULL);
661
0
    g_string_append_printf(str, "  signature: 0x%x\n",
662
0
                           (guint) fu_struct_acpi_phat_version_record_get_signature(st));
663
0
    g_string_append_printf(str, "  rcdlen: 0x%x\n",
664
0
                           (guint) fu_struct_acpi_phat_version_record_get_rcdlen(st));
665
0
    g_string_append_printf(str, "  version: 0x%x\n",
666
0
                           (guint) fu_struct_acpi_phat_version_record_get_version(st));
667
0
    g_string_append_printf(str, "  record_count: 0x%x\n",
668
0
                           (guint) fu_struct_acpi_phat_version_record_get_record_count(st));
669
0
    if (str->len > 0)
670
0
        g_string_set_size(str, str->len - 1);
671
0
    return g_string_free(g_steal_pointer(&str), FALSE);
672
0
}
673
static gboolean
674
fu_struct_acpi_phat_version_record_validate_internal(FuStructAcpiPhatVersionRecord *st, GError **error)
675
21.9k
{
676
21.9k
    g_return_val_if_fail(st != NULL, FALSE);
677
21.9k
    return TRUE;
678
21.9k
}
679
static gboolean
680
fu_struct_acpi_phat_version_record_parse_internal(FuStructAcpiPhatVersionRecord *st, GError **error)
681
21.9k
{
682
21.9k
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
683
0
        g_autofree gchar *str = fu_struct_acpi_phat_version_record_to_string(st);
684
0
        g_debug("%s", str);
685
0
    }
686
21.9k
    if (!fu_struct_acpi_phat_version_record_validate_internal(st, error))
687
0
        return FALSE;
688
21.9k
    return TRUE;
689
21.9k
}
690
/**
691
 * fu_struct_acpi_phat_version_record_parse_stream: (skip):
692
 **/
693
FuStructAcpiPhatVersionRecord *
694
fu_struct_acpi_phat_version_record_parse_stream(GInputStream *stream, gsize offset, GError **error)
695
22.0k
{
696
22.0k
    g_autoptr(FuStructAcpiPhatVersionRecord) st = fu_struct_acpi_phat_version_record_new_internal();
697
22.0k
    st->buf = fu_input_stream_read_byte_array(stream, offset, 12, NULL, error);
698
22.0k
    if (st->buf == NULL) {
699
0
        g_prefix_error(error, "FuStructAcpiPhatVersionRecord failed read of 0x%x: ", (guint) 12);
700
0
        return NULL;
701
0
    }
702
22.0k
    if (st->buf->len != 12) {
703
40
        g_set_error(error,
704
40
                    FWUPD_ERROR,
705
40
                    FWUPD_ERROR_INVALID_DATA,
706
40
                    "FuStructAcpiPhatVersionRecord requested 0x%x and got 0x%x",
707
40
                    (guint) 12,
708
40
                    (guint) st->buf->len);
709
40
        return NULL;
710
40
    }
711
21.9k
    if (!fu_struct_acpi_phat_version_record_parse_internal(st, error))
712
0
        return NULL;
713
21.9k
    return g_steal_pointer(&st);
714
21.9k
}