Coverage Report

Created: 2025-11-11 06:44

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