/work/fu-ccgx-dmc-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-ccgx-dmc-struct.h" |
12 | | #include "fu-byte-array.h" |
13 | | #include "fu-mem-private.h" |
14 | | #include "fu-string.h" |
15 | | |
16 | | #ifdef G_LOG_DOMAIN |
17 | | #undef G_LOG_DOMAIN |
18 | | #endif |
19 | 0 | #define G_LOG_DOMAIN "FuStruct" |
20 | | |
21 | | |
22 | | /** |
23 | | * fu_ccgx_dmc_img_status_to_string: |
24 | | * @val: value, e.g. %FU_CCGX_DMC_IMG_STATUS_VALID |
25 | | * |
26 | | * Converts an enumerated value to a string. |
27 | | * |
28 | | * Returns: identifier string |
29 | | **/ |
30 | | const gchar * |
31 | | fu_ccgx_dmc_img_status_to_string(FuCcgxDmcImgStatus val) |
32 | 0 | { |
33 | 0 | if (val == FU_CCGX_DMC_IMG_STATUS_VALID) |
34 | 0 | return "valid"; |
35 | 0 | if (val == FU_CCGX_DMC_IMG_STATUS_INVALID) |
36 | 0 | return "invalid"; |
37 | 0 | if (val == FU_CCGX_DMC_IMG_STATUS_RECOVERY) |
38 | 0 | return "recovery"; |
39 | 0 | if (val == FU_CCGX_DMC_IMG_STATUS_RECOVERED_FROM_SECONDARY) |
40 | 0 | return "recovered-from-secondary"; |
41 | 0 | if (val == FU_CCGX_DMC_IMG_STATUS_NOT_SUPPORTED) |
42 | 0 | return "not-supported"; |
43 | 0 | return NULL; |
44 | 0 | } |
45 | | |
46 | | /** |
47 | | * fu_ccgx_dmc_img_mode_to_string: |
48 | | * @val: value, e.g. %FU_CCGX_DMC_IMG_MODE_DUAL_IMG_SYM |
49 | | * |
50 | | * Converts an enumerated value to a string. |
51 | | * |
52 | | * Returns: identifier string |
53 | | **/ |
54 | | const gchar * |
55 | | fu_ccgx_dmc_img_mode_to_string(FuCcgxDmcImgMode val) |
56 | 0 | { |
57 | 0 | if (val == FU_CCGX_DMC_IMG_MODE_SINGLE_IMG) |
58 | 0 | return "single-img"; |
59 | 0 | if (val == FU_CCGX_DMC_IMG_MODE_DUAL_IMG_SYM) |
60 | 0 | return "dual-img-sym"; |
61 | 0 | if (val == FU_CCGX_DMC_IMG_MODE_DUAL_IMG_ASYM) |
62 | 0 | return "dual-img-asym"; |
63 | 0 | if (val == FU_CCGX_DMC_IMG_MODE_SINGLE_IMG_WITH_RAM_IMG) |
64 | 0 | return "single-img-with-ram-img"; |
65 | 0 | return NULL; |
66 | 0 | } |
67 | | |
68 | | /** |
69 | | * fu_ccgx_dmc_device_status_to_string: |
70 | | * @val: value, e.g. %FU_CCGX_DMC_DEVICE_STATUS_UPDATE_PHASE1_IN_PROGRESS |
71 | | * |
72 | | * Converts an enumerated value to a string. |
73 | | * |
74 | | * Returns: identifier string |
75 | | **/ |
76 | | const gchar * |
77 | | fu_ccgx_dmc_device_status_to_string(FuCcgxDmcDeviceStatus val) |
78 | 0 | { |
79 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_IDLE) |
80 | 0 | return "idle"; |
81 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_UPDATE_PHASE1_IN_PROGRESS) |
82 | 0 | return "update-phase1-in-progress"; |
83 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_UPDATE_PHASE1_PARTIAL) |
84 | 0 | return "update-phase1-partial"; |
85 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_UPDATE_COMPLETE_FULL) |
86 | 0 | return "update-complete-full"; |
87 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_UPDATE_PHASE1_COMPLETE_PARTIAL) |
88 | 0 | return "update-phase1-complete-partial"; |
89 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_UPDATE_PHASE1_COMPLETE_FULL_PHASE2_NOT_DONE) |
90 | 0 | return "update-phase1-complete-full-phase2-not-done"; |
91 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_FW_DOWNLOADED_UPDATE_PEND) |
92 | 0 | return "fw-downloaded-update-pend"; |
93 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_FW_DOWNLOADED_PARTIAL_UPDATE_PEND) |
94 | 0 | return "fw-downloaded-partial-update-pend"; |
95 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_IN_PROGRESS) |
96 | 0 | return "phase2-update-in-progress"; |
97 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_PARTIAL) |
98 | 0 | return "phase2-update-partial"; |
99 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FACTORY_BACKUP) |
100 | 0 | return "phase2-update-factory-backup"; |
101 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_COMPLETE_PARTIAL) |
102 | 0 | return "phase2-update-complete-partial"; |
103 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_COMPLETE_FULL) |
104 | 0 | return "phase2-update-complete-full"; |
105 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FAIL_INVALID_FWCT) |
106 | 0 | return "phase2-update-fail-invalid-fwct"; |
107 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FAIL_INVALID_DOCK_IDENTITY) |
108 | 0 | return "phase2-update-fail-invalid-dock-identity"; |
109 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FAIL_INVALID_COMPOSITE_VER) |
110 | 0 | return "phase2-update-fail-invalid-composite-ver"; |
111 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FAIL_AUTHENTICATION_FAILED) |
112 | 0 | return "phase2-update-fail-authentication-failed"; |
113 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FAIL_INVALID_ALGORITHM) |
114 | 0 | return "phase2-update-fail-invalid-algorithm"; |
115 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FAIL_SPI_READ_FAILED) |
116 | 0 | return "phase2-update-fail-spi-read-failed"; |
117 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FAIL_NO_VALID_KEY) |
118 | 0 | return "phase2-update-fail-no-valid-key"; |
119 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FAIL_NO_VALID_SPI_PACKAGE) |
120 | 0 | return "phase2-update-fail-no-valid-spi-package"; |
121 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FAIL_RAM_INIT_FAILED) |
122 | 0 | return "phase2-update-fail-ram-init-failed"; |
123 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FAIL_FACTORY_BACKUP_FAILED) |
124 | 0 | return "phase2-update-fail-factory-backup-failed"; |
125 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_PHASE2_UPDATE_FAIL_NO_VALID_FACTORY_PACKAGE) |
126 | 0 | return "phase2-update-fail-no-valid-factory-package"; |
127 | 0 | if (val == FU_CCGX_DMC_DEVICE_STATUS_UPDATE_FAIL) |
128 | 0 | return "update-fail"; |
129 | 0 | return NULL; |
130 | 0 | } |
131 | | |
132 | | /** |
133 | | * fu_ccgx_dmc_devx_device_type_to_string: |
134 | | * @val: value, e.g. %FU_CCGX_DMC_DEVX_DEVICE_TYPE_CCG3 |
135 | | * |
136 | | * Converts an enumerated value to a string. |
137 | | * |
138 | | * Returns: identifier string |
139 | | **/ |
140 | | const gchar * |
141 | | fu_ccgx_dmc_devx_device_type_to_string(FuCcgxDmcDevxDeviceType val) |
142 | 0 | { |
143 | 0 | if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_INVALID) |
144 | 0 | return "invalid"; |
145 | 0 | if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_CCG3) |
146 | 0 | return "ccg3"; |
147 | 0 | if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_DMC) |
148 | 0 | return "dmc"; |
149 | 0 | if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_CCG4) |
150 | 0 | return "ccg4"; |
151 | 0 | if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_CCG5) |
152 | 0 | return "ccg5"; |
153 | 0 | if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_HX3) |
154 | 0 | return "hx3"; |
155 | 0 | if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_HX3_PD) |
156 | 0 | return "hx3-pd"; |
157 | 0 | if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_DMC_PD) |
158 | 0 | return "dmc-pd"; |
159 | 0 | if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_CCG6) |
160 | 0 | return "ccg6"; |
161 | 0 | if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_PMG1S3) |
162 | 0 | return "pmg1s3"; |
163 | 0 | if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_CCG7SC) |
164 | 0 | return "ccg7sc"; |
165 | 0 | if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_CCG6SF) |
166 | 0 | return "ccg6sf"; |
167 | 0 | if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_CCG8) |
168 | 0 | return "ccg8"; |
169 | 0 | if (val == FU_CCGX_DMC_DEVX_DEVICE_TYPE_SPI) |
170 | 0 | return "spi"; |
171 | 0 | return NULL; |
172 | 0 | } |
173 | | |
174 | | |
175 | | /** |
176 | | * fu_ccgx_dmc_int_opcode_to_string: |
177 | | * @val: value, e.g. %FU_CCGX_DMC_INT_OPCODE_FW_UPGRADE_STATUS |
178 | | * |
179 | | * Converts an enumerated value to a string. |
180 | | * |
181 | | * Returns: identifier string |
182 | | **/ |
183 | | const gchar * |
184 | | fu_ccgx_dmc_int_opcode_to_string(FuCcgxDmcIntOpcode val) |
185 | 0 | { |
186 | 0 | if (val == FU_CCGX_DMC_INT_OPCODE_FW_UPGRADE_RQT) |
187 | 0 | return "fw-upgrade-rqt"; |
188 | 0 | if (val == FU_CCGX_DMC_INT_OPCODE_FW_UPGRADE_STATUS) |
189 | 0 | return "fw-upgrade-status"; |
190 | 0 | if (val == FU_CCGX_DMC_INT_OPCODE_IMG_WRITE_STATUS) |
191 | 0 | return "img-write-status"; |
192 | 0 | if (val == FU_CCGX_DMC_INT_OPCODE_REENUM) |
193 | 0 | return "reenum"; |
194 | 0 | if (val == FU_CCGX_DMC_INT_OPCODE_FWCT_ANALYSIS_STATUS) |
195 | 0 | return "fwct-analysis-status"; |
196 | 0 | return NULL; |
197 | 0 | } |
198 | | |
199 | | /** |
200 | | * fu_ccgx_dmc_fwct_analysis_status_to_string: |
201 | | * @val: value, e.g. %FU_CCGX_DMC_FWCT_ANALYSIS_STATUS_INVALID_DOCK_IDENTITY |
202 | | * |
203 | | * Converts an enumerated value to a string. |
204 | | * |
205 | | * Returns: identifier string |
206 | | **/ |
207 | | const gchar * |
208 | | fu_ccgx_dmc_fwct_analysis_status_to_string(FuCcgxDmcFwctAnalysisStatus val) |
209 | 0 | { |
210 | 0 | if (val == FU_CCGX_DMC_FWCT_ANALYSIS_STATUS_INVALID_FWCT) |
211 | 0 | return "invalid-fwct"; |
212 | 0 | if (val == FU_CCGX_DMC_FWCT_ANALYSIS_STATUS_INVALID_DOCK_IDENTITY) |
213 | 0 | return "invalid-dock-identity"; |
214 | 0 | if (val == FU_CCGX_DMC_FWCT_ANALYSIS_STATUS_INVALID_COMPOSITE_VERSION) |
215 | 0 | return "invalid-composite-version"; |
216 | 0 | if (val == FU_CCGX_DMC_FWCT_ANALYSIS_STATUS_AUTHENTICATION_FAILED) |
217 | 0 | return "authentication-failed"; |
218 | 0 | if (val == FU_CCGX_DMC_FWCT_ANALYSIS_STATUS_INVALID_ALGORITHM) |
219 | 0 | return "invalid-algorithm"; |
220 | 0 | if (val == FU_CCGX_DMC_FWCT_ANALYSIS_STATUS_INVALID_FENCE) |
221 | 0 | return "invalid-fence"; |
222 | 0 | return NULL; |
223 | 0 | } |
224 | | |
225 | | /** |
226 | | * fu_ccgx_dmc_update_model_to_string: |
227 | | * @val: value, e.g. %FU_CCGX_DMC_UPDATE_MODEL_DOWNLOAD_TRIGGER |
228 | | * |
229 | | * Converts an enumerated value to a string. |
230 | | * |
231 | | * Returns: identifier string |
232 | | **/ |
233 | | const gchar * |
234 | | fu_ccgx_dmc_update_model_to_string(FuCcgxDmcUpdateModel val) |
235 | 0 | { |
236 | 0 | if (val == FU_CCGX_DMC_UPDATE_MODEL_NONE) |
237 | 0 | return "none"; |
238 | 0 | if (val == FU_CCGX_DMC_UPDATE_MODEL_DOWNLOAD_TRIGGER) |
239 | 0 | return "download-trigger"; |
240 | 0 | if (val == FU_CCGX_DMC_UPDATE_MODEL_PENDING_RESET) |
241 | 0 | return "pending-reset"; |
242 | 0 | return NULL; |
243 | 0 | } |
244 | | /** |
245 | | * fu_struct_ccgx_dmc_dock_identity_ref: (skip): |
246 | | **/ |
247 | | FuStructCcgxDmcDockIdentity * |
248 | | fu_struct_ccgx_dmc_dock_identity_ref(FuStructCcgxDmcDockIdentity *st) |
249 | 0 | { |
250 | 0 | g_return_val_if_fail(st != NULL, NULL); |
251 | 0 | st->refcount++; |
252 | 0 | return st; |
253 | 0 | } |
254 | | /** |
255 | | * fu_struct_ccgx_dmc_dock_identity_unref: (skip): |
256 | | **/ |
257 | | void |
258 | | fu_struct_ccgx_dmc_dock_identity_unref(FuStructCcgxDmcDockIdentity *st) |
259 | 0 | { |
260 | 0 | g_return_if_fail(st != NULL); |
261 | 0 | if (st->refcount == 0) { |
262 | 0 | g_critical("FuStructCcgxDmcDockIdentity refcount already zero"); |
263 | 0 | return; |
264 | 0 | } |
265 | 0 | if (--st->refcount > 0) |
266 | 0 | return; |
267 | 0 | if (st->buf != NULL) |
268 | 0 | g_byte_array_unref(st->buf); |
269 | 0 | g_free(st); |
270 | 0 | } |
271 | | /** |
272 | | * fu_struct_ccgx_dmc_dock_identity_new_internal: (skip): |
273 | | **/ |
274 | | static FuStructCcgxDmcDockIdentity * |
275 | | fu_struct_ccgx_dmc_dock_identity_new_internal(void) |
276 | 0 | { |
277 | 0 | FuStructCcgxDmcDockIdentity *st = g_new0(FuStructCcgxDmcDockIdentity, 1); |
278 | 0 | st->refcount = 1; |
279 | 0 | return st; |
280 | 0 | } |
281 | | |
282 | | /* getters */ |
283 | | /** |
284 | | * fu_struct_ccgx_dmc_dock_identity_get_structure_version: (skip): |
285 | | **/ |
286 | | guint8 |
287 | | fu_struct_ccgx_dmc_dock_identity_get_structure_version(const FuStructCcgxDmcDockIdentity *st) |
288 | 0 | { |
289 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
290 | 0 | return st->buf->data[0]; |
291 | 0 | } |
292 | | /** |
293 | | * fu_struct_ccgx_dmc_dock_identity_get_cdtt_version: (skip): |
294 | | **/ |
295 | | guint8 |
296 | | fu_struct_ccgx_dmc_dock_identity_get_cdtt_version(const FuStructCcgxDmcDockIdentity *st) |
297 | 0 | { |
298 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
299 | 0 | return st->buf->data[1]; |
300 | 0 | } |
301 | | /** |
302 | | * fu_struct_ccgx_dmc_dock_identity_get_vid: (skip): |
303 | | **/ |
304 | | guint16 |
305 | | fu_struct_ccgx_dmc_dock_identity_get_vid(const FuStructCcgxDmcDockIdentity *st) |
306 | 0 | { |
307 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
308 | 0 | return fu_memread_uint16(st->buf->data + 2, G_LITTLE_ENDIAN); |
309 | 0 | } |
310 | | /** |
311 | | * fu_struct_ccgx_dmc_dock_identity_get_pid: (skip): |
312 | | **/ |
313 | | guint16 |
314 | | fu_struct_ccgx_dmc_dock_identity_get_pid(const FuStructCcgxDmcDockIdentity *st) |
315 | 0 | { |
316 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
317 | 0 | return fu_memread_uint16(st->buf->data + 4, G_LITTLE_ENDIAN); |
318 | 0 | } |
319 | | /** |
320 | | * fu_struct_ccgx_dmc_dock_identity_get_device_id: (skip): |
321 | | **/ |
322 | | guint16 |
323 | | fu_struct_ccgx_dmc_dock_identity_get_device_id(const FuStructCcgxDmcDockIdentity *st) |
324 | 0 | { |
325 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
326 | 0 | return fu_memread_uint16(st->buf->data + 6, G_LITTLE_ENDIAN); |
327 | 0 | } |
328 | | /** |
329 | | * fu_struct_ccgx_dmc_dock_identity_get_vendor_string: (skip): |
330 | | **/ |
331 | | gchar * |
332 | | fu_struct_ccgx_dmc_dock_identity_get_vendor_string(const FuStructCcgxDmcDockIdentity *st) |
333 | 0 | { |
334 | 0 | g_return_val_if_fail(st != NULL, NULL); |
335 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 8, 32, NULL); |
336 | 0 | } |
337 | | /** |
338 | | * fu_struct_ccgx_dmc_dock_identity_get_product_string: (skip): |
339 | | **/ |
340 | | gchar * |
341 | | fu_struct_ccgx_dmc_dock_identity_get_product_string(const FuStructCcgxDmcDockIdentity *st) |
342 | 0 | { |
343 | 0 | g_return_val_if_fail(st != NULL, NULL); |
344 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 40, 32, NULL); |
345 | 0 | } |
346 | | /** |
347 | | * fu_struct_ccgx_dmc_dock_identity_get_custom_meta_data_flag: (skip): |
348 | | **/ |
349 | | guint8 |
350 | | fu_struct_ccgx_dmc_dock_identity_get_custom_meta_data_flag(const FuStructCcgxDmcDockIdentity *st) |
351 | 0 | { |
352 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
353 | 0 | return st->buf->data[72]; |
354 | 0 | } |
355 | | /** |
356 | | * fu_struct_ccgx_dmc_dock_identity_get_model: (skip): |
357 | | **/ |
358 | | guint8 |
359 | | fu_struct_ccgx_dmc_dock_identity_get_model(const FuStructCcgxDmcDockIdentity *st) |
360 | 0 | { |
361 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
362 | 0 | return st->buf->data[73]; |
363 | 0 | } |
364 | | |
365 | | /* setters */ |
366 | | /** |
367 | | * fu_struct_ccgx_dmc_dock_identity_set_structure_version: (skip): |
368 | | **/ |
369 | | void |
370 | | fu_struct_ccgx_dmc_dock_identity_set_structure_version(FuStructCcgxDmcDockIdentity *st, guint8 value) |
371 | 0 | { |
372 | 0 | g_return_if_fail(st != NULL); |
373 | 0 | st->buf->data[0] = value; |
374 | 0 | } |
375 | | /** |
376 | | * fu_struct_ccgx_dmc_dock_identity_set_cdtt_version: (skip): |
377 | | **/ |
378 | | void |
379 | | fu_struct_ccgx_dmc_dock_identity_set_cdtt_version(FuStructCcgxDmcDockIdentity *st, guint8 value) |
380 | 0 | { |
381 | 0 | g_return_if_fail(st != NULL); |
382 | 0 | st->buf->data[1] = value; |
383 | 0 | } |
384 | | /** |
385 | | * fu_struct_ccgx_dmc_dock_identity_set_vid: (skip): |
386 | | **/ |
387 | | void |
388 | | fu_struct_ccgx_dmc_dock_identity_set_vid(FuStructCcgxDmcDockIdentity *st, guint16 value) |
389 | 0 | { |
390 | 0 | g_return_if_fail(st != NULL); |
391 | 0 | fu_memwrite_uint16(st->buf->data + 2, value, G_LITTLE_ENDIAN); |
392 | 0 | } |
393 | | /** |
394 | | * fu_struct_ccgx_dmc_dock_identity_set_pid: (skip): |
395 | | **/ |
396 | | void |
397 | | fu_struct_ccgx_dmc_dock_identity_set_pid(FuStructCcgxDmcDockIdentity *st, guint16 value) |
398 | 0 | { |
399 | 0 | g_return_if_fail(st != NULL); |
400 | 0 | fu_memwrite_uint16(st->buf->data + 4, value, G_LITTLE_ENDIAN); |
401 | 0 | } |
402 | | /** |
403 | | * fu_struct_ccgx_dmc_dock_identity_set_device_id: (skip): |
404 | | **/ |
405 | | void |
406 | | fu_struct_ccgx_dmc_dock_identity_set_device_id(FuStructCcgxDmcDockIdentity *st, guint16 value) |
407 | 0 | { |
408 | 0 | g_return_if_fail(st != NULL); |
409 | 0 | fu_memwrite_uint16(st->buf->data + 6, value, G_LITTLE_ENDIAN); |
410 | 0 | } |
411 | | /** |
412 | | * fu_struct_ccgx_dmc_dock_identity_set_vendor_string: (skip): |
413 | | **/ |
414 | | gboolean |
415 | | fu_struct_ccgx_dmc_dock_identity_set_vendor_string(FuStructCcgxDmcDockIdentity *st, const gchar *value, GError **error) |
416 | 0 | { |
417 | 0 | gsize len; |
418 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
419 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
420 | 0 | if (value == NULL) { |
421 | 0 | memset(st->buf->data + 8, 0x0, 32); |
422 | 0 | return TRUE; |
423 | 0 | } |
424 | 0 | len = strlen(value); |
425 | 0 | if (len > 32) { |
426 | 0 | g_set_error(error, |
427 | 0 | FWUPD_ERROR, |
428 | 0 | FWUPD_ERROR_INVALID_DATA, |
429 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructCcgxDmcDockIdentity.vendor_string (0x%x bytes)", |
430 | 0 | value, (guint) len, (guint) 32); |
431 | 0 | return FALSE; |
432 | 0 | } |
433 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 8, (const guint8 *)value, len, 0x0, len, error); |
434 | 0 | } |
435 | | /** |
436 | | * fu_struct_ccgx_dmc_dock_identity_set_product_string: (skip): |
437 | | **/ |
438 | | gboolean |
439 | | fu_struct_ccgx_dmc_dock_identity_set_product_string(FuStructCcgxDmcDockIdentity *st, const gchar *value, GError **error) |
440 | 0 | { |
441 | 0 | gsize len; |
442 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
443 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
444 | 0 | if (value == NULL) { |
445 | 0 | memset(st->buf->data + 40, 0x0, 32); |
446 | 0 | return TRUE; |
447 | 0 | } |
448 | 0 | len = strlen(value); |
449 | 0 | if (len > 32) { |
450 | 0 | g_set_error(error, |
451 | 0 | FWUPD_ERROR, |
452 | 0 | FWUPD_ERROR_INVALID_DATA, |
453 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructCcgxDmcDockIdentity.product_string (0x%x bytes)", |
454 | 0 | value, (guint) len, (guint) 32); |
455 | 0 | return FALSE; |
456 | 0 | } |
457 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 40, (const guint8 *)value, len, 0x0, len, error); |
458 | 0 | } |
459 | | /** |
460 | | * fu_struct_ccgx_dmc_dock_identity_set_custom_meta_data_flag: (skip): |
461 | | **/ |
462 | | void |
463 | | fu_struct_ccgx_dmc_dock_identity_set_custom_meta_data_flag(FuStructCcgxDmcDockIdentity *st, guint8 value) |
464 | 0 | { |
465 | 0 | g_return_if_fail(st != NULL); |
466 | 0 | st->buf->data[72] = value; |
467 | 0 | } |
468 | | /** |
469 | | * fu_struct_ccgx_dmc_dock_identity_set_model: (skip): |
470 | | **/ |
471 | | void |
472 | | fu_struct_ccgx_dmc_dock_identity_set_model(FuStructCcgxDmcDockIdentity *st, guint8 value) |
473 | 0 | { |
474 | 0 | g_return_if_fail(st != NULL); |
475 | 0 | st->buf->data[73] = value; |
476 | 0 | } |
477 | | /** |
478 | | * fu_struct_ccgx_dmc_dock_identity_new: (skip): |
479 | | **/ |
480 | | FuStructCcgxDmcDockIdentity * |
481 | | fu_struct_ccgx_dmc_dock_identity_new(void) |
482 | 0 | { |
483 | 0 | FuStructCcgxDmcDockIdentity *st = fu_struct_ccgx_dmc_dock_identity_new_internal(); |
484 | 0 | st->buf = g_byte_array_sized_new(74); |
485 | 0 | fu_byte_array_set_size(st->buf, 74, 0x0); |
486 | 0 | return st; |
487 | 0 | } |
488 | | /** |
489 | | * fu_struct_ccgx_dmc_devx_status_ref: (skip): |
490 | | **/ |
491 | | FuStructCcgxDmcDevxStatus * |
492 | | fu_struct_ccgx_dmc_devx_status_ref(FuStructCcgxDmcDevxStatus *st) |
493 | 0 | { |
494 | 0 | g_return_val_if_fail(st != NULL, NULL); |
495 | 0 | st->refcount++; |
496 | 0 | return st; |
497 | 0 | } |
498 | | /** |
499 | | * fu_struct_ccgx_dmc_devx_status_unref: (skip): |
500 | | **/ |
501 | | void |
502 | | fu_struct_ccgx_dmc_devx_status_unref(FuStructCcgxDmcDevxStatus *st) |
503 | 0 | { |
504 | 0 | g_return_if_fail(st != NULL); |
505 | 0 | if (st->refcount == 0) { |
506 | 0 | g_critical("FuStructCcgxDmcDevxStatus refcount already zero"); |
507 | 0 | return; |
508 | 0 | } |
509 | 0 | if (--st->refcount > 0) |
510 | 0 | return; |
511 | 0 | if (st->buf != NULL) |
512 | 0 | g_byte_array_unref(st->buf); |
513 | 0 | g_free(st); |
514 | 0 | } |
515 | | /** |
516 | | * fu_struct_ccgx_dmc_devx_status_new_internal: (skip): |
517 | | **/ |
518 | | static FuStructCcgxDmcDevxStatus * |
519 | | fu_struct_ccgx_dmc_devx_status_new_internal(void) |
520 | 0 | { |
521 | 0 | FuStructCcgxDmcDevxStatus *st = g_new0(FuStructCcgxDmcDevxStatus, 1); |
522 | 0 | st->refcount = 1; |
523 | 0 | return st; |
524 | 0 | } |
525 | | |
526 | | /* getters */ |
527 | | /** |
528 | | * fu_struct_ccgx_dmc_devx_status_get_device_type: (skip): |
529 | | **/ |
530 | | FuCcgxDmcDevxDeviceType |
531 | | fu_struct_ccgx_dmc_devx_status_get_device_type(const FuStructCcgxDmcDevxStatus *st) |
532 | 0 | { |
533 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
534 | 0 | return st->buf->data[0]; |
535 | 0 | } |
536 | | /** |
537 | | * fu_struct_ccgx_dmc_devx_status_get_component_id: (skip): |
538 | | **/ |
539 | | guint8 |
540 | | fu_struct_ccgx_dmc_devx_status_get_component_id(const FuStructCcgxDmcDevxStatus *st) |
541 | 0 | { |
542 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
543 | 0 | return st->buf->data[1]; |
544 | 0 | } |
545 | | /** |
546 | | * fu_struct_ccgx_dmc_devx_status_get_image_mode: (skip): |
547 | | **/ |
548 | | FuCcgxDmcImgMode |
549 | | fu_struct_ccgx_dmc_devx_status_get_image_mode(const FuStructCcgxDmcDevxStatus *st) |
550 | 0 | { |
551 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
552 | 0 | return st->buf->data[2]; |
553 | 0 | } |
554 | | /** |
555 | | * fu_struct_ccgx_dmc_devx_status_get_current_image: (skip): |
556 | | **/ |
557 | | guint8 |
558 | | fu_struct_ccgx_dmc_devx_status_get_current_image(const FuStructCcgxDmcDevxStatus *st) |
559 | 0 | { |
560 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
561 | 0 | return st->buf->data[3]; |
562 | 0 | } |
563 | | /** |
564 | | * fu_struct_ccgx_dmc_devx_status_get_img_status: (skip): |
565 | | **/ |
566 | | guint8 |
567 | | fu_struct_ccgx_dmc_devx_status_get_img_status(const FuStructCcgxDmcDevxStatus *st) |
568 | 0 | { |
569 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
570 | 0 | return st->buf->data[4]; |
571 | 0 | } |
572 | | /** |
573 | | * fu_struct_ccgx_dmc_devx_status_get_fw_version: (skip): |
574 | | **/ |
575 | | const guint8 * |
576 | | fu_struct_ccgx_dmc_devx_status_get_fw_version(const FuStructCcgxDmcDevxStatus *st, gsize *bufsz) |
577 | 0 | { |
578 | 0 | g_return_val_if_fail(st != NULL, NULL); |
579 | 0 | if (bufsz != NULL) |
580 | 0 | *bufsz = 24; |
581 | 0 | return st->buf->data + 8; |
582 | 0 | } |
583 | | |
584 | | /* setters */ |
585 | | /** |
586 | | * fu_struct_ccgx_dmc_devx_status_to_string: (skip): |
587 | | **/ |
588 | | static gchar * |
589 | | fu_struct_ccgx_dmc_devx_status_to_string(const FuStructCcgxDmcDevxStatus *st) |
590 | 0 | { |
591 | 0 | g_autoptr(GString) str = g_string_new("FuStructCcgxDmcDevxStatus:\n"); |
592 | 0 | g_return_val_if_fail(st != NULL, NULL); |
593 | 0 | { |
594 | 0 | const gchar *tmp = fu_ccgx_dmc_devx_device_type_to_string(fu_struct_ccgx_dmc_devx_status_get_device_type(st)); |
595 | 0 | if (tmp != NULL) { |
596 | 0 | g_string_append_printf(str, " device_type: 0x%x [%s]\n", (guint) fu_struct_ccgx_dmc_devx_status_get_device_type(st), tmp); |
597 | 0 | } else { |
598 | 0 | g_string_append_printf(str, " device_type: 0x%x\n", (guint) fu_struct_ccgx_dmc_devx_status_get_device_type(st)); |
599 | 0 | } |
600 | 0 | } |
601 | 0 | g_string_append_printf(str, " component_id: 0x%x\n", |
602 | 0 | (guint) fu_struct_ccgx_dmc_devx_status_get_component_id(st)); |
603 | 0 | { |
604 | 0 | const gchar *tmp = fu_ccgx_dmc_img_mode_to_string(fu_struct_ccgx_dmc_devx_status_get_image_mode(st)); |
605 | 0 | if (tmp != NULL) { |
606 | 0 | g_string_append_printf(str, " image_mode: 0x%x [%s]\n", (guint) fu_struct_ccgx_dmc_devx_status_get_image_mode(st), tmp); |
607 | 0 | } else { |
608 | 0 | g_string_append_printf(str, " image_mode: 0x%x\n", (guint) fu_struct_ccgx_dmc_devx_status_get_image_mode(st)); |
609 | 0 | } |
610 | 0 | } |
611 | 0 | g_string_append_printf(str, " current_image: 0x%x\n", |
612 | 0 | (guint) fu_struct_ccgx_dmc_devx_status_get_current_image(st)); |
613 | 0 | g_string_append_printf(str, " img_status: 0x%x\n", |
614 | 0 | (guint) fu_struct_ccgx_dmc_devx_status_get_img_status(st)); |
615 | 0 | { |
616 | 0 | gsize bufsz = 0; |
617 | 0 | const guint8 *buf = fu_struct_ccgx_dmc_devx_status_get_fw_version(st, &bufsz); |
618 | 0 | g_autoptr(GString) tmp = g_string_new(NULL); |
619 | 0 | for (gsize i = 0; i < bufsz; i++) |
620 | 0 | g_string_append_printf(tmp, "%02X", buf[i]); |
621 | 0 | g_string_append_printf(str, " fw_version: 0x%s\n", tmp->str); |
622 | 0 | } |
623 | 0 | if (str->len > 0) |
624 | 0 | g_string_set_size(str, str->len - 1); |
625 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
626 | 0 | } |
627 | | static gboolean |
628 | | fu_struct_ccgx_dmc_devx_status_validate_internal(FuStructCcgxDmcDevxStatus *st, GError **error) |
629 | 0 | { |
630 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
631 | 0 | return TRUE; |
632 | 0 | } |
633 | | static gboolean |
634 | | fu_struct_ccgx_dmc_devx_status_parse_internal(FuStructCcgxDmcDevxStatus *st, GError **error) |
635 | 0 | { |
636 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
637 | 0 | g_autofree gchar *str = fu_struct_ccgx_dmc_devx_status_to_string(st); |
638 | 0 | g_debug("%s", str); |
639 | 0 | } |
640 | 0 | if (!fu_struct_ccgx_dmc_devx_status_validate_internal(st, error)) |
641 | 0 | return FALSE; |
642 | 0 | return TRUE; |
643 | 0 | } |
644 | | |
645 | | /** |
646 | | * fu_struct_ccgx_dmc_devx_status_parse: (skip): |
647 | | **/ |
648 | | FuStructCcgxDmcDevxStatus * |
649 | | fu_struct_ccgx_dmc_devx_status_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
650 | 0 | { |
651 | 0 | g_autoptr(FuStructCcgxDmcDevxStatus) st = fu_struct_ccgx_dmc_devx_status_new_internal(); |
652 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
653 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
654 | 0 | if (!fu_memchk_read(bufsz, offset, 32, error)) { |
655 | 0 | g_prefix_error_literal(error, "invalid struct FuStructCcgxDmcDevxStatus: "); |
656 | 0 | return NULL; |
657 | 0 | } |
658 | 0 | st->buf = g_byte_array_new(); |
659 | 0 | g_byte_array_append(st->buf, buf + offset, 32); |
660 | 0 | if (!fu_struct_ccgx_dmc_devx_status_parse_internal(st, error)) |
661 | 0 | return NULL; |
662 | 0 | return g_steal_pointer(&st); |
663 | 0 | } |
664 | | /** |
665 | | * fu_struct_ccgx_dmc_dock_status_ref: (skip): |
666 | | **/ |
667 | | FuStructCcgxDmcDockStatus * |
668 | | fu_struct_ccgx_dmc_dock_status_ref(FuStructCcgxDmcDockStatus *st) |
669 | 0 | { |
670 | 0 | g_return_val_if_fail(st != NULL, NULL); |
671 | 0 | st->refcount++; |
672 | 0 | return st; |
673 | 0 | } |
674 | | /** |
675 | | * fu_struct_ccgx_dmc_dock_status_unref: (skip): |
676 | | **/ |
677 | | void |
678 | | fu_struct_ccgx_dmc_dock_status_unref(FuStructCcgxDmcDockStatus *st) |
679 | 0 | { |
680 | 0 | g_return_if_fail(st != NULL); |
681 | 0 | if (st->refcount == 0) { |
682 | 0 | g_critical("FuStructCcgxDmcDockStatus refcount already zero"); |
683 | 0 | return; |
684 | 0 | } |
685 | 0 | if (--st->refcount > 0) |
686 | 0 | return; |
687 | 0 | if (st->buf != NULL) |
688 | 0 | g_byte_array_unref(st->buf); |
689 | 0 | g_free(st); |
690 | 0 | } |
691 | | /** |
692 | | * fu_struct_ccgx_dmc_dock_status_new_internal: (skip): |
693 | | **/ |
694 | | static FuStructCcgxDmcDockStatus * |
695 | | fu_struct_ccgx_dmc_dock_status_new_internal(void) |
696 | 0 | { |
697 | 0 | FuStructCcgxDmcDockStatus *st = g_new0(FuStructCcgxDmcDockStatus, 1); |
698 | 0 | st->refcount = 1; |
699 | 0 | return st; |
700 | 0 | } |
701 | | |
702 | | /* getters */ |
703 | | /** |
704 | | * fu_struct_ccgx_dmc_dock_status_get_device_status: (skip): |
705 | | **/ |
706 | | FuCcgxDmcDeviceStatus |
707 | | fu_struct_ccgx_dmc_dock_status_get_device_status(const FuStructCcgxDmcDockStatus *st) |
708 | 0 | { |
709 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
710 | 0 | return st->buf->data[0]; |
711 | 0 | } |
712 | | /** |
713 | | * fu_struct_ccgx_dmc_dock_status_get_device_count: (skip): |
714 | | **/ |
715 | | guint8 |
716 | | fu_struct_ccgx_dmc_dock_status_get_device_count(const FuStructCcgxDmcDockStatus *st) |
717 | 0 | { |
718 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
719 | 0 | return st->buf->data[1]; |
720 | 0 | } |
721 | | /** |
722 | | * fu_struct_ccgx_dmc_dock_status_get_status_length: (skip): |
723 | | **/ |
724 | | guint16 |
725 | | fu_struct_ccgx_dmc_dock_status_get_status_length(const FuStructCcgxDmcDockStatus *st) |
726 | 0 | { |
727 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
728 | 0 | return fu_memread_uint16(st->buf->data + 2, G_LITTLE_ENDIAN); |
729 | 0 | } |
730 | | /** |
731 | | * fu_struct_ccgx_dmc_dock_status_get_composite_version: (skip): |
732 | | **/ |
733 | | guint32 |
734 | | fu_struct_ccgx_dmc_dock_status_get_composite_version(const FuStructCcgxDmcDockStatus *st) |
735 | 0 | { |
736 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
737 | 0 | return fu_memread_uint32(st->buf->data + 4, G_LITTLE_ENDIAN); |
738 | 0 | } |
739 | | |
740 | | /* setters */ |
741 | | /** |
742 | | * fu_struct_ccgx_dmc_dock_status_set_device_status: (skip): |
743 | | **/ |
744 | | void |
745 | | fu_struct_ccgx_dmc_dock_status_set_device_status(FuStructCcgxDmcDockStatus *st, FuCcgxDmcDeviceStatus value) |
746 | 0 | { |
747 | 0 | g_return_if_fail(st != NULL); |
748 | 0 | st->buf->data[0] = value; |
749 | 0 | } |
750 | | /** |
751 | | * fu_struct_ccgx_dmc_dock_status_set_device_count: (skip): |
752 | | **/ |
753 | | void |
754 | | fu_struct_ccgx_dmc_dock_status_set_device_count(FuStructCcgxDmcDockStatus *st, guint8 value) |
755 | 0 | { |
756 | 0 | g_return_if_fail(st != NULL); |
757 | 0 | st->buf->data[1] = value; |
758 | 0 | } |
759 | | /** |
760 | | * fu_struct_ccgx_dmc_dock_status_set_status_length: (skip): |
761 | | **/ |
762 | | void |
763 | | fu_struct_ccgx_dmc_dock_status_set_status_length(FuStructCcgxDmcDockStatus *st, guint16 value) |
764 | 0 | { |
765 | 0 | g_return_if_fail(st != NULL); |
766 | 0 | fu_memwrite_uint16(st->buf->data + 2, value, G_LITTLE_ENDIAN); |
767 | 0 | } |
768 | | /** |
769 | | * fu_struct_ccgx_dmc_dock_status_set_composite_version: (skip): |
770 | | **/ |
771 | | void |
772 | | fu_struct_ccgx_dmc_dock_status_set_composite_version(FuStructCcgxDmcDockStatus *st, guint32 value) |
773 | 0 | { |
774 | 0 | g_return_if_fail(st != NULL); |
775 | 0 | fu_memwrite_uint32(st->buf->data + 4, value, G_LITTLE_ENDIAN); |
776 | 0 | } |
777 | | /** |
778 | | * fu_struct_ccgx_dmc_dock_status_new: (skip): |
779 | | **/ |
780 | | FuStructCcgxDmcDockStatus * |
781 | | fu_struct_ccgx_dmc_dock_status_new(void) |
782 | 0 | { |
783 | 0 | FuStructCcgxDmcDockStatus *st = fu_struct_ccgx_dmc_dock_status_new_internal(); |
784 | 0 | st->buf = g_byte_array_sized_new(8); |
785 | 0 | fu_byte_array_set_size(st->buf, 8, 0x0); |
786 | 0 | return st; |
787 | 0 | } |
788 | | /** |
789 | | * fu_struct_ccgx_dmc_int_rqt_ref: (skip): |
790 | | **/ |
791 | | FuStructCcgxDmcIntRqt * |
792 | | fu_struct_ccgx_dmc_int_rqt_ref(FuStructCcgxDmcIntRqt *st) |
793 | 0 | { |
794 | 0 | g_return_val_if_fail(st != NULL, NULL); |
795 | 0 | st->refcount++; |
796 | 0 | return st; |
797 | 0 | } |
798 | | /** |
799 | | * fu_struct_ccgx_dmc_int_rqt_unref: (skip): |
800 | | **/ |
801 | | void |
802 | | fu_struct_ccgx_dmc_int_rqt_unref(FuStructCcgxDmcIntRqt *st) |
803 | 0 | { |
804 | 0 | g_return_if_fail(st != NULL); |
805 | 0 | if (st->refcount == 0) { |
806 | 0 | g_critical("FuStructCcgxDmcIntRqt refcount already zero"); |
807 | 0 | return; |
808 | 0 | } |
809 | 0 | if (--st->refcount > 0) |
810 | 0 | return; |
811 | 0 | if (st->buf != NULL) |
812 | 0 | g_byte_array_unref(st->buf); |
813 | 0 | g_free(st); |
814 | 0 | } |
815 | | /** |
816 | | * fu_struct_ccgx_dmc_int_rqt_new_internal: (skip): |
817 | | **/ |
818 | | static FuStructCcgxDmcIntRqt * |
819 | | fu_struct_ccgx_dmc_int_rqt_new_internal(void) |
820 | 0 | { |
821 | 0 | FuStructCcgxDmcIntRqt *st = g_new0(FuStructCcgxDmcIntRqt, 1); |
822 | 0 | st->refcount = 1; |
823 | 0 | return st; |
824 | 0 | } |
825 | | |
826 | | /* getters */ |
827 | | /** |
828 | | * fu_struct_ccgx_dmc_int_rqt_get_opcode: (skip): |
829 | | **/ |
830 | | FuCcgxDmcIntOpcode |
831 | | fu_struct_ccgx_dmc_int_rqt_get_opcode(const FuStructCcgxDmcIntRqt *st) |
832 | 0 | { |
833 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
834 | 0 | return st->buf->data[0]; |
835 | 0 | } |
836 | | /** |
837 | | * fu_struct_ccgx_dmc_int_rqt_get_length: (skip): |
838 | | **/ |
839 | | guint8 |
840 | | fu_struct_ccgx_dmc_int_rqt_get_length(const FuStructCcgxDmcIntRqt *st) |
841 | 0 | { |
842 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
843 | 0 | return st->buf->data[1]; |
844 | 0 | } |
845 | | /** |
846 | | * fu_struct_ccgx_dmc_int_rqt_get_data: (skip): |
847 | | **/ |
848 | | const guint8 * |
849 | | fu_struct_ccgx_dmc_int_rqt_get_data(const FuStructCcgxDmcIntRqt *st, gsize *bufsz) |
850 | 0 | { |
851 | 0 | g_return_val_if_fail(st != NULL, NULL); |
852 | 0 | if (bufsz != NULL) |
853 | 0 | *bufsz = 8; |
854 | 0 | return st->buf->data + 2; |
855 | 0 | } |
856 | | |
857 | | /* setters */ |
858 | | /** |
859 | | * fu_struct_ccgx_dmc_int_rqt_set_opcode: (skip): |
860 | | **/ |
861 | | void |
862 | | fu_struct_ccgx_dmc_int_rqt_set_opcode(FuStructCcgxDmcIntRqt *st, FuCcgxDmcIntOpcode value) |
863 | 0 | { |
864 | 0 | g_return_if_fail(st != NULL); |
865 | 0 | st->buf->data[0] = value; |
866 | 0 | } |
867 | | /** |
868 | | * fu_struct_ccgx_dmc_int_rqt_set_length: (skip): |
869 | | **/ |
870 | | void |
871 | | fu_struct_ccgx_dmc_int_rqt_set_length(FuStructCcgxDmcIntRqt *st, guint8 value) |
872 | 0 | { |
873 | 0 | g_return_if_fail(st != NULL); |
874 | 0 | st->buf->data[1] = value; |
875 | 0 | } |
876 | | /** |
877 | | * fu_struct_ccgx_dmc_int_rqt_set_data: (skip): |
878 | | **/ |
879 | | gboolean |
880 | | fu_struct_ccgx_dmc_int_rqt_set_data(FuStructCcgxDmcIntRqt *st, const guint8 *buf, gsize bufsz, GError **error) |
881 | 0 | { |
882 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
883 | 0 | g_return_val_if_fail(buf != NULL, FALSE); |
884 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
885 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 2, buf, bufsz, 0x0, bufsz, error); |
886 | 0 | } |
887 | | /** |
888 | | * fu_struct_ccgx_dmc_int_rqt_new: (skip): |
889 | | **/ |
890 | | FuStructCcgxDmcIntRqt * |
891 | | fu_struct_ccgx_dmc_int_rqt_new(void) |
892 | 0 | { |
893 | 0 | FuStructCcgxDmcIntRqt *st = fu_struct_ccgx_dmc_int_rqt_new_internal(); |
894 | 0 | st->buf = g_byte_array_sized_new(10); |
895 | 0 | fu_byte_array_set_size(st->buf, 10, 0x0); |
896 | 0 | return st; |
897 | 0 | } |
898 | | /** |
899 | | * fu_struct_ccgx_dmc_fwct_info_ref: (skip): |
900 | | **/ |
901 | | FuStructCcgxDmcFwctInfo * |
902 | | fu_struct_ccgx_dmc_fwct_info_ref(FuStructCcgxDmcFwctInfo *st) |
903 | 0 | { |
904 | 0 | g_return_val_if_fail(st != NULL, NULL); |
905 | 0 | st->refcount++; |
906 | 0 | return st; |
907 | 0 | } |
908 | | /** |
909 | | * fu_struct_ccgx_dmc_fwct_info_unref: (skip): |
910 | | **/ |
911 | | void |
912 | | fu_struct_ccgx_dmc_fwct_info_unref(FuStructCcgxDmcFwctInfo *st) |
913 | 290k | { |
914 | 290k | g_return_if_fail(st != NULL); |
915 | 290k | if (st->refcount == 0) { |
916 | 0 | g_critical("FuStructCcgxDmcFwctInfo refcount already zero"); |
917 | 0 | return; |
918 | 0 | } |
919 | 290k | if (--st->refcount > 0) |
920 | 0 | return; |
921 | 290k | if (st->buf != NULL) |
922 | 290k | g_byte_array_unref(st->buf); |
923 | 290k | g_free(st); |
924 | 290k | } |
925 | | /** |
926 | | * fu_struct_ccgx_dmc_fwct_info_new_internal: (skip): |
927 | | **/ |
928 | | static FuStructCcgxDmcFwctInfo * |
929 | | fu_struct_ccgx_dmc_fwct_info_new_internal(void) |
930 | 290k | { |
931 | 290k | FuStructCcgxDmcFwctInfo *st = g_new0(FuStructCcgxDmcFwctInfo, 1); |
932 | 290k | st->refcount = 1; |
933 | 290k | return st; |
934 | 290k | } |
935 | | |
936 | | /* getters */ |
937 | | /** |
938 | | * fu_struct_ccgx_dmc_fwct_info_get_signature: (skip): |
939 | | **/ |
940 | | static guint32 |
941 | | fu_struct_ccgx_dmc_fwct_info_get_signature(const FuStructCcgxDmcFwctInfo *st) |
942 | 567k | { |
943 | 567k | g_return_val_if_fail(st != NULL, 0x0); |
944 | 567k | return fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
945 | 567k | } |
946 | | /** |
947 | | * fu_struct_ccgx_dmc_fwct_info_get_size: (skip): |
948 | | **/ |
949 | | guint16 |
950 | | fu_struct_ccgx_dmc_fwct_info_get_size(const FuStructCcgxDmcFwctInfo *st) |
951 | 1.07k | { |
952 | 1.07k | g_return_val_if_fail(st != NULL, 0x0); |
953 | 1.07k | return fu_memread_uint16(st->buf->data + 4, G_LITTLE_ENDIAN); |
954 | 1.07k | } |
955 | | /** |
956 | | * fu_struct_ccgx_dmc_fwct_info_get_checksum: (skip): |
957 | | **/ |
958 | | guint8 |
959 | | fu_struct_ccgx_dmc_fwct_info_get_checksum(const FuStructCcgxDmcFwctInfo *st) |
960 | 0 | { |
961 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
962 | 0 | return st->buf->data[6]; |
963 | 0 | } |
964 | | /** |
965 | | * fu_struct_ccgx_dmc_fwct_info_get_version: (skip): |
966 | | **/ |
967 | | guint8 |
968 | | fu_struct_ccgx_dmc_fwct_info_get_version(const FuStructCcgxDmcFwctInfo *st) |
969 | 0 | { |
970 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
971 | 0 | return st->buf->data[7]; |
972 | 0 | } |
973 | | /** |
974 | | * fu_struct_ccgx_dmc_fwct_info_get_custom_meta_type: (skip): |
975 | | **/ |
976 | | guint8 |
977 | | fu_struct_ccgx_dmc_fwct_info_get_custom_meta_type(const FuStructCcgxDmcFwctInfo *st) |
978 | 0 | { |
979 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
980 | 0 | return st->buf->data[8]; |
981 | 0 | } |
982 | | /** |
983 | | * fu_struct_ccgx_dmc_fwct_info_get_cdtt_version: (skip): |
984 | | **/ |
985 | | guint8 |
986 | | fu_struct_ccgx_dmc_fwct_info_get_cdtt_version(const FuStructCcgxDmcFwctInfo *st) |
987 | 0 | { |
988 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
989 | 0 | return st->buf->data[9]; |
990 | 0 | } |
991 | | /** |
992 | | * fu_struct_ccgx_dmc_fwct_info_get_vid: (skip): |
993 | | **/ |
994 | | guint16 |
995 | | fu_struct_ccgx_dmc_fwct_info_get_vid(const FuStructCcgxDmcFwctInfo *st) |
996 | 0 | { |
997 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
998 | 0 | return fu_memread_uint16(st->buf->data + 10, G_LITTLE_ENDIAN); |
999 | 0 | } |
1000 | | /** |
1001 | | * fu_struct_ccgx_dmc_fwct_info_get_pid: (skip): |
1002 | | **/ |
1003 | | guint16 |
1004 | | fu_struct_ccgx_dmc_fwct_info_get_pid(const FuStructCcgxDmcFwctInfo *st) |
1005 | 0 | { |
1006 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1007 | 0 | return fu_memread_uint16(st->buf->data + 12, G_LITTLE_ENDIAN); |
1008 | 0 | } |
1009 | | /** |
1010 | | * fu_struct_ccgx_dmc_fwct_info_get_device_id: (skip): |
1011 | | **/ |
1012 | | guint16 |
1013 | | fu_struct_ccgx_dmc_fwct_info_get_device_id(const FuStructCcgxDmcFwctInfo *st) |
1014 | 0 | { |
1015 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1016 | 0 | return fu_memread_uint16(st->buf->data + 14, G_LITTLE_ENDIAN); |
1017 | 0 | } |
1018 | | /** |
1019 | | * fu_struct_ccgx_dmc_fwct_info_get_composite_version: (skip): |
1020 | | **/ |
1021 | | guint32 |
1022 | | fu_struct_ccgx_dmc_fwct_info_get_composite_version(const FuStructCcgxDmcFwctInfo *st) |
1023 | 1.05k | { |
1024 | 1.05k | g_return_val_if_fail(st != NULL, 0x0); |
1025 | 1.05k | return fu_memread_uint32(st->buf->data + 32, G_LITTLE_ENDIAN); |
1026 | 1.05k | } |
1027 | | /** |
1028 | | * fu_struct_ccgx_dmc_fwct_info_get_image_count: (skip): |
1029 | | **/ |
1030 | | guint8 |
1031 | | fu_struct_ccgx_dmc_fwct_info_get_image_count(const FuStructCcgxDmcFwctInfo *st) |
1032 | 966 | { |
1033 | 966 | g_return_val_if_fail(st != NULL, 0x0); |
1034 | 966 | return st->buf->data[36]; |
1035 | 966 | } |
1036 | | |
1037 | | /* setters */ |
1038 | | /** |
1039 | | * fu_struct_ccgx_dmc_fwct_info_set_signature: (skip): |
1040 | | **/ |
1041 | | static void |
1042 | | fu_struct_ccgx_dmc_fwct_info_set_signature(FuStructCcgxDmcFwctInfo *st, guint32 value) |
1043 | 181 | { |
1044 | 181 | g_return_if_fail(st != NULL); |
1045 | 181 | fu_memwrite_uint32(st->buf->data + 0, value, G_LITTLE_ENDIAN); |
1046 | 181 | } |
1047 | | /** |
1048 | | * fu_struct_ccgx_dmc_fwct_info_set_size: (skip): |
1049 | | **/ |
1050 | | void |
1051 | | fu_struct_ccgx_dmc_fwct_info_set_size(FuStructCcgxDmcFwctInfo *st, guint16 value) |
1052 | 181 | { |
1053 | 181 | g_return_if_fail(st != NULL); |
1054 | 181 | fu_memwrite_uint16(st->buf->data + 4, value, G_LITTLE_ENDIAN); |
1055 | 181 | } |
1056 | | /** |
1057 | | * fu_struct_ccgx_dmc_fwct_info_set_checksum: (skip): |
1058 | | **/ |
1059 | | void |
1060 | | fu_struct_ccgx_dmc_fwct_info_set_checksum(FuStructCcgxDmcFwctInfo *st, guint8 value) |
1061 | 0 | { |
1062 | 0 | g_return_if_fail(st != NULL); |
1063 | 0 | st->buf->data[6] = value; |
1064 | 0 | } |
1065 | | /** |
1066 | | * fu_struct_ccgx_dmc_fwct_info_set_version: (skip): |
1067 | | **/ |
1068 | | void |
1069 | | fu_struct_ccgx_dmc_fwct_info_set_version(FuStructCcgxDmcFwctInfo *st, guint8 value) |
1070 | 181 | { |
1071 | 181 | g_return_if_fail(st != NULL); |
1072 | 181 | st->buf->data[7] = value; |
1073 | 181 | } |
1074 | | /** |
1075 | | * fu_struct_ccgx_dmc_fwct_info_set_custom_meta_type: (skip): |
1076 | | **/ |
1077 | | void |
1078 | | fu_struct_ccgx_dmc_fwct_info_set_custom_meta_type(FuStructCcgxDmcFwctInfo *st, guint8 value) |
1079 | 181 | { |
1080 | 181 | g_return_if_fail(st != NULL); |
1081 | 181 | st->buf->data[8] = value; |
1082 | 181 | } |
1083 | | /** |
1084 | | * fu_struct_ccgx_dmc_fwct_info_set_cdtt_version: (skip): |
1085 | | **/ |
1086 | | void |
1087 | | fu_struct_ccgx_dmc_fwct_info_set_cdtt_version(FuStructCcgxDmcFwctInfo *st, guint8 value) |
1088 | 181 | { |
1089 | 181 | g_return_if_fail(st != NULL); |
1090 | 181 | st->buf->data[9] = value; |
1091 | 181 | } |
1092 | | /** |
1093 | | * fu_struct_ccgx_dmc_fwct_info_set_vid: (skip): |
1094 | | **/ |
1095 | | void |
1096 | | fu_struct_ccgx_dmc_fwct_info_set_vid(FuStructCcgxDmcFwctInfo *st, guint16 value) |
1097 | 0 | { |
1098 | 0 | g_return_if_fail(st != NULL); |
1099 | 0 | fu_memwrite_uint16(st->buf->data + 10, value, G_LITTLE_ENDIAN); |
1100 | 0 | } |
1101 | | /** |
1102 | | * fu_struct_ccgx_dmc_fwct_info_set_pid: (skip): |
1103 | | **/ |
1104 | | void |
1105 | | fu_struct_ccgx_dmc_fwct_info_set_pid(FuStructCcgxDmcFwctInfo *st, guint16 value) |
1106 | 0 | { |
1107 | 0 | g_return_if_fail(st != NULL); |
1108 | 0 | fu_memwrite_uint16(st->buf->data + 12, value, G_LITTLE_ENDIAN); |
1109 | 0 | } |
1110 | | /** |
1111 | | * fu_struct_ccgx_dmc_fwct_info_set_device_id: (skip): |
1112 | | **/ |
1113 | | void |
1114 | | fu_struct_ccgx_dmc_fwct_info_set_device_id(FuStructCcgxDmcFwctInfo *st, guint16 value) |
1115 | 181 | { |
1116 | 181 | g_return_if_fail(st != NULL); |
1117 | 181 | fu_memwrite_uint16(st->buf->data + 14, value, G_LITTLE_ENDIAN); |
1118 | 181 | } |
1119 | | /** |
1120 | | * fu_struct_ccgx_dmc_fwct_info_set_composite_version: (skip): |
1121 | | **/ |
1122 | | void |
1123 | | fu_struct_ccgx_dmc_fwct_info_set_composite_version(FuStructCcgxDmcFwctInfo *st, guint32 value) |
1124 | 181 | { |
1125 | 181 | g_return_if_fail(st != NULL); |
1126 | 181 | fu_memwrite_uint32(st->buf->data + 32, value, G_LITTLE_ENDIAN); |
1127 | 181 | } |
1128 | | /** |
1129 | | * fu_struct_ccgx_dmc_fwct_info_set_image_count: (skip): |
1130 | | **/ |
1131 | | void |
1132 | | fu_struct_ccgx_dmc_fwct_info_set_image_count(FuStructCcgxDmcFwctInfo *st, guint8 value) |
1133 | 181 | { |
1134 | 181 | g_return_if_fail(st != NULL); |
1135 | 181 | st->buf->data[36] = value; |
1136 | 181 | } |
1137 | | /** |
1138 | | * fu_struct_ccgx_dmc_fwct_info_new: (skip): |
1139 | | **/ |
1140 | | FuStructCcgxDmcFwctInfo * |
1141 | | fu_struct_ccgx_dmc_fwct_info_new(void) |
1142 | 181 | { |
1143 | 181 | FuStructCcgxDmcFwctInfo *st = fu_struct_ccgx_dmc_fwct_info_new_internal(); |
1144 | 181 | st->buf = g_byte_array_sized_new(40); |
1145 | 181 | fu_byte_array_set_size(st->buf, 40, 0x0); |
1146 | 181 | fu_struct_ccgx_dmc_fwct_info_set_signature(st, 0x54435746); |
1147 | 181 | return st; |
1148 | 181 | } |
1149 | | /** |
1150 | | * fu_struct_ccgx_dmc_fwct_info_to_string: (skip): |
1151 | | **/ |
1152 | | static gchar * |
1153 | | fu_struct_ccgx_dmc_fwct_info_to_string(const FuStructCcgxDmcFwctInfo *st) |
1154 | 0 | { |
1155 | 0 | g_autoptr(GString) str = g_string_new("FuStructCcgxDmcFwctInfo:\n"); |
1156 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1157 | 0 | g_string_append_printf(str, " signature: 0x%x\n", |
1158 | 0 | (guint) fu_struct_ccgx_dmc_fwct_info_get_signature(st)); |
1159 | 0 | g_string_append_printf(str, " size: 0x%x\n", |
1160 | 0 | (guint) fu_struct_ccgx_dmc_fwct_info_get_size(st)); |
1161 | 0 | g_string_append_printf(str, " checksum: 0x%x\n", |
1162 | 0 | (guint) fu_struct_ccgx_dmc_fwct_info_get_checksum(st)); |
1163 | 0 | g_string_append_printf(str, " version: 0x%x\n", |
1164 | 0 | (guint) fu_struct_ccgx_dmc_fwct_info_get_version(st)); |
1165 | 0 | g_string_append_printf(str, " custom_meta_type: 0x%x\n", |
1166 | 0 | (guint) fu_struct_ccgx_dmc_fwct_info_get_custom_meta_type(st)); |
1167 | 0 | g_string_append_printf(str, " cdtt_version: 0x%x\n", |
1168 | 0 | (guint) fu_struct_ccgx_dmc_fwct_info_get_cdtt_version(st)); |
1169 | 0 | g_string_append_printf(str, " vid: 0x%x\n", |
1170 | 0 | (guint) fu_struct_ccgx_dmc_fwct_info_get_vid(st)); |
1171 | 0 | g_string_append_printf(str, " pid: 0x%x\n", |
1172 | 0 | (guint) fu_struct_ccgx_dmc_fwct_info_get_pid(st)); |
1173 | 0 | g_string_append_printf(str, " device_id: 0x%x\n", |
1174 | 0 | (guint) fu_struct_ccgx_dmc_fwct_info_get_device_id(st)); |
1175 | 0 | g_string_append_printf(str, " composite_version: 0x%x\n", |
1176 | 0 | (guint) fu_struct_ccgx_dmc_fwct_info_get_composite_version(st)); |
1177 | 0 | g_string_append_printf(str, " image_count: 0x%x\n", |
1178 | 0 | (guint) fu_struct_ccgx_dmc_fwct_info_get_image_count(st)); |
1179 | 0 | if (str->len > 0) |
1180 | 0 | g_string_set_size(str, str->len - 1); |
1181 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1182 | 0 | } |
1183 | | static gboolean |
1184 | | fu_struct_ccgx_dmc_fwct_info_validate_internal(FuStructCcgxDmcFwctInfo *st, GError **error) |
1185 | 284k | { |
1186 | 284k | g_return_val_if_fail(st != NULL, FALSE); |
1187 | 284k | if (fu_struct_ccgx_dmc_fwct_info_get_signature(st) != 0x54435746) { |
1188 | 282k | g_set_error(error, |
1189 | 282k | FWUPD_ERROR, |
1190 | 282k | FWUPD_ERROR_INVALID_DATA, |
1191 | 282k | "constant FuStructCcgxDmcFwctInfo.signature was not valid, " |
1192 | 282k | "expected 0x%x and got 0x%x", |
1193 | 282k | (guint) 0x54435746, |
1194 | 282k | (guint) fu_struct_ccgx_dmc_fwct_info_get_signature(st)); |
1195 | 282k | return FALSE; |
1196 | 282k | } |
1197 | 2.15k | return TRUE; |
1198 | 284k | } |
1199 | | /** |
1200 | | * fu_struct_ccgx_dmc_fwct_info_validate_stream: (skip): |
1201 | | **/ |
1202 | | gboolean |
1203 | | fu_struct_ccgx_dmc_fwct_info_validate_stream(GInputStream *stream, gsize offset, GError **error) |
1204 | 288k | { |
1205 | 288k | g_autoptr(FuStructCcgxDmcFwctInfo) st = fu_struct_ccgx_dmc_fwct_info_new_internal(); |
1206 | 288k | g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE); |
1207 | 288k | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
1208 | 288k | st->buf = fu_input_stream_read_byte_array(stream, offset, 40, NULL, error); |
1209 | 288k | if (st->buf == NULL) { |
1210 | 0 | g_prefix_error(error, "FuStructCcgxDmcFwctInfo failed read of 0x%x: ", (guint) 40); |
1211 | 0 | return FALSE; |
1212 | 0 | } |
1213 | 288k | if (st->buf->len != 40) { |
1214 | 5.25k | g_set_error(error, |
1215 | 5.25k | FWUPD_ERROR, |
1216 | 5.25k | FWUPD_ERROR_INVALID_DATA, |
1217 | 5.25k | "FuStructCcgxDmcFwctInfo requested 0x%x and got 0x%x", |
1218 | 5.25k | (guint) 40, |
1219 | 5.25k | (guint) st->buf->len); |
1220 | 5.25k | return FALSE; |
1221 | 5.25k | } |
1222 | 283k | return fu_struct_ccgx_dmc_fwct_info_validate_internal(st, error); |
1223 | 288k | } |
1224 | | static gboolean |
1225 | | fu_struct_ccgx_dmc_fwct_info_parse_internal(FuStructCcgxDmcFwctInfo *st, GError **error) |
1226 | 1.07k | { |
1227 | 1.07k | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
1228 | 0 | g_autofree gchar *str = fu_struct_ccgx_dmc_fwct_info_to_string(st); |
1229 | 0 | g_debug("%s", str); |
1230 | 0 | } |
1231 | 1.07k | if (!fu_struct_ccgx_dmc_fwct_info_validate_internal(st, error)) |
1232 | 0 | return FALSE; |
1233 | 1.07k | return TRUE; |
1234 | 1.07k | } |
1235 | | /** |
1236 | | * fu_struct_ccgx_dmc_fwct_info_parse_stream: (skip): |
1237 | | **/ |
1238 | | FuStructCcgxDmcFwctInfo * |
1239 | | fu_struct_ccgx_dmc_fwct_info_parse_stream(GInputStream *stream, gsize offset, GError **error) |
1240 | 1.07k | { |
1241 | 1.07k | g_autoptr(FuStructCcgxDmcFwctInfo) st = fu_struct_ccgx_dmc_fwct_info_new_internal(); |
1242 | 1.07k | st->buf = fu_input_stream_read_byte_array(stream, offset, 40, NULL, error); |
1243 | 1.07k | if (st->buf == NULL) { |
1244 | 0 | g_prefix_error(error, "FuStructCcgxDmcFwctInfo failed read of 0x%x: ", (guint) 40); |
1245 | 0 | return NULL; |
1246 | 0 | } |
1247 | 1.07k | if (st->buf->len != 40) { |
1248 | 0 | g_set_error(error, |
1249 | 0 | FWUPD_ERROR, |
1250 | 0 | FWUPD_ERROR_INVALID_DATA, |
1251 | 0 | "FuStructCcgxDmcFwctInfo requested 0x%x and got 0x%x", |
1252 | 0 | (guint) 40, |
1253 | 0 | (guint) st->buf->len); |
1254 | 0 | return NULL; |
1255 | 0 | } |
1256 | 1.07k | if (!fu_struct_ccgx_dmc_fwct_info_parse_internal(st, error)) |
1257 | 0 | return NULL; |
1258 | 1.07k | return g_steal_pointer(&st); |
1259 | 1.07k | } |
1260 | | /** |
1261 | | * fu_struct_ccgx_dmc_fwct_image_info_ref: (skip): |
1262 | | **/ |
1263 | | FuStructCcgxDmcFwctImageInfo * |
1264 | | fu_struct_ccgx_dmc_fwct_image_info_ref(FuStructCcgxDmcFwctImageInfo *st) |
1265 | 0 | { |
1266 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1267 | 0 | st->refcount++; |
1268 | 0 | return st; |
1269 | 0 | } |
1270 | | /** |
1271 | | * fu_struct_ccgx_dmc_fwct_image_info_unref: (skip): |
1272 | | **/ |
1273 | | void |
1274 | | fu_struct_ccgx_dmc_fwct_image_info_unref(FuStructCcgxDmcFwctImageInfo *st) |
1275 | 2.52k | { |
1276 | 2.52k | g_return_if_fail(st != NULL); |
1277 | 2.52k | if (st->refcount == 0) { |
1278 | 0 | g_critical("FuStructCcgxDmcFwctImageInfo refcount already zero"); |
1279 | 0 | return; |
1280 | 0 | } |
1281 | 2.52k | if (--st->refcount > 0) |
1282 | 0 | return; |
1283 | 2.52k | if (st->buf != NULL) |
1284 | 2.42k | g_byte_array_unref(st->buf); |
1285 | 2.52k | g_free(st); |
1286 | 2.52k | } |
1287 | | /** |
1288 | | * fu_struct_ccgx_dmc_fwct_image_info_new_internal: (skip): |
1289 | | **/ |
1290 | | static FuStructCcgxDmcFwctImageInfo * |
1291 | | fu_struct_ccgx_dmc_fwct_image_info_new_internal(void) |
1292 | 2.52k | { |
1293 | 2.52k | FuStructCcgxDmcFwctImageInfo *st = g_new0(FuStructCcgxDmcFwctImageInfo, 1); |
1294 | 2.52k | st->refcount = 1; |
1295 | 2.52k | return st; |
1296 | 2.52k | } |
1297 | | |
1298 | | /* getters */ |
1299 | | /** |
1300 | | * fu_struct_ccgx_dmc_fwct_image_info_get_device_type: (skip): |
1301 | | **/ |
1302 | | guint8 |
1303 | | fu_struct_ccgx_dmc_fwct_image_info_get_device_type(const FuStructCcgxDmcFwctImageInfo *st) |
1304 | 0 | { |
1305 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1306 | 0 | return st->buf->data[0]; |
1307 | 0 | } |
1308 | | /** |
1309 | | * fu_struct_ccgx_dmc_fwct_image_info_get_img_type: (skip): |
1310 | | **/ |
1311 | | guint8 |
1312 | | fu_struct_ccgx_dmc_fwct_image_info_get_img_type(const FuStructCcgxDmcFwctImageInfo *st) |
1313 | 0 | { |
1314 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1315 | 0 | return st->buf->data[1]; |
1316 | 0 | } |
1317 | | /** |
1318 | | * fu_struct_ccgx_dmc_fwct_image_info_get_comp_id: (skip): |
1319 | | **/ |
1320 | | guint8 |
1321 | | fu_struct_ccgx_dmc_fwct_image_info_get_comp_id(const FuStructCcgxDmcFwctImageInfo *st) |
1322 | 0 | { |
1323 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1324 | 0 | return st->buf->data[2]; |
1325 | 0 | } |
1326 | | /** |
1327 | | * fu_struct_ccgx_dmc_fwct_image_info_get_row_size: (skip): |
1328 | | **/ |
1329 | | guint8 |
1330 | | fu_struct_ccgx_dmc_fwct_image_info_get_row_size(const FuStructCcgxDmcFwctImageInfo *st) |
1331 | 2.38k | { |
1332 | 2.38k | g_return_val_if_fail(st != NULL, 0x0); |
1333 | 2.38k | return st->buf->data[3]; |
1334 | 2.38k | } |
1335 | | /** |
1336 | | * fu_struct_ccgx_dmc_fwct_image_info_get_fw_version: (skip): |
1337 | | **/ |
1338 | | guint32 |
1339 | | fu_struct_ccgx_dmc_fwct_image_info_get_fw_version(const FuStructCcgxDmcFwctImageInfo *st) |
1340 | 0 | { |
1341 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1342 | 0 | return fu_memread_uint32(st->buf->data + 8, G_LITTLE_ENDIAN); |
1343 | 0 | } |
1344 | | /** |
1345 | | * fu_struct_ccgx_dmc_fwct_image_info_get_app_version: (skip): |
1346 | | **/ |
1347 | | guint32 |
1348 | | fu_struct_ccgx_dmc_fwct_image_info_get_app_version(const FuStructCcgxDmcFwctImageInfo *st) |
1349 | 0 | { |
1350 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1351 | 0 | return fu_memread_uint32(st->buf->data + 12, G_LITTLE_ENDIAN); |
1352 | 0 | } |
1353 | | /** |
1354 | | * fu_struct_ccgx_dmc_fwct_image_info_get_img_offset: (skip): |
1355 | | **/ |
1356 | | guint32 |
1357 | | fu_struct_ccgx_dmc_fwct_image_info_get_img_offset(const FuStructCcgxDmcFwctImageInfo *st) |
1358 | 2.36k | { |
1359 | 2.36k | g_return_val_if_fail(st != NULL, 0x0); |
1360 | 2.36k | return fu_memread_uint32(st->buf->data + 16, G_LITTLE_ENDIAN); |
1361 | 2.36k | } |
1362 | | /** |
1363 | | * fu_struct_ccgx_dmc_fwct_image_info_get_img_size: (skip): |
1364 | | **/ |
1365 | | guint32 |
1366 | | fu_struct_ccgx_dmc_fwct_image_info_get_img_size(const FuStructCcgxDmcFwctImageInfo *st) |
1367 | 0 | { |
1368 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1369 | 0 | return fu_memread_uint32(st->buf->data + 20, G_LITTLE_ENDIAN); |
1370 | 0 | } |
1371 | | /** |
1372 | | * fu_struct_ccgx_dmc_fwct_image_info_get_img_digest: (skip): |
1373 | | **/ |
1374 | | const guint8 * |
1375 | | fu_struct_ccgx_dmc_fwct_image_info_get_img_digest(const FuStructCcgxDmcFwctImageInfo *st, gsize *bufsz) |
1376 | 1.91k | { |
1377 | 1.91k | g_return_val_if_fail(st != NULL, NULL); |
1378 | 1.91k | if (bufsz != NULL) |
1379 | 1.91k | *bufsz = 32; |
1380 | 1.91k | return st->buf->data + 24; |
1381 | 1.91k | } |
1382 | | /** |
1383 | | * fu_struct_ccgx_dmc_fwct_image_info_get_num_img_segments: (skip): |
1384 | | **/ |
1385 | | guint8 |
1386 | | fu_struct_ccgx_dmc_fwct_image_info_get_num_img_segments(const FuStructCcgxDmcFwctImageInfo *st) |
1387 | 2.36k | { |
1388 | 2.36k | g_return_val_if_fail(st != NULL, 0x0); |
1389 | 2.36k | return st->buf->data[56]; |
1390 | 2.36k | } |
1391 | | |
1392 | | /* setters */ |
1393 | | /** |
1394 | | * fu_struct_ccgx_dmc_fwct_image_info_set_device_type: (skip): |
1395 | | **/ |
1396 | | void |
1397 | | fu_struct_ccgx_dmc_fwct_image_info_set_device_type(FuStructCcgxDmcFwctImageInfo *st, guint8 value) |
1398 | 0 | { |
1399 | 0 | g_return_if_fail(st != NULL); |
1400 | 0 | st->buf->data[0] = value; |
1401 | 0 | } |
1402 | | /** |
1403 | | * fu_struct_ccgx_dmc_fwct_image_info_set_img_type: (skip): |
1404 | | **/ |
1405 | | void |
1406 | | fu_struct_ccgx_dmc_fwct_image_info_set_img_type(FuStructCcgxDmcFwctImageInfo *st, guint8 value) |
1407 | 0 | { |
1408 | 0 | g_return_if_fail(st != NULL); |
1409 | 0 | st->buf->data[1] = value; |
1410 | 0 | } |
1411 | | /** |
1412 | | * fu_struct_ccgx_dmc_fwct_image_info_set_comp_id: (skip): |
1413 | | **/ |
1414 | | void |
1415 | | fu_struct_ccgx_dmc_fwct_image_info_set_comp_id(FuStructCcgxDmcFwctImageInfo *st, guint8 value) |
1416 | 0 | { |
1417 | 0 | g_return_if_fail(st != NULL); |
1418 | 0 | st->buf->data[2] = value; |
1419 | 0 | } |
1420 | | /** |
1421 | | * fu_struct_ccgx_dmc_fwct_image_info_set_row_size: (skip): |
1422 | | **/ |
1423 | | void |
1424 | | fu_struct_ccgx_dmc_fwct_image_info_set_row_size(FuStructCcgxDmcFwctImageInfo *st, guint8 value) |
1425 | 0 | { |
1426 | 0 | g_return_if_fail(st != NULL); |
1427 | 0 | st->buf->data[3] = value; |
1428 | 0 | } |
1429 | | /** |
1430 | | * fu_struct_ccgx_dmc_fwct_image_info_set_fw_version: (skip): |
1431 | | **/ |
1432 | | void |
1433 | | fu_struct_ccgx_dmc_fwct_image_info_set_fw_version(FuStructCcgxDmcFwctImageInfo *st, guint32 value) |
1434 | 0 | { |
1435 | 0 | g_return_if_fail(st != NULL); |
1436 | 0 | fu_memwrite_uint32(st->buf->data + 8, value, G_LITTLE_ENDIAN); |
1437 | 0 | } |
1438 | | /** |
1439 | | * fu_struct_ccgx_dmc_fwct_image_info_set_app_version: (skip): |
1440 | | **/ |
1441 | | void |
1442 | | fu_struct_ccgx_dmc_fwct_image_info_set_app_version(FuStructCcgxDmcFwctImageInfo *st, guint32 value) |
1443 | 0 | { |
1444 | 0 | g_return_if_fail(st != NULL); |
1445 | 0 | fu_memwrite_uint32(st->buf->data + 12, value, G_LITTLE_ENDIAN); |
1446 | 0 | } |
1447 | | /** |
1448 | | * fu_struct_ccgx_dmc_fwct_image_info_set_img_offset: (skip): |
1449 | | **/ |
1450 | | void |
1451 | | fu_struct_ccgx_dmc_fwct_image_info_set_img_offset(FuStructCcgxDmcFwctImageInfo *st, guint32 value) |
1452 | 0 | { |
1453 | 0 | g_return_if_fail(st != NULL); |
1454 | 0 | fu_memwrite_uint32(st->buf->data + 16, value, G_LITTLE_ENDIAN); |
1455 | 0 | } |
1456 | | /** |
1457 | | * fu_struct_ccgx_dmc_fwct_image_info_set_img_size: (skip): |
1458 | | **/ |
1459 | | void |
1460 | | fu_struct_ccgx_dmc_fwct_image_info_set_img_size(FuStructCcgxDmcFwctImageInfo *st, guint32 value) |
1461 | 0 | { |
1462 | 0 | g_return_if_fail(st != NULL); |
1463 | 0 | fu_memwrite_uint32(st->buf->data + 20, value, G_LITTLE_ENDIAN); |
1464 | 0 | } |
1465 | | /** |
1466 | | * fu_struct_ccgx_dmc_fwct_image_info_set_img_digest: (skip): |
1467 | | **/ |
1468 | | gboolean |
1469 | | fu_struct_ccgx_dmc_fwct_image_info_set_img_digest(FuStructCcgxDmcFwctImageInfo *st, const guint8 *buf, gsize bufsz, GError **error) |
1470 | 0 | { |
1471 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
1472 | 0 | g_return_val_if_fail(buf != NULL, FALSE); |
1473 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
1474 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 24, buf, bufsz, 0x0, bufsz, error); |
1475 | 0 | } |
1476 | | /** |
1477 | | * fu_struct_ccgx_dmc_fwct_image_info_set_num_img_segments: (skip): |
1478 | | **/ |
1479 | | void |
1480 | | fu_struct_ccgx_dmc_fwct_image_info_set_num_img_segments(FuStructCcgxDmcFwctImageInfo *st, guint8 value) |
1481 | 0 | { |
1482 | 0 | g_return_if_fail(st != NULL); |
1483 | 0 | st->buf->data[56] = value; |
1484 | 0 | } |
1485 | | /** |
1486 | | * fu_struct_ccgx_dmc_fwct_image_info_new: (skip): |
1487 | | **/ |
1488 | | FuStructCcgxDmcFwctImageInfo * |
1489 | | fu_struct_ccgx_dmc_fwct_image_info_new(void) |
1490 | 0 | { |
1491 | 0 | FuStructCcgxDmcFwctImageInfo *st = fu_struct_ccgx_dmc_fwct_image_info_new_internal(); |
1492 | 0 | st->buf = g_byte_array_sized_new(60); |
1493 | 0 | fu_byte_array_set_size(st->buf, 60, 0x0); |
1494 | 0 | return st; |
1495 | 0 | } |
1496 | | /** |
1497 | | * fu_struct_ccgx_dmc_fwct_image_info_to_string: (skip): |
1498 | | **/ |
1499 | | static gchar * |
1500 | | fu_struct_ccgx_dmc_fwct_image_info_to_string(const FuStructCcgxDmcFwctImageInfo *st) |
1501 | 0 | { |
1502 | 0 | g_autoptr(GString) str = g_string_new("FuStructCcgxDmcFwctImageInfo:\n"); |
1503 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1504 | 0 | g_string_append_printf(str, " device_type: 0x%x\n", |
1505 | 0 | (guint) fu_struct_ccgx_dmc_fwct_image_info_get_device_type(st)); |
1506 | 0 | g_string_append_printf(str, " img_type: 0x%x\n", |
1507 | 0 | (guint) fu_struct_ccgx_dmc_fwct_image_info_get_img_type(st)); |
1508 | 0 | g_string_append_printf(str, " comp_id: 0x%x\n", |
1509 | 0 | (guint) fu_struct_ccgx_dmc_fwct_image_info_get_comp_id(st)); |
1510 | 0 | g_string_append_printf(str, " row_size: 0x%x\n", |
1511 | 0 | (guint) fu_struct_ccgx_dmc_fwct_image_info_get_row_size(st)); |
1512 | 0 | g_string_append_printf(str, " fw_version: 0x%x\n", |
1513 | 0 | (guint) fu_struct_ccgx_dmc_fwct_image_info_get_fw_version(st)); |
1514 | 0 | g_string_append_printf(str, " app_version: 0x%x\n", |
1515 | 0 | (guint) fu_struct_ccgx_dmc_fwct_image_info_get_app_version(st)); |
1516 | 0 | g_string_append_printf(str, " img_offset: 0x%x\n", |
1517 | 0 | (guint) fu_struct_ccgx_dmc_fwct_image_info_get_img_offset(st)); |
1518 | 0 | g_string_append_printf(str, " img_size: 0x%x\n", |
1519 | 0 | (guint) fu_struct_ccgx_dmc_fwct_image_info_get_img_size(st)); |
1520 | 0 | { |
1521 | 0 | gsize bufsz = 0; |
1522 | 0 | const guint8 *buf = fu_struct_ccgx_dmc_fwct_image_info_get_img_digest(st, &bufsz); |
1523 | 0 | g_autoptr(GString) tmp = g_string_new(NULL); |
1524 | 0 | for (gsize i = 0; i < bufsz; i++) |
1525 | 0 | g_string_append_printf(tmp, "%02X", buf[i]); |
1526 | 0 | g_string_append_printf(str, " img_digest: 0x%s\n", tmp->str); |
1527 | 0 | } |
1528 | 0 | g_string_append_printf(str, " num_img_segments: 0x%x\n", |
1529 | 0 | (guint) fu_struct_ccgx_dmc_fwct_image_info_get_num_img_segments(st)); |
1530 | 0 | if (str->len > 0) |
1531 | 0 | g_string_set_size(str, str->len - 1); |
1532 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1533 | 0 | } |
1534 | | static gboolean |
1535 | | fu_struct_ccgx_dmc_fwct_image_info_validate_internal(FuStructCcgxDmcFwctImageInfo *st, GError **error) |
1536 | 2.38k | { |
1537 | 2.38k | g_return_val_if_fail(st != NULL, FALSE); |
1538 | 2.38k | return TRUE; |
1539 | 2.38k | } |
1540 | | static gboolean |
1541 | | fu_struct_ccgx_dmc_fwct_image_info_parse_internal(FuStructCcgxDmcFwctImageInfo *st, GError **error) |
1542 | 2.38k | { |
1543 | 2.38k | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
1544 | 0 | g_autofree gchar *str = fu_struct_ccgx_dmc_fwct_image_info_to_string(st); |
1545 | 0 | g_debug("%s", str); |
1546 | 0 | } |
1547 | 2.38k | if (!fu_struct_ccgx_dmc_fwct_image_info_validate_internal(st, error)) |
1548 | 0 | return FALSE; |
1549 | 2.38k | return TRUE; |
1550 | 2.38k | } |
1551 | | /** |
1552 | | * fu_struct_ccgx_dmc_fwct_image_info_parse_stream: (skip): |
1553 | | **/ |
1554 | | FuStructCcgxDmcFwctImageInfo * |
1555 | | fu_struct_ccgx_dmc_fwct_image_info_parse_stream(GInputStream *stream, gsize offset, GError **error) |
1556 | 2.52k | { |
1557 | 2.52k | g_autoptr(FuStructCcgxDmcFwctImageInfo) st = fu_struct_ccgx_dmc_fwct_image_info_new_internal(); |
1558 | 2.52k | st->buf = fu_input_stream_read_byte_array(stream, offset, 60, NULL, error); |
1559 | 2.52k | if (st->buf == NULL) { |
1560 | 96 | g_prefix_error(error, "FuStructCcgxDmcFwctImageInfo failed read of 0x%x: ", (guint) 60); |
1561 | 96 | return NULL; |
1562 | 96 | } |
1563 | 2.42k | if (st->buf->len != 60) { |
1564 | 47 | g_set_error(error, |
1565 | 47 | FWUPD_ERROR, |
1566 | 47 | FWUPD_ERROR_INVALID_DATA, |
1567 | 47 | "FuStructCcgxDmcFwctImageInfo requested 0x%x and got 0x%x", |
1568 | 47 | (guint) 60, |
1569 | 47 | (guint) st->buf->len); |
1570 | 47 | return NULL; |
1571 | 47 | } |
1572 | 2.38k | if (!fu_struct_ccgx_dmc_fwct_image_info_parse_internal(st, error)) |
1573 | 0 | return NULL; |
1574 | 2.38k | return g_steal_pointer(&st); |
1575 | 2.38k | } |
1576 | | /** |
1577 | | * fu_struct_ccgx_dmc_fwct_segmentation_info_ref: (skip): |
1578 | | **/ |
1579 | | FuStructCcgxDmcFwctSegmentationInfo * |
1580 | | fu_struct_ccgx_dmc_fwct_segmentation_info_ref(FuStructCcgxDmcFwctSegmentationInfo *st) |
1581 | 0 | { |
1582 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1583 | 0 | st->refcount++; |
1584 | 0 | return st; |
1585 | 0 | } |
1586 | | /** |
1587 | | * fu_struct_ccgx_dmc_fwct_segmentation_info_unref: (skip): |
1588 | | **/ |
1589 | | void |
1590 | | fu_struct_ccgx_dmc_fwct_segmentation_info_unref(FuStructCcgxDmcFwctSegmentationInfo *st) |
1591 | 23.7k | { |
1592 | 23.7k | g_return_if_fail(st != NULL); |
1593 | 23.7k | if (st->refcount == 0) { |
1594 | 0 | g_critical("FuStructCcgxDmcFwctSegmentationInfo refcount already zero"); |
1595 | 0 | return; |
1596 | 0 | } |
1597 | 23.7k | if (--st->refcount > 0) |
1598 | 0 | return; |
1599 | 23.7k | if (st->buf != NULL) |
1600 | 23.5k | g_byte_array_unref(st->buf); |
1601 | 23.7k | g_free(st); |
1602 | 23.7k | } |
1603 | | /** |
1604 | | * fu_struct_ccgx_dmc_fwct_segmentation_info_new_internal: (skip): |
1605 | | **/ |
1606 | | static FuStructCcgxDmcFwctSegmentationInfo * |
1607 | | fu_struct_ccgx_dmc_fwct_segmentation_info_new_internal(void) |
1608 | 23.7k | { |
1609 | 23.7k | FuStructCcgxDmcFwctSegmentationInfo *st = g_new0(FuStructCcgxDmcFwctSegmentationInfo, 1); |
1610 | 23.7k | st->refcount = 1; |
1611 | 23.7k | return st; |
1612 | 23.7k | } |
1613 | | |
1614 | | /* getters */ |
1615 | | /** |
1616 | | * fu_struct_ccgx_dmc_fwct_segmentation_info_get_img_id: (skip): |
1617 | | **/ |
1618 | | guint8 |
1619 | | fu_struct_ccgx_dmc_fwct_segmentation_info_get_img_id(const FuStructCcgxDmcFwctSegmentationInfo *st) |
1620 | 0 | { |
1621 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1622 | 0 | return st->buf->data[0]; |
1623 | 0 | } |
1624 | | /** |
1625 | | * fu_struct_ccgx_dmc_fwct_segmentation_info_get_type: (skip): |
1626 | | **/ |
1627 | | guint8 |
1628 | | fu_struct_ccgx_dmc_fwct_segmentation_info_get_type(const FuStructCcgxDmcFwctSegmentationInfo *st) |
1629 | 0 | { |
1630 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1631 | 0 | return st->buf->data[1]; |
1632 | 0 | } |
1633 | | /** |
1634 | | * fu_struct_ccgx_dmc_fwct_segmentation_info_get_start_row: (skip): |
1635 | | **/ |
1636 | | guint16 |
1637 | | fu_struct_ccgx_dmc_fwct_segmentation_info_get_start_row(const FuStructCcgxDmcFwctSegmentationInfo *st) |
1638 | 23.5k | { |
1639 | 23.5k | g_return_val_if_fail(st != NULL, 0x0); |
1640 | 23.5k | return fu_memread_uint16(st->buf->data + 2, G_LITTLE_ENDIAN); |
1641 | 23.5k | } |
1642 | | /** |
1643 | | * fu_struct_ccgx_dmc_fwct_segmentation_info_get_num_rows: (skip): |
1644 | | **/ |
1645 | | guint16 |
1646 | | fu_struct_ccgx_dmc_fwct_segmentation_info_get_num_rows(const FuStructCcgxDmcFwctSegmentationInfo *st) |
1647 | 23.5k | { |
1648 | 23.5k | g_return_val_if_fail(st != NULL, 0x0); |
1649 | 23.5k | return fu_memread_uint16(st->buf->data + 4, G_LITTLE_ENDIAN); |
1650 | 23.5k | } |
1651 | | |
1652 | | /* setters */ |
1653 | | /** |
1654 | | * fu_struct_ccgx_dmc_fwct_segmentation_info_set_img_id: (skip): |
1655 | | **/ |
1656 | | void |
1657 | | fu_struct_ccgx_dmc_fwct_segmentation_info_set_img_id(FuStructCcgxDmcFwctSegmentationInfo *st, guint8 value) |
1658 | 0 | { |
1659 | 0 | g_return_if_fail(st != NULL); |
1660 | 0 | st->buf->data[0] = value; |
1661 | 0 | } |
1662 | | /** |
1663 | | * fu_struct_ccgx_dmc_fwct_segmentation_info_set_type: (skip): |
1664 | | **/ |
1665 | | void |
1666 | | fu_struct_ccgx_dmc_fwct_segmentation_info_set_type(FuStructCcgxDmcFwctSegmentationInfo *st, guint8 value) |
1667 | 0 | { |
1668 | 0 | g_return_if_fail(st != NULL); |
1669 | 0 | st->buf->data[1] = value; |
1670 | 0 | } |
1671 | | /** |
1672 | | * fu_struct_ccgx_dmc_fwct_segmentation_info_set_start_row: (skip): |
1673 | | **/ |
1674 | | void |
1675 | | fu_struct_ccgx_dmc_fwct_segmentation_info_set_start_row(FuStructCcgxDmcFwctSegmentationInfo *st, guint16 value) |
1676 | 0 | { |
1677 | 0 | g_return_if_fail(st != NULL); |
1678 | 0 | fu_memwrite_uint16(st->buf->data + 2, value, G_LITTLE_ENDIAN); |
1679 | 0 | } |
1680 | | /** |
1681 | | * fu_struct_ccgx_dmc_fwct_segmentation_info_set_num_rows: (skip): |
1682 | | **/ |
1683 | | void |
1684 | | fu_struct_ccgx_dmc_fwct_segmentation_info_set_num_rows(FuStructCcgxDmcFwctSegmentationInfo *st, guint16 value) |
1685 | 0 | { |
1686 | 0 | g_return_if_fail(st != NULL); |
1687 | 0 | fu_memwrite_uint16(st->buf->data + 4, value, G_LITTLE_ENDIAN); |
1688 | 0 | } |
1689 | | /** |
1690 | | * fu_struct_ccgx_dmc_fwct_segmentation_info_new: (skip): |
1691 | | **/ |
1692 | | FuStructCcgxDmcFwctSegmentationInfo * |
1693 | | fu_struct_ccgx_dmc_fwct_segmentation_info_new(void) |
1694 | 0 | { |
1695 | 0 | FuStructCcgxDmcFwctSegmentationInfo *st = fu_struct_ccgx_dmc_fwct_segmentation_info_new_internal(); |
1696 | 0 | st->buf = g_byte_array_sized_new(8); |
1697 | 0 | fu_byte_array_set_size(st->buf, 8, 0x0); |
1698 | 0 | return st; |
1699 | 0 | } |
1700 | | /** |
1701 | | * fu_struct_ccgx_dmc_fwct_segmentation_info_to_string: (skip): |
1702 | | **/ |
1703 | | static gchar * |
1704 | | fu_struct_ccgx_dmc_fwct_segmentation_info_to_string(const FuStructCcgxDmcFwctSegmentationInfo *st) |
1705 | 0 | { |
1706 | 0 | g_autoptr(GString) str = g_string_new("FuStructCcgxDmcFwctSegmentationInfo:\n"); |
1707 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1708 | 0 | g_string_append_printf(str, " img_id: 0x%x\n", |
1709 | 0 | (guint) fu_struct_ccgx_dmc_fwct_segmentation_info_get_img_id(st)); |
1710 | 0 | g_string_append_printf(str, " type: 0x%x\n", |
1711 | 0 | (guint) fu_struct_ccgx_dmc_fwct_segmentation_info_get_type(st)); |
1712 | 0 | g_string_append_printf(str, " start_row: 0x%x\n", |
1713 | 0 | (guint) fu_struct_ccgx_dmc_fwct_segmentation_info_get_start_row(st)); |
1714 | 0 | g_string_append_printf(str, " num_rows: 0x%x\n", |
1715 | 0 | (guint) fu_struct_ccgx_dmc_fwct_segmentation_info_get_num_rows(st)); |
1716 | 0 | if (str->len > 0) |
1717 | 0 | g_string_set_size(str, str->len - 1); |
1718 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1719 | 0 | } |
1720 | | static gboolean |
1721 | | fu_struct_ccgx_dmc_fwct_segmentation_info_validate_internal(FuStructCcgxDmcFwctSegmentationInfo *st, GError **error) |
1722 | 23.5k | { |
1723 | 23.5k | g_return_val_if_fail(st != NULL, FALSE); |
1724 | 23.5k | return TRUE; |
1725 | 23.5k | } |
1726 | | static gboolean |
1727 | | fu_struct_ccgx_dmc_fwct_segmentation_info_parse_internal(FuStructCcgxDmcFwctSegmentationInfo *st, GError **error) |
1728 | 23.5k | { |
1729 | 23.5k | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
1730 | 0 | g_autofree gchar *str = fu_struct_ccgx_dmc_fwct_segmentation_info_to_string(st); |
1731 | 0 | g_debug("%s", str); |
1732 | 0 | } |
1733 | 23.5k | if (!fu_struct_ccgx_dmc_fwct_segmentation_info_validate_internal(st, error)) |
1734 | 0 | return FALSE; |
1735 | 23.5k | return TRUE; |
1736 | 23.5k | } |
1737 | | /** |
1738 | | * fu_struct_ccgx_dmc_fwct_segmentation_info_parse_stream: (skip): |
1739 | | **/ |
1740 | | FuStructCcgxDmcFwctSegmentationInfo * |
1741 | | fu_struct_ccgx_dmc_fwct_segmentation_info_parse_stream(GInputStream *stream, gsize offset, GError **error) |
1742 | 23.7k | { |
1743 | 23.7k | g_autoptr(FuStructCcgxDmcFwctSegmentationInfo) st = fu_struct_ccgx_dmc_fwct_segmentation_info_new_internal(); |
1744 | 23.7k | st->buf = fu_input_stream_read_byte_array(stream, offset, 8, NULL, error); |
1745 | 23.7k | if (st->buf == NULL) { |
1746 | 126 | g_prefix_error(error, "FuStructCcgxDmcFwctSegmentationInfo failed read of 0x%x: ", (guint) 8); |
1747 | 126 | return NULL; |
1748 | 126 | } |
1749 | 23.5k | if (st->buf->len != 8) { |
1750 | 34 | g_set_error(error, |
1751 | 34 | FWUPD_ERROR, |
1752 | 34 | FWUPD_ERROR_INVALID_DATA, |
1753 | 34 | "FuStructCcgxDmcFwctSegmentationInfo requested 0x%x and got 0x%x", |
1754 | 34 | (guint) 8, |
1755 | 34 | (guint) st->buf->len); |
1756 | 34 | return NULL; |
1757 | 34 | } |
1758 | 23.5k | if (!fu_struct_ccgx_dmc_fwct_segmentation_info_parse_internal(st, error)) |
1759 | 0 | return NULL; |
1760 | 23.5k | return g_steal_pointer(&st); |
1761 | 23.5k | } |