Coverage Report

Created: 2025-11-24 06:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/fu-cros-ec-struct.c
Line
Count
Source
1
/* auto-generated, do not modify */
2
#include "config.h"
3
4
#include <glib.h>
5
6
#include "fu-cros-ec-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
17
18
/**
19
 * fu_struct_cros_ec_update_frame_header_ref: (skip):
20
 **/
21
FuStructCrosEcUpdateFrameHeader *
22
fu_struct_cros_ec_update_frame_header_ref(FuStructCrosEcUpdateFrameHeader *st)
23
0
{
24
0
    g_return_val_if_fail(st != NULL, NULL);
25
0
    st->refcount++;
26
0
    return st;
27
0
}
28
/**
29
 * fu_struct_cros_ec_update_frame_header_unref: (skip):
30
 **/
31
void
32
fu_struct_cros_ec_update_frame_header_unref(FuStructCrosEcUpdateFrameHeader *st)
33
0
{
34
0
    g_return_if_fail(st != NULL);
35
0
    if (st->refcount == 0) {
36
0
        g_critical("FuStructCrosEcUpdateFrameHeader refcount already zero");
37
0
        return;
38
0
    }
39
0
    if (--st->refcount > 0)
40
0
        return;
41
0
    if (st->buf != NULL)
42
0
        g_byte_array_unref(st->buf);
43
0
    g_free(st);
44
0
}
45
/**
46
 * fu_struct_cros_ec_update_frame_header_new_internal: (skip):
47
 **/
48
static FuStructCrosEcUpdateFrameHeader *
49
fu_struct_cros_ec_update_frame_header_new_internal(void)
50
0
{
51
0
    FuStructCrosEcUpdateFrameHeader *st = g_new0(FuStructCrosEcUpdateFrameHeader, 1);
52
0
    st->refcount = 1;
53
0
    return st;
54
0
}
55
56
/* getters */
57
58
/* setters */
59
/**
60
 * fu_struct_cros_ec_update_frame_header_set_block_size: (skip):
61
 **/
62
void
63
fu_struct_cros_ec_update_frame_header_set_block_size(FuStructCrosEcUpdateFrameHeader *st, guint32 value)
64
0
{
65
0
    g_return_if_fail(st != NULL);
66
0
    fu_memwrite_uint32(st->buf->data + 0, value, G_BIG_ENDIAN);
67
0
}
68
/**
69
 * fu_struct_cros_ec_update_frame_header_set_cmd_block_digest: (skip):
70
 **/
71
void
72
fu_struct_cros_ec_update_frame_header_set_cmd_block_digest(FuStructCrosEcUpdateFrameHeader *st, guint32 value)
73
0
{
74
0
    g_return_if_fail(st != NULL);
75
0
    fu_memwrite_uint32(st->buf->data + 4, value, G_BIG_ENDIAN);
76
0
}
77
/**
78
 * fu_struct_cros_ec_update_frame_header_set_cmd_block_base: (skip):
79
 **/
80
void
81
fu_struct_cros_ec_update_frame_header_set_cmd_block_base(FuStructCrosEcUpdateFrameHeader *st, guint32 value)
82
0
{
83
0
    g_return_if_fail(st != NULL);
84
0
    fu_memwrite_uint32(st->buf->data + 8, value, G_BIG_ENDIAN);
85
0
}
86
/**
87
 * fu_struct_cros_ec_update_frame_header_new: (skip):
88
 **/
89
FuStructCrosEcUpdateFrameHeader *
90
fu_struct_cros_ec_update_frame_header_new(void)
91
0
{
92
0
    FuStructCrosEcUpdateFrameHeader *st = fu_struct_cros_ec_update_frame_header_new_internal();
93
0
    st->buf = g_byte_array_sized_new(12);
94
0
    fu_byte_array_set_size(st->buf, 12, 0x0);
95
0
    return st;
96
0
}
97
/**
98
 * fu_struct_cros_ec_update_done_ref: (skip):
99
 **/
100
FuStructCrosEcUpdateDone *
101
fu_struct_cros_ec_update_done_ref(FuStructCrosEcUpdateDone *st)
102
0
{
103
0
    g_return_val_if_fail(st != NULL, NULL);
104
0
    st->refcount++;
105
0
    return st;
106
0
}
107
/**
108
 * fu_struct_cros_ec_update_done_unref: (skip):
109
 **/
