Coverage Report

Created: 2026-07-30 07:09

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