/*
 * This file is auto-generated, do not modify!
 *
 * SPDX-License-Identifier: LGPL-2.1-or-later
 */

#include "config.h"

#include <glib.h>

#include "fu-sunwinon-hid-struct.h"
#include "fu-byte-array.h"
#include "fu-bytes.h"
#include "fu-mem-private.h"
#include "fu-string.h"

#ifdef G_LOG_DOMAIN
  #undef G_LOG_DOMAIN
#endif
#define G_LOG_DOMAIN "FuStruct"

/**
 * fu_sunwinon_hid_report_to_string:
 * @val: value
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_sunwinon_hid_report_to_string(FuSunwinonHidReport val)
{
    if (val == FU_SUNWINON_HID_REPORT_CHANNEL_ID)
        return "channel-id";
    return NULL;
}

/**
 * fu_sunwinon_dfu_cmd_to_string:
 * @val: value, e.g. %FU_SUNWINON_DFU_CMD_PROGRAM_START
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
const gchar *
fu_sunwinon_dfu_cmd_to_string(FuSunwinonDfuCmd val)
{
    if (val == FU_SUNWINON_DFU_CMD_GET_INFO)
        return "get-info";
    if (val == FU_SUNWINON_DFU_CMD_PROGRAM_START)
        return "program-start";
    if (val == FU_SUNWINON_DFU_CMD_PROGRAM_FLASH)
        return "program-flash";
    if (val == FU_SUNWINON_DFU_CMD_PROGRAM_END)
        return "program-end";
    if (val == FU_SUNWINON_DFU_CMD_SYSTEM_INFO)
        return "system-info";
    if (val == FU_SUNWINON_DFU_CMD_MODE_SET)
        return "mode-set";
    if (val == FU_SUNWINON_DFU_CMD_FW_INFO_GET)
        return "fw-info-get";
    if (val == FU_SUNWINON_DFU_CMD_FAST_DFU_FLASH_SUCCESS)
        return "fast-dfu-flash-success";
    return NULL;
}

/**
 * fu_sunwinon_dfu_ack_to_string:
 * @val: value, e.g. %FU_SUNWINON_DFU_ACK_ERROR
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_sunwinon_dfu_ack_to_string(FuSunwinonDfuAck val)
{
    if (val == FU_SUNWINON_DFU_ACK_SUCCESS)
        return "success";
    if (val == FU_SUNWINON_DFU_ACK_ERROR)
        return "error";
    return NULL;
}

/**
 * fu_sunwinon_fw_type_to_string:
 * @val: value, e.g. %FU_SUNWINON_FW_TYPE_SIGNED
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
const gchar *
fu_sunwinon_fw_type_to_string(FuSunwinonFwType val)
{
    if (val == FU_SUNWINON_FW_TYPE_NORMAL)
        return "normal";
    if (val == FU_SUNWINON_FW_TYPE_SIGNED)
        return "signed";
    return NULL;
}

/**
 * fu_struct_sunwinon_hid_out_ref: (skip):
 **/
