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