Coverage Report

Created: 2026-06-15 06:54

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.08k
{
37
1.08k
    g_return_if_fail(st != NULL);
38
1.08k
    if (st->refcount == 0) {
39
0
        g_critical("FuStructAcpiPhatHdr refcount already zero");
40
0
        return;
41
0
    }
42
1.08k
    if (--st->refcount > 0)
43
0
        return;
44
1.08k
    if (st->buf != NULL)
45
1.08k
        g_byte_array_unref(st->buf);
46
1.08k
    g_free(st);
47
1.08k
}
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.08k
{
54
1.08k
    FuStructAcpiPhatHdr *st = g_new0(FuStructAcpiPhatHdr, 1);
55
1.08k
    st->refcount = 1;
56
1.08k
    return st;
57
1.08k
}
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.07k
{
74
1.07k
    g_return_val_if_fail(st != NULL, FALSE);
75
1.07k
    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.03k
    return TRUE;
86
1.07k
}
87
/**
88
 * fu_struct_acpi_phat_hdr_validate_stream: (skip):
89
 **/
90
gboolean
91
fu_struct_acpi_phat_hdr_validate_stream(GInputStream *stream, gsize offset, GError **error)
92
1.08k
{
93
1.08k
    g_autoptr(FuStructAcpiPhatHdr) st = fu_struct_acpi_phat_hdr_new_internal();
94
1.08k
    g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE);
95
1.08k
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
96
1.08k
    st->buf = fu_input_stream_read_byte_array(stream, offset, 4, NULL, error);
97
1.08k
    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.08k
    if (st->buf->len != 4) {
102
6
        g_set_error(error,
103
6
                    FWUPD_ERROR,
104
6
                    FWUPD_ERROR_INVALID_DATA,
105
6
                    "FuStructAcpiPhatHdr requested 0x%x and got 0x%x",
106
6
                    (guint) 4,
107
6
                    (guint) st->buf->len);
108
6
        return FALSE;
109
6
    }
110
1.07k
    return fu_struct_acpi_phat_hdr_validate_internal(st, error);
111
1.08k
}
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.25k
{
128
2.25k
    g_return_if_fail(st != NULL);
129
2.25k
    if (st->refcount == 0) {
130
0
        g_critical("FuStructAcpiPhatHealthRecord refcount already zero");
131
0
        return;
132
0
    }
133
2.25k
    if (--st->refcount > 0)
134
0
        return;
135
2.25k
    if (st->buf != NULL)
136
1.28k
        g_byte_array_unref(st->buf);
137
2.25k
    g_free(st);
138
2.25k
}
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.25k
{
145
2.25k
    FuStructAcpiPhatHealthRecord *st = g_new0(FuStructAcpiPhatHealthRecord, 1);
146
2.25k
    st->refcount = 1;
147
2.25k
    return st;
148
2.25k
}
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.26k
{
166
1.26k
    g_return_val_if_fail(st != NULL, 0x0);
167
1.26k
    return fu_memread_uint16(st->buf->data + 2, G_LITTLE_ENDIAN);
168
1.26k
}
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.26k
{
184
1.26k
    g_return_val_if_fail(st != NULL, 0x0);
185
1.26k
    return st->buf->data[7];
186
1.26k
}
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.26k
{
193
1.26k
    g_return_val_if_fail(st != NULL, NULL);
194
1.26k
    return (const fwupd_guid_t *) (st->buf->data + 8);
195
1.26k
}
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.26k
{
202
1.26k
    g_return_val_if_fail(st != NULL, 0x0);
203
1.26k
    return fu_memread_uint32(st->buf->data + 24, G_LITTLE_ENDIAN);
204
1.26k
}
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
969
{
213
969
    g_return_if_fail(st != NULL);
214
969
    fu_memwrite_uint16(st->buf->data + 0, value, G_LITTLE_ENDIAN);
215
969
}
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
969
{
222
969
    g_return_if_fail(st != NULL);
223
969
    fu_memwrite_uint16(st->buf->data + 2, value, G_LITTLE_ENDIAN);
224
969
}
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
969
{
231
969
    g_return_if_fail(st != NULL);
232
969
    st->buf->data[4] = value;
233
969
}
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
969
{
240
969
    g_return_if_fail(st != NULL);
241
969
    st->buf->data[7] = value;
242
969
}
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
969
{
249
969
    g_return_if_fail(st != NULL);
250
969
    g_return_if_fail(value != NULL);
251
969
    memcpy(st->buf->data + 8, value, sizeof(*value)); /* nocheck:blocked */
252
969
}
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
969
{
268
969
    FuStructAcpiPhatHealthRecord *st = fu_struct_acpi_phat_health_record_new_internal();
269
969
    st->buf = g_byte_array_sized_new(28);
270
969
    fu_byte_array_set_size(st->buf, 28, 0x0);
271
969
    fu_struct_acpi_phat_health_record_set_signature(st, 0x1);
272
969
    return st;
273
969
}
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.26k
{
303
1.26k
    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.26k
    return TRUE;
308
1.26k
}
309
/**
310
 * fu_struct_acpi_phat_health_record_parse_stream: (skip):
311
 **/