110
void
111
fu_struct_cros_ec_update_done_unref(FuStructCrosEcUpdateDone *st)
112
0
{
113
0
    g_return_if_fail(st != NULL);
114
0
    if (st->refcount == 0) {
115
0
        g_critical("FuStructCrosEcUpdateDone refcount already zero");
116
0
        return;
117
0
    }
118
0
    if (--st->refcount > 0)
119
0
        return;
120
0
    if (st->buf != NULL)
121
0
        g_byte_array_unref(st->buf);
122
0
    g_free(st);
123
0
}
124
/**
125
 * fu_struct_cros_ec_update_done_new_internal: (skip):
126
 **/
127
static FuStructCrosEcUpdateDone *
128
fu_struct_cros_ec_update_done_new_internal(void)
129
0
{
130
0
    FuStructCrosEcUpdateDone *st = g_new0(FuStructCrosEcUpdateDone, 1);
131
0
    st->refcount = 1;
132
0
    return st;
133
0
}
134
135
/* getters */
136
137
/* setters */
138
/**
139
 * fu_struct_cros_ec_update_done_set_value: (skip):
140
 **/
141
static void
142
fu_struct_cros_ec_update_done_set_value(FuStructCrosEcUpdateDone *st, guint32 value)
143
0
{
144
0
    g_return_if_fail(st != NULL);
145
0
    fu_memwrite_uint32(st->buf->data + 0, value, G_BIG_ENDIAN);
146
0
}
147
/**
148
 * fu_struct_cros_ec_update_done_new: (skip):
149
 **/
150
FuStructCrosEcUpdateDone *
151
fu_struct_cros_ec_update_done_new(void)
152
0
{
153
0
    FuStructCrosEcUpdateDone *st = fu_struct_cros_ec_update_done_new_internal();
154
0
    st->buf = g_byte_array_sized_new(4);
155
0
    fu_byte_array_set_size(st->buf, 4, 0x0);
156
0
    fu_struct_cros_ec_update_done_set_value(st, 0xB007AB1E);
157
0
    return st;
158
0
}
159
/**
160
 * fu_struct_cros_ec_signed_header_version_ref: (skip):
161
 **/
162
FuStructCrosEcSignedHeaderVersion *
163
fu_struct_cros_ec_signed_header_version_ref(FuStructCrosEcSignedHeaderVersion *st)
164
0
{
165
0
    g_return_val_if_fail(st != NULL, NULL);
166
0
    st->refcount++;
167
0
    return st;
168
0
}
169
/**
170
 * fu_struct_cros_ec_signed_header_version_unref: (skip):
171
 **/
172
void
173
fu_struct_cros_ec_signed_header_version_unref(FuStructCrosEcSignedHeaderVersion *st)
174
0
{
175
0
    g_return_if_fail(st != NULL);
176
0
    if (st->refcount == 0) {
177
0
        g_critical("FuStructCrosEcSignedHeaderVersion refcount already zero");
178
0
        return;
179
0
    }
180
0
    if (--st->refcount > 0)
181
0
        return;
182
0
    if (st->buf != NULL)
183
0
        g_byte_array_unref(st->buf);
184
0
    g_free(st);
185
0
}
186
187
/* getters */
188
189
/* setters */
190
/**
191
 * fu_struct_cros_ec_first_response_pdu_ref: (skip):
192
 **/
193
FuStructCrosEcFirstResponsePdu *
194
fu_struct_cros_ec_first_response_pdu_ref(FuStructCrosEcFirstResponsePdu *st)
195
0
{
196
0
    g_return_val_if_fail(st != NULL, NULL);
197
0
    st->refcount++;
198
0
    return st;
199
0
}
200
/**
201
 * fu_struct_cros_ec_first_response_pdu_unref: (skip):
202
 **/
203
void
204
fu_struct_cros_ec_first_response_pdu_unref(FuStructCrosEcFirstResponsePdu *st)
205
0
{
206
0
    g_return_if_fail(st != NULL);
207
0
    if (st->refcount == 0) {
208
0
        g_critical("FuStructCrosEcFirstResponsePdu refcount already zero");
209
0
        return;
210
0
    }
211
0
    if (--st->refcount > 0)
212
0
        return;
213
0
    if (st->buf != NULL)
214
0
        g_byte_array_unref(st->buf);
215
0
    g_free(st);
216
0
}
217
/**
218
 * fu_struct_cros_ec_first_response_pdu_new_internal: (skip):
219
 **/