FuStructSunwinonHidOut *
fu_struct_sunwinon_hid_out_ref(FuStructSunwinonHidOut *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_sunwinon_hid_out_unref: (skip):
 **/
void
fu_struct_sunwinon_hid_out_unref(FuStructSunwinonHidOut *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructSunwinonHidOut refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_sunwinon_hid_out_new_internal: (skip):
 **/
static FuStructSunwinonHidOut *
fu_struct_sunwinon_hid_out_new_internal(void)
{
    FuStructSunwinonHidOut *st = g_new0(FuStructSunwinonHidOut, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_sunwinon_hid_out_set_report_id: (skip):
 **/
static void
fu_struct_sunwinon_hid_out_set_report_id(FuStructSunwinonHidOut *st, FuSunwinonHidReport value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_sunwinon_hid_out_set_device_id: (skip):
 **/
void
fu_struct_sunwinon_hid_out_set_device_id(FuStructSunwinonHidOut *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_sunwinon_hid_out_set_sub_id: (skip):
 **/
void
fu_struct_sunwinon_hid_out_set_sub_id(FuStructSunwinonHidOut *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[2] = value;
}
/**
 * fu_struct_sunwinon_hid_out_set_data_len: (skip):
 **/
void
fu_struct_sunwinon_hid_out_set_data_len(FuStructSunwinonHidOut *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 3, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_hid_out_set_dfu_magic: (skip):
 **/
static void
fu_struct_sunwinon_hid_out_set_dfu_magic(FuStructSunwinonHidOut *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 5, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_hid_out_set_dfu_cmd_type: (skip):
 **/
void
fu_struct_sunwinon_hid_out_set_dfu_cmd_type(FuStructSunwinonHidOut *st, FuSunwinonDfuCmd value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 7, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_hid_out_set_dfu_data_len: (skip):
 **/
void
fu_struct_sunwinon_hid_out_set_dfu_data_len(FuStructSunwinonHidOut *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 9, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_hid_out_set_data: (skip):
 **/
gboolean
fu_struct_sunwinon_hid_out_set_data(FuStructSunwinonHidOut *st, const guint8 *buf, gsize bufsz, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    g_return_val_if_fail(buf != NULL, FALSE);
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
    return fu_memcpy_safe(st->buf->data, st->buf->len, 11, buf, bufsz, 0x0, bufsz, error);
}
/**
 * fu_struct_sunwinon_hid_out_new: (skip):
 **/
FuStructSunwinonHidOut *
fu_struct_sunwinon_hid_out_new(void)
{
    FuStructSunwinonHidOut *st = fu_struct_sunwinon_hid_out_new_internal();
    st->buf = g_byte_array_sized_new(485);
    fu_byte_array_set_size(st->buf, 485, 0x0);
    fu_struct_sunwinon_hid_out_set_report_id(st, FU_SUNWINON_HID_REPORT_CHANNEL_ID);
    fu_struct_sunwinon_hid_out_set_device_id(st, 0x00);
    fu_struct_sunwinon_hid_out_set_sub_id(st, 0x01);
    fu_struct_sunwinon_hid_out_set_dfu_magic(st, 0x4744);
    return st;
}
/**
 * fu_struct_sunwinon_hid_in_ref: (skip):
 **/
FuStructSunwinonHidIn *
fu_struct_sunwinon_hid_in_ref(FuStructSunwinonHidIn *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_sunwinon_hid_in_unref: (skip):
 **/
void
fu_struct_sunwinon_hid_in_unref(FuStructSunwinonHidIn *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructSunwinonHidIn refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_sunwinon_hid_in_new_internal: (skip):
 **/
static FuStructSunwinonHidIn *
fu_struct_sunwinon_hid_in_new_internal(void)
{
    FuStructSunwinonHidIn *st = g_new0(FuStructSunwinonHidIn, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_sunwinon_hid_in_get_report_id: (skip):
 **/
static FuSunwinonHidReport
fu_struct_sunwinon_hid_in_get_report_id(const FuStructSunwinonHidIn *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_sunwinon_hid_in_get_device_id: (skip):
 **/
guint8
fu_struct_sunwinon_hid_in_get_device_id(const FuStructSunwinonHidIn *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_sunwinon_hid_in_get_sub_id: (skip):
 **/
guint8
fu_struct_sunwinon_hid_in_get_sub_id(const FuStructSunwinonHidIn *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[2];
}
/**
 * fu_struct_sunwinon_hid_in_get_data_len: (skip):
 **/
guint16
fu_struct_sunwinon_hid_in_get_data_len(const FuStructSunwinonHidIn *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 3, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_hid_in_get_dfu_magic: (skip):
 **/
static guint16
fu_struct_sunwinon_hid_in_get_dfu_magic(const FuStructSunwinonHidIn *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 5, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_hid_in_get_dfu_cmd_type: (skip):
 **/
FuSunwinonDfuCmd
fu_struct_sunwinon_hid_in_get_dfu_cmd_type(const FuStructSunwinonHidIn *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 7, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_hid_in_get_dfu_data_len: (skip):
 **/
guint16
fu_struct_sunwinon_hid_in_get_dfu_data_len(const FuStructSunwinonHidIn *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 9, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_hid_in_get_data: (skip):
 **/
const guint8 *
fu_struct_sunwinon_hid_in_get_data(const FuStructSunwinonHidIn *st, gsize *bufsz)
{
    g_return_val_if_fail(st != NULL, NULL);
    if (bufsz != NULL)
        *bufsz = 474;
    return st->buf->data + 11;
}

/* setters */
/**
 * fu_struct_sunwinon_hid_in_to_string: (skip):
 **/
static gchar *
fu_struct_sunwinon_hid_in_to_string(const FuStructSunwinonHidIn *st)
{
    g_autoptr(GString) str = g_string_new("FuStructSunwinonHidIn:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_sunwinon_hid_report_to_string(fu_struct_sunwinon_hid_in_get_report_id(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  report_id: 0x%x [%s]\n", (guint) fu_struct_sunwinon_hid_in_get_report_id(st), tmp);
        } else {
            g_string_append_printf(str, "  report_id: 0x%x\n", (guint) fu_struct_sunwinon_hid_in_get_report_id(st));
        }
    }
    g_string_append_printf(str, "  device_id: 0x%x\n",
                           (guint) fu_struct_sunwinon_hid_in_get_device_id(st));
    g_string_append_printf(str, "  sub_id: 0x%x\n",
                           (guint) fu_struct_sunwinon_hid_in_get_sub_id(st));
    g_string_append_printf(str, "  data_len: 0x%x\n",
                           (guint) fu_struct_sunwinon_hid_in_get_data_len(st));
    g_string_append_printf(str, "  dfu_magic: 0x%x\n",
                           (guint) fu_struct_sunwinon_hid_in_get_dfu_magic(st));
    {
        const gchar *tmp = fu_sunwinon_dfu_cmd_to_string(fu_struct_sunwinon_hid_in_get_dfu_cmd_type(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  dfu_cmd_type: 0x%x [%s]\n", (guint) fu_struct_sunwinon_hid_in_get_dfu_cmd_type(st), tmp);
        } else {
            g_string_append_printf(str, "  dfu_cmd_type: 0x%x\n", (guint) fu_struct_sunwinon_hid_in_get_dfu_cmd_type(st));
        }
    }
    g_string_append_printf(str, "  dfu_data_len: 0x%x\n",
                           (guint) fu_struct_sunwinon_hid_in_get_dfu_data_len(st));
    {
        gsize bufsz = 0;
        const guint8 *buf = fu_struct_sunwinon_hid_in_get_data(st, &bufsz);
        g_autoptr(GString) tmp = g_string_new(NULL);
        for (gsize i = 0; i < bufsz; i++)
            g_string_append_printf(tmp, "%02X", buf[i]);
        g_string_append_printf(str, "  data: 0x%s\n", tmp->str);
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_sunwinon_hid_in_validate_internal(FuStructSunwinonHidIn *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_sunwinon_hid_in_get_report_id(st) != FU_SUNWINON_HID_REPORT_CHANNEL_ID) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructSunwinonHidIn.report_id was not valid, "
                    "expected 'FU_SUNWINON_HID_REPORT_CHANNEL_ID' and got 0x%x '%s'",
                    fu_struct_sunwinon_hid_in_get_report_id(st),
                    fu_sunwinon_hid_report_to_string(fu_struct_sunwinon_hid_in_get_report_id(st)));
        return FALSE;
    }
    if (fu_struct_sunwinon_hid_in_get_dfu_magic(st) != 0x4744) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructSunwinonHidIn.dfu_magic was not valid, "
                    "expected 0x%x and got 0x%x",
                    (guint) 0x4744,
                    (guint) fu_struct_sunwinon_hid_in_get_dfu_magic(st));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_sunwinon_hid_in_parse_internal(FuStructSunwinonHidIn *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_sunwinon_hid_in_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_sunwinon_hid_in_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_sunwinon_hid_in_parse: (skip):
 **/
FuStructSunwinonHidIn *
fu_struct_sunwinon_hid_in_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructSunwinonHidIn) st = fu_struct_sunwinon_hid_in_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 485, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructSunwinonHidIn: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 485);
    if (!fu_struct_sunwinon_hid_in_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_sunwinon_dfu_payload_system_info_ref: (skip):
 **/
FuStructSunwinonDfuPayloadSystemInfo *
fu_struct_sunwinon_dfu_payload_system_info_ref(FuStructSunwinonDfuPayloadSystemInfo *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_sunwinon_dfu_payload_system_info_unref: (skip):
 **/
void
fu_struct_sunwinon_dfu_payload_system_info_unref(FuStructSunwinonDfuPayloadSystemInfo *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructSunwinonDfuPayloadSystemInfo refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_sunwinon_dfu_payload_system_info_new_internal: (skip):
 **/
static FuStructSunwinonDfuPayloadSystemInfo *
fu_struct_sunwinon_dfu_payload_system_info_new_internal(void)
{
    FuStructSunwinonDfuPayloadSystemInfo *st = g_new0(FuStructSunwinonDfuPayloadSystemInfo, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_sunwinon_dfu_payload_system_info_set_opcode: (skip):
 **/
static void
fu_struct_sunwinon_dfu_payload_system_info_set_opcode(FuStructSunwinonDfuPayloadSystemInfo *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_sunwinon_dfu_payload_system_info_set_flash_start_addr: (skip):
 **/
void
fu_struct_sunwinon_dfu_payload_system_info_set_flash_start_addr(FuStructSunwinonDfuPayloadSystemInfo *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 1, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_payload_system_info_set_len: (skip):
 **/
static void
fu_struct_sunwinon_dfu_payload_system_info_set_len(FuStructSunwinonDfuPayloadSystemInfo *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 5, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_payload_system_info_new: (skip):
 **/
FuStructSunwinonDfuPayloadSystemInfo *
fu_struct_sunwinon_dfu_payload_system_info_new(void)
{
    FuStructSunwinonDfuPayloadSystemInfo *st = fu_struct_sunwinon_dfu_payload_system_info_new_internal();
    st->buf = g_byte_array_sized_new(7);
    fu_byte_array_set_size(st->buf, 7, 0x0);
    fu_struct_sunwinon_dfu_payload_system_info_set_opcode(st, 0x00);
    fu_struct_sunwinon_dfu_payload_system_info_set_len(st, 0x30);
    return st;
}
/**
 * fu_struct_sunwinon_dfu_payload_program_start_ref: (skip):
 **/
FuStructSunwinonDfuPayloadProgramStart *
fu_struct_sunwinon_dfu_payload_program_start_ref(FuStructSunwinonDfuPayloadProgramStart *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_sunwinon_dfu_payload_program_start_unref: (skip):
 **/
void
fu_struct_sunwinon_dfu_payload_program_start_unref(FuStructSunwinonDfuPayloadProgramStart *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructSunwinonDfuPayloadProgramStart refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_sunwinon_dfu_payload_program_start_new_internal: (skip):
 **/
static FuStructSunwinonDfuPayloadProgramStart *
fu_struct_sunwinon_dfu_payload_program_start_new_internal(void)
{
    FuStructSunwinonDfuPayloadProgramStart *st = g_new0(FuStructSunwinonDfuPayloadProgramStart, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_sunwinon_dfu_payload_program_start_set_mode: (skip):
 **/
void
fu_struct_sunwinon_dfu_payload_program_start_set_mode(FuStructSunwinonDfuPayloadProgramStart *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_sunwinon_dfu_payload_program_start_set_image_info_raw: (skip):
 **/
gboolean
fu_struct_sunwinon_dfu_payload_program_start_set_image_info_raw(FuStructSunwinonDfuPayloadProgramStart *st, const guint8 *buf, gsize bufsz, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    g_return_val_if_fail(buf != NULL, FALSE);
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
    return fu_memcpy_safe(st->buf->data, st->buf->len, 1, buf, bufsz, 0x0, bufsz, error);
}
/**
 * fu_struct_sunwinon_dfu_payload_program_start_new: (skip):
 **/
FuStructSunwinonDfuPayloadProgramStart *
fu_struct_sunwinon_dfu_payload_program_start_new(void)
{
    FuStructSunwinonDfuPayloadProgramStart *st = fu_struct_sunwinon_dfu_payload_program_start_new_internal();
    st->buf = g_byte_array_sized_new(41);
    fu_byte_array_set_size(st->buf, 41, 0x0);
    return st;
}
/**
 * fu_struct_sunwinon_dfu_payload_program_flash_ref: (skip):
 **/
FuStructSunwinonDfuPayloadProgramFlash *
fu_struct_sunwinon_dfu_payload_program_flash_ref(FuStructSunwinonDfuPayloadProgramFlash *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_sunwinon_dfu_payload_program_flash_unref: (skip):
 **/
void
fu_struct_sunwinon_dfu_payload_program_flash_unref(FuStructSunwinonDfuPayloadProgramFlash *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructSunwinonDfuPayloadProgramFlash refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_sunwinon_dfu_payload_program_flash_new_internal: (skip):
 **/
static FuStructSunwinonDfuPayloadProgramFlash *
fu_struct_sunwinon_dfu_payload_program_flash_new_internal(void)
{
    FuStructSunwinonDfuPayloadProgramFlash *st = g_new0(FuStructSunwinonDfuPayloadProgramFlash, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_sunwinon_dfu_payload_program_flash_set_write_mode: (skip):
 **/
static void
fu_struct_sunwinon_dfu_payload_program_flash_set_write_mode(FuStructSunwinonDfuPayloadProgramFlash *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_sunwinon_dfu_payload_program_flash_set_dfu_save_addr: (skip):
 **/
void
fu_struct_sunwinon_dfu_payload_program_flash_set_dfu_save_addr(FuStructSunwinonDfuPayloadProgramFlash *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 1, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_payload_program_flash_set_data_len: (skip):
 **/
void
fu_struct_sunwinon_dfu_payload_program_flash_set_data_len(FuStructSunwinonDfuPayloadProgramFlash *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 5, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_payload_program_flash_set_fw_data: (skip):
 **/
gboolean
fu_struct_sunwinon_dfu_payload_program_flash_set_fw_data(FuStructSunwinonDfuPayloadProgramFlash *st, const guint8 *buf, gsize bufsz, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    g_return_val_if_fail(buf != NULL, FALSE);
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
    return fu_memcpy_safe(st->buf->data, st->buf->len, 7, buf, bufsz, 0x0, bufsz, error);
}
/**
 * fu_struct_sunwinon_dfu_payload_program_flash_new: (skip):
 **/
FuStructSunwinonDfuPayloadProgramFlash *
fu_struct_sunwinon_dfu_payload_program_flash_new(void)
{
    FuStructSunwinonDfuPayloadProgramFlash *st = fu_struct_sunwinon_dfu_payload_program_flash_new_internal();
    st->buf = g_byte_array_sized_new(471);
    fu_byte_array_set_size(st->buf, 471, 0x0);
    fu_struct_sunwinon_dfu_payload_program_flash_set_write_mode(st, 0x01);
    return st;
}
/**
 * fu_struct_sunwinon_dfu_payload_program_end_ref: (skip):
 **/
FuStructSunwinonDfuPayloadProgramEnd *
fu_struct_sunwinon_dfu_payload_program_end_ref(FuStructSunwinonDfuPayloadProgramEnd *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_sunwinon_dfu_payload_program_end_unref: (skip):
 **/
void
fu_struct_sunwinon_dfu_payload_program_end_unref(FuStructSunwinonDfuPayloadProgramEnd *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructSunwinonDfuPayloadProgramEnd refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_sunwinon_dfu_payload_program_end_new_internal: (skip):
 **/
static FuStructSunwinonDfuPayloadProgramEnd *
fu_struct_sunwinon_dfu_payload_program_end_new_internal(void)
{
    FuStructSunwinonDfuPayloadProgramEnd *st = g_new0(FuStructSunwinonDfuPayloadProgramEnd, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_sunwinon_dfu_payload_program_end_set_end_mode: (skip):
 **/
static void
fu_struct_sunwinon_dfu_payload_program_end_set_end_mode(FuStructSunwinonDfuPayloadProgramEnd *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_sunwinon_dfu_payload_program_end_set_file_checksum: (skip):
 **/
void
fu_struct_sunwinon_dfu_payload_program_end_set_file_checksum(FuStructSunwinonDfuPayloadProgramEnd *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 1, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_payload_program_end_new: (skip):
 **/
FuStructSunwinonDfuPayloadProgramEnd *
fu_struct_sunwinon_dfu_payload_program_end_new(void)
{
    FuStructSunwinonDfuPayloadProgramEnd *st = fu_struct_sunwinon_dfu_payload_program_end_new_internal();
    st->buf = g_byte_array_sized_new(5);
    fu_byte_array_set_size(st->buf, 5, 0x0);
    fu_struct_sunwinon_dfu_payload_program_end_set_end_mode(st, 0x01);
    return st;
}
/**
 * fu_struct_sunwinon_dfu_rsp_get_info_ref: (skip):
 **/
FuStructSunwinonDfuRspGetInfo *
fu_struct_sunwinon_dfu_rsp_get_info_ref(FuStructSunwinonDfuRspGetInfo *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_sunwinon_dfu_rsp_get_info_unref: (skip):
 **/
void
fu_struct_sunwinon_dfu_rsp_get_info_unref(FuStructSunwinonDfuRspGetInfo *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructSunwinonDfuRspGetInfo refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_sunwinon_dfu_rsp_get_info_new_internal: (skip):
 **/
static FuStructSunwinonDfuRspGetInfo *
fu_struct_sunwinon_dfu_rsp_get_info_new_internal(void)
{
    FuStructSunwinonDfuRspGetInfo *st = g_new0(FuStructSunwinonDfuRspGetInfo, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_sunwinon_dfu_rsp_get_info_get_ack_status: (skip):
 **/
FuSunwinonDfuAck
fu_struct_sunwinon_dfu_rsp_get_info_get_ack_status(const FuStructSunwinonDfuRspGetInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_sunwinon_dfu_rsp_get_info_get_info_that_this_program_dont_care: (skip):
 **/
const guint8 *
fu_struct_sunwinon_dfu_rsp_get_info_get_info_that_this_program_dont_care(const FuStructSunwinonDfuRspGetInfo *st, gsize *bufsz)
{
    g_return_val_if_fail(st != NULL, NULL);
    if (bufsz != NULL)
        *bufsz = 19;
    return st->buf->data + 1;
}

/* setters */
/**
 * fu_struct_sunwinon_dfu_rsp_get_info_to_string: (skip):
 **/
static gchar *
fu_struct_sunwinon_dfu_rsp_get_info_to_string(const FuStructSunwinonDfuRspGetInfo *st)
{
    g_autoptr(GString) str = g_string_new("FuStructSunwinonDfuRspGetInfo:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_sunwinon_dfu_ack_to_string(fu_struct_sunwinon_dfu_rsp_get_info_get_ack_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  ack_status: 0x%x [%s]\n", (guint) fu_struct_sunwinon_dfu_rsp_get_info_get_ack_status(st), tmp);
        } else {
            g_string_append_printf(str, "  ack_status: 0x%x\n", (guint) fu_struct_sunwinon_dfu_rsp_get_info_get_ack_status(st));
        }
    }
    {
        gsize bufsz = 0;
        const guint8 *buf = fu_struct_sunwinon_dfu_rsp_get_info_get_info_that_this_program_dont_care(st, &bufsz);
        g_autoptr(GString) tmp = g_string_new(NULL);
        for (gsize i = 0; i < bufsz; i++)
            g_string_append_printf(tmp, "%02X", buf[i]);
        g_string_append_printf(str, "  info_that_this_program_dont_care: 0x%s\n", tmp->str);
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_sunwinon_dfu_rsp_get_info_validate_internal(FuStructSunwinonDfuRspGetInfo *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    return TRUE;
}
static gboolean
fu_struct_sunwinon_dfu_rsp_get_info_parse_internal(FuStructSunwinonDfuRspGetInfo *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_sunwinon_dfu_rsp_get_info_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_sunwinon_dfu_rsp_get_info_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_sunwinon_dfu_rsp_get_info_parse: (skip):
 **/
FuStructSunwinonDfuRspGetInfo *
fu_struct_sunwinon_dfu_rsp_get_info_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructSunwinonDfuRspGetInfo) st = fu_struct_sunwinon_dfu_rsp_get_info_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 20, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructSunwinonDfuRspGetInfo: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 20);
    if (!fu_struct_sunwinon_dfu_rsp_get_info_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_sunwinon_dfu_boot_info_flags_ref: (skip):
 **/
FuStructSunwinonDfuBootInfoFlags *
fu_struct_sunwinon_dfu_boot_info_flags_ref(FuStructSunwinonDfuBootInfoFlags *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_sunwinon_dfu_boot_info_flags_unref: (skip):
 **/
void
fu_struct_sunwinon_dfu_boot_info_flags_unref(FuStructSunwinonDfuBootInfoFlags *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructSunwinonDfuBootInfoFlags refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_sunwinon_dfu_boot_info_flags_new_internal: (skip):
 **/
static FuStructSunwinonDfuBootInfoFlags *
fu_struct_sunwinon_dfu_boot_info_flags_new_internal(void)
{
    FuStructSunwinonDfuBootInfoFlags *st = g_new0(FuStructSunwinonDfuBootInfoFlags, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_sunwinon_dfu_boot_info_flags_get_xqspi_speed: (skip):
 **/
guint32
fu_struct_sunwinon_dfu_boot_info_flags_get_xqspi_speed(const FuStructSunwinonDfuBootInfoFlags *st)
{
    guint32 val;
    g_return_val_if_fail(st != NULL, 0x0);
    g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0);
    val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN);
    return (val >> 0) & 15;
}
/**
 * fu_struct_sunwinon_dfu_boot_info_flags_get_code_copy_mode: (skip):
 **/
guint32
fu_struct_sunwinon_dfu_boot_info_flags_get_code_copy_mode(const FuStructSunwinonDfuBootInfoFlags *st)
{
    guint32 val;
    g_return_val_if_fail(st != NULL, 0x0);
    g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0);
    val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN);
    return (val >> 4) & 1;
}
/**
 * fu_struct_sunwinon_dfu_boot_info_flags_get_system_clk: (skip):
 **/
guint32
fu_struct_sunwinon_dfu_boot_info_flags_get_system_clk(const FuStructSunwinonDfuBootInfoFlags *st)
{
    guint32 val;
    g_return_val_if_fail(st != NULL, 0x0);
    g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0);
    val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN);
    return (val >> 5) & 7;
}
/**
 * fu_struct_sunwinon_dfu_boot_info_flags_get_check_image: (skip):
 **/
guint32
fu_struct_sunwinon_dfu_boot_info_flags_get_check_image(const FuStructSunwinonDfuBootInfoFlags *st)
{
    guint32 val;
    g_return_val_if_fail(st != NULL, 0x0);
    g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0);
    val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN);
    return (val >> 8) & 1;
}
/**
 * fu_struct_sunwinon_dfu_boot_info_flags_get_boot_delay: (skip):
 **/
guint32
fu_struct_sunwinon_dfu_boot_info_flags_get_boot_delay(const FuStructSunwinonDfuBootInfoFlags *st)
{
    guint32 val;
    g_return_val_if_fail(st != NULL, 0x0);
    g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0);
    val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN);
    return (val >> 9) & 1;
}
/**
 * fu_struct_sunwinon_dfu_boot_info_flags_get_signature_algorithm: (skip):
 **/
guint32
fu_struct_sunwinon_dfu_boot_info_flags_get_signature_algorithm(const FuStructSunwinonDfuBootInfoFlags *st)
{
    guint32 val;
    g_return_val_if_fail(st != NULL, 0x0);
    g_return_val_if_fail(st->buf->len >= sizeof(guint32), 0x0);
    val = fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN);
    return (val >> 10) & 3;
}

/* setters */
/**
 * fu_struct_sunwinon_dfu_boot_info_flags_to_string: (skip):
 **/
static gchar *
fu_struct_sunwinon_dfu_boot_info_flags_to_string(const FuStructSunwinonDfuBootInfoFlags *st)
{
    g_autoptr(GString) str = g_string_new("FuStructSunwinonDfuBootInfoFlags:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  xqspi_speed: 0x%x\n",
                           (guint) fu_struct_sunwinon_dfu_boot_info_flags_get_xqspi_speed(st));
    g_string_append_printf(str, "  code_copy_mode: 0x%x\n",
                           (guint) fu_struct_sunwinon_dfu_boot_info_flags_get_code_copy_mode(st));
    g_string_append_printf(str, "  system_clk: 0x%x\n",
                           (guint) fu_struct_sunwinon_dfu_boot_info_flags_get_system_clk(st));
    g_string_append_printf(str, "  check_image: 0x%x\n",
                           (guint) fu_struct_sunwinon_dfu_boot_info_flags_get_check_image(st));
    g_string_append_printf(str, "  boot_delay: 0x%x\n",
                           (guint) fu_struct_sunwinon_dfu_boot_info_flags_get_boot_delay(st));
    g_string_append_printf(str, "  signature_algorithm: 0x%x\n",
                           (guint) fu_struct_sunwinon_dfu_boot_info_flags_get_signature_algorithm(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_sunwinon_dfu_boot_info_flags_validate_internal(FuStructSunwinonDfuBootInfoFlags *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    return TRUE;
}
/**
 * fu_struct_sunwinon_dfu_rsp_system_info_ref: (skip):
 **/
FuStructSunwinonDfuRspSystemInfo *
fu_struct_sunwinon_dfu_rsp_system_info_ref(FuStructSunwinonDfuRspSystemInfo *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_sunwinon_dfu_rsp_system_info_unref: (skip):
 **/
void
fu_struct_sunwinon_dfu_rsp_system_info_unref(FuStructSunwinonDfuRspSystemInfo *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructSunwinonDfuRspSystemInfo refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_sunwinon_dfu_rsp_system_info_new_internal: (skip):
 **/
static FuStructSunwinonDfuRspSystemInfo *
fu_struct_sunwinon_dfu_rsp_system_info_new_internal(void)
{
    FuStructSunwinonDfuRspSystemInfo *st = g_new0(FuStructSunwinonDfuRspSystemInfo, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_sunwinon_dfu_rsp_system_info_get_ack_status: (skip):
 **/
FuSunwinonDfuAck
fu_struct_sunwinon_dfu_rsp_system_info_get_ack_status(const FuStructSunwinonDfuRspSystemInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_sunwinon_dfu_rsp_system_info_get_opcode: (skip):
 **/
guint8
fu_struct_sunwinon_dfu_rsp_system_info_get_opcode(const FuStructSunwinonDfuRspSystemInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[1];
}
/**
 * fu_struct_sunwinon_dfu_rsp_system_info_get_start_addr: (skip):
 **/
guint32
fu_struct_sunwinon_dfu_rsp_system_info_get_start_addr(const FuStructSunwinonDfuRspSystemInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 2, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_rsp_system_info_get_length: (skip):
 **/
static guint16
fu_struct_sunwinon_dfu_rsp_system_info_get_length(const FuStructSunwinonDfuRspSystemInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 6, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_rsp_system_info_get_bin_size: (skip):
 **/
guint32
fu_struct_sunwinon_dfu_rsp_system_info_get_bin_size(const FuStructSunwinonDfuRspSystemInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 8, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_rsp_system_info_get_checksum: (skip):
 **/
guint32
fu_struct_sunwinon_dfu_rsp_system_info_get_checksum(const FuStructSunwinonDfuRspSystemInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 12, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_rsp_system_info_get_load_addr: (skip):
 **/
guint32
fu_struct_sunwinon_dfu_rsp_system_info_get_load_addr(const FuStructSunwinonDfuRspSystemInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 16, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_rsp_system_info_get_run_addr: (skip):
 **/
guint32
fu_struct_sunwinon_dfu_rsp_system_info_get_run_addr(const FuStructSunwinonDfuRspSystemInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 20, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_rsp_system_info_get_xqspi_xip_cmd: (skip):
 **/
guint32
fu_struct_sunwinon_dfu_rsp_system_info_get_xqspi_xip_cmd(const FuStructSunwinonDfuRspSystemInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 24, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_rsp_system_info_get_flags: (skip):
 **/
FuStructSunwinonDfuBootInfoFlags *
fu_struct_sunwinon_dfu_rsp_system_info_get_flags(const FuStructSunwinonDfuRspSystemInfo *st)
{
    g_autoptr(FuStructSunwinonDfuBootInfoFlags) st_tmp = fu_struct_sunwinon_dfu_boot_info_flags_new_internal();
    g_return_val_if_fail(st != NULL, NULL);
    st_tmp->buf = g_byte_array_new();
    g_byte_array_append(st_tmp->buf, st->buf->data + FU_STRUCT_SUNWINON_DFU_RSP_SYSTEM_INFO_OFFSET_FLAGS, 4);
    return g_steal_pointer(&st_tmp);
}

/* setters */
/**
 * fu_struct_sunwinon_dfu_rsp_system_info_to_string: (skip):
 **/
static gchar *
fu_struct_sunwinon_dfu_rsp_system_info_to_string(const FuStructSunwinonDfuRspSystemInfo *st)
{
    g_autoptr(GString) str = g_string_new("FuStructSunwinonDfuRspSystemInfo:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_sunwinon_dfu_ack_to_string(fu_struct_sunwinon_dfu_rsp_system_info_get_ack_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  ack_status: 0x%x [%s]\n", (guint) fu_struct_sunwinon_dfu_rsp_system_info_get_ack_status(st), tmp);
        } else {
            g_string_append_printf(str, "  ack_status: 0x%x\n", (guint) fu_struct_sunwinon_dfu_rsp_system_info_get_ack_status(st));
        }
    }
    g_string_append_printf(str, "  opcode: 0x%x\n",
                           (guint) fu_struct_sunwinon_dfu_rsp_system_info_get_opcode(st));
    g_string_append_printf(str, "  start_addr: 0x%x\n",
                           (guint) fu_struct_sunwinon_dfu_rsp_system_info_get_start_addr(st));
    g_string_append_printf(str, "  length: 0x%x\n",
                           (guint) fu_struct_sunwinon_dfu_rsp_system_info_get_length(st));
    g_string_append_printf(str, "  bin_size: 0x%x\n",
                           (guint) fu_struct_sunwinon_dfu_rsp_system_info_get_bin_size(st));
    g_string_append_printf(str, "  checksum: 0x%x\n",
                           (guint) fu_struct_sunwinon_dfu_rsp_system_info_get_checksum(st));
    g_string_append_printf(str, "  load_addr: 0x%x\n",
                           (guint) fu_struct_sunwinon_dfu_rsp_system_info_get_load_addr(st));
    g_string_append_printf(str, "  run_addr: 0x%x\n",
                           (guint) fu_struct_sunwinon_dfu_rsp_system_info_get_run_addr(st));
    g_string_append_printf(str, "  xqspi_xip_cmd: 0x%x\n",
                           (guint) fu_struct_sunwinon_dfu_rsp_system_info_get_xqspi_xip_cmd(st));
    {
        g_autoptr(FuStructSunwinonDfuBootInfoFlags) st_tmp = fu_struct_sunwinon_dfu_rsp_system_info_get_flags(st);
        g_autofree gchar *tmp = fu_struct_sunwinon_dfu_boot_info_flags_to_string(st_tmp);
        g_string_append_printf(str, "  flags: %s\n", tmp);
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_sunwinon_dfu_rsp_system_info_validate_internal(FuStructSunwinonDfuRspSystemInfo *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_sunwinon_dfu_rsp_system_info_get_length(st) != 0x30) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructSunwinonDfuRspSystemInfo.length was not valid, "
                    "expected 0x%x and got 0x%x",
                    (guint) 0x30,
                    (guint) fu_struct_sunwinon_dfu_rsp_system_info_get_length(st));
        return FALSE;
    }
    {
        GByteArray buf_tmp = {
            .data = (guint8*) st->buf->data + 0x1C,
            .len = 4,
        };
        FuStructSunwinonDfuBootInfoFlags st_tmp = { .buf = &buf_tmp };
        if (!fu_struct_sunwinon_dfu_boot_info_flags_validate_internal(&st_tmp, error))
            return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_sunwinon_dfu_rsp_system_info_parse_internal(FuStructSunwinonDfuRspSystemInfo *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_sunwinon_dfu_rsp_system_info_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_sunwinon_dfu_rsp_system_info_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_sunwinon_dfu_rsp_system_info_parse: (skip):
 **/
FuStructSunwinonDfuRspSystemInfo *
fu_struct_sunwinon_dfu_rsp_system_info_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructSunwinonDfuRspSystemInfo) st = fu_struct_sunwinon_dfu_rsp_system_info_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 56, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructSunwinonDfuRspSystemInfo: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 56);
    if (!fu_struct_sunwinon_dfu_rsp_system_info_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_sunwinon_dfu_image_info_ref: (skip):
 **/
FuStructSunwinonDfuImageInfo *
fu_struct_sunwinon_dfu_image_info_ref(FuStructSunwinonDfuImageInfo *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_sunwinon_dfu_image_info_unref: (skip):
 **/
void
fu_struct_sunwinon_dfu_image_info_unref(FuStructSunwinonDfuImageInfo *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructSunwinonDfuImageInfo refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_sunwinon_dfu_image_info_new_internal: (skip):
 **/
static FuStructSunwinonDfuImageInfo *
fu_struct_sunwinon_dfu_image_info_new_internal(void)
{
    FuStructSunwinonDfuImageInfo *st = g_new0(FuStructSunwinonDfuImageInfo, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_sunwinon_dfu_image_info_get_pattern: (skip):
 **/
static guint16
fu_struct_sunwinon_dfu_image_info_get_pattern(const FuStructSunwinonDfuImageInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 0, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_image_info_get_version: (skip):
 **/
guint16
fu_struct_sunwinon_dfu_image_info_get_version(const FuStructSunwinonDfuImageInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 2, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_image_info_get_bin_size: (skip):
 **/
guint32
fu_struct_sunwinon_dfu_image_info_get_bin_size(const FuStructSunwinonDfuImageInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 4, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_image_info_get_checksum: (skip):
 **/
guint32
fu_struct_sunwinon_dfu_image_info_get_checksum(const FuStructSunwinonDfuImageInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 8, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_image_info_get_load_addr: (skip):
 **/
guint32
fu_struct_sunwinon_dfu_image_info_get_load_addr(const FuStructSunwinonDfuImageInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 12, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_image_info_get_run_addr: (skip):
 **/
guint32
fu_struct_sunwinon_dfu_image_info_get_run_addr(const FuStructSunwinonDfuImageInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 16, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_image_info_get_xqspi_xip_cmd: (skip):
 **/
guint32
fu_struct_sunwinon_dfu_image_info_get_xqspi_xip_cmd(const FuStructSunwinonDfuImageInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 20, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_image_info_get_flags: (skip):
 **/
FuStructSunwinonDfuBootInfoFlags *
fu_struct_sunwinon_dfu_image_info_get_flags(const FuStructSunwinonDfuImageInfo *st)
{
    g_autoptr(FuStructSunwinonDfuBootInfoFlags) st_tmp = fu_struct_sunwinon_dfu_boot_info_flags_new_internal();
    g_return_val_if_fail(st != NULL, NULL);
    st_tmp->buf = g_byte_array_new();
    g_byte_array_append(st_tmp->buf, st->buf->data + FU_STRUCT_SUNWINON_DFU_IMAGE_INFO_OFFSET_FLAGS, 4);
    return g_steal_pointer(&st_tmp);
}
/**
 * fu_struct_sunwinon_dfu_image_info_get_comments: (skip):
 **/
gchar *
fu_struct_sunwinon_dfu_image_info_get_comments(const FuStructSunwinonDfuImageInfo *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    return fu_memstrsafe(st->buf->data, st->buf->len, 28, 12, NULL);
}

/* setters */
/**
 * fu_struct_sunwinon_dfu_image_info_set_version: (skip):
 **/
void
fu_struct_sunwinon_dfu_image_info_set_version(FuStructSunwinonDfuImageInfo *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_image_info_set_bin_size: (skip):
 **/
void
fu_struct_sunwinon_dfu_image_info_set_bin_size(FuStructSunwinonDfuImageInfo *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 4, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_image_info_set_checksum: (skip):
 **/
void
fu_struct_sunwinon_dfu_image_info_set_checksum(FuStructSunwinonDfuImageInfo *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 8, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_image_info_set_load_addr: (skip):
 **/
void
fu_struct_sunwinon_dfu_image_info_set_load_addr(FuStructSunwinonDfuImageInfo *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 12, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_image_info_set_run_addr: (skip):
 **/
void
fu_struct_sunwinon_dfu_image_info_set_run_addr(FuStructSunwinonDfuImageInfo *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 16, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_image_info_set_xqspi_xip_cmd: (skip):
 **/
void
fu_struct_sunwinon_dfu_image_info_set_xqspi_xip_cmd(FuStructSunwinonDfuImageInfo *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 20, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_image_info_set_flags: (skip):
 **/
gboolean
fu_struct_sunwinon_dfu_image_info_set_flags(FuStructSunwinonDfuImageInfo *st, const FuStructSunwinonDfuBootInfoFlags *st_donor, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    g_return_val_if_fail(st_donor != NULL, FALSE);
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);

    if (st_donor->buf->len > FU_STRUCT_SUNWINON_DFU_BOOT_INFO_FLAGS_SIZE) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "donor 'FuStructSunwinonDfuBootInfoFlags' (0x%x bytes) does not fit in "
                    "FuStructSunwinonDfuImageInfo.flags (0x%x bytes)",
                    (guint) st_donor->buf->len,
                    (guint) FU_STRUCT_SUNWINON_DFU_BOOT_INFO_FLAGS_SIZE);
        return FALSE;
    }
    memcpy(st->buf->data + FU_STRUCT_SUNWINON_DFU_IMAGE_INFO_OFFSET_FLAGS, st_donor->buf->data, st_donor->buf->len);
    return TRUE;
}
/**
 * fu_struct_sunwinon_dfu_image_info_set_comments: (skip):
 **/
gboolean
fu_struct_sunwinon_dfu_image_info_set_comments(FuStructSunwinonDfuImageInfo *st, const gchar *value, GError **error)
{
    gsize len;
    g_return_val_if_fail(st != NULL, FALSE);
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
    if (value == NULL) {
        memset(st->buf->data + 28, 0x0, 12);
        return TRUE;
    }
    len = strlen(value);
    if (len > 12) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "string '%s' (0x%x bytes) does not fit in FuStructSunwinonDfuImageInfo.comments (0x%x bytes)",
                    value, (guint) len, (guint) 12);
        return FALSE;
    }
    return fu_memcpy_safe(st->buf->data, st->buf->len, 28, (const guint8 *)value, len, 0x0, len, error);
}
/**
 * fu_struct_sunwinon_dfu_image_info_to_string: (skip):
 **/
static gchar *
fu_struct_sunwinon_dfu_image_info_to_string(const FuStructSunwinonDfuImageInfo *st)
{
    g_autoptr(GString) str = g_string_new("FuStructSunwinonDfuImageInfo:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  pattern: 0x%x\n",
                           (guint) fu_struct_sunwinon_dfu_image_info_get_pattern(st));
    g_string_append_printf(str, "  version: 0x%x\n",
                           (guint) fu_struct_sunwinon_dfu_image_info_get_version(st));
    g_string_append_printf(str, "  bin_size: 0x%x\n",
                           (guint) fu_struct_sunwinon_dfu_image_info_get_bin_size(st));
    g_string_append_printf(str, "  checksum: 0x%x\n",
                           (guint) fu_struct_sunwinon_dfu_image_info_get_checksum(st));
    g_string_append_printf(str, "  load_addr: 0x%x\n",
                           (guint) fu_struct_sunwinon_dfu_image_info_get_load_addr(st));
    g_string_append_printf(str, "  run_addr: 0x%x\n",
                           (guint) fu_struct_sunwinon_dfu_image_info_get_run_addr(st));
    g_string_append_printf(str, "  xqspi_xip_cmd: 0x%x\n",
                           (guint) fu_struct_sunwinon_dfu_image_info_get_xqspi_xip_cmd(st));
    {
        g_autoptr(FuStructSunwinonDfuBootInfoFlags) st_tmp = fu_struct_sunwinon_dfu_image_info_get_flags(st);
        g_autofree gchar *tmp = fu_struct_sunwinon_dfu_boot_info_flags_to_string(st_tmp);
        g_string_append_printf(str, "  flags: %s\n", tmp);
    }
    {
        g_autofree gchar *tmp = fu_struct_sunwinon_dfu_image_info_get_comments(st);
        if (tmp != NULL)
            g_string_append_printf(str, "  comments: %s\n", tmp);
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_sunwinon_dfu_image_info_validate_internal(FuStructSunwinonDfuImageInfo *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_sunwinon_dfu_image_info_get_pattern(st) != 0x4744) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructSunwinonDfuImageInfo.pattern was not valid, "
                    "expected 0x%x and got 0x%x",
                    (guint) 0x4744,
                    (guint) fu_struct_sunwinon_dfu_image_info_get_pattern(st));
        return FALSE;
    }
    {
        GByteArray buf_tmp = {
            .data = (guint8*) st->buf->data + 0x18,
            .len = 4,
        };
        FuStructSunwinonDfuBootInfoFlags st_tmp = { .buf = &buf_tmp };
        if (!fu_struct_sunwinon_dfu_boot_info_flags_validate_internal(&st_tmp, error))
            return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_sunwinon_dfu_image_info_parse_internal(FuStructSunwinonDfuImageInfo *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_sunwinon_dfu_image_info_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_sunwinon_dfu_image_info_validate_internal(st, error))
        return FALSE;
    return TRUE;
}
/**
 * fu_struct_sunwinon_dfu_image_info_parse_stream: (skip):
 **/
FuStructSunwinonDfuImageInfo *
fu_struct_sunwinon_dfu_image_info_parse_stream(GInputStream *stream, gsize offset, GError **error)
{
    g_autoptr(FuStructSunwinonDfuImageInfo) st = fu_struct_sunwinon_dfu_image_info_new_internal();
    st->buf = fu_input_stream_read_byte_array(stream, offset, 48, NULL, error);
    if (st->buf == NULL) {
        g_prefix_error(error, "FuStructSunwinonDfuImageInfo failed read of 0x%x: ", (guint) 48);
        return NULL;
    }
    if (st->buf->len != 48) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "FuStructSunwinonDfuImageInfo requested 0x%x and got 0x%x",
                    (guint) 48,
                    (guint) st->buf->len);
        return NULL;
    }
    if (!fu_struct_sunwinon_dfu_image_info_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_sunwinon_dfu_rsp_fw_info_get_ref: (skip):
 **/
FuStructSunwinonDfuRspFwInfoGet *
fu_struct_sunwinon_dfu_rsp_fw_info_get_ref(FuStructSunwinonDfuRspFwInfoGet *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_sunwinon_dfu_rsp_fw_info_get_unref: (skip):
 **/
void
fu_struct_sunwinon_dfu_rsp_fw_info_get_unref(FuStructSunwinonDfuRspFwInfoGet *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructSunwinonDfuRspFwInfoGet refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_sunwinon_dfu_rsp_fw_info_get_new_internal: (skip):
 **/
static FuStructSunwinonDfuRspFwInfoGet *
fu_struct_sunwinon_dfu_rsp_fw_info_get_new_internal(void)
{
    FuStructSunwinonDfuRspFwInfoGet *st = g_new0(FuStructSunwinonDfuRspFwInfoGet, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_sunwinon_dfu_rsp_fw_info_get_get_ack_status: (skip):
 **/
FuSunwinonDfuAck
fu_struct_sunwinon_dfu_rsp_fw_info_get_get_ack_status(const FuStructSunwinonDfuRspFwInfoGet *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_sunwinon_dfu_rsp_fw_info_get_get_dfu_save_addr: (skip):
 **/
guint32
fu_struct_sunwinon_dfu_rsp_fw_info_get_get_dfu_save_addr(const FuStructSunwinonDfuRspFwInfoGet *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 1, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_sunwinon_dfu_rsp_fw_info_get_get_run_position: (skip):
 **/
guint8
fu_struct_sunwinon_dfu_rsp_fw_info_get_get_run_position(const FuStructSunwinonDfuRspFwInfoGet *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[5];
}
/**
 * fu_struct_sunwinon_dfu_rsp_fw_info_get_get_image_info: (skip):
 **/
FuStructSunwinonDfuImageInfo *
fu_struct_sunwinon_dfu_rsp_fw_info_get_get_image_info(const FuStructSunwinonDfuRspFwInfoGet *st)
{
    g_autoptr(FuStructSunwinonDfuImageInfo) st_tmp = fu_struct_sunwinon_dfu_image_info_new_internal();
    g_return_val_if_fail(st != NULL, NULL);
    st_tmp->buf = g_byte_array_new();
    g_byte_array_append(st_tmp->buf, st->buf->data + FU_STRUCT_SUNWINON_DFU_RSP_FW_INFO_GET_OFFSET_IMAGE_INFO, 48);
    return g_steal_pointer(&st_tmp);
}

/* setters */
/**
 * fu_struct_sunwinon_dfu_rsp_fw_info_get_to_string: (skip):
 **/
static gchar *
fu_struct_sunwinon_dfu_rsp_fw_info_get_to_string(const FuStructSunwinonDfuRspFwInfoGet *st)
{
    g_autoptr(GString) str = g_string_new("FuStructSunwinonDfuRspFwInfoGet:\n");
    g_return_val_if_fail(st != NULL, NULL);
    {
        const gchar *tmp = fu_sunwinon_dfu_ack_to_string(fu_struct_sunwinon_dfu_rsp_fw_info_get_get_ack_status(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  ack_status: 0x%x [%s]\n", (guint) fu_struct_sunwinon_dfu_rsp_fw_info_get_get_ack_status(st), tmp);
        } else {
            g_string_append_printf(str, "  ack_status: 0x%x\n", (guint) fu_struct_sunwinon_dfu_rsp_fw_info_get_get_ack_status(st));
        }
    }
    g_string_append_printf(str, "  dfu_save_addr: 0x%x\n",
                           (guint) fu_struct_sunwinon_dfu_rsp_fw_info_get_get_dfu_save_addr(st));
    g_string_append_printf(str, "  run_position: 0x%x\n",
                           (guint) fu_struct_sunwinon_dfu_rsp_fw_info_get_get_run_position(st));
    {
        g_autoptr(FuStructSunwinonDfuImageInfo) st_tmp = fu_struct_sunwinon_dfu_rsp_fw_info_get_get_image_info(st);
        g_autofree gchar *tmp = fu_struct_sunwinon_dfu_image_info_to_string(st_tmp);
        g_string_append_printf(str, "  image_info: %s\n", tmp);
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_sunwinon_dfu_rsp_fw_info_get_validate_internal(FuStructSunwinonDfuRspFwInfoGet *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    {
        GByteArray buf_tmp = {
            .data = (guint8*) st->buf->data + 0x6,
            .len = 48,
        };
        FuStructSunwinonDfuImageInfo st_tmp = { .buf = &buf_tmp };
        if (!fu_struct_sunwinon_dfu_image_info_validate_internal(&st_tmp, error))
            return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_sunwinon_dfu_rsp_fw_info_get_parse_internal(FuStructSunwinonDfuRspFwInfoGet *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_sunwinon_dfu_rsp_fw_info_get_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_sunwinon_dfu_rsp_fw_info_get_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_sunwinon_dfu_rsp_fw_info_get_parse: (skip):
 **/
FuStructSunwinonDfuRspFwInfoGet *
fu_struct_sunwinon_dfu_rsp_fw_info_get_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructSunwinonDfuRspFwInfoGet) st = fu_struct_sunwinon_dfu_rsp_fw_info_get_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 54, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructSunwinonDfuRspFwInfoGet: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 54);
    if (!fu_struct_sunwinon_dfu_rsp_fw_info_get_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