312
FuStructAcpiPhatHealthRecord *
313
fu_struct_acpi_phat_health_record_parse_stream(GInputStream *stream, gsize offset, GError **error)
314
1.28k
{
315
1.28k
    g_autoptr(FuStructAcpiPhatHealthRecord) st = fu_struct_acpi_phat_health_record_new_internal();
316
1.28k
    st->buf = fu_input_stream_read_byte_array(stream, offset, 28, NULL, error);
317
1.28k
    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.28k
    if (st->buf->len != 28) {
322
18
        g_set_error(error,
323
18
                    FWUPD_ERROR,
324
18
                    FWUPD_ERROR_INVALID_DATA,
325
18
                    "FuStructAcpiPhatHealthRecord requested 0x%x and got 0x%x",
326
18
                    (guint) 28,
327
18
                    (guint) st->buf->len);
328
18
        return NULL;
329
18
    }
330
1.26k
    if (!fu_struct_acpi_phat_health_record_parse_internal(st, error))
331
0
        return NULL;
332
1.26k
    return g_steal_pointer(&st);
333
1.26k
}
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
20.8k
{
350
20.8k
    g_return_if_fail(st != NULL);
351
20.8k
    if (st->refcount == 0) {
352
0
        g_critical("FuStructAcpiPhatVersionElement refcount already zero");
353
0
        return;
354
0
    }
355
20.8k
    if (--st->refcount > 0)
356
0
        return;
357
20.8k
    if (st->buf != NULL)
358
18.3k
        g_byte_array_unref(st->buf);
359
20.8k
    g_free(st);
360
20.8k
}
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
20.8k
{
367
20.8k
    FuStructAcpiPhatVersionElement *st = g_new0(FuStructAcpiPhatVersionElement, 1);
368
20.8k
    st->refcount = 1;
369
20.8k
    return st;
370
20.8k
}
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
18.3k
{
379
18.3k
    g_return_val_if_fail(st != NULL, NULL);
380
18.3k
    return (const fwupd_guid_t *) (st->buf->data + 0);
381
18.3k
}
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
18.3k
{
388
18.3k
    g_return_val_if_fail(st != NULL, 0x0);
389
18.3k
    return fu_memread_uint64(st->buf->data + 16, G_LITTLE_ENDIAN);
390
18.3k
}
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
18.3k
{
397
18.3k
    g_return_val_if_fail(st != NULL, NULL);
398
18.3k
    return fu_memstrsafe(st->buf->data, st->buf->len, 24, 4, NULL);
399
18.3k
}
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.51k
{
408
2.51k
    g_return_if_fail(st != NULL);
409
2.51k
    g_return_if_fail(value != NULL);
410
2.51k
    memcpy(st->buf->data + 0, value, sizeof(*value)); /* nocheck:blocked */
411
2.51k
}
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.51k
{
418
2.51k
    g_return_if_fail(st != NULL);
419
2.51k
    fu_memwrite_uint64(st->buf->data + 16, value, G_LITTLE_ENDIAN);
420
2.51k
}
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.51k
{
427
2.51k
    gsize len;
428
2.51k
    g_return_val_if_fail(st != NULL, FALSE);
429
2.51k
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
430
2.51k
    if (value == NULL) {
431
1.28k
        memset(st->buf->data + 24, 0x0, 4);
432
1.28k
        return TRUE;
433
1.28k
    }
434
1.22k
    len = strlen(value);
435
1.22k
    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.22k
    return fu_memcpy_safe(st->buf->data, st->buf->len, 24, (const guint8 *)value, len, 0x0, len, error);
444
1.22k
}
445
/**
446
 * fu_struct_acpi_phat_version_element_new: (skip):
447
 **/
448
FuStructAcpiPhatVersionElement *
449
fu_struct_acpi_phat_version_element_new(void)
450
2.51k
{
451
2.51k
    FuStructAcpiPhatVersionElement *st = fu_struct_acpi_phat_version_element_new_internal();
452
2.51k
    st->buf = g_byte_array_sized_new(28);
453
2.51k
    fu_byte_array_set_size(st->buf, 28, 0x0);
454
2.51k
    return st;
455
2.51k
}
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
18.3k
{
482
18.3k
    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
18.3k
    return TRUE;
487
18.3k
}
488
/**
489
 * fu_struct_acpi_phat_version_element_parse_stream: (skip):
490
 **/