220
static FuStructCrosEcFirstResponsePdu *
221
fu_struct_cros_ec_first_response_pdu_new_internal(void)
222
0
{
223
0
    FuStructCrosEcFirstResponsePdu *st = g_new0(FuStructCrosEcFirstResponsePdu, 1);
224
0
    st->refcount = 1;
225
0
    return st;
226
0
}
227
228
/* getters */
229
/**
230
 * fu_struct_cros_ec_first_response_pdu_get_return_value: (skip):
231
 **/
232
guint32
233
fu_struct_cros_ec_first_response_pdu_get_return_value(const FuStructCrosEcFirstResponsePdu *st)
234
0
{
235
0
    g_return_val_if_fail(st != NULL, 0x0);
236
0
    return fu_memread_uint32(st->buf->data + 0, G_BIG_ENDIAN);
237
0
}
238
/**
239
 * fu_struct_cros_ec_first_response_pdu_get_header_type: (skip):
240
 **/
241
FuStructCrosEcFirstResponsePduHeaderType
242
fu_struct_cros_ec_first_response_pdu_get_header_type(const FuStructCrosEcFirstResponsePdu *st)
243
0
{
244
0
    g_return_val_if_fail(st != NULL, 0x0);
245
0
    return fu_memread_uint16(st->buf->data + 4, G_BIG_ENDIAN);
246
0
}
247
/**
248
 * fu_struct_cros_ec_first_response_pdu_get_protocol_version: (skip):
249
 **/
250
guint16
251
fu_struct_cros_ec_first_response_pdu_get_protocol_version(const FuStructCrosEcFirstResponsePdu *st)
252
0
{
253
0
    g_return_val_if_fail(st != NULL, 0x0);
254
0
    return fu_memread_uint16(st->buf->data + 6, G_BIG_ENDIAN);
255
0
}
256
/**
257
 * fu_struct_cros_ec_first_response_pdu_get_maximum_pdu_size: (skip):
258
 **/
259
guint32
260
fu_struct_cros_ec_first_response_pdu_get_maximum_pdu_size(const FuStructCrosEcFirstResponsePdu *st)
261
0
{
262
0
    g_return_val_if_fail(st != NULL, 0x0);
263
0
    return fu_memread_uint32(st->buf->data + 8, G_BIG_ENDIAN);
264
0
}
265
/**
266
 * fu_struct_cros_ec_first_response_pdu_get_flash_protection: (skip):
267
 **/
268
guint32
269
fu_struct_cros_ec_first_response_pdu_get_flash_protection(const FuStructCrosEcFirstResponsePdu *st)
270
0
{
271
0
    g_return_val_if_fail(st != NULL, 0x0);
272
0
    return fu_memread_uint32(st->buf->data + 12, G_BIG_ENDIAN);
273
0
}
274
/**
275
 * fu_struct_cros_ec_first_response_pdu_get_offset: (skip):
276
 **/
277
guint32
278
fu_struct_cros_ec_first_response_pdu_get_offset(const FuStructCrosEcFirstResponsePdu *st)
279
0
{
280
0
    g_return_val_if_fail(st != NULL, 0x0);
281
0
    return fu_memread_uint32(st->buf->data + 16, G_BIG_ENDIAN);
282
0
}
283
/**
284
 * fu_struct_cros_ec_first_response_pdu_get_version: (skip):
285
 **/
286
gchar *
287
fu_struct_cros_ec_first_response_pdu_get_version(const FuStructCrosEcFirstResponsePdu *st)
288
0
{
289
0
    g_return_val_if_fail(st != NULL, NULL);
290
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 20, 32, NULL);
291
0
}
292
293
/* setters */
294
/**
295
 * fu_struct_cros_ec_first_response_pdu_set_return_value: (skip):
296
 **/
