mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 16:53:55 -06:00
hw/intc/loongarch_pch: Use generic read callback for iomem32_low region
For memory region iomem32_low, generic read callback is used. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Song Gao <gaosong@loongson.cn> Message-Id: <20250507023148.1877287-8-maobibo@loongson.cn> Signed-off-by: Song Gao <gaosong@loongson.cn>
This commit is contained in:
parent
53339a8120
commit
9e29bf4e4c
1 changed files with 47 additions and 20 deletions
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "qemu/bitops.h"
|
#include "qemu/bitops.h"
|
||||||
|
#include "qemu/log.h"
|
||||||
#include "hw/irq.h"
|
#include "hw/irq.h"
|
||||||
#include "hw/intc/loongarch_pch_pic.h"
|
#include "hw/intc/loongarch_pch_pic.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
@ -71,47 +72,73 @@ static void pch_pic_irq_handler(void *opaque, int irq, int level)
|
||||||
pch_pic_update_irq(s, mask, level);
|
pch_pic_update_irq(s, mask, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t loongarch_pch_pic_low_readw(void *opaque, hwaddr addr,
|
static uint64_t pch_pic_read(void *opaque, hwaddr addr, uint64_t field_mask)
|
||||||
unsigned size)
|
|
||||||
{
|
{
|
||||||
LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(opaque);
|
LoongArchPICCommonState *s = LOONGARCH_PIC_COMMON(opaque);
|
||||||
uint64_t val = 0;
|
uint64_t val = 0;
|
||||||
|
uint32_t offset;
|
||||||
|
|
||||||
|
offset = addr & 7;
|
||||||
|
addr -= offset;
|
||||||
switch (addr) {
|
switch (addr) {
|
||||||
case PCH_PIC_INT_ID:
|
case PCH_PIC_INT_ID:
|
||||||
val = s->id.data & UINT_MAX;
|
val = s->id.data;
|
||||||
break;
|
|
||||||
case PCH_PIC_INT_ID + 4:
|
|
||||||
val = s->id.data >> 32;
|
|
||||||
break;
|
break;
|
||||||
case PCH_PIC_INT_MASK:
|
case PCH_PIC_INT_MASK:
|
||||||
val = (uint32_t)s->int_mask;
|
val = s->int_mask;
|
||||||
break;
|
|
||||||
case PCH_PIC_INT_MASK + 4:
|
|
||||||
val = s->int_mask >> 32;
|
|
||||||
break;
|
break;
|
||||||
case PCH_PIC_INT_EDGE:
|
case PCH_PIC_INT_EDGE:
|
||||||
val = (uint32_t)s->intedge;
|
val = s->intedge;
|
||||||
break;
|
|
||||||
case PCH_PIC_INT_EDGE + 4:
|
|
||||||
val = s->intedge >> 32;
|
|
||||||
break;
|
break;
|
||||||
case PCH_PIC_HTMSI_EN:
|
case PCH_PIC_HTMSI_EN:
|
||||||
val = (uint32_t)s->htmsi_en;
|
val = s->htmsi_en;
|
||||||
break;
|
|
||||||
case PCH_PIC_HTMSI_EN + 4:
|
|
||||||
val = s->htmsi_en >> 32;
|
|
||||||
break;
|
break;
|
||||||
case PCH_PIC_AUTO_CTRL0:
|
case PCH_PIC_AUTO_CTRL0:
|
||||||
case PCH_PIC_AUTO_CTRL0 + 4:
|
|
||||||
case PCH_PIC_AUTO_CTRL1:
|
case PCH_PIC_AUTO_CTRL1:
|
||||||
case PCH_PIC_AUTO_CTRL1 + 4:
|
|
||||||
/* PCH PIC connect to EXTIOI always, discard auto_ctrl access */
|
/* PCH PIC connect to EXTIOI always, discard auto_ctrl access */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
qemu_log_mask(LOG_GUEST_ERROR,
|
||||||
|
"pch_pic_read: Bad address 0x%"PRIx64"\n", addr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (val >> (offset * 8)) & field_mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint64_t loongarch_pch_pic_read(void *opaque, hwaddr addr,
|
||||||
|
unsigned size)
|
||||||
|
{
|
||||||
|
uint64_t val = 0;
|
||||||
|
|
||||||
|
switch (size) {
|
||||||
|
case 1:
|
||||||
|
val = pch_pic_read(opaque, addr, UCHAR_MAX);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
val = pch_pic_read(opaque, addr, USHRT_MAX);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
val = pch_pic_read(opaque, addr, UINT_MAX);
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
val = pch_pic_read(opaque, addr, UINT64_MAX);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
qemu_log_mask(LOG_GUEST_ERROR,
|
||||||
|
"loongarch_pch_pic_read: Bad size %d\n", size);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint64_t loongarch_pch_pic_low_readw(void *opaque, hwaddr addr,
|
||||||
|
unsigned size)
|
||||||
|
{
|
||||||
|
uint64_t val;
|
||||||
|
|
||||||
|
val = loongarch_pch_pic_read(opaque, addr, size);
|
||||||
trace_loongarch_pch_pic_low_readw(size, addr, val);
|
trace_loongarch_pch_pic_low_readw(size, addr, val);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue