/work/fu-intel-me-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-intel-me-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 | | * fu_intel_me_family_to_string: |
24 | | * @val: value, e.g. %FU_INTEL_ME_FAMILY_SPS |
25 | | * |
26 | | * Converts an enumerated value to a string. |
27 | | * |
28 | | * Returns: identifier string |
29 | | **/ |
30 | | const gchar * |
31 | | fu_intel_me_family_to_string(FuIntelMeFamily val) |
32 | 0 | { |
33 | 0 | if (val == FU_INTEL_ME_FAMILY_SPS) |
34 | 0 | return "sps"; |
35 | 0 | if (val == FU_INTEL_ME_FAMILY_TXE) |
36 | 0 | return "txe"; |
37 | 0 | if (val == FU_INTEL_ME_FAMILY_ME) |
38 | 0 | return "me"; |
39 | 0 | if (val == FU_INTEL_ME_FAMILY_CSME11) |
40 | 0 | return "csme11"; |
41 | 0 | if (val == FU_INTEL_ME_FAMILY_CSME16) |
42 | 0 | return "csme16"; |
43 | 0 | if (val == FU_INTEL_ME_FAMILY_CSME18) |
44 | 0 | return "csme18"; |
45 | 0 | return NULL; |
46 | 0 | } |
47 | | |
48 | | /** |
49 | | * fu_intel_me_issue_to_string: |
50 | | * @val: value, e.g. %FU_INTEL_ME_ISSUE_NOT_VULNERABLE |
51 | | * |
52 | | * Converts an enumerated value to a string. |
53 | | * |
54 | | * Returns: identifier string |
55 | | **/ |
56 | | const gchar * |
57 | | fu_intel_me_issue_to_string(FuIntelMeIssue val) |
58 | 0 | { |
59 | 0 | if (val == FU_INTEL_ME_ISSUE_NOT_VULNERABLE) |
60 | 0 | return "not-vulnerable"; |
61 | 0 | if (val == FU_INTEL_ME_ISSUE_VULNERABLE) |
62 | 0 | return "vulnerable"; |
63 | 0 | if (val == FU_INTEL_ME_ISSUE_PATCHED) |
64 | 0 | return "patched"; |
65 | 0 | return NULL; |
66 | 0 | } |
67 | | |
68 | | /** |
69 | | * fu_me_hfs_cws_to_string: |
70 | | * @val: value, e.g. %FU_ME_HFS_CWS_INITIALIZING |
71 | | * |
72 | | * Converts an enumerated value to a string. |
73 | | * |
74 | | * Returns: identifier string |
75 | | **/ |
76 | | const gchar * |
77 | | fu_me_hfs_cws_to_string(FuMeHfsCws val) |
78 | 0 | { |
79 | 0 | if (val == FU_ME_HFS_CWS_RESET) |
80 | 0 | return "reset"; |
81 | 0 | if (val == FU_ME_HFS_CWS_INITIALIZING) |
82 | 0 | return "initializing"; |
83 | 0 | if (val == FU_ME_HFS_CWS_RECOVERY) |
84 | 0 | return "recovery"; |
85 | 0 | if (val == FU_ME_HFS_CWS_TEST) |
86 | 0 | return "test"; |
87 | 0 | if (val == FU_ME_HFS_CWS_DISABLED) |
88 | 0 | return "disabled"; |
89 | 0 | if (val == FU_ME_HFS_CWS_NORMAL) |
90 | 0 | return "normal"; |
91 | 0 | if (val == FU_ME_HFS_CWS_WAIT) |
92 | 0 | return "wait"; |
93 | 0 | if (val == FU_ME_HFS_CWS_TRANSITION) |
94 | 0 | return "transition"; |
95 | 0 | if (val == FU_ME_HFS_CWS_INVALID_CPU) |
96 | 0 | return "invalid-cpu"; |
97 | 0 | if (val == FU_ME_HFS_CWS_HALT) |
98 | 0 | return "halt"; |
99 | 0 | return NULL; |
100 | 0 | } |
101 | | |
102 | | |
103 | | /** |
104 | | * fu_me_hfs_mode_to_string: |
105 | | * @val: value, e.g. %FU_ME_HFS_MODE___RESERVED |
106 | | * |
107 | | * Converts an enumerated value to a string. |
108 | | * |
109 | | * Returns: identifier string |
110 | | **/ |
111 | | static const gchar * |
112 | | fu_me_hfs_mode_to_string(FuMeHfsMode val) |
113 | 0 | { |
114 | 0 | if (val == FU_ME_HFS_MODE_NORMAL) |
115 | 0 | return "normal"; |
116 | 0 | if (val == FU_ME_HFS_MODE___RESERVED) |
117 | 0 | return "--reserved"; |
118 | 0 | if (val == FU_ME_HFS_MODE_DEBUG) |
119 | 0 | return "debug"; |
120 | 0 | if (val == FU_ME_HFS_MODE_DISABLE) |
121 | 0 | return "disable"; |
122 | 0 | if (val == FU_ME_HFS_MODE_OVERRIDE_JUMPER) |
123 | 0 | return "override-jumper"; |
124 | 0 | if (val == FU_ME_HFS_MODE_OVERRIDE_MEI) |
125 | 0 | return "override-mei"; |
126 | 0 | if (val == FU_ME_HFS_MODE_UNKNOWN6) |
127 | 0 | return "unknown6"; |
128 | 0 | if (val == FU_ME_HFS_MODE_ENHANCED_DEBUG) |
129 | 0 | return "enhanced-debug"; |
130 | 0 | return NULL; |
131 | 0 | } |
132 | | |
133 | | |
134 | | /** |
135 | | * fu_me_hfs_enforcement_policy_to_string: |
136 | | * @val: value, e.g. %FU_ME_HFS_ENFORCEMENT_POLICY_SHUTDOWN_TO |
137 | | * |
138 | | * Converts an enumerated value to a string. |
139 | | * |
140 | | * Returns: identifier string |
141 | | **/ |
142 | | static const gchar * |
143 | | fu_me_hfs_enforcement_policy_to_string(FuMeHfsEnforcementPolicy val) |
144 | 0 | { |
145 | 0 | if (val == FU_ME_HFS_ENFORCEMENT_POLICY_NOTHING) |
146 | 0 | return "nothing"; |
147 | 0 | if (val == FU_ME_HFS_ENFORCEMENT_POLICY_SHUTDOWN_TO) |
148 | 0 | return "shutdown-to"; |
149 | 0 | if (val == FU_ME_HFS_ENFORCEMENT_POLICY_SHUTDOWN_NOW) |
150 | 0 | return "shutdown-now"; |
151 | 0 | if (val == FU_ME_HFS_ENFORCEMENT_POLICY_SHUTDOWN_30MINS) |
152 | 0 | return "shutdown-30mins"; |
153 | 0 | return NULL; |
154 | 0 | } |
155 | | |
156 | | |
157 | | /** |
158 | | * fu_struct_intel_me_hfsts_ref: (skip): |
159 | | **/ |
160 | | FuStructIntelMeHfsts * |
161 | | fu_struct_intel_me_hfsts_ref(FuStructIntelMeHfsts *st) |
162 | 0 | { |
163 | 0 | g_return_val_if_fail(st != NULL, NULL); |
164 | 0 | st->refcount++; |
165 | 0 | return st; |
166 | 0 | } |
167 | | /** |
168 | | * fu_struct_intel_me_hfsts_unref: (skip): |
169 | | **/ |
170 | | void |
171 | | fu_struct_intel_me_hfsts_unref(FuStructIntelMeHfsts *st) |
172 | 0 | { |
173 | 0 | g_return_if_fail(st != NULL); |
174 | 0 | if (st->refcount == 0) { |
175 | 0 | g_critical("FuStructIntelMeHfsts refcount already zero"); |
176 | 0 | return; |
177 | 0 | } |
178 | 0 | if (--st->refcount > 0) |
179 | 0 | return; |
180 | 0 | if (st->buf != NULL) |
181 | 0 | g_byte_array_unref(st->buf); |
182 | 0 | g_free(st); |
183 | 0 | } |
184 | | /** |
185 | | * fu_struct_intel_me_hfsts_new_internal: (skip): |
186 | | **/ |
187 | | FuStructIntelMeHfsts * |
188 | | fu_struct_intel_me_hfsts_new_internal(void) |
189 | 0 | { |
190 | 0 | FuStructIntelMeHfsts *st = g_new0(FuStructIntelMeHfsts, 1); |
191 | 0 | st->refcount = 1; |
192 | 0 | return st; |
193 | 0 | } |
194 | | |
195 | | /* getters */ |
196 | | /** |
197 | | * fu_struct_intel_me_hfsts_get_value: (skip): |
198 | | **/ |
199 | | guint32 |
200 | | fu_struct_intel_me_hfsts_get_value(const FuStructIntelMeHfsts *st) |
201 | 0 | { |
202 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
203 | 0 | return fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
204 | 0 | } |
205 | | |
206 | | /* setters */ |
207 | | /** |
208 | | * fu_struct_intel_me_hfsts_set_value: (skip): |
209 | | **/ |
210 | | void |
211 | | fu_struct_intel_me_hfsts_set_value(FuStructIntelMeHfsts *st, guint32 value) |
212 | 0 | { |
213 | 0 | g_return_if_fail(st != NULL); |
214 | 0 | fu_memwrite_uint32(st->buf->data + 0, value, G_LITTLE_ENDIAN); |
215 | 0 | } |
216 | | /** |
217 | | * fu_struct_intel_me_hfsts_new: (skip): |
218 | | **/ |
219 | | FuStructIntelMeHfsts * |
220 | | fu_struct_intel_me_hfsts_new(void) |
221 | 0 | { |
222 | 0 | FuStructIntelMeHfsts *st = fu_struct_intel_me_hfsts_new_internal(); |
223 | 0 | st->buf = g_byte_array_sized_new(4); |
224 | 0 | fu_byte_array_set_size(st->buf, 4, 0x0); |
225 | 0 | return st; |
226 | 0 | } |
227 | | /** |
228 | | * fu_struct_intel_me_hfsts_to_string: (skip): |
229 | | **/ |
230 | | gchar * |
231 | | fu_struct_intel_me_hfsts_to_string(const FuStructIntelMeHfsts *st) |
232 | 0 | { |
233 | 0 | g_autoptr(GString) str = g_string_new("FuStructIntelMeHfsts:\n"); |
234 | 0 | g_return_val_if_fail(st != NULL, NULL); |
235 | 0 | g_string_append_printf(str, " value: 0x%x\n", |
236 | 0 | (guint) fu_struct_intel_me_hfsts_get_value(st)); |
237 | 0 | if (str->len > 0) |
238 | 0 | g_string_set_size(str, str->len - 1); |
239 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
240 | 0 | } |
241 | | static gboolean |
242 | | fu_struct_intel_me_hfsts_parse_internal(FuStructIntelMeHfsts *st, GError **error) |
243 | 0 | { |
244 | 0 | if (g_log_get_debug_enabled()) { |
245 | 0 | g_autofree gchar *str = fu_struct_intel_me_hfsts_to_string(st); |
246 | 0 | g_debug("%s", str); |
247 | 0 | } |
248 | 0 | return TRUE; |
249 | 0 | } |
250 | | |
251 | | /** |
252 | | * fu_struct_intel_me_hfsts_parse: (skip): |
253 | | **/ |
254 | | FuStructIntelMeHfsts * |
255 | | fu_struct_intel_me_hfsts_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
256 | 0 | { |
257 | 0 | g_autoptr(FuStructIntelMeHfsts) st = fu_struct_intel_me_hfsts_new_internal(); |
258 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
259 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
260 | 0 | if (!fu_memchk_read(bufsz, offset, 4, error)) { |
261 | 0 | g_prefix_error_literal(error, "invalid struct FuStructIntelMeHfsts: "); |
262 | 0 | return NULL; |
263 | 0 | } |
264 | 0 | st->buf = g_byte_array_new(); |
265 | 0 | g_byte_array_append(st->buf, buf + offset, 4); |
266 | 0 | if (!fu_struct_intel_me_hfsts_parse_internal(st, error)) |
267 | 0 | return NULL; |
268 | 0 | return g_steal_pointer(&st); |
269 | 0 | } |
270 | | /** |
271 | | * fu_mei_csme11_hfsts1_ref: (skip): |
272 | | **/ |
273 | | FuMeiCsme11Hfsts1 * |
274 | | fu_mei_csme11_hfsts1_ref(FuMeiCsme11Hfsts1 *st) |
275 | 0 | { |
276 | 0 | g_return_val_if_fail(st != NULL, NULL); |
277 | 0 | st->refcount++; |
278 | 0 | return st; |
279 | 0 | } |
280 | | /** |
281 | | * fu_mei_csme11_hfsts1_unref: (skip): |
282 | | **/ |
283 | | void |
284 | | fu_mei_csme11_hfsts1_unref(FuMeiCsme11Hfsts1 *st) |
285 | 0 | { |
286 | 0 | g_return_if_fail(st != NULL); |
287 | 0 | if (st->refcount == 0) { |
288 | 0 | g_critical("FuMeiCsme11Hfsts1 refcount already zero"); |
289 | 0 | return; |
290 | 0 | } |
291 | 0 | if (--st->refcount > 0) |
292 | 0 | return; |
293 | 0 | if (st->buf != NULL) |
294 | 0 | g_byte_array_unref(st->buf); |
295 | 0 | g_free(st); |
296 | 0 | } |
297 | | /** |
298 | | * fu_mei_csme11_hfsts1_new_internal: (skip): |
299 | | **/ |
300 | | static FuMeiCsme11Hfsts1 * |
301 | | fu_mei_csme11_hfsts1_new_internal(void) |
302 | 0 | { |
303 | 0 | FuMeiCsme11Hfsts1 *st = g_new0(FuMeiCsme11Hfsts1, 1); |
304 | 0 | st->refcount = 1; |
305 | 0 | return st; |
306 | 0 | } |
307 | | |
308 | | /* getters */ |
309 | | /** |
310 | | * fu_mei_csme11_hfsts1_get_working_state: (skip): |
311 | | **/ |
312 | | FuMeHfsCws |
313 | | fu_mei_csme11_hfsts1_get_working_state(const FuMeiCsme11Hfsts1 *st) |
314 | 0 | { |
315 | 0 | guint32 val; |
316 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
317 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(FuMeHfsCws), 0x0); |
318 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
319 | 0 | return (val >> 0) & 15; |
320 | 0 | } |
321 | | /** |
322 | | * fu_mei_csme11_hfsts1_get_mfg_mode: (skip): |
323 | | **/ |
324 | | guint32 |
325 | | fu_mei_csme11_hfsts1_get_mfg_mode(const FuMeiCsme11Hfsts1 *st) |
326 | 0 | { |
327 | 0 | guint32 val; |
328 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
329 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0); |
330 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
331 | 0 | return (val >> 4) & 1; |
332 | 0 | } |
333 | | /** |
334 | | * fu_mei_csme11_hfsts1_get_operation_mode: (skip): |
335 | | **/ |
336 | | FuMeHfsMode |
337 | | fu_mei_csme11_hfsts1_get_operation_mode(const FuMeiCsme11Hfsts1 *st) |
338 | 0 | { |
339 | 0 | guint32 val; |
340 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
341 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(FuMeHfsMode), 0x0); |
342 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
343 | 0 | return (val >> 16) & 15; |
344 | 0 | } |
345 | | |
346 | | /* setters */ |
347 | | /** |
348 | | * fu_mei_csme11_hfsts1_to_string: (skip): |
349 | | **/ |
350 | | gchar * |
351 | | fu_mei_csme11_hfsts1_to_string(const FuMeiCsme11Hfsts1 *st) |
352 | 0 | { |
353 | 0 | g_autoptr(GString) str = g_string_new("FuMeiCsme11Hfsts1:\n"); |
354 | 0 | g_return_val_if_fail(st != NULL, NULL); |
355 | 0 | { |
356 | 0 | const gchar *tmp = fu_me_hfs_cws_to_string(fu_mei_csme11_hfsts1_get_working_state(st)); |
357 | 0 | if (tmp != NULL) { |
358 | 0 | g_string_append_printf(str, " working_state: 0x%x [%s]\n", (guint) fu_mei_csme11_hfsts1_get_working_state(st), tmp); |
359 | 0 | } else { |
360 | 0 | g_string_append_printf(str, " working_state: 0x%x\n", (guint) fu_mei_csme11_hfsts1_get_working_state(st)); |
361 | 0 | } |
362 | 0 | } |
363 | 0 | g_string_append_printf(str, " mfg_mode: 0x%x\n", |
364 | 0 | (guint) fu_mei_csme11_hfsts1_get_mfg_mode(st)); |
365 | 0 | { |
366 | 0 | const gchar *tmp = fu_me_hfs_mode_to_string(fu_mei_csme11_hfsts1_get_operation_mode(st)); |
367 | 0 | if (tmp != NULL) { |
368 | 0 | g_string_append_printf(str, " operation_mode: 0x%x [%s]\n", (guint) fu_mei_csme11_hfsts1_get_operation_mode(st), tmp); |
369 | 0 | } else { |
370 | 0 | g_string_append_printf(str, " operation_mode: 0x%x\n", (guint) fu_mei_csme11_hfsts1_get_operation_mode(st)); |
371 | 0 | } |
372 | 0 | } |
373 | 0 | if (str->len > 0) |
374 | 0 | g_string_set_size(str, str->len - 1); |
375 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
376 | 0 | } |
377 | | static gboolean |
378 | | fu_mei_csme11_hfsts1_parse_internal(FuMeiCsme11Hfsts1 *st, GError **error) |
379 | 0 | { |
380 | 0 | if (g_log_get_debug_enabled()) { |
381 | 0 | g_autofree gchar *str = fu_mei_csme11_hfsts1_to_string(st); |
382 | 0 | g_debug("%s", str); |
383 | 0 | } |
384 | 0 | return TRUE; |
385 | 0 | } |
386 | | |
387 | | /** |
388 | | * fu_mei_csme11_hfsts1_parse: (skip): |
389 | | **/ |
390 | | FuMeiCsme11Hfsts1 * |
391 | | fu_mei_csme11_hfsts1_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
392 | 0 | { |
393 | 0 | g_autoptr(FuMeiCsme11Hfsts1) st = fu_mei_csme11_hfsts1_new_internal(); |
394 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
395 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
396 | 0 | if (!fu_memchk_read(bufsz, offset, 4, error)) { |
397 | 0 | g_prefix_error_literal(error, "invalid struct FuMeiCsme11Hfsts1: "); |
398 | 0 | return NULL; |
399 | 0 | } |
400 | 0 | st->buf = g_byte_array_new(); |
401 | 0 | g_byte_array_append(st->buf, buf + offset, 4); |
402 | 0 | if (!fu_mei_csme11_hfsts1_parse_internal(st, error)) |
403 | 0 | return NULL; |
404 | 0 | return g_steal_pointer(&st); |
405 | 0 | } |
406 | | /** |
407 | | * fu_mei_csme11_hfsts2_ref: (skip): |
408 | | **/ |
409 | | FuMeiCsme11Hfsts2 * |
410 | | fu_mei_csme11_hfsts2_ref(FuMeiCsme11Hfsts2 *st) |
411 | 0 | { |
412 | 0 | g_return_val_if_fail(st != NULL, NULL); |
413 | 0 | st->refcount++; |
414 | 0 | return st; |
415 | 0 | } |
416 | | /** |
417 | | * fu_mei_csme11_hfsts2_unref: (skip): |
418 | | **/ |
419 | | void |
420 | | fu_mei_csme11_hfsts2_unref(FuMeiCsme11Hfsts2 *st) |
421 | 0 | { |
422 | 0 | g_return_if_fail(st != NULL); |
423 | 0 | if (st->refcount == 0) { |
424 | 0 | g_critical("FuMeiCsme11Hfsts2 refcount already zero"); |
425 | 0 | return; |
426 | 0 | } |
427 | 0 | if (--st->refcount > 0) |
428 | 0 | return; |
429 | 0 | if (st->buf != NULL) |
430 | 0 | g_byte_array_unref(st->buf); |
431 | 0 | g_free(st); |
432 | 0 | } |
433 | | |
434 | | /* getters */ |
435 | | |
436 | | /* setters */ |
437 | | /** |
438 | | * fu_mei_csme11_hfsts3_ref: (skip): |
439 | | **/ |
440 | | FuMeiCsme11Hfsts3 * |
441 | | fu_mei_csme11_hfsts3_ref(FuMeiCsme11Hfsts3 *st) |
442 | 0 | { |
443 | 0 | g_return_val_if_fail(st != NULL, NULL); |
444 | 0 | st->refcount++; |
445 | 0 | return st; |
446 | 0 | } |
447 | | /** |
448 | | * fu_mei_csme11_hfsts3_unref: (skip): |
449 | | **/ |
450 | | void |
451 | | fu_mei_csme11_hfsts3_unref(FuMeiCsme11Hfsts3 *st) |
452 | 0 | { |
453 | 0 | g_return_if_fail(st != NULL); |
454 | 0 | if (st->refcount == 0) { |
455 | 0 | g_critical("FuMeiCsme11Hfsts3 refcount already zero"); |
456 | 0 | return; |
457 | 0 | } |
458 | 0 | if (--st->refcount > 0) |
459 | 0 | return; |
460 | 0 | if (st->buf != NULL) |
461 | 0 | g_byte_array_unref(st->buf); |
462 | 0 | g_free(st); |
463 | 0 | } |
464 | | |
465 | | /* getters */ |
466 | | |
467 | | /* setters */ |
468 | | /** |
469 | | * fu_mei_csme11_hfsts4_ref: (skip): |
470 | | **/ |
471 | | FuMeiCsme11Hfsts4 * |
472 | | fu_mei_csme11_hfsts4_ref(FuMeiCsme11Hfsts4 *st) |
473 | 0 | { |
474 | 0 | g_return_val_if_fail(st != NULL, NULL); |
475 | 0 | st->refcount++; |
476 | 0 | return st; |
477 | 0 | } |
478 | | /** |
479 | | * fu_mei_csme11_hfsts4_unref: (skip): |
480 | | **/ |
481 | | void |
482 | | fu_mei_csme11_hfsts4_unref(FuMeiCsme11Hfsts4 *st) |
483 | 0 | { |
484 | 0 | g_return_if_fail(st != NULL); |
485 | 0 | if (st->refcount == 0) { |
486 | 0 | g_critical("FuMeiCsme11Hfsts4 refcount already zero"); |
487 | 0 | return; |
488 | 0 | } |
489 | 0 | if (--st->refcount > 0) |
490 | 0 | return; |
491 | 0 | if (st->buf != NULL) |
492 | 0 | g_byte_array_unref(st->buf); |
493 | 0 | g_free(st); |
494 | 0 | } |
495 | | |
496 | | /* getters */ |
497 | | |
498 | | /* setters */ |
499 | | /** |
500 | | * fu_mei_csme11_hfsts5_ref: (skip): |
501 | | **/ |
502 | | FuMeiCsme11Hfsts5 * |
503 | | fu_mei_csme11_hfsts5_ref(FuMeiCsme11Hfsts5 *st) |
504 | 0 | { |
505 | 0 | g_return_val_if_fail(st != NULL, NULL); |
506 | 0 | st->refcount++; |
507 | 0 | return st; |
508 | 0 | } |
509 | | /** |
510 | | * fu_mei_csme11_hfsts5_unref: (skip): |
511 | | **/ |
512 | | void |
513 | | fu_mei_csme11_hfsts5_unref(FuMeiCsme11Hfsts5 *st) |
514 | 0 | { |
515 | 0 | g_return_if_fail(st != NULL); |
516 | 0 | if (st->refcount == 0) { |
517 | 0 | g_critical("FuMeiCsme11Hfsts5 refcount already zero"); |
518 | 0 | return; |
519 | 0 | } |
520 | 0 | if (--st->refcount > 0) |
521 | 0 | return; |
522 | 0 | if (st->buf != NULL) |
523 | 0 | g_byte_array_unref(st->buf); |
524 | 0 | g_free(st); |
525 | 0 | } |
526 | | |
527 | | /* getters */ |
528 | | |
529 | | /* setters */ |
530 | | /** |
531 | | * fu_mei_csme11_hfsts6_ref: (skip): |
532 | | **/ |
533 | | FuMeiCsme11Hfsts6 * |
534 | | fu_mei_csme11_hfsts6_ref(FuMeiCsme11Hfsts6 *st) |
535 | 0 | { |
536 | 0 | g_return_val_if_fail(st != NULL, NULL); |
537 | 0 | st->refcount++; |
538 | 0 | return st; |
539 | 0 | } |
540 | | /** |
541 | | * fu_mei_csme11_hfsts6_unref: (skip): |
542 | | **/ |
543 | | void |
544 | | fu_mei_csme11_hfsts6_unref(FuMeiCsme11Hfsts6 *st) |
545 | 0 | { |
546 | 0 | g_return_if_fail(st != NULL); |
547 | 0 | if (st->refcount == 0) { |
548 | 0 | g_critical("FuMeiCsme11Hfsts6 refcount already zero"); |
549 | 0 | return; |
550 | 0 | } |
551 | 0 | if (--st->refcount > 0) |
552 | 0 | return; |
553 | 0 | if (st->buf != NULL) |
554 | 0 | g_byte_array_unref(st->buf); |
555 | 0 | g_free(st); |
556 | 0 | } |
557 | | /** |
558 | | * fu_mei_csme11_hfsts6_new_internal: (skip): |
559 | | **/ |
560 | | static FuMeiCsme11Hfsts6 * |
561 | | fu_mei_csme11_hfsts6_new_internal(void) |
562 | 0 | { |
563 | 0 | FuMeiCsme11Hfsts6 *st = g_new0(FuMeiCsme11Hfsts6, 1); |
564 | 0 | st->refcount = 1; |
565 | 0 | return st; |
566 | 0 | } |
567 | | |
568 | | /* getters */ |
569 | | /** |
570 | | * fu_mei_csme11_hfsts6_get_force_boot_guard_acm: (skip): |
571 | | **/ |
572 | | guint32 |
573 | | fu_mei_csme11_hfsts6_get_force_boot_guard_acm(const FuMeiCsme11Hfsts6 *st) |
574 | 0 | { |
575 | 0 | guint32 val; |
576 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
577 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0); |
578 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
579 | 0 | return (val >> 0) & 1; |
580 | 0 | } |
581 | | /** |
582 | | * fu_mei_csme11_hfsts6_get_error_enforce_policy: (skip): |
583 | | **/ |
584 | | FuMeHfsEnforcementPolicy |
585 | | fu_mei_csme11_hfsts6_get_error_enforce_policy(const FuMeiCsme11Hfsts6 *st) |
586 | 0 | { |
587 | 0 | guint32 val; |
588 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
589 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(FuMeHfsEnforcementPolicy), 0x0); |
590 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
591 | 0 | return (val >> 6) & 3; |
592 | 0 | } |
593 | | /** |
594 | | * fu_mei_csme11_hfsts6_get_verified_boot: (skip): |
595 | | **/ |
596 | | guint32 |
597 | | fu_mei_csme11_hfsts6_get_verified_boot(const FuMeiCsme11Hfsts6 *st) |
598 | 0 | { |
599 | 0 | guint32 val; |
600 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
601 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0); |
602 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
603 | 0 | return (val >> 9) & 1; |
604 | 0 | } |
605 | | /** |
606 | | * fu_mei_csme11_hfsts6_get_boot_guard_disable: (skip): |
607 | | **/ |
608 | | guint32 |
609 | | fu_mei_csme11_hfsts6_get_boot_guard_disable(const FuMeiCsme11Hfsts6 *st) |
610 | 0 | { |
611 | 0 | guint32 val; |
612 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
613 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0); |
614 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
615 | 0 | return (val >> 28) & 1; |
616 | 0 | } |
617 | | /** |
618 | | * fu_mei_csme11_hfsts6_get_fpf_soc_lock: (skip): |
619 | | **/ |
620 | | guint32 |
621 | | fu_mei_csme11_hfsts6_get_fpf_soc_lock(const FuMeiCsme11Hfsts6 *st) |
622 | 0 | { |
623 | 0 | guint32 val; |
624 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
625 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0); |
626 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
627 | 0 | return (val >> 30) & 1; |
628 | 0 | } |
629 | | |
630 | | /* setters */ |
631 | | /** |
632 | | * fu_mei_csme11_hfsts6_to_string: (skip): |
633 | | **/ |
634 | | static gchar * |
635 | | fu_mei_csme11_hfsts6_to_string(const FuMeiCsme11Hfsts6 *st) |
636 | 0 | { |
637 | 0 | g_autoptr(GString) str = g_string_new("FuMeiCsme11Hfsts6:\n"); |
638 | 0 | g_return_val_if_fail(st != NULL, NULL); |
639 | 0 | g_string_append_printf(str, " force_boot_guard_acm: 0x%x\n", |
640 | 0 | (guint) fu_mei_csme11_hfsts6_get_force_boot_guard_acm(st)); |
641 | 0 | { |
642 | 0 | const gchar *tmp = fu_me_hfs_enforcement_policy_to_string(fu_mei_csme11_hfsts6_get_error_enforce_policy(st)); |
643 | 0 | if (tmp != NULL) { |
644 | 0 | g_string_append_printf(str, " error_enforce_policy: 0x%x [%s]\n", (guint) fu_mei_csme11_hfsts6_get_error_enforce_policy(st), tmp); |
645 | 0 | } else { |
646 | 0 | g_string_append_printf(str, " error_enforce_policy: 0x%x\n", (guint) fu_mei_csme11_hfsts6_get_error_enforce_policy(st)); |
647 | 0 | } |
648 | 0 | } |
649 | 0 | g_string_append_printf(str, " verified_boot: 0x%x\n", |
650 | 0 | (guint) fu_mei_csme11_hfsts6_get_verified_boot(st)); |
651 | 0 | g_string_append_printf(str, " boot_guard_disable: 0x%x\n", |
652 | 0 | (guint) fu_mei_csme11_hfsts6_get_boot_guard_disable(st)); |
653 | 0 | g_string_append_printf(str, " fpf_soc_lock: 0x%x\n", |
654 | 0 | (guint) fu_mei_csme11_hfsts6_get_fpf_soc_lock(st)); |
655 | 0 | if (str->len > 0) |
656 | 0 | g_string_set_size(str, str->len - 1); |
657 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
658 | 0 | } |
659 | | static gboolean |
660 | | fu_mei_csme11_hfsts6_parse_internal(FuMeiCsme11Hfsts6 *st, GError **error) |
661 | 0 | { |
662 | 0 | if (g_log_get_debug_enabled()) { |
663 | 0 | g_autofree gchar *str = fu_mei_csme11_hfsts6_to_string(st); |
664 | 0 | g_debug("%s", str); |
665 | 0 | } |
666 | 0 | return TRUE; |
667 | 0 | } |
668 | | |
669 | | /** |
670 | | * fu_mei_csme11_hfsts6_parse: (skip): |
671 | | **/ |
672 | | FuMeiCsme11Hfsts6 * |
673 | | fu_mei_csme11_hfsts6_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
674 | 0 | { |
675 | 0 | g_autoptr(FuMeiCsme11Hfsts6) st = fu_mei_csme11_hfsts6_new_internal(); |
676 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
677 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
678 | 0 | if (!fu_memchk_read(bufsz, offset, 4, error)) { |
679 | 0 | g_prefix_error_literal(error, "invalid struct FuMeiCsme11Hfsts6: "); |
680 | 0 | return NULL; |
681 | 0 | } |
682 | 0 | st->buf = g_byte_array_new(); |
683 | 0 | g_byte_array_append(st->buf, buf + offset, 4); |
684 | 0 | if (!fu_mei_csme11_hfsts6_parse_internal(st, error)) |
685 | 0 | return NULL; |
686 | 0 | return g_steal_pointer(&st); |
687 | 0 | } |
688 | | /** |
689 | | * fu_mei_csme18_hfsts1_ref: (skip): |
690 | | **/ |
691 | | FuMeiCsme18Hfsts1 * |
692 | | fu_mei_csme18_hfsts1_ref(FuMeiCsme18Hfsts1 *st) |
693 | 0 | { |
694 | 0 | g_return_val_if_fail(st != NULL, NULL); |
695 | 0 | st->refcount++; |
696 | 0 | return st; |
697 | 0 | } |
698 | | /** |
699 | | * fu_mei_csme18_hfsts1_unref: (skip): |
700 | | **/ |
701 | | void |
702 | | fu_mei_csme18_hfsts1_unref(FuMeiCsme18Hfsts1 *st) |
703 | 0 | { |
704 | 0 | g_return_if_fail(st != NULL); |
705 | 0 | if (st->refcount == 0) { |
706 | 0 | g_critical("FuMeiCsme18Hfsts1 refcount already zero"); |
707 | 0 | return; |
708 | 0 | } |
709 | 0 | if (--st->refcount > 0) |
710 | 0 | return; |
711 | 0 | if (st->buf != NULL) |
712 | 0 | g_byte_array_unref(st->buf); |
713 | 0 | g_free(st); |
714 | 0 | } |
715 | | /** |
716 | | * fu_mei_csme18_hfsts1_new_internal: (skip): |
717 | | **/ |
718 | | static FuMeiCsme18Hfsts1 * |
719 | | fu_mei_csme18_hfsts1_new_internal(void) |
720 | 0 | { |
721 | 0 | FuMeiCsme18Hfsts1 *st = g_new0(FuMeiCsme18Hfsts1, 1); |
722 | 0 | st->refcount = 1; |
723 | 0 | return st; |
724 | 0 | } |
725 | | |
726 | | /* getters */ |
727 | | /** |
728 | | * fu_mei_csme18_hfsts1_get_spi_protection_mode: (skip): |
729 | | **/ |
730 | | guint32 |
731 | | fu_mei_csme18_hfsts1_get_spi_protection_mode(const FuMeiCsme18Hfsts1 *st) |
732 | 0 | { |
733 | 0 | guint32 val; |
734 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
735 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0); |
736 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
737 | 0 | return (val >> 4) & 1; |
738 | 0 | } |
739 | | /** |
740 | | * fu_mei_csme18_hfsts1_get_operation_mode: (skip): |
741 | | **/ |
742 | | FuMeHfsMode |
743 | | fu_mei_csme18_hfsts1_get_operation_mode(const FuMeiCsme18Hfsts1 *st) |
744 | 0 | { |
745 | 0 | guint32 val; |
746 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
747 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(FuMeHfsMode), 0x0); |
748 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
749 | 0 | return (val >> 16) & 15; |
750 | 0 | } |
751 | | |
752 | | /* setters */ |
753 | | /** |
754 | | * fu_mei_csme18_hfsts1_to_string: (skip): |
755 | | **/ |
756 | | static gchar * |
757 | | fu_mei_csme18_hfsts1_to_string(const FuMeiCsme18Hfsts1 *st) |
758 | 0 | { |
759 | 0 | g_autoptr(GString) str = g_string_new("FuMeiCsme18Hfsts1:\n"); |
760 | 0 | g_return_val_if_fail(st != NULL, NULL); |
761 | 0 | g_string_append_printf(str, " spi_protection_mode: 0x%x\n", |
762 | 0 | (guint) fu_mei_csme18_hfsts1_get_spi_protection_mode(st)); |
763 | 0 | { |
764 | 0 | const gchar *tmp = fu_me_hfs_mode_to_string(fu_mei_csme18_hfsts1_get_operation_mode(st)); |
765 | 0 | if (tmp != NULL) { |
766 | 0 | g_string_append_printf(str, " operation_mode: 0x%x [%s]\n", (guint) fu_mei_csme18_hfsts1_get_operation_mode(st), tmp); |
767 | 0 | } else { |
768 | 0 | g_string_append_printf(str, " operation_mode: 0x%x\n", (guint) fu_mei_csme18_hfsts1_get_operation_mode(st)); |
769 | 0 | } |
770 | 0 | } |
771 | 0 | if (str->len > 0) |
772 | 0 | g_string_set_size(str, str->len - 1); |
773 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
774 | 0 | } |
775 | | static gboolean |
776 | | fu_mei_csme18_hfsts1_parse_internal(FuMeiCsme18Hfsts1 *st, GError **error) |
777 | 0 | { |
778 | 0 | if (g_log_get_debug_enabled()) { |
779 | 0 | g_autofree gchar *str = fu_mei_csme18_hfsts1_to_string(st); |
780 | 0 | g_debug("%s", str); |
781 | 0 | } |
782 | 0 | return TRUE; |
783 | 0 | } |
784 | | |
785 | | /** |
786 | | * fu_mei_csme18_hfsts1_parse: (skip): |
787 | | **/ |
788 | | FuMeiCsme18Hfsts1 * |
789 | | fu_mei_csme18_hfsts1_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
790 | 0 | { |
791 | 0 | g_autoptr(FuMeiCsme18Hfsts1) st = fu_mei_csme18_hfsts1_new_internal(); |
792 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
793 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
794 | 0 | if (!fu_memchk_read(bufsz, offset, 4, error)) { |
795 | 0 | g_prefix_error_literal(error, "invalid struct FuMeiCsme18Hfsts1: "); |
796 | 0 | return NULL; |
797 | 0 | } |
798 | 0 | st->buf = g_byte_array_new(); |
799 | 0 | g_byte_array_append(st->buf, buf + offset, 4); |
800 | 0 | if (!fu_mei_csme18_hfsts1_parse_internal(st, error)) |
801 | 0 | return NULL; |
802 | 0 | return g_steal_pointer(&st); |
803 | 0 | } |
804 | | /** |
805 | | * fu_mei_csme18_hfsts2_ref: (skip): |
806 | | **/ |
807 | | FuMeiCsme18Hfsts2 * |
808 | | fu_mei_csme18_hfsts2_ref(FuMeiCsme18Hfsts2 *st) |
809 | 0 | { |
810 | 0 | g_return_val_if_fail(st != NULL, NULL); |
811 | 0 | st->refcount++; |
812 | 0 | return st; |
813 | 0 | } |
814 | | /** |
815 | | * fu_mei_csme18_hfsts2_unref: (skip): |
816 | | **/ |
817 | | void |
818 | | fu_mei_csme18_hfsts2_unref(FuMeiCsme18Hfsts2 *st) |
819 | 0 | { |
820 | 0 | g_return_if_fail(st != NULL); |
821 | 0 | if (st->refcount == 0) { |
822 | 0 | g_critical("FuMeiCsme18Hfsts2 refcount already zero"); |
823 | 0 | return; |
824 | 0 | } |
825 | 0 | if (--st->refcount > 0) |
826 | 0 | return; |
827 | 0 | if (st->buf != NULL) |
828 | 0 | g_byte_array_unref(st->buf); |
829 | 0 | g_free(st); |
830 | 0 | } |
831 | | |
832 | | /* getters */ |
833 | | |
834 | | /* setters */ |
835 | | /** |
836 | | * fu_mei_csme18_hfsts3_ref: (skip): |
837 | | **/ |
838 | | FuMeiCsme18Hfsts3 * |
839 | | fu_mei_csme18_hfsts3_ref(FuMeiCsme18Hfsts3 *st) |
840 | 0 | { |
841 | 0 | g_return_val_if_fail(st != NULL, NULL); |
842 | 0 | st->refcount++; |
843 | 0 | return st; |
844 | 0 | } |
845 | | /** |
846 | | * fu_mei_csme18_hfsts3_unref: (skip): |
847 | | **/ |
848 | | void |
849 | | fu_mei_csme18_hfsts3_unref(FuMeiCsme18Hfsts3 *st) |
850 | 0 | { |
851 | 0 | g_return_if_fail(st != NULL); |
852 | 0 | if (st->refcount == 0) { |
853 | 0 | g_critical("FuMeiCsme18Hfsts3 refcount already zero"); |
854 | 0 | return; |
855 | 0 | } |
856 | 0 | if (--st->refcount > 0) |
857 | 0 | return; |
858 | 0 | if (st->buf != NULL) |
859 | 0 | g_byte_array_unref(st->buf); |
860 | 0 | g_free(st); |
861 | 0 | } |
862 | | |
863 | | /* getters */ |
864 | | |
865 | | /* setters */ |
866 | | /** |
867 | | * fu_mei_csme18_hfsts4_ref: (skip): |
868 | | **/ |
869 | | FuMeiCsme18Hfsts4 * |
870 | | fu_mei_csme18_hfsts4_ref(FuMeiCsme18Hfsts4 *st) |
871 | 0 | { |
872 | 0 | g_return_val_if_fail(st != NULL, NULL); |
873 | 0 | st->refcount++; |
874 | 0 | return st; |
875 | 0 | } |
876 | | /** |
877 | | * fu_mei_csme18_hfsts4_unref: (skip): |
878 | | **/ |
879 | | void |
880 | | fu_mei_csme18_hfsts4_unref(FuMeiCsme18Hfsts4 *st) |
881 | 0 | { |
882 | 0 | g_return_if_fail(st != NULL); |
883 | 0 | if (st->refcount == 0) { |
884 | 0 | g_critical("FuMeiCsme18Hfsts4 refcount already zero"); |
885 | 0 | return; |
886 | 0 | } |
887 | 0 | if (--st->refcount > 0) |
888 | 0 | return; |
889 | 0 | if (st->buf != NULL) |
890 | 0 | g_byte_array_unref(st->buf); |
891 | 0 | g_free(st); |
892 | 0 | } |
893 | | |
894 | | /* getters */ |
895 | | |
896 | | /* setters */ |
897 | | /** |
898 | | * fu_mei_csme18_hfsts5_ref: (skip): |
899 | | **/ |
900 | | FuMeiCsme18Hfsts5 * |
901 | | fu_mei_csme18_hfsts5_ref(FuMeiCsme18Hfsts5 *st) |
902 | 0 | { |
903 | 0 | g_return_val_if_fail(st != NULL, NULL); |
904 | 0 | st->refcount++; |
905 | 0 | return st; |
906 | 0 | } |
907 | | /** |
908 | | * fu_mei_csme18_hfsts5_unref: (skip): |
909 | | **/ |
910 | | void |
911 | | fu_mei_csme18_hfsts5_unref(FuMeiCsme18Hfsts5 *st) |
912 | 0 | { |
913 | 0 | g_return_if_fail(st != NULL); |
914 | 0 | if (st->refcount == 0) { |
915 | 0 | g_critical("FuMeiCsme18Hfsts5 refcount already zero"); |
916 | 0 | return; |
917 | 0 | } |
918 | 0 | if (--st->refcount > 0) |
919 | 0 | return; |
920 | 0 | if (st->buf != NULL) |
921 | 0 | g_byte_array_unref(st->buf); |
922 | 0 | g_free(st); |
923 | 0 | } |
924 | | /** |
925 | | * fu_mei_csme18_hfsts5_new_internal: (skip): |
926 | | **/ |
927 | | static FuMeiCsme18Hfsts5 * |
928 | | fu_mei_csme18_hfsts5_new_internal(void) |
929 | 0 | { |
930 | 0 | FuMeiCsme18Hfsts5 *st = g_new0(FuMeiCsme18Hfsts5, 1); |
931 | 0 | st->refcount = 1; |
932 | 0 | return st; |
933 | 0 | } |
934 | | |
935 | | /* getters */ |
936 | | /** |
937 | | * fu_mei_csme18_hfsts5_get_btg_acm_active: (skip): |
938 | | **/ |
939 | | guint32 |
940 | | fu_mei_csme18_hfsts5_get_btg_acm_active(const FuMeiCsme18Hfsts5 *st) |
941 | 0 | { |
942 | 0 | guint32 val; |
943 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
944 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0); |
945 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
946 | 0 | return (val >> 0) & 1; |
947 | 0 | } |
948 | | /** |
949 | | * fu_mei_csme18_hfsts5_get_valid: (skip): |
950 | | **/ |
951 | | guint32 |
952 | | fu_mei_csme18_hfsts5_get_valid(const FuMeiCsme18Hfsts5 *st) |
953 | 0 | { |
954 | 0 | guint32 val; |
955 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
956 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0); |
957 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
958 | 0 | return (val >> 1) & 1; |
959 | 0 | } |
960 | | /** |
961 | | * fu_mei_csme18_hfsts5_get_acm_done_sts: (skip): |
962 | | **/ |
963 | | guint32 |
964 | | fu_mei_csme18_hfsts5_get_acm_done_sts(const FuMeiCsme18Hfsts5 *st) |
965 | 0 | { |
966 | 0 | guint32 val; |
967 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
968 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0); |
969 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
970 | 0 | return (val >> 8) & 1; |
971 | 0 | } |
972 | | |
973 | | /* setters */ |
974 | | /** |
975 | | * fu_mei_csme18_hfsts5_to_string: (skip): |
976 | | **/ |
977 | | static gchar * |
978 | | fu_mei_csme18_hfsts5_to_string(const FuMeiCsme18Hfsts5 *st) |
979 | 0 | { |
980 | 0 | g_autoptr(GString) str = g_string_new("FuMeiCsme18Hfsts5:\n"); |
981 | 0 | g_return_val_if_fail(st != NULL, NULL); |
982 | 0 | g_string_append_printf(str, " btg_acm_active: 0x%x\n", |
983 | 0 | (guint) fu_mei_csme18_hfsts5_get_btg_acm_active(st)); |
984 | 0 | g_string_append_printf(str, " valid: 0x%x\n", |
985 | 0 | (guint) fu_mei_csme18_hfsts5_get_valid(st)); |
986 | 0 | g_string_append_printf(str, " acm_done_sts: 0x%x\n", |
987 | 0 | (guint) fu_mei_csme18_hfsts5_get_acm_done_sts(st)); |
988 | 0 | if (str->len > 0) |
989 | 0 | g_string_set_size(str, str->len - 1); |
990 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
991 | 0 | } |
992 | | static gboolean |
993 | | fu_mei_csme18_hfsts5_parse_internal(FuMeiCsme18Hfsts5 *st, GError **error) |
994 | 0 | { |
995 | 0 | if (g_log_get_debug_enabled()) { |
996 | 0 | g_autofree gchar *str = fu_mei_csme18_hfsts5_to_string(st); |
997 | 0 | g_debug("%s", str); |
998 | 0 | } |
999 | 0 | return TRUE; |
1000 | 0 | } |
1001 | | |
1002 | | /** |
1003 | | * fu_mei_csme18_hfsts5_parse: (skip): |
1004 | | **/ |
1005 | | FuMeiCsme18Hfsts5 * |
1006 | | fu_mei_csme18_hfsts5_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
1007 | 0 | { |
1008 | 0 | g_autoptr(FuMeiCsme18Hfsts5) st = fu_mei_csme18_hfsts5_new_internal(); |
1009 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
1010 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
1011 | 0 | if (!fu_memchk_read(bufsz, offset, 4, error)) { |
1012 | 0 | g_prefix_error_literal(error, "invalid struct FuMeiCsme18Hfsts5: "); |
1013 | 0 | return NULL; |
1014 | 0 | } |
1015 | 0 | st->buf = g_byte_array_new(); |
1016 | 0 | g_byte_array_append(st->buf, buf + offset, 4); |
1017 | 0 | if (!fu_mei_csme18_hfsts5_parse_internal(st, error)) |
1018 | 0 | return NULL; |
1019 | 0 | return g_steal_pointer(&st); |
1020 | 0 | } |
1021 | | /** |
1022 | | * fu_mei_csme18_hfsts6_ref: (skip): |
1023 | | **/ |
1024 | | FuMeiCsme18Hfsts6 * |
1025 | | fu_mei_csme18_hfsts6_ref(FuMeiCsme18Hfsts6 *st) |
1026 | 0 | { |
1027 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1028 | 0 | st->refcount++; |
1029 | 0 | return st; |
1030 | 0 | } |
1031 | | /** |
1032 | | * fu_mei_csme18_hfsts6_unref: (skip): |
1033 | | **/ |
1034 | | void |
1035 | | fu_mei_csme18_hfsts6_unref(FuMeiCsme18Hfsts6 *st) |
1036 | 0 | { |
1037 | 0 | g_return_if_fail(st != NULL); |
1038 | 0 | if (st->refcount == 0) { |
1039 | 0 | g_critical("FuMeiCsme18Hfsts6 refcount already zero"); |
1040 | 0 | return; |
1041 | 0 | } |
1042 | 0 | if (--st->refcount > 0) |
1043 | 0 | return; |
1044 | 0 | if (st->buf != NULL) |
1045 | 0 | g_byte_array_unref(st->buf); |
1046 | 0 | g_free(st); |
1047 | 0 | } |
1048 | | /** |
1049 | | * fu_mei_csme18_hfsts6_new_internal: (skip): |
1050 | | **/ |
1051 | | static FuMeiCsme18Hfsts6 * |
1052 | | fu_mei_csme18_hfsts6_new_internal(void) |
1053 | 0 | { |
1054 | 0 | FuMeiCsme18Hfsts6 *st = g_new0(FuMeiCsme18Hfsts6, 1); |
1055 | 0 | st->refcount = 1; |
1056 | 0 | return st; |
1057 | 0 | } |
1058 | | |
1059 | | /* getters */ |
1060 | | /** |
1061 | | * fu_mei_csme18_hfsts6_get_fpf_soc_configuration_lock: (skip): |
1062 | | **/ |
1063 | | guint32 |
1064 | | fu_mei_csme18_hfsts6_get_fpf_soc_configuration_lock(const FuMeiCsme18Hfsts6 *st) |
1065 | 0 | { |
1066 | 0 | guint32 val; |
1067 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1068 | 0 | g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0); |
1069 | 0 | val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN); |
1070 | 0 | return (val >> 30) & 1; |
1071 | 0 | } |
1072 | | |
1073 | | /* setters */ |
1074 | | /** |
1075 | | * fu_mei_csme18_hfsts6_to_string: (skip): |
1076 | | **/ |
1077 | | static gchar * |
1078 | | fu_mei_csme18_hfsts6_to_string(const FuMeiCsme18Hfsts6 *st) |
1079 | 0 | { |
1080 | 0 | g_autoptr(GString) str = g_string_new("FuMeiCsme18Hfsts6:\n"); |
1081 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1082 | 0 | g_string_append_printf(str, " fpf_soc_configuration_lock: 0x%x\n", |
1083 | 0 | (guint) fu_mei_csme18_hfsts6_get_fpf_soc_configuration_lock(st)); |
1084 | 0 | if (str->len > 0) |
1085 | 0 | g_string_set_size(str, str->len - 1); |
1086 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1087 | 0 | } |
1088 | | static gboolean |
1089 | | fu_mei_csme18_hfsts6_parse_internal(FuMeiCsme18Hfsts6 *st, GError **error) |
1090 | 0 | { |
1091 | 0 | if (g_log_get_debug_enabled()) { |
1092 | 0 | g_autofree gchar *str = fu_mei_csme18_hfsts6_to_string(st); |
1093 | 0 | g_debug("%s", str); |
1094 | 0 | } |
1095 | 0 | return TRUE; |
1096 | 0 | } |
1097 | | |
1098 | | /** |
1099 | | * fu_mei_csme18_hfsts6_parse: (skip): |
1100 | | **/ |
1101 | | FuMeiCsme18Hfsts6 * |
1102 | | fu_mei_csme18_hfsts6_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
1103 | 0 | { |
1104 | 0 | g_autoptr(FuMeiCsme18Hfsts6) st = fu_mei_csme18_hfsts6_new_internal(); |
1105 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
1106 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
1107 | 0 | if (!fu_memchk_read(bufsz, offset, 4, error)) { |
1108 | 0 | g_prefix_error_literal(error, "invalid struct FuMeiCsme18Hfsts6: "); |
1109 | 0 | return NULL; |
1110 | 0 | } |
1111 | 0 | st->buf = g_byte_array_new(); |
1112 | 0 | g_byte_array_append(st->buf, buf + offset, 4); |
1113 | 0 | if (!fu_mei_csme18_hfsts6_parse_internal(st, error)) |
1114 | 0 | return NULL; |
1115 | 0 | return g_steal_pointer(&st); |
1116 | 0 | } |