297
void
298
fu_struct_cros_ec_first_response_pdu_set_return_value(FuStructCrosEcFirstResponsePdu *st, guint32 value)
299
0
{
300
0
    g_return_if_fail(st != NULL);
301
0
    fu_memwrite_uint32(st->buf->data + 0, value, G_BIG_ENDIAN);
302
0
}
303
/**
304
 * fu_struct_cros_ec_first_response_pdu_set_header_type: (skip):
305
 **/
306
void
307
fu_struct_cros_ec_first_response_pdu_set_header_type(FuStructCrosEcFirstResponsePdu *st, FuStructCrosEcFirstResponsePduHeaderType value)
308
0
{
309
0
    g_return_if_fail(st != NULL);
310
0
    fu_memwrite_uint16(st->buf->data + 4, value, G_BIG_ENDIAN);
311
0
}
312
/**
313
 * fu_struct_cros_ec_first_response_pdu_set_protocol_version: (skip):
314
 **/
315
void
316
fu_struct_cros_ec_first_response_pdu_set_protocol_version(FuStructCrosEcFirstResponsePdu *st, guint16 value)
317
0
{
318
0
    g_return_if_fail(st != NULL);
319
0
    fu_memwrite_uint16(st->buf->data + 6, value, G_BIG_ENDIAN);
320
0
}
321
/**
322
 * fu_struct_cros_ec_first_response_pdu_set_maximum_pdu_size: (skip):
323
 **/
324
void
325
fu_struct_cros_ec_first_response_pdu_set_maximum_pdu_size(FuStructCrosEcFirstResponsePdu *st, guint32 value)
326
0
{
327
0
    g_return_if_fail(st != NULL);
328
0
    fu_memwrite_uint32(st->buf->data + 8, value, G_BIG_ENDIAN);
329
0
}
330
/**
331
 * fu_struct_cros_ec_first_response_pdu_set_flash_protection: (skip):
332
 **/
333
void
334
fu_struct_cros_ec_first_response_pdu_set_flash_protection(FuStructCrosEcFirstResponsePdu *st, guint32 value)
335
0
{
336
0
    g_return_if_fail(st != NULL);
337
0
    fu_memwrite_uint32(st->buf->data + 12, value, G_BIG_ENDIAN);
338
0
}
339
/**
340
 * fu_struct_cros_ec_first_response_pdu_set_offset: (skip):
341
 **/
342
void
343
fu_struct_cros_ec_first_response_pdu_set_offset(FuStructCrosEcFirstResponsePdu *st, guint32 value)
344
0
{
345
0
    g_return_if_fail(st != NULL);
346
0
    fu_memwrite_uint32(st->buf->data + 16, value, G_BIG_ENDIAN);
347
0
}
348
/**
349
 * fu_struct_cros_ec_first_response_pdu_set_version: (skip):
350
 **/
351
gboolean
352
fu_struct_cros_ec_first_response_pdu_set_version(FuStructCrosEcFirstResponsePdu *st, const gchar *value, GError **error)
353
0
{
354
0
    gsize len;
355
0
    g_return_val_if_fail(st != NULL, FALSE);
356
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
357
0
    if (value == NULL) {
358
0
        memset(st->buf->data + 20, 0x0, 32);
359
0
        return TRUE;
360
0
    }
361
0
    len = strlen(value);
362
0
    if (len > 32) {
363
0
        g_set_error(error,
364
0
                    FWUPD_ERROR,
365
0
                    FWUPD_ERROR_INVALID_DATA,
366
0
                    "string '%s' (0x%x bytes) does not fit in FuStructCrosEcFirstResponsePdu.version (0x%x bytes)",
367
0
                    value, (guint) len, (guint) 32);
368
0
        return FALSE;
369
0
    }
370
0
    return fu_memcpy_safe(st->buf->data, st->buf->len, 20, (const guint8 *)value, len, 0x0, len, error);
371
0
}
372
/**
373
 * fu_struct_cros_ec_first_response_pdu_new: (skip):
374
 **/
375
FuStructCrosEcFirstResponsePdu *
376
fu_struct_cros_ec_first_response_pdu_new(void)
377
0
{
378
0
    FuStructCrosEcFirstResponsePdu *st = fu_struct_cros_ec_first_response_pdu_new_internal();
379
0
    st->buf = g_byte_array_sized_new(60);
380
0
    fu_byte_array_set_size(st->buf, 60, 0x0);
381
0
    return st;
382
0
}