On Wed, 22 Jul 2026 00:13:32 +0800, Tao Ding <[email protected]> wrote:
> diff --git a/hw/misc/k230_decomp_gzip.c b/hw/misc/k230_decomp_gzip.c
> new file mode 100644
> index 0000000000..4284262259
> --- /dev/null
> +++ b/hw/misc/k230_decomp_gzip.c
> @@ -0,0 +1,498 @@
> [ ... skip 184 lines ... ]
> +                                        s->output_buf, produced)) {
> +            return false;
> +        }
> +        s->output.current_offset += produced;
> +        s->total_produced += produced;
> +    }
> +
> +    if (consumed) {
> +        s->input.current_offset += consumed;
> +    }
> +
> +    if (ret == Z_STREAM_END) {
> +        s->stream_end = true;
> +        if (s->total_produced != output_size) {
> +            return false;
> +        }
> +    }
> +
> +    return true;
> +}
> +

The current implementation calls a universal DEFLATE decoder, which natively 
supports three BType formats: 00, 01, and 10.
Based on the K230 technical manual's semantics, the current settings support 
the Dynamic Huffman format. 
I believe we need to add a BType==10 validation.

> [ ... skip 109 lines ... ]
> +    if (!(s->gzip_src_size & K230_DECOMP_GZIP_CTRL_EN) ||
> +        input_size == 0 || s->gzip_out_size == 0) {
> +        k230_decomp_gzip_finish(s, false);
> +        return;
> +    }
> +
> +    s->active = true;
> +    k230_decomp_gzip_update_ctrl_en(s);
> +    k230_decomp_gzip_kick(s);
> +}
> +
> +static uint64_t k230_decomp_gzip_read(void *opaque, hwaddr offset,
> +                                      unsigned size)
> +{
> +    K230DecompGzipState *s = opaque;
> +    uint64_t value = 0;
> +
> +    switch (offset) {
> +    case K230_DECOMP_GZIP_DECOMP_START:
> +        value = s->decomp_start;
> +        break;

Bit 0 of this register, decomp_start, is write-only. I believe the semantics 
here are inconsistent with the manual.

> [ ... skip 124 lines ... ]
> +
> +    memory_region_init_io(&s->iomem, OBJECT(dev), &k230_decomp_gzip_ops, s,
> +                          TYPE_K230_DECOMP_GZIP,
> +                          K230_DECOMP_GZIP_MMIO_SIZE);
> +    sysbus_init_mmio(sbd, &s->iomem);
> +    qdev_init_gpio_in(dev, k230_decomp_gzip_handle_ack,
> +                      K230_DECOMP_GZIP_NUM_GPIOS_IN);
> +    qdev_init_gpio_out(dev, s->signal_out,
> +                       K230_DECOMP_GZIP_NUM_GPIOS_OUT);
> +}
> +
> +static const Property k230_decomp_gzip_properties[] = {
> +    DEFINE_PROP_UINT64("sram-base", K230DecompGzipState, sram_base, 0),
> +};
> +
> +static void k230_decomp_gzip_class_init(ObjectClass *oc, const void *data)
> +{
> +    DeviceClass *dc = DEVICE_CLASS(oc);
> +
> +    dc->realize = k230_decomp_gzip_realize;
> +    device_class_set_legacy_reset(dc, k230_decomp_gzip_reset);

This interface has been deprecated; please refer to qdev.h for further details. 
This issue is similar to patch 1/7 (actually, it's identical).

-- 
Junze Cao <[email protected]>


Reply via email to