[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v6 15/29] hw/loongarch: Add LoongArch cpu interrupt support(C
From: |
Xiaojuan Yang |
Subject: |
[RFC PATCH v6 15/29] hw/loongarch: Add LoongArch cpu interrupt support(CPUINTC) |
Date: |
Fri, 25 Feb 2022 03:02:54 -0500 |
Loongson-3A5000 support 14 interrupts from 64 - 77(Timer->75 IPI->76)
Loongson-3A5000 and ls7a form a legacy model and extended model irq
hierarchy.Tcg mode emulate a simplified extended model which
has no Legacy I/O Interrupt Controller(LIOINTC) and LPC.
e.g:
| +-----+ +---------+ +-------+ |
| | IPI |--> | CPUINTC | <-- | Timer | |
| +-----+ +---------+ +-------+ |
| ^ |
| | |
| +---------+
| | EIOINTC |
| +---------+
| ^ ^ |
| | | |
| +---------+ +---------+ |
| | PCH-PIC | | PCH-MSI | |
| +---------+ +---------+ |
| ^ ^ ^ |
| | | | |
| +---------+ +---------+ +---------+ |
| | UARTs | | Devices | | Devices | |
| +---------+ +---------+ +---------+ |
| ^ |
The following series patch will realize the interrupt
controller in this model.
More detailed info can be found at the kernel doc or manual
1.https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/
linux-loongson.git/tree/Documentation/loongarch?h=loongarch-next
2.https://github.com/loongson/LoongArch-Documentation
Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
---
hw/loongarch/loongson3.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/hw/loongarch/loongson3.c b/hw/loongarch/loongson3.c
index 1cb7bf057c..7b4e77a6a6 100644
--- a/hw/loongarch/loongson3.c
+++ b/hw/loongarch/loongson3.c
@@ -19,6 +19,29 @@
#include "target/loongarch/cpu.h"
+static void loongarch_cpu_set_irq(void *opaque, int irq, int level)
+{
+ LoongArchCPU *cpu = opaque;
+ CPULoongArchState *env = &cpu->env;
+ CPUState *cs = CPU(cpu);
+
+ if (irq < 0 || irq > N_IRQS) {
+ return;
+ }
+
+ if (level) {
+ env->CSR_ESTAT |= 1 << irq;
+ } else {
+ env->CSR_ESTAT &= ~(1 << irq);
+ }
+
+ if (FIELD_EX64(env->CSR_ESTAT, CSR_ESTAT, IS)) {
+ cpu_interrupt(cs, CPU_INTERRUPT_HARD);
+ } else {
+ cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD);
+ }
+}
+
static void loongarch_cpu_reset(void *opaque)
{
LoongArchCPU *cpu = opaque;
@@ -69,6 +92,8 @@ static void loongarch_cpu_init(LoongArchCPU *la_cpu, int
cpu_num)
CPULoongArchState *env;
env = &la_cpu->env;
+ qdev_init_gpio_in(DEVICE(la_cpu), loongarch_cpu_set_irq, N_IRQS);
+
memory_region_init_io(&env->system_iocsr, OBJECT(la_cpu), NULL,
env, "iocsr", UINT64_MAX);
address_space_init(&env->address_space_iocsr, &env->system_iocsr, "IOCSR");
--
2.27.0
- [RFC PATCH v6 00/29] Add LoongArch softmmu support, (continued)
- [RFC PATCH v6 00/29] Add LoongArch softmmu support, Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 02/29] target/loongarch: Add CSRs definition, Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 11/29] target/loongarch: Add LoongArch interrupt and exception handle, Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 09/29] target/loongarch: Add TLB instruction support, Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 18/29] hw/intc: Add LoongArch ls7a msi interrupt controller support(PCH-MSI), Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 23/29] hw/loongarch: Add LoongArch ls7a rtc device support, Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 01/29] target/loongarch: Add system emulation introduction, Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 03/29] target/loongarch: Add basic vmstate description of CPU., Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 13/29] target/loongarch: Add gdb support., Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 22/29] hw/loongarch: Add some devices support for 3A5000., Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 15/29] hw/loongarch: Add LoongArch cpu interrupt support(CPUINTC),
Xiaojuan Yang <=
- [RFC PATCH v6 29/29] tests/tcg/loongarch64: Add hello/memory test in loongarch64 system, Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 12/29] target/loongarch: Add timer related instructions support., Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 28/29] hw/loongarch: Add fdt support., Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 16/29] hw/loongarch: Add LoongArch ipi interrupt support(IPI), Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 10/29] target/loongarch: Add other core instructions support, Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 26/29] hw/loongarch: Add LoongArch smbios support, Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 08/29] target/loongarch: Add LoongArch IOCSR instruction, Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 04/29] target/loongarch: Implement qmp_query_cpu_definitions(), Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 21/29] Enable common virtio pci support for LoongArch, Xiaojuan Yang, 2022/02/25
- [RFC PATCH v6 05/29] target/loongarch: Add constant timer support, Xiaojuan Yang, 2022/02/25