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-ifwi-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_ifwi_cpd_ref: (skip): |
23 | | **/ |
24 | | FuStructIfwiCpd * |
25 | | fu_struct_ifwi_cpd_ref(FuStructIfwiCpd *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_ifwi_cpd_unref: (skip): |
33 | | **/ |
34 | | void |
35 | | fu_struct_ifwi_cpd_unref(FuStructIfwiCpd *st) |
36 | 2.74k | { |
37 | 2.74k | g_return_if_fail(st != NULL); |
38 | 2.74k | if (st->refcount == 0) { |
39 | 0 | g_critical("FuStructIfwiCpd refcount already zero"); |
40 | 0 | return; |
41 | 0 | } |
42 | 2.74k | if (--st->refcount > 0) |
43 | 0 | return; |
44 | 2.74k | if (st->buf != NULL) |
45 | 2.74k | g_byte_array_unref(st->buf); |
46 | 2.74k | g_free(st); |
47 | 2.74k | } |
48 | | /** |
49 | | * fu_struct_ifwi_cpd_new_internal: (skip): |
50 | | **/ |
51 | | static FuStructIfwiCpd * |
52 | | fu_struct_ifwi_cpd_new_internal(void) |
53 | 2.74k | { |
54 | 2.74k | FuStructIfwiCpd *st = g_new0(FuStructIfwiCpd, 1); |
55 | 2.74k | st->refcount = 1; |
56 | 2.74k | return st; |
57 | 2.74k | } |
58 | | |
59 | | /* getters */ |
60 | | /** |
61 | | * fu_struct_ifwi_cpd_get_header_marker: (skip): |
62 | | **/ |
63 | | static guint32 |
64 | | fu_struct_ifwi_cpd_get_header_marker(const FuStructIfwiCpd *st) |
65 | 2.71k | { |
66 | 2.71k | g_return_val_if_fail(st != NULL, 0x0); |
67 | 2.71k | return fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
68 | 2.71k | } |
69 | | /** |
70 | | * fu_struct_ifwi_cpd_get_num_of_entries: (skip): |
71 | | **/ |
72 | | guint32 |
73 | | fu_struct_ifwi_cpd_get_num_of_entries(const FuStructIfwiCpd *st) |
74 | 1.24k | { |
75 | 1.24k | g_return_val_if_fail(st != NULL, 0x0); |
76 | 1.24k | return fu_memread_uint32(st->buf->data + 4, G_LITTLE_ENDIAN); |
77 | 1.24k | } |
78 | | /** |
79 | | * fu_struct_ifwi_cpd_get_header_version: (skip): |
80 | | **/ |
81 | | guint8 |
82 | | fu_struct_ifwi_cpd_get_header_version(const FuStructIfwiCpd *st) |
83 | 1.24k | { |
84 | 1.24k | g_return_val_if_fail(st != NULL, 0x0); |
85 | 1.24k | return st->buf->data[8]; |
86 | 1.24k | } |
87 | | /** |
88 | | * fu_struct_ifwi_cpd_get_entry_version: (skip): |
89 | | **/ |
90 | | guint8 |
91 | | fu_struct_ifwi_cpd_get_entry_version(const FuStructIfwiCpd *st) |
92 | 1.24k | { |
93 | 1.24k | g_return_val_if_fail(st != NULL, 0x0); |
94 | 1.24k | return st->buf->data[9]; |
95 | 1.24k | } |
96 | | /** |
97 | | * fu_struct_ifwi_cpd_get_header_length: (skip): |
98 | | **/ |
99 | | guint8 |
100 | | fu_struct_ifwi_cpd_get_header_length(const FuStructIfwiCpd *st) |
101 | 1.18k | { |
102 | 1.18k | g_return_val_if_fail(st != NULL, 0x0); |
103 | 1.18k | return st->buf->data[10]; |
104 | 1.18k | } |
105 | | /** |
106 | | * fu_struct_ifwi_cpd_get_checksum: (skip): |
107 | | **/ |
108 | | guint8 |
109 | | fu_struct_ifwi_cpd_get_checksum(const FuStructIfwiCpd *st) |
110 | 0 | { |
111 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
112 | 0 | return st->buf->data[11]; |
113 | 0 | } |
114 | | /** |
115 | | * fu_struct_ifwi_cpd_get_partition_name: (skip): |
116 | | **/ |
117 | | guint32 |
118 | | fu_struct_ifwi_cpd_get_partition_name(const FuStructIfwiCpd *st) |
119 | 1.24k | { |
120 | 1.24k | g_return_val_if_fail(st != NULL, 0x0); |
121 | 1.24k | return fu_memread_uint32(st->buf->data + 12, G_LITTLE_ENDIAN); |
122 | 1.24k | } |
123 | | /** |
124 | | * fu_struct_ifwi_cpd_get_crc32: (skip): |
125 | | **/ |
126 | | guint32 |
127 | | fu_struct_ifwi_cpd_get_crc32(const FuStructIfwiCpd *st) |
128 | 0 | { |
129 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
130 | 0 | return fu_memread_uint32(st->buf->data + 16, G_LITTLE_ENDIAN); |
131 | 0 | } |
132 | | |
133 | | /* setters */ |
134 | | /** |
135 | | * fu_struct_ifwi_cpd_set_header_marker: (skip): |
136 | | **/ |
137 | | static void |
138 | | fu_struct_ifwi_cpd_set_header_marker(FuStructIfwiCpd *st, guint32 value) |
139 | 106 | { |
140 | 106 | g_return_if_fail(st != NULL); |
141 | 106 | fu_memwrite_uint32(st->buf->data + 0, value, G_LITTLE_ENDIAN); |
142 | 106 | } |
143 | | /** |
144 | | * fu_struct_ifwi_cpd_set_num_of_entries: (skip): |
145 | | **/ |
146 | | void |
147 | | fu_struct_ifwi_cpd_set_num_of_entries(FuStructIfwiCpd *st, guint32 value) |
148 | 106 | { |
149 | 106 | g_return_if_fail(st != NULL); |
150 | 106 | fu_memwrite_uint32(st->buf->data + 4, value, G_LITTLE_ENDIAN); |
151 | 106 | } |
152 | | /** |
153 | | * fu_struct_ifwi_cpd_set_header_version: (skip): |
154 | | **/ |
155 | | void |
156 | | fu_struct_ifwi_cpd_set_header_version(FuStructIfwiCpd *st, guint8 value) |
157 | 106 | { |
158 | 106 | g_return_if_fail(st != NULL); |
159 | 106 | st->buf->data[8] = value; |
160 | 106 | } |
161 | | /** |
162 | | * fu_struct_ifwi_cpd_set_entry_version: (skip): |
163 | | **/ |
164 | | void |
165 | | fu_struct_ifwi_cpd_set_entry_version(FuStructIfwiCpd *st, guint8 value) |
166 | 106 | { |
167 | 106 | g_return_if_fail(st != NULL); |
168 | 106 | st->buf->data[9] = value; |
169 | 106 | } |
170 | | /** |
171 | | * fu_struct_ifwi_cpd_set_header_length: (skip): |
172 | | **/ |
173 | | void |
174 | | fu_struct_ifwi_cpd_set_header_length(FuStructIfwiCpd *st, guint8 value) |
175 | 106 | { |
176 | 106 | g_return_if_fail(st != NULL); |
177 | 106 | st->buf->data[10] = value; |
178 | 106 | } |
179 | | /** |
180 | | * fu_struct_ifwi_cpd_set_checksum: (skip): |
181 | | **/ |
182 | | void |
183 | | fu_struct_ifwi_cpd_set_checksum(FuStructIfwiCpd *st, guint8 value) |
184 | 106 | { |
185 | 106 | g_return_if_fail(st != NULL); |
186 | 106 | st->buf->data[11] = value; |
187 | 106 | } |
188 | | /** |
189 | | * fu_struct_ifwi_cpd_set_partition_name: (skip): |
190 | | **/ |
191 | | void |
192 | | fu_struct_ifwi_cpd_set_partition_name(FuStructIfwiCpd *st, guint32 value) |
193 | 106 | { |
194 | 106 | g_return_if_fail(st != NULL); |
195 | 106 | fu_memwrite_uint32(st->buf->data + 12, value, G_LITTLE_ENDIAN); |
196 | 106 | } |
197 | | /** |
198 | | * fu_struct_ifwi_cpd_set_crc32: (skip): |
199 | | **/ |
200 | | void |
201 | | fu_struct_ifwi_cpd_set_crc32(FuStructIfwiCpd *st, guint32 value) |
202 | 106 | { |
203 | 106 | g_return_if_fail(st != NULL); |
204 | 106 | fu_memwrite_uint32(st->buf->data + 16, value, G_LITTLE_ENDIAN); |
205 | 106 | } |
206 | | /** |
207 | | * fu_struct_ifwi_cpd_new: (skip): |
208 | | **/ |
209 | | FuStructIfwiCpd * |
210 | | fu_struct_ifwi_cpd_new(void) |
211 | 106 | { |
212 | 106 | FuStructIfwiCpd *st = fu_struct_ifwi_cpd_new_internal(); |
213 | 106 | st->buf = g_byte_array_sized_new(20); |
214 | 106 | fu_byte_array_set_size(st->buf, 20, 0x0); |
215 | 106 | fu_struct_ifwi_cpd_set_header_marker(st, 0x44504324); |
216 | 106 | fu_struct_ifwi_cpd_set_header_length(st, 20); |
217 | 106 | return st; |
218 | 106 | } |
219 | | /** |
220 | | * fu_struct_ifwi_cpd_to_string: (skip): |
221 | | **/ |
222 | | static gchar * |
223 | | fu_struct_ifwi_cpd_to_string(const FuStructIfwiCpd *st) |
224 | 0 | { |
225 | 0 | g_autoptr(GString) str = g_string_new("FuStructIfwiCpd:\n"); |
226 | 0 | g_return_val_if_fail(st != NULL, NULL); |
227 | 0 | g_string_append_printf(str, " header_marker: 0x%x\n", |
228 | 0 | (guint) fu_struct_ifwi_cpd_get_header_marker(st)); |
229 | 0 | g_string_append_printf(str, " num_of_entries: 0x%x\n", |
230 | 0 | (guint) fu_struct_ifwi_cpd_get_num_of_entries(st)); |
231 | 0 | g_string_append_printf(str, " header_version: 0x%x\n", |
232 | 0 | (guint) fu_struct_ifwi_cpd_get_header_version(st)); |
233 | 0 | g_string_append_printf(str, " entry_version: 0x%x\n", |
234 | 0 | (guint) fu_struct_ifwi_cpd_get_entry_version(st)); |
235 | 0 | g_string_append_printf(str, " header_length: 0x%x\n", |
236 | 0 | (guint) fu_struct_ifwi_cpd_get_header_length(st)); |
237 | 0 | g_string_append_printf(str, " checksum: 0x%x\n", |
238 | 0 | (guint) fu_struct_ifwi_cpd_get_checksum(st)); |
239 | 0 | g_string_append_printf(str, " partition_name: 0x%x\n", |
240 | 0 | (guint) fu_struct_ifwi_cpd_get_partition_name(st)); |
241 | 0 | g_string_append_printf(str, " crc32: 0x%x\n", |
242 | 0 | (guint) fu_struct_ifwi_cpd_get_crc32(st)); |
243 | 0 | if (str->len > 0) |
244 | 0 | g_string_set_size(str, str->len - 1); |
245 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
246 | 0 | } |
247 | | static gboolean |
248 | | fu_struct_ifwi_cpd_validate_internal(FuStructIfwiCpd *st, GError **error) |
249 | 2.60k | { |
250 | 2.60k | g_return_val_if_fail(st != NULL, FALSE); |
251 | 2.60k | if (fu_struct_ifwi_cpd_get_header_marker(st) != 0x44504324) { |
252 | 112 | g_set_error(error, |
253 | 112 | FWUPD_ERROR, |
254 | 112 | FWUPD_ERROR_INVALID_DATA, |
255 | 112 | "constant FuStructIfwiCpd.header_marker was not valid, " |
256 | 112 | "expected 0x%x and got 0x%x", |
257 | 112 | (guint) 0x44504324, |
258 | 112 | (guint) fu_struct_ifwi_cpd_get_header_marker(st)); |
259 | 112 | return FALSE; |
260 | 112 | } |
261 | 2.49k | return TRUE; |
262 | 2.60k | } |
263 | | /** |
264 | | * fu_struct_ifwi_cpd_validate_stream: (skip): |
265 | | **/ |
266 | | gboolean |
267 | | fu_struct_ifwi_cpd_validate_stream(GInputStream *stream, gsize offset, GError **error) |
268 | 1.39k | { |
269 | 1.39k | g_autoptr(FuStructIfwiCpd) st = fu_struct_ifwi_cpd_new_internal(); |
270 | 1.39k | g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE); |
271 | 1.39k | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
272 | 1.39k | st->buf = fu_input_stream_read_byte_array(stream, offset, 20, NULL, error); |
273 | 1.39k | if (st->buf == NULL) { |
274 | 0 | g_prefix_error(error, "FuStructIfwiCpd failed read of 0x%x: ", (guint) 20); |
275 | 0 | return FALSE; |
276 | 0 | } |
277 | 1.39k | if (st->buf->len != 20) { |
278 | 35 | g_set_error(error, |
279 | 35 | FWUPD_ERROR, |
280 | 35 | FWUPD_ERROR_INVALID_DATA, |
281 | 35 | "FuStructIfwiCpd requested 0x%x and got 0x%x", |
282 | 35 | (guint) 20, |
283 | 35 | (guint) st->buf->len); |
284 | 35 | return FALSE; |
285 | 35 | } |
286 | 1.35k | return fu_struct_ifwi_cpd_validate_internal(st, error); |
287 | 1.39k | } |
288 | | static gboolean |
289 | | fu_struct_ifwi_cpd_parse_internal(FuStructIfwiCpd *st, GError **error) |
290 | 1.24k | { |
291 | 1.24k | if (g_log_get_debug_enabled()) { |
292 | 0 | g_autofree gchar *str = fu_struct_ifwi_cpd_to_string(st); |
293 | 0 | g_debug("%s", str); |
294 | 0 | } |
295 | 1.24k | if (!fu_struct_ifwi_cpd_validate_internal(st, error)) |
296 | 0 | return FALSE; |
297 | 1.24k | return TRUE; |
298 | 1.24k | } |
299 | | /** |
300 | | * fu_struct_ifwi_cpd_parse_stream: (skip): |
301 | | **/ |
302 | | FuStructIfwiCpd * |
303 | | fu_struct_ifwi_cpd_parse_stream(GInputStream *stream, gsize offset, GError **error) |
304 | 1.24k | { |
305 | 1.24k | g_autoptr(FuStructIfwiCpd) st = fu_struct_ifwi_cpd_new_internal(); |
306 | 1.24k | st->buf = fu_input_stream_read_byte_array(stream, offset, 20, NULL, error); |
307 | 1.24k | if (st->buf == NULL) { |
308 | 0 | g_prefix_error(error, "FuStructIfwiCpd failed read of 0x%x: ", (guint) 20); |
309 | 0 | return NULL; |
310 | 0 | } |
311 | 1.24k | if (st->buf->len != 20) { |
312 | 0 | g_set_error(error, |
313 | 0 | FWUPD_ERROR, |
314 | 0 | FWUPD_ERROR_INVALID_DATA, |
315 | 0 | "FuStructIfwiCpd requested 0x%x and got 0x%x", |
316 | 0 | (guint) 20, |
317 | 0 | (guint) st->buf->len); |
318 | 0 | return NULL; |
319 | 0 | } |
320 | 1.24k | if (!fu_struct_ifwi_cpd_parse_internal(st, error)) |
321 | 0 | return NULL; |
322 | 1.24k | return g_steal_pointer(&st); |
323 | 1.24k | } |
324 | | /** |
325 | | * fu_struct_ifwi_cpd_entry_ref: (skip): |
326 | | **/ |
327 | | FuStructIfwiCpdEntry * |
328 | | fu_struct_ifwi_cpd_entry_ref(FuStructIfwiCpdEntry *st) |
329 | 0 | { |
330 | 0 | g_return_val_if_fail(st != NULL, NULL); |
331 | 0 | st->refcount++; |
332 | 0 | return st; |
333 | 0 | } |
334 | | /** |
335 | | * fu_struct_ifwi_cpd_entry_unref: (skip): |
336 | | **/ |
337 | | void |
338 | | fu_struct_ifwi_cpd_entry_unref(FuStructIfwiCpdEntry *st) |
339 | 47.8k | { |
340 | 47.8k | g_return_if_fail(st != NULL); |
341 | 47.8k | if (st->refcount == 0) { |
342 | 0 | g_critical("FuStructIfwiCpdEntry refcount already zero"); |
343 | 0 | return; |
344 | 0 | } |
345 | 47.8k | if (--st->refcount > 0) |
346 | 0 | return; |
347 | 47.8k | if (st->buf != NULL) |
348 | 47.6k | g_byte_array_unref(st->buf); |
349 | 47.8k | g_free(st); |
350 | 47.8k | } |
351 | | /** |
352 | | * fu_struct_ifwi_cpd_entry_new_internal: (skip): |
353 | | **/ |
354 | | static FuStructIfwiCpdEntry * |
355 | | fu_struct_ifwi_cpd_entry_new_internal(void) |
356 | 47.8k | { |
357 | 47.8k | FuStructIfwiCpdEntry *st = g_new0(FuStructIfwiCpdEntry, 1); |
358 | 47.8k | st->refcount = 1; |
359 | 47.8k | return st; |
360 | 47.8k | } |
361 | | |
362 | | /* getters */ |
363 | | /** |
364 | | * fu_struct_ifwi_cpd_entry_get_name: (skip): |
365 | | **/ |
366 | | gchar * |
367 | | fu_struct_ifwi_cpd_entry_get_name(const FuStructIfwiCpdEntry *st) |
368 | 47.5k | { |
369 | 47.5k | g_return_val_if_fail(st != NULL, NULL); |
370 | 47.5k | return fu_memstrsafe(st->buf->data, st->buf->len, 0, 12, NULL); |
371 | 47.5k | } |
372 | | /** |
373 | | * fu_struct_ifwi_cpd_entry_get_offset: (skip): |
374 | | **/ |
375 | | guint32 |
376 | | fu_struct_ifwi_cpd_entry_get_offset(const FuStructIfwiCpdEntry *st) |
377 | 47.5k | { |
378 | 47.5k | g_return_val_if_fail(st != NULL, 0x0); |
379 | 47.5k | return fu_memread_uint32(st->buf->data + 12, G_LITTLE_ENDIAN); |
380 | 47.5k | } |
381 | | /** |
382 | | * fu_struct_ifwi_cpd_entry_get_length: (skip): |
383 | | **/ |
384 | | guint32 |
385 | | fu_struct_ifwi_cpd_entry_get_length(const FuStructIfwiCpdEntry *st) |
386 | 48.5k | { |
387 | 48.5k | g_return_val_if_fail(st != NULL, 0x0); |
388 | 48.5k | return fu_memread_uint32(st->buf->data + 16, G_LITTLE_ENDIAN); |
389 | 48.5k | } |
390 | | |
391 | | /* setters */ |
392 | | /** |
393 | | * fu_struct_ifwi_cpd_entry_set_name: (skip): |
394 | | **/ |
395 | | gboolean |
396 | | fu_struct_ifwi_cpd_entry_set_name(FuStructIfwiCpdEntry *st, const gchar *value, GError **error) |
397 | 0 | { |
398 | 0 | gsize len; |
399 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
400 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
401 | 0 | if (value == NULL) { |
402 | 0 | memset(st->buf->data + 0, 0x0, 12); |
403 | 0 | return TRUE; |
404 | 0 | } |
405 | 0 | len = strlen(value); |
406 | 0 | if (len > 12) { |
407 | 0 | g_set_error(error, |
408 | 0 | FWUPD_ERROR, |
409 | 0 | FWUPD_ERROR_INVALID_DATA, |
410 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructIfwiCpdEntry.name (0x%x bytes)", |
411 | 0 | value, (guint) len, (guint) 12); |
412 | 0 | return FALSE; |
413 | 0 | } |
414 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 0, (const guint8 *)value, len, 0x0, len, error); |
415 | 0 | } |
416 | | /** |
417 | | * fu_struct_ifwi_cpd_entry_set_offset: (skip): |
418 | | **/ |
419 | | void |
420 | | fu_struct_ifwi_cpd_entry_set_offset(FuStructIfwiCpdEntry *st, guint32 value) |
421 | 0 | { |
422 | 0 | g_return_if_fail(st != NULL); |
423 | 0 | fu_memwrite_uint32(st->buf->data + 12, value, G_LITTLE_ENDIAN); |
424 | 0 | } |
425 | | /** |
426 | | * fu_struct_ifwi_cpd_entry_set_length: (skip): |
427 | | **/ |
428 | | void |
429 | | fu_struct_ifwi_cpd_entry_set_length(FuStructIfwiCpdEntry *st, guint32 value) |
430 | 0 | { |
431 | 0 | g_return_if_fail(st != NULL); |
432 | 0 | fu_memwrite_uint32(st->buf->data + 16, value, G_LITTLE_ENDIAN); |
433 | 0 | } |
434 | | /** |
435 | | * fu_struct_ifwi_cpd_entry_new: (skip): |
436 | | **/ |
437 | | FuStructIfwiCpdEntry * |
438 | | fu_struct_ifwi_cpd_entry_new(void) |
439 | 0 | { |
440 | 0 | FuStructIfwiCpdEntry *st = fu_struct_ifwi_cpd_entry_new_internal(); |
441 | 0 | st->buf = g_byte_array_sized_new(24); |
442 | 0 | fu_byte_array_set_size(st->buf, 24, 0x0); |
443 | 0 | return st; |
444 | 0 | } |
445 | | /** |
446 | | * fu_struct_ifwi_cpd_entry_to_string: (skip): |
447 | | **/ |
448 | | static gchar * |
449 | | fu_struct_ifwi_cpd_entry_to_string(const FuStructIfwiCpdEntry *st) |
450 | 0 | { |
451 | 0 | g_autoptr(GString) str = g_string_new("FuStructIfwiCpdEntry:\n"); |
452 | 0 | g_return_val_if_fail(st != NULL, NULL); |
453 | 0 | { |
454 | 0 | g_autofree gchar *tmp = fu_struct_ifwi_cpd_entry_get_name(st); |
455 | 0 | if (tmp != NULL) |
456 | 0 | g_string_append_printf(str, " name: %s\n", tmp); |
457 | 0 | } |
458 | 0 | g_string_append_printf(str, " offset: 0x%x\n", |
459 | 0 | (guint) fu_struct_ifwi_cpd_entry_get_offset(st)); |
460 | 0 | g_string_append_printf(str, " length: 0x%x\n", |
461 | 0 | (guint) fu_struct_ifwi_cpd_entry_get_length(st)); |
462 | 0 | if (str->len > 0) |
463 | 0 | g_string_set_size(str, str->len - 1); |
464 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
465 | 0 | } |
466 | | static gboolean |
467 | | fu_struct_ifwi_cpd_entry_parse_internal(FuStructIfwiCpdEntry *st, GError **error) |
468 | 47.5k | { |
469 | 47.5k | if (g_log_get_debug_enabled()) { |
470 | 0 | g_autofree gchar *str = fu_struct_ifwi_cpd_entry_to_string(st); |
471 | 0 | g_debug("%s", str); |
472 | 0 | } |
473 | 47.5k | return TRUE; |
474 | 47.5k | } |
475 | | /** |
476 | | * fu_struct_ifwi_cpd_entry_parse_stream: (skip): |
477 | | **/ |
478 | | FuStructIfwiCpdEntry * |
479 | | fu_struct_ifwi_cpd_entry_parse_stream(GInputStream *stream, gsize offset, GError **error) |
480 | 47.8k | { |
481 | 47.8k | g_autoptr(FuStructIfwiCpdEntry) st = fu_struct_ifwi_cpd_entry_new_internal(); |
482 | 47.8k | st->buf = fu_input_stream_read_byte_array(stream, offset, 24, NULL, error); |
483 | 47.8k | if (st->buf == NULL) { |
484 | 169 | g_prefix_error(error, "FuStructIfwiCpdEntry failed read of 0x%x: ", (guint) 24); |
485 | 169 | return NULL; |
486 | 169 | } |
487 | 47.6k | if (st->buf->len != 24) { |
488 | 125 | g_set_error(error, |
489 | 125 | FWUPD_ERROR, |
490 | 125 | FWUPD_ERROR_INVALID_DATA, |
491 | 125 | "FuStructIfwiCpdEntry requested 0x%x and got 0x%x", |
492 | 125 | (guint) 24, |
493 | 125 | (guint) st->buf->len); |
494 | 125 | return NULL; |
495 | 125 | } |
496 | 47.5k | if (!fu_struct_ifwi_cpd_entry_parse_internal(st, error)) |
497 | 0 | return NULL; |
498 | 47.5k | return g_steal_pointer(&st); |
499 | 47.5k | } |
500 | | /** |
501 | | * fu_struct_ifwi_cpd_manifest_ref: (skip): |
502 | | **/ |
503 | | FuStructIfwiCpdManifest * |
504 | | fu_struct_ifwi_cpd_manifest_ref(FuStructIfwiCpdManifest *st) |
505 | 0 | { |
506 | 0 | g_return_val_if_fail(st != NULL, NULL); |
507 | 0 | st->refcount++; |
508 | 0 | return st; |
509 | 0 | } |
510 | | /** |
511 | | * fu_struct_ifwi_cpd_manifest_unref: (skip): |
512 | | **/ |
513 | | void |
514 | | fu_struct_ifwi_cpd_manifest_unref(FuStructIfwiCpdManifest *st) |
515 | 756 | { |
516 | 756 | g_return_if_fail(st != NULL); |
517 | 756 | if (st->refcount == 0) { |
518 | 0 | g_critical("FuStructIfwiCpdManifest refcount already zero"); |
519 | 0 | return; |
520 | 0 | } |
521 | 756 | if (--st->refcount > 0) |
522 | 0 | return; |
523 | 756 | if (st->buf != NULL) |
524 | 756 | g_byte_array_unref(st->buf); |
525 | 756 | g_free(st); |
526 | 756 | } |
527 | | /** |
528 | | * fu_struct_ifwi_cpd_manifest_new_internal: (skip): |
529 | | **/ |
530 | | static FuStructIfwiCpdManifest * |
531 | | fu_struct_ifwi_cpd_manifest_new_internal(void) |
532 | 756 | { |
533 | 756 | FuStructIfwiCpdManifest *st = g_new0(FuStructIfwiCpdManifest, 1); |
534 | 756 | st->refcount = 1; |
535 | 756 | return st; |
536 | 756 | } |
537 | | |
538 | | /* getters */ |
539 | | /** |
540 | | * fu_struct_ifwi_cpd_manifest_get_header_type: (skip): |
541 | | **/ |
542 | | guint32 |
543 | | fu_struct_ifwi_cpd_manifest_get_header_type(const FuStructIfwiCpdManifest *st) |
544 | 0 | { |
545 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
546 | 0 | return fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
547 | 0 | } |
548 | | /** |
549 | | * fu_struct_ifwi_cpd_manifest_get_header_length: (skip): |
550 | | **/ |
551 | | guint32 |
552 | | fu_struct_ifwi_cpd_manifest_get_header_length(const FuStructIfwiCpdManifest *st) |
553 | 598 | { |
554 | 598 | g_return_val_if_fail(st != NULL, 0x0); |
555 | 598 | return fu_memread_uint32(st->buf->data + 4, G_LITTLE_ENDIAN); |
556 | 598 | } |
557 | | /** |
558 | | * fu_struct_ifwi_cpd_manifest_get_header_version: (skip): |
559 | | **/ |
560 | | guint32 |
561 | | fu_struct_ifwi_cpd_manifest_get_header_version(const FuStructIfwiCpdManifest *st) |
562 | 0 | { |
563 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
564 | 0 | return fu_memread_uint32(st->buf->data + 8, G_LITTLE_ENDIAN); |
565 | 0 | } |
566 | | /** |
567 | | * fu_struct_ifwi_cpd_manifest_get_flags: (skip): |
568 | | **/ |
569 | | guint32 |
570 | | fu_struct_ifwi_cpd_manifest_get_flags(const FuStructIfwiCpdManifest *st) |
571 | 0 | { |
572 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
573 | 0 | return fu_memread_uint32(st->buf->data + 12, G_LITTLE_ENDIAN); |
574 | 0 | } |
575 | | /** |
576 | | * fu_struct_ifwi_cpd_manifest_get_vendor: (skip): |
577 | | **/ |
578 | | guint32 |
579 | | fu_struct_ifwi_cpd_manifest_get_vendor(const FuStructIfwiCpdManifest *st) |
580 | 0 | { |
581 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
582 | 0 | return fu_memread_uint32(st->buf->data + 16, G_LITTLE_ENDIAN); |
583 | 0 | } |
584 | | /** |
585 | | * fu_struct_ifwi_cpd_manifest_get_date: (skip): |
586 | | **/ |
587 | | guint32 |
588 | | fu_struct_ifwi_cpd_manifest_get_date(const FuStructIfwiCpdManifest *st) |
589 | 0 | { |
590 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
591 | 0 | return fu_memread_uint32(st->buf->data + 20, G_LITTLE_ENDIAN); |
592 | 0 | } |
593 | | /** |
594 | | * fu_struct_ifwi_cpd_manifest_get_size: (skip): |
595 | | **/ |
596 | | guint32 |
597 | | fu_struct_ifwi_cpd_manifest_get_size(const FuStructIfwiCpdManifest *st) |
598 | 756 | { |
599 | 756 | g_return_val_if_fail(st != NULL, 0x0); |
600 | 756 | return fu_memread_uint32(st->buf->data + 24, G_LITTLE_ENDIAN); |
601 | 756 | } |
602 | | /** |
603 | | * fu_struct_ifwi_cpd_manifest_get_id: (skip): |
604 | | **/ |
605 | | guint32 |
606 | | fu_struct_ifwi_cpd_manifest_get_id(const FuStructIfwiCpdManifest *st) |
607 | 0 | { |
608 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
609 | 0 | return fu_memread_uint32(st->buf->data + 28, G_LITTLE_ENDIAN); |
610 | 0 | } |
611 | | /** |
612 | | * fu_struct_ifwi_cpd_manifest_get_rsvd: (skip): |
613 | | **/ |
614 | | guint32 |
615 | | fu_struct_ifwi_cpd_manifest_get_rsvd(const FuStructIfwiCpdManifest *st) |
616 | 0 | { |
617 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
618 | 0 | return fu_memread_uint32(st->buf->data + 32, G_LITTLE_ENDIAN); |
619 | 0 | } |
620 | | /** |
621 | | * fu_struct_ifwi_cpd_manifest_get_version_major: (skip): |
622 | | **/ |
623 | | guint16 |
624 | | fu_struct_ifwi_cpd_manifest_get_version_major(const FuStructIfwiCpdManifest *st) |
625 | 756 | { |
626 | 756 | g_return_val_if_fail(st != NULL, 0x0); |
627 | 756 | return fu_memread_uint16(st->buf->data + 36, G_LITTLE_ENDIAN); |
628 | 756 | } |
629 | | /** |
630 | | * fu_struct_ifwi_cpd_manifest_get_version_minor: (skip): |
631 | | **/ |
632 | | guint16 |
633 | | fu_struct_ifwi_cpd_manifest_get_version_minor(const FuStructIfwiCpdManifest *st) |
634 | 756 | { |
635 | 756 | g_return_val_if_fail(st != NULL, 0x0); |
636 | 756 | return fu_memread_uint16(st->buf->data + 38, G_LITTLE_ENDIAN); |
637 | 756 | } |
638 | | /** |
639 | | * fu_struct_ifwi_cpd_manifest_get_version_hotfix: (skip): |
640 | | **/ |
641 | | guint16 |
642 | | fu_struct_ifwi_cpd_manifest_get_version_hotfix(const FuStructIfwiCpdManifest *st) |
643 | 756 | { |
644 | 756 | g_return_val_if_fail(st != NULL, 0x0); |
645 | 756 | return fu_memread_uint16(st->buf->data + 40, G_LITTLE_ENDIAN); |
646 | 756 | } |
647 | | /** |
648 | | * fu_struct_ifwi_cpd_manifest_get_version_build: (skip): |
649 | | **/ |
650 | | guint16 |
651 | | fu_struct_ifwi_cpd_manifest_get_version_build(const FuStructIfwiCpdManifest *st) |
652 | 756 | { |
653 | 756 | g_return_val_if_fail(st != NULL, 0x0); |
654 | 756 | return fu_memread_uint16(st->buf->data + 42, G_LITTLE_ENDIAN); |
655 | 756 | } |
656 | | /** |
657 | | * fu_struct_ifwi_cpd_manifest_get_svn: (skip): |
658 | | **/ |
659 | | guint32 |
660 | | fu_struct_ifwi_cpd_manifest_get_svn(const FuStructIfwiCpdManifest *st) |
661 | 0 | { |
662 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
663 | 0 | return fu_memread_uint32(st->buf->data + 44, G_LITTLE_ENDIAN); |
664 | 0 | } |
665 | | |
666 | | /* setters */ |
667 | | /** |
668 | | * fu_struct_ifwi_cpd_manifest_set_header_type: (skip): |
669 | | **/ |
670 | | void |
671 | | fu_struct_ifwi_cpd_manifest_set_header_type(FuStructIfwiCpdManifest *st, guint32 value) |
672 | 0 | { |
673 | 0 | g_return_if_fail(st != NULL); |
674 | 0 | fu_memwrite_uint32(st->buf->data + 0, value, G_LITTLE_ENDIAN); |
675 | 0 | } |
676 | | /** |
677 | | * fu_struct_ifwi_cpd_manifest_set_header_length: (skip): |
678 | | **/ |
679 | | void |
680 | | fu_struct_ifwi_cpd_manifest_set_header_length(FuStructIfwiCpdManifest *st, guint32 value) |
681 | 0 | { |
682 | 0 | g_return_if_fail(st != NULL); |
683 | 0 | fu_memwrite_uint32(st->buf->data + 4, value, G_LITTLE_ENDIAN); |
684 | 0 | } |
685 | | /** |
686 | | * fu_struct_ifwi_cpd_manifest_set_header_version: (skip): |
687 | | **/ |
688 | | void |
689 | | fu_struct_ifwi_cpd_manifest_set_header_version(FuStructIfwiCpdManifest *st, guint32 value) |
690 | 0 | { |
691 | 0 | g_return_if_fail(st != NULL); |
692 | 0 | fu_memwrite_uint32(st->buf->data + 8, value, G_LITTLE_ENDIAN); |
693 | 0 | } |
694 | | /** |
695 | | * fu_struct_ifwi_cpd_manifest_set_flags: (skip): |
696 | | **/ |
697 | | void |
698 | | fu_struct_ifwi_cpd_manifest_set_flags(FuStructIfwiCpdManifest *st, guint32 value) |
699 | 0 | { |
700 | 0 | g_return_if_fail(st != NULL); |
701 | 0 | fu_memwrite_uint32(st->buf->data + 12, value, G_LITTLE_ENDIAN); |
702 | 0 | } |
703 | | /** |
704 | | * fu_struct_ifwi_cpd_manifest_set_vendor: (skip): |
705 | | **/ |
706 | | void |
707 | | fu_struct_ifwi_cpd_manifest_set_vendor(FuStructIfwiCpdManifest *st, guint32 value) |
708 | 0 | { |
709 | 0 | g_return_if_fail(st != NULL); |
710 | 0 | fu_memwrite_uint32(st->buf->data + 16, value, G_LITTLE_ENDIAN); |
711 | 0 | } |
712 | | /** |
713 | | * fu_struct_ifwi_cpd_manifest_set_date: (skip): |
714 | | **/ |
715 | | void |
716 | | fu_struct_ifwi_cpd_manifest_set_date(FuStructIfwiCpdManifest *st, guint32 value) |
717 | 0 | { |
718 | 0 | g_return_if_fail(st != NULL); |
719 | 0 | fu_memwrite_uint32(st->buf->data + 20, value, G_LITTLE_ENDIAN); |
720 | 0 | } |
721 | | /** |
722 | | * fu_struct_ifwi_cpd_manifest_set_size: (skip): |
723 | | **/ |
724 | | void |
725 | | fu_struct_ifwi_cpd_manifest_set_size(FuStructIfwiCpdManifest *st, guint32 value) |
726 | 0 | { |
727 | 0 | g_return_if_fail(st != NULL); |
728 | 0 | fu_memwrite_uint32(st->buf->data + 24, value, G_LITTLE_ENDIAN); |
729 | 0 | } |
730 | | /** |
731 | | * fu_struct_ifwi_cpd_manifest_set_id: (skip): |
732 | | **/ |
733 | | void |
734 | | fu_struct_ifwi_cpd_manifest_set_id(FuStructIfwiCpdManifest *st, guint32 value) |
735 | 0 | { |
736 | 0 | g_return_if_fail(st != NULL); |
737 | 0 | fu_memwrite_uint32(st->buf->data + 28, value, G_LITTLE_ENDIAN); |
738 | 0 | } |
739 | | /** |
740 | | * fu_struct_ifwi_cpd_manifest_set_rsvd: (skip): |
741 | | **/ |
742 | | void |
743 | | fu_struct_ifwi_cpd_manifest_set_rsvd(FuStructIfwiCpdManifest *st, guint32 value) |
744 | 0 | { |
745 | 0 | g_return_if_fail(st != NULL); |
746 | 0 | fu_memwrite_uint32(st->buf->data + 32, value, G_LITTLE_ENDIAN); |
747 | 0 | } |
748 | | /** |
749 | | * fu_struct_ifwi_cpd_manifest_set_version_major: (skip): |
750 | | **/ |
751 | | void |
752 | | fu_struct_ifwi_cpd_manifest_set_version_major(FuStructIfwiCpdManifest *st, guint16 value) |
753 | 0 | { |
754 | 0 | g_return_if_fail(st != NULL); |
755 | 0 | fu_memwrite_uint16(st->buf->data + 36, value, G_LITTLE_ENDIAN); |
756 | 0 | } |
757 | | /** |
758 | | * fu_struct_ifwi_cpd_manifest_set_version_minor: (skip): |
759 | | **/ |
760 | | void |
761 | | fu_struct_ifwi_cpd_manifest_set_version_minor(FuStructIfwiCpdManifest *st, guint16 value) |
762 | 0 | { |
763 | 0 | g_return_if_fail(st != NULL); |
764 | 0 | fu_memwrite_uint16(st->buf->data + 38, value, G_LITTLE_ENDIAN); |
765 | 0 | } |
766 | | /** |
767 | | * fu_struct_ifwi_cpd_manifest_set_version_hotfix: (skip): |
768 | | **/ |
769 | | void |
770 | | fu_struct_ifwi_cpd_manifest_set_version_hotfix(FuStructIfwiCpdManifest *st, guint16 value) |
771 | 0 | { |
772 | 0 | g_return_if_fail(st != NULL); |
773 | 0 | fu_memwrite_uint16(st->buf->data + 40, value, G_LITTLE_ENDIAN); |
774 | 0 | } |
775 | | /** |
776 | | * fu_struct_ifwi_cpd_manifest_set_version_build: (skip): |
777 | | **/ |
778 | | void |
779 | | fu_struct_ifwi_cpd_manifest_set_version_build(FuStructIfwiCpdManifest *st, guint16 value) |
780 | 0 | { |
781 | 0 | g_return_if_fail(st != NULL); |
782 | 0 | fu_memwrite_uint16(st->buf->data + 42, value, G_LITTLE_ENDIAN); |
783 | 0 | } |
784 | | /** |
785 | | * fu_struct_ifwi_cpd_manifest_set_svn: (skip): |
786 | | **/ |
787 | | void |
788 | | fu_struct_ifwi_cpd_manifest_set_svn(FuStructIfwiCpdManifest *st, guint32 value) |
789 | 0 | { |
790 | 0 | g_return_if_fail(st != NULL); |
791 | 0 | fu_memwrite_uint32(st->buf->data + 44, value, G_LITTLE_ENDIAN); |
792 | 0 | } |
793 | | /** |
794 | | * fu_struct_ifwi_cpd_manifest_new: (skip): |
795 | | **/ |
796 | | FuStructIfwiCpdManifest * |
797 | | fu_struct_ifwi_cpd_manifest_new(void) |
798 | 0 | { |
799 | 0 | FuStructIfwiCpdManifest *st = fu_struct_ifwi_cpd_manifest_new_internal(); |
800 | 0 | st->buf = g_byte_array_sized_new(48); |
801 | 0 | fu_byte_array_set_size(st->buf, 48, 0x0); |
802 | 0 | return st; |
803 | 0 | } |
804 | | /** |
805 | | * fu_struct_ifwi_cpd_manifest_to_string: (skip): |
806 | | **/ |
807 | | static gchar * |
808 | | fu_struct_ifwi_cpd_manifest_to_string(const FuStructIfwiCpdManifest *st) |
809 | 0 | { |
810 | 0 | g_autoptr(GString) str = g_string_new("FuStructIfwiCpdManifest:\n"); |
811 | 0 | g_return_val_if_fail(st != NULL, NULL); |
812 | 0 | g_string_append_printf(str, " header_type: 0x%x\n", |
813 | 0 | (guint) fu_struct_ifwi_cpd_manifest_get_header_type(st)); |
814 | 0 | g_string_append_printf(str, " header_length: 0x%x\n", |
815 | 0 | (guint) fu_struct_ifwi_cpd_manifest_get_header_length(st)); |
816 | 0 | g_string_append_printf(str, " header_version: 0x%x\n", |
817 | 0 | (guint) fu_struct_ifwi_cpd_manifest_get_header_version(st)); |
818 | 0 | g_string_append_printf(str, " flags: 0x%x\n", |
819 | 0 | (guint) fu_struct_ifwi_cpd_manifest_get_flags(st)); |
820 | 0 | g_string_append_printf(str, " vendor: 0x%x\n", |
821 | 0 | (guint) fu_struct_ifwi_cpd_manifest_get_vendor(st)); |
822 | 0 | g_string_append_printf(str, " date: 0x%x\n", |
823 | 0 | (guint) fu_struct_ifwi_cpd_manifest_get_date(st)); |
824 | 0 | g_string_append_printf(str, " size: 0x%x\n", |
825 | 0 | (guint) fu_struct_ifwi_cpd_manifest_get_size(st)); |
826 | 0 | g_string_append_printf(str, " id: 0x%x\n", |
827 | 0 | (guint) fu_struct_ifwi_cpd_manifest_get_id(st)); |
828 | 0 | g_string_append_printf(str, " rsvd: 0x%x\n", |
829 | 0 | (guint) fu_struct_ifwi_cpd_manifest_get_rsvd(st)); |
830 | 0 | g_string_append_printf(str, " version_major: 0x%x\n", |
831 | 0 | (guint) fu_struct_ifwi_cpd_manifest_get_version_major(st)); |
832 | 0 | g_string_append_printf(str, " version_minor: 0x%x\n", |
833 | 0 | (guint) fu_struct_ifwi_cpd_manifest_get_version_minor(st)); |
834 | 0 | g_string_append_printf(str, " version_hotfix: 0x%x\n", |
835 | 0 | (guint) fu_struct_ifwi_cpd_manifest_get_version_hotfix(st)); |
836 | 0 | g_string_append_printf(str, " version_build: 0x%x\n", |
837 | 0 | (guint) fu_struct_ifwi_cpd_manifest_get_version_build(st)); |
838 | 0 | g_string_append_printf(str, " svn: 0x%x\n", |
839 | 0 | (guint) fu_struct_ifwi_cpd_manifest_get_svn(st)); |
840 | 0 | if (str->len > 0) |
841 | 0 | g_string_set_size(str, str->len - 1); |
842 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
843 | 0 | } |
844 | | static gboolean |
845 | | fu_struct_ifwi_cpd_manifest_parse_internal(FuStructIfwiCpdManifest *st, GError **error) |
846 | 756 | { |
847 | 756 | if (g_log_get_debug_enabled()) { |
848 | 0 | g_autofree gchar *str = fu_struct_ifwi_cpd_manifest_to_string(st); |
849 | 0 | g_debug("%s", str); |
850 | 0 | } |
851 | 756 | return TRUE; |
852 | 756 | } |
853 | | /** |
854 | | * fu_struct_ifwi_cpd_manifest_parse_stream: (skip): |
855 | | **/ |
856 | | FuStructIfwiCpdManifest * |
857 | | fu_struct_ifwi_cpd_manifest_parse_stream(GInputStream *stream, gsize offset, GError **error) |
858 | 756 | { |
859 | 756 | g_autoptr(FuStructIfwiCpdManifest) st = fu_struct_ifwi_cpd_manifest_new_internal(); |
860 | 756 | st->buf = fu_input_stream_read_byte_array(stream, offset, 48, NULL, error); |
861 | 756 | if (st->buf == NULL) { |
862 | 0 | g_prefix_error(error, "FuStructIfwiCpdManifest failed read of 0x%x: ", (guint) 48); |
863 | 0 | return NULL; |
864 | 0 | } |
865 | 756 | if (st->buf->len != 48) { |
866 | 0 | g_set_error(error, |
867 | 0 | FWUPD_ERROR, |
868 | 0 | FWUPD_ERROR_INVALID_DATA, |
869 | 0 | "FuStructIfwiCpdManifest requested 0x%x and got 0x%x", |
870 | 0 | (guint) 48, |
871 | 0 | (guint) st->buf->len); |
872 | 0 | return NULL; |
873 | 0 | } |
874 | 756 | if (!fu_struct_ifwi_cpd_manifest_parse_internal(st, error)) |
875 | 0 | return NULL; |
876 | 756 | return g_steal_pointer(&st); |
877 | 756 | } |
878 | | /** |
879 | | * fu_struct_ifwi_cpd_manifest_ext_ref: (skip): |
880 | | **/ |
881 | | FuStructIfwiCpdManifestExt * |
882 | | fu_struct_ifwi_cpd_manifest_ext_ref(FuStructIfwiCpdManifestExt *st) |
883 | 0 | { |
884 | 0 | g_return_val_if_fail(st != NULL, NULL); |
885 | 0 | st->refcount++; |
886 | 0 | return st; |
887 | 0 | } |
888 | | /** |
889 | | * fu_struct_ifwi_cpd_manifest_ext_unref: (skip): |
890 | | **/ |
891 | | void |
892 | | fu_struct_ifwi_cpd_manifest_ext_unref(FuStructIfwiCpdManifestExt *st) |
893 | 5.30k | { |
894 | 5.30k | g_return_if_fail(st != NULL); |
895 | 5.30k | if (st->refcount == 0) { |
896 | 0 | g_critical("FuStructIfwiCpdManifestExt refcount already zero"); |
897 | 0 | return; |
898 | 0 | } |
899 | 5.30k | if (--st->refcount > 0) |
900 | 0 | return; |
901 | 5.30k | if (st->buf != NULL) |
902 | 5.30k | g_byte_array_unref(st->buf); |
903 | 5.30k | g_free(st); |
904 | 5.30k | } |
905 | | /** |
906 | | * fu_struct_ifwi_cpd_manifest_ext_new_internal: (skip): |
907 | | **/ |
908 | | static FuStructIfwiCpdManifestExt * |
909 | | fu_struct_ifwi_cpd_manifest_ext_new_internal(void) |
910 | 5.30k | { |
911 | 5.30k | FuStructIfwiCpdManifestExt *st = g_new0(FuStructIfwiCpdManifestExt, 1); |
912 | 5.30k | st->refcount = 1; |
913 | 5.30k | return st; |
914 | 5.30k | } |
915 | | |
916 | | /* getters */ |
917 | | /** |
918 | | * fu_struct_ifwi_cpd_manifest_ext_get_extension_type: (skip): |
919 | | **/ |
920 | | guint32 |
921 | | fu_struct_ifwi_cpd_manifest_ext_get_extension_type(const FuStructIfwiCpdManifestExt *st) |
922 | 5.28k | { |
923 | 5.28k | g_return_val_if_fail(st != NULL, 0x0); |
924 | 5.28k | return fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
925 | 5.28k | } |
926 | | /** |
927 | | * fu_struct_ifwi_cpd_manifest_ext_get_extension_length: (skip): |
928 | | **/ |
929 | | guint32 |
930 | | fu_struct_ifwi_cpd_manifest_ext_get_extension_length(const FuStructIfwiCpdManifestExt *st) |
931 | 5.18k | { |
932 | 5.18k | g_return_val_if_fail(st != NULL, 0x0); |
933 | 5.18k | return fu_memread_uint32(st->buf->data + 4, G_LITTLE_ENDIAN); |
934 | 5.18k | } |
935 | | |
936 | | /* setters */ |
937 | | /** |
938 | | * fu_struct_ifwi_cpd_manifest_ext_set_extension_type: (skip): |
939 | | **/ |
940 | | void |
941 | | fu_struct_ifwi_cpd_manifest_ext_set_extension_type(FuStructIfwiCpdManifestExt *st, guint32 value) |
942 | 0 | { |
943 | 0 | g_return_if_fail(st != NULL); |
944 | 0 | fu_memwrite_uint32(st->buf->data + 0, value, G_LITTLE_ENDIAN); |
945 | 0 | } |
946 | | /** |
947 | | * fu_struct_ifwi_cpd_manifest_ext_set_extension_length: (skip): |
948 | | **/ |
949 | | void |
950 | | fu_struct_ifwi_cpd_manifest_ext_set_extension_length(FuStructIfwiCpdManifestExt *st, guint32 value) |
951 | 0 | { |
952 | 0 | g_return_if_fail(st != NULL); |
953 | 0 | fu_memwrite_uint32(st->buf->data + 4, value, G_LITTLE_ENDIAN); |
954 | 0 | } |
955 | | /** |
956 | | * fu_struct_ifwi_cpd_manifest_ext_new: (skip): |
957 | | **/ |
958 | | FuStructIfwiCpdManifestExt * |
959 | | fu_struct_ifwi_cpd_manifest_ext_new(void) |
960 | 0 | { |
961 | 0 | FuStructIfwiCpdManifestExt *st = fu_struct_ifwi_cpd_manifest_ext_new_internal(); |
962 | 0 | st->buf = g_byte_array_sized_new(8); |
963 | 0 | fu_byte_array_set_size(st->buf, 8, 0x0); |
964 | 0 | return st; |
965 | 0 | } |
966 | | /** |
967 | | * fu_struct_ifwi_cpd_manifest_ext_to_string: (skip): |
968 | | **/ |
969 | | static gchar * |
970 | | fu_struct_ifwi_cpd_manifest_ext_to_string(const FuStructIfwiCpdManifestExt *st) |
971 | 0 | { |
972 | 0 | g_autoptr(GString) str = g_string_new("FuStructIfwiCpdManifestExt:\n"); |
973 | 0 | g_return_val_if_fail(st != NULL, NULL); |
974 | 0 | g_string_append_printf(str, " extension_type: 0x%x\n", |
975 | 0 | (guint) fu_struct_ifwi_cpd_manifest_ext_get_extension_type(st)); |
976 | 0 | g_string_append_printf(str, " extension_length: 0x%x\n", |
977 | 0 | (guint) fu_struct_ifwi_cpd_manifest_ext_get_extension_length(st)); |
978 | 0 | if (str->len > 0) |
979 | 0 | g_string_set_size(str, str->len - 1); |
980 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
981 | 0 | } |
982 | | static gboolean |
983 | | fu_struct_ifwi_cpd_manifest_ext_parse_internal(FuStructIfwiCpdManifestExt *st, GError **error) |
984 | 5.28k | { |
985 | 5.28k | if (g_log_get_debug_enabled()) { |
986 | 0 | g_autofree gchar *str = fu_struct_ifwi_cpd_manifest_ext_to_string(st); |
987 | 0 | g_debug("%s", str); |
988 | 0 | } |
989 | 5.28k | return TRUE; |
990 | 5.28k | } |
991 | | /** |
992 | | * fu_struct_ifwi_cpd_manifest_ext_parse_stream: (skip): |
993 | | **/ |
994 | | FuStructIfwiCpdManifestExt * |
995 | | fu_struct_ifwi_cpd_manifest_ext_parse_stream(GInputStream *stream, gsize offset, GError **error) |
996 | 5.30k | { |
997 | 5.30k | g_autoptr(FuStructIfwiCpdManifestExt) st = fu_struct_ifwi_cpd_manifest_ext_new_internal(); |
998 | 5.30k | st->buf = fu_input_stream_read_byte_array(stream, offset, 8, NULL, error); |
999 | 5.30k | if (st->buf == NULL) { |
1000 | 0 | g_prefix_error(error, "FuStructIfwiCpdManifestExt failed read of 0x%x: ", (guint) 8); |
1001 | 0 | return NULL; |
1002 | 0 | } |
1003 | 5.30k | if (st->buf->len != 8) { |
1004 | 15 | g_set_error(error, |
1005 | 15 | FWUPD_ERROR, |
1006 | 15 | FWUPD_ERROR_INVALID_DATA, |
1007 | 15 | "FuStructIfwiCpdManifestExt requested 0x%x and got 0x%x", |
1008 | 15 | (guint) 8, |
1009 | 15 | (guint) st->buf->len); |
1010 | 15 | return NULL; |
1011 | 15 | } |
1012 | 5.28k | if (!fu_struct_ifwi_cpd_manifest_ext_parse_internal(st, error)) |
1013 | 0 | return NULL; |
1014 | 5.28k | return g_steal_pointer(&st); |
1015 | 5.28k | } |
1016 | | /** |
1017 | | * fu_struct_ifwi_fpt_ref: (skip): |
1018 | | **/ |
1019 | | FuStructIfwiFpt * |
1020 | | fu_struct_ifwi_fpt_ref(FuStructIfwiFpt *st) |
1021 | 0 | { |
1022 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1023 | 0 | st->refcount++; |
1024 | 0 | return st; |
1025 | 0 | } |
1026 | | /** |
1027 | | * fu_struct_ifwi_fpt_unref: (skip): |
1028 | | **/ |
1029 | | void |
1030 | | fu_struct_ifwi_fpt_unref(FuStructIfwiFpt *st) |
1031 | 975 | { |
1032 | 975 | g_return_if_fail(st != NULL); |
1033 | 975 | if (st->refcount == 0) { |
1034 | 0 | g_critical("FuStructIfwiFpt refcount already zero"); |
1035 | 0 | return; |
1036 | 0 | } |
1037 | 975 | if (--st->refcount > 0) |
1038 | 0 | return; |
1039 | 975 | if (st->buf != NULL) |
1040 | 973 | g_byte_array_unref(st->buf); |
1041 | 975 | g_free(st); |
1042 | 975 | } |
1043 | | /** |
1044 | | * fu_struct_ifwi_fpt_new_internal: (skip): |
1045 | | **/ |
1046 | | static FuStructIfwiFpt * |
1047 | | fu_struct_ifwi_fpt_new_internal(void) |
1048 | 975 | { |
1049 | 975 | FuStructIfwiFpt *st = g_new0(FuStructIfwiFpt, 1); |
1050 | 975 | st->refcount = 1; |
1051 | 975 | return st; |
1052 | 975 | } |
1053 | | |
1054 | | /* getters */ |
1055 | | /** |
1056 | | * fu_struct_ifwi_fpt_get_header_marker: (skip): |
1057 | | **/ |
1058 | | static guint32 |
1059 | | fu_struct_ifwi_fpt_get_header_marker(const FuStructIfwiFpt *st) |
1060 | 954 | { |
1061 | 954 | g_return_val_if_fail(st != NULL, 0x0); |
1062 | 954 | return fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
1063 | 954 | } |
1064 | | /** |
1065 | | * fu_struct_ifwi_fpt_get_num_of_entries: (skip): |
1066 | | **/ |
1067 | | guint32 |
1068 | | fu_struct_ifwi_fpt_get_num_of_entries(const FuStructIfwiFpt *st) |
1069 | 417 | { |
1070 | 417 | g_return_val_if_fail(st != NULL, 0x0); |
1071 | 417 | return fu_memread_uint32(st->buf->data + 4, G_LITTLE_ENDIAN); |
1072 | 417 | } |
1073 | | /** |
1074 | | * fu_struct_ifwi_fpt_get_header_version: (skip): |
1075 | | **/ |
1076 | | guint8 |
1077 | | fu_struct_ifwi_fpt_get_header_version(const FuStructIfwiFpt *st) |
1078 | 382 | { |
1079 | 382 | g_return_val_if_fail(st != NULL, 0x0); |
1080 | 382 | return st->buf->data[8]; |
1081 | 382 | } |
1082 | | /** |
1083 | | * fu_struct_ifwi_fpt_get_entry_version: (skip): |
1084 | | **/ |
1085 | | static guint8 |
1086 | | fu_struct_ifwi_fpt_get_entry_version(const FuStructIfwiFpt *st) |
1087 | 844 | { |
1088 | 844 | g_return_val_if_fail(st != NULL, 0x0); |
1089 | 844 | return st->buf->data[9]; |
1090 | 844 | } |
1091 | | /** |
1092 | | * fu_struct_ifwi_fpt_get_header_length: (skip): |
1093 | | **/ |
1094 | | guint8 |
1095 | | fu_struct_ifwi_fpt_get_header_length(const FuStructIfwiFpt *st) |
1096 | 372 | { |
1097 | 372 | g_return_val_if_fail(st != NULL, 0x0); |
1098 | 372 | return st->buf->data[10]; |
1099 | 372 | } |
1100 | | /** |
1101 | | * fu_struct_ifwi_fpt_get_flags: (skip): |
1102 | | **/ |
1103 | | guint8 |
1104 | | fu_struct_ifwi_fpt_get_flags(const FuStructIfwiFpt *st) |
1105 | 0 | { |
1106 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1107 | 0 | return st->buf->data[11]; |
1108 | 0 | } |
1109 | | /** |
1110 | | * fu_struct_ifwi_fpt_get_ticks_to_add: (skip): |
1111 | | **/ |
1112 | | guint16 |
1113 | | fu_struct_ifwi_fpt_get_ticks_to_add(const FuStructIfwiFpt *st) |
1114 | 0 | { |
1115 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1116 | 0 | return fu_memread_uint16(st->buf->data + 12, G_LITTLE_ENDIAN); |
1117 | 0 | } |
1118 | | /** |
1119 | | * fu_struct_ifwi_fpt_get_tokens_to_add: (skip): |
1120 | | **/ |
1121 | | guint16 |
1122 | | fu_struct_ifwi_fpt_get_tokens_to_add(const FuStructIfwiFpt *st) |
1123 | 0 | { |
1124 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1125 | 0 | return fu_memread_uint16(st->buf->data + 14, G_LITTLE_ENDIAN); |
1126 | 0 | } |
1127 | | /** |
1128 | | * fu_struct_ifwi_fpt_get_uma_size: (skip): |
1129 | | **/ |
1130 | | guint32 |
1131 | | fu_struct_ifwi_fpt_get_uma_size(const FuStructIfwiFpt *st) |
1132 | 0 | { |
1133 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1134 | 0 | return fu_memread_uint32(st->buf->data + 16, G_LITTLE_ENDIAN); |
1135 | 0 | } |
1136 | | /** |
1137 | | * fu_struct_ifwi_fpt_get_crc32: (skip): |
1138 | | **/ |
1139 | | guint32 |
1140 | | fu_struct_ifwi_fpt_get_crc32(const FuStructIfwiFpt *st) |
1141 | 0 | { |
1142 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1143 | 0 | return fu_memread_uint32(st->buf->data + 20, G_LITTLE_ENDIAN); |
1144 | 0 | } |
1145 | | /** |
1146 | | * fu_struct_ifwi_fpt_get_fitc_major: (skip): |
1147 | | **/ |
1148 | | guint16 |
1149 | | fu_struct_ifwi_fpt_get_fitc_major(const FuStructIfwiFpt *st) |
1150 | 0 | { |
1151 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1152 | 0 | return fu_memread_uint16(st->buf->data + 24, G_LITTLE_ENDIAN); |
1153 | 0 | } |
1154 | | /** |
1155 | | * fu_struct_ifwi_fpt_get_fitc_minor: (skip): |
1156 | | **/ |
1157 | | guint16 |
1158 | | fu_struct_ifwi_fpt_get_fitc_minor(const FuStructIfwiFpt *st) |
1159 | 0 | { |
1160 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1161 | 0 | return fu_memread_uint16(st->buf->data + 26, G_LITTLE_ENDIAN); |
1162 | 0 | } |
1163 | | /** |
1164 | | * fu_struct_ifwi_fpt_get_fitc_hotfix: (skip): |
1165 | | **/ |
1166 | | guint16 |
1167 | | fu_struct_ifwi_fpt_get_fitc_hotfix(const FuStructIfwiFpt *st) |
1168 | 0 | { |
1169 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1170 | 0 | return fu_memread_uint16(st->buf->data + 28, G_LITTLE_ENDIAN); |
1171 | 0 | } |
1172 | | /** |
1173 | | * fu_struct_ifwi_fpt_get_fitc_build: (skip): |
1174 | | **/ |
1175 | | guint16 |
1176 | | fu_struct_ifwi_fpt_get_fitc_build(const FuStructIfwiFpt *st) |
1177 | 0 | { |
1178 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1179 | 0 | return fu_memread_uint16(st->buf->data + 30, G_LITTLE_ENDIAN); |
1180 | 0 | } |
1181 | | |
1182 | | /* setters */ |
1183 | | /** |
1184 | | * fu_struct_ifwi_fpt_set_header_marker: (skip): |
1185 | | **/ |
1186 | | static void |
1187 | | fu_struct_ifwi_fpt_set_header_marker(FuStructIfwiFpt *st, guint32 value) |
1188 | 59 | { |
1189 | 59 | g_return_if_fail(st != NULL); |
1190 | 59 | fu_memwrite_uint32(st->buf->data + 0, value, G_LITTLE_ENDIAN); |
1191 | 59 | } |
1192 | | /** |
1193 | | * fu_struct_ifwi_fpt_set_num_of_entries: (skip): |
1194 | | **/ |
1195 | | void |
1196 | | fu_struct_ifwi_fpt_set_num_of_entries(FuStructIfwiFpt *st, guint32 value) |
1197 | 2 | { |
1198 | 2 | g_return_if_fail(st != NULL); |
1199 | 2 | fu_memwrite_uint32(st->buf->data + 4, value, G_LITTLE_ENDIAN); |
1200 | 2 | } |
1201 | | /** |
1202 | | * fu_struct_ifwi_fpt_set_header_version: (skip): |
1203 | | **/ |
1204 | | void |
1205 | | fu_struct_ifwi_fpt_set_header_version(FuStructIfwiFpt *st, guint8 value) |
1206 | 59 | { |
1207 | 59 | g_return_if_fail(st != NULL); |
1208 | 59 | st->buf->data[8] = value; |
1209 | 59 | } |
1210 | | /** |
1211 | | * fu_struct_ifwi_fpt_set_entry_version: (skip): |
1212 | | **/ |
1213 | | static void |
1214 | | fu_struct_ifwi_fpt_set_entry_version(FuStructIfwiFpt *st, guint8 value) |
1215 | 59 | { |
1216 | 59 | g_return_if_fail(st != NULL); |
1217 | 59 | st->buf->data[9] = value; |
1218 | 59 | } |
1219 | | /** |
1220 | | * fu_struct_ifwi_fpt_set_header_length: (skip): |
1221 | | **/ |
1222 | | void |
1223 | | fu_struct_ifwi_fpt_set_header_length(FuStructIfwiFpt *st, guint8 value) |
1224 | 59 | { |
1225 | 59 | g_return_if_fail(st != NULL); |
1226 | 59 | st->buf->data[10] = value; |
1227 | 59 | } |
1228 | | /** |
1229 | | * fu_struct_ifwi_fpt_set_flags: (skip): |
1230 | | **/ |
1231 | | void |
1232 | | fu_struct_ifwi_fpt_set_flags(FuStructIfwiFpt *st, guint8 value) |
1233 | 0 | { |
1234 | 0 | g_return_if_fail(st != NULL); |
1235 | 0 | st->buf->data[11] = value; |
1236 | 0 | } |
1237 | | /** |
1238 | | * fu_struct_ifwi_fpt_set_ticks_to_add: (skip): |
1239 | | **/ |
1240 | | void |
1241 | | fu_struct_ifwi_fpt_set_ticks_to_add(FuStructIfwiFpt *st, guint16 value) |
1242 | 0 | { |
1243 | 0 | g_return_if_fail(st != NULL); |
1244 | 0 | fu_memwrite_uint16(st->buf->data + 12, value, G_LITTLE_ENDIAN); |
1245 | 0 | } |
1246 | | /** |
1247 | | * fu_struct_ifwi_fpt_set_tokens_to_add: (skip): |
1248 | | **/ |
1249 | | void |
1250 | | fu_struct_ifwi_fpt_set_tokens_to_add(FuStructIfwiFpt *st, guint16 value) |
1251 | 0 | { |
1252 | 0 | g_return_if_fail(st != NULL); |
1253 | 0 | fu_memwrite_uint16(st->buf->data + 14, value, G_LITTLE_ENDIAN); |
1254 | 0 | } |
1255 | | /** |
1256 | | * fu_struct_ifwi_fpt_set_uma_size: (skip): |
1257 | | **/ |
1258 | | void |
1259 | | fu_struct_ifwi_fpt_set_uma_size(FuStructIfwiFpt *st, guint32 value) |
1260 | 0 | { |
1261 | 0 | g_return_if_fail(st != NULL); |
1262 | 0 | fu_memwrite_uint32(st->buf->data + 16, value, G_LITTLE_ENDIAN); |
1263 | 0 | } |
1264 | | /** |
1265 | | * fu_struct_ifwi_fpt_set_crc32: (skip): |
1266 | | **/ |
1267 | | void |
1268 | | fu_struct_ifwi_fpt_set_crc32(FuStructIfwiFpt *st, guint32 value) |
1269 | 0 | { |
1270 | 0 | g_return_if_fail(st != NULL); |
1271 | 0 | fu_memwrite_uint32(st->buf->data + 20, value, G_LITTLE_ENDIAN); |
1272 | 0 | } |
1273 | | /** |
1274 | | * fu_struct_ifwi_fpt_set_fitc_major: (skip): |
1275 | | **/ |
1276 | | void |
1277 | | fu_struct_ifwi_fpt_set_fitc_major(FuStructIfwiFpt *st, guint16 value) |
1278 | 0 | { |
1279 | 0 | g_return_if_fail(st != NULL); |
1280 | 0 | fu_memwrite_uint16(st->buf->data + 24, value, G_LITTLE_ENDIAN); |
1281 | 0 | } |
1282 | | /** |
1283 | | * fu_struct_ifwi_fpt_set_fitc_minor: (skip): |
1284 | | **/ |
1285 | | void |
1286 | | fu_struct_ifwi_fpt_set_fitc_minor(FuStructIfwiFpt *st, guint16 value) |
1287 | 0 | { |
1288 | 0 | g_return_if_fail(st != NULL); |
1289 | 0 | fu_memwrite_uint16(st->buf->data + 26, value, G_LITTLE_ENDIAN); |
1290 | 0 | } |
1291 | | /** |
1292 | | * fu_struct_ifwi_fpt_set_fitc_hotfix: (skip): |
1293 | | **/ |
1294 | | void |
1295 | | fu_struct_ifwi_fpt_set_fitc_hotfix(FuStructIfwiFpt *st, guint16 value) |
1296 | 0 | { |
1297 | 0 | g_return_if_fail(st != NULL); |
1298 | 0 | fu_memwrite_uint16(st->buf->data + 28, value, G_LITTLE_ENDIAN); |
1299 | 0 | } |
1300 | | /** |
1301 | | * fu_struct_ifwi_fpt_set_fitc_build: (skip): |
1302 | | **/ |
1303 | | void |
1304 | | fu_struct_ifwi_fpt_set_fitc_build(FuStructIfwiFpt *st, guint16 value) |
1305 | 0 | { |
1306 | 0 | g_return_if_fail(st != NULL); |
1307 | 0 | fu_memwrite_uint16(st->buf->data + 30, value, G_LITTLE_ENDIAN); |
1308 | 0 | } |
1309 | | /** |
1310 | | * fu_struct_ifwi_fpt_new: (skip): |
1311 | | **/ |
1312 | | FuStructIfwiFpt * |
1313 | | fu_struct_ifwi_fpt_new(void) |
1314 | 59 | { |
1315 | 59 | FuStructIfwiFpt *st = fu_struct_ifwi_fpt_new_internal(); |
1316 | 59 | st->buf = g_byte_array_sized_new(32); |
1317 | 59 | fu_byte_array_set_size(st->buf, 32, 0x0); |
1318 | 59 | fu_struct_ifwi_fpt_set_header_marker(st, 0x54504624); |
1319 | 59 | fu_struct_ifwi_fpt_set_header_version(st, 0x20); |
1320 | 59 | fu_struct_ifwi_fpt_set_entry_version(st, 0x10); |
1321 | 59 | fu_struct_ifwi_fpt_set_header_length(st, 32); |
1322 | 59 | return st; |
1323 | 59 | } |
1324 | | /** |
1325 | | * fu_struct_ifwi_fpt_to_string: (skip): |
1326 | | **/ |
1327 | | static gchar * |
1328 | | fu_struct_ifwi_fpt_to_string(const FuStructIfwiFpt *st) |
1329 | 0 | { |
1330 | 0 | g_autoptr(GString) str = g_string_new("FuStructIfwiFpt:\n"); |
1331 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1332 | 0 | g_string_append_printf(str, " header_marker: 0x%x\n", |
1333 | 0 | (guint) fu_struct_ifwi_fpt_get_header_marker(st)); |
1334 | 0 | g_string_append_printf(str, " num_of_entries: 0x%x\n", |
1335 | 0 | (guint) fu_struct_ifwi_fpt_get_num_of_entries(st)); |
1336 | 0 | g_string_append_printf(str, " header_version: 0x%x\n", |
1337 | 0 | (guint) fu_struct_ifwi_fpt_get_header_version(st)); |
1338 | 0 | g_string_append_printf(str, " entry_version: 0x%x\n", |
1339 | 0 | (guint) fu_struct_ifwi_fpt_get_entry_version(st)); |
1340 | 0 | g_string_append_printf(str, " header_length: 0x%x\n", |
1341 | 0 | (guint) fu_struct_ifwi_fpt_get_header_length(st)); |
1342 | 0 | g_string_append_printf(str, " flags: 0x%x\n", |
1343 | 0 | (guint) fu_struct_ifwi_fpt_get_flags(st)); |
1344 | 0 | g_string_append_printf(str, " ticks_to_add: 0x%x\n", |
1345 | 0 | (guint) fu_struct_ifwi_fpt_get_ticks_to_add(st)); |
1346 | 0 | g_string_append_printf(str, " tokens_to_add: 0x%x\n", |
1347 | 0 | (guint) fu_struct_ifwi_fpt_get_tokens_to_add(st)); |
1348 | 0 | g_string_append_printf(str, " uma_size: 0x%x\n", |
1349 | 0 | (guint) fu_struct_ifwi_fpt_get_uma_size(st)); |
1350 | 0 | g_string_append_printf(str, " crc32: 0x%x\n", |
1351 | 0 | (guint) fu_struct_ifwi_fpt_get_crc32(st)); |
1352 | 0 | g_string_append_printf(str, " fitc_major: 0x%x\n", |
1353 | 0 | (guint) fu_struct_ifwi_fpt_get_fitc_major(st)); |
1354 | 0 | g_string_append_printf(str, " fitc_minor: 0x%x\n", |
1355 | 0 | (guint) fu_struct_ifwi_fpt_get_fitc_minor(st)); |
1356 | 0 | g_string_append_printf(str, " fitc_hotfix: 0x%x\n", |
1357 | 0 | (guint) fu_struct_ifwi_fpt_get_fitc_hotfix(st)); |
1358 | 0 | g_string_append_printf(str, " fitc_build: 0x%x\n", |
1359 | 0 | (guint) fu_struct_ifwi_fpt_get_fitc_build(st)); |
1360 | 0 | if (str->len > 0) |
1361 | 0 | g_string_set_size(str, str->len - 1); |
1362 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1363 | 0 | } |
1364 | | static gboolean |
1365 | | fu_struct_ifwi_fpt_validate_internal(FuStructIfwiFpt *st, GError **error) |
1366 | 899 | { |
1367 | 899 | g_return_val_if_fail(st != NULL, FALSE); |
1368 | 899 | if (fu_struct_ifwi_fpt_get_header_marker(st) != 0x54504624) { |
1369 | 55 | g_set_error(error, |
1370 | 55 | FWUPD_ERROR, |
1371 | 55 | FWUPD_ERROR_INVALID_DATA, |
1372 | 55 | "constant FuStructIfwiFpt.header_marker was not valid, " |
1373 | 55 | "expected 0x%x and got 0x%x", |
1374 | 55 | (guint) 0x54504624, |
1375 | 55 | (guint) fu_struct_ifwi_fpt_get_header_marker(st)); |
1376 | 55 | return FALSE; |
1377 | 55 | } |
1378 | 844 | if (fu_struct_ifwi_fpt_get_entry_version(st) != 0x10) { |
1379 | 10 | g_set_error_literal(error, |
1380 | 10 | FWUPD_ERROR, |
1381 | 10 | FWUPD_ERROR_INVALID_DATA, |
1382 | 10 | "constant FuStructIfwiFpt.entry_version was not valid"); |
1383 | 10 | return FALSE; |
1384 | 10 | } |
1385 | 834 | return TRUE; |
1386 | 844 | } |
1387 | | /** |
1388 | | * fu_struct_ifwi_fpt_validate_stream: (skip): |
1389 | | **/ |
1390 | | gboolean |
1391 | | fu_struct_ifwi_fpt_validate_stream(GInputStream *stream, gsize offset, GError **error) |
1392 | 499 | { |
1393 | 499 | g_autoptr(FuStructIfwiFpt) st = fu_struct_ifwi_fpt_new_internal(); |
1394 | 499 | g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE); |
1395 | 499 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
1396 | 499 | st->buf = fu_input_stream_read_byte_array(stream, offset, 32, NULL, error); |
1397 | 499 | if (st->buf == NULL) { |
1398 | 0 | g_prefix_error(error, "FuStructIfwiFpt failed read of 0x%x: ", (guint) 32); |
1399 | 0 | return FALSE; |
1400 | 0 | } |
1401 | 499 | if (st->buf->len != 32) { |
1402 | 17 | g_set_error(error, |
1403 | 17 | FWUPD_ERROR, |
1404 | 17 | FWUPD_ERROR_INVALID_DATA, |
1405 | 17 | "FuStructIfwiFpt requested 0x%x and got 0x%x", |
1406 | 17 | (guint) 32, |
1407 | 17 | (guint) st->buf->len); |
1408 | 17 | return FALSE; |
1409 | 17 | } |
1410 | 482 | return fu_struct_ifwi_fpt_validate_internal(st, error); |
1411 | 499 | } |
1412 | | static gboolean |
1413 | | fu_struct_ifwi_fpt_parse_internal(FuStructIfwiFpt *st, GError **error) |
1414 | 417 | { |
1415 | 417 | if (g_log_get_debug_enabled()) { |
1416 | 0 | g_autofree gchar *str = fu_struct_ifwi_fpt_to_string(st); |
1417 | 0 | g_debug("%s", str); |
1418 | 0 | } |
1419 | 417 | if (!fu_struct_ifwi_fpt_validate_internal(st, error)) |
1420 | 0 | return FALSE; |
1421 | 417 | return TRUE; |
1422 | 417 | } |
1423 | | /** |
1424 | | * fu_struct_ifwi_fpt_parse_stream: (skip): |
1425 | | **/ |
1426 | | FuStructIfwiFpt * |
1427 | | fu_struct_ifwi_fpt_parse_stream(GInputStream *stream, gsize offset, GError **error) |
1428 | 417 | { |
1429 | 417 | g_autoptr(FuStructIfwiFpt) st = fu_struct_ifwi_fpt_new_internal(); |
1430 | 417 | st->buf = fu_input_stream_read_byte_array(stream, offset, 32, NULL, error); |
1431 | 417 | if (st->buf == NULL) { |
1432 | 0 | g_prefix_error(error, "FuStructIfwiFpt failed read of 0x%x: ", (guint) 32); |
1433 | 0 | return NULL; |
1434 | 0 | } |
1435 | 417 | if (st->buf->len != 32) { |
1436 | 0 | g_set_error(error, |
1437 | 0 | FWUPD_ERROR, |
1438 | 0 | FWUPD_ERROR_INVALID_DATA, |
1439 | 0 | "FuStructIfwiFpt requested 0x%x and got 0x%x", |
1440 | 0 | (guint) 32, |
1441 | 0 | (guint) st->buf->len); |
1442 | 0 | return NULL; |
1443 | 0 | } |
1444 | 417 | if (!fu_struct_ifwi_fpt_parse_internal(st, error)) |
1445 | 0 | return NULL; |
1446 | 417 | return g_steal_pointer(&st); |
1447 | 417 | } |
1448 | | /** |
1449 | | * fu_struct_ifwi_fpt_entry_ref: (skip): |
1450 | | **/ |
1451 | | FuStructIfwiFptEntry * |
1452 | | fu_struct_ifwi_fpt_entry_ref(FuStructIfwiFptEntry *st) |
1453 | 0 | { |
1454 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1455 | 0 | st->refcount++; |
1456 | 0 | return st; |
1457 | 0 | } |
1458 | | /** |
1459 | | * fu_struct_ifwi_fpt_entry_unref: (skip): |
1460 | | **/ |
1461 | | void |
1462 | | fu_struct_ifwi_fpt_entry_unref(FuStructIfwiFptEntry *st) |
1463 | 4.60k | { |
1464 | 4.60k | g_return_if_fail(st != NULL); |
1465 | 4.60k | if (st->refcount == 0) { |
1466 | 0 | g_critical("FuStructIfwiFptEntry refcount already zero"); |
1467 | 0 | return; |
1468 | 0 | } |
1469 | 4.60k | if (--st->refcount > 0) |
1470 | 0 | return; |
1471 | 4.60k | if (st->buf != NULL) |
1472 | 4.48k | g_byte_array_unref(st->buf); |
1473 | 4.60k | g_free(st); |
1474 | 4.60k | } |
1475 | | /** |
1476 | | * fu_struct_ifwi_fpt_entry_new_internal: (skip): |
1477 | | **/ |
1478 | | static FuStructIfwiFptEntry * |
1479 | | fu_struct_ifwi_fpt_entry_new_internal(void) |
1480 | 4.60k | { |
1481 | 4.60k | FuStructIfwiFptEntry *st = g_new0(FuStructIfwiFptEntry, 1); |
1482 | 4.60k | st->refcount = 1; |
1483 | 4.60k | return st; |
1484 | 4.60k | } |
1485 | | |
1486 | | /* getters */ |
1487 | | /** |
1488 | | * fu_struct_ifwi_fpt_entry_get_partition_name: (skip): |
1489 | | **/ |
1490 | | guint32 |
1491 | | fu_struct_ifwi_fpt_entry_get_partition_name(const FuStructIfwiFptEntry *st) |
1492 | 4.45k | { |
1493 | 4.45k | g_return_val_if_fail(st != NULL, 0x0); |
1494 | 4.45k | return fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
1495 | 4.45k | } |
1496 | | /** |
1497 | | * fu_struct_ifwi_fpt_entry_get_offset: (skip): |
1498 | | **/ |
1499 | | guint32 |
1500 | | fu_struct_ifwi_fpt_entry_get_offset(const FuStructIfwiFptEntry *st) |
1501 | 2.86k | { |
1502 | 2.86k | g_return_val_if_fail(st != NULL, 0x0); |
1503 | 2.86k | return fu_memread_uint32(st->buf->data + 8, G_LITTLE_ENDIAN); |
1504 | 2.86k | } |
1505 | | /** |
1506 | | * fu_struct_ifwi_fpt_entry_get_length: (skip): |
1507 | | **/ |
1508 | | guint32 |
1509 | | fu_struct_ifwi_fpt_entry_get_length(const FuStructIfwiFptEntry *st) |
1510 | 4.45k | { |
1511 | 4.45k | g_return_val_if_fail(st != NULL, 0x0); |
1512 | 4.45k | return fu_memread_uint32(st->buf->data + 12, G_LITTLE_ENDIAN); |
1513 | 4.45k | } |
1514 | | /** |
1515 | | * fu_struct_ifwi_fpt_entry_get_partition_type: (skip): |
1516 | | **/ |
1517 | | guint32 |
1518 | | fu_struct_ifwi_fpt_entry_get_partition_type(const FuStructIfwiFptEntry *st) |
1519 | 0 | { |
1520 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1521 | 0 | return fu_memread_uint32(st->buf->data + 28, G_LITTLE_ENDIAN); |
1522 | 0 | } |
1523 | | |
1524 | | /* setters */ |
1525 | | /** |
1526 | | * fu_struct_ifwi_fpt_entry_set_partition_name: (skip): |
1527 | | **/ |
1528 | | void |
1529 | | fu_struct_ifwi_fpt_entry_set_partition_name(FuStructIfwiFptEntry *st, guint32 value) |
1530 | 0 | { |
1531 | 0 | g_return_if_fail(st != NULL); |
1532 | 0 | fu_memwrite_uint32(st->buf->data + 0, value, G_LITTLE_ENDIAN); |
1533 | 0 | } |
1534 | | /** |
1535 | | * fu_struct_ifwi_fpt_entry_set_offset: (skip): |
1536 | | **/ |
1537 | | void |
1538 | | fu_struct_ifwi_fpt_entry_set_offset(FuStructIfwiFptEntry *st, guint32 value) |
1539 | 0 | { |
1540 | 0 | g_return_if_fail(st != NULL); |
1541 | 0 | fu_memwrite_uint32(st->buf->data + 8, value, G_LITTLE_ENDIAN); |
1542 | 0 | } |
1543 | | /** |
1544 | | * fu_struct_ifwi_fpt_entry_set_length: (skip): |
1545 | | **/ |
1546 | | void |
1547 | | fu_struct_ifwi_fpt_entry_set_length(FuStructIfwiFptEntry *st, guint32 value) |
1548 | 0 | { |
1549 | 0 | g_return_if_fail(st != NULL); |
1550 | 0 | fu_memwrite_uint32(st->buf->data + 12, value, G_LITTLE_ENDIAN); |
1551 | 0 | } |
1552 | | /** |
1553 | | * fu_struct_ifwi_fpt_entry_set_partition_type: (skip): |
1554 | | **/ |
1555 | | void |
1556 | | fu_struct_ifwi_fpt_entry_set_partition_type(FuStructIfwiFptEntry *st, guint32 value) |
1557 | 0 | { |
1558 | 0 | g_return_if_fail(st != NULL); |
1559 | 0 | fu_memwrite_uint32(st->buf->data + 28, value, G_LITTLE_ENDIAN); |
1560 | 0 | } |
1561 | | /** |
1562 | | * fu_struct_ifwi_fpt_entry_new: (skip): |
1563 | | **/ |
1564 | | FuStructIfwiFptEntry * |
1565 | | fu_struct_ifwi_fpt_entry_new(void) |
1566 | 0 | { |
1567 | 0 | FuStructIfwiFptEntry *st = fu_struct_ifwi_fpt_entry_new_internal(); |
1568 | 0 | st->buf = g_byte_array_sized_new(32); |
1569 | 0 | fu_byte_array_set_size(st->buf, 32, 0x0); |
1570 | 0 | return st; |
1571 | 0 | } |
1572 | | /** |
1573 | | * fu_struct_ifwi_fpt_entry_to_string: (skip): |
1574 | | **/ |
1575 | | static gchar * |
1576 | | fu_struct_ifwi_fpt_entry_to_string(const FuStructIfwiFptEntry *st) |
1577 | 0 | { |
1578 | 0 | g_autoptr(GString) str = g_string_new("FuStructIfwiFptEntry:\n"); |
1579 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1580 | 0 | g_string_append_printf(str, " partition_name: 0x%x\n", |
1581 | 0 | (guint) fu_struct_ifwi_fpt_entry_get_partition_name(st)); |
1582 | 0 | g_string_append_printf(str, " offset: 0x%x\n", |
1583 | 0 | (guint) fu_struct_ifwi_fpt_entry_get_offset(st)); |
1584 | 0 | g_string_append_printf(str, " length: 0x%x\n", |
1585 | 0 | (guint) fu_struct_ifwi_fpt_entry_get_length(st)); |
1586 | 0 | g_string_append_printf(str, " partition_type: 0x%x\n", |
1587 | 0 | (guint) fu_struct_ifwi_fpt_entry_get_partition_type(st)); |
1588 | 0 | if (str->len > 0) |
1589 | 0 | g_string_set_size(str, str->len - 1); |
1590 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1591 | 0 | } |
1592 | | static gboolean |
1593 | | fu_struct_ifwi_fpt_entry_parse_internal(FuStructIfwiFptEntry *st, GError **error) |
1594 | 4.45k | { |
1595 | 4.45k | if (g_log_get_debug_enabled()) { |
1596 | 0 | g_autofree gchar *str = fu_struct_ifwi_fpt_entry_to_string(st); |
1597 | 0 | g_debug("%s", str); |
1598 | 0 | } |
1599 | 4.45k | return TRUE; |
1600 | 4.45k | } |
1601 | | /** |
1602 | | * fu_struct_ifwi_fpt_entry_parse_stream: (skip): |
1603 | | **/ |
1604 | | FuStructIfwiFptEntry * |
1605 | | fu_struct_ifwi_fpt_entry_parse_stream(GInputStream *stream, gsize offset, GError **error) |
1606 | 4.60k | { |
1607 | 4.60k | g_autoptr(FuStructIfwiFptEntry) st = fu_struct_ifwi_fpt_entry_new_internal(); |
1608 | 4.60k | st->buf = fu_input_stream_read_byte_array(stream, offset, 32, NULL, error); |
1609 | 4.60k | if (st->buf == NULL) { |
1610 | 113 | g_prefix_error(error, "FuStructIfwiFptEntry failed read of 0x%x: ", (guint) 32); |
1611 | 113 | return NULL; |
1612 | 113 | } |
1613 | 4.48k | if (st->buf->len != 32) { |
1614 | 33 | g_set_error(error, |
1615 | 33 | FWUPD_ERROR, |
1616 | 33 | FWUPD_ERROR_INVALID_DATA, |
1617 | 33 | "FuStructIfwiFptEntry requested 0x%x and got 0x%x", |
1618 | 33 | (guint) 32, |
1619 | 33 | (guint) st->buf->len); |
1620 | 33 | return NULL; |
1621 | 33 | } |
1622 | 4.45k | if (!fu_struct_ifwi_fpt_entry_parse_internal(st, error)) |
1623 | 0 | return NULL; |
1624 | 4.45k | return g_steal_pointer(&st); |
1625 | 4.45k | } |