/work/fu-synaprom-struct.c
Line | Count | Source |
1 | | /* auto-generated, do not modify */ |
2 | | #include "config.h" |
3 | | |
4 | | #include <glib.h> |
5 | | |
6 | | #include "fu-synaprom-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 | | static const gchar * |
18 | | fu_synaprom_product_to_string(FuSynapromProduct val) |
19 | 0 | { |
20 | 0 | if (val == FU_SYNAPROM_PRODUCT_PROMETHEUS) |
21 | 0 | return "prometheus"; |
22 | 0 | if (val == FU_SYNAPROM_PRODUCT_PROMETHEUSPBL) |
23 | 0 | return "prometheuspbl"; |
24 | 0 | if (val == FU_SYNAPROM_PRODUCT_PROMETHEUSMSBL) |
25 | 0 | return "prometheusmsbl"; |
26 | 0 | if (val == FU_SYNAPROM_PRODUCT_TRITON) |
27 | 0 | return "triton"; |
28 | 0 | if (val == FU_SYNAPROM_PRODUCT_TRITONPBL) |
29 | 0 | return "tritonpbl"; |
30 | 0 | if (val == FU_SYNAPROM_PRODUCT_TRITONMSBL) |
31 | 0 | return "tritonmsbl"; |
32 | 0 | return NULL; |
33 | 0 | } |
34 | | |
35 | | const gchar * |
36 | | fu_synaprom_result_to_string(FuSynapromResult val) |
37 | 0 | { |
38 | 0 | if (val == FU_SYNAPROM_RESULT_OK) |
39 | 0 | return "ok"; |
40 | 0 | if (val == FU_SYNAPROM_RESULT_GEN_OPERATION_CANCELED) |
41 | 0 | return "gen-operation-canceled"; |
42 | 0 | if (val == FU_SYNAPROM_RESULT_GEN_INVALID) |
43 | 0 | return "gen-invalid"; |
44 | 0 | if (val == FU_SYNAPROM_RESULT_GEN_BAD_PARAM) |
45 | 0 | return "gen-bad-param"; |
46 | 0 | if (val == FU_SYNAPROM_RESULT_GEN_NULL_POINTER) |
47 | 0 | return "gen-null-pointer"; |
48 | 0 | if (val == FU_SYNAPROM_RESULT_GEN_UNEXPECTED_FORMAT) |
49 | 0 | return "gen-unexpected-format"; |
50 | 0 | if (val == FU_SYNAPROM_RESULT_GEN_TIMEOUT) |
51 | 0 | return "gen-timeout"; |
52 | 0 | if (val == FU_SYNAPROM_RESULT_GEN_OBJECT_DOESNT_EXIST) |
53 | 0 | return "gen-object-doesnt-exist"; |
54 | 0 | if (val == FU_SYNAPROM_RESULT_GEN_ERROR) |
55 | 0 | return "gen-error"; |
56 | 0 | if (val == FU_SYNAPROM_RESULT_SENSOR_MALFUNCTIONED) |
57 | 0 | return "sensor-malfunctioned"; |
58 | 0 | if (val == FU_SYNAPROM_RESULT_SYS_OUT_OF_MEMORY) |
59 | 0 | return "sys-out-of-memory"; |
60 | 0 | return NULL; |
61 | 0 | } |
62 | | |
63 | | |
64 | | const gchar * |
65 | | fu_synaprom_firmware_tag_to_string(FuSynapromFirmwareTag val) |
66 | 4.44k | { |
67 | 4.44k | if (val == FU_SYNAPROM_FIRMWARE_TAG_MFW_UPDATE_HEADER) |
68 | 141 | return "mfw-update-header"; |
69 | 4.30k | if (val == FU_SYNAPROM_FIRMWARE_TAG_MFW_UPDATE_PAYLOAD) |
70 | 55 | return "mfw-update-payload"; |
71 | 4.25k | if (val == FU_SYNAPROM_FIRMWARE_TAG_CFG_UPDATE_HEADER) |
72 | 35 | return "cfg-update-header"; |
73 | 4.21k | if (val == FU_SYNAPROM_FIRMWARE_TAG_CFG_UPDATE_PAYLOAD) |
74 | 36 | return "cfg-update-payload"; |
75 | 4.18k | return NULL; |
76 | 4.21k | } |
77 | | /** |
78 | | * fu_struct_synaprom_request_ref: (skip): |
79 | | **/ |
80 | | FuStructSynapromRequest * |
81 | | fu_struct_synaprom_request_ref(FuStructSynapromRequest *st) |
82 | 0 | { |
83 | 0 | g_return_val_if_fail(st != NULL, NULL); |
84 | 0 | st->refcount++; |
85 | 0 | return st; |
86 | 0 | } |
87 | | /** |
88 | | * fu_struct_synaprom_request_unref: (skip): |
89 | | **/ |
90 | | void |
91 | | fu_struct_synaprom_request_unref(FuStructSynapromRequest *st) |
92 | 0 | { |
93 | 0 | g_return_if_fail(st != NULL); |
94 | 0 | if (st->refcount == 0) { |
95 | 0 | g_critical("FuStructSynapromRequest refcount already zero"); |
96 | 0 | return; |
97 | 0 | } |
98 | 0 | if (--st->refcount > 0) |
99 | 0 | return; |
100 | 0 | if (st->buf != NULL) |
101 | 0 | g_byte_array_unref(st->buf); |
102 | 0 | g_free(st); |
103 | 0 | } |
104 | | static FuStructSynapromRequest * |
105 | | fu_struct_synaprom_request_new_internal(void) |
106 | 0 | { |
107 | 0 | FuStructSynapromRequest *st = g_new0(FuStructSynapromRequest, 1); |
108 | 0 | st->refcount = 1; |
109 | 0 | return st; |
110 | 0 | } |
111 | | |
112 | | /* getters */ |
113 | | |
114 | | /* setters */ |
115 | | /** |
116 | | * fu_struct_synaprom_request_set_cmd: (skip): |
117 | | **/ |
118 | | void |
119 | | fu_struct_synaprom_request_set_cmd(FuStructSynapromRequest *st, FuSynapromCmd value) |
120 | 0 | { |
121 | 0 | g_return_if_fail(st != NULL); |
122 | 0 | st->buf->data[0] = value; |
123 | 0 | } |
124 | | /** |
125 | | * fu_struct_synaprom_request_new: (skip): |
126 | | **/ |
127 | | FuStructSynapromRequest * |
128 | | fu_struct_synaprom_request_new(void) |
129 | 0 | { |
130 | 0 | FuStructSynapromRequest *st = fu_struct_synaprom_request_new_internal(); |
131 | 0 | st->buf = g_byte_array_sized_new(1); |
132 | 0 | fu_byte_array_set_size(st->buf, 1, 0x0); |
133 | 0 | return st; |
134 | 0 | } |
135 | | /** |
136 | | * fu_struct_synaprom_reply_generic_ref: (skip): |
137 | | **/ |
138 | | FuStructSynapromReplyGeneric * |
139 | | fu_struct_synaprom_reply_generic_ref(FuStructSynapromReplyGeneric *st) |
140 | 0 | { |
141 | 0 | g_return_val_if_fail(st != NULL, NULL); |
142 | 0 | st->refcount++; |
143 | 0 | return st; |
144 | 0 | } |
145 | | /** |
146 | | * fu_struct_synaprom_reply_generic_unref: (skip): |
147 | | **/ |
148 | | void |
149 | | fu_struct_synaprom_reply_generic_unref(FuStructSynapromReplyGeneric *st) |
150 | 0 | { |
151 | 0 | g_return_if_fail(st != NULL); |
152 | 0 | if (st->refcount == 0) { |
153 | 0 | g_critical("FuStructSynapromReplyGeneric refcount already zero"); |
154 | 0 | return; |
155 | 0 | } |
156 | 0 | if (--st->refcount > 0) |
157 | 0 | return; |
158 | 0 | if (st->buf != NULL) |
159 | 0 | g_byte_array_unref(st->buf); |
160 | 0 | g_free(st); |
161 | 0 | } |
162 | | static FuStructSynapromReplyGeneric * |
163 | | fu_struct_synaprom_reply_generic_new_internal(void) |
164 | 0 | { |
165 | 0 | FuStructSynapromReplyGeneric *st = g_new0(FuStructSynapromReplyGeneric, 1); |
166 | 0 | st->refcount = 1; |
167 | 0 | return st; |
168 | 0 | } |
169 | | |
170 | | /* getters */ |
171 | | /** |
172 | | * fu_struct_synaprom_reply_generic_get_status: (skip): |
173 | | **/ |
174 | | guint16 |
175 | | fu_struct_synaprom_reply_generic_get_status(const FuStructSynapromReplyGeneric *st) |
176 | 0 | { |
177 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
178 | 0 | return fu_memread_uint16(st->buf->data + 0, G_LITTLE_ENDIAN); |
179 | 0 | } |
180 | | |
181 | | /* setters */ |
182 | | /** |
183 | | * fu_struct_synaprom_reply_generic_to_string: (skip): |
184 | | **/ |
185 | | static gchar * |
186 | | fu_struct_synaprom_reply_generic_to_string(const FuStructSynapromReplyGeneric *st) |
187 | 0 | { |
188 | 0 | g_autoptr(GString) str = g_string_new("FuStructSynapromReplyGeneric:\n"); |
189 | 0 | g_return_val_if_fail(st != NULL, NULL); |
190 | 0 | g_string_append_printf(str, " status: 0x%x\n", |
191 | 0 | (guint) fu_struct_synaprom_reply_generic_get_status(st)); |
192 | 0 | if (str->len > 0) |
193 | 0 | g_string_set_size(str, str->len - 1); |
194 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
195 | 0 | } |
196 | | static gboolean |
197 | | fu_struct_synaprom_reply_generic_validate_internal(FuStructSynapromReplyGeneric *st, GError **error) |
198 | 0 | { |
199 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
200 | 0 | return TRUE; |
201 | 0 | } |
202 | | static gboolean |
203 | | fu_struct_synaprom_reply_generic_parse_internal(FuStructSynapromReplyGeneric *st, GError **error) |
204 | 0 | { |
205 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
206 | 0 | g_autofree gchar *str = fu_struct_synaprom_reply_generic_to_string(st); |
207 | 0 | g_debug("%s", str); |
208 | 0 | } |
209 | 0 | if (!fu_struct_synaprom_reply_generic_validate_internal(st, error)) |
210 | 0 | return FALSE; |
211 | 0 | return TRUE; |
212 | 0 | } |
213 | | |
214 | | /** |
215 | | * fu_struct_synaprom_reply_generic_parse: (skip): |
216 | | **/ |
217 | | FuStructSynapromReplyGeneric * |
218 | | fu_struct_synaprom_reply_generic_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
219 | 0 | { |
220 | 0 | g_autoptr(FuStructSynapromReplyGeneric) st = fu_struct_synaprom_reply_generic_new_internal(); |
221 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
222 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
223 | 0 | if (!fu_memchk_read(bufsz, offset, 2, error)) { |
224 | 0 | g_prefix_error_literal(error, "invalid struct FuStructSynapromReplyGeneric: "); |
225 | 0 | return NULL; |
226 | 0 | } |
227 | 0 | st->buf = g_byte_array_new(); |
228 | 0 | g_byte_array_append(st->buf, buf + offset, 2); |
229 | 0 | if (!fu_struct_synaprom_reply_generic_parse_internal(st, error)) |
230 | 0 | return NULL; |
231 | 0 | return g_steal_pointer(&st); |
232 | 0 | } |
233 | | /** |
234 | | * fu_struct_synaprom_reply_get_version_ref: (skip): |
235 | | **/ |
236 | | FuStructSynapromReplyGetVersion * |
237 | | fu_struct_synaprom_reply_get_version_ref(FuStructSynapromReplyGetVersion *st) |
238 | 0 | { |
239 | 0 | g_return_val_if_fail(st != NULL, NULL); |
240 | 0 | st->refcount++; |
241 | 0 | return st; |
242 | 0 | } |
243 | | /** |
244 | | * fu_struct_synaprom_reply_get_version_unref: (skip): |
245 | | **/ |
246 | | void |
247 | | fu_struct_synaprom_reply_get_version_unref(FuStructSynapromReplyGetVersion *st) |
248 | 0 | { |
249 | 0 | g_return_if_fail(st != NULL); |
250 | 0 | if (st->refcount == 0) { |
251 | 0 | g_critical("FuStructSynapromReplyGetVersion refcount already zero"); |
252 | 0 | return; |
253 | 0 | } |
254 | 0 | if (--st->refcount > 0) |
255 | 0 | return; |
256 | 0 | if (st->buf != NULL) |
257 | 0 | g_byte_array_unref(st->buf); |
258 | 0 | g_free(st); |
259 | 0 | } |
260 | | static FuStructSynapromReplyGetVersion * |
261 | | fu_struct_synaprom_reply_get_version_new_internal(void) |
262 | 0 | { |
263 | 0 | FuStructSynapromReplyGetVersion *st = g_new0(FuStructSynapromReplyGetVersion, 1); |
264 | 0 | st->refcount = 1; |
265 | 0 | return st; |
266 | 0 | } |
267 | | |
268 | | /* getters */ |
269 | | /** |
270 | | * fu_struct_synaprom_reply_get_version_get_status: (skip): |
271 | | **/ |
272 | | guint16 |
273 | | fu_struct_synaprom_reply_get_version_get_status(const FuStructSynapromReplyGetVersion *st) |
274 | 0 | { |
275 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
276 | 0 | return fu_memread_uint16(st->buf->data + 0, G_LITTLE_ENDIAN); |
277 | 0 | } |
278 | | /** |
279 | | * fu_struct_synaprom_reply_get_version_get_buildtime: (skip): |
280 | | **/ |
281 | | guint32 |
282 | | fu_struct_synaprom_reply_get_version_get_buildtime(const FuStructSynapromReplyGetVersion *st) |
283 | 0 | { |
284 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
285 | 0 | return fu_memread_uint32(st->buf->data + 2, G_LITTLE_ENDIAN); |
286 | 0 | } |
287 | | /** |
288 | | * fu_struct_synaprom_reply_get_version_get_buildnum: (skip): |
289 | | **/ |
290 | | guint32 |
291 | | fu_struct_synaprom_reply_get_version_get_buildnum(const FuStructSynapromReplyGetVersion *st) |
292 | 0 | { |
293 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
294 | 0 | return fu_memread_uint32(st->buf->data + 6, G_LITTLE_ENDIAN); |
295 | 0 | } |
296 | | /** |
297 | | * fu_struct_synaprom_reply_get_version_get_vmajor: (skip): |
298 | | **/ |
299 | | guint8 |
300 | | fu_struct_synaprom_reply_get_version_get_vmajor(const FuStructSynapromReplyGetVersion *st) |
301 | 0 | { |
302 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
303 | 0 | return st->buf->data[10]; |
304 | 0 | } |
305 | | /** |
306 | | * fu_struct_synaprom_reply_get_version_get_vminor: (skip): |
307 | | **/ |
308 | | guint8 |
309 | | fu_struct_synaprom_reply_get_version_get_vminor(const FuStructSynapromReplyGetVersion *st) |
310 | 0 | { |
311 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
312 | 0 | return st->buf->data[11]; |
313 | 0 | } |
314 | | /** |
315 | | * fu_struct_synaprom_reply_get_version_get_target: (skip): |
316 | | **/ |
317 | | guint8 |
318 | | fu_struct_synaprom_reply_get_version_get_target(const FuStructSynapromReplyGetVersion *st) |
319 | 0 | { |
320 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
321 | 0 | return st->buf->data[12]; |
322 | 0 | } |
323 | | /** |
324 | | * fu_struct_synaprom_reply_get_version_get_product: (skip): |
325 | | **/ |
326 | | FuSynapromProduct |
327 | | fu_struct_synaprom_reply_get_version_get_product(const FuStructSynapromReplyGetVersion *st) |
328 | 0 | { |
329 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
330 | 0 | return st->buf->data[13]; |
331 | 0 | } |
332 | | /** |
333 | | * fu_struct_synaprom_reply_get_version_get_siliconrev: (skip): |
334 | | **/ |
335 | | guint8 |
336 | | fu_struct_synaprom_reply_get_version_get_siliconrev(const FuStructSynapromReplyGetVersion *st) |
337 | 0 | { |
338 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
339 | 0 | return st->buf->data[14]; |
340 | 0 | } |
341 | | /** |
342 | | * fu_struct_synaprom_reply_get_version_get_formalrel: (skip): |
343 | | **/ |
344 | | guint8 |
345 | | fu_struct_synaprom_reply_get_version_get_formalrel(const FuStructSynapromReplyGetVersion *st) |
346 | 0 | { |
347 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
348 | 0 | return st->buf->data[15]; |
349 | 0 | } |
350 | | /** |
351 | | * fu_struct_synaprom_reply_get_version_get_platform: (skip): |
352 | | **/ |
353 | | guint8 |
354 | | fu_struct_synaprom_reply_get_version_get_platform(const FuStructSynapromReplyGetVersion *st) |
355 | 0 | { |
356 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
357 | 0 | return st->buf->data[16]; |
358 | 0 | } |
359 | | /** |
360 | | * fu_struct_synaprom_reply_get_version_get_patch: (skip): |
361 | | **/ |
362 | | guint8 |
363 | | fu_struct_synaprom_reply_get_version_get_patch(const FuStructSynapromReplyGetVersion *st) |
364 | 0 | { |
365 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
366 | 0 | return st->buf->data[17]; |
367 | 0 | } |
368 | | /** |
369 | | * fu_struct_synaprom_reply_get_version_get_serial_number: (skip): |
370 | | **/ |
371 | | const guint8 * |
372 | | fu_struct_synaprom_reply_get_version_get_serial_number(const FuStructSynapromReplyGetVersion *st, gsize *bufsz) |
373 | 0 | { |
374 | 0 | g_return_val_if_fail(st != NULL, NULL); |
375 | 0 | if (bufsz != NULL) |
376 | 0 | *bufsz = 6; |
377 | 0 | return st->buf->data + 18; |
378 | 0 | } |
379 | | /** |
380 | | * fu_struct_synaprom_reply_get_version_get_security0: (skip): |
381 | | **/ |
382 | | guint8 |
383 | | fu_struct_synaprom_reply_get_version_get_security0(const FuStructSynapromReplyGetVersion *st) |
384 | 0 | { |
385 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
386 | 0 | return st->buf->data[24]; |
387 | 0 | } |
388 | | /** |
389 | | * fu_struct_synaprom_reply_get_version_get_security1: (skip): |
390 | | **/ |
391 | | guint8 |
392 | | fu_struct_synaprom_reply_get_version_get_security1(const FuStructSynapromReplyGetVersion *st) |
393 | 0 | { |
394 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
395 | 0 | return st->buf->data[25]; |
396 | 0 | } |
397 | | /** |
398 | | * fu_struct_synaprom_reply_get_version_get_patchsig: (skip): |
399 | | **/ |
400 | | guint32 |
401 | | fu_struct_synaprom_reply_get_version_get_patchsig(const FuStructSynapromReplyGetVersion *st) |
402 | 0 | { |
403 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
404 | 0 | return fu_memread_uint32(st->buf->data + 26, G_LITTLE_ENDIAN); |
405 | 0 | } |
406 | | /** |
407 | | * fu_struct_synaprom_reply_get_version_get_iface: (skip): |
408 | | **/ |
409 | | guint8 |
410 | | fu_struct_synaprom_reply_get_version_get_iface(const FuStructSynapromReplyGetVersion *st) |
411 | 0 | { |
412 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
413 | 0 | return st->buf->data[30]; |
414 | 0 | } |
415 | | /** |
416 | | * fu_struct_synaprom_reply_get_version_get_otpsig: (skip): |
417 | | **/ |
418 | | const guint8 * |
419 | | fu_struct_synaprom_reply_get_version_get_otpsig(const FuStructSynapromReplyGetVersion *st, gsize *bufsz) |
420 | 0 | { |
421 | 0 | g_return_val_if_fail(st != NULL, NULL); |
422 | 0 | if (bufsz != NULL) |
423 | 0 | *bufsz = 3; |
424 | 0 | return st->buf->data + 31; |
425 | 0 | } |
426 | | /** |
427 | | * fu_struct_synaprom_reply_get_version_get_otpspare1: (skip): |
428 | | **/ |
429 | | guint16 |
430 | | fu_struct_synaprom_reply_get_version_get_otpspare1(const FuStructSynapromReplyGetVersion *st) |
431 | 0 | { |
432 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
433 | 0 | return fu_memread_uint16(st->buf->data + 34, G_LITTLE_ENDIAN); |
434 | 0 | } |
435 | | /** |
436 | | * fu_struct_synaprom_reply_get_version_get_device_type: (skip): |
437 | | **/ |
438 | | guint8 |
439 | | fu_struct_synaprom_reply_get_version_get_device_type(const FuStructSynapromReplyGetVersion *st) |
440 | 0 | { |
441 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
442 | 0 | return st->buf->data[37]; |
443 | 0 | } |
444 | | |
445 | | /* setters */ |
446 | | /** |
447 | | * fu_struct_synaprom_reply_get_version_to_string: (skip): |
448 | | **/ |
449 | | static gchar * |
450 | | fu_struct_synaprom_reply_get_version_to_string(const FuStructSynapromReplyGetVersion *st) |
451 | 0 | { |
452 | 0 | g_autoptr(GString) str = g_string_new("FuStructSynapromReplyGetVersion:\n"); |
453 | 0 | g_return_val_if_fail(st != NULL, NULL); |
454 | 0 | g_string_append_printf(str, " status: 0x%x\n", |
455 | 0 | (guint) fu_struct_synaprom_reply_get_version_get_status(st)); |
456 | 0 | g_string_append_printf(str, " buildtime: 0x%x\n", |
457 | 0 | (guint) fu_struct_synaprom_reply_get_version_get_buildtime(st)); |
458 | 0 | g_string_append_printf(str, " buildnum: 0x%x\n", |
459 | 0 | (guint) fu_struct_synaprom_reply_get_version_get_buildnum(st)); |
460 | 0 | g_string_append_printf(str, " vmajor: 0x%x\n", |
461 | 0 | (guint) fu_struct_synaprom_reply_get_version_get_vmajor(st)); |
462 | 0 | g_string_append_printf(str, " vminor: 0x%x\n", |
463 | 0 | (guint) fu_struct_synaprom_reply_get_version_get_vminor(st)); |
464 | 0 | g_string_append_printf(str, " target: 0x%x\n", |
465 | 0 | (guint) fu_struct_synaprom_reply_get_version_get_target(st)); |
466 | 0 | { |
467 | 0 | const gchar *tmp = fu_synaprom_product_to_string(fu_struct_synaprom_reply_get_version_get_product(st)); |
468 | 0 | if (tmp != NULL) { |
469 | 0 | g_string_append_printf(str, " product: 0x%x [%s]\n", (guint) fu_struct_synaprom_reply_get_version_get_product(st), tmp); |
470 | 0 | } else { |
471 | 0 | g_string_append_printf(str, " product: 0x%x\n", (guint) fu_struct_synaprom_reply_get_version_get_product(st)); |
472 | 0 | } |
473 | 0 | } |
474 | 0 | g_string_append_printf(str, " siliconrev: 0x%x\n", |
475 | 0 | (guint) fu_struct_synaprom_reply_get_version_get_siliconrev(st)); |
476 | 0 | g_string_append_printf(str, " formalrel: 0x%x\n", |
477 | 0 | (guint) fu_struct_synaprom_reply_get_version_get_formalrel(st)); |
478 | 0 | g_string_append_printf(str, " platform: 0x%x\n", |
479 | 0 | (guint) fu_struct_synaprom_reply_get_version_get_platform(st)); |
480 | 0 | g_string_append_printf(str, " patch: 0x%x\n", |
481 | 0 | (guint) fu_struct_synaprom_reply_get_version_get_patch(st)); |
482 | 0 | { |
483 | 0 | gsize bufsz = 0; |
484 | 0 | const guint8 *buf = fu_struct_synaprom_reply_get_version_get_serial_number(st, &bufsz); |
485 | 0 | g_autoptr(GString) tmp = g_string_new(NULL); |
486 | 0 | for (gsize i = 0; i < bufsz; i++) |
487 | 0 | g_string_append_printf(tmp, "%02X", buf[i]); |
488 | 0 | g_string_append_printf(str, " serial_number: 0x%s\n", tmp->str); |
489 | 0 | } |
490 | 0 | g_string_append_printf(str, " security0: 0x%x\n", |
491 | 0 | (guint) fu_struct_synaprom_reply_get_version_get_security0(st)); |
492 | 0 | g_string_append_printf(str, " security1: 0x%x\n", |
493 | 0 | (guint) fu_struct_synaprom_reply_get_version_get_security1(st)); |
494 | 0 | g_string_append_printf(str, " patchsig: 0x%x\n", |
495 | 0 | (guint) fu_struct_synaprom_reply_get_version_get_patchsig(st)); |
496 | 0 | g_string_append_printf(str, " iface: 0x%x\n", |
497 | 0 | (guint) fu_struct_synaprom_reply_get_version_get_iface(st)); |
498 | 0 | { |
499 | 0 | gsize bufsz = 0; |
500 | 0 | const guint8 *buf = fu_struct_synaprom_reply_get_version_get_otpsig(st, &bufsz); |
501 | 0 | g_autoptr(GString) tmp = g_string_new(NULL); |
502 | 0 | for (gsize i = 0; i < bufsz; i++) |
503 | 0 | g_string_append_printf(tmp, "%02X", buf[i]); |
504 | 0 | g_string_append_printf(str, " otpsig: 0x%s\n", tmp->str); |
505 | 0 | } |
506 | 0 | g_string_append_printf(str, " otpspare1: 0x%x\n", |
507 | 0 | (guint) fu_struct_synaprom_reply_get_version_get_otpspare1(st)); |
508 | 0 | g_string_append_printf(str, " device_type: 0x%x\n", |
509 | 0 | (guint) fu_struct_synaprom_reply_get_version_get_device_type(st)); |
510 | 0 | if (str->len > 0) |
511 | 0 | g_string_set_size(str, str->len - 1); |
512 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
513 | 0 | } |
514 | | static gboolean |
515 | | fu_struct_synaprom_reply_get_version_validate_internal(FuStructSynapromReplyGetVersion *st, GError **error) |
516 | 0 | { |
517 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
518 | 0 | return TRUE; |
519 | 0 | } |
520 | | static gboolean |
521 | | fu_struct_synaprom_reply_get_version_parse_internal(FuStructSynapromReplyGetVersion *st, GError **error) |
522 | 0 | { |
523 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
524 | 0 | g_autofree gchar *str = fu_struct_synaprom_reply_get_version_to_string(st); |
525 | 0 | g_debug("%s", str); |
526 | 0 | } |
527 | 0 | if (!fu_struct_synaprom_reply_get_version_validate_internal(st, error)) |
528 | 0 | return FALSE; |
529 | 0 | return TRUE; |
530 | 0 | } |
531 | | |
532 | | /** |
533 | | * fu_struct_synaprom_reply_get_version_parse: (skip): |
534 | | **/ |
535 | | FuStructSynapromReplyGetVersion * |
536 | | fu_struct_synaprom_reply_get_version_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
537 | 0 | { |
538 | 0 | g_autoptr(FuStructSynapromReplyGetVersion) st = fu_struct_synaprom_reply_get_version_new_internal(); |
539 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
540 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
541 | 0 | if (!fu_memchk_read(bufsz, offset, 38, error)) { |
542 | 0 | g_prefix_error_literal(error, "invalid struct FuStructSynapromReplyGetVersion: "); |
543 | 0 | return NULL; |
544 | 0 | } |
545 | 0 | st->buf = g_byte_array_new(); |
546 | 0 | g_byte_array_append(st->buf, buf + offset, 38); |
547 | 0 | if (!fu_struct_synaprom_reply_get_version_parse_internal(st, error)) |
548 | 0 | return NULL; |
549 | 0 | return g_steal_pointer(&st); |
550 | 0 | } |
551 | | /** |
552 | | * fu_struct_synaprom_mfw_hdr_ref: (skip): |
553 | | **/ |
554 | | FuStructSynapromMfwHdr * |
555 | | fu_struct_synaprom_mfw_hdr_ref(FuStructSynapromMfwHdr *st) |
556 | 0 | { |
557 | 0 | g_return_val_if_fail(st != NULL, NULL); |
558 | 0 | st->refcount++; |
559 | 0 | return st; |
560 | 0 | } |
561 | | /** |
562 | | * fu_struct_synaprom_mfw_hdr_unref: (skip): |
563 | | **/ |
564 | | void |
565 | | fu_struct_synaprom_mfw_hdr_unref(FuStructSynapromMfwHdr *st) |
566 | 271 | { |
567 | 271 | g_return_if_fail(st != NULL); |
568 | 271 | if (st->refcount == 0) { |
569 | 0 | g_critical("FuStructSynapromMfwHdr refcount already zero"); |
570 | 0 | return; |
571 | 0 | } |
572 | 271 | if (--st->refcount > 0) |
573 | 0 | return; |
574 | 271 | if (st->buf != NULL) |
575 | 271 | g_byte_array_unref(st->buf); |
576 | 271 | g_free(st); |
577 | 271 | } |
578 | | static FuStructSynapromMfwHdr * |
579 | | fu_struct_synaprom_mfw_hdr_new_internal(void) |
580 | 271 | { |
581 | 271 | FuStructSynapromMfwHdr *st = g_new0(FuStructSynapromMfwHdr, 1); |
582 | 271 | st->refcount = 1; |
583 | 271 | return st; |
584 | 271 | } |
585 | | |
586 | | /* getters */ |
587 | | /** |
588 | | * fu_struct_synaprom_mfw_hdr_get_product: (skip): |
589 | | **/ |
590 | | guint32 |
591 | | fu_struct_synaprom_mfw_hdr_get_product(const FuStructSynapromMfwHdr *st) |
592 | 141 | { |
593 | 141 | g_return_val_if_fail(st != NULL, 0x0); |
594 | 141 | return fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
595 | 141 | } |
596 | | /** |
597 | | * fu_struct_synaprom_mfw_hdr_get_id: (skip): |
598 | | **/ |
599 | | guint32 |
600 | | fu_struct_synaprom_mfw_hdr_get_id(const FuStructSynapromMfwHdr *st) |
601 | 0 | { |
602 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
603 | 0 | return fu_memread_uint32(st->buf->data + 4, G_LITTLE_ENDIAN); |
604 | 0 | } |
605 | | /** |
606 | | * fu_struct_synaprom_mfw_hdr_get_buildtime: (skip): |
607 | | **/ |
608 | | guint32 |
609 | | fu_struct_synaprom_mfw_hdr_get_buildtime(const FuStructSynapromMfwHdr *st) |
610 | 0 | { |
611 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
612 | 0 | return fu_memread_uint32(st->buf->data + 8, G_LITTLE_ENDIAN); |
613 | 0 | } |
614 | | /** |
615 | | * fu_struct_synaprom_mfw_hdr_get_buildnum: (skip): |
616 | | **/ |
617 | | guint32 |
618 | | fu_struct_synaprom_mfw_hdr_get_buildnum(const FuStructSynapromMfwHdr *st) |
619 | 0 | { |
620 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
621 | 0 | return fu_memread_uint32(st->buf->data + 12, G_LITTLE_ENDIAN); |
622 | 0 | } |
623 | | /** |
624 | | * fu_struct_synaprom_mfw_hdr_get_vmajor: (skip): |
625 | | **/ |
626 | | guint8 |
627 | | fu_struct_synaprom_mfw_hdr_get_vmajor(const FuStructSynapromMfwHdr *st) |
628 | 141 | { |
629 | 141 | g_return_val_if_fail(st != NULL, 0x0); |
630 | 141 | return st->buf->data[16]; |
631 | 141 | } |
632 | | /** |
633 | | * fu_struct_synaprom_mfw_hdr_get_vminor: (skip): |
634 | | **/ |
635 | | guint8 |
636 | | fu_struct_synaprom_mfw_hdr_get_vminor(const FuStructSynapromMfwHdr *st) |
637 | 141 | { |
638 | 141 | g_return_val_if_fail(st != NULL, 0x0); |
639 | 141 | return st->buf->data[17]; |
640 | 141 | } |
641 | | /** |
642 | | * fu_struct_synaprom_mfw_hdr_get_unused: (skip): |
643 | | **/ |
644 | | const guint8 * |
645 | | fu_struct_synaprom_mfw_hdr_get_unused(const FuStructSynapromMfwHdr *st, gsize *bufsz) |
646 | 0 | { |
647 | 0 | g_return_val_if_fail(st != NULL, NULL); |
648 | 0 | if (bufsz != NULL) |
649 | 0 | *bufsz = 6; |
650 | 0 | return st->buf->data + 18; |
651 | 0 | } |
652 | | |
653 | | /* setters */ |
654 | | /** |
655 | | * fu_struct_synaprom_mfw_hdr_set_product: (skip): |
656 | | **/ |
657 | | void |
658 | | fu_struct_synaprom_mfw_hdr_set_product(FuStructSynapromMfwHdr *st, guint32 value) |
659 | 130 | { |
660 | 130 | g_return_if_fail(st != NULL); |
661 | 130 | fu_memwrite_uint32(st->buf->data + 0, value, G_LITTLE_ENDIAN); |
662 | 130 | } |
663 | | /** |
664 | | * fu_struct_synaprom_mfw_hdr_set_id: (skip): |
665 | | **/ |
666 | | void |
667 | | fu_struct_synaprom_mfw_hdr_set_id(FuStructSynapromMfwHdr *st, guint32 value) |
668 | 130 | { |
669 | 130 | g_return_if_fail(st != NULL); |
670 | 130 | fu_memwrite_uint32(st->buf->data + 4, value, G_LITTLE_ENDIAN); |
671 | 130 | } |
672 | | /** |
673 | | * fu_struct_synaprom_mfw_hdr_set_buildtime: (skip): |
674 | | **/ |
675 | | void |
676 | | fu_struct_synaprom_mfw_hdr_set_buildtime(FuStructSynapromMfwHdr *st, guint32 value) |
677 | 130 | { |
678 | 130 | g_return_if_fail(st != NULL); |
679 | 130 | fu_memwrite_uint32(st->buf->data + 8, value, G_LITTLE_ENDIAN); |
680 | 130 | } |
681 | | /** |
682 | | * fu_struct_synaprom_mfw_hdr_set_buildnum: (skip): |
683 | | **/ |
684 | | void |
685 | | fu_struct_synaprom_mfw_hdr_set_buildnum(FuStructSynapromMfwHdr *st, guint32 value) |
686 | 130 | { |
687 | 130 | g_return_if_fail(st != NULL); |
688 | 130 | fu_memwrite_uint32(st->buf->data + 12, value, G_LITTLE_ENDIAN); |
689 | 130 | } |
690 | | /** |
691 | | * fu_struct_synaprom_mfw_hdr_set_vmajor: (skip): |
692 | | **/ |
693 | | void |
694 | | fu_struct_synaprom_mfw_hdr_set_vmajor(FuStructSynapromMfwHdr *st, guint8 value) |
695 | 130 | { |
696 | 130 | g_return_if_fail(st != NULL); |
697 | 130 | st->buf->data[16] = value; |
698 | 130 | } |
699 | | /** |
700 | | * fu_struct_synaprom_mfw_hdr_set_vminor: (skip): |
701 | | **/ |
702 | | void |
703 | | fu_struct_synaprom_mfw_hdr_set_vminor(FuStructSynapromMfwHdr *st, guint8 value) |
704 | 130 | { |
705 | 130 | g_return_if_fail(st != NULL); |
706 | 130 | st->buf->data[17] = value; |
707 | 130 | } |
708 | | /** |
709 | | * fu_struct_synaprom_mfw_hdr_set_unused: (skip): |
710 | | **/ |
711 | | gboolean |
712 | | fu_struct_synaprom_mfw_hdr_set_unused(FuStructSynapromMfwHdr *st, const guint8 *buf, gsize bufsz, GError **error) |
713 | 0 | { |
714 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
715 | 0 | g_return_val_if_fail(buf != NULL, FALSE); |
716 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
717 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 18, buf, bufsz, 0x0, bufsz, error); |
718 | 0 | } |
719 | | /** |
720 | | * fu_struct_synaprom_mfw_hdr_new: (skip): |
721 | | **/ |
722 | | FuStructSynapromMfwHdr * |
723 | | fu_struct_synaprom_mfw_hdr_new(void) |
724 | 130 | { |
725 | 130 | FuStructSynapromMfwHdr *st = fu_struct_synaprom_mfw_hdr_new_internal(); |
726 | 130 | st->buf = g_byte_array_sized_new(24); |
727 | 130 | fu_byte_array_set_size(st->buf, 24, 0x0); |
728 | 130 | fu_struct_synaprom_mfw_hdr_set_id(st, 0xFF); |
729 | 130 | fu_struct_synaprom_mfw_hdr_set_buildtime(st, 0xFF); |
730 | 130 | fu_struct_synaprom_mfw_hdr_set_buildnum(st, 0xFF); |
731 | 130 | fu_struct_synaprom_mfw_hdr_set_vmajor(st, 10); |
732 | 130 | fu_struct_synaprom_mfw_hdr_set_vminor(st, 1); |
733 | 130 | return st; |
734 | 130 | } |
735 | | /** |
736 | | * fu_struct_synaprom_mfw_hdr_to_string: (skip): |
737 | | **/ |
738 | | static gchar * |
739 | | fu_struct_synaprom_mfw_hdr_to_string(const FuStructSynapromMfwHdr *st) |
740 | 0 | { |
741 | 0 | g_autoptr(GString) str = g_string_new("FuStructSynapromMfwHdr:\n"); |
742 | 0 | g_return_val_if_fail(st != NULL, NULL); |
743 | 0 | g_string_append_printf(str, " product: 0x%x\n", |
744 | 0 | (guint) fu_struct_synaprom_mfw_hdr_get_product(st)); |
745 | 0 | g_string_append_printf(str, " id: 0x%x\n", |
746 | 0 | (guint) fu_struct_synaprom_mfw_hdr_get_id(st)); |
747 | 0 | g_string_append_printf(str, " buildtime: 0x%x\n", |
748 | 0 | (guint) fu_struct_synaprom_mfw_hdr_get_buildtime(st)); |
749 | 0 | g_string_append_printf(str, " buildnum: 0x%x\n", |
750 | 0 | (guint) fu_struct_synaprom_mfw_hdr_get_buildnum(st)); |
751 | 0 | g_string_append_printf(str, " vmajor: 0x%x\n", |
752 | 0 | (guint) fu_struct_synaprom_mfw_hdr_get_vmajor(st)); |
753 | 0 | g_string_append_printf(str, " vminor: 0x%x\n", |
754 | 0 | (guint) fu_struct_synaprom_mfw_hdr_get_vminor(st)); |
755 | 0 | { |
756 | 0 | gsize bufsz = 0; |
757 | 0 | const guint8 *buf = fu_struct_synaprom_mfw_hdr_get_unused(st, &bufsz); |
758 | 0 | g_autoptr(GString) tmp = g_string_new(NULL); |
759 | 0 | for (gsize i = 0; i < bufsz; i++) |
760 | 0 | g_string_append_printf(tmp, "%02X", buf[i]); |
761 | 0 | g_string_append_printf(str, " unused: 0x%s\n", tmp->str); |
762 | 0 | } |
763 | 0 | if (str->len > 0) |
764 | 0 | g_string_set_size(str, str->len - 1); |
765 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
766 | 0 | } |
767 | | static gboolean |
768 | | fu_struct_synaprom_mfw_hdr_validate_internal(FuStructSynapromMfwHdr *st, GError **error) |
769 | 141 | { |
770 | 141 | g_return_val_if_fail(st != NULL, FALSE); |
771 | 141 | return TRUE; |
772 | 141 | } |
773 | | static gboolean |
774 | | fu_struct_synaprom_mfw_hdr_parse_internal(FuStructSynapromMfwHdr *st, GError **error) |
775 | 141 | { |
776 | 141 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
777 | 0 | g_autofree gchar *str = fu_struct_synaprom_mfw_hdr_to_string(st); |
778 | 0 | g_debug("%s", str); |
779 | 0 | } |
780 | 141 | if (!fu_struct_synaprom_mfw_hdr_validate_internal(st, error)) |
781 | 0 | return FALSE; |
782 | 141 | return TRUE; |
783 | 141 | } |
784 | | /** |
785 | | * fu_struct_synaprom_mfw_hdr_parse_stream: (skip): |
786 | | **/ |
787 | | FuStructSynapromMfwHdr * |
788 | | fu_struct_synaprom_mfw_hdr_parse_stream(GInputStream *stream, gsize offset, GError **error) |
789 | 141 | { |
790 | 141 | g_autoptr(FuStructSynapromMfwHdr) st = fu_struct_synaprom_mfw_hdr_new_internal(); |
791 | 141 | st->buf = fu_input_stream_read_byte_array(stream, offset, 24, NULL, error); |
792 | 141 | if (st->buf == NULL) { |
793 | 0 | g_prefix_error(error, "FuStructSynapromMfwHdr failed read of 0x%x: ", (guint) 24); |
794 | 0 | return NULL; |
795 | 0 | } |
796 | 141 | if (st->buf->len != 24) { |
797 | 0 | g_set_error(error, |
798 | 0 | FWUPD_ERROR, |
799 | 0 | FWUPD_ERROR_INVALID_DATA, |
800 | 0 | "FuStructSynapromMfwHdr requested 0x%x and got 0x%x", |
801 | 0 | (guint) 24, |
802 | 0 | (guint) st->buf->len); |
803 | 0 | return NULL; |
804 | 0 | } |
805 | 141 | if (!fu_struct_synaprom_mfw_hdr_parse_internal(st, error)) |
806 | 0 | return NULL; |
807 | 141 | return g_steal_pointer(&st); |
808 | 141 | } |
809 | | /** |
810 | | * fu_struct_synaprom_hdr_ref: (skip): |
811 | | **/ |
812 | | FuStructSynapromHdr * |
813 | | fu_struct_synaprom_hdr_ref(FuStructSynapromHdr *st) |
814 | 0 | { |
815 | 0 | g_return_val_if_fail(st != NULL, NULL); |
816 | 0 | st->refcount++; |
817 | 0 | return st; |
818 | 0 | } |
819 | | /** |
820 | | * fu_struct_synaprom_hdr_unref: (skip): |
821 | | **/ |
822 | | void |
823 | | fu_struct_synaprom_hdr_unref(FuStructSynapromHdr *st) |
824 | 4.79k | { |
825 | 4.79k | g_return_if_fail(st != NULL); |
826 | 4.79k | if (st->refcount == 0) { |
827 | 0 | g_critical("FuStructSynapromHdr refcount already zero"); |
828 | 0 | return; |
829 | 0 | } |
830 | 4.79k | if (--st->refcount > 0) |
831 | 0 | return; |
832 | 4.79k | if (st->buf != NULL) |
833 | 4.79k | g_byte_array_unref(st->buf); |
834 | 4.79k | g_free(st); |
835 | 4.79k | } |
836 | | static FuStructSynapromHdr * |
837 | | fu_struct_synaprom_hdr_new_internal(void) |
838 | 4.79k | { |
839 | 4.79k | FuStructSynapromHdr *st = g_new0(FuStructSynapromHdr, 1); |
840 | 4.79k | st->refcount = 1; |
841 | 4.79k | return st; |
842 | 4.79k | } |
843 | | |
844 | | /* getters */ |
845 | | /** |
846 | | * fu_struct_synaprom_hdr_get_tag: (skip): |
847 | | **/ |
848 | | FuSynapromFirmwareTag |
849 | | fu_struct_synaprom_hdr_get_tag(const FuStructSynapromHdr *st) |
850 | 4.66k | { |
851 | 4.66k | g_return_val_if_fail(st != NULL, 0x0); |
852 | 4.66k | return fu_memread_uint16(st->buf->data + 0, G_LITTLE_ENDIAN); |
853 | 4.66k | } |
854 | | /** |
855 | | * fu_struct_synaprom_hdr_get_bufsz: (skip): |
856 | | **/ |
857 | | guint32 |
858 | | fu_struct_synaprom_hdr_get_bufsz(const FuStructSynapromHdr *st) |
859 | 4.63k | { |
860 | 4.63k | g_return_val_if_fail(st != NULL, 0x0); |
861 | 4.63k | return fu_memread_uint32(st->buf->data + 2, G_LITTLE_ENDIAN); |
862 | 4.63k | } |
863 | | |
864 | | /* setters */ |
865 | | /** |
866 | | * fu_struct_synaprom_hdr_set_tag: (skip): |
867 | | **/ |
868 | | void |
869 | | fu_struct_synaprom_hdr_set_tag(FuStructSynapromHdr *st, FuSynapromFirmwareTag value) |
870 | 130 | { |
871 | 130 | g_return_if_fail(st != NULL); |
872 | 130 | fu_memwrite_uint16(st->buf->data + 0, value, G_LITTLE_ENDIAN); |
873 | 130 | } |
874 | | /** |
875 | | * fu_struct_synaprom_hdr_set_bufsz: (skip): |
876 | | **/ |
877 | | void |
878 | | fu_struct_synaprom_hdr_set_bufsz(FuStructSynapromHdr *st, guint32 value) |
879 | 130 | { |
880 | 130 | g_return_if_fail(st != NULL); |
881 | 130 | fu_memwrite_uint32(st->buf->data + 2, value, G_LITTLE_ENDIAN); |
882 | 130 | } |
883 | | /** |
884 | | * fu_struct_synaprom_hdr_new: (skip): |
885 | | **/ |
886 | | FuStructSynapromHdr * |
887 | | fu_struct_synaprom_hdr_new(void) |
888 | 130 | { |
889 | 130 | FuStructSynapromHdr *st = fu_struct_synaprom_hdr_new_internal(); |
890 | 130 | st->buf = g_byte_array_sized_new(6); |
891 | 130 | fu_byte_array_set_size(st->buf, 6, 0x0); |
892 | 130 | return st; |
893 | 130 | } |
894 | | /** |
895 | | * fu_struct_synaprom_hdr_to_string: (skip): |
896 | | **/ |
897 | | static gchar * |
898 | | fu_struct_synaprom_hdr_to_string(const FuStructSynapromHdr *st) |
899 | 0 | { |
900 | 0 | g_autoptr(GString) str = g_string_new("FuStructSynapromHdr:\n"); |
901 | 0 | g_return_val_if_fail(st != NULL, NULL); |
902 | 0 | { |
903 | 0 | const gchar *tmp = fu_synaprom_firmware_tag_to_string(fu_struct_synaprom_hdr_get_tag(st)); |
904 | 0 | if (tmp != NULL) { |
905 | 0 | g_string_append_printf(str, " tag: 0x%x [%s]\n", (guint) fu_struct_synaprom_hdr_get_tag(st), tmp); |
906 | 0 | } else { |
907 | 0 | g_string_append_printf(str, " tag: 0x%x\n", (guint) fu_struct_synaprom_hdr_get_tag(st)); |
908 | 0 | } |
909 | 0 | } |
910 | 0 | g_string_append_printf(str, " bufsz: 0x%x\n", |
911 | 0 | (guint) fu_struct_synaprom_hdr_get_bufsz(st)); |
912 | 0 | if (str->len > 0) |
913 | 0 | g_string_set_size(str, str->len - 1); |
914 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
915 | 0 | } |
916 | | static gboolean |
917 | | fu_struct_synaprom_hdr_validate_internal(FuStructSynapromHdr *st, GError **error) |
918 | 4.66k | { |
919 | 4.66k | g_return_val_if_fail(st != NULL, FALSE); |
920 | 4.66k | return TRUE; |
921 | 4.66k | } |
922 | | static gboolean |
923 | | fu_struct_synaprom_hdr_parse_internal(FuStructSynapromHdr *st, GError **error) |
924 | 4.66k | { |
925 | 4.66k | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
926 | 0 | g_autofree gchar *str = fu_struct_synaprom_hdr_to_string(st); |
927 | 0 | g_debug("%s", str); |
928 | 0 | } |
929 | 4.66k | if (!fu_struct_synaprom_hdr_validate_internal(st, error)) |
930 | 0 | return FALSE; |
931 | 4.66k | return TRUE; |
932 | 4.66k | } |
933 | | /** |
934 | | * fu_struct_synaprom_hdr_parse_stream: (skip): |
935 | | **/ |
936 | | FuStructSynapromHdr * |
937 | | fu_struct_synaprom_hdr_parse_stream(GInputStream *stream, gsize offset, GError **error) |
938 | 4.66k | { |
939 | 4.66k | g_autoptr(FuStructSynapromHdr) st = fu_struct_synaprom_hdr_new_internal(); |
940 | 4.66k | st->buf = fu_input_stream_read_byte_array(stream, offset, 6, NULL, error); |
941 | 4.66k | if (st->buf == NULL) { |
942 | 0 | g_prefix_error(error, "FuStructSynapromHdr failed read of 0x%x: ", (guint) 6); |
943 | 0 | return NULL; |
944 | 0 | } |
945 | 4.66k | if (st->buf->len != 6) { |
946 | 0 | g_set_error(error, |
947 | 0 | FWUPD_ERROR, |
948 | 0 | FWUPD_ERROR_INVALID_DATA, |
949 | 0 | "FuStructSynapromHdr requested 0x%x and got 0x%x", |
950 | 0 | (guint) 6, |
951 | 0 | (guint) st->buf->len); |
952 | 0 | return NULL; |
953 | 0 | } |
954 | 4.66k | if (!fu_struct_synaprom_hdr_parse_internal(st, error)) |
955 | 0 | return NULL; |
956 | 4.66k | return g_steal_pointer(&st); |
957 | 4.66k | } |
958 | | /** |
959 | | * fu_struct_synaprom_cfg_hdr_ref: (skip): |
960 | | **/ |
961 | | FuStructSynapromCfgHdr * |
962 | | fu_struct_synaprom_cfg_hdr_ref(FuStructSynapromCfgHdr *st) |
963 | 0 | { |
964 | 0 | g_return_val_if_fail(st != NULL, NULL); |
965 | 0 | st->refcount++; |
966 | 0 | return st; |
967 | 0 | } |
968 | | /** |
969 | | * fu_struct_synaprom_cfg_hdr_unref: (skip): |
970 | | **/ |
971 | | void |
972 | | fu_struct_synaprom_cfg_hdr_unref(FuStructSynapromCfgHdr *st) |
973 | 0 | { |
974 | 0 | g_return_if_fail(st != NULL); |
975 | 0 | if (st->refcount == 0) { |
976 | 0 | g_critical("FuStructSynapromCfgHdr refcount already zero"); |
977 | 0 | return; |
978 | 0 | } |
979 | 0 | if (--st->refcount > 0) |
980 | 0 | return; |
981 | 0 | if (st->buf != NULL) |
982 | 0 | g_byte_array_unref(st->buf); |
983 | 0 | g_free(st); |
984 | 0 | } |
985 | | static FuStructSynapromCfgHdr * |
986 | | fu_struct_synaprom_cfg_hdr_new_internal(void) |
987 | 0 | { |
988 | 0 | FuStructSynapromCfgHdr *st = g_new0(FuStructSynapromCfgHdr, 1); |
989 | 0 | st->refcount = 1; |
990 | 0 | return st; |
991 | 0 | } |
992 | | |
993 | | /* getters */ |
994 | | /** |
995 | | * fu_struct_synaprom_cfg_hdr_get_product: (skip): |
996 | | **/ |
997 | | guint32 |
998 | | fu_struct_synaprom_cfg_hdr_get_product(const FuStructSynapromCfgHdr *st) |
999 | 0 | { |
1000 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1001 | 0 | return fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
1002 | 0 | } |
1003 | | /** |
1004 | | * fu_struct_synaprom_cfg_hdr_get_id1: (skip): |
1005 | | **/ |
1006 | | guint32 |
1007 | | fu_struct_synaprom_cfg_hdr_get_id1(const FuStructSynapromCfgHdr *st) |
1008 | 0 | { |
1009 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1010 | 0 | return fu_memread_uint32(st->buf->data + 4, G_LITTLE_ENDIAN); |
1011 | 0 | } |
1012 | | /** |
1013 | | * fu_struct_synaprom_cfg_hdr_get_id2: (skip): |
1014 | | **/ |
1015 | | guint32 |
1016 | | fu_struct_synaprom_cfg_hdr_get_id2(const FuStructSynapromCfgHdr *st) |
1017 | 0 | { |
1018 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1019 | 0 | return fu_memread_uint32(st->buf->data + 8, G_LITTLE_ENDIAN); |
1020 | 0 | } |
1021 | | /** |
1022 | | * fu_struct_synaprom_cfg_hdr_get_version: (skip): |
1023 | | **/ |
1024 | | guint16 |
1025 | | fu_struct_synaprom_cfg_hdr_get_version(const FuStructSynapromCfgHdr *st) |
1026 | 0 | { |
1027 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1028 | 0 | return fu_memread_uint16(st->buf->data + 12, G_LITTLE_ENDIAN); |
1029 | 0 | } |
1030 | | |
1031 | | /* setters */ |
1032 | | /** |
1033 | | * fu_struct_synaprom_cfg_hdr_to_string: (skip): |
1034 | | **/ |
1035 | | static gchar * |
1036 | | fu_struct_synaprom_cfg_hdr_to_string(const FuStructSynapromCfgHdr *st) |
1037 | 0 | { |
1038 | 0 | g_autoptr(GString) str = g_string_new("FuStructSynapromCfgHdr:\n"); |
1039 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1040 | 0 | g_string_append_printf(str, " product: 0x%x\n", |
1041 | 0 | (guint) fu_struct_synaprom_cfg_hdr_get_product(st)); |
1042 | 0 | g_string_append_printf(str, " id1: 0x%x\n", |
1043 | 0 | (guint) fu_struct_synaprom_cfg_hdr_get_id1(st)); |
1044 | 0 | g_string_append_printf(str, " id2: 0x%x\n", |
1045 | 0 | (guint) fu_struct_synaprom_cfg_hdr_get_id2(st)); |
1046 | 0 | g_string_append_printf(str, " version: 0x%x\n", |
1047 | 0 | (guint) fu_struct_synaprom_cfg_hdr_get_version(st)); |
1048 | 0 | if (str->len > 0) |
1049 | 0 | g_string_set_size(str, str->len - 1); |
1050 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1051 | 0 | } |
1052 | | static gboolean |
1053 | | fu_struct_synaprom_cfg_hdr_validate_internal(FuStructSynapromCfgHdr *st, GError **error) |
1054 | 0 | { |
1055 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
1056 | 0 | return TRUE; |
1057 | 0 | } |
1058 | | static gboolean |
1059 | | fu_struct_synaprom_cfg_hdr_parse_internal(FuStructSynapromCfgHdr *st, GError **error) |
1060 | 0 | { |
1061 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
1062 | 0 | g_autofree gchar *str = fu_struct_synaprom_cfg_hdr_to_string(st); |
1063 | 0 | g_debug("%s", str); |
1064 | 0 | } |
1065 | 0 | if (!fu_struct_synaprom_cfg_hdr_validate_internal(st, error)) |
1066 | 0 | return FALSE; |
1067 | 0 | return TRUE; |
1068 | 0 | } |
1069 | | /** |
1070 | | * fu_struct_synaprom_cfg_hdr_parse_stream: (skip): |
1071 | | **/ |
1072 | | FuStructSynapromCfgHdr * |
1073 | | fu_struct_synaprom_cfg_hdr_parse_stream(GInputStream *stream, gsize offset, GError **error) |
1074 | 0 | { |
1075 | 0 | g_autoptr(FuStructSynapromCfgHdr) st = fu_struct_synaprom_cfg_hdr_new_internal(); |
1076 | 0 | st->buf = fu_input_stream_read_byte_array(stream, offset, 16, NULL, error); |
1077 | 0 | if (st->buf == NULL) { |
1078 | 0 | g_prefix_error(error, "FuStructSynapromCfgHdr failed read of 0x%x: ", (guint) 16); |
1079 | 0 | return NULL; |
1080 | 0 | } |
1081 | 0 | if (st->buf->len != 16) { |
1082 | 0 | g_set_error(error, |
1083 | 0 | FWUPD_ERROR, |
1084 | 0 | FWUPD_ERROR_INVALID_DATA, |
1085 | 0 | "FuStructSynapromCfgHdr requested 0x%x and got 0x%x", |
1086 | 0 | (guint) 16, |
1087 | 0 | (guint) st->buf->len); |
1088 | 0 | return NULL; |
1089 | 0 | } |
1090 | 0 | if (!fu_struct_synaprom_cfg_hdr_parse_internal(st, error)) |
1091 | 0 | return NULL; |
1092 | 0 | return g_steal_pointer(&st); |
1093 | 0 | } |
1094 | | /** |
1095 | | * fu_struct_synaprom_iota_config_version_ref: (skip): |
1096 | | **/ |
1097 | | FuStructSynapromIotaConfigVersion * |
1098 | | fu_struct_synaprom_iota_config_version_ref(FuStructSynapromIotaConfigVersion *st) |
1099 | 0 | { |
1100 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1101 | 0 | st->refcount++; |
1102 | 0 | return st; |
1103 | 0 | } |
1104 | | /** |
1105 | | * fu_struct_synaprom_iota_config_version_unref: (skip): |
1106 | | **/ |
1107 | | void |
1108 | | fu_struct_synaprom_iota_config_version_unref(FuStructSynapromIotaConfigVersion *st) |
1109 | 0 | { |
1110 | 0 | g_return_if_fail(st != NULL); |
1111 | 0 | if (st->refcount == 0) { |
1112 | 0 | g_critical("FuStructSynapromIotaConfigVersion refcount already zero"); |
1113 | 0 | return; |
1114 | 0 | } |
1115 | 0 | if (--st->refcount > 0) |
1116 | 0 | return; |
1117 | 0 | if (st->buf != NULL) |
1118 | 0 | g_byte_array_unref(st->buf); |
1119 | 0 | g_free(st); |
1120 | 0 | } |
1121 | | static FuStructSynapromIotaConfigVersion * |
1122 | | fu_struct_synaprom_iota_config_version_new_internal(void) |
1123 | 0 | { |
1124 | 0 | FuStructSynapromIotaConfigVersion *st = g_new0(FuStructSynapromIotaConfigVersion, 1); |
1125 | 0 | st->refcount = 1; |
1126 | 0 | return st; |
1127 | 0 | } |
1128 | | |
1129 | | /* getters */ |
1130 | | /** |
1131 | | * fu_struct_synaprom_iota_config_version_get_config_id1: (skip): |
1132 | | **/ |
1133 | | guint32 |
1134 | | fu_struct_synaprom_iota_config_version_get_config_id1(const FuStructSynapromIotaConfigVersion *st) |
1135 | 0 | { |
1136 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1137 | 0 | return fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
1138 | 0 | } |
1139 | | /** |
1140 | | * fu_struct_synaprom_iota_config_version_get_config_id2: (skip): |
1141 | | **/ |
1142 | | guint32 |
1143 | | fu_struct_synaprom_iota_config_version_get_config_id2(const FuStructSynapromIotaConfigVersion *st) |
1144 | 0 | { |
1145 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1146 | 0 | return fu_memread_uint32(st->buf->data + 4, G_LITTLE_ENDIAN); |
1147 | 0 | } |
1148 | | /** |
1149 | | * fu_struct_synaprom_iota_config_version_get_version: (skip): |
1150 | | **/ |
1151 | | guint16 |
1152 | | fu_struct_synaprom_iota_config_version_get_version(const FuStructSynapromIotaConfigVersion *st) |
1153 | 0 | { |
1154 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1155 | 0 | return fu_memread_uint16(st->buf->data + 8, G_LITTLE_ENDIAN); |
1156 | 0 | } |
1157 | | |
1158 | | /* setters */ |
1159 | | /** |
1160 | | * fu_struct_synaprom_iota_config_version_to_string: (skip): |
1161 | | **/ |
1162 | | static gchar * |
1163 | | fu_struct_synaprom_iota_config_version_to_string(const FuStructSynapromIotaConfigVersion *st) |
1164 | 0 | { |
1165 | 0 | g_autoptr(GString) str = g_string_new("FuStructSynapromIotaConfigVersion:\n"); |
1166 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1167 | 0 | g_string_append_printf(str, " config_id1: 0x%x\n", |
1168 | 0 | (guint) fu_struct_synaprom_iota_config_version_get_config_id1(st)); |
1169 | 0 | g_string_append_printf(str, " config_id2: 0x%x\n", |
1170 | 0 | (guint) fu_struct_synaprom_iota_config_version_get_config_id2(st)); |
1171 | 0 | g_string_append_printf(str, " version: 0x%x\n", |
1172 | 0 | (guint) fu_struct_synaprom_iota_config_version_get_version(st)); |
1173 | 0 | if (str->len > 0) |
1174 | 0 | g_string_set_size(str, str->len - 1); |
1175 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1176 | 0 | } |
1177 | | static gboolean |
1178 | | fu_struct_synaprom_iota_config_version_validate_internal(FuStructSynapromIotaConfigVersion *st, GError **error) |
1179 | 0 | { |
1180 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
1181 | 0 | return TRUE; |
1182 | 0 | } |
1183 | | static gboolean |
1184 | | fu_struct_synaprom_iota_config_version_parse_internal(FuStructSynapromIotaConfigVersion *st, GError **error) |
1185 | 0 | { |
1186 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
1187 | 0 | g_autofree gchar *str = fu_struct_synaprom_iota_config_version_to_string(st); |
1188 | 0 | g_debug("%s", str); |
1189 | 0 | } |
1190 | 0 | if (!fu_struct_synaprom_iota_config_version_validate_internal(st, error)) |
1191 | 0 | return FALSE; |
1192 | 0 | return TRUE; |
1193 | 0 | } |
1194 | | |
1195 | | /** |
1196 | | * fu_struct_synaprom_iota_config_version_parse: (skip): |
1197 | | **/ |
1198 | | FuStructSynapromIotaConfigVersion * |
1199 | | fu_struct_synaprom_iota_config_version_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
1200 | 0 | { |
1201 | 0 | g_autoptr(FuStructSynapromIotaConfigVersion) st = fu_struct_synaprom_iota_config_version_new_internal(); |
1202 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
1203 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
1204 | 0 | if (!fu_memchk_read(bufsz, offset, 16, error)) { |
1205 | 0 | g_prefix_error_literal(error, "invalid struct FuStructSynapromIotaConfigVersion: "); |
1206 | 0 | return NULL; |
1207 | 0 | } |
1208 | 0 | st->buf = g_byte_array_new(); |
1209 | 0 | g_byte_array_append(st->buf, buf + offset, 16); |
1210 | 0 | if (!fu_struct_synaprom_iota_config_version_parse_internal(st, error)) |
1211 | 0 | return NULL; |
1212 | 0 | return g_steal_pointer(&st); |
1213 | 0 | } |
1214 | | /** |
1215 | | * fu_struct_synaprom_reply_iota_find_hdr_ref: (skip): |
1216 | | **/ |
1217 | | FuStructSynapromReplyIotaFindHdr * |
1218 | | fu_struct_synaprom_reply_iota_find_hdr_ref(FuStructSynapromReplyIotaFindHdr *st) |
1219 | 0 | { |
1220 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1221 | 0 | st->refcount++; |
1222 | 0 | return st; |
1223 | 0 | } |
1224 | | /** |
1225 | | * fu_struct_synaprom_reply_iota_find_hdr_unref: (skip): |
1226 | | **/ |
1227 | | void |
1228 | | fu_struct_synaprom_reply_iota_find_hdr_unref(FuStructSynapromReplyIotaFindHdr *st) |
1229 | 0 | { |
1230 | 0 | g_return_if_fail(st != NULL); |
1231 | 0 | if (st->refcount == 0) { |
1232 | 0 | g_critical("FuStructSynapromReplyIotaFindHdr refcount already zero"); |
1233 | 0 | return; |
1234 | 0 | } |
1235 | 0 | if (--st->refcount > 0) |
1236 | 0 | return; |
1237 | 0 | if (st->buf != NULL) |
1238 | 0 | g_byte_array_unref(st->buf); |
1239 | 0 | g_free(st); |
1240 | 0 | } |
1241 | | static FuStructSynapromReplyIotaFindHdr * |
1242 | | fu_struct_synaprom_reply_iota_find_hdr_new_internal(void) |
1243 | 0 | { |
1244 | 0 | FuStructSynapromReplyIotaFindHdr *st = g_new0(FuStructSynapromReplyIotaFindHdr, 1); |
1245 | 0 | st->refcount = 1; |
1246 | 0 | return st; |
1247 | 0 | } |
1248 | | |
1249 | | /* getters */ |
1250 | | /** |
1251 | | * fu_struct_synaprom_reply_iota_find_hdr_get_status: (skip): |
1252 | | **/ |
1253 | | guint16 |
1254 | | fu_struct_synaprom_reply_iota_find_hdr_get_status(const FuStructSynapromReplyIotaFindHdr *st) |
1255 | 0 | { |
1256 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1257 | 0 | return fu_memread_uint16(st->buf->data + 0, G_LITTLE_ENDIAN); |
1258 | 0 | } |
1259 | | /** |
1260 | | * fu_struct_synaprom_reply_iota_find_hdr_get_fullsize: (skip): |
1261 | | **/ |
1262 | | guint32 |
1263 | | fu_struct_synaprom_reply_iota_find_hdr_get_fullsize(const FuStructSynapromReplyIotaFindHdr *st) |
1264 | 0 | { |
1265 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1266 | 0 | return fu_memread_uint32(st->buf->data + 2, G_LITTLE_ENDIAN); |
1267 | 0 | } |
1268 | | /** |
1269 | | * fu_struct_synaprom_reply_iota_find_hdr_get_nbytes: (skip): |
1270 | | **/ |
1271 | | guint16 |
1272 | | fu_struct_synaprom_reply_iota_find_hdr_get_nbytes(const FuStructSynapromReplyIotaFindHdr *st) |
1273 | 0 | { |
1274 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1275 | 0 | return fu_memread_uint16(st->buf->data + 6, G_LITTLE_ENDIAN); |
1276 | 0 | } |
1277 | | /** |
1278 | | * fu_struct_synaprom_reply_iota_find_hdr_get_itype: (skip): |
1279 | | **/ |
1280 | | guint16 |
1281 | | fu_struct_synaprom_reply_iota_find_hdr_get_itype(const FuStructSynapromReplyIotaFindHdr *st) |
1282 | 0 | { |
1283 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1284 | 0 | return fu_memread_uint16(st->buf->data + 8, G_LITTLE_ENDIAN); |
1285 | 0 | } |
1286 | | |
1287 | | /* setters */ |
1288 | | /** |
1289 | | * fu_struct_synaprom_reply_iota_find_hdr_to_string: (skip): |
1290 | | **/ |
1291 | | static gchar * |
1292 | | fu_struct_synaprom_reply_iota_find_hdr_to_string(const FuStructSynapromReplyIotaFindHdr *st) |
1293 | 0 | { |
1294 | 0 | g_autoptr(GString) str = g_string_new("FuStructSynapromReplyIotaFindHdr:\n"); |
1295 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1296 | 0 | g_string_append_printf(str, " status: 0x%x\n", |
1297 | 0 | (guint) fu_struct_synaprom_reply_iota_find_hdr_get_status(st)); |
1298 | 0 | g_string_append_printf(str, " fullsize: 0x%x\n", |
1299 | 0 | (guint) fu_struct_synaprom_reply_iota_find_hdr_get_fullsize(st)); |
1300 | 0 | g_string_append_printf(str, " nbytes: 0x%x\n", |
1301 | 0 | (guint) fu_struct_synaprom_reply_iota_find_hdr_get_nbytes(st)); |
1302 | 0 | g_string_append_printf(str, " itype: 0x%x\n", |
1303 | 0 | (guint) fu_struct_synaprom_reply_iota_find_hdr_get_itype(st)); |
1304 | 0 | if (str->len > 0) |
1305 | 0 | g_string_set_size(str, str->len - 1); |
1306 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1307 | 0 | } |
1308 | | static gboolean |
1309 | | fu_struct_synaprom_reply_iota_find_hdr_validate_internal(FuStructSynapromReplyIotaFindHdr *st, GError **error) |
1310 | 0 | { |
1311 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
1312 | 0 | return TRUE; |
1313 | 0 | } |
1314 | | static gboolean |
1315 | | fu_struct_synaprom_reply_iota_find_hdr_parse_internal(FuStructSynapromReplyIotaFindHdr *st, GError **error) |
1316 | 0 | { |
1317 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
1318 | 0 | g_autofree gchar *str = fu_struct_synaprom_reply_iota_find_hdr_to_string(st); |
1319 | 0 | g_debug("%s", str); |
1320 | 0 | } |
1321 | 0 | if (!fu_struct_synaprom_reply_iota_find_hdr_validate_internal(st, error)) |
1322 | 0 | return FALSE; |
1323 | 0 | return TRUE; |
1324 | 0 | } |
1325 | | |
1326 | | /** |
1327 | | * fu_struct_synaprom_reply_iota_find_hdr_parse: (skip): |
1328 | | **/ |
1329 | | FuStructSynapromReplyIotaFindHdr * |
1330 | | fu_struct_synaprom_reply_iota_find_hdr_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
1331 | 0 | { |
1332 | 0 | g_autoptr(FuStructSynapromReplyIotaFindHdr) st = fu_struct_synaprom_reply_iota_find_hdr_new_internal(); |
1333 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
1334 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
1335 | 0 | if (!fu_memchk_read(bufsz, offset, 10, error)) { |
1336 | 0 | g_prefix_error_literal(error, "invalid struct FuStructSynapromReplyIotaFindHdr: "); |
1337 | 0 | return NULL; |
1338 | 0 | } |
1339 | 0 | st->buf = g_byte_array_new(); |
1340 | 0 | g_byte_array_append(st->buf, buf + offset, 10); |
1341 | 0 | if (!fu_struct_synaprom_reply_iota_find_hdr_parse_internal(st, error)) |
1342 | 0 | return NULL; |
1343 | 0 | return g_steal_pointer(&st); |
1344 | 0 | } |
1345 | | /** |
1346 | | * fu_struct_synaprom_cmd_iota_find_ref: (skip): |
1347 | | **/ |
1348 | | FuStructSynapromCmdIotaFind * |
1349 | | fu_struct_synaprom_cmd_iota_find_ref(FuStructSynapromCmdIotaFind *st) |
1350 | 0 | { |
1351 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1352 | 0 | st->refcount++; |
1353 | 0 | return st; |
1354 | 0 | } |
1355 | | /** |
1356 | | * fu_struct_synaprom_cmd_iota_find_unref: (skip): |
1357 | | **/ |
1358 | | void |
1359 | | fu_struct_synaprom_cmd_iota_find_unref(FuStructSynapromCmdIotaFind *st) |
1360 | 0 | { |
1361 | 0 | g_return_if_fail(st != NULL); |
1362 | 0 | if (st->refcount == 0) { |
1363 | 0 | g_critical("FuStructSynapromCmdIotaFind refcount already zero"); |
1364 | 0 | return; |
1365 | 0 | } |
1366 | 0 | if (--st->refcount > 0) |
1367 | 0 | return; |
1368 | 0 | if (st->buf != NULL) |
1369 | 0 | g_byte_array_unref(st->buf); |
1370 | 0 | g_free(st); |
1371 | 0 | } |
1372 | | static FuStructSynapromCmdIotaFind * |
1373 | | fu_struct_synaprom_cmd_iota_find_new_internal(void) |
1374 | 0 | { |
1375 | 0 | FuStructSynapromCmdIotaFind *st = g_new0(FuStructSynapromCmdIotaFind, 1); |
1376 | 0 | st->refcount = 1; |
1377 | 0 | return st; |
1378 | 0 | } |
1379 | | |
1380 | | /* getters */ |
1381 | | /** |
1382 | | * fu_struct_synaprom_cmd_iota_find_get_itype: (skip): |
1383 | | **/ |
1384 | | guint16 |
1385 | | fu_struct_synaprom_cmd_iota_find_get_itype(const FuStructSynapromCmdIotaFind *st) |
1386 | 0 | { |
1387 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1388 | 0 | return fu_memread_uint16(st->buf->data + 0, G_LITTLE_ENDIAN); |
1389 | 0 | } |
1390 | | /** |
1391 | | * fu_struct_synaprom_cmd_iota_find_get_flags: (skip): |
1392 | | **/ |
1393 | | guint16 |
1394 | | fu_struct_synaprom_cmd_iota_find_get_flags(const FuStructSynapromCmdIotaFind *st) |
1395 | 0 | { |
1396 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1397 | 0 | return fu_memread_uint16(st->buf->data + 2, G_LITTLE_ENDIAN); |
1398 | 0 | } |
1399 | | /** |
1400 | | * fu_struct_synaprom_cmd_iota_find_get_maxniotas: (skip): |
1401 | | **/ |
1402 | | guint8 |
1403 | | fu_struct_synaprom_cmd_iota_find_get_maxniotas(const FuStructSynapromCmdIotaFind *st) |
1404 | 0 | { |
1405 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1406 | 0 | return st->buf->data[4]; |
1407 | 0 | } |
1408 | | /** |
1409 | | * fu_struct_synaprom_cmd_iota_find_get_firstidx: (skip): |
1410 | | **/ |
1411 | | guint8 |
1412 | | fu_struct_synaprom_cmd_iota_find_get_firstidx(const FuStructSynapromCmdIotaFind *st) |
1413 | 0 | { |
1414 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1415 | 0 | return st->buf->data[5]; |
1416 | 0 | } |
1417 | | /** |
1418 | | * fu_struct_synaprom_cmd_iota_find_get_offset: (skip): |
1419 | | **/ |
1420 | | guint32 |
1421 | | fu_struct_synaprom_cmd_iota_find_get_offset(const FuStructSynapromCmdIotaFind *st) |
1422 | 0 | { |
1423 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1424 | 0 | return fu_memread_uint32(st->buf->data + 8, G_LITTLE_ENDIAN); |
1425 | 0 | } |
1426 | | /** |
1427 | | * fu_struct_synaprom_cmd_iota_find_get_nbytes: (skip): |
1428 | | **/ |
1429 | | guint32 |
1430 | | fu_struct_synaprom_cmd_iota_find_get_nbytes(const FuStructSynapromCmdIotaFind *st) |
1431 | 0 | { |
1432 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1433 | 0 | return fu_memread_uint32(st->buf->data + 12, G_LITTLE_ENDIAN); |
1434 | 0 | } |
1435 | | |
1436 | | /* setters */ |
1437 | | /** |
1438 | | * fu_struct_synaprom_cmd_iota_find_set_itype: (skip): |
1439 | | **/ |
1440 | | void |
1441 | | fu_struct_synaprom_cmd_iota_find_set_itype(FuStructSynapromCmdIotaFind *st, guint16 value) |
1442 | 0 | { |
1443 | 0 | g_return_if_fail(st != NULL); |
1444 | 0 | fu_memwrite_uint16(st->buf->data + 0, value, G_LITTLE_ENDIAN); |
1445 | 0 | } |
1446 | | /** |
1447 | | * fu_struct_synaprom_cmd_iota_find_set_flags: (skip): |
1448 | | **/ |
1449 | | void |
1450 | | fu_struct_synaprom_cmd_iota_find_set_flags(FuStructSynapromCmdIotaFind *st, guint16 value) |
1451 | 0 | { |
1452 | 0 | g_return_if_fail(st != NULL); |
1453 | 0 | fu_memwrite_uint16(st->buf->data + 2, value, G_LITTLE_ENDIAN); |
1454 | 0 | } |
1455 | | /** |
1456 | | * fu_struct_synaprom_cmd_iota_find_set_maxniotas: (skip): |
1457 | | **/ |
1458 | | void |
1459 | | fu_struct_synaprom_cmd_iota_find_set_maxniotas(FuStructSynapromCmdIotaFind *st, guint8 value) |
1460 | 0 | { |
1461 | 0 | g_return_if_fail(st != NULL); |
1462 | 0 | st->buf->data[4] = value; |
1463 | 0 | } |
1464 | | /** |
1465 | | * fu_struct_synaprom_cmd_iota_find_set_firstidx: (skip): |
1466 | | **/ |
1467 | | void |
1468 | | fu_struct_synaprom_cmd_iota_find_set_firstidx(FuStructSynapromCmdIotaFind *st, guint8 value) |
1469 | 0 | { |
1470 | 0 | g_return_if_fail(st != NULL); |
1471 | 0 | st->buf->data[5] = value; |
1472 | 0 | } |
1473 | | /** |
1474 | | * fu_struct_synaprom_cmd_iota_find_set_offset: (skip): |
1475 | | **/ |
1476 | | void |
1477 | | fu_struct_synaprom_cmd_iota_find_set_offset(FuStructSynapromCmdIotaFind *st, guint32 value) |
1478 | 0 | { |
1479 | 0 | g_return_if_fail(st != NULL); |
1480 | 0 | fu_memwrite_uint32(st->buf->data + 8, value, G_LITTLE_ENDIAN); |
1481 | 0 | } |
1482 | | /** |
1483 | | * fu_struct_synaprom_cmd_iota_find_set_nbytes: (skip): |
1484 | | **/ |
1485 | | void |
1486 | | fu_struct_synaprom_cmd_iota_find_set_nbytes(FuStructSynapromCmdIotaFind *st, guint32 value) |
1487 | 0 | { |
1488 | 0 | g_return_if_fail(st != NULL); |
1489 | 0 | fu_memwrite_uint32(st->buf->data + 12, value, G_LITTLE_ENDIAN); |
1490 | 0 | } |
1491 | | /** |
1492 | | * fu_struct_synaprom_cmd_iota_find_new: (skip): |
1493 | | **/ |
1494 | | FuStructSynapromCmdIotaFind * |
1495 | | fu_struct_synaprom_cmd_iota_find_new(void) |
1496 | 0 | { |
1497 | 0 | FuStructSynapromCmdIotaFind *st = fu_struct_synaprom_cmd_iota_find_new_internal(); |
1498 | 0 | st->buf = g_byte_array_sized_new(16); |
1499 | 0 | fu_byte_array_set_size(st->buf, 16, 0x0); |
1500 | 0 | return st; |
1501 | 0 | } |