/work/fu-synaptics-rmi-struct.c
Line | Count | Source |
1 | | /* |
2 | | * This file is auto-generated, do not modify! |
3 | | * |
4 | | * SPDX-License-Identifier: LGPL-2.1-or-later |
5 | | */ |
6 | | |
7 | | #include "config.h" |
8 | | |
9 | | #include <glib.h> |
10 | | |
11 | | #include "fu-synaptics-rmi-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 | | |
23 | | |
24 | | /** |
25 | | * fu_rmi_partition_id_to_string: |
26 | | * @val: value, e.g. %FU_RMI_PARTITION_ID_BOOTLOADER |
27 | | * |
28 | | * Converts an enumerated value to a string. |
29 | | * |
30 | | * Returns: identifier string |
31 | | **/ |
32 | | const gchar * |
33 | | fu_rmi_partition_id_to_string(FuRmiPartitionId val) |
34 | 0 | { |
35 | 0 | if (val == FU_RMI_PARTITION_ID_NONE) |
36 | 0 | return "none"; |
37 | 0 | if (val == FU_RMI_PARTITION_ID_BOOTLOADER) |
38 | 0 | return "bootloader"; |
39 | 0 | if (val == FU_RMI_PARTITION_ID_DEVICE_CONFIG) |
40 | 0 | return "device-config"; |
41 | 0 | if (val == FU_RMI_PARTITION_ID_FLASH_CONFIG) |
42 | 0 | return "flash-config"; |
43 | 0 | if (val == FU_RMI_PARTITION_ID_MANUFACTURING_BLOCK) |
44 | 0 | return "manufacturing-block"; |
45 | 0 | if (val == FU_RMI_PARTITION_ID_GUEST_SERIALIZATION) |
46 | 0 | return "guest-serialization"; |
47 | 0 | if (val == FU_RMI_PARTITION_ID_GLOBAL_PARAMETERS) |
48 | 0 | return "global-parameters"; |
49 | 0 | if (val == FU_RMI_PARTITION_ID_CORE_CODE) |
50 | 0 | return "core-code"; |
51 | 0 | if (val == FU_RMI_PARTITION_ID_CORE_CONFIG) |
52 | 0 | return "core-config"; |
53 | 0 | if (val == FU_RMI_PARTITION_ID_GUEST_CODE) |
54 | 0 | return "guest-code"; |
55 | 0 | if (val == FU_RMI_PARTITION_ID_DISPLAY_CONFIG) |
56 | 0 | return "display-config"; |
57 | 0 | if (val == FU_RMI_PARTITION_ID_EXTERNAL_TOUCH_AFE_CONFIG) |
58 | 0 | return "external-touch-afe-config"; |
59 | 0 | if (val == FU_RMI_PARTITION_ID_UTILITY_PARAMETER) |
60 | 0 | return "utility-parameter"; |
61 | 0 | if (val == FU_RMI_PARTITION_ID_PUBKEY) |
62 | 0 | return "pubkey"; |
63 | 0 | if (val == FU_RMI_PARTITION_ID_FIXED_LOCATION_DATA) |
64 | 0 | return "fixed-location-data"; |
65 | 0 | return NULL; |
66 | 0 | } |
67 | | |
68 | | /** |
69 | | * fu_rmi_container_id_to_string: |
70 | | * @val: value, e.g. %FU_RMI_CONTAINER_ID_UI |
71 | | * |
72 | | * Converts an enumerated value to a string. |
73 | | * |
74 | | * Returns: identifier string |
75 | | **/ |
76 | | const gchar * |
77 | | fu_rmi_container_id_to_string(FuRmiContainerId val) |
78 | 5.88k | { |
79 | 5.88k | if (val == FU_RMI_CONTAINER_ID_TOP_LEVEL) |
80 | 719 | return "top-level"; |
81 | 5.16k | if (val == FU_RMI_CONTAINER_ID_UI) |
82 | 0 | return "ui"; |
83 | 5.16k | if (val == FU_RMI_CONTAINER_ID_UI_CONFIG) |
84 | 0 | return "ui-config"; |
85 | 5.16k | if (val == FU_RMI_CONTAINER_ID_BL) |
86 | 0 | return "bl"; |
87 | 5.16k | if (val == FU_RMI_CONTAINER_ID_BL_IMAGE) |
88 | 766 | return "bl-image"; |
89 | 4.39k | if (val == FU_RMI_CONTAINER_ID_BL_CONFIG) |
90 | 442 | return "bl-config"; |
91 | 3.95k | if (val == FU_RMI_CONTAINER_ID_BL_LOCKDOWN_INFO) |
92 | 244 | return "bl-lockdown-info"; |
93 | 3.71k | if (val == FU_RMI_CONTAINER_ID_PERMANENT_CONFIG) |
94 | 199 | return "permanent-config"; |
95 | 3.51k | if (val == FU_RMI_CONTAINER_ID_GUEST_CODE) |
96 | 197 | return "guest-code"; |
97 | 3.31k | if (val == FU_RMI_CONTAINER_ID_BL_PROTOCOL_DESCRIPTOR) |
98 | 202 | return "bl-protocol-descriptor"; |
99 | 3.11k | if (val == FU_RMI_CONTAINER_ID_UI_PROTOCOL_DESCRIPTOR) |
100 | 201 | return "ui-protocol-descriptor"; |
101 | 2.91k | if (val == FU_RMI_CONTAINER_ID_RMI_SELF_DISCOVERY) |
102 | 435 | return "rmi-self-discovery"; |
103 | 2.47k | if (val == FU_RMI_CONTAINER_ID_RMI_PAGE_CONTENT) |
104 | 200 | return "rmi-page-content"; |
105 | 2.27k | if (val == FU_RMI_CONTAINER_ID_GENERAL_INFORMATION) |
106 | 0 | return "general-information"; |
107 | 2.27k | if (val == FU_RMI_CONTAINER_ID_DEVICE_CONFIG) |
108 | 197 | return "device-config"; |
109 | 2.08k | if (val == FU_RMI_CONTAINER_ID_FLASH_CONFIG) |
110 | 0 | return "flash-config"; |
111 | 2.08k | if (val == FU_RMI_CONTAINER_ID_GUEST_SERIALIZATION) |
112 | 203 | return "guest-serialization"; |
113 | 1.87k | if (val == FU_RMI_CONTAINER_ID_GLOBAL_PARAMETERS) |
114 | 418 | return "global-parameters"; |
115 | 1.46k | if (val == FU_RMI_CONTAINER_ID_CORE_CODE) |
116 | 0 | return "core-code"; |
117 | 1.46k | if (val == FU_RMI_CONTAINER_ID_CORE_CONFIG) |
118 | 0 | return "core-config"; |
119 | 1.46k | if (val == FU_RMI_CONTAINER_ID_DISPLAY_CONFIG) |
120 | 0 | return "display-config"; |
121 | 1.46k | if (val == FU_RMI_CONTAINER_ID_EXTERNAL_TOUCH_AFE_CONFIG) |
122 | 0 | return "external-touch-afe-config"; |
123 | 1.46k | if (val == FU_RMI_CONTAINER_ID_UTILITY) |
124 | 200 | return "utility"; |
125 | 1.26k | if (val == FU_RMI_CONTAINER_ID_UTILITY_PARAMETER) |
126 | 452 | return "utility-parameter"; |
127 | 808 | if (val == FU_RMI_CONTAINER_ID_FIXED_LOCATION_DATA) |
128 | 0 | return "fixed-location-data"; |
129 | 808 | return NULL; |
130 | 808 | } |
131 | | |
132 | | |
133 | | |
134 | | |
135 | | |
136 | | |
137 | | |
138 | | /** |
139 | | * fu_struct_rmi_partition_tbl_ref: (skip): |
140 | | **/ |
141 | | FuStructRmiPartitionTbl * |
142 | | fu_struct_rmi_partition_tbl_ref(FuStructRmiPartitionTbl *st) |
143 | 0 | { |
144 | 0 | g_return_val_if_fail(st != NULL, NULL); |
145 | 0 | st->refcount++; |
146 | 0 | return st; |
147 | 0 | } |
148 | | /** |
149 | | * fu_struct_rmi_partition_tbl_unref: (skip): |
150 | | **/ |
151 | | void |
152 | | fu_struct_rmi_partition_tbl_unref(FuStructRmiPartitionTbl *st) |
153 | 0 | { |
154 | 0 | g_return_if_fail(st != NULL); |
155 | 0 | if (st->refcount == 0) { |
156 | 0 | g_critical("FuStructRmiPartitionTbl refcount already zero"); |
157 | 0 | return; |
158 | 0 | } |
159 | 0 | if (--st->refcount > 0) |
160 | 0 | return; |
161 | 0 | if (st->buf != NULL) |
162 | 0 | g_byte_array_unref(st->buf); |
163 | 0 | g_free(st); |
164 | 0 | } |
165 | | /** |
166 | | * fu_struct_rmi_partition_tbl_new_internal: (skip): |
167 | | **/ |
168 | | static FuStructRmiPartitionTbl * |
169 | | fu_struct_rmi_partition_tbl_new_internal(void) |
170 | 0 | { |
171 | 0 | FuStructRmiPartitionTbl *st = g_new0(FuStructRmiPartitionTbl, 1); |
172 | 0 | st->refcount = 1; |
173 | 0 | return st; |
174 | 0 | } |
175 | | |
176 | | /* getters */ |
177 | | /** |
178 | | * fu_struct_rmi_partition_tbl_get_partition_id: (skip): |
179 | | **/ |
180 | | guint16 |
181 | | fu_struct_rmi_partition_tbl_get_partition_id(const FuStructRmiPartitionTbl *st) |
182 | 0 | { |
183 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
184 | 0 | return fu_memread_uint16(st->buf->data + 0, G_LITTLE_ENDIAN); |
185 | 0 | } |
186 | | /** |
187 | | * fu_struct_rmi_partition_tbl_get_partition_len: (skip): |
188 | | **/ |
189 | | guint16 |
190 | | fu_struct_rmi_partition_tbl_get_partition_len(const FuStructRmiPartitionTbl *st) |
191 | 0 | { |
192 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
193 | 0 | return fu_memread_uint16(st->buf->data + 2, G_LITTLE_ENDIAN); |
194 | 0 | } |
195 | | /** |
196 | | * fu_struct_rmi_partition_tbl_get_partition_addr: (skip): |
197 | | **/ |
198 | | guint16 |
199 | | fu_struct_rmi_partition_tbl_get_partition_addr(const FuStructRmiPartitionTbl *st) |
200 | 0 | { |
201 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
202 | 0 | return fu_memread_uint16(st->buf->data + 4, G_LITTLE_ENDIAN); |
203 | 0 | } |
204 | | /** |
205 | | * fu_struct_rmi_partition_tbl_get_partition_prop: (skip): |
206 | | **/ |
207 | | guint16 |
208 | | fu_struct_rmi_partition_tbl_get_partition_prop(const FuStructRmiPartitionTbl *st) |
209 | 0 | { |
210 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
211 | 0 | return fu_memread_uint16(st->buf->data + 6, G_LITTLE_ENDIAN); |
212 | 0 | } |
213 | | |
214 | | /* setters */ |
215 | | /** |
216 | | * fu_struct_rmi_partition_tbl_to_string: (skip): |
217 | | **/ |
218 | | static gchar * |
219 | | fu_struct_rmi_partition_tbl_to_string(const FuStructRmiPartitionTbl *st) |
220 | 0 | { |
221 | 0 | g_autoptr(GString) str = g_string_new("FuStructRmiPartitionTbl:\n"); |
222 | 0 | g_return_val_if_fail(st != NULL, NULL); |
223 | 0 | g_string_append_printf(str, " partition_id: 0x%x\n", |
224 | 0 | (guint) fu_struct_rmi_partition_tbl_get_partition_id(st)); |
225 | 0 | g_string_append_printf(str, " partition_len: 0x%x\n", |
226 | 0 | (guint) fu_struct_rmi_partition_tbl_get_partition_len(st)); |
227 | 0 | g_string_append_printf(str, " partition_addr: 0x%x\n", |
228 | 0 | (guint) fu_struct_rmi_partition_tbl_get_partition_addr(st)); |
229 | 0 | g_string_append_printf(str, " partition_prop: 0x%x\n", |
230 | 0 | (guint) fu_struct_rmi_partition_tbl_get_partition_prop(st)); |
231 | 0 | if (str->len > 0) |
232 | 0 | g_string_set_size(str, str->len - 1); |
233 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
234 | 0 | } |
235 | | static gboolean |
236 | | fu_struct_rmi_partition_tbl_validate_internal(FuStructRmiPartitionTbl *st, GError **error) |
237 | 0 | { |
238 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
239 | 0 | return TRUE; |
240 | 0 | } |
241 | | static gboolean |
242 | | fu_struct_rmi_partition_tbl_parse_internal(FuStructRmiPartitionTbl *st, GError **error) |
243 | 0 | { |
244 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
245 | 0 | g_autofree gchar *str = fu_struct_rmi_partition_tbl_to_string(st); |
246 | 0 | g_debug("%s", str); |
247 | 0 | } |
248 | 0 | if (!fu_struct_rmi_partition_tbl_validate_internal(st, error)) |
249 | 0 | return FALSE; |
250 | 0 | return TRUE; |
251 | 0 | } |
252 | | |
253 | | /** |
254 | | * fu_struct_rmi_partition_tbl_parse: (skip): |
255 | | **/ |
256 | | FuStructRmiPartitionTbl * |
257 | | fu_struct_rmi_partition_tbl_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
258 | 0 | { |
259 | 0 | g_autoptr(FuStructRmiPartitionTbl) st = fu_struct_rmi_partition_tbl_new_internal(); |
260 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
261 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
262 | 0 | if (!fu_memchk_read(bufsz, offset, 8, error)) { |
263 | 0 | g_prefix_error_literal(error, "invalid struct FuStructRmiPartitionTbl: "); |
264 | 0 | return NULL; |
265 | 0 | } |
266 | 0 | st->buf = g_byte_array_new(); |
267 | 0 | g_byte_array_append(st->buf, buf + offset, 8); |
268 | 0 | if (!fu_struct_rmi_partition_tbl_parse_internal(st, error)) |
269 | 0 | return NULL; |
270 | 0 | return g_steal_pointer(&st); |
271 | 0 | } |
272 | | /** |
273 | | * fu_struct_rmi_img_ref: (skip): |
274 | | **/ |
275 | | FuStructRmiImg * |
276 | | fu_struct_rmi_img_ref(FuStructRmiImg *st) |
277 | 0 | { |
278 | 0 | g_return_val_if_fail(st != NULL, NULL); |
279 | 0 | st->refcount++; |
280 | 0 | return st; |
281 | 0 | } |
282 | | /** |
283 | | * fu_struct_rmi_img_unref: (skip): |
284 | | **/ |
285 | | void |
286 | | fu_struct_rmi_img_unref(FuStructRmiImg *st) |
287 | 1.06k | { |
288 | 1.06k | g_return_if_fail(st != NULL); |
289 | 1.06k | if (st->refcount == 0) { |
290 | 0 | g_critical("FuStructRmiImg refcount already zero"); |
291 | 0 | return; |
292 | 0 | } |
293 | 1.06k | if (--st->refcount > 0) |
294 | 0 | return; |
295 | 1.06k | if (st->buf != NULL) |
296 | 1.06k | g_byte_array_unref(st->buf); |
297 | 1.06k | g_free(st); |
298 | 1.06k | } |
299 | | /** |
300 | | * fu_struct_rmi_img_new_internal: (skip): |
301 | | **/ |
302 | | static FuStructRmiImg * |
303 | | fu_struct_rmi_img_new_internal(void) |
304 | 1.06k | { |
305 | 1.06k | FuStructRmiImg *st = g_new0(FuStructRmiImg, 1); |
306 | 1.06k | st->refcount = 1; |
307 | 1.06k | return st; |
308 | 1.06k | } |
309 | | |
310 | | /* getters */ |
311 | | /** |
312 | | * fu_struct_rmi_img_get_checksum: (skip): |
313 | | **/ |
314 | | guint32 |
315 | | fu_struct_rmi_img_get_checksum(const FuStructRmiImg *st) |
316 | 896 | { |
317 | 896 | g_return_val_if_fail(st != NULL, 0x0); |
318 | 896 | return fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
319 | 896 | } |
320 | | /** |
321 | | * fu_struct_rmi_img_get_io_offset: (skip): |
322 | | **/ |
323 | | guint8 |
324 | | fu_struct_rmi_img_get_io_offset(const FuStructRmiImg *st) |
325 | 896 | { |
326 | 896 | g_return_val_if_fail(st != NULL, 0x0); |
327 | 896 | return st->buf->data[6]; |
328 | 896 | } |
329 | | /** |
330 | | * fu_struct_rmi_img_get_bootloader_version: (skip): |
331 | | **/ |
332 | | guint8 |
333 | | fu_struct_rmi_img_get_bootloader_version(const FuStructRmiImg *st) |
334 | 896 | { |
335 | 896 | g_return_val_if_fail(st != NULL, 0x0); |
336 | 896 | return st->buf->data[7]; |
337 | 896 | } |
338 | | /** |
339 | | * fu_struct_rmi_img_get_image_size: (skip): |
340 | | **/ |
341 | | guint32 |
342 | | fu_struct_rmi_img_get_image_size(const FuStructRmiImg *st) |
343 | 998 | { |
344 | 998 | g_return_val_if_fail(st != NULL, 0x0); |
345 | 998 | return fu_memread_uint32(st->buf->data + 8, G_LITTLE_ENDIAN); |
346 | 998 | } |
347 | | /** |
348 | | * fu_struct_rmi_img_get_config_size: (skip): |
349 | | **/ |
350 | | guint32 |
351 | | fu_struct_rmi_img_get_config_size(const FuStructRmiImg *st) |
352 | 44 | { |
353 | 44 | g_return_val_if_fail(st != NULL, 0x0); |
354 | 44 | return fu_memread_uint32(st->buf->data + 12, G_LITTLE_ENDIAN); |
355 | 44 | } |
356 | | /** |
357 | | * fu_struct_rmi_img_get_product_id: (skip): |
358 | | **/ |
359 | | gchar * |
360 | | fu_struct_rmi_img_get_product_id(const FuStructRmiImg *st) |
361 | 896 | { |
362 | 896 | g_return_val_if_fail(st != NULL, NULL); |
363 | 896 | return fu_memstrsafe(st->buf->data, st->buf->len, 16, 10, NULL); |
364 | 896 | } |
365 | | /** |
366 | | * fu_struct_rmi_img_get_package_id: (skip): |
367 | | **/ |
368 | | guint32 |
369 | | fu_struct_rmi_img_get_package_id(const FuStructRmiImg *st) |
370 | 399 | { |
371 | 399 | g_return_val_if_fail(st != NULL, 0x0); |
372 | 399 | return fu_memread_uint32(st->buf->data + 26, G_LITTLE_ENDIAN); |
373 | 399 | } |
374 | | /** |
375 | | * fu_struct_rmi_img_get_product_info: (skip): |
376 | | **/ |
377 | | guint32 |
378 | | fu_struct_rmi_img_get_product_info(const FuStructRmiImg *st) |
379 | 896 | { |
380 | 896 | g_return_val_if_fail(st != NULL, 0x0); |
381 | 896 | return fu_memread_uint32(st->buf->data + 30, G_LITTLE_ENDIAN); |
382 | 896 | } |
383 | | /** |
384 | | * fu_struct_rmi_img_get_fw_build_id: (skip): |
385 | | **/ |
386 | | guint32 |
387 | | fu_struct_rmi_img_get_fw_build_id(const FuStructRmiImg *st) |
388 | 399 | { |
389 | 399 | g_return_val_if_fail(st != NULL, 0x0); |
390 | 399 | return fu_memread_uint32(st->buf->data + 80, G_LITTLE_ENDIAN); |
391 | 399 | } |
392 | | /** |
393 | | * fu_struct_rmi_img_get_signature_size: (skip): |
394 | | **/ |
395 | | guint32 |
396 | | fu_struct_rmi_img_get_signature_size(const FuStructRmiImg *st) |
397 | 78 | { |
398 | 78 | g_return_val_if_fail(st != NULL, 0x0); |
399 | 78 | return fu_memread_uint32(st->buf->data + 84, G_LITTLE_ENDIAN); |
400 | 78 | } |
401 | | |
402 | | /* setters */ |
403 | | /** |
404 | | * fu_struct_rmi_img_set_checksum: (skip): |
405 | | **/ |
406 | | void |
407 | | fu_struct_rmi_img_set_checksum(FuStructRmiImg *st, guint32 value) |
408 | 0 | { |
409 | 0 | g_return_if_fail(st != NULL); |
410 | 0 | fu_memwrite_uint32(st->buf->data + 0, value, G_LITTLE_ENDIAN); |
411 | 0 | } |
412 | | /** |
413 | | * fu_struct_rmi_img_set_io_offset: (skip): |
414 | | **/ |
415 | | void |
416 | | fu_struct_rmi_img_set_io_offset(FuStructRmiImg *st, guint8 value) |
417 | 0 | { |
418 | 0 | g_return_if_fail(st != NULL); |
419 | 0 | st->buf->data[6] = value; |
420 | 0 | } |
421 | | /** |
422 | | * fu_struct_rmi_img_set_bootloader_version: (skip): |
423 | | **/ |
424 | | void |
425 | | fu_struct_rmi_img_set_bootloader_version(FuStructRmiImg *st, guint8 value) |
426 | 0 | { |
427 | 0 | g_return_if_fail(st != NULL); |
428 | 0 | st->buf->data[7] = value; |
429 | 0 | } |
430 | | /** |
431 | | * fu_struct_rmi_img_set_image_size: (skip): |
432 | | **/ |
433 | | void |
434 | | fu_struct_rmi_img_set_image_size(FuStructRmiImg *st, guint32 value) |
435 | 0 | { |
436 | 0 | g_return_if_fail(st != NULL); |
437 | 0 | fu_memwrite_uint32(st->buf->data + 8, value, G_LITTLE_ENDIAN); |
438 | 0 | } |
439 | | /** |
440 | | * fu_struct_rmi_img_set_config_size: (skip): |
441 | | **/ |
442 | | void |
443 | | fu_struct_rmi_img_set_config_size(FuStructRmiImg *st, guint32 value) |
444 | 0 | { |
445 | 0 | g_return_if_fail(st != NULL); |
446 | 0 | fu_memwrite_uint32(st->buf->data + 12, value, G_LITTLE_ENDIAN); |
447 | 0 | } |
448 | | /** |
449 | | * fu_struct_rmi_img_set_product_id: (skip): |
450 | | **/ |
451 | | gboolean |
452 | | fu_struct_rmi_img_set_product_id(FuStructRmiImg *st, const gchar *value, GError **error) |
453 | 0 | { |
454 | 0 | gsize len; |
455 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
456 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
457 | 0 | if (value == NULL) { |
458 | 0 | memset(st->buf->data + 16, 0x0, 10); |
459 | 0 | return TRUE; |
460 | 0 | } |
461 | 0 | len = strlen(value); |
462 | 0 | if (len > 10) { |
463 | 0 | g_set_error(error, |
464 | 0 | FWUPD_ERROR, |
465 | 0 | FWUPD_ERROR_INVALID_DATA, |
466 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructRmiImg.product_id (0x%x bytes)", |
467 | 0 | value, (guint) len, (guint) 10); |
468 | 0 | return FALSE; |
469 | 0 | } |
470 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 16, (const guint8 *)value, len, 0x0, len, error); |
471 | 0 | } |
472 | | /** |
473 | | * fu_struct_rmi_img_set_package_id: (skip): |
474 | | **/ |
475 | | void |
476 | | fu_struct_rmi_img_set_package_id(FuStructRmiImg *st, guint32 value) |
477 | 0 | { |
478 | 0 | g_return_if_fail(st != NULL); |
479 | 0 | fu_memwrite_uint32(st->buf->data + 26, value, G_LITTLE_ENDIAN); |
480 | 0 | } |
481 | | /** |
482 | | * fu_struct_rmi_img_set_product_info: (skip): |
483 | | **/ |
484 | | void |
485 | | fu_struct_rmi_img_set_product_info(FuStructRmiImg *st, guint32 value) |
486 | 0 | { |
487 | 0 | g_return_if_fail(st != NULL); |
488 | 0 | fu_memwrite_uint32(st->buf->data + 30, value, G_LITTLE_ENDIAN); |
489 | 0 | } |
490 | | /** |
491 | | * fu_struct_rmi_img_set_fw_build_id: (skip): |
492 | | **/ |
493 | | void |
494 | | fu_struct_rmi_img_set_fw_build_id(FuStructRmiImg *st, guint32 value) |
495 | 0 | { |
496 | 0 | g_return_if_fail(st != NULL); |
497 | 0 | fu_memwrite_uint32(st->buf->data + 80, value, G_LITTLE_ENDIAN); |
498 | 0 | } |
499 | | /** |
500 | | * fu_struct_rmi_img_set_signature_size: (skip): |
501 | | **/ |
502 | | void |
503 | | fu_struct_rmi_img_set_signature_size(FuStructRmiImg *st, guint32 value) |
504 | 0 | { |
505 | 0 | g_return_if_fail(st != NULL); |
506 | 0 | fu_memwrite_uint32(st->buf->data + 84, value, G_LITTLE_ENDIAN); |
507 | 0 | } |
508 | | /** |
509 | | * fu_struct_rmi_img_new: (skip): |
510 | | **/ |
511 | | FuStructRmiImg * |
512 | | fu_struct_rmi_img_new(void) |
513 | 4 | { |
514 | 4 | FuStructRmiImg *st = fu_struct_rmi_img_new_internal(); |
515 | 4 | st->buf = g_byte_array_sized_new(88); |
516 | 4 | fu_byte_array_set_size(st->buf, 88, 0x0); |
517 | 4 | return st; |
518 | 4 | } |
519 | | /** |
520 | | * fu_struct_rmi_img_to_string: (skip): |
521 | | **/ |
522 | | static gchar * |
523 | | fu_struct_rmi_img_to_string(const FuStructRmiImg *st) |
524 | 0 | { |
525 | 0 | g_autoptr(GString) str = g_string_new("FuStructRmiImg:\n"); |
526 | 0 | g_return_val_if_fail(st != NULL, NULL); |
527 | 0 | g_string_append_printf(str, " checksum: 0x%x\n", |
528 | 0 | (guint) fu_struct_rmi_img_get_checksum(st)); |
529 | 0 | g_string_append_printf(str, " io_offset: 0x%x\n", |
530 | 0 | (guint) fu_struct_rmi_img_get_io_offset(st)); |
531 | 0 | g_string_append_printf(str, " bootloader_version: 0x%x\n", |
532 | 0 | (guint) fu_struct_rmi_img_get_bootloader_version(st)); |
533 | 0 | g_string_append_printf(str, " image_size: 0x%x\n", |
534 | 0 | (guint) fu_struct_rmi_img_get_image_size(st)); |
535 | 0 | g_string_append_printf(str, " config_size: 0x%x\n", |
536 | 0 | (guint) fu_struct_rmi_img_get_config_size(st)); |
537 | 0 | { |
538 | 0 | g_autofree gchar *tmp = fu_struct_rmi_img_get_product_id(st); |
539 | 0 | if (tmp != NULL) |
540 | 0 | g_string_append_printf(str, " product_id: %s\n", tmp); |
541 | 0 | } |
542 | 0 | g_string_append_printf(str, " package_id: 0x%x\n", |
543 | 0 | (guint) fu_struct_rmi_img_get_package_id(st)); |
544 | 0 | g_string_append_printf(str, " product_info: 0x%x\n", |
545 | 0 | (guint) fu_struct_rmi_img_get_product_info(st)); |
546 | 0 | g_string_append_printf(str, " fw_build_id: 0x%x\n", |
547 | 0 | (guint) fu_struct_rmi_img_get_fw_build_id(st)); |
548 | 0 | g_string_append_printf(str, " signature_size: 0x%x\n", |
549 | 0 | (guint) fu_struct_rmi_img_get_signature_size(st)); |
550 | 0 | if (str->len > 0) |
551 | 0 | g_string_set_size(str, str->len - 1); |
552 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
553 | 0 | } |
554 | | static gboolean |
555 | | fu_struct_rmi_img_validate_internal(FuStructRmiImg *st, GError **error) |
556 | 1.03k | { |
557 | 1.03k | g_return_val_if_fail(st != NULL, FALSE); |
558 | 1.03k | return TRUE; |
559 | 1.03k | } |
560 | | static gboolean |
561 | | fu_struct_rmi_img_parse_internal(FuStructRmiImg *st, GError **error) |
562 | 1.03k | { |
563 | 1.03k | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
564 | 0 | g_autofree gchar *str = fu_struct_rmi_img_to_string(st); |
565 | 0 | g_debug("%s", str); |
566 | 0 | } |
567 | 1.03k | if (!fu_struct_rmi_img_validate_internal(st, error)) |
568 | 0 | return FALSE; |
569 | 1.03k | return TRUE; |
570 | 1.03k | } |
571 | | /** |
572 | | * fu_struct_rmi_img_parse_stream: (skip): |
573 | | **/ |
574 | | FuStructRmiImg * |
575 | | fu_struct_rmi_img_parse_stream(GInputStream *stream, gsize offset, GError **error) |
576 | 1.06k | { |
577 | 1.06k | g_autoptr(FuStructRmiImg) st = fu_struct_rmi_img_new_internal(); |
578 | 1.06k | st->buf = fu_input_stream_read_byte_array(stream, offset, 88, NULL, error); |
579 | 1.06k | if (st->buf == NULL) { |
580 | 0 | g_prefix_error(error, "FuStructRmiImg failed read of 0x%x: ", (guint) 88); |
581 | 0 | return NULL; |
582 | 0 | } |
583 | 1.06k | if (st->buf->len != 88) { |
584 | 25 | g_set_error(error, |
585 | 25 | FWUPD_ERROR, |
586 | 25 | FWUPD_ERROR_INVALID_DATA, |
587 | 25 | "FuStructRmiImg requested 0x%x and got 0x%x", |
588 | 25 | (guint) 88, |
589 | 25 | (guint) st->buf->len); |
590 | 25 | return NULL; |
591 | 25 | } |
592 | 1.03k | if (!fu_struct_rmi_img_parse_internal(st, error)) |
593 | 0 | return NULL; |
594 | 1.03k | return g_steal_pointer(&st); |
595 | 1.03k | } |
596 | | /** |
597 | | * fu_struct_rmi_container_descriptor_ref: (skip): |
598 | | **/ |
599 | | FuStructRmiContainerDescriptor * |
600 | | fu_struct_rmi_container_descriptor_ref(FuStructRmiContainerDescriptor *st) |
601 | 0 | { |
602 | 0 | g_return_val_if_fail(st != NULL, NULL); |
603 | 0 | st->refcount++; |
604 | 0 | return st; |
605 | 0 | } |
606 | | /** |
607 | | * fu_struct_rmi_container_descriptor_unref: (skip): |
608 | | **/ |
609 | | void |
610 | | fu_struct_rmi_container_descriptor_unref(FuStructRmiContainerDescriptor *st) |
611 | 76.6k | { |
612 | 76.6k | g_return_if_fail(st != NULL); |
613 | 76.6k | if (st->refcount == 0) { |
614 | 0 | g_critical("FuStructRmiContainerDescriptor refcount already zero"); |
615 | 0 | return; |
616 | 0 | } |
617 | 76.6k | if (--st->refcount > 0) |
618 | 0 | return; |
619 | 76.6k | if (st->buf != NULL) |
620 | 76.4k | g_byte_array_unref(st->buf); |
621 | 76.6k | g_free(st); |
622 | 76.6k | } |
623 | | /** |
624 | | * fu_struct_rmi_container_descriptor_new_internal: (skip): |
625 | | **/ |
626 | | static FuStructRmiContainerDescriptor * |
627 | | fu_struct_rmi_container_descriptor_new_internal(void) |
628 | 76.6k | { |
629 | 76.6k | FuStructRmiContainerDescriptor *st = g_new0(FuStructRmiContainerDescriptor, 1); |
630 | 76.6k | st->refcount = 1; |
631 | 76.6k | return st; |
632 | 76.6k | } |
633 | | |
634 | | /* getters */ |
635 | | /** |
636 | | * fu_struct_rmi_container_descriptor_get_content_checksum: (skip): |
637 | | **/ |
638 | | guint32 |
639 | | fu_struct_rmi_container_descriptor_get_content_checksum(const FuStructRmiContainerDescriptor *st) |
640 | 0 | { |
641 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
642 | 0 | return fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
643 | 0 | } |
644 | | /** |
645 | | * fu_struct_rmi_container_descriptor_get_container_id: (skip): |
646 | | **/ |
647 | | FuRmiContainerId |
648 | | fu_struct_rmi_container_descriptor_get_container_id(const FuStructRmiContainerDescriptor *st) |
649 | 72.9k | { |
650 | 72.9k | g_return_val_if_fail(st != NULL, 0x0); |
651 | 72.9k | return fu_memread_uint16(st->buf->data + 4, G_LITTLE_ENDIAN); |
652 | 72.9k | } |
653 | | /** |
654 | | * fu_struct_rmi_container_descriptor_get_minor_version: (skip): |
655 | | **/ |
656 | | guint8 |
657 | | fu_struct_rmi_container_descriptor_get_minor_version(const FuStructRmiContainerDescriptor *st) |
658 | 0 | { |
659 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
660 | 0 | return st->buf->data[6]; |
661 | 0 | } |
662 | | /** |
663 | | * fu_struct_rmi_container_descriptor_get_major_version: (skip): |
664 | | **/ |
665 | | guint8 |
666 | | fu_struct_rmi_container_descriptor_get_major_version(const FuStructRmiContainerDescriptor *st) |
667 | 0 | { |
668 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
669 | 0 | return st->buf->data[7]; |
670 | 0 | } |
671 | | /** |
672 | | * fu_struct_rmi_container_descriptor_get_signature_size: (skip): |
673 | | **/ |
674 | | guint32 |
675 | | fu_struct_rmi_container_descriptor_get_signature_size(const FuStructRmiContainerDescriptor *st) |
676 | 72.2k | { |
677 | 72.2k | g_return_val_if_fail(st != NULL, 0x0); |
678 | 72.2k | return fu_memread_uint32(st->buf->data + 8, G_LITTLE_ENDIAN); |
679 | 72.2k | } |
680 | | /** |
681 | | * fu_struct_rmi_container_descriptor_get_container_option_flags: (skip): |
682 | | **/ |
683 | | guint32 |
684 | | fu_struct_rmi_container_descriptor_get_container_option_flags(const FuStructRmiContainerDescriptor *st) |
685 | 0 | { |
686 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
687 | 0 | return fu_memread_uint32(st->buf->data + 12, G_LITTLE_ENDIAN); |
688 | 0 | } |
689 | | /** |
690 | | * fu_struct_rmi_container_descriptor_get_content_options_length: (skip): |
691 | | **/ |
692 | | guint32 |
693 | | fu_struct_rmi_container_descriptor_get_content_options_length(const FuStructRmiContainerDescriptor *st) |
694 | 0 | { |
695 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
696 | 0 | return fu_memread_uint32(st->buf->data + 16, G_LITTLE_ENDIAN); |
697 | 0 | } |
698 | | /** |
699 | | * fu_struct_rmi_container_descriptor_get_content_options_address: (skip): |
700 | | **/ |
701 | | guint32 |
702 | | fu_struct_rmi_container_descriptor_get_content_options_address(const FuStructRmiContainerDescriptor *st) |
703 | 0 | { |
704 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
705 | 0 | return fu_memread_uint32(st->buf->data + 20, G_LITTLE_ENDIAN); |
706 | 0 | } |
707 | | /** |
708 | | * fu_struct_rmi_container_descriptor_get_content_length: (skip): |
709 | | **/ |
710 | | guint32 |
711 | | fu_struct_rmi_container_descriptor_get_content_length(const FuStructRmiContainerDescriptor *st) |
712 | 76.2k | { |
713 | 76.2k | g_return_val_if_fail(st != NULL, 0x0); |
714 | 76.2k | return fu_memread_uint32(st->buf->data + 24, G_LITTLE_ENDIAN); |
715 | 76.2k | } |
716 | | /** |
717 | | * fu_struct_rmi_container_descriptor_get_content_address: (skip): |
718 | | **/ |
719 | | guint32 |
720 | | fu_struct_rmi_container_descriptor_get_content_address(const FuStructRmiContainerDescriptor *st) |
721 | 76.2k | { |
722 | 76.2k | g_return_val_if_fail(st != NULL, 0x0); |
723 | 76.2k | return fu_memread_uint32(st->buf->data + 28, G_LITTLE_ENDIAN); |
724 | 76.2k | } |
725 | | |
726 | | /* setters */ |
727 | | /** |
728 | | * fu_struct_rmi_container_descriptor_set_content_checksum: (skip): |
729 | | **/ |
730 | | void |
731 | | fu_struct_rmi_container_descriptor_set_content_checksum(FuStructRmiContainerDescriptor *st, guint32 value) |
732 | 0 | { |
733 | 0 | g_return_if_fail(st != NULL); |
734 | 0 | fu_memwrite_uint32(st->buf->data + 0, value, G_LITTLE_ENDIAN); |
735 | 0 | } |
736 | | /** |
737 | | * fu_struct_rmi_container_descriptor_set_container_id: (skip): |
738 | | **/ |
739 | | void |
740 | | fu_struct_rmi_container_descriptor_set_container_id(FuStructRmiContainerDescriptor *st, FuRmiContainerId value) |
741 | 114 | { |
742 | 114 | g_return_if_fail(st != NULL); |
743 | 114 | fu_memwrite_uint16(st->buf->data + 4, value, G_LITTLE_ENDIAN); |
744 | 114 | } |
745 | | /** |
746 | | * fu_struct_rmi_container_descriptor_set_minor_version: (skip): |
747 | | **/ |
748 | | void |
749 | | fu_struct_rmi_container_descriptor_set_minor_version(FuStructRmiContainerDescriptor *st, guint8 value) |
750 | 0 | { |
751 | 0 | g_return_if_fail(st != NULL); |
752 | 0 | st->buf->data[6] = value; |
753 | 0 | } |
754 | | /** |
755 | | * fu_struct_rmi_container_descriptor_set_major_version: (skip): |
756 | | **/ |
757 | | void |
758 | | fu_struct_rmi_container_descriptor_set_major_version(FuStructRmiContainerDescriptor *st, guint8 value) |
759 | 0 | { |
760 | 0 | g_return_if_fail(st != NULL); |
761 | 0 | st->buf->data[7] = value; |
762 | 0 | } |
763 | | /** |
764 | | * fu_struct_rmi_container_descriptor_set_signature_size: (skip): |
765 | | **/ |
766 | | void |
767 | | fu_struct_rmi_container_descriptor_set_signature_size(FuStructRmiContainerDescriptor *st, guint32 value) |
768 | 0 | { |
769 | 0 | g_return_if_fail(st != NULL); |
770 | 0 | fu_memwrite_uint32(st->buf->data + 8, value, G_LITTLE_ENDIAN); |
771 | 0 | } |
772 | | /** |
773 | | * fu_struct_rmi_container_descriptor_set_container_option_flags: (skip): |
774 | | **/ |
775 | | void |
776 | | fu_struct_rmi_container_descriptor_set_container_option_flags(FuStructRmiContainerDescriptor *st, guint32 value) |
777 | 0 | { |
778 | 0 | g_return_if_fail(st != NULL); |
779 | 0 | fu_memwrite_uint32(st->buf->data + 12, value, G_LITTLE_ENDIAN); |
780 | 0 | } |
781 | | /** |
782 | | * fu_struct_rmi_container_descriptor_set_content_options_length: (skip): |
783 | | **/ |
784 | | void |
785 | | fu_struct_rmi_container_descriptor_set_content_options_length(FuStructRmiContainerDescriptor *st, guint32 value) |
786 | 0 | { |
787 | 0 | g_return_if_fail(st != NULL); |
788 | 0 | fu_memwrite_uint32(st->buf->data + 16, value, G_LITTLE_ENDIAN); |
789 | 0 | } |
790 | | /** |
791 | | * fu_struct_rmi_container_descriptor_set_content_options_address: (skip): |
792 | | **/ |
793 | | void |
794 | | fu_struct_rmi_container_descriptor_set_content_options_address(FuStructRmiContainerDescriptor *st, guint32 value) |
795 | 0 | { |
796 | 0 | g_return_if_fail(st != NULL); |
797 | 0 | fu_memwrite_uint32(st->buf->data + 20, value, G_LITTLE_ENDIAN); |
798 | 0 | } |
799 | | /** |
800 | | * fu_struct_rmi_container_descriptor_set_content_length: (skip): |
801 | | **/ |
802 | | void |
803 | | fu_struct_rmi_container_descriptor_set_content_length(FuStructRmiContainerDescriptor *st, guint32 value) |
804 | 0 | { |
805 | 0 | g_return_if_fail(st != NULL); |
806 | 0 | fu_memwrite_uint32(st->buf->data + 24, value, G_LITTLE_ENDIAN); |
807 | 0 | } |
808 | | /** |
809 | | * fu_struct_rmi_container_descriptor_set_content_address: (skip): |
810 | | **/ |
811 | | void |
812 | | fu_struct_rmi_container_descriptor_set_content_address(FuStructRmiContainerDescriptor *st, guint32 value) |
813 | 114 | { |
814 | 114 | g_return_if_fail(st != NULL); |
815 | 114 | fu_memwrite_uint32(st->buf->data + 28, value, G_LITTLE_ENDIAN); |
816 | 114 | } |
817 | | /** |
818 | | * fu_struct_rmi_container_descriptor_new: (skip): |
819 | | **/ |
820 | | FuStructRmiContainerDescriptor * |
821 | | fu_struct_rmi_container_descriptor_new(void) |
822 | 228 | { |
823 | 228 | FuStructRmiContainerDescriptor *st = fu_struct_rmi_container_descriptor_new_internal(); |
824 | 228 | st->buf = g_byte_array_sized_new(32); |
825 | 228 | fu_byte_array_set_size(st->buf, 32, 0x0); |
826 | 228 | return st; |
827 | 228 | } |
828 | | /** |
829 | | * fu_struct_rmi_container_descriptor_to_string: (skip): |
830 | | **/ |
831 | | static gchar * |
832 | | fu_struct_rmi_container_descriptor_to_string(const FuStructRmiContainerDescriptor *st) |
833 | 0 | { |
834 | 0 | g_autoptr(GString) str = g_string_new("FuStructRmiContainerDescriptor:\n"); |
835 | 0 | g_return_val_if_fail(st != NULL, NULL); |
836 | 0 | g_string_append_printf(str, " content_checksum: 0x%x\n", |
837 | 0 | (guint) fu_struct_rmi_container_descriptor_get_content_checksum(st)); |
838 | 0 | { |
839 | 0 | const gchar *tmp = fu_rmi_container_id_to_string(fu_struct_rmi_container_descriptor_get_container_id(st)); |
840 | 0 | if (tmp != NULL) { |
841 | 0 | g_string_append_printf(str, " container_id: 0x%x [%s]\n", (guint) fu_struct_rmi_container_descriptor_get_container_id(st), tmp); |
842 | 0 | } else { |
843 | 0 | g_string_append_printf(str, " container_id: 0x%x\n", (guint) fu_struct_rmi_container_descriptor_get_container_id(st)); |
844 | 0 | } |
845 | 0 | } |
846 | 0 | g_string_append_printf(str, " minor_version: 0x%x\n", |
847 | 0 | (guint) fu_struct_rmi_container_descriptor_get_minor_version(st)); |
848 | 0 | g_string_append_printf(str, " major_version: 0x%x\n", |
849 | 0 | (guint) fu_struct_rmi_container_descriptor_get_major_version(st)); |
850 | 0 | g_string_append_printf(str, " signature_size: 0x%x\n", |
851 | 0 | (guint) fu_struct_rmi_container_descriptor_get_signature_size(st)); |
852 | 0 | g_string_append_printf(str, " container_option_flags: 0x%x\n", |
853 | 0 | (guint) fu_struct_rmi_container_descriptor_get_container_option_flags(st)); |
854 | 0 | g_string_append_printf(str, " content_options_length: 0x%x\n", |
855 | 0 | (guint) fu_struct_rmi_container_descriptor_get_content_options_length(st)); |
856 | 0 | g_string_append_printf(str, " content_options_address: 0x%x\n", |
857 | 0 | (guint) fu_struct_rmi_container_descriptor_get_content_options_address(st)); |
858 | 0 | g_string_append_printf(str, " content_length: 0x%x\n", |
859 | 0 | (guint) fu_struct_rmi_container_descriptor_get_content_length(st)); |
860 | 0 | g_string_append_printf(str, " content_address: 0x%x\n", |
861 | 0 | (guint) fu_struct_rmi_container_descriptor_get_content_address(st)); |
862 | 0 | if (str->len > 0) |
863 | 0 | g_string_set_size(str, str->len - 1); |
864 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
865 | 0 | } |
866 | | static gboolean |
867 | | fu_struct_rmi_container_descriptor_validate_internal(FuStructRmiContainerDescriptor *st, GError **error) |
868 | 76.2k | { |
869 | 76.2k | g_return_val_if_fail(st != NULL, FALSE); |
870 | 76.2k | return TRUE; |
871 | 76.2k | } |
872 | | static gboolean |
873 | | fu_struct_rmi_container_descriptor_parse_internal(FuStructRmiContainerDescriptor *st, GError **error) |
874 | 76.2k | { |
875 | 76.2k | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
876 | 0 | g_autofree gchar *str = fu_struct_rmi_container_descriptor_to_string(st); |
877 | 0 | g_debug("%s", str); |
878 | 0 | } |
879 | 76.2k | if (!fu_struct_rmi_container_descriptor_validate_internal(st, error)) |
880 | 0 | return FALSE; |
881 | 76.2k | return TRUE; |
882 | 76.2k | } |
883 | | /** |
884 | | * fu_struct_rmi_container_descriptor_parse_stream: (skip): |
885 | | **/ |
886 | | FuStructRmiContainerDescriptor * |
887 | | fu_struct_rmi_container_descriptor_parse_stream(GInputStream *stream, gsize offset, GError **error) |
888 | 76.4k | { |
889 | 76.4k | g_autoptr(FuStructRmiContainerDescriptor) st = fu_struct_rmi_container_descriptor_new_internal(); |
890 | 76.4k | st->buf = fu_input_stream_read_byte_array(stream, offset, 32, NULL, error); |
891 | 76.4k | if (st->buf == NULL) { |
892 | 212 | g_prefix_error(error, "FuStructRmiContainerDescriptor failed read of 0x%x: ", (guint) 32); |
893 | 212 | return NULL; |
894 | 212 | } |
895 | 76.2k | if (st->buf->len != 32) { |
896 | 9 | g_set_error(error, |
897 | 9 | FWUPD_ERROR, |
898 | 9 | FWUPD_ERROR_INVALID_DATA, |
899 | 9 | "FuStructRmiContainerDescriptor requested 0x%x and got 0x%x", |
900 | 9 | (guint) 32, |
901 | 9 | (guint) st->buf->len); |
902 | 9 | return NULL; |
903 | 9 | } |
904 | 76.2k | if (!fu_struct_rmi_container_descriptor_parse_internal(st, error)) |
905 | 0 | return NULL; |
906 | 76.2k | return g_steal_pointer(&st); |
907 | 76.2k | } |
908 | | /** |
909 | | * fu_struct_synaptics_rmi_v7_f34x_ref: (skip): |
910 | | **/ |
911 | | FuStructSynapticsRmiV7F34x * |
912 | | fu_struct_synaptics_rmi_v7_f34x_ref(FuStructSynapticsRmiV7F34x *st) |
913 | 0 | { |
914 | 0 | g_return_val_if_fail(st != NULL, NULL); |
915 | 0 | st->refcount++; |
916 | 0 | return st; |
917 | 0 | } |
918 | | /** |
919 | | * fu_struct_synaptics_rmi_v7_f34x_unref: (skip): |
920 | | **/ |
921 | | void |
922 | | fu_struct_synaptics_rmi_v7_f34x_unref(FuStructSynapticsRmiV7F34x *st) |
923 | 0 | { |
924 | 0 | g_return_if_fail(st != NULL); |
925 | 0 | if (st->refcount == 0) { |
926 | 0 | g_critical("FuStructSynapticsRmiV7F34x refcount already zero"); |
927 | 0 | return; |
928 | 0 | } |
929 | 0 | if (--st->refcount > 0) |
930 | 0 | return; |
931 | 0 | if (st->buf != NULL) |
932 | 0 | g_byte_array_unref(st->buf); |
933 | 0 | g_free(st); |
934 | 0 | } |
935 | | /** |
936 | | * fu_struct_synaptics_rmi_v7_f34x_new_internal: (skip): |
937 | | **/ |
938 | | static FuStructSynapticsRmiV7F34x * |
939 | | fu_struct_synaptics_rmi_v7_f34x_new_internal(void) |
940 | 0 | { |
941 | 0 | FuStructSynapticsRmiV7F34x *st = g_new0(FuStructSynapticsRmiV7F34x, 1); |
942 | 0 | st->refcount = 1; |
943 | 0 | return st; |
944 | 0 | } |
945 | | |
946 | | /* getters */ |
947 | | /** |
948 | | * fu_struct_synaptics_rmi_v7_f34x_get_bootloader_id0: (skip): |
949 | | **/ |
950 | | guint8 |
951 | | fu_struct_synaptics_rmi_v7_f34x_get_bootloader_id0(const FuStructSynapticsRmiV7F34x *st) |
952 | 0 | { |
953 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
954 | 0 | return st->buf->data[0]; |
955 | 0 | } |
956 | | /** |
957 | | * fu_struct_synaptics_rmi_v7_f34x_get_bootloader_id1: (skip): |
958 | | **/ |
959 | | guint8 |
960 | | fu_struct_synaptics_rmi_v7_f34x_get_bootloader_id1(const FuStructSynapticsRmiV7F34x *st) |
961 | 0 | { |
962 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
963 | 0 | return st->buf->data[1]; |
964 | 0 | } |
965 | | /** |
966 | | * fu_struct_synaptics_rmi_v7_f34x_get_build_id: (skip): |
967 | | **/ |
968 | | guint32 |
969 | | fu_struct_synaptics_rmi_v7_f34x_get_build_id(const FuStructSynapticsRmiV7F34x *st) |
970 | 0 | { |
971 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
972 | 0 | return fu_memread_uint32(st->buf->data + 2, G_LITTLE_ENDIAN); |
973 | 0 | } |
974 | | /** |
975 | | * fu_struct_synaptics_rmi_v7_f34x_get_block_size: (skip): |
976 | | **/ |
977 | | guint16 |
978 | | fu_struct_synaptics_rmi_v7_f34x_get_block_size(const FuStructSynapticsRmiV7F34x *st) |
979 | 0 | { |
980 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
981 | 0 | return fu_memread_uint16(st->buf->data + 7, G_LITTLE_ENDIAN); |
982 | 0 | } |
983 | | /** |
984 | | * fu_struct_synaptics_rmi_v7_f34x_get_config_length: (skip): |
985 | | **/ |
986 | | guint16 |
987 | | fu_struct_synaptics_rmi_v7_f34x_get_config_length(const FuStructSynapticsRmiV7F34x *st) |
988 | 0 | { |
989 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
990 | 0 | return fu_memread_uint16(st->buf->data + 13, G_LITTLE_ENDIAN); |
991 | 0 | } |
992 | | /** |
993 | | * fu_struct_synaptics_rmi_v7_f34x_get_payload_length: (skip): |
994 | | **/ |
995 | | guint16 |
996 | | fu_struct_synaptics_rmi_v7_f34x_get_payload_length(const FuStructSynapticsRmiV7F34x *st) |
997 | 0 | { |
998 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
999 | 0 | return fu_memread_uint16(st->buf->data + 15, G_LITTLE_ENDIAN); |
1000 | 0 | } |
1001 | | /** |
1002 | | * fu_struct_synaptics_rmi_v7_f34x_get_supported_partitions: (skip): |
1003 | | **/ |
1004 | | guint16 |
1005 | | fu_struct_synaptics_rmi_v7_f34x_get_supported_partitions(const FuStructSynapticsRmiV7F34x *st) |
1006 | 0 | { |
1007 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1008 | 0 | return fu_memread_uint16(st->buf->data + 17, G_LITTLE_ENDIAN); |
1009 | 0 | } |
1010 | | |
1011 | | /* setters */ |
1012 | | /** |
1013 | | * fu_struct_synaptics_rmi_v7_f34x_to_string: (skip): |
1014 | | **/ |
1015 | | static gchar * |
1016 | | fu_struct_synaptics_rmi_v7_f34x_to_string(const FuStructSynapticsRmiV7F34x *st) |
1017 | 0 | { |
1018 | 0 | g_autoptr(GString) str = g_string_new("FuStructSynapticsRmiV7F34x:\n"); |
1019 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1020 | 0 | g_string_append_printf(str, " bootloader_id0: 0x%x\n", |
1021 | 0 | (guint) fu_struct_synaptics_rmi_v7_f34x_get_bootloader_id0(st)); |
1022 | 0 | g_string_append_printf(str, " bootloader_id1: 0x%x\n", |
1023 | 0 | (guint) fu_struct_synaptics_rmi_v7_f34x_get_bootloader_id1(st)); |
1024 | 0 | g_string_append_printf(str, " build_id: 0x%x\n", |
1025 | 0 | (guint) fu_struct_synaptics_rmi_v7_f34x_get_build_id(st)); |
1026 | 0 | g_string_append_printf(str, " block_size: 0x%x\n", |
1027 | 0 | (guint) fu_struct_synaptics_rmi_v7_f34x_get_block_size(st)); |
1028 | 0 | g_string_append_printf(str, " config_length: 0x%x\n", |
1029 | 0 | (guint) fu_struct_synaptics_rmi_v7_f34x_get_config_length(st)); |
1030 | 0 | g_string_append_printf(str, " payload_length: 0x%x\n", |
1031 | 0 | (guint) fu_struct_synaptics_rmi_v7_f34x_get_payload_length(st)); |
1032 | 0 | g_string_append_printf(str, " supported_partitions: 0x%x\n", |
1033 | 0 | (guint) fu_struct_synaptics_rmi_v7_f34x_get_supported_partitions(st)); |
1034 | 0 | if (str->len > 0) |
1035 | 0 | g_string_set_size(str, str->len - 1); |
1036 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1037 | 0 | } |
1038 | | static gboolean |
1039 | | fu_struct_synaptics_rmi_v7_f34x_validate_internal(FuStructSynapticsRmiV7F34x *st, GError **error) |
1040 | 0 | { |
1041 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
1042 | 0 | return TRUE; |
1043 | 0 | } |
1044 | | static gboolean |
1045 | | fu_struct_synaptics_rmi_v7_f34x_parse_internal(FuStructSynapticsRmiV7F34x *st, GError **error) |
1046 | 0 | { |
1047 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
1048 | 0 | g_autofree gchar *str = fu_struct_synaptics_rmi_v7_f34x_to_string(st); |
1049 | 0 | g_debug("%s", str); |
1050 | 0 | } |
1051 | 0 | if (!fu_struct_synaptics_rmi_v7_f34x_validate_internal(st, error)) |
1052 | 0 | return FALSE; |
1053 | 0 | return TRUE; |
1054 | 0 | } |
1055 | | |
1056 | | /** |
1057 | | * fu_struct_synaptics_rmi_v7_f34x_parse: (skip): |
1058 | | **/ |
1059 | | FuStructSynapticsRmiV7F34x * |
1060 | | fu_struct_synaptics_rmi_v7_f34x_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
1061 | 0 | { |
1062 | 0 | g_autoptr(FuStructSynapticsRmiV7F34x) st = fu_struct_synaptics_rmi_v7_f34x_new_internal(); |
1063 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
1064 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
1065 | 0 | if (!fu_memchk_read(bufsz, offset, 19, error)) { |
1066 | 0 | g_prefix_error_literal(error, "invalid struct FuStructSynapticsRmiV7F34x: "); |
1067 | 0 | return NULL; |
1068 | 0 | } |
1069 | 0 | st->buf = g_byte_array_new(); |
1070 | 0 | g_byte_array_append(st->buf, buf + offset, 19); |
1071 | 0 | if (!fu_struct_synaptics_rmi_v7_f34x_parse_internal(st, error)) |
1072 | 0 | return NULL; |
1073 | 0 | return g_steal_pointer(&st); |
1074 | 0 | } |
1075 | | /** |
1076 | | * fu_struct_synaptics_rmi_v7_enter_sbl_ref: (skip): |
1077 | | **/ |
1078 | | FuStructSynapticsRmiV7EnterSbl * |
1079 | | fu_struct_synaptics_rmi_v7_enter_sbl_ref(FuStructSynapticsRmiV7EnterSbl *st) |
1080 | 0 | { |
1081 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1082 | 0 | st->refcount++; |
1083 | 0 | return st; |
1084 | 0 | } |
1085 | | /** |
1086 | | * fu_struct_synaptics_rmi_v7_enter_sbl_unref: (skip): |
1087 | | **/ |
1088 | | void |
1089 | | fu_struct_synaptics_rmi_v7_enter_sbl_unref(FuStructSynapticsRmiV7EnterSbl *st) |
1090 | 0 | { |
1091 | 0 | g_return_if_fail(st != NULL); |
1092 | 0 | if (st->refcount == 0) { |
1093 | 0 | g_critical("FuStructSynapticsRmiV7EnterSbl refcount already zero"); |
1094 | 0 | return; |
1095 | 0 | } |
1096 | 0 | if (--st->refcount > 0) |
1097 | 0 | return; |
1098 | 0 | if (st->buf != NULL) |
1099 | 0 | g_byte_array_unref(st->buf); |
1100 | 0 | g_free(st); |
1101 | 0 | } |
1102 | | /** |
1103 | | * fu_struct_synaptics_rmi_v7_enter_sbl_new_internal: (skip): |
1104 | | **/ |
1105 | | static FuStructSynapticsRmiV7EnterSbl * |
1106 | | fu_struct_synaptics_rmi_v7_enter_sbl_new_internal(void) |
1107 | 0 | { |
1108 | 0 | FuStructSynapticsRmiV7EnterSbl *st = g_new0(FuStructSynapticsRmiV7EnterSbl, 1); |
1109 | 0 | st->refcount = 1; |
1110 | 0 | return st; |
1111 | 0 | } |
1112 | | |
1113 | | /* getters */ |
1114 | | |
1115 | | /* setters */ |
1116 | | /** |
1117 | | * fu_struct_synaptics_rmi_v7_enter_sbl_set_partition_id: (skip): |
1118 | | **/ |
1119 | | static void |
1120 | | fu_struct_synaptics_rmi_v7_enter_sbl_set_partition_id(FuStructSynapticsRmiV7EnterSbl *st, FuRmiPartitionId value) |
1121 | 0 | { |
1122 | 0 | g_return_if_fail(st != NULL); |
1123 | 0 | st->buf->data[0] = value; |
1124 | 0 | } |
1125 | | /** |
1126 | | * fu_struct_synaptics_rmi_v7_enter_sbl_set_cmd: (skip): |
1127 | | **/ |
1128 | | static void |
1129 | | fu_struct_synaptics_rmi_v7_enter_sbl_set_cmd(FuStructSynapticsRmiV7EnterSbl *st, FuSynapticsRmiFlashCmd value) |
1130 | 0 | { |
1131 | 0 | g_return_if_fail(st != NULL); |
1132 | 0 | st->buf->data[5] = value; |
1133 | 0 | } |
1134 | | /** |
1135 | | * fu_struct_synaptics_rmi_v7_enter_sbl_set_bootloader_id0: (skip): |
1136 | | **/ |
1137 | | void |
1138 | | fu_struct_synaptics_rmi_v7_enter_sbl_set_bootloader_id0(FuStructSynapticsRmiV7EnterSbl *st, guint8 value) |
1139 | 0 | { |
1140 | 0 | g_return_if_fail(st != NULL); |
1141 | 0 | st->buf->data[6] = value; |
1142 | 0 | } |
1143 | | /** |
1144 | | * fu_struct_synaptics_rmi_v7_enter_sbl_set_bootloader_id1: (skip): |
1145 | | **/ |
1146 | | void |
1147 | | fu_struct_synaptics_rmi_v7_enter_sbl_set_bootloader_id1(FuStructSynapticsRmiV7EnterSbl *st, guint8 value) |
1148 | 0 | { |
1149 | 0 | g_return_if_fail(st != NULL); |
1150 | 0 | st->buf->data[7] = value; |
1151 | 0 | } |
1152 | | /** |
1153 | | * fu_struct_synaptics_rmi_v7_enter_sbl_set_unknown: (skip): |
1154 | | **/ |
1155 | | static void |
1156 | | fu_struct_synaptics_rmi_v7_enter_sbl_set_unknown(FuStructSynapticsRmiV7EnterSbl *st, guint8 value) |
1157 | 0 | { |
1158 | 0 | g_return_if_fail(st != NULL); |
1159 | 0 | st->buf->data[8] = value; |
1160 | 0 | } |
1161 | | /** |
1162 | | * fu_struct_synaptics_rmi_v7_enter_sbl_new: (skip): |
1163 | | **/ |
1164 | | FuStructSynapticsRmiV7EnterSbl * |
1165 | | fu_struct_synaptics_rmi_v7_enter_sbl_new(void) |
1166 | 0 | { |
1167 | 0 | FuStructSynapticsRmiV7EnterSbl *st = fu_struct_synaptics_rmi_v7_enter_sbl_new_internal(); |
1168 | 0 | st->buf = g_byte_array_sized_new(9); |
1169 | 0 | fu_byte_array_set_size(st->buf, 9, 0x0); |
1170 | 0 | fu_struct_synaptics_rmi_v7_enter_sbl_set_partition_id(st, FU_RMI_PARTITION_ID_BOOTLOADER); |
1171 | 0 | fu_struct_synaptics_rmi_v7_enter_sbl_set_cmd(st, FU_SYNAPTICS_RMI_FLASH_CMD_ENTER_BL); |
1172 | 0 | fu_struct_synaptics_rmi_v7_enter_sbl_set_unknown(st, 0x1); |
1173 | 0 | return st; |
1174 | 0 | } |
1175 | | /** |
1176 | | * fu_struct_synaptics_rmi_v7_enter_bl_ref: (skip): |
1177 | | **/ |
1178 | | FuStructSynapticsRmiV7EnterBl * |
1179 | | fu_struct_synaptics_rmi_v7_enter_bl_ref(FuStructSynapticsRmiV7EnterBl *st) |
1180 | 0 | { |
1181 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1182 | 0 | st->refcount++; |
1183 | 0 | return st; |
1184 | 0 | } |
1185 | | /** |
1186 | | * fu_struct_synaptics_rmi_v7_enter_bl_unref: (skip): |
1187 | | **/ |
1188 | | void |
1189 | | fu_struct_synaptics_rmi_v7_enter_bl_unref(FuStructSynapticsRmiV7EnterBl *st) |
1190 | 0 | { |
1191 | 0 | g_return_if_fail(st != NULL); |
1192 | 0 | if (st->refcount == 0) { |
1193 | 0 | g_critical("FuStructSynapticsRmiV7EnterBl refcount already zero"); |
1194 | 0 | return; |
1195 | 0 | } |
1196 | 0 | if (--st->refcount > 0) |
1197 | 0 | return; |
1198 | 0 | if (st->buf != NULL) |
1199 | 0 | g_byte_array_unref(st->buf); |
1200 | 0 | g_free(st); |
1201 | 0 | } |
1202 | | /** |
1203 | | * fu_struct_synaptics_rmi_v7_enter_bl_new_internal: (skip): |
1204 | | **/ |
1205 | | static FuStructSynapticsRmiV7EnterBl * |
1206 | | fu_struct_synaptics_rmi_v7_enter_bl_new_internal(void) |
1207 | 0 | { |
1208 | 0 | FuStructSynapticsRmiV7EnterBl *st = g_new0(FuStructSynapticsRmiV7EnterBl, 1); |
1209 | 0 | st->refcount = 1; |
1210 | 0 | return st; |
1211 | 0 | } |
1212 | | |
1213 | | /* getters */ |
1214 | | |
1215 | | /* setters */ |
1216 | | /** |
1217 | | * fu_struct_synaptics_rmi_v7_enter_bl_set_partition_id: (skip): |
1218 | | **/ |
1219 | | static void |
1220 | | fu_struct_synaptics_rmi_v7_enter_bl_set_partition_id(FuStructSynapticsRmiV7EnterBl *st, FuRmiPartitionId value) |
1221 | 0 | { |
1222 | 0 | g_return_if_fail(st != NULL); |
1223 | 0 | st->buf->data[0] = value; |
1224 | 0 | } |
1225 | | /** |
1226 | | * fu_struct_synaptics_rmi_v7_enter_bl_set_cmd: (skip): |
1227 | | **/ |
1228 | | static void |
1229 | | fu_struct_synaptics_rmi_v7_enter_bl_set_cmd(FuStructSynapticsRmiV7EnterBl *st, FuSynapticsRmiFlashCmd value) |
1230 | 0 | { |
1231 | 0 | g_return_if_fail(st != NULL); |
1232 | 0 | st->buf->data[5] = value; |
1233 | 0 | } |
1234 | | /** |
1235 | | * fu_struct_synaptics_rmi_v7_enter_bl_set_bootloader_id0: (skip): |
1236 | | **/ |
1237 | | void |
1238 | | fu_struct_synaptics_rmi_v7_enter_bl_set_bootloader_id0(FuStructSynapticsRmiV7EnterBl *st, guint8 value) |
1239 | 0 | { |
1240 | 0 | g_return_if_fail(st != NULL); |
1241 | 0 | st->buf->data[6] = value; |
1242 | 0 | } |
1243 | | /** |
1244 | | * fu_struct_synaptics_rmi_v7_enter_bl_set_bootloader_id1: (skip): |
1245 | | **/ |
1246 | | void |
1247 | | fu_struct_synaptics_rmi_v7_enter_bl_set_bootloader_id1(FuStructSynapticsRmiV7EnterBl *st, guint8 value) |
1248 | 0 | { |
1249 | 0 | g_return_if_fail(st != NULL); |
1250 | 0 | st->buf->data[7] = value; |
1251 | 0 | } |
1252 | | /** |
1253 | | * fu_struct_synaptics_rmi_v7_enter_bl_new: (skip): |
1254 | | **/ |
1255 | | FuStructSynapticsRmiV7EnterBl * |
1256 | | fu_struct_synaptics_rmi_v7_enter_bl_new(void) |
1257 | 0 | { |
1258 | 0 | FuStructSynapticsRmiV7EnterBl *st = fu_struct_synaptics_rmi_v7_enter_bl_new_internal(); |
1259 | 0 | st->buf = g_byte_array_sized_new(8); |
1260 | 0 | fu_byte_array_set_size(st->buf, 8, 0x0); |
1261 | 0 | fu_struct_synaptics_rmi_v7_enter_bl_set_partition_id(st, FU_RMI_PARTITION_ID_BOOTLOADER); |
1262 | 0 | fu_struct_synaptics_rmi_v7_enter_bl_set_cmd(st, FU_SYNAPTICS_RMI_FLASH_CMD_ENTER_BL); |
1263 | 0 | return st; |
1264 | 0 | } |
1265 | | /** |
1266 | | * fu_struct_synaptics_rmi_v7_erase_ref: (skip): |
1267 | | **/ |
1268 | | FuStructSynapticsRmiV7Erase * |
1269 | | fu_struct_synaptics_rmi_v7_erase_ref(FuStructSynapticsRmiV7Erase *st) |
1270 | 0 | { |
1271 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1272 | 0 | st->refcount++; |
1273 | 0 | return st; |
1274 | 0 | } |
1275 | | /** |
1276 | | * fu_struct_synaptics_rmi_v7_erase_unref: (skip): |
1277 | | **/ |
1278 | | void |
1279 | | fu_struct_synaptics_rmi_v7_erase_unref(FuStructSynapticsRmiV7Erase *st) |
1280 | 0 | { |
1281 | 0 | g_return_if_fail(st != NULL); |
1282 | 0 | if (st->refcount == 0) { |
1283 | 0 | g_critical("FuStructSynapticsRmiV7Erase refcount already zero"); |
1284 | 0 | return; |
1285 | 0 | } |
1286 | 0 | if (--st->refcount > 0) |
1287 | 0 | return; |
1288 | 0 | if (st->buf != NULL) |
1289 | 0 | g_byte_array_unref(st->buf); |
1290 | 0 | g_free(st); |
1291 | 0 | } |
1292 | | /** |
1293 | | * fu_struct_synaptics_rmi_v7_erase_new_internal: (skip): |
1294 | | **/ |
1295 | | static FuStructSynapticsRmiV7Erase * |
1296 | | fu_struct_synaptics_rmi_v7_erase_new_internal(void) |
1297 | 0 | { |
1298 | 0 | FuStructSynapticsRmiV7Erase *st = g_new0(FuStructSynapticsRmiV7Erase, 1); |
1299 | 0 | st->refcount = 1; |
1300 | 0 | return st; |
1301 | 0 | } |
1302 | | |
1303 | | /* getters */ |
1304 | | |
1305 | | /* setters */ |
1306 | | /** |
1307 | | * fu_struct_synaptics_rmi_v7_erase_set_partition_id: (skip): |
1308 | | **/ |
1309 | | void |
1310 | | fu_struct_synaptics_rmi_v7_erase_set_partition_id(FuStructSynapticsRmiV7Erase *st, FuRmiPartitionId value) |
1311 | 0 | { |
1312 | 0 | g_return_if_fail(st != NULL); |
1313 | 0 | st->buf->data[0] = value; |
1314 | 0 | } |
1315 | | /** |
1316 | | * fu_struct_synaptics_rmi_v7_erase_set_cmd: (skip): |
1317 | | **/ |
1318 | | static void |
1319 | | fu_struct_synaptics_rmi_v7_erase_set_cmd(FuStructSynapticsRmiV7Erase *st, FuSynapticsRmiFlashCmd value) |
1320 | 0 | { |
1321 | 0 | g_return_if_fail(st != NULL); |
1322 | 0 | st->buf->data[5] = value; |
1323 | 0 | } |
1324 | | /** |
1325 | | * fu_struct_synaptics_rmi_v7_erase_set_bootloader_id0: (skip): |
1326 | | **/ |
1327 | | void |
1328 | | fu_struct_synaptics_rmi_v7_erase_set_bootloader_id0(FuStructSynapticsRmiV7Erase *st, guint8 value) |
1329 | 0 | { |
1330 | 0 | g_return_if_fail(st != NULL); |
1331 | 0 | st->buf->data[6] = value; |
1332 | 0 | } |
1333 | | /** |
1334 | | * fu_struct_synaptics_rmi_v7_erase_set_bootloader_id1: (skip): |
1335 | | **/ |
1336 | | void |
1337 | | fu_struct_synaptics_rmi_v7_erase_set_bootloader_id1(FuStructSynapticsRmiV7Erase *st, guint8 value) |
1338 | 0 | { |
1339 | 0 | g_return_if_fail(st != NULL); |
1340 | 0 | st->buf->data[7] = value; |
1341 | 0 | } |
1342 | | /** |
1343 | | * fu_struct_synaptics_rmi_v7_erase_new: (skip): |
1344 | | **/ |
1345 | | FuStructSynapticsRmiV7Erase * |
1346 | | fu_struct_synaptics_rmi_v7_erase_new(void) |
1347 | 0 | { |
1348 | 0 | FuStructSynapticsRmiV7Erase *st = fu_struct_synaptics_rmi_v7_erase_new_internal(); |
1349 | 0 | st->buf = g_byte_array_sized_new(8); |
1350 | 0 | fu_byte_array_set_size(st->buf, 8, 0x0); |
1351 | 0 | fu_struct_synaptics_rmi_v7_erase_set_cmd(st, FU_SYNAPTICS_RMI_FLASH_CMD_ERASE); |
1352 | 0 | return st; |
1353 | 0 | } |
1354 | | /** |
1355 | | * fu_struct_synaptics_rmi_v7_erase_core_code_ref: (skip): |
1356 | | **/ |
1357 | | FuStructSynapticsRmiV7EraseCoreCode * |
1358 | | fu_struct_synaptics_rmi_v7_erase_core_code_ref(FuStructSynapticsRmiV7EraseCoreCode *st) |
1359 | 0 | { |
1360 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1361 | 0 | st->refcount++; |
1362 | 0 | return st; |
1363 | 0 | } |
1364 | | /** |
1365 | | * fu_struct_synaptics_rmi_v7_erase_core_code_unref: (skip): |
1366 | | **/ |
1367 | | void |
1368 | | fu_struct_synaptics_rmi_v7_erase_core_code_unref(FuStructSynapticsRmiV7EraseCoreCode *st) |
1369 | 0 | { |
1370 | 0 | g_return_if_fail(st != NULL); |
1371 | 0 | if (st->refcount == 0) { |
1372 | 0 | g_critical("FuStructSynapticsRmiV7EraseCoreCode refcount already zero"); |
1373 | 0 | return; |
1374 | 0 | } |
1375 | 0 | if (--st->refcount > 0) |
1376 | 0 | return; |
1377 | 0 | if (st->buf != NULL) |
1378 | 0 | g_byte_array_unref(st->buf); |
1379 | 0 | g_free(st); |
1380 | 0 | } |
1381 | | /** |
1382 | | * fu_struct_synaptics_rmi_v7_erase_core_code_new_internal: (skip): |
1383 | | **/ |
1384 | | static FuStructSynapticsRmiV7EraseCoreCode * |
1385 | | fu_struct_synaptics_rmi_v7_erase_core_code_new_internal(void) |
1386 | 0 | { |
1387 | 0 | FuStructSynapticsRmiV7EraseCoreCode *st = g_new0(FuStructSynapticsRmiV7EraseCoreCode, 1); |
1388 | 0 | st->refcount = 1; |
1389 | 0 | return st; |
1390 | 0 | } |
1391 | | |
1392 | | /* getters */ |
1393 | | |
1394 | | /* setters */ |
1395 | | /** |
1396 | | * fu_struct_synaptics_rmi_v7_erase_core_code_set_partition_id: (skip): |
1397 | | **/ |
1398 | | static void |
1399 | | fu_struct_synaptics_rmi_v7_erase_core_code_set_partition_id(FuStructSynapticsRmiV7EraseCoreCode *st, FuRmiPartitionId value) |
1400 | 0 | { |
1401 | 0 | g_return_if_fail(st != NULL); |
1402 | 0 | st->buf->data[0] = value; |
1403 | 0 | } |
1404 | | /** |
1405 | | * fu_struct_synaptics_rmi_v7_erase_core_code_set_cmd: (skip): |
1406 | | **/ |
1407 | | void |
1408 | | fu_struct_synaptics_rmi_v7_erase_core_code_set_cmd(FuStructSynapticsRmiV7EraseCoreCode *st, FuSynapticsRmiFlashCmd value) |
1409 | 0 | { |
1410 | 0 | g_return_if_fail(st != NULL); |
1411 | 0 | st->buf->data[5] = value; |
1412 | 0 | } |
1413 | | /** |
1414 | | * fu_struct_synaptics_rmi_v7_erase_core_code_set_bootloader_id0: (skip): |
1415 | | **/ |
1416 | | void |
1417 | | fu_struct_synaptics_rmi_v7_erase_core_code_set_bootloader_id0(FuStructSynapticsRmiV7EraseCoreCode *st, guint8 value) |
1418 | 0 | { |
1419 | 0 | g_return_if_fail(st != NULL); |
1420 | 0 | st->buf->data[6] = value; |
1421 | 0 | } |
1422 | | /** |
1423 | | * fu_struct_synaptics_rmi_v7_erase_core_code_set_bootloader_id1: (skip): |
1424 | | **/ |
1425 | | void |
1426 | | fu_struct_synaptics_rmi_v7_erase_core_code_set_bootloader_id1(FuStructSynapticsRmiV7EraseCoreCode *st, guint8 value) |
1427 | 0 | { |
1428 | 0 | g_return_if_fail(st != NULL); |
1429 | 0 | st->buf->data[7] = value; |
1430 | 0 | } |
1431 | | /** |
1432 | | * fu_struct_synaptics_rmi_v7_erase_core_code_new: (skip): |
1433 | | **/ |
1434 | | FuStructSynapticsRmiV7EraseCoreCode * |
1435 | | fu_struct_synaptics_rmi_v7_erase_core_code_new(void) |
1436 | 0 | { |
1437 | 0 | FuStructSynapticsRmiV7EraseCoreCode *st = fu_struct_synaptics_rmi_v7_erase_core_code_new_internal(); |
1438 | 0 | st->buf = g_byte_array_sized_new(8); |
1439 | 0 | fu_byte_array_set_size(st->buf, 8, 0x0); |
1440 | 0 | fu_struct_synaptics_rmi_v7_erase_core_code_set_partition_id(st, FU_RMI_PARTITION_ID_CORE_CODE); |
1441 | 0 | fu_struct_synaptics_rmi_v7_erase_core_code_set_cmd(st, FU_SYNAPTICS_RMI_FLASH_CMD_ERASE_AP); |
1442 | 0 | return st; |
1443 | 0 | } |
1444 | | /** |
1445 | | * fu_struct_synaptics_rmi_v7_erase_core_config_ref: (skip): |
1446 | | **/ |
1447 | | FuStructSynapticsRmiV7EraseCoreConfig * |
1448 | | fu_struct_synaptics_rmi_v7_erase_core_config_ref(FuStructSynapticsRmiV7EraseCoreConfig *st) |
1449 | 0 | { |
1450 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1451 | 0 | st->refcount++; |
1452 | 0 | return st; |
1453 | 0 | } |
1454 | | /** |
1455 | | * fu_struct_synaptics_rmi_v7_erase_core_config_unref: (skip): |
1456 | | **/ |
1457 | | void |
1458 | | fu_struct_synaptics_rmi_v7_erase_core_config_unref(FuStructSynapticsRmiV7EraseCoreConfig *st) |
1459 | 0 | { |
1460 | 0 | g_return_if_fail(st != NULL); |
1461 | 0 | if (st->refcount == 0) { |
1462 | 0 | g_critical("FuStructSynapticsRmiV7EraseCoreConfig refcount already zero"); |
1463 | 0 | return; |
1464 | 0 | } |
1465 | 0 | if (--st->refcount > 0) |
1466 | 0 | return; |
1467 | 0 | if (st->buf != NULL) |
1468 | 0 | g_byte_array_unref(st->buf); |
1469 | 0 | g_free(st); |
1470 | 0 | } |
1471 | | /** |
1472 | | * fu_struct_synaptics_rmi_v7_erase_core_config_new_internal: (skip): |
1473 | | **/ |
1474 | | static FuStructSynapticsRmiV7EraseCoreConfig * |
1475 | | fu_struct_synaptics_rmi_v7_erase_core_config_new_internal(void) |
1476 | 0 | { |
1477 | 0 | FuStructSynapticsRmiV7EraseCoreConfig *st = g_new0(FuStructSynapticsRmiV7EraseCoreConfig, 1); |
1478 | 0 | st->refcount = 1; |
1479 | 0 | return st; |
1480 | 0 | } |
1481 | | |
1482 | | /* getters */ |
1483 | | |
1484 | | /* setters */ |
1485 | | /** |
1486 | | * fu_struct_synaptics_rmi_v7_erase_core_config_set_partition_id: (skip): |
1487 | | **/ |
1488 | | static void |
1489 | | fu_struct_synaptics_rmi_v7_erase_core_config_set_partition_id(FuStructSynapticsRmiV7EraseCoreConfig *st, FuRmiPartitionId value) |
1490 | 0 | { |
1491 | 0 | g_return_if_fail(st != NULL); |
1492 | 0 | st->buf->data[0] = value; |
1493 | 0 | } |
1494 | | /** |
1495 | | * fu_struct_synaptics_rmi_v7_erase_core_config_set_cmd: (skip): |
1496 | | **/ |
1497 | | static void |
1498 | | fu_struct_synaptics_rmi_v7_erase_core_config_set_cmd(FuStructSynapticsRmiV7EraseCoreConfig *st, FuSynapticsRmiFlashCmd value) |
1499 | 0 | { |
1500 | 0 | g_return_if_fail(st != NULL); |
1501 | 0 | st->buf->data[5] = value; |
1502 | 0 | } |
1503 | | /** |
1504 | | * fu_struct_synaptics_rmi_v7_erase_core_config_new: (skip): |
1505 | | **/ |
1506 | | FuStructSynapticsRmiV7EraseCoreConfig * |
1507 | | fu_struct_synaptics_rmi_v7_erase_core_config_new(void) |
1508 | 0 | { |
1509 | 0 | FuStructSynapticsRmiV7EraseCoreConfig *st = fu_struct_synaptics_rmi_v7_erase_core_config_new_internal(); |
1510 | 0 | st->buf = g_byte_array_sized_new(6); |
1511 | 0 | fu_byte_array_set_size(st->buf, 6, 0x0); |
1512 | 0 | fu_struct_synaptics_rmi_v7_erase_core_config_set_partition_id(st, FU_RMI_PARTITION_ID_CORE_CONFIG); |
1513 | 0 | fu_struct_synaptics_rmi_v7_erase_core_config_set_cmd(st, FU_SYNAPTICS_RMI_FLASH_CMD_ERASE); |
1514 | 0 | return st; |
1515 | 0 | } |