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

#include "config.h"

#include <glib.h>

#include "fu-algoltek-usbcr-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_struct_ag_usbcr_firmware_hdr_ref: (skip):
 **/
FuStructAgUsbcrFirmwareHdr *
fu_struct_ag_usbcr_firmware_hdr_ref(FuStructAgUsbcrFirmwareHdr *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_ag_usbcr_firmware_hdr_unref: (skip):
 **/
void
fu_struct_ag_usbcr_firmware_hdr_unref(FuStructAgUsbcrFirmwareHdr *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructAgUsbcrFirmwareHdr refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_ag_usbcr_firmware_hdr_new_internal: (skip):
 **/
static FuStructAgUsbcrFirmwareHdr *
fu_struct_ag_usbcr_firmware_hdr_new_internal(void)
{
    FuStructAgUsbcrFirmwareHdr *st = g_new0(FuStructAgUsbcrFirmwareHdr, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_ag_usbcr_firmware_hdr_get_fw_addr: (skip):
 **/
guint16
fu_struct_ag_usbcr_firmware_hdr_get_fw_addr(const FuStructAgUsbcrFirmwareHdr *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 11, G_BIG_ENDIAN);
}
/**
 * fu_struct_ag_usbcr_firmware_hdr_get_fw_len: (skip):
 **/
guint16
fu_struct_ag_usbcr_firmware_hdr_get_fw_len(const FuStructAgUsbcrFirmwareHdr *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 13, G_BIG_ENDIAN);
}
/**
 * fu_struct_ag_usbcr_firmware_hdr_get_emmc_ver: (skip):
 **/
guint16
fu_struct_ag_usbcr_firmware_hdr_get_emmc_ver(const FuStructAgUsbcrFirmwareHdr *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 510, G_LITTLE_ENDIAN);
}

/* setters */
/**
 * fu_struct_ag_usbcr_firmware_hdr_set_fw_addr: (skip):
 **/
void
fu_struct_ag_usbcr_firmware_hdr_set_fw_addr(FuStructAgUsbcrFirmwareHdr *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 11, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_ag_usbcr_firmware_hdr_set_fw_len: (skip):
 **/
void
fu_struct_ag_usbcr_firmware_hdr_set_fw_len(FuStructAgUsbcrFirmwareHdr *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 13, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_ag_usbcr_firmware_hdr_set_emmc_ver: (skip):
 **/
void
fu_struct_ag_usbcr_firmware_hdr_set_emmc_ver(FuStructAgUsbcrFirmwareHdr *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 510, value, G_LITTLE_ENDIAN);
}
/**
 * fu_struct_ag_usbcr_firmware_hdr_new: (skip):
 **/
FuStructAgUsbcrFirmwareHdr *
fu_struct_ag_usbcr_firmware_hdr_new(void)
{
    FuStructAgUsbcrFirmwareHdr *st = fu_struct_ag_usbcr_firmware_hdr_new_internal();
    st->buf = g_byte_array_sized_new(512);
    fu_byte_array_set_size(st->buf, 512, 0x0);
    fu_struct_ag_usbcr_firmware_hdr_set_emmc_ver(st, 0x123);
    return st;
}
/**
 * fu_struct_ag_usbcr_firmware_hdr_to_string: (skip):
 **/
static gchar *
fu_struct_ag_usbcr_firmware_hdr_to_string(const FuStructAgUsbcrFirmwareHdr *st)
{
    g_autoptr(GString) str = g_string_new("FuStructAgUsbcrFirmwareHdr:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  fw_addr: 0x%x\n",
                           (guint) fu_struct_ag_usbcr_firmware_hdr_get_fw_addr(st));
    g_string_append_printf(str, "  fw_len: 0x%x\n",
                           (guint) fu_struct_ag_usbcr_firmware_hdr_get_fw_len(st));
    g_string_append_printf(str, "  emmc_ver: 0x%x\n",
                           (guint) fu_struct_ag_usbcr_firmware_hdr_get_emmc_ver(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_ag_usbcr_firmware_hdr_validate_internal(FuStructAgUsbcrFirmwareHdr *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    return TRUE;
}
static gboolean
fu_struct_ag_usbcr_firmware_hdr_parse_internal(FuStructAgUsbcrFirmwareHdr *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_ag_usbcr_firmware_hdr_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_ag_usbcr_firmware_hdr_validate_internal(st, error))
        return FALSE;
    return TRUE;
}
/**
 * fu_struct_ag_usbcr_firmware_hdr_parse_stream: (skip):
 **/
FuStructAgUsbcrFirmwareHdr *
fu_struct_ag_usbcr_firmware_hdr_parse_stream(GInputStream *stream, gsize offset, GError **error)
{
    g_autoptr(FuStructAgUsbcrFirmwareHdr) st = fu_struct_ag_usbcr_firmware_hdr_new_internal();
    st->buf = fu_input_stream_read_byte_array(stream, offset, 512, NULL, error);
    if (st->buf == NULL) {
        g_prefix_error(error, "FuStructAgUsbcrFirmwareHdr failed read of 0x%x: ", (guint) 512);
        return NULL;
    }
    if (st->buf->len != 512) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "FuStructAgUsbcrFirmwareHdr requested 0x%x and got 0x%x",
                    (guint) 512,
                    (guint) st->buf->len);
        return NULL;
    }
    if (!fu_struct_ag_usbcr_firmware_hdr_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_ag_usbcr_firmware_info_ref: (skip):
 **/
FuStructAgUsbcrFirmwareInfo *
fu_struct_ag_usbcr_firmware_info_ref(FuStructAgUsbcrFirmwareInfo *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_ag_usbcr_firmware_info_unref: (skip):
 **/
void
fu_struct_ag_usbcr_firmware_info_unref(FuStructAgUsbcrFirmwareInfo *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructAgUsbcrFirmwareInfo refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_ag_usbcr_firmware_info_new_internal: (skip):
 **/
static FuStructAgUsbcrFirmwareInfo *
fu_struct_ag_usbcr_firmware_info_new_internal(void)
{
    FuStructAgUsbcrFirmwareInfo *st = g_new0(FuStructAgUsbcrFirmwareInfo, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_ag_usbcr_firmware_info_get_app_ver: (skip):
 **/
guint16
fu_struct_ag_usbcr_firmware_info_get_app_ver(const FuStructAgUsbcrFirmwareInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 0, G_BIG_ENDIAN);
}
/**
 * fu_struct_ag_usbcr_firmware_info_get_boot_ver: (skip):
 **/
guint16
fu_struct_ag_usbcr_firmware_info_get_boot_ver(const FuStructAgUsbcrFirmwareInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 2, G_BIG_ENDIAN);
}
/**
 * fu_struct_ag_usbcr_firmware_info_get_emmc_support_ver: (skip):
 **/
guint16
fu_struct_ag_usbcr_firmware_info_get_emmc_support_ver(const FuStructAgUsbcrFirmwareInfo *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 44, G_BIG_ENDIAN);
}

/* setters */
/**
 * fu_struct_ag_usbcr_firmware_info_set_app_ver: (skip):
 **/
void
fu_struct_ag_usbcr_firmware_info_set_app_ver(FuStructAgUsbcrFirmwareInfo *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 0, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_ag_usbcr_firmware_info_set_boot_ver: (skip):
 **/
void
fu_struct_ag_usbcr_firmware_info_set_boot_ver(FuStructAgUsbcrFirmwareInfo *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_ag_usbcr_firmware_info_set_emmc_support_ver: (skip):
 **/
void
fu_struct_ag_usbcr_firmware_info_set_emmc_support_ver(FuStructAgUsbcrFirmwareInfo *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 44, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_ag_usbcr_firmware_info_new: (skip):
 **/
FuStructAgUsbcrFirmwareInfo *
fu_struct_ag_usbcr_firmware_info_new(void)
{
    FuStructAgUsbcrFirmwareInfo *st = fu_struct_ag_usbcr_firmware_info_new_internal();
    st->buf = g_byte_array_sized_new(51);
    fu_byte_array_set_size(st->buf, 51, 0x0);
    fu_struct_ag_usbcr_firmware_info_set_emmc_support_ver(st, 0x123);
    return st;
}
/**
 * fu_struct_ag_usbcr_firmware_info_to_string: (skip):
 **/
static gchar *
fu_struct_ag_usbcr_firmware_info_to_string(const FuStructAgUsbcrFirmwareInfo *st)
{
    g_autoptr(GString) str = g_string_new("FuStructAgUsbcrFirmwareInfo:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  app_ver: 0x%x\n",
                           (guint) fu_struct_ag_usbcr_firmware_info_get_app_ver(st));
    g_string_append_printf(str, "  boot_ver: 0x%x\n",
                           (guint) fu_struct_ag_usbcr_firmware_info_get_boot_ver(st));
    g_string_append_printf(str, "  emmc_support_ver: 0x%x\n",
                           (guint) fu_struct_ag_usbcr_firmware_info_get_emmc_support_ver(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_ag_usbcr_firmware_info_validate_internal(FuStructAgUsbcrFirmwareInfo *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    return TRUE;
}
static gboolean
fu_struct_ag_usbcr_firmware_info_parse_internal(FuStructAgUsbcrFirmwareInfo *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_ag_usbcr_firmware_info_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_ag_usbcr_firmware_info_validate_internal(st, error))
        return FALSE;
    return TRUE;
}
/**
 * fu_struct_ag_usbcr_firmware_info_parse_stream: (skip):
 **/
FuStructAgUsbcrFirmwareInfo *
fu_struct_ag_usbcr_firmware_info_parse_stream(GInputStream *stream, gsize offset, GError **error)
{
    g_autoptr(FuStructAgUsbcrFirmwareInfo) st = fu_struct_ag_usbcr_firmware_info_new_internal();
    st->buf = fu_input_stream_read_byte_array(stream, offset, 51, NULL, error);
    if (st->buf == NULL) {
        g_prefix_error(error, "FuStructAgUsbcrFirmwareInfo failed read of 0x%x: ", (guint) 51);
        return NULL;
    }
    if (st->buf->len != 51) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "FuStructAgUsbcrFirmwareInfo requested 0x%x and got 0x%x",
                    (guint) 51,
                    (guint) st->buf->len);
        return NULL;
    }
    if (!fu_struct_ag_usbcr_firmware_info_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_ag_usbcr_firmware_revision_cdb_ref: (skip):
 **/
FuStructAgUsbcrFirmwareRevisionCdb *
fu_struct_ag_usbcr_firmware_revision_cdb_ref(FuStructAgUsbcrFirmwareRevisionCdb *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_ag_usbcr_firmware_revision_cdb_unref: (skip):
 **/
void
fu_struct_ag_usbcr_firmware_revision_cdb_unref(FuStructAgUsbcrFirmwareRevisionCdb *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructAgUsbcrFirmwareRevisionCdb refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_ag_usbcr_firmware_revision_cdb_new_internal: (skip):
 **/
static FuStructAgUsbcrFirmwareRevisionCdb *
fu_struct_ag_usbcr_firmware_revision_cdb_new_internal(void)
{
    FuStructAgUsbcrFirmwareRevisionCdb *st = g_new0(FuStructAgUsbcrFirmwareRevisionCdb, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_ag_usbcr_firmware_revision_cdb_set_opcode: (skip):
 **/
static void
fu_struct_ag_usbcr_firmware_revision_cdb_set_opcode(FuStructAgUsbcrFirmwareRevisionCdb *st, FuAgUsbcrScsiopVendor value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_ag_usbcr_firmware_revision_cdb_set_subopcode: (skip):
 **/
static void
fu_struct_ag_usbcr_firmware_revision_cdb_set_subopcode(FuStructAgUsbcrFirmwareRevisionCdb *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_ag_usbcr_firmware_revision_cdb_set_sig: (skip):
 **/
static void
fu_struct_ag_usbcr_firmware_revision_cdb_set_sig(FuStructAgUsbcrFirmwareRevisionCdb *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_ag_usbcr_firmware_revision_cdb_set_cmd: (skip):
 **/
void
fu_struct_ag_usbcr_firmware_revision_cdb_set_cmd(FuStructAgUsbcrFirmwareRevisionCdb *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_ag_usbcr_firmware_revision_cdb_set_subcmd: (skip):
 **/
void
fu_struct_ag_usbcr_firmware_revision_cdb_set_subcmd(FuStructAgUsbcrFirmwareRevisionCdb *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[5] = value;
}
/**
 * fu_struct_ag_usbcr_firmware_revision_cdb_set_sig2: (skip):
 **/
static void
fu_struct_ag_usbcr_firmware_revision_cdb_set_sig2(FuStructAgUsbcrFirmwareRevisionCdb *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 6, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_ag_usbcr_firmware_revision_cdb_set_ramdest: (skip):
 **/
void
fu_struct_ag_usbcr_firmware_revision_cdb_set_ramdest(FuStructAgUsbcrFirmwareRevisionCdb *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[10] = value;
}
/**
 * fu_struct_ag_usbcr_firmware_revision_cdb_set_addr: (skip):
 **/
void
fu_struct_ag_usbcr_firmware_revision_cdb_set_addr(FuStructAgUsbcrFirmwareRevisionCdb *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 11, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_ag_usbcr_firmware_revision_cdb_set_val: (skip):
 **/
void
fu_struct_ag_usbcr_firmware_revision_cdb_set_val(FuStructAgUsbcrFirmwareRevisionCdb *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[13] = value;
}
/**
 * fu_struct_ag_usbcr_firmware_revision_cdb_new: (skip):
 **/
FuStructAgUsbcrFirmwareRevisionCdb *
fu_struct_ag_usbcr_firmware_revision_cdb_new(void)
{
    FuStructAgUsbcrFirmwareRevisionCdb *st = fu_struct_ag_usbcr_firmware_revision_cdb_new_internal();
    st->buf = g_byte_array_sized_new(16);
    fu_byte_array_set_size(st->buf, 16, 0x0);
    fu_struct_ag_usbcr_firmware_revision_cdb_set_opcode(st, FU_AG_USBCR_SCSIOP_VENDOR_FIRMWARE_REVISION);
    fu_struct_ag_usbcr_firmware_revision_cdb_set_subopcode(st, 0x1F);
    fu_struct_ag_usbcr_firmware_revision_cdb_set_sig(st, 0x058F);
    fu_struct_ag_usbcr_firmware_revision_cdb_set_sig2(st, 0x30353846);
    return st;
}
/**
 * fu_struct_ag_usbcr_reg_cdb_ref: (skip):
 **/
FuStructAgUsbcrRegCdb *
fu_struct_ag_usbcr_reg_cdb_ref(FuStructAgUsbcrRegCdb *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_ag_usbcr_reg_cdb_unref: (skip):
 **/
void
fu_struct_ag_usbcr_reg_cdb_unref(FuStructAgUsbcrRegCdb *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructAgUsbcrRegCdb refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_ag_usbcr_reg_cdb_new_internal: (skip):
 **/
static FuStructAgUsbcrRegCdb *
fu_struct_ag_usbcr_reg_cdb_new_internal(void)
{
    FuStructAgUsbcrRegCdb *st = g_new0(FuStructAgUsbcrRegCdb, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_ag_usbcr_reg_cdb_set_opcode: (skip):
 **/
static void
fu_struct_ag_usbcr_reg_cdb_set_opcode(FuStructAgUsbcrRegCdb *st, FuAgUsbcrScsiopVendor value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_ag_usbcr_reg_cdb_set_subopcode: (skip):
 **/
static void
fu_struct_ag_usbcr_reg_cdb_set_subopcode(FuStructAgUsbcrRegCdb *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_ag_usbcr_reg_cdb_set_sig: (skip):
 **/
static void
fu_struct_ag_usbcr_reg_cdb_set_sig(FuStructAgUsbcrRegCdb *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_ag_usbcr_reg_cdb_set_cmd: (skip):
 **/
void
fu_struct_ag_usbcr_reg_cdb_set_cmd(FuStructAgUsbcrRegCdb *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_ag_usbcr_reg_cdb_set_subcmd: (skip):
 **/
void
fu_struct_ag_usbcr_reg_cdb_set_subcmd(FuStructAgUsbcrRegCdb *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[5] = value;
}
/**
 * fu_struct_ag_usbcr_reg_cdb_set_sig2: (skip):
 **/
static void
fu_struct_ag_usbcr_reg_cdb_set_sig2(FuStructAgUsbcrRegCdb *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 6, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_ag_usbcr_reg_cdb_set_ramdest: (skip):
 **/
void
fu_struct_ag_usbcr_reg_cdb_set_ramdest(FuStructAgUsbcrRegCdb *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[10] = value;
}
/**
 * fu_struct_ag_usbcr_reg_cdb_set_addr: (skip):
 **/
void
fu_struct_ag_usbcr_reg_cdb_set_addr(FuStructAgUsbcrRegCdb *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 11, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_ag_usbcr_reg_cdb_set_val: (skip):
 **/
void
fu_struct_ag_usbcr_reg_cdb_set_val(FuStructAgUsbcrRegCdb *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[13] = value;
}
/**
 * fu_struct_ag_usbcr_reg_cdb_new: (skip):
 **/
FuStructAgUsbcrRegCdb *
fu_struct_ag_usbcr_reg_cdb_new(void)
{
    FuStructAgUsbcrRegCdb *st = fu_struct_ag_usbcr_reg_cdb_new_internal();
    st->buf = g_byte_array_sized_new(16);
    fu_byte_array_set_size(st->buf, 16, 0x0);
    fu_struct_ag_usbcr_reg_cdb_set_opcode(st, FU_AG_USBCR_SCSIOP_VENDOR_GENERIC_CMD);
    fu_struct_ag_usbcr_reg_cdb_set_subopcode(st, 0x1F);
    fu_struct_ag_usbcr_reg_cdb_set_sig(st, 0x058F);
    fu_struct_ag_usbcr_reg_cdb_set_sig2(st, 0x30353846);
    return st;
}
/**
 * fu_struct_ag_usbcr_reset_cdb_ref: (skip):
 **/
FuStructAgUsbcrResetCdb *
fu_struct_ag_usbcr_reset_cdb_ref(FuStructAgUsbcrResetCdb *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_ag_usbcr_reset_cdb_unref: (skip):
 **/
void
fu_struct_ag_usbcr_reset_cdb_unref(FuStructAgUsbcrResetCdb *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructAgUsbcrResetCdb refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_ag_usbcr_reset_cdb_new_internal: (skip):
 **/
static FuStructAgUsbcrResetCdb *
fu_struct_ag_usbcr_reset_cdb_new_internal(void)
{
    FuStructAgUsbcrResetCdb *st = g_new0(FuStructAgUsbcrResetCdb, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_ag_usbcr_reset_cdb_set_opcode: (skip):
 **/
static void
fu_struct_ag_usbcr_reset_cdb_set_opcode(FuStructAgUsbcrResetCdb *st, FuAgUsbcrScsiopVendor value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_ag_usbcr_reset_cdb_set_subopcode: (skip):
 **/
static void
fu_struct_ag_usbcr_reset_cdb_set_subopcode(FuStructAgUsbcrResetCdb *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_ag_usbcr_reset_cdb_set_sig: (skip):
 **/
static void
fu_struct_ag_usbcr_reset_cdb_set_sig(FuStructAgUsbcrResetCdb *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_ag_usbcr_reset_cdb_set_cmd: (skip):
 **/
void
fu_struct_ag_usbcr_reset_cdb_set_cmd(FuStructAgUsbcrResetCdb *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_ag_usbcr_reset_cdb_set_subcmd: (skip):
 **/
void
fu_struct_ag_usbcr_reset_cdb_set_subcmd(FuStructAgUsbcrResetCdb *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[5] = value;
}
/**
 * fu_struct_ag_usbcr_reset_cdb_set_sig2: (skip):
 **/
static void
fu_struct_ag_usbcr_reset_cdb_set_sig2(FuStructAgUsbcrResetCdb *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint32(st->buf->data + 6, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_ag_usbcr_reset_cdb_set_val: (skip):
 **/
void
fu_struct_ag_usbcr_reset_cdb_set_val(FuStructAgUsbcrResetCdb *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[10] = value;
}
/**
 * fu_struct_ag_usbcr_reset_cdb_set_val2: (skip):
 **/
void
fu_struct_ag_usbcr_reset_cdb_set_val2(FuStructAgUsbcrResetCdb *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[11] = value;
}
/**
 * fu_struct_ag_usbcr_reset_cdb_new: (skip):
 **/
FuStructAgUsbcrResetCdb *
fu_struct_ag_usbcr_reset_cdb_new(void)
{
    FuStructAgUsbcrResetCdb *st = fu_struct_ag_usbcr_reset_cdb_new_internal();
    st->buf = g_byte_array_sized_new(16);
    fu_byte_array_set_size(st->buf, 16, 0x0);
    fu_struct_ag_usbcr_reset_cdb_set_opcode(st, FU_AG_USBCR_SCSIOP_VENDOR_GENERIC_CMD);
    fu_struct_ag_usbcr_reset_cdb_set_subopcode(st, 0x1F);
    fu_struct_ag_usbcr_reset_cdb_set_sig(st, 0x058F);
    fu_struct_ag_usbcr_reset_cdb_set_sig2(st, 0x30353846);
    return st;
}
/**
 * fu_struct_ag_usbcr_spi_cdb_ref: (skip):
 **/
FuStructAgUsbcrSpiCdb *
fu_struct_ag_usbcr_spi_cdb_ref(FuStructAgUsbcrSpiCdb *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_ag_usbcr_spi_cdb_unref: (skip):
 **/
void
fu_struct_ag_usbcr_spi_cdb_unref(FuStructAgUsbcrSpiCdb *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructAgUsbcrSpiCdb refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_ag_usbcr_spi_cdb_new_internal: (skip):
 **/
static FuStructAgUsbcrSpiCdb *
fu_struct_ag_usbcr_spi_cdb_new_internal(void)
{
    FuStructAgUsbcrSpiCdb *st = g_new0(FuStructAgUsbcrSpiCdb, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_ag_usbcr_spi_cdb_set_opcode: (skip):
 **/
static void
fu_struct_ag_usbcr_spi_cdb_set_opcode(FuStructAgUsbcrSpiCdb *st, FuAgUsbcrScsiopVendor value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_ag_usbcr_spi_cdb_set_subopcode: (skip):
 **/
static void
fu_struct_ag_usbcr_spi_cdb_set_subopcode(FuStructAgUsbcrSpiCdb *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[1] = value;
}
/**
 * fu_struct_ag_usbcr_spi_cdb_set_sig: (skip):
 **/
static void
fu_struct_ag_usbcr_spi_cdb_set_sig(FuStructAgUsbcrSpiCdb *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 2, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_ag_usbcr_spi_cdb_set_cmd: (skip):
 **/
void
fu_struct_ag_usbcr_spi_cdb_set_cmd(FuStructAgUsbcrSpiCdb *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_ag_usbcr_spi_cdb_set_addr: (skip):
 **/
void
fu_struct_ag_usbcr_spi_cdb_set_addr(FuStructAgUsbcrSpiCdb *st, guint16 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint16(st->buf->data + 5, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_ag_usbcr_spi_cdb_set_bufsz: (skip):
 **/
void
fu_struct_ag_usbcr_spi_cdb_set_bufsz(FuStructAgUsbcrSpiCdb *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[7] = value;
}
/**
 * fu_struct_ag_usbcr_spi_cdb_set_tag: (skip):
 **/
void
fu_struct_ag_usbcr_spi_cdb_set_tag(FuStructAgUsbcrSpiCdb *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[8] = value;
}
/**
 * fu_struct_ag_usbcr_spi_cdb_set_valid: (skip):
 **/
void
fu_struct_ag_usbcr_spi_cdb_set_valid(FuStructAgUsbcrSpiCdb *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[9] = value;
}
/**
 * fu_struct_ag_usbcr_spi_cdb_set_spisig1: (skip):
 **/
void
fu_struct_ag_usbcr_spi_cdb_set_spisig1(FuStructAgUsbcrSpiCdb *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[10] = value;
}
/**
 * fu_struct_ag_usbcr_spi_cdb_set_spisig2: (skip):
 **/
void
fu_struct_ag_usbcr_spi_cdb_set_spisig2(FuStructAgUsbcrSpiCdb *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[11] = value;
}
/**
 * fu_struct_ag_usbcr_spi_cdb_set_spicmd: (skip):
 **/
void
fu_struct_ag_usbcr_spi_cdb_set_spicmd(FuStructAgUsbcrSpiCdb *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[12] = value;
}
/**
 * fu_struct_ag_usbcr_spi_cdb_new: (skip):
 **/
FuStructAgUsbcrSpiCdb *
fu_struct_ag_usbcr_spi_cdb_new(void)
{
    FuStructAgUsbcrSpiCdb *st = fu_struct_ag_usbcr_spi_cdb_new_internal();
    st->buf = g_byte_array_sized_new(16);
    fu_byte_array_set_size(st->buf, 16, 0x0);
    fu_struct_ag_usbcr_spi_cdb_set_opcode(st, FU_AG_USBCR_SCSIOP_VENDOR_GENERIC_CMD);
    fu_struct_ag_usbcr_spi_cdb_set_subopcode(st, 0x1F);
    fu_struct_ag_usbcr_spi_cdb_set_sig(st, 0x058F);
    return st;
}