491
FuStructAcpiPhatVersionElement *
492
fu_struct_acpi_phat_version_element_parse_stream(GInputStream *stream, gsize offset, GError **error)
493
18.3k
{
494
18.3k
    g_autoptr(FuStructAcpiPhatVersionElement) st = fu_struct_acpi_phat_version_element_new_internal();
495
18.3k
    st->buf = fu_input_stream_read_byte_array(stream, offset, 28, NULL, error);
496
18.3k
    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
18.3k
    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
18.3k
    if (!fu_struct_acpi_phat_version_element_parse_internal(st, error))
510
0
        return NULL;
511
18.3k
    return g_steal_pointer(&st);
512
18.3k
}
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
21.7k
{
529
21.7k
    g_return_if_fail(st != NULL);
530
21.7k
    if (st->refcount == 0) {
531
0
        g_critical("FuStructAcpiPhatVersionRecord refcount already zero");
532
0
        return;
533
0
    }
534
21.7k
    if (--st->refcount > 0)
535
0
        return;
536
21.7k
    if (st->buf != NULL)
537
15.1k
        g_byte_array_unref(st->buf);
538
21.7k
    g_free(st);
539
21.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
21.7k
{
546
21.7k
    FuStructAcpiPhatVersionRecord *st = g_new0(FuStructAcpiPhatVersionRecord, 1);
547
21.7k
    st->refcount = 1;
548
21.7k
    return st;
549
21.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
15.1k
{
585
15.1k
    g_return_val_if_fail(st != NULL, 0x0);
586
15.1k
    return fu_memread_uint32(st->buf->data + 8, G_LITTLE_ENDIAN);
587
15.1k
}
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
6.56k
{
596
6.56k
    g_return_if_fail(st != NULL);
597
6.56k
    fu_memwrite_uint16(st->buf->data + 0, value, G_LITTLE_ENDIAN);
598
6.56k
}
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
6.56k
{
605
6.56k
    g_return_if_fail(st != NULL);
606
6.56k
    fu_memwrite_uint16(st->buf->data + 2, value, G_LITTLE_ENDIAN);
607
6.56k
}
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
6.56k
{
614
6.56k
    g_return_if_fail(st != NULL);
615
6.56k
    st->buf->data[4] = value;
616
6.56k
}
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
6.56k
{
623
6.56k
    g_return_if_fail(st != NULL);
624
6.56k
    fu_memwrite_uint32(st->buf->data + 8, value, G_LITTLE_ENDIAN);
625
6.56k
}
626
/**
627
 * fu_struct_acpi_phat_version_record_new: (skip):
628
 **/
629
FuStructAcpiPhatVersionRecord *
630
fu_struct_acpi_phat_version_record_new(void)
631
6.56k
{
632
6.56k
    FuStructAcpiPhatVersionRecord *st = fu_struct_acpi_phat_version_record_new_internal();
633
6.56k
    st->buf = g_byte_array_sized_new(12);
634
6.56k
    fu_byte_array_set_size(st->buf, 12, 0x0);
635
6.56k
    fu_struct_acpi_phat_version_record_set_signature(st, 0x0);
636
6.56k
    return st;
637
6.56k
}
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
15.1k
{
661
15.1k
    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
15.1k
    return TRUE;
666
15.1k
}
667
/**
668
 * fu_struct_acpi_phat_version_record_parse_stream: (skip):
669
 **/
670
FuStructAcpiPhatVersionRecord *
671
fu_struct_acpi_phat_version_record_parse_stream(GInputStream *stream, gsize offset, GError **error)
672
15.1k
{
673
15.1k
    g_autoptr(FuStructAcpiPhatVersionRecord) st = fu_struct_acpi_phat_version_record_new_internal();
674
15.1k
    st->buf = fu_input_stream_read_byte_array(stream, offset, 12, NULL, error);
675
15.1k
    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
15.1k
    if (st->buf->len != 12) {
680
21
        g_set_error(error,
681
21
                    FWUPD_ERROR,
682
21
                    FWUPD_ERROR_INVALID_DATA,
683
21
                    "FuStructAcpiPhatVersionRecord requested 0x%x and got 0x%x",
684
21
                    (guint) 12,
685
21
                    (guint) st->buf->len);
686
21
        return NULL;
687
21
    }
688
15.1k
    if (!fu_struct_acpi_phat_version_record_parse_internal(st, error))
689
0
        return NULL;
690
15.1k
    return g_steal_pointer(&st);
691
15.1k
}