/work/fu-cros-ec-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-cros-ec-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 | | /** |
24 | | * fu_struct_cros_ec_update_frame_header_ref: (skip): |
25 | | **/ |
26 | | FuStructCrosEcUpdateFrameHeader * |
27 | | fu_struct_cros_ec_update_frame_header_ref(FuStructCrosEcUpdateFrameHeader *st) |
28 | 0 | { |
29 | 0 | g_return_val_if_fail(st != NULL, NULL); |
30 | 0 | st->refcount++; |
31 | 0 | return st; |
32 | 0 | } |
33 | | /** |
34 | | * fu_struct_cros_ec_update_frame_header_unref: (skip): |
35 | | **/ |
36 | | void |
37 | | fu_struct_cros_ec_update_frame_header_unref(FuStructCrosEcUpdateFrameHeader *st) |
38 | 0 | { |
39 | 0 | g_return_if_fail(st != NULL); |
40 | 0 | if (st->refcount == 0) { |
41 | 0 | g_critical("FuStructCrosEcUpdateFrameHeader refcount already zero"); |
42 | 0 | return; |
43 | 0 | } |
44 | 0 | if (--st->refcount > 0) |
45 | 0 | return; |
46 | 0 | if (st->buf != NULL) |
47 | 0 | g_byte_array_unref(st->buf); |
48 | 0 | g_free(st); |
49 | 0 | } |
50 | | /** |
51 | | * fu_struct_cros_ec_update_frame_header_new_internal: (skip): |
52 | | **/ |
53 | | static FuStructCrosEcUpdateFrameHeader * |
54 | | fu_struct_cros_ec_update_frame_header_new_internal(void) |
55 | 0 | { |
56 | 0 | FuStructCrosEcUpdateFrameHeader *st = g_new0(FuStructCrosEcUpdateFrameHeader, 1); |
57 | 0 | st->refcount = 1; |
58 | 0 | return st; |
59 | 0 | } |
60 | | |
61 | | /* getters */ |
62 | | |
63 | | /* setters */ |
64 | | /** |
65 | | * fu_struct_cros_ec_update_frame_header_set_block_size: (skip): |
66 | | **/ |
67 | | void |
68 | | fu_struct_cros_ec_update_frame_header_set_block_size(FuStructCrosEcUpdateFrameHeader *st, guint32 value) |
69 | 0 | { |
70 | 0 | g_return_if_fail(st != NULL); |
71 | 0 | fu_memwrite_uint32(st->buf->data + 0, value, G_BIG_ENDIAN); |
72 | 0 | } |
73 | | /** |
74 | | * fu_struct_cros_ec_update_frame_header_set_cmd_block_digest: (skip): |
75 | | **/ |
76 | | void |
77 | | fu_struct_cros_ec_update_frame_header_set_cmd_block_digest(FuStructCrosEcUpdateFrameHeader *st, guint32 value) |
78 | 0 | { |
79 | 0 | g_return_if_fail(st != NULL); |
80 | 0 | fu_memwrite_uint32(st->buf->data + 4, value, G_BIG_ENDIAN); |
81 | 0 | } |
82 | | /** |
83 | | * fu_struct_cros_ec_update_frame_header_set_cmd_block_base: (skip): |
84 | | **/ |
85 | | void |
86 | | fu_struct_cros_ec_update_frame_header_set_cmd_block_base(FuStructCrosEcUpdateFrameHeader *st, guint32 value) |
87 | 0 | { |
88 | 0 | g_return_if_fail(st != NULL); |
89 | 0 | fu_memwrite_uint32(st->buf->data + 8, value, G_BIG_ENDIAN); |
90 | 0 | } |
91 | | /** |
92 | | * fu_struct_cros_ec_update_frame_header_new: (skip): |
93 | | **/ |
94 | | FuStructCrosEcUpdateFrameHeader * |
95 | | fu_struct_cros_ec_update_frame_header_new(void) |
96 | 0 | { |
97 | 0 | FuStructCrosEcUpdateFrameHeader *st = fu_struct_cros_ec_update_frame_header_new_internal(); |
98 | 0 | st->buf = g_byte_array_sized_new(12); |
99 | 0 | fu_byte_array_set_size(st->buf, 12, 0x0); |
100 | 0 | return st; |
101 | 0 | } |
102 | | /** |
103 | | * fu_struct_cros_ec_update_done_ref: (skip): |
104 | | **/ |
105 | | FuStructCrosEcUpdateDone * |
106 | | fu_struct_cros_ec_update_done_ref(FuStructCrosEcUpdateDone *st) |
107 | 0 | { |
108 | 0 | g_return_val_if_fail(st != NULL, NULL); |
109 | 0 | st->refcount++; |
110 | 0 | return st; |
111 | 0 | } |
112 | | /** |
113 | | * fu_struct_cros_ec_update_done_unref: (skip): |
114 | | **/ |
115 | | void |
116 | | fu_struct_cros_ec_update_done_unref(FuStructCrosEcUpdateDone *st) |
117 | 0 | { |
118 | 0 | g_return_if_fail(st != NULL); |
119 | 0 | if (st->refcount == 0) { |
120 | 0 | g_critical("FuStructCrosEcUpdateDone refcount already zero"); |
121 | 0 | return; |
122 | 0 | } |
123 | 0 | if (--st->refcount > 0) |
124 | 0 | return; |
125 | 0 | if (st->buf != NULL) |
126 | 0 | g_byte_array_unref(st->buf); |
127 | 0 | g_free(st); |
128 | 0 | } |
129 | | /** |
130 | | * fu_struct_cros_ec_update_done_new_internal: (skip): |
131 | | **/ |
132 | | static FuStructCrosEcUpdateDone * |
133 | | fu_struct_cros_ec_update_done_new_internal(void) |
134 | 0 | { |
135 | 0 | FuStructCrosEcUpdateDone *st = g_new0(FuStructCrosEcUpdateDone, 1); |
136 | 0 | st->refcount = 1; |
137 | 0 | return st; |
138 | 0 | } |
139 | | |
140 | | /* getters */ |
141 | | |
142 | | /* setters */ |
143 | | /** |
144 | | * fu_struct_cros_ec_update_done_set_value: (skip): |
145 | | **/ |
146 | | static void |
147 | | fu_struct_cros_ec_update_done_set_value(FuStructCrosEcUpdateDone *st, guint32 value) |
148 | 0 | { |
149 | 0 | g_return_if_fail(st != NULL); |
150 | 0 | fu_memwrite_uint32(st->buf->data + 0, value, G_BIG_ENDIAN); |
151 | 0 | } |
152 | | /** |
153 | | * fu_struct_cros_ec_update_done_new: (skip): |
154 | | **/ |
155 | | FuStructCrosEcUpdateDone * |
156 | | fu_struct_cros_ec_update_done_new(void) |
157 | 0 | { |
158 | 0 | FuStructCrosEcUpdateDone *st = fu_struct_cros_ec_update_done_new_internal(); |
159 | 0 | st->buf = g_byte_array_sized_new(4); |
160 | 0 | fu_byte_array_set_size(st->buf, 4, 0x0); |
161 | 0 | fu_struct_cros_ec_update_done_set_value(st, 0xB007AB1E); |
162 | 0 | return st; |
163 | 0 | } |
164 | | /** |
165 | | * fu_struct_cros_ec_signed_header_version_ref: (skip): |
166 | | **/ |
167 | | FuStructCrosEcSignedHeaderVersion * |
168 | | fu_struct_cros_ec_signed_header_version_ref(FuStructCrosEcSignedHeaderVersion *st) |
169 | 0 | { |
170 | 0 | g_return_val_if_fail(st != NULL, NULL); |
171 | 0 | st->refcount++; |
172 | 0 | return st; |
173 | 0 | } |
174 | | /** |
175 | | * fu_struct_cros_ec_signed_header_version_unref: (skip): |
176 | | **/ |
177 | | void |
178 | | fu_struct_cros_ec_signed_header_version_unref(FuStructCrosEcSignedHeaderVersion *st) |
179 | 0 | { |
180 | 0 | g_return_if_fail(st != NULL); |
181 | 0 | if (st->refcount == 0) { |
182 | 0 | g_critical("FuStructCrosEcSignedHeaderVersion refcount already zero"); |
183 | 0 | return; |
184 | 0 | } |
185 | 0 | if (--st->refcount > 0) |
186 | 0 | return; |
187 | 0 | if (st->buf != NULL) |
188 | 0 | g_byte_array_unref(st->buf); |
189 | 0 | g_free(st); |
190 | 0 | } |
191 | | |
192 | | /* getters */ |
193 | | |
194 | | /* setters */ |
195 | | /** |
196 | | * fu_struct_cros_ec_first_response_pdu_ref: (skip): |
197 | | **/ |
198 | | FuStructCrosEcFirstResponsePdu * |
199 | | fu_struct_cros_ec_first_response_pdu_ref(FuStructCrosEcFirstResponsePdu *st) |
200 | 0 | { |
201 | 0 | g_return_val_if_fail(st != NULL, NULL); |
202 | 0 | st->refcount++; |
203 | 0 | return st; |
204 | 0 | } |
205 | | /** |
206 | | * fu_struct_cros_ec_first_response_pdu_unref: (skip): |
207 | | **/ |
208 | | void |
209 | | fu_struct_cros_ec_first_response_pdu_unref(FuStructCrosEcFirstResponsePdu *st) |
210 | 0 | { |
211 | 0 | g_return_if_fail(st != NULL); |
212 | 0 | if (st->refcount == 0) { |
213 | 0 | g_critical("FuStructCrosEcFirstResponsePdu refcount already zero"); |
214 | 0 | return; |
215 | 0 | } |
216 | 0 | if (--st->refcount > 0) |
217 | 0 | return; |
218 | 0 | if (st->buf != NULL) |
219 | 0 | g_byte_array_unref(st->buf); |
220 | 0 | g_free(st); |
221 | 0 | } |
222 | | /** |
223 | | * fu_struct_cros_ec_first_response_pdu_new_internal: (skip): |
224 | | **/ |
225 | | static FuStructCrosEcFirstResponsePdu * |
226 | | fu_struct_cros_ec_first_response_pdu_new_internal(void) |
227 | 0 | { |
228 | 0 | FuStructCrosEcFirstResponsePdu *st = g_new0(FuStructCrosEcFirstResponsePdu, 1); |
229 | 0 | st->refcount = 1; |
230 | 0 | return st; |
231 | 0 | } |
232 | | |
233 | | /* getters */ |
234 | | /** |
235 | | * fu_struct_cros_ec_first_response_pdu_get_return_value: (skip): |
236 | | **/ |
237 | | guint32 |
238 | | fu_struct_cros_ec_first_response_pdu_get_return_value(const FuStructCrosEcFirstResponsePdu *st) |
239 | 0 | { |
240 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
241 | 0 | return fu_memread_uint32(st->buf->data + 0, G_BIG_ENDIAN); |
242 | 0 | } |
243 | | /** |
244 | | * fu_struct_cros_ec_first_response_pdu_get_header_type: (skip): |
245 | | **/ |
246 | | FuStructCrosEcFirstResponsePduHeaderType |
247 | | fu_struct_cros_ec_first_response_pdu_get_header_type(const FuStructCrosEcFirstResponsePdu *st) |
248 | 0 | { |
249 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
250 | 0 | return fu_memread_uint16(st->buf->data + 4, G_BIG_ENDIAN); |
251 | 0 | } |
252 | | /** |
253 | | * fu_struct_cros_ec_first_response_pdu_get_protocol_version: (skip): |
254 | | **/ |
255 | | guint16 |
256 | | fu_struct_cros_ec_first_response_pdu_get_protocol_version(const FuStructCrosEcFirstResponsePdu *st) |
257 | 0 | { |
258 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
259 | 0 | return fu_memread_uint16(st->buf->data + 6, G_BIG_ENDIAN); |
260 | 0 | } |
261 | | /** |
262 | | * fu_struct_cros_ec_first_response_pdu_get_maximum_pdu_size: (skip): |
263 | | **/ |
264 | | guint32 |
265 | | fu_struct_cros_ec_first_response_pdu_get_maximum_pdu_size(const FuStructCrosEcFirstResponsePdu *st) |
266 | 0 | { |
267 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
268 | 0 | return fu_memread_uint32(st->buf->data + 8, G_BIG_ENDIAN); |
269 | 0 | } |
270 | | /** |
271 | | * fu_struct_cros_ec_first_response_pdu_get_flash_protection: (skip): |
272 | | **/ |
273 | | guint32 |
274 | | fu_struct_cros_ec_first_response_pdu_get_flash_protection(const FuStructCrosEcFirstResponsePdu *st) |
275 | 0 | { |
276 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
277 | 0 | return fu_memread_uint32(st->buf->data + 12, G_BIG_ENDIAN); |
278 | 0 | } |
279 | | /** |
280 | | * fu_struct_cros_ec_first_response_pdu_get_offset: (skip): |
281 | | **/ |
282 | | guint32 |
283 | | fu_struct_cros_ec_first_response_pdu_get_offset(const FuStructCrosEcFirstResponsePdu *st) |
284 | 0 | { |
285 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
286 | 0 | return fu_memread_uint32(st->buf->data + 16, G_BIG_ENDIAN); |
287 | 0 | } |
288 | | /** |
289 | | * fu_struct_cros_ec_first_response_pdu_get_version: (skip): |
290 | | **/ |
291 | | gchar * |
292 | | fu_struct_cros_ec_first_response_pdu_get_version(const FuStructCrosEcFirstResponsePdu *st) |
293 | 0 | { |
294 | 0 | g_return_val_if_fail(st != NULL, NULL); |
295 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 20, 32, NULL); |
296 | 0 | } |
297 | | |
298 | | /* setters */ |
299 | | /** |
300 | | * fu_struct_cros_ec_first_response_pdu_set_return_value: (skip): |
301 | | **/ |
302 | | void |
303 | | fu_struct_cros_ec_first_response_pdu_set_return_value(FuStructCrosEcFirstResponsePdu *st, guint32 value) |
304 | 0 | { |
305 | 0 | g_return_if_fail(st != NULL); |
306 | 0 | fu_memwrite_uint32(st->buf->data + 0, value, G_BIG_ENDIAN); |
307 | 0 | } |
308 | | /** |
309 | | * fu_struct_cros_ec_first_response_pdu_set_header_type: (skip): |
310 | | **/ |
311 | | void |
312 | | fu_struct_cros_ec_first_response_pdu_set_header_type(FuStructCrosEcFirstResponsePdu *st, FuStructCrosEcFirstResponsePduHeaderType value) |
313 | 0 | { |
314 | 0 | g_return_if_fail(st != NULL); |
315 | 0 | fu_memwrite_uint16(st->buf->data + 4, value, G_BIG_ENDIAN); |
316 | 0 | } |
317 | | /** |
318 | | * fu_struct_cros_ec_first_response_pdu_set_protocol_version: (skip): |
319 | | **/ |
320 | | void |
321 | | fu_struct_cros_ec_first_response_pdu_set_protocol_version(FuStructCrosEcFirstResponsePdu *st, guint16 value) |
322 | 0 | { |
323 | 0 | g_return_if_fail(st != NULL); |
324 | 0 | fu_memwrite_uint16(st->buf->data + 6, value, G_BIG_ENDIAN); |
325 | 0 | } |
326 | | /** |
327 | | * fu_struct_cros_ec_first_response_pdu_set_maximum_pdu_size: (skip): |
328 | | **/ |
329 | | void |
330 | | fu_struct_cros_ec_first_response_pdu_set_maximum_pdu_size(FuStructCrosEcFirstResponsePdu *st, guint32 value) |
331 | 0 | { |
332 | 0 | g_return_if_fail(st != NULL); |
333 | 0 | fu_memwrite_uint32(st->buf->data + 8, value, G_BIG_ENDIAN); |
334 | 0 | } |
335 | | /** |
336 | | * fu_struct_cros_ec_first_response_pdu_set_flash_protection: (skip): |
337 | | **/ |
338 | | void |
339 | | fu_struct_cros_ec_first_response_pdu_set_flash_protection(FuStructCrosEcFirstResponsePdu *st, guint32 value) |
340 | 0 | { |
341 | 0 | g_return_if_fail(st != NULL); |
342 | 0 | fu_memwrite_uint32(st->buf->data + 12, value, G_BIG_ENDIAN); |
343 | 0 | } |
344 | | /** |
345 | | * fu_struct_cros_ec_first_response_pdu_set_offset: (skip): |
346 | | **/ |
347 | | void |
348 | | fu_struct_cros_ec_first_response_pdu_set_offset(FuStructCrosEcFirstResponsePdu *st, guint32 value) |
349 | 0 | { |
350 | 0 | g_return_if_fail(st != NULL); |
351 | 0 | fu_memwrite_uint32(st->buf->data + 16, value, G_BIG_ENDIAN); |
352 | 0 | } |
353 | | /** |
354 | | * fu_struct_cros_ec_first_response_pdu_set_version: (skip): |
355 | | **/ |
356 | | gboolean |
357 | | fu_struct_cros_ec_first_response_pdu_set_version(FuStructCrosEcFirstResponsePdu *st, const gchar *value, GError **error) |
358 | 0 | { |
359 | 0 | gsize len; |
360 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
361 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
362 | 0 | if (value == NULL) { |
363 | 0 | memset(st->buf->data + 20, 0x0, 32); |
364 | 0 | return TRUE; |
365 | 0 | } |
366 | 0 | len = strlen(value); |
367 | 0 | if (len > 32) { |
368 | 0 | g_set_error(error, |
369 | 0 | FWUPD_ERROR, |
370 | 0 | FWUPD_ERROR_INVALID_DATA, |
371 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructCrosEcFirstResponsePdu.version (0x%x bytes)", |
372 | 0 | value, (guint) len, (guint) 32); |
373 | 0 | return FALSE; |
374 | 0 | } |
375 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 20, (const guint8 *)value, len, 0x0, len, error); |
376 | 0 | } |
377 | | /** |
378 | | * fu_struct_cros_ec_first_response_pdu_new: (skip): |
379 | | **/ |
380 | | FuStructCrosEcFirstResponsePdu * |
381 | | fu_struct_cros_ec_first_response_pdu_new(void) |
382 | 0 | { |
383 | 0 | FuStructCrosEcFirstResponsePdu *st = fu_struct_cros_ec_first_response_pdu_new_internal(); |
384 | 0 | st->buf = g_byte_array_sized_new(60); |
385 | 0 | fu_byte_array_set_size(st->buf, 60, 0x0); |
386 | 0 | return st; |
387 | 0 | } |