[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 11/17] hw/intc/loongarch_pch: Use generic write callback for iomem
From: |
Song Gao |
Subject: |
[PULL 11/17] hw/intc/loongarch_pch: Use generic write callback for iomem32_high region |
Date: |
Wed, 14 May 2025 15:39:21 +0800 |
From: Bibo Mao <maobibo@loongson.cn>
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 <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
Message-Id: <20250507023148.1877287-12-maobibo@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
---
hw/intc/loongarch_pch_pic.c | 28 +++++-----------------------
1 file changed, 5 insertions(+), 23 deletions(-)
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,
--
2.34.1
- [PULL 03/17] hw/intc/loongarch_pch: Remove some duplicate macro, (continued)
- [PULL 03/17] hw/intc/loongarch_pch: Remove some duplicate macro, Song Gao, 2025/05/14
- [PULL 02/17] hw/intc/loongarch_pch: Modify register name PCH_PIC_xxx_OFFSET with PCH_PIC_xxx, Song Gao, 2025/05/14
- [PULL 04/17] hw/intc/loongarch_pch: Set version information at initial stage, Song Gao, 2025/05/14
- [PULL 01/17] hw/intc/loongarch_pch: Modify name of some registers, Song Gao, 2025/05/14
- [PULL 05/17] hw/intc/loongarch_pch: Use relative address in MemoryRegionOps, Song Gao, 2025/05/14
- [PULL 07/17] hw/intc/loongarch_pch: Use generic read callback for iomem32_low region, Song Gao, 2025/05/14
- [PULL 06/17] hw/intc/loongarch_pch: Discard write operation with ISR register, Song Gao, 2025/05/14
- [PULL 08/17] hw/intc/loongarch_pch: Use generic read callback for iomem32_high region, Song Gao, 2025/05/14
- [PULL 09/17] hw/intc/loongarch_pch: Use generic read callback for iomem8 region, Song Gao, 2025/05/14
- [PULL 10/17] hw/intc/loongarch_pch: Use generic write callback for iomem32_low region, Song Gao, 2025/05/14
- [PULL 11/17] hw/intc/loongarch_pch: Use generic write callback for iomem32_high region,
Song Gao <=
- [PULL 12/17] hw/intc/loongarch_pch: Use generic write callback for iomem8 region, Song Gao, 2025/05/14
- [PULL 13/17] hw/intc/loongarch_pch: Use unified trace event for memory region ops, Song Gao, 2025/05/14
- [PULL 14/17] hw/intc/loongarch_pch: Rename memory region iomem32_low with iomem, Song Gao, 2025/05/14
- [PULL 15/17] hw/intc/loongarch_pch: Set flexible memory access size with iomem region, Song Gao, 2025/05/14
- Re: [PULL 00/17] loongarch-to-apply queue, Stefan Hajnoczi, 2025/05/14