From: Bibo Mao Date: Wed, 7 May 2025 02:31:43 +0000 (+0800) Subject: hw/intc/loongarch_pch: Use generic write callback for iomem32_high region X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2618d65036d4c05771727784ec665132689e2608;p=thirdparty%2Fqemu.git hw/intc/loongarch_pch: Use generic write callback for iomem32_high region Add iomem32_high region register write operation emulation in generic write function loongarch_pch_pic_write(), and use this function for iomem32_high region. Signed-off-by: Bibo Mao Reviewed-by: Song Gao Message-Id: <20250507023148.1877287-12-maobibo@loongson.cn> Signed-off-by: Song Gao --- diff --git a/hw/intc/loongarch_pch_pic.c b/hw/intc/loongarch_pch_pic.c index 07f9b07b09..50bcc23d7d 100644 --- a/hw/intc/loongarch_pch_pic.c +++ b/hw/intc/loongarch_pch_pic.c @@ -158,6 +158,9 @@ static void pch_pic_write(void *opaque, hwaddr addr, uint64_t value, case PCH_PIC_AUTO_CTRL1: /* Discard auto_ctrl access */ break; + case PCH_PIC_INT_POL: + s->int_polarity = (s->int_polarity & ~mask) | data; + break; default: qemu_log_mask(LOG_GUEST_ERROR, "pch_pic_write: Bad address 0x%"PRIx64"\n", addr); @@ -226,14 +229,6 @@ static uint64_t loongarch_pch_pic_low_readw(void *opaque, hwaddr addr, return val; } -static uint64_t get_writew_val(uint64_t value, uint32_t target, bool hi) -{ - uint64_t mask = 0xffffffff00000000; - uint64_t data = target; - - return hi ? (value & ~mask) | (data << 32) : (value & mask) | data; -} - static void loongarch_pch_pic_low_writew(void *opaque, hwaddr addr, uint64_t value, unsigned size) { @@ -255,22 +250,9 @@ static uint64_t loongarch_pch_pic_high_readw(void *opaque, hwaddr addr, static void loongarch_pch_pic_high_writew(void *opaque, hwaddr addr, uint64_t value, unsigned size) { - LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(opaque); - uint32_t data = (uint32_t)value; - addr += PCH_PIC_INT_STATUS; - trace_loongarch_pch_pic_high_writew(size, addr, data); - - switch (addr) { - case PCH_PIC_INT_POL: - s->int_polarity = get_writew_val(s->int_polarity, data, 0); - break; - case PCH_PIC_INT_POL + 4: - s->int_polarity = get_writew_val(s->int_polarity, data, 1); - break; - default: - break; - } + trace_loongarch_pch_pic_high_writew(size, addr, value); + loongarch_pch_pic_write(opaque, addr, value, size); } static uint64_t loongarch_pch_pic_readb(void *opaque, hwaddr addr